mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
* Expand static three.js workflows and host integration * Preserve JavaScript class state in static three.js workflows * Preserve inferred JavaScript behavior across static workflows * Preserve inferred callables and native compatibility boundaries * Retain annotated JavaScript factory exports and bootstrap-safe call spreads * Preserve Buffer and child callback identities in static packages * Clarify JavaScript symbol spread support
21 lines
695 B
JavaScript
21 lines
695 B
JavaScript
function call(options) {
|
|
return options?.render?.(4);
|
|
}
|
|
const host = { value: 3, render(n) { return this.value + n; } };
|
|
console.log(call(host), call({}), call(undefined), call(null));
|
|
|
|
function reference(key, options) {
|
|
function Service() {}
|
|
Object.setPrototypeOf(Service, { useSync(fn) { return fn(this.key); } });
|
|
const init = (name, config) => {
|
|
Service.key = name;
|
|
Service.render = config?.render;
|
|
return Service;
|
|
};
|
|
return arguments.length ? init(key, options) : init;
|
|
}
|
|
const service = reference("scene", host);
|
|
console.log(service.useSync(name => name.toUpperCase()));
|
|
console.log(service.render?.(5));
|
|
console.log(reference()("mesh", {}).useSync(name => name));
|