How to use the @aurelia/kernel.DI function in @aurelia/kernel

To help you get started, we’ve selected a few @aurelia/kernel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / runtime / dist / umd / lifecycle.js View on Github external
var ViewModelKind;
    (function (ViewModelKind) {
        ViewModelKind[ViewModelKind["customElement"] = 0] = "customElement";
        ViewModelKind[ViewModelKind["customAttribute"] = 1] = "customAttribute";
        ViewModelKind[ViewModelKind["synthetic"] = 2] = "synthetic";
    })(ViewModelKind = exports.ViewModelKind || (exports.ViewModelKind = {}));
    exports.IController = kernel_1.DI.createInterface('IController').noDefault();
    /**
     * Describing characteristics of a mounting operation a controller will perform
     */
    var MountStrategy;
    (function (MountStrategy) {
        MountStrategy[MountStrategy["insertBefore"] = 1] = "insertBefore";
        MountStrategy[MountStrategy["append"] = 2] = "append";
    })(MountStrategy = exports.MountStrategy || (exports.MountStrategy = {}));
    exports.IViewFactory = kernel_1.DI.createInterface('IViewFactory').noDefault();
    exports.ILifecycle = kernel_1.DI.createInterface('ILifecycle').withDefault(x => x.singleton(Lifecycle));
    let BoundQueue = class BoundQueue {
        constructor(lifecycle) {
            this.lifecycle = lifecycle;
            this.depth = 0;
            this.head = void 0;
            this.tail = void 0;
        }
        begin() {
            ++this.depth;
        }
        end(flags) {
            if (flags === void 0) {
                flags = 0 /* none */;
            }
            if (--this.depth === 0) {
github aurelia / aurelia / packages / jit-html / dist / umd / template-element-factory.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const tslib_1 = require("tslib");
    const kernel_1 = require("@aurelia/kernel");
    const runtime_1 = require("@aurelia/runtime");
    // For some reason rollup complains about `DI.createInterface().noDefault()` with this message:
    // "semantic error TS2742 The inferred type of 'ITemplateElementFactory' cannot be named without a reference to '@aurelia/jit/node_modules/@aurelia/kernel'. This is likely not portable. A type annotation is necessary"
    // So.. investigate why that happens (or rather, why it *only* happens here and not for the other 50)
    exports.ITemplateElementFactory = kernel_1.DI.createInterface('ITemplateElementFactory').noDefault();
    const markupCache = {};
    /**
     * Default implementation for `ITemplateFactory` for use in an HTML based runtime.
     *
     * @internal
     */
    let HTMLTemplateElementFactory = class HTMLTemplateElementFactory {
        constructor(dom) {
            this.dom = dom;
            this.template = dom.createTemplate();
        }
        static register(container) {
            return kernel_1.Registration.singleton(exports.ITemplateElementFactory, this).register(container);
        }
        createTemplate(input) {
            if (typeof input === 'string') {
github aurelia / aurelia / packages / aurelia / dist / umd / index.js View on Github external
// OneTimeBindingCommand,
    // ToViewBindingCommand,
    // TwoWayBindingCommand,
    // IExpressionParserRegistration,
    // DefaultComponents as JitDefaultComponents,
    // RefAttributePatternRegistration,
    // DotSeparatedAttributePatternRegistration,
    // DefaultBindingSyntax,
    // AtPrefixedTriggerAttributePatternRegistration,
    // ColonPrefixedBindAttributePatternRegistration,
    exports.ShortHandBindingSyntax = jit_1.ShortHandBindingSyntax;
    var jit_html_browser_1 = require("@aurelia/jit-html-browser");
    exports.JitHtmlBrowserConfiguration = jit_html_browser_1.JitHtmlBrowserConfiguration;
    var kernel_1 = require("@aurelia/kernel");
    exports.all = kernel_1.all;
    exports.DI = kernel_1.DI;
    exports.IContainer = kernel_1.IContainer;
    // IDefaultableInterfaceSymbol,
    // IFactory,
    exports.inject = kernel_1.inject;
    exports.IServiceLocator = kernel_1.IServiceLocator;
    exports.lazy = kernel_1.lazy;
    exports.optional = kernel_1.optional;
    // RegisterSelf,
    exports.Registration = kernel_1.Registration;
    // ResolveCallback,
    exports.singleton = kernel_1.singleton;
    exports.transient = kernel_1.transient;
    // Injectable,
    // InterfaceSymbol,
    exports.InstanceProvider = kernel_1.InstanceProvider;
    // IPerformance,
github aurelia / aurelia / packages / runtime / dist / umd / rendering-engine.js View on Github external
})(function (require, exports) {
    "use strict";
    var ChildrenObserver_1;
    Object.defineProperty(exports, "__esModule", { value: true });
    const tslib_1 = require("tslib");
    const kernel_1 = require("@aurelia/kernel");
    const lifecycle_1 = require("./lifecycle");
    const subscriber_collection_1 = require("./observation/subscriber-collection");
    const render_context_1 = require("./render-context");
    const custom_element_1 = require("./resources/custom-element");
    const controller_1 = require("./templating/controller");
    const view_1 = require("./templating/view");
    exports.ITemplateCompiler = kernel_1.DI.createInterface('ITemplateCompiler').noDefault();
    var ViewCompileFlags;
    (function (ViewCompileFlags) {
        ViewCompileFlags[ViewCompileFlags["none"] = 1] = "none";
        ViewCompileFlags[ViewCompileFlags["surrogate"] = 2] = "surrogate";
        ViewCompileFlags[ViewCompileFlags["shadowDOM"] = 4] = "shadowDOM";
    })(ViewCompileFlags = exports.ViewCompileFlags || (exports.ViewCompileFlags = {}));
    exports.ITemplateFactory = kernel_1.DI.createInterface('ITemplateFactory').noDefault();
    // This is the main implementation of ITemplate.
    // It is used to create instances of IController based on a compiled CustomElementDefinition.
    // TemplateDefinitions are hand-coded today, but will ultimately be the output of the
    // TemplateCompiler either through a JIT or AOT process.
    // Essentially, CompiledTemplate wraps up the small bit of code that is needed to take a CustomElementDefinition
    // and create instances of it on demand.
    class CompiledTemplate {
        constructor(dom, definition, factory, renderContext) {
            this.dom = dom;
github aurelia / aurelia / packages / runtime / dist / umd / activator.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const kernel_1 = require("@aurelia/kernel");
    const lifecycle_1 = require("./lifecycle");
    const lifecycle_task_1 = require("./lifecycle-task");
    const controller_1 = require("./templating/controller");
    exports.IActivator = kernel_1.DI.createInterface('IActivator').withDefault(x => x.singleton(Activator));
    /** @internal */
    class Activator {
        constructor(taskManager) {
            this.taskManager = taskManager;
        }
        static register(container) {
            return kernel_1.Registration.singleton(exports.IActivator, this).register(container);
        }
        activate(host, component, container, flags = 1024 /* fromStartTask */, parentScope) {
            flags = flags === void 0 ? 0 /* none */ : flags;
            const mgr = this.taskManager;
            let task = mgr.runBeforeRender();
            if (task.done) {
                this.render(host, component, container, flags);
            }
            else {
github aurelia / aurelia / packages / testing / dist / umd / test-builder.js View on Github external
function createObserverLocator(containerOrLifecycle) {
        let container;
        if (containerOrLifecycle === undefined || !('get' in containerOrLifecycle)) {
            container = kernel_1.DI.createContainer();
            container.register(runtime_1.ILifecycleRegistration);
        }
        else {
            container = containerOrLifecycle;
        }
        const dummyLocator = {
            handles() {
                return false;
            }
        };
        kernel_1.Registration.instance(runtime_1.IDirtyChecker, null).register(container);
        kernel_1.Registration.instance(runtime_1.ITargetObserverLocator, dummyLocator).register(container);
        kernel_1.Registration.instance(runtime_1.ITargetAccessorLocator, dummyLocator).register(container);
        container.register(runtime_1.IObserverLocatorRegistration);
        return container.get(runtime_1.IObserverLocator);
    }
github aurelia / aurelia / packages / runtime-html / dist / umd / styles / shadow-dom-styles.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const kernel_1 = require("@aurelia/kernel");
    exports.noopShadowDOMStyles = Object.freeze({
        applyTo: kernel_1.PLATFORM.noop
    });
    exports.IShadowDOMStyles = kernel_1.DI.createInterface('IShadowDOMStyles').noDefault();
    exports.IShadowDOMGlobalStyles = kernel_1.DI.createInterface('IShadowDOMGlobalStyles')
        .withDefault(x => x.instance(exports.noopShadowDOMStyles));
    class AdoptedStyleSheetsStyles {
        constructor(dom, localStyles, styleSheetCache, sharedStyles = null) {
            this.sharedStyles = sharedStyles;
            this.styleSheets = localStyles.map(x => {
                let sheet;
                if (x instanceof dom.CSSStyleSheet) {
                    sheet = x;
                }
                else {
                    sheet = styleSheetCache.get(x);
                    if (!sheet) {
                        sheet = new dom.CSSStyleSheet();
                        sheet.replaceSync(x);
                        styleSheetCache.set(x, sheet);
                    }
github aurelia / aurelia / packages / i18n / dist / umd / i18next-wrapper.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const kernel_1 = require("@aurelia/kernel");
    const i18next_1 = require("i18next");
    exports.I18nWrapper = kernel_1.DI.createInterface('I18nextWrapper').noDefault();
    /**
     * A wrapper class over i18next to facilitate the easy testing and DI.
     */
    class I18nextWrapper {
        constructor() {
            this.i18next = i18next_1.default;
        }
    }
    exports.I18nextWrapper = I18nextWrapper;
});
//# sourceMappingURL=i18next-wrapper.js.map
github aurelia / aurelia / packages / runtime / dist / umd / observation / dirty-checker.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const tslib_1 = require("tslib");
    const kernel_1 = require("@aurelia/kernel");
    const subscriber_collection_1 = require("./subscriber-collection");
    const scheduler_1 = require("../scheduler");
    exports.IDirtyChecker = kernel_1.DI.createInterface('IDirtyChecker').withDefault(x => x.singleton(DirtyChecker));
    exports.DirtyCheckSettings = {
        /**
         * Default: `6`
         *
         * Adjust the global dirty check frequency.
         * Measures in "frames per check", such that (given an FPS of 60):
         * - A value of 1 will result in 60 dirty checks per second
         * - A value of 6 will result in 10 dirty checks per second
         */
        framesPerCheck: 6,
        /**
         * Default: `false`
         *
         * Disable dirty-checking entirely. Properties that cannot be observed without dirty checking
         * or an adapter, will simply not be observed.
         */
github aurelia / aurelia / packages / runtime / dist / umd / resources / binding-behavior.js View on Github external
constructor(container, Type) {
            this.container = container;
            this.Type = Type;
            this.deps = kernel_1.DI.getDependencies(Type);
        }
        construct(binding, expr) {