Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (evalScope) {
for (let i = 0; i < partialSymbols.length; i++) {
let name = partialSymbols[i];
let symbol = i + 1;
let value = evalScope[name];
if (value !== undefined) partialScope.bind(symbol, value);
}
}
partialScope.bindPartialMap(locals);
vm.pushFrame(); // sp += 2
vm.call(unwrapHandle(vmHandle!));
}
},
'jit'
appendTo(selector: string) {
let element = assertElement(document.querySelector(selector) as SimpleElement);
let self = new UpdatableRootReference(this);
let cursor = { element, nextSibling: null };
let handle = unwrapTemplate(this.template)
.asLayout()
.compile(this.syntax);
let templateIterator = renderJitMain(
this.runtime,
this.syntax,
self,
clientBuilder(this.runtime.env, cursor),
unwrapHandle(handle)
);
let result;
do {
result = templateIterator.next();
} while (!result.done);
this.element = firstElementChild(element)!;
}
}
export function renderTemplate(
src: string,
{ runtime, syntax }: JitTestDelegateContext,
self: VersionedPathReference,
builder: ElementBuilder
): RenderResult {
let template = preprocess(src);
let handle = unwrapTemplate(template)
.asLayout()
.compile(syntax);
let iterator = renderJitMain(runtime, syntax, self, builder, unwrapHandle(handle));
return renderSync(runtime.env, iterator);
}
const definition = expect(
resolveComponent(vm.runtime.resolver, name),
`could not find component "${name}"`
);
const { manager, state } = definition;
const capabilities = capabilityFlagsFrom(manager.getCapabilities(state));
let invocation: Invocation;
if (hasStaticLayoutCapability(capabilities, manager)) {
let layout = (manager as WithJitStaticLayout).getJitStaticLayout(state, vm.runtime.resolver);
let handle = unwrapHandle(layout.compile(context));
if (Array.isArray(handle)) {
let error = handle[0];
throw new Error(
`Compile Error: ${error.problem} ${error.span.start}..${error.span.end} :: TODO (thread better)`
);
}
invocation = { handle, symbolTable: layout.symbolTable };
} else {
throw new Error('Cannot invoke components with dynamic layouts as a root component.');
}
return renderInvocation(vm, invocation, definition, args);
}
async getTemplateIterator(
app: Application,
env: Environment,
builder: ElementBuilder,
dynamicScope: DynamicScope,
self: PathReference
): Promise {
let resolver = this.getResolver(app);
let context = this.getContext(resolver);
let runtime = CustomJitRuntime(resolver, context, app.env);
let mainLayout = unwrapTemplate(templateFactory(mainTemplate).create());
let handle = unwrapHandle(mainLayout.asLayout().compile(context));
return Promise.resolve(
renderJitMain(
runtime,
context,
self,
builder,
handle,
dynamicScope
)
);
}