diff --git a/dist/aurelia.esm.js b/dist/aurelia.esm.js index eb07447..c37c18e 100644 --- a/dist/aurelia.esm.js +++ b/dist/aurelia.esm.js @@ -15297,6 +15297,78 @@ let ConsoleAppender = class ConsoleAppender { } }; +/** + * Bootstrap a new Aurelia instance and start an application + * @param {QuickStartOptions} options + * @returns {Aurelia} the running Aurelia instance + */ +const createAndStart = (options = {}) => { + const aurelia = new Aurelia(); + const use = aurelia.use; + use.standardConfiguration(); + if (options.debug) { + use.developmentLogging(); + } + if (Array.isArray(options.plugins)) { + options.plugins.forEach((plgCfg) => { + if (Array.isArray(plgCfg)) { + use.plugin(plgCfg[0], plgCfg[1]); + } else { + use.plugin(plgCfg); + } + }); + } + if (Array.isArray(options.resources)) { + use.globalResources(options.resources); + } + return aurelia.start(); +}; + +/** + * Bootstrap a new Aurelia instance and start an application + * @param {QuickStartOptions} options + * @returns {Aurelia} the running Aurelia instance + */ +async function start(options = {}) { + const aurelia = await createAndStart(options); + await aurelia.setRoot(options.root || 'app.js', options.host || document.body); + return aurelia; +} + +/** + * Bootstrap a new Aurelia instance and start an application by enhancing a DOM tree + * @param {QuickEnhanceOptions} options Configuration for enhancing a DOM tree + * @returns {View} the enhanced View by selected options + */ +async function enhance(options = {}) { + const aurelia = await createAndStart(options); + if (typeof options.root === 'function') { + options.root = aurelia.container.get(options.root); + } + return aurelia.enhance(options.root || {}, options.host || document.body); +} + +/** @typed ConfigureFn + * @param {FrameworkConfiguration} frameWorkConfig + * @param {any} plugigConfig + */ + +/** @typedef QuickStartOptions + * @property {string | Function} [root] application root. Either string or a class, which will be instantiated with DI + * @property {string | Element} [host] application host, element or a string, which will be used to query the element + * @property {Array} [resources] global resources for the application + * @property {Array any} | [(fwCfg: FrameworkConfiguration, cfg: {}) => any, {}]>} [plugins] + * @property {boolean} [debug] true to use development console logging + */ + +/** @typedef QuickEnhanceOptions + * @property {{} | Function} [root] binding context for enhancement, can be either object or a class, which will be instantiated with DI + * @property {string | Element} [host] host node of to be enhanced tree + * @property {Array} [resources] global resources for the application + * @property {Array any} | [(fwCfg: FrameworkConfiguration, cfg: {}) => any, {}]>} [plugins] + * @property {boolean} [debug] true to use development console logging + */ + initialize(); // Using static convention to avoid having to fetch / load module dynamically @@ -15324,11 +15396,11 @@ initialize(); getLogger('aurelia').error(errorMsg); return this; }; - + frameworkCfgProto.router = function() { getLogger('aurelia').error(errorMsg); return this; }; })(FrameworkConfiguration.prototype); -export { EventAggregator, includeEventsIn, If, Else, Repeat, Compose, Show, Hide, Focus, With, Replaceable, AbstractRepeater, ArrayRepeatStrategy, AttrBindingBehavior, BindingSignaler, DebounceBindingBehavior, FromViewBindingBehavior, HTMLSanitizer, MapRepeatStrategy, NullRepeatStrategy, NumberRepeatStrategy, OneTimeBindingBehavior, OneWayBindingBehavior, RepeatStrategyLocator, SanitizeHTMLValueConverter, SelfBindingBehavior, SetRepeatStrategy, SignalBindingBehavior, ThrottleBindingBehavior, ToViewBindingBehavior, TwoWayBindingBehavior, UpdateTriggerBindingBehavior, createFullOverrideContext, updateOneTimeBinding, updateOverrideContext, isOneTime, viewsRequireLifecycle, unwrapExpression, getItemsSourceExpression, Aurelia, FrameworkConfiguration, LogManager, resolver, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, _emptyParameters, InvocationHandler, Container, autoinject, inject, targetContext, sourceContext, camelCase, createOverrideContext, getContextFor, createScopeForTest, connectable, enqueueBindingConnect, setConnectQueueThreshold, enableConnectQueue, disableConnectQueue, getConnectQueueSize, subscriberCollection, ExpressionObserver, calcSplices, mergeSplice, projectArraySplices, getChangeRecords, ModifyCollectionObserver, CollectionLengthObserver, getArrayObserver, Expression, BindingBehavior, ValueConverter, Assign, Conditional, AccessThis, AccessScope, AccessMember, AccessKeyed, CallScope, CallMember, CallFunction, Binary, Unary, LiteralPrimitive, LiteralString, LiteralTemplate, LiteralArray, LiteralObject, Unparser, ExpressionCloner, cloneExpression, bindingMode, Parser, ParserImplementation, getMapObserver, delegationStrategy, EventManager, EventSubscriber, DirtyChecker, DirtyCheckProperty, propertyAccessor, PrimitiveObserver, SetterObserver, XLinkAttributeObserver, dataAttributeAccessor, DataAttributeObserver, StyleObserver, ValueAttributeObserver, CheckedObserver, SelectValueObserver, ClassObserver, hasDeclaredDependencies, declarePropertyDependencies, computedFrom, ComputedExpression, createComputedObserver, elements, presentationElements, presentationAttributes, SVGAnalyzer, ObserverLocator, ObjectObservationAdapter, BindingExpression, Binding, CallExpression, Call, ValueConverterResource, valueConverter, BindingBehaviorResource, bindingBehavior, ListenerExpression, Listener, NameExpression, BindingEngine, getSetObserver, observable, connectBindingToSignal, signalBindings, metadata, Origin, decorators, deprecated, mixin, protocol, animationEvent, Animator, CompositionTransactionNotifier, CompositionTransactionOwnershipToken, CompositionTransaction, _hyphenate, _isAllWhitespace, ViewEngineHooksResource, viewEngineHooks, ElementEvents, ResourceLoadContext, ViewCompileInstruction, BehaviorInstruction, TargetInstruction, viewStrategy, RelativeViewStrategy, ConventionalViewStrategy, NoViewStrategy, TemplateRegistryViewStrategy, InlineViewStrategy, StaticViewStrategy, ViewLocator, BindingLanguage, SlotCustomAttribute, PassThroughSlot, ShadowSlot, ShadowDOM, validateBehaviorName, ViewResources, View, ViewSlot, BoundViewFactory, ViewFactory, ViewCompiler, ResourceModule, ResourceDescription, ModuleAnalyzer, ViewEngine, Controller, BehaviorPropertyObserver, BindableProperty, HtmlBehaviorResource, children, child, SwapStrategies, CompositionEngine, ElementConfigResource, resource, behavior, customElement, customAttribute, templateController, bindable, dynamicOptions, useShadowDOM, processAttributes, processContent, containerless, useViewStrategy, useView, inlineView, noView, view, elementConfig, viewResources, TemplatingEngine, TemplateDependency, TemplateRegistryEntry, Loader, TaskQueue, relativeToFile, join, buildQueryString, parseQueryString, AggregateError, FEATURE, PLATFORM, DOM, isInitialized, initializePAL, reset }; +export { start, enhance, EventAggregator, includeEventsIn, If, Else, Repeat, Compose, Show, Hide, Focus, With, Replaceable, AbstractRepeater, ArrayRepeatStrategy, AttrBindingBehavior, BindingSignaler, DebounceBindingBehavior, FromViewBindingBehavior, HTMLSanitizer, MapRepeatStrategy, NullRepeatStrategy, NumberRepeatStrategy, OneTimeBindingBehavior, OneWayBindingBehavior, RepeatStrategyLocator, SanitizeHTMLValueConverter, SelfBindingBehavior, SetRepeatStrategy, SignalBindingBehavior, ThrottleBindingBehavior, ToViewBindingBehavior, TwoWayBindingBehavior, UpdateTriggerBindingBehavior, createFullOverrideContext, updateOneTimeBinding, updateOverrideContext, isOneTime, viewsRequireLifecycle, unwrapExpression, getItemsSourceExpression, Aurelia, FrameworkConfiguration, LogManager, resolver, StrategyResolver, Lazy, All, Optional, Parent, Factory, NewInstance, getDecoratorDependencies, lazy, all, optional, parent, factory, newInstance, invoker, invokeAsFactory, FactoryInvoker, registration, transient, singleton, TransientRegistration, SingletonRegistration, _emptyParameters, InvocationHandler, Container, autoinject, inject, targetContext, sourceContext, camelCase, createOverrideContext, getContextFor, createScopeForTest, connectable, enqueueBindingConnect, setConnectQueueThreshold, enableConnectQueue, disableConnectQueue, getConnectQueueSize, subscriberCollection, ExpressionObserver, calcSplices, mergeSplice, projectArraySplices, getChangeRecords, ModifyCollectionObserver, CollectionLengthObserver, getArrayObserver, Expression, BindingBehavior, ValueConverter, Assign, Conditional, AccessThis, AccessScope, AccessMember, AccessKeyed, CallScope, CallMember, CallFunction, Binary, Unary, LiteralPrimitive, LiteralString, LiteralTemplate, LiteralArray, LiteralObject, Unparser, ExpressionCloner, cloneExpression, bindingMode, Parser, ParserImplementation, getMapObserver, delegationStrategy, EventManager, EventSubscriber, DirtyChecker, DirtyCheckProperty, propertyAccessor, PrimitiveObserver, SetterObserver, XLinkAttributeObserver, dataAttributeAccessor, DataAttributeObserver, StyleObserver, ValueAttributeObserver, CheckedObserver, SelectValueObserver, ClassObserver, hasDeclaredDependencies, declarePropertyDependencies, computedFrom, ComputedExpression, createComputedObserver, elements, presentationElements, presentationAttributes, SVGAnalyzer, ObserverLocator, ObjectObservationAdapter, BindingExpression, Binding, CallExpression, Call, ValueConverterResource, valueConverter, BindingBehaviorResource, bindingBehavior, ListenerExpression, Listener, NameExpression, BindingEngine, getSetObserver, observable, connectBindingToSignal, signalBindings, metadata, Origin, decorators, deprecated, mixin, protocol, animationEvent, Animator, CompositionTransactionNotifier, CompositionTransactionOwnershipToken, CompositionTransaction, _hyphenate, _isAllWhitespace, ViewEngineHooksResource, viewEngineHooks, ElementEvents, ResourceLoadContext, ViewCompileInstruction, BehaviorInstruction, TargetInstruction, viewStrategy, RelativeViewStrategy, ConventionalViewStrategy, NoViewStrategy, TemplateRegistryViewStrategy, InlineViewStrategy, StaticViewStrategy, ViewLocator, BindingLanguage, SlotCustomAttribute, PassThroughSlot, ShadowSlot, ShadowDOM, validateBehaviorName, ViewResources, View, ViewSlot, BoundViewFactory, ViewFactory, ViewCompiler, ResourceModule, ResourceDescription, ModuleAnalyzer, ViewEngine, Controller, BehaviorPropertyObserver, BindableProperty, HtmlBehaviorResource, children, child, SwapStrategies, CompositionEngine, ElementConfigResource, resource, behavior, customElement, customAttribute, templateController, bindable, dynamicOptions, useShadowDOM, processAttributes, processContent, containerless, useViewStrategy, useView, inlineView, noView, view, elementConfig, viewResources, TemplatingEngine, TemplateDependency, TemplateRegistryEntry, Loader, TaskQueue, relativeToFile, join, buildQueryString, parseQueryString, AggregateError, FEATURE, PLATFORM, DOM, isInitialized, initializePAL, reset }; diff --git a/dist/aurelia.esm.min.js b/dist/aurelia.esm.min.js index cc6d59f..2419bc4 100644 --- a/dist/aurelia.esm.min.js +++ b/dist/aurelia.esm.min.js @@ -1 +1 @@ -function AggregateError(e,t,i){if(t){if(t.innerError&&i)return t;const r="\n------------------------------------------------\n";e+=`${r}Inner Error:\n`,"string"==typeof t?e+=`Message: ${t}`:(t.message?e+=`Message: ${t.message}`:e+=`Unknown Inner Error Type. Displaying Inner Error as JSON:\n ${JSON.stringify(t,null," ")}`,t.stack&&(e+=`\nInner Error Stack:\n${t.stack}`,e+="\nEnd Inner Error Stack")),e+=r}let r=new Error(e);return t&&(r.innerError=t),r}const FEATURE={},PLATFORM={noop(){},eachModule(){},moduleName:e=>e};PLATFORM.global="undefined"!=typeof self?self:"undefined"!=typeof global?global:new Function("return this")();const DOM={};let isInitialized=!1;function initializePAL(e){isInitialized||(isInitialized=!0,"function"!=typeof Object.getPropertyDescriptor&&(Object.getPropertyDescriptor=function(e,t){let i=Object.getOwnPropertyDescriptor(e,t),r=Object.getPrototypeOf(e);for(;void 0===i&&null!==r;)i=Object.getOwnPropertyDescriptor(r,t),r=Object.getPrototypeOf(r);return i}),e(PLATFORM,FEATURE,DOM))}function reset(){isInitialized=!1}String.prototype.endsWith&&!function(){try{return!"ab".endsWith("a",1)}catch(e){return!0}}()||(String.prototype.endsWith=function(e,t){let i=this.toString();("number"!=typeof t||!isFinite(t)||Math.floor(t)!==t||t>i.length)&&(t=i.length),t-=e.length;let r=i.indexOf(e,t);return-1!==r&&r===t}),String.prototype.startsWith&&!function(){try{return!"ab".startsWith("b",1)}catch(e){return!0}}()||(String.prototype.startsWith=function(e,t){return t=t||0,this.substr(t,e.length)===e});{const e=Object.freeze({}),t="__metadata__";"function"!=typeof Reflect.getOwnMetadata&&(Reflect.getOwnMetadata=function(i,r,n){if(r.hasOwnProperty(t))return(r[t][n]||e)[i]}),"function"!=typeof Reflect.defineMetadata&&(Reflect.defineMetadata=function(e,i,r,n){let s=r.hasOwnProperty(t)?r[t]:r[t]={};(s[n]||(s[n]={}))[e]=i}),"function"!=typeof Reflect.metadata&&(Reflect.metadata=function(e,t){return function(i,r){Reflect.defineMetadata(e,t,i,r)}})}const _PLATFORM={location:window.location,history:window.history,addEventListener(e,t,i){this.global.addEventListener(e,t,i)},removeEventListener(e,t,i){this.global.removeEventListener(e,t,i)},performance:window.performance,requestAnimationFrame(e){return this.global.requestAnimationFrame(e)}};if(Element&&!Element.prototype.matches){let e=Element.prototype;e.matches=e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}const _FEATURE={shadowDOM:!!HTMLElement.prototype.attachShadow,scopedCSS:"scoped"in document.createElement("style"),htmlTemplateElement:function(){let e=document.createElement("div");return e.innerHTML="","content"in e.children[0]}(),mutationObserver:!(!window.MutationObserver&&!window.WebKitMutationObserver),ensureHTMLTemplateElement:e=>e};let shadowPoly=window.ShadowDOMPolyfill||null;const _DOM={Element,NodeList,SVGElement,boundary:"aurelia-dom-boundary",addEventListener(e,t,i){document.addEventListener(e,t,i)},removeEventListener(e,t,i){document.removeEventListener(e,t,i)},adoptNode:e=>document.adoptNode(e),createAttribute:e=>document.createAttribute(e),createElement:e=>document.createElement(e),createTextNode:e=>document.createTextNode(e),createComment:e=>document.createComment(e),createDocumentFragment:()=>document.createDocumentFragment(),createTemplateElement(){let e=document.createElement("template");return _FEATURE.ensureHTMLTemplateElement(e)},createMutationObserver:e=>new(window.MutationObserver||window.WebKitMutationObserver)(e),createCustomEvent:(e,t)=>new window.CustomEvent(e,t),dispatchEvent(e){document.dispatchEvent(e)},getComputedStyle:e=>window.getComputedStyle(e),getElementById:e=>document.getElementById(e),querySelector:e=>document.querySelector(e),querySelectorAll:e=>document.querySelectorAll(e),nextElementSibling(e){if(e.nextElementSibling)return e.nextElementSibling;do{e=e.nextSibling}while(e&&1!==e.nodeType);return e},createTemplateFromMarkup(e){let t=document.createElement("div");t.innerHTML=e;let i=t.firstElementChild;if(!i||"TEMPLATE"!==i.nodeName)throw new Error("Template markup must be wrapped in a