complete performance and reliability follow-ups
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
// Generated by scripts/build-editor-compiler.mjs. Do not edit directly.
|
||||
// WRN editor compiler source hash: 4f9249b868459eb792fcd6dc7814e440bd2c0ad6d08f1dec947939dc48db92b3
|
||||
// WRN editor compiler source hash: 196a514b18fb6e31fdd8f4ca667a76b0b62cab547af33725ba78564d70bbc01b
|
||||
// WRN editor compiler generator hash: c71e7fe4258c97b73b384ff14b321f0cf0b30cc2ed0322f5f84b04e757159b18
|
||||
// Generated with TypeScript: 5.9.3
|
||||
const __nodeRequire = require;
|
||||
@@ -1454,7 +1454,12 @@ function __wrnexusEscapeHtml(value: unknown): string {
|
||||
return String(value).replace(/[&<>"']/g, (ch) => __wrnexusHtmlEscapes[ch] ?? ch);
|
||||
}
|
||||
|
||||
function __wrnexusEvalData(data: unknown, body: string, helpers = "", ctx: any): unknown {
|
||||
type __WrnexusContext = import("@wrnexus/core").Context & {
|
||||
__wrnexusCallApi?: (path: string, method: string) => Promise<unknown>;
|
||||
localStorage?: unknown;
|
||||
};
|
||||
|
||||
function __wrnexusEvalData(data: unknown, body: string, helpers = "", ctx: __WrnexusContext): unknown {
|
||||
const adapters = {
|
||||
cookies: ctx.cookies,
|
||||
session: ctx.session,
|
||||
@@ -1485,7 +1490,7 @@ function __wrnexusPropAttr(
|
||||
);
|
||||
}
|
||||
|
||||
async function __wrnexusCallApi(path: string, method: string, ctx: any): Promise<unknown> {
|
||||
async function __wrnexusCallApi(path: string, method: string, ctx: __WrnexusContext): Promise<unknown> {
|
||||
if (typeof ctx.__wrnexusCallApi === "function") {
|
||||
return await ctx.__wrnexusCallApi(path, method);
|
||||
}
|
||||
@@ -1500,7 +1505,7 @@ async function __wrnexusCallApi(path: string, method: string, ctx: any): Promise
|
||||
return type.includes("application/json") ? await res.json() : await res.text();
|
||||
}
|
||||
|
||||
async function __wrnexusRenderSsrBindings(html: string, ctx: any): Promise<string> {
|
||||
async function __wrnexusRenderSsrBindings(html: string, ctx: __WrnexusContext): Promise<string> {
|
||||
for (const binding of __wrnexusSsrBindings) {
|
||||
const data = await __wrnexusCallApi(binding.path, binding.method, ctx);
|
||||
const value = __wrnexusEvalData(data, binding.body, binding.helpers, ctx);
|
||||
@@ -1933,14 +1938,14 @@ function generate(ast) {
|
||||
out.push(ssrRuntimeSource());
|
||||
out.push(`const __wrnexusSsrBindings = ${JSON.stringify(ssrBindings, null, 2)};`);
|
||||
const decls = loopConsts.length > 0 ? loopConsts.join("\n") + "\n" : "";
|
||||
out.push(`export default async function ${ast.name}(ctx: any) {
|
||||
out.push(`export default async function ${ast.name}(ctx: __WrnexusContext) {
|
||||
${storeDeclarations}
|
||||
${serverLoadAliases}
|
||||
${decls}
|
||||
const __state: ${stateType} = ${dynamicStateInitializer};
|
||||
${ssrStateAliases}
|
||||
${ssrComputedAliases}
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, (__state as any)[key]]));
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, Reflect.get(__state, key)]));
|
||||
const __scopeValue = Object.entries(__hydrationState)
|
||||
.map(([key, value]) => {
|
||||
let encoded: string;
|
||||
@@ -1966,13 +1971,13 @@ function generate(ast) {
|
||||
}`);
|
||||
}
|
||||
else {
|
||||
out.push(`export default ${storeBindings.length > 0 ? "async " : ""}function ${ast.name}(ctx: any) {
|
||||
out.push(`export default ${storeBindings.length > 0 ? "async " : ""}function ${ast.name}(ctx: import("@wrnexus/core").Context) {
|
||||
${storeDeclarations}
|
||||
${serverLoadAliases}
|
||||
const __state: ${stateType} = ${dynamicStateInitializer};
|
||||
${ssrStateAliases}
|
||||
${ssrComputedAliases}
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, (__state as any)[key]]));
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, Reflect.get(__state, key)]));
|
||||
const __scopeValue = Object.entries(__hydrationState)
|
||||
.map(([key, value]) => {
|
||||
let encoded: string;
|
||||
@@ -1996,14 +2001,14 @@ function generate(ast) {
|
||||
}`);
|
||||
}
|
||||
if (staticShellBody !== undefined) {
|
||||
out.push(`export async function __wrnexusBuildStaticShell(ctx: any = {}) {
|
||||
out.push(`export async function __wrnexusBuildStaticShell(ctx: import("@wrnexus/core").Context = {} as import("@wrnexus/core").Context) {
|
||||
${storeDeclarations}
|
||||
${serverLoadAliases}
|
||||
${loopConsts.length > 0 ? loopConsts.join("\n") : ""}
|
||||
const __state: ${stateType} = ${dynamicStateInitializer};
|
||||
${ssrStateAliases}
|
||||
${ssrComputedAliases}
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, (__state as any)[key]]));
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, Reflect.get(__state, key)]));
|
||||
const __scopeValue = Object.entries(__hydrationState)
|
||||
.map(([key, value]) => {
|
||||
let encoded: string;
|
||||
@@ -2053,7 +2058,7 @@ function generate(ast) {
|
||||
})
|
||||
.join("\n");
|
||||
const visible = exposed.filter((entry) => entry.name);
|
||||
return `export async function ${exportName}(ctx: any) {
|
||||
return `export async function ${exportName}(ctx: import("@wrnexus/core").Context) {
|
||||
${exposed
|
||||
.filter((entry) => !entry.name)
|
||||
.map((entry) => entry.body)
|
||||
@@ -2076,7 +2081,7 @@ ${visible.length
|
||||
out.push(`export async function ${action.name}(${action.args.join(", ")}) {${action.body}}`);
|
||||
continue;
|
||||
}
|
||||
out.push(`export async function ${action.name}(input: any, ctx: any) {
|
||||
out.push(`export async function ${action.name}(input: InferSchema<typeof ${action.schema}>, ctx: import("@wrnexus/core").Context) {
|
||||
const invalidate = (...tags: string[]) => {
|
||||
const bucket = (ctx.locals.__wrnexusInvalidatedTags ??= []);
|
||||
bucket.push(...tags.flat());
|
||||
@@ -2098,7 +2103,7 @@ ${ast.actions
|
||||
ast.apis.forEach((api, index) => {
|
||||
const name = `__wrnexusApi_${api.method}_${index}`;
|
||||
out.push(`// ${api.method} ${apiRoutePath(api.path)}
|
||||
const ${name} = async (ctx: any) => {${api.body}};`);
|
||||
const ${name} = async (ctx: import("@wrnexus/core").Context) => {${api.body}};`);
|
||||
});
|
||||
const entries = ast.apis.map((api, index) => ` ${JSON.stringify(`${api.method} ${apiRoutePath(api.path)}`)}: __wrnexusApi_${api.method}_${index},`);
|
||||
out.push(`export const __wrnexusApi = {\n${entries.join("\n")}\n};`);
|
||||
@@ -2114,7 +2119,7 @@ const ${name} = async (ctx: any) => {${api.body}};`);
|
||||
if (ast.realtimes.length > 0) {
|
||||
const handlers = ast.realtimes.flatMap((rt) => rt.handlers.map((h) => {
|
||||
const params = ["ws", ...h.args].join(", ");
|
||||
return ` ${h.event}(${params}: any) {${h.body}},`;
|
||||
return ` ${h.event}(${params}: Event) {${h.body}},`;
|
||||
}));
|
||||
out.push(`export const websocket = {\n${handlers.join("\n")}\n};`);
|
||||
}
|
||||
@@ -2697,7 +2702,7 @@ function generateComponent(ast) {
|
||||
if (prop.required) {
|
||||
decls.push(` if (__p[${JSON.stringify(prop.name)}] === undefined) throw new TypeError(${JSON.stringify(`${ast.name} requires prop '${prop.name}' (${prop.valueType ?? "unknown"})`)});`);
|
||||
}
|
||||
decls.push(` const ${nameRefs.get(prop.name)}: ${prop.valueType ?? "any"} = __coerce(__p[${JSON.stringify(prop.name)}], (${resolveExpr(prop.default)}), ${JSON.stringify((0, types_ts_1.runtimeTypeOf)(prop.valueType))}, ${JSON.stringify(prop.name)});`);
|
||||
decls.push(` const ${nameRefs.get(prop.name)}: ${prop.valueType ?? "unknown"} = __coerce(__p[${JSON.stringify(prop.name)}], (${resolveExpr(prop.default)}), ${JSON.stringify((0, types_ts_1.runtimeTypeOf)(prop.valueType))}, ${JSON.stringify(prop.name)}) as ${prop.valueType ?? "unknown"};`);
|
||||
}
|
||||
if (!effectiveProps.some((prop) => prop.name === "attrs")) {
|
||||
decls.push(` const __attrs = __restProps(__p, new Set(${JSON.stringify(effectiveProps.map((prop) => prop.name))}));`);
|
||||
@@ -2762,7 +2767,7 @@ function generateComponent(ast) {
|
||||
.map((output) => ` ${JSON.stringify(output.name)}(${output.payload ? `${output.payload.name}${output.payload.optional ? "?" : ""}: ${output.payload.valueType}` : ""}): void;`)
|
||||
.join("\n")}\n}`);
|
||||
}
|
||||
out.push(`function __coerce(v: any, def: any, declared: string = "unknown", propName: string = "prop"): any {
|
||||
out.push(`function __coerce(v: unknown, def: unknown, declared: string = "unknown", propName: string = "prop"): unknown {
|
||||
if (v === undefined || v === null) {
|
||||
return def;
|
||||
}
|
||||
@@ -2822,7 +2827,7 @@ function generateComponent(ast) {
|
||||
throw new TypeError("Expected an object prop '" + propName + "'");
|
||||
}
|
||||
|
||||
if (declared === "bigint") return BigInt(v);
|
||||
if (declared === "bigint") return BigInt(v as string | number | bigint | boolean);
|
||||
if (declared === "function" && typeof v !== "function") {
|
||||
throw new TypeError("Expected a function prop");
|
||||
}
|
||||
@@ -2830,15 +2835,15 @@ function generateComponent(ast) {
|
||||
}
|
||||
|
||||
function __restProps(
|
||||
props: Record<string, any>,
|
||||
props: Record<string, unknown>,
|
||||
declared: Set<string>,
|
||||
): Record<string, any> {
|
||||
): Record<string, unknown> {
|
||||
return Object.fromEntries(
|
||||
Object.entries(props).filter(([name]) => !declared.has(name)),
|
||||
);
|
||||
}
|
||||
|
||||
function __wireHtml(v: any): string {
|
||||
function __wireHtml(v: unknown): string {
|
||||
return String(v == null ? "" : v).replace(
|
||||
/[&<>]/g,
|
||||
(c) =>
|
||||
@@ -2850,7 +2855,7 @@ function __wireHtml(v: any): string {
|
||||
);
|
||||
}
|
||||
|
||||
function __wireAttr(v: any): string {
|
||||
function __wireAttr(v: unknown): string {
|
||||
return String(v == null ? "" : v).replace(
|
||||
/[&<>"]/g,
|
||||
(c) =>
|
||||
@@ -2864,7 +2869,7 @@ function __wireAttr(v: any): string {
|
||||
);
|
||||
}
|
||||
|
||||
function __wireBooleanAttr(name: string, value: any): string {
|
||||
function __wireBooleanAttr(name: string, value: unknown): string {
|
||||
return value === true ||
|
||||
value === "true" ||
|
||||
value === "" ||
|
||||
@@ -2875,7 +2880,7 @@ function __wireBooleanAttr(name: string, value: any): string {
|
||||
: "";
|
||||
}
|
||||
|
||||
function __wireSpreadAttrs(value: any): string {
|
||||
function __wireSpreadAttrs(value: unknown): string {
|
||||
if (value === null || typeof value !== "object" || Array.isArray(value)) return "";
|
||||
|
||||
const booleanAttributes = new Set(${JSON.stringify([...HTML_BOOLEAN_ATTRIBUTES])});
|
||||
@@ -2911,7 +2916,7 @@ function __wireSpreadAttrs(value: any): string {
|
||||
return attributes.join("");
|
||||
}
|
||||
|
||||
function __wireProp(v: any): string {
|
||||
function __wireProp(v: unknown): string {
|
||||
const value =
|
||||
v !== null && typeof v === "object"
|
||||
? JSON.stringify(v)
|
||||
@@ -2920,16 +2925,16 @@ function __wireProp(v: any): string {
|
||||
return __wireAttr(value);
|
||||
}
|
||||
|
||||
function __wireRaw(v: any): string {
|
||||
function __wireRaw(v: unknown): string {
|
||||
return String(v == null ? "" : v);
|
||||
}`);
|
||||
if (hasServerEach) {
|
||||
out.push(`function __wrnexusEncodeLoopLocals(value: Record<string, any>): string {
|
||||
out.push(`function __wrnexusEncodeLoopLocals(value: Record<string, unknown>): string {
|
||||
return __WrnexusBuffer.from(JSON.stringify(value), "utf8").toString("base64");
|
||||
}`);
|
||||
}
|
||||
if (needsScope) {
|
||||
out.push(`function __wrnexusSerializeScopeValue(value: any): string {
|
||||
out.push(`function __wrnexusSerializeScopeValue(value: unknown): string {
|
||||
if (value === undefined) {
|
||||
return "undefined";
|
||||
}
|
||||
@@ -2963,7 +2968,7 @@ function __wireRaw(v: any): string {
|
||||
}
|
||||
}
|
||||
|
||||
function __wrnexusScopeDecl(obj: Record<string, any>): string {
|
||||
function __wrnexusScopeDecl(obj: Record<string, unknown>): string {
|
||||
return Object.keys(obj)
|
||||
.map(
|
||||
(key) =>
|
||||
@@ -2981,7 +2986,7 @@ function __wireRaw(v: any): string {
|
||||
}`);
|
||||
}
|
||||
const serverFunctionSource = serverFunctions ? `${serverFunctions}\n` : "";
|
||||
out.push(`export function render(props: ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, any>"} = {} as ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, any>"}): string {\n` +
|
||||
out.push(`export function render(props: ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, unknown>"} = {} as ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, unknown>"}): string {\n` +
|
||||
` const __p = props || {};\n` +
|
||||
(decls.length > 0 ? decls.join("\n") + "\n" : "") +
|
||||
serverFunctionSource +
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// WRN editor extension source hash: c09cc127dcc7fbae562648b09435fb96134c18e63ba21d7a4b476b916f4a8256
|
||||
// WRN editor extension source hash: 47188196a996fce0b8f1e2a4302e563767451d9b56df885abc60e9c925653b21
|
||||
// WRN editor extension generator hash: 456d1d614e44e5fb1f19b784176c09cf2ade9b64ef73a17934c2698150b62728
|
||||
"use strict";
|
||||
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
||||
@@ -23863,7 +23863,12 @@ function __wrnexusEscapeHtml(value: unknown): string {
|
||||
return String(value).replace(/[&<>"']/g, (ch) => __wrnexusHtmlEscapes[ch] ?? ch);
|
||||
}
|
||||
|
||||
function __wrnexusEvalData(data: unknown, body: string, helpers = "", ctx: any): unknown {
|
||||
type __WrnexusContext = import("@wrnexus/core").Context & {
|
||||
__wrnexusCallApi?: (path: string, method: string) => Promise<unknown>;
|
||||
localStorage?: unknown;
|
||||
};
|
||||
|
||||
function __wrnexusEvalData(data: unknown, body: string, helpers = "", ctx: __WrnexusContext): unknown {
|
||||
const adapters = {
|
||||
cookies: ctx.cookies,
|
||||
session: ctx.session,
|
||||
@@ -23894,7 +23899,7 @@ function __wrnexusPropAttr(
|
||||
);
|
||||
}
|
||||
|
||||
async function __wrnexusCallApi(path: string, method: string, ctx: any): Promise<unknown> {
|
||||
async function __wrnexusCallApi(path: string, method: string, ctx: __WrnexusContext): Promise<unknown> {
|
||||
if (typeof ctx.__wrnexusCallApi === "function") {
|
||||
return await ctx.__wrnexusCallApi(path, method);
|
||||
}
|
||||
@@ -23909,7 +23914,7 @@ async function __wrnexusCallApi(path: string, method: string, ctx: any): Promise
|
||||
return type.includes("application/json") ? await res.json() : await res.text();
|
||||
}
|
||||
|
||||
async function __wrnexusRenderSsrBindings(html: string, ctx: any): Promise<string> {
|
||||
async function __wrnexusRenderSsrBindings(html: string, ctx: __WrnexusContext): Promise<string> {
|
||||
for (const binding of __wrnexusSsrBindings) {
|
||||
const data = await __wrnexusCallApi(binding.path, binding.method, ctx);
|
||||
const value = __wrnexusEvalData(data, binding.body, binding.helpers, ctx);
|
||||
@@ -24300,14 +24305,14 @@ ${helpers}`);
|
||||
const decls = loopConsts.length > 0 ? loopConsts.join(`
|
||||
`) + `
|
||||
` : "";
|
||||
out.push(`export default async function ${ast.name}(ctx: any) {
|
||||
out.push(`export default async function ${ast.name}(ctx: __WrnexusContext) {
|
||||
${storeDeclarations}
|
||||
${serverLoadAliases}
|
||||
${decls}
|
||||
const __state: ${stateType} = ${dynamicStateInitializer};
|
||||
${ssrStateAliases}
|
||||
${ssrComputedAliases}
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, (__state as any)[key]]));
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, Reflect.get(__state, key)]));
|
||||
const __scopeValue = Object.entries(__hydrationState)
|
||||
.map(([key, value]) => {
|
||||
let encoded: string;
|
||||
@@ -24332,13 +24337,13 @@ ${helpers}`);
|
||||
return await __wrnexusRenderSsrBindings(html, ctx);
|
||||
}`);
|
||||
} else {
|
||||
out.push(`export default ${storeBindings.length > 0 ? "async " : ""}function ${ast.name}(ctx: any) {
|
||||
out.push(`export default ${storeBindings.length > 0 ? "async " : ""}function ${ast.name}(ctx: import("@wrnexus/core").Context) {
|
||||
${storeDeclarations}
|
||||
${serverLoadAliases}
|
||||
const __state: ${stateType} = ${dynamicStateInitializer};
|
||||
${ssrStateAliases}
|
||||
${ssrComputedAliases}
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, (__state as any)[key]]));
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, Reflect.get(__state, key)]));
|
||||
const __scopeValue = Object.entries(__hydrationState)
|
||||
.map(([key, value]) => {
|
||||
let encoded: string;
|
||||
@@ -24362,7 +24367,7 @@ ${helpers}`);
|
||||
}`);
|
||||
}
|
||||
if (staticShellBody !== undefined) {
|
||||
out.push(`export async function __wrnexusBuildStaticShell(ctx: any = {}) {
|
||||
out.push(`export async function __wrnexusBuildStaticShell(ctx: import("@wrnexus/core").Context = {} as import("@wrnexus/core").Context) {
|
||||
${storeDeclarations}
|
||||
${serverLoadAliases}
|
||||
${loopConsts.length > 0 ? loopConsts.join(`
|
||||
@@ -24370,7 +24375,7 @@ ${helpers}`);
|
||||
const __state: ${stateType} = ${dynamicStateInitializer};
|
||||
${ssrStateAliases}
|
||||
${ssrComputedAliases}
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, (__state as any)[key]]));
|
||||
const __hydrationState = Object.fromEntries(${hydrationStateNames}.map((key) => [key, Reflect.get(__state, key)]));
|
||||
const __scopeValue = Object.entries(__hydrationState)
|
||||
.map(([key, value]) => {
|
||||
let encoded: string;
|
||||
@@ -24417,7 +24422,7 @@ ${helpers}`);
|
||||
}).join(`
|
||||
`);
|
||||
const visible = exposed.filter((entry) => entry.name);
|
||||
return `export async function ${exportName}(ctx: any) {
|
||||
return `export async function ${exportName}(ctx: import("@wrnexus/core").Context) {
|
||||
${exposed.filter((entry) => !entry.name).map((entry) => entry.body).join(`
|
||||
`)}
|
||||
${declarations}
|
||||
@@ -24436,7 +24441,7 @@ ${visible.length ? ` const __values = await Promise.all([${visible.map((entry)
|
||||
out.push(`export async function ${action.name}(${action.args.join(", ")}) {${action.body}}`);
|
||||
continue;
|
||||
}
|
||||
out.push(`export async function ${action.name}(input: any, ctx: any) {
|
||||
out.push(`export async function ${action.name}(input: InferSchema<typeof ${action.schema}>, ctx: import("@wrnexus/core").Context) {
|
||||
const invalidate = (...tags: string[]) => {
|
||||
const bucket = (ctx.locals.__wrnexusInvalidatedTags ??= []);
|
||||
bucket.push(...tags.flat());
|
||||
@@ -24454,7 +24459,7 @@ ${ast.actions.map((action) => ` ${action.name}: createActionClient<${action.sch
|
||||
ast.apis.forEach((api, index) => {
|
||||
const name = `__wrnexusApi_${api.method}_${index}`;
|
||||
out.push(`// ${api.method} ${apiRoutePath(api.path)}
|
||||
const ${name} = async (ctx: any) => {${api.body}};`);
|
||||
const ${name} = async (ctx: import("@wrnexus/core").Context) => {${api.body}};`);
|
||||
});
|
||||
const entries = ast.apis.map((api, index) => ` ${JSON.stringify(`${api.method} ${apiRoutePath(api.path)}`)}: __wrnexusApi_${api.method}_${index},`);
|
||||
out.push(`export const __wrnexusApi = {
|
||||
@@ -24472,7 +24477,7 @@ ${entries.join(`
|
||||
if (ast.realtimes.length > 0) {
|
||||
const handlers = ast.realtimes.flatMap((rt) => rt.handlers.map((h) => {
|
||||
const params = ["ws", ...h.args].join(", ");
|
||||
return ` ${h.event}(${params}: any) {${h.body}},`;
|
||||
return ` ${h.event}(${params}: Event) {${h.body}},`;
|
||||
}));
|
||||
out.push(`export const websocket = {
|
||||
${handlers.join(`
|
||||
@@ -24929,7 +24934,7 @@ ${handlers.join(`
|
||||
if (prop.required) {
|
||||
decls.push(` if (__p[${JSON.stringify(prop.name)}] === undefined) throw new TypeError(${JSON.stringify(`${ast.name} requires prop '${prop.name}' (${prop.valueType ?? "unknown"})`)});`);
|
||||
}
|
||||
decls.push(` const ${nameRefs.get(prop.name)}: ${prop.valueType ?? "any"} = __coerce(__p[${JSON.stringify(prop.name)}], (${resolveExpr(prop.default)}), ${JSON.stringify((0, types_ts_1.runtimeTypeOf)(prop.valueType))}, ${JSON.stringify(prop.name)});`);
|
||||
decls.push(` const ${nameRefs.get(prop.name)}: ${prop.valueType ?? "unknown"} = __coerce(__p[${JSON.stringify(prop.name)}], (${resolveExpr(prop.default)}), ${JSON.stringify((0, types_ts_1.runtimeTypeOf)(prop.valueType))}, ${JSON.stringify(prop.name)}) as ${prop.valueType ?? "unknown"};`);
|
||||
}
|
||||
if (!effectiveProps.some((prop) => prop.name === "attrs")) {
|
||||
decls.push(` const __attrs = __restProps(__p, new Set(${JSON.stringify(effectiveProps.map((prop) => prop.name))}));`);
|
||||
@@ -24989,7 +24994,7 @@ ${ast.outputs.map((output) => ` ${JSON.stringify(output.name)}(${output.payload
|
||||
`)}
|
||||
}`);
|
||||
}
|
||||
out.push(`function __coerce(v: any, def: any, declared: string = "unknown", propName: string = "prop"): any {
|
||||
out.push(`function __coerce(v: unknown, def: unknown, declared: string = "unknown", propName: string = "prop"): unknown {
|
||||
if (v === undefined || v === null) {
|
||||
return def;
|
||||
}
|
||||
@@ -25049,7 +25054,7 @@ ${ast.outputs.map((output) => ` ${JSON.stringify(output.name)}(${output.payload
|
||||
throw new TypeError("Expected an object prop '" + propName + "'");
|
||||
}
|
||||
|
||||
if (declared === "bigint") return BigInt(v);
|
||||
if (declared === "bigint") return BigInt(v as string | number | bigint | boolean);
|
||||
if (declared === "function" && typeof v !== "function") {
|
||||
throw new TypeError("Expected a function prop");
|
||||
}
|
||||
@@ -25057,15 +25062,15 @@ ${ast.outputs.map((output) => ` ${JSON.stringify(output.name)}(${output.payload
|
||||
}
|
||||
|
||||
function __restProps(
|
||||
props: Record<string, any>,
|
||||
props: Record<string, unknown>,
|
||||
declared: Set<string>,
|
||||
): Record<string, any> {
|
||||
): Record<string, unknown> {
|
||||
return Object.fromEntries(
|
||||
Object.entries(props).filter(([name]) => !declared.has(name)),
|
||||
);
|
||||
}
|
||||
|
||||
function __wireHtml(v: any): string {
|
||||
function __wireHtml(v: unknown): string {
|
||||
return String(v == null ? "" : v).replace(
|
||||
/[&<>]/g,
|
||||
(c) =>
|
||||
@@ -25077,7 +25082,7 @@ function __wireHtml(v: any): string {
|
||||
);
|
||||
}
|
||||
|
||||
function __wireAttr(v: any): string {
|
||||
function __wireAttr(v: unknown): string {
|
||||
return String(v == null ? "" : v).replace(
|
||||
/[&<>"]/g,
|
||||
(c) =>
|
||||
@@ -25091,7 +25096,7 @@ function __wireAttr(v: any): string {
|
||||
);
|
||||
}
|
||||
|
||||
function __wireBooleanAttr(name: string, value: any): string {
|
||||
function __wireBooleanAttr(name: string, value: unknown): string {
|
||||
return value === true ||
|
||||
value === "true" ||
|
||||
value === "" ||
|
||||
@@ -25102,7 +25107,7 @@ function __wireBooleanAttr(name: string, value: any): string {
|
||||
: "";
|
||||
}
|
||||
|
||||
function __wireSpreadAttrs(value: any): string {
|
||||
function __wireSpreadAttrs(value: unknown): string {
|
||||
if (value === null || typeof value !== "object" || Array.isArray(value)) return "";
|
||||
|
||||
const booleanAttributes = new Set(${JSON.stringify([...HTML_BOOLEAN_ATTRIBUTES])});
|
||||
@@ -25138,7 +25143,7 @@ function __wireSpreadAttrs(value: any): string {
|
||||
return attributes.join("");
|
||||
}
|
||||
|
||||
function __wireProp(v: any): string {
|
||||
function __wireProp(v: unknown): string {
|
||||
const value =
|
||||
v !== null && typeof v === "object"
|
||||
? JSON.stringify(v)
|
||||
@@ -25147,16 +25152,16 @@ function __wireProp(v: any): string {
|
||||
return __wireAttr(value);
|
||||
}
|
||||
|
||||
function __wireRaw(v: any): string {
|
||||
function __wireRaw(v: unknown): string {
|
||||
return String(v == null ? "" : v);
|
||||
}`);
|
||||
if (hasServerEach) {
|
||||
out.push(`function __wrnexusEncodeLoopLocals(value: Record<string, any>): string {
|
||||
out.push(`function __wrnexusEncodeLoopLocals(value: Record<string, unknown>): string {
|
||||
return __WrnexusBuffer.from(JSON.stringify(value), "utf8").toString("base64");
|
||||
}`);
|
||||
}
|
||||
if (needsScope) {
|
||||
out.push(`function __wrnexusSerializeScopeValue(value: any): string {
|
||||
out.push(`function __wrnexusSerializeScopeValue(value: unknown): string {
|
||||
if (value === undefined) {
|
||||
return "undefined";
|
||||
}
|
||||
@@ -25190,7 +25195,7 @@ function __wireRaw(v: any): string {
|
||||
}
|
||||
}
|
||||
|
||||
function __wrnexusScopeDecl(obj: Record<string, any>): string {
|
||||
function __wrnexusScopeDecl(obj: Record<string, unknown>): string {
|
||||
return Object.keys(obj)
|
||||
.map(
|
||||
(key) =>
|
||||
@@ -25209,7 +25214,7 @@ function __wireRaw(v: any): string {
|
||||
}
|
||||
const serverFunctionSource = serverFunctions ? `${serverFunctions}
|
||||
` : "";
|
||||
out.push(`export function render(props: ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, any>"} = {} as ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, any>"}): string {
|
||||
out.push(`export function render(props: ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, unknown>"} = {} as ${effectiveProps.length > 0 ? `${ast.name}Props` : "Record<string, unknown>"}): string {
|
||||
` + ` const __p = props || {};
|
||||
` + (decls.length > 0 ? decls.join(`
|
||||
`) + `
|
||||
|
||||
Reference in New Issue
Block a user