How to use the @glimmer/util.assign 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-vm / packages / @glimmer / integration-tests / lib / components / emberish-root-view.ts View on Github external
constructor(
    private runtime: JitRuntimeContext,
    private syntax: SyntaxCompilationContext,
    template: string,
    state?: Object
  ) {
    this.template = preprocess(template);
    assign(this, state);
  }
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / components / emberish-glimmer.ts View on Github external
didReceiveAttrs(_diff: AttrsDiff) {}
  willInsertElement() {}
  willUpdate() {}
  willRender() {}
  didInsertElement() {}
  didUpdate() {}
  didRender() {}
}

export interface EmberishGlimmerComponentFactory
  extends TestComponentConstructor {
  create(options: { attrs: Attrs }): EmberishGlimmerComponent;
  new (...args: unknown[]): this;
}

export const EMBERISH_GLIMMER_CAPABILITIES = assign({}, BASIC_CAPABILITIES, {
  dynamicTag: true,
  createArgs: true,
  attributeHook: true,
  updateHook: true,
  createInstance: true,
});

export interface EmberishGlimmerComponentState {
  args: CapturedNamedArguments;
  component: EmberishGlimmerComponent;
}

export class EmberishGlimmerComponentManager
  implements
    ComponentManager,
    WithJitStaticLayout<
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment.ts View on Github external
constructor(bucket = null) {
    if (bucket) {
      this.bucket = assign({}, bucket);
    } else {
      this.bucket = {};
    }
  }
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / components / emberish-curly.ts View on Github external
args: VMArguments
  ): Option {
    const { positionalParams } = state.ComponentClass || EmberishCurlyComponent;

    if (typeof positionalParams === 'string') {
      if (args.named.has(positionalParams)) {
        if (args.positional.length === 0) {
          return null;
        } else {
          throw new Error(
            `You cannot specify positional parameters and the hash argument \`${positionalParams}\`.`
          );
        }
      }

      let named = assign({}, args.named.capture().map);
      named[positionalParams] = args.positional.capture();

      return { positional: EMPTY_ARRAY, named };
    } else if (Array.isArray(positionalParams)) {
      let named = assign({}, args.named.capture().map);
      let count = Math.min(positionalParams.length, args.positional.length);

      for (let i = 0; i < count; i++) {
        let name = positionalParams[i];

        if (named[name]) {
          throw new Error(
            `You cannot specify both a positional param (at position ${i}) and the hash argument \`${name}\`.`
          );
        }
github glimmerjs / glimmer-vm / packages / @glimmer / integration-tests / lib / components / capabilities.ts View on Github external
export const CURLY_CAPABILITIES: ComponentCapabilities = {
  dynamicLayout: true,
  dynamicTag: true,
  prepareArgs: true,
  createArgs: true,
  attributeHook: true,
  elementHook: true,
  dynamicScope: true,
  createCaller: true,
  updateHook: true,
  createInstance: true,
  wrapped: true,
  willDestroy: true,
};

export const EMBERISH_CURLY_CAPABILITIES: ComponentCapabilities = assign({}, CURLY_CAPABILITIES, {
  dynamicLayout: false,
  attributeHook: false,
});
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / components / emberish-curly.ts View on Github external
create(_environment: Environment, state: EmberishCurlyComponentDefinitionState, _args: Arguments, dynamicScope: DynamicScope, callerSelf: PathReference, hasDefaultBlock: boolean): EmberishCurlyComponent {
    let klass = state.ComponentClass || BaseEmberishCurlyComponent;
    let self = callerSelf.value();
    let args = _args.named.capture();
    let attrs = args.value();
    let merged = assign({}, attrs, { attrs }, { args }, { targetObject: self }, { HAS_BLOCK: hasDefaultBlock });
    let component = klass.create(merged);

    component.name = state.name;
    component.args = args;

    if (state.layout) {
      component.layout = { name: component.name, handle: state.layout };
    }

    let dyn: Option = state.ComponentClass ? state.ComponentClass['fromDynamicScope'] : null;

    if (dyn) {
      for (let i = 0; i < dyn.length; i++) {
        let name = dyn[i];
        component.set(name, dynamicScope.get(name).value());
      }
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / template.ts View on Github external
asLayout(): CompilableProgram {
    if (this.layout) return this.layout;
    return (this.layout = compilable(
      assign({}, this.parsedLayout, {
        asPartial: false,
      })
    ));
  }
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / utils.ts View on Github external
with(name: string, block: Option): NamedBlocks {
    let { blocks } = this;

    if (blocks) {
      return new NamedBlocksImpl(assign({}, blocks, { [name]: block }));
    } else {
      return new NamedBlocksImpl({ [name]: block });
    }
  }
github glimmerjs / glimmer.js / packages / @glimmer / application / src / dynamic-scope.ts View on Github external
constructor(bucket: Bucket = null) {
    if (bucket) {
      this.bucket = assign({}, bucket);
    } else {
      this.bucket = {};
    }
  }
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / template.ts View on Github external
asWrappedLayout(): CompilableProgram {
    if (this.wrappedLayout) return this.wrappedLayout;
    return (this.wrappedLayout = new WrappedBuilder(
      assign({}, this.parsedLayout, {
        asPartial: false,
      })
    ));
  }
}