How to use the @glimmer/util.expect function in @glimmer/util

To help you get started, we’ve selected a few @glimmer/util 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 glimmerjs / glimmer.js / packages / @glimmer / application / src / application.ts View on Github external
protected async _render(): Promise {
    const env = expect(this.env, 'Unexpected missing environment during render');

    // Create the template context for the root `main` template, which just
    // contains the array of component roots. Any property references in that
    // template will be looked up from this object.
    let self = (this._self = new UpdatableReference({ roots: this._roots }));

    // Create an empty root scope.
    let dynamicScope = new DefaultDynamicScope();

    let builder = this.builder.getBuilder(env);

    let templateIterator = await this.loader.getTemplateIterator(
      this,
      env,
      builder,
      dynamicScope,
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / modes / aot / delegate.ts View on Github external
let block = bundleCompiler.preprocess(locator, state.template!);
        let parsedLayout = { block, referrer: locator, asPartial: false };
        let wrapped = new WrappedBuilder(parsedLayout);
        bundleCompiler.addCompilableTemplate(normalizeLocator(locator), wrapped);

        compileTimeModules.register(key, 'other', {
          default: wrapped.symbolTable,
        });

        symbolTable = wrapped.symbolTable;

        this.symbolTables.set(locator, symbolTable);
      } else {
        block = bundleCompiler.addTemplateSource(
          locator,
          expect(state.template, 'expected component definition state to have template')
        );
        symbolTable = {
          hasEval: block.hasEval,
          symbols: block.symbols,
        };

        this.symbolTables.set(locator, symbolTable);

        compileTimeModules.register(key, 'other', {
          default: symbolTable,
        });
      }

      if (state.hasSymbolTable) {
        registry.register(key, 'component', {
          default: {
github glimmerjs / glimmer.js / packages / @glimmer / application / src / application.ts View on Github external
protected async _rerender() {
    const env = expect(this.env, 'Unexpected missing environment during re-render');

    try {
      env.begin();
      await this.renderer.rerender();
      env.commit();

      this._didRender();
    } catch (err) {
      this._didError(err);
    }
  }
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / environment.ts View on Github external
private get transaction(): TransactionImpl {
    return expect(this[TRANSACTION]!, 'must be in a transaction');
  }
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / vm / element-builder.ts View on Github external
block(): Tracker {
    return expect(this.blockStack.current, "Expected a current block tracker");
  }
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / vm / element-builder.ts View on Github external
popBlock(): Tracker {
    this.block().finalize(this);
    return expect(this.blockStack.pop(), "Expected popBlock to return a block");
  }
github glimmerjs / glimmer-vm / packages / @glimmer / bundle-compiler / lib / lookup.ts View on Github external
getCapabilities(handle: number): ComponentCapabilities {
    let l = expect(
      this.table.byHandle.get(handle),
      `BUG: Shouldn't call getCapabilities if a handle has no associated locator`
    );
    let meta = expect(this.meta.get(l), `could not find template metadata for module ${l.module}`);
    return this.delegate.getComponentCapabilities(meta);
  }
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / vm / append.ts View on Github external
dynamicScope(): DynamicScope {
    return expect(this.dynamicScopeStack.current, 'expected dynamic scope on the dynamic scope stack');
  }
github emberjs / ember.js / packages / @ember / -internals / glimmer / lib / utils / debug-render-tree.ts View on Github external
willDestroy(state: Bucket): void {
    expect(this.refs.get(state), 'BUG: missing ref').release();
  }
github glimmerjs / glimmer.js / packages / @glimmer / application / src / loaders / runtime-compiler / resolver.ts View on Github external
lookupComponentDefinition(name: string, meta: Specifier): ComponentDefinition {
    let handle: number;
    if (!this.cache.component.hasName(name)) {
      let specifier = expect(
        this.identifyComponent(name, meta),
        `Could not find the component '${name}'`
      );

      let template = this.owner.lookup('template', specifier);
      let componentSpecifier = this.owner.identify('component', specifier);
      let componentFactory: Option = null;

      if (componentSpecifier !== undefined) {
        componentFactory = this.owner.factoryFor(componentSpecifier);
      }

      handle = this.registerComponent(name, specifier, componentFactory, template);
    } else {
      handle = this.lookup('component', name, meta)!;
    }