How to use the @aurelia/runtime.Aurelia function in @aurelia/runtime

To help you get started, we’ve selected a few @aurelia/runtime 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 / testing / dist / esnext / startup.js View on Github external
export function createFixture(template, $class, registrations = [], autoStart = true, ctx = TestContext.createHTMLTestContext()) {
    const { container, lifecycle, scheduler, observerLocator } = ctx;
    container.register(...registrations);
    const root = ctx.doc.body.appendChild(ctx.doc.createElement('div'));
    const host = root.appendChild(ctx.createElement('app'));
    const au = new Aurelia(container);
    const App = CustomElement.define({ name: 'app', template }, $class || class {
    });
    const component = new App();
    let startPromise = Promise.resolve();
    if (autoStart) {
        au.app({ host: host, component });
        startPromise = au.start().wait();
    }
    return {
        startPromise,
        ctx,
        host: ctx.doc.firstElementChild,
        container,
        lifecycle,
        scheduler,
        testHost: root,
github aurelia / aurelia / packages / __tests__ / 5-jit-html / repeater-if-else.spec.ts View on Github external
},
          class App {
            public items: any[];
            public display: boolean;
            public count: number;
            public afterCompileChildren() {
              this.items = initialItems;
              this.display = false;
              this.count = count;
            }
          }
        );

        const host = ctx.createElement('div');

        const au = new Aurelia(container);
        const task = au.register(TestConfiguration)
          .app({ host, component: Component, strategy })
          .start();
        const component = au.root.controller.bindingContext;
        await task.wait();

        assert.strictEqual(trimFull(host.textContent), elseText.repeat(count), `trimFull(host.textContent) === elseText.repeat(count)`);

        execute(component as any, ctx.scheduler, host, count, ifText, elseText);

        au.stop();
        assert.strictEqual(trimFull(host.textContent), '', `trimFull(host.textContent) === ''`);
      });
    });
github aurelia / aurelia / packages / __tests__ / jit-html / replaceable_with.spec.tsx View on Github external
it(`\n----\n${testTitle}`, async function() {
            const Foo = CustomElement.define(
              { name: 'foo', template: <template>{fooContentTemplate}</template> },
              class Foo { items = fooItems }
            );
            const App = CustomElement.define(
              { name: 'app', template: <template>{appContentTemplate}</template> },
              class App { message = 'Aurelia' }
            );

            const ctx = TestContext.createHTMLTestContext();
            ctx.container.register(Foo);
            const au = new Aurelia(ctx.container);

            const host = ctx.createElement('div');
            const component = new App();

            au.app({ host, component });
            await au.start().wait();

            assert.strictEqual(host.textContent, expectedTextContent, `host.textContent`);
            if (customAssertion) {
              await customAssertion(ctx, host, component, component.$controller.controllers[0] as any as IFoo);
            }
            await tearDown(au);
          });
        }
github aurelia / aurelia / packages / testing / src / setup.ts View on Github external
export function setup(ctx: HTMLTestContext, template: string | Node, $class: Constructable | null, ...registrations: any[]) {
  const { container, lifecycle, observerLocator } = ctx;
  container.register(...registrations);
  const host = ctx.createElement('app');
  const au = new Aurelia(container);
  const App = CustomElementResource.define({ name: 'app', template }, $class);
  const component = new App() as any;

  return { container, lifecycle, host, au, component, observerLocator };
}
github aurelia / aurelia / packages / __tests__ / 3-runtime-html / children-observer.spec.ts View on Github external
const { container } = ctx;

    const HostElement = defineAndRegisterElementWithChildren(container, childrenOptions);
    const ChildOne = defineAndRegisterElement('child-one', container);
    const ChildTwo = defineAndRegisterElement('child-two', container);
    const component = defineAndRegisterHost(
      `
        
          
          
        
      `,
      container
    );

    const au = new Aurelia(container);
    const host = ctx.createElement(CustomElement.getDefinition(component).name);

    au.app({ host, component });
    au.start();

    const hostViewModel = (host as any).$controller.viewModel;
    const viewModel = (host.children[0] as any).$controller.viewModel;

    return {
      au,
      hostViewModel,
      viewModel,
      ChildOne,
      ChildTwo
    };
  }
github aurelia / aurelia / test / wdio / cases / local / jit-aurelia-cli-ts / src / startup.ts View on Github external
import { DebugConfiguration } from '@aurelia/debug';
import { BasicConfiguration } from '@aurelia/jit-html-browser';
import { Aurelia } from '@aurelia/runtime';
import { App } from './app';

window['au'] = new Aurelia()
  .register(BasicConfiguration, DebugConfiguration)
  .app({ host: document.querySelector('app'), component: new App() })
  .start();
github aurelia / aurelia / packages / testing / dist / umd / au-dom.js View on Github external
setup() {
            const container = exports.AuDOMConfiguration.createContainer();
            const au = new runtime_1.Aurelia(container);
            const lifecycle = container.get(runtime_1.ILifecycle);
            const host = AuNode.createHost();
            return { au, container, lifecycle, host };
        },
        createTextDefinition(expression, name = `${expression}-text`) {
github aurelia / aurelia / packages / __tests__ / jit-html / compose.spec.ts View on Github external
function setup(): SpecContext {
    const ctx = TestContext.createHTMLTestContext();
    const { container, dom, lifecycle, observerLocator, renderingEngine: re } = ctx;
    const au = new Aurelia(container);
    const host = dom.createElement('div');

    return { container, dom, au, host, lifecycle, re, observerLocator };
  }
github aurelia / aurelia / packages / examples / fractals / src / startup.ts View on Github external
import { BasicConfiguration } from '@aurelia/jit';
import { Aurelia } from '@aurelia/runtime';
import { App } from './app';
import { IContainer } from '@aurelia/kernel';
import { register } from '@aurelia/plugin-svg';
import { State } from './state';
import { Pythagoras } from './pythagoras';

window['App'] = App;
window['Pythagoras'] = Pythagoras;

let state: State;
const au = window['au'] = new Aurelia()
  .register(
    {
      register(container: IContainer) {
        state = container.get(State);
        register(container);
      }
    },
    BasicConfiguration,
    Pythagoras as any
  )
  .app({ host: document.querySelector('app'), component: new App(state) });
au
  .start();