refactor: replace the legacy function runtime with shared
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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: b0e3094d8c2a70ee2b34fe961c186b58de9527aa072ca12292b715d3d5f51c87
|
||||
// WRN editor compiler source hash: b5b5e076bca1aa1b5603d5b6caf5d5a3169a04e33da8b83ae94e952f8685ab3e
|
||||
// WRN editor compiler generator hash: a54ca847c758bc98d8e353ad6d70088df31de1820f6cf9d1c3462505f563e6b8
|
||||
// Generated with TypeScript: 6.0.3
|
||||
const __nodeRequire = require;
|
||||
@@ -600,7 +600,7 @@ function selectedBrowserImports(ast, functions) {
|
||||
.filter((entry) => entry !== null);
|
||||
}
|
||||
function browserModuleRequired(ast) {
|
||||
const functions = ast.runtimeFunctions.filter((fn) => ["legacy", "client", "shared"].includes(fn.runtime));
|
||||
const functions = ast.runtimeFunctions.filter((fn) => ["client", "shared"].includes(fn.runtime));
|
||||
return functions.length > 0 || selectedBrowserImports(ast, functions).length > 0;
|
||||
}
|
||||
function _functionEntry(ast, fn, availableFunctions) {
|
||||
@@ -734,7 +734,7 @@ function apiBindings(ast) {
|
||||
return members.length ? `const api = {\n${members.join(",\n")}\n };` : "";
|
||||
}
|
||||
function generateBrowserModule(ast) {
|
||||
const functions = ast.runtimeFunctions.filter((fn) => ["legacy", "client", "shared"].includes(fn.runtime));
|
||||
const functions = ast.runtimeFunctions.filter((fn) => ["client", "shared"].includes(fn.runtime));
|
||||
const functionNames = functions.map((fn) => fn.name);
|
||||
const state = ast.states.filter((entry) => entry.runtime !== "server").map((entry) => entry.name);
|
||||
const selectedImports = selectedBrowserImports(ast, functions);
|
||||
@@ -1900,9 +1900,7 @@ function hydrationAttribute(ast) {
|
||||
return ` data-wrn-hydration="${attrEscape(hydrationId(ast))}" data-wrn-hydrate="${attrEscape(strategy)}" data-wrn-runtime="${attrEscape(ast.runtime ?? "universal")}"${moduleAttribute}`;
|
||||
}
|
||||
function targetFunctions(ast, target) {
|
||||
const runtimes = target === "browser"
|
||||
? ["legacy", "client", "shared"]
|
||||
: ["legacy", "server", "shared"];
|
||||
const runtimes = target === "browser" ? ["client", "shared"] : ["server", "shared"];
|
||||
return ast.functions
|
||||
.map((body) => (0, syntax_1.stripRuntimeFunctionModifiers)(body, [...runtimes]))
|
||||
.map((body) => body.trim())
|
||||
@@ -4163,7 +4161,7 @@ function stableId(value) {
|
||||
*/
|
||||
function remotelyReferencedServerFunctions(ast) {
|
||||
const browserSources = ast.runtimeFunctions
|
||||
.filter((fn) => ["legacy", "client", "shared"].includes(fn.runtime))
|
||||
.filter((fn) => ["client", "shared"].includes(fn.runtime))
|
||||
.map((fn) => fn.body);
|
||||
for (const [hook, body] of Object.entries(ast.storeLifecycle)) {
|
||||
if (hook !== "serverInit" && body)
|
||||
@@ -4195,11 +4193,11 @@ function rpcManifest(ast) {
|
||||
}
|
||||
function generateServerFunctionsModule(ast) {
|
||||
const source = ast.functions
|
||||
.map((body) => (0, syntax_1.stripRuntimeFunctionModifiers)(body, ["legacy", "server", "shared"]))
|
||||
.map((body) => (0, syntax_1.stripRuntimeFunctionModifiers)(body, ["server", "shared"]))
|
||||
.filter(Boolean)
|
||||
.join("\n\n");
|
||||
const names = ast.runtimeFunctions
|
||||
.filter((fn) => ["legacy", "server", "shared"].includes(fn.runtime))
|
||||
.filter((fn) => ["server", "shared"].includes(fn.runtime))
|
||||
.map((fn) => fn.name);
|
||||
const manifest = rpcManifest(ast);
|
||||
return `// generated WRNexusJS server module for ${ast.name}\n${source}\n\nexport const __wrnexusServerFunctions = { ${[...new Set(names)].join(", ")} };\nexport const __wrnexusRpcManifest = ${JSON.stringify(manifest, null, 2)};\n`;
|
||||
@@ -4381,7 +4379,7 @@ function generateStoreBrowserModule(ast) {
|
||||
.map((entry) => `${JSON.stringify(entry.name)}: (state) => { ${safeStateNames.length ? `const { ${safeStateNames.join(", ")} } = state;` : ""} return (${entry.expr}); }`)
|
||||
.join(",\n");
|
||||
const groups = new Map();
|
||||
for (const fn of ast.runtimeFunctions.filter((entry) => ["client", "shared", "legacy"].includes(entry.runtime))) {
|
||||
for (const fn of ast.runtimeFunctions.filter((entry) => ["client", "shared"].includes(entry.runtime))) {
|
||||
const group = groups.get(fn.name) ?? [];
|
||||
group.push(fn);
|
||||
groups.set(fn.name, group);
|
||||
@@ -4496,7 +4494,7 @@ function __create(definition) {
|
||||
Object.keys(actions).forEach(function (name) { delete actions[name]; });
|
||||
Object.entries(currentDefinition.actions || {}).forEach(function (pair) {
|
||||
const name = pair[0], candidates = pair[1];
|
||||
const selected = candidates.find(function (entry) { return entry.runtime === "client"; }) || candidates.find(function (entry) { return entry.runtime === "shared"; }) || candidates.find(function (entry) { return entry.runtime === "legacy"; });
|
||||
const selected = candidates.find(function (entry) { return entry.runtime === "client"; }) || candidates.find(function (entry) { return entry.runtime === "shared"; });
|
||||
if (!selected) return;
|
||||
actions[name] = async function () {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
@@ -4689,7 +4687,7 @@ function generateDeclarations(ast) {
|
||||
.map((output) => ` ${member(output.name)}(${output.payload ? `${member(output.payload.name)}${output.payload.optional ? "?" : ""}: ${output.payload.valueType}` : ""}): void;`)
|
||||
.join("\n");
|
||||
const clientFunctions = ast.runtimeFunctions
|
||||
.filter((fn) => fn.runtime === "client" || fn.runtime === "shared" || fn.runtime === "legacy")
|
||||
.filter((fn) => fn.runtime === "client" || fn.runtime === "shared")
|
||||
.map((fn) => ` ${member(fn.name)}(${params(fn.parameters)}): ${fn.returnType ?? (fn.async ? "Promise<unknown>" : "unknown")};`)
|
||||
.join("\n");
|
||||
const serverFunctions = ast.runtimeFunctions
|
||||
@@ -7973,7 +7971,7 @@ function parseRuntimeFunctions(source) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
let runtime = "legacy";
|
||||
let runtime = "shared";
|
||||
if (["client", "server", "shared"].includes(token.word)) {
|
||||
runtime = token.word;
|
||||
i = skipTrivia(source, token.end);
|
||||
|
||||
Reference in New Issue
Block a user