Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(
private runtime: JitRuntimeContext,
private syntax: SyntaxCompilationContext,
template: string,
state?: Object
) {
this.template = preprocess(template);
assign(this, state);
}
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<
constructor(bucket = null) {
if (bucket) {
this.bucket = assign({}, bucket);
} else {
this.bucket = {};
}
}
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}\`.`
);
}
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,
});
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());
}
asLayout(): CompilableProgram {
if (this.layout) return this.layout;
return (this.layout = compilable(
assign({}, this.parsedLayout, {
asPartial: false,
})
));
}
with(name: string, block: Option): NamedBlocks {
let { blocks } = this;
if (blocks) {
return new NamedBlocksImpl(assign({}, blocks, { [name]: block }));
} else {
return new NamedBlocksImpl({ [name]: block });
}
}
constructor(bucket: Bucket = null) {
if (bucket) {
this.bucket = assign({}, bucket);
} else {
this.bucket = {};
}
}
asWrappedLayout(): CompilableProgram {
if (this.wrappedLayout) return this.wrappedLayout;
return (this.wrappedLayout = new WrappedBuilder(
assign({}, this.parsedLayout, {
asPartial: false,
})
));
}
}