@vitejs/plugin-rsc 0.5.21 → 0.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-CUMAmYC3.d.ts +6 -0
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +1 -3
- package/dist/{chunk-f2BShn47.js → chunk-BYIdrdsR.js} +8 -14
- package/dist/cjs-BdahOUyh.js +115 -0
- package/dist/core/browser.d.ts +1 -5
- package/dist/core/browser.js +3 -5
- package/dist/core/plugin.js +1 -2
- package/dist/core/rsc.d.ts +1 -1
- package/dist/core/rsc.js +4 -6
- package/dist/core/ssr.d.ts +1 -1
- package/dist/core/ssr.js +3 -5
- package/dist/{dist-yW9-EeG1.js → dist-rz-Bnebz.js} +1 -2
- package/dist/{encryption-utils-Bk5eKdu6.js → encryption-utils-BblioYEx.js} +1 -2
- package/dist/{server-action-B2zS9t-J.d.ts → index-2GoUFmVR.d.ts} +34 -1
- package/dist/index-D2a5dlVU.d.ts +70 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.js +2 -6
- package/dist/{picocolors-B0A1T24z.js → picocolors-B6RAUUd2.js} +2 -5
- package/dist/plugin-DGxRH4Nv.d.ts +185 -0
- package/dist/plugin-DMfc_Eqq.js +1944 -0
- package/dist/plugin.d.ts +2 -179
- package/dist/plugin.js +2 -1468
- package/dist/plugins/cjs.js +2 -64
- package/dist/react/browser.d.ts +6 -6
- package/dist/react/browser.js +1 -3
- package/dist/react/rsc.d.ts +7 -6
- package/dist/react/rsc.js +2 -6
- package/dist/react/ssr.d.ts +2 -1
- package/dist/react/ssr.js +1 -3
- package/dist/rsc.d.ts +1 -3
- package/dist/rsc.js +2 -4
- package/dist/scope-DKCDtt0O.js +211 -0
- package/dist/{shared-Dhw3vs8e.js → shared-BViDMJTQ.js} +2 -3
- package/dist/{shared-d80_k_tn.js → shared-DeahDSXi.js} +1 -2
- package/dist/ssr.d.ts +1 -3
- package/dist/ssr.js +2 -4
- package/dist/transforms/index.d.ts +2 -2
- package/dist/transforms/index.js +367 -3
- package/dist/utils/encryption-runtime.js +3 -5
- package/dist/utils/rpc.js +1 -3
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.development.js +2 -2
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.development.js +3 -6
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.production.js +3 -6
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.development.js +3 -6
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.production.js +3 -6
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.development.js +3 -6
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.production.js +3 -6
- package/dist/vendor/react-server-dom/package.json +3 -3
- package/package.json +12 -13
- package/dist/cjs-v2jRTNln.js +0 -59
- package/dist/import-environment-B994HXEc.d.ts +0 -11
- package/dist/index-BIbdRBfk.d.ts +0 -26
- package/dist/server-action-JkEy-6yW.js +0 -344
- package/dist/validate-import-DJumtHRw.js +0 -498
package/dist/transforms/index.js
CHANGED
|
@@ -1,3 +1,367 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { i as tinyassert } from "../dist-rz-Bnebz.js";
|
|
2
|
+
import { a as hasDirective, i as getExportNames, n as extractIdentifiers, o as validateNonAsyncFunction, r as extractNames, t as buildScopeTree } from "../scope-DKCDtt0O.js";
|
|
3
|
+
import MagicString from "magic-string";
|
|
4
|
+
import { walk } from "estree-walker";
|
|
5
|
+
//#region src/transforms/hoist.ts
|
|
6
|
+
function transformHoistInlineDirective(input, ast, { runtime, rejectNonAsyncFunction, ...options }) {
|
|
7
|
+
if (!input.endsWith("\n")) input += "\n";
|
|
8
|
+
const output = new MagicString(input);
|
|
9
|
+
const directive = typeof options.directive === "string" ? exactRegex(options.directive) : options.directive;
|
|
10
|
+
const scopeTree = buildScopeTree(ast);
|
|
11
|
+
const names = [];
|
|
12
|
+
walk(ast, { enter(node, parent) {
|
|
13
|
+
if ((node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression") && node.body.type === "BlockStatement") {
|
|
14
|
+
const match = matchDirective(node.body.body, directive)?.match;
|
|
15
|
+
if (!match) return;
|
|
16
|
+
if (!node.async && rejectNonAsyncFunction) throw Object.assign(/* @__PURE__ */ new Error(`"${directive}" doesn't allow non async function`), { pos: node.start });
|
|
17
|
+
const declName = node.type === "FunctionDeclaration" && node.id.name;
|
|
18
|
+
const originalName = declName || parent?.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.id.name || "anonymous_server_function";
|
|
19
|
+
const bindVars = getBindVars(node, scopeTree);
|
|
20
|
+
let newParams = [...bindVars.map((b) => b.root), ...node.params.map((n) => input.slice(n.start, n.end))].join(", ");
|
|
21
|
+
if (bindVars.length > 0 && options.decode) {
|
|
22
|
+
newParams = ["$$hoist_encoded", ...node.params.map((n) => input.slice(n.start, n.end))].join(", ");
|
|
23
|
+
output.appendLeft(node.body.body[0].start, `const [${bindVars.map((b) => b.root).join(",")}] = ${options.decode("$$hoist_encoded")};\n`);
|
|
24
|
+
}
|
|
25
|
+
const newName = `$$hoist_${names.length}` + (originalName ? `_${originalName}` : "");
|
|
26
|
+
names.push(newName);
|
|
27
|
+
output.update(node.start, node.body.start, `\n;${options.noExport ? "" : "export "}${node.async ? "async " : ""}function ${newName}(${newParams}) `);
|
|
28
|
+
output.appendLeft(node.end, `;\n/* #__PURE__ */ Object.defineProperty(${newName}, "name", { value: ${JSON.stringify(originalName)} });\n`);
|
|
29
|
+
output.move(node.start, node.end, input.length);
|
|
30
|
+
let newCode = `/* #__PURE__ */ ${runtime(newName, newName, { directiveMatch: match })}`;
|
|
31
|
+
if (bindVars.length > 0) {
|
|
32
|
+
const bindArgs = options.encode ? options.encode("[" + bindVars.map((b) => b.expr).join(", ") + "]") : bindVars.map((b) => b.expr).join(", ");
|
|
33
|
+
newCode = `${newCode}.bind(null, ${bindArgs})`;
|
|
34
|
+
}
|
|
35
|
+
if (declName) {
|
|
36
|
+
newCode = `const ${declName} = ${newCode};`;
|
|
37
|
+
if (parent?.type === "ExportDefaultDeclaration") {
|
|
38
|
+
output.remove(parent.start, node.start);
|
|
39
|
+
newCode = `${newCode}\nexport default ${declName};`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
output.appendLeft(node.start, newCode);
|
|
43
|
+
}
|
|
44
|
+
} });
|
|
45
|
+
return {
|
|
46
|
+
output,
|
|
47
|
+
names
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const exactRegex = (s) => new RegExp("^" + s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") + "$");
|
|
51
|
+
function matchDirective(body, directive) {
|
|
52
|
+
for (const stmt of body) if (stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string") {
|
|
53
|
+
const match = stmt.expression.value.match(directive);
|
|
54
|
+
if (match) return {
|
|
55
|
+
match,
|
|
56
|
+
node: stmt.expression
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function findDirectives(ast, directive) {
|
|
61
|
+
const directiveRE = exactRegex(directive);
|
|
62
|
+
const nodes = [];
|
|
63
|
+
walk(ast, { enter(node) {
|
|
64
|
+
if (node.type === "Program" || node.type === "BlockStatement") {
|
|
65
|
+
const match = matchDirective(node.body, directiveRE);
|
|
66
|
+
if (match) nodes.push(match.node);
|
|
67
|
+
}
|
|
68
|
+
} });
|
|
69
|
+
return nodes;
|
|
70
|
+
}
|
|
71
|
+
function getBindVars(fn, scopeTree) {
|
|
72
|
+
const fnScope = scopeTree.nodeScope.get(fn);
|
|
73
|
+
const ancestorScopes = fnScope.getAncestorScopes();
|
|
74
|
+
const bindReferences = (scopeTree.scopeToReferences.get(fnScope) ?? []).filter((id) => {
|
|
75
|
+
const scope = scopeTree.referenceToDeclaredScope.get(id);
|
|
76
|
+
return scope && scope !== scopeTree.moduleScope && ancestorScopes.has(scope);
|
|
77
|
+
});
|
|
78
|
+
const accessMap = {};
|
|
79
|
+
for (const id of bindReferences) {
|
|
80
|
+
const name = id.name;
|
|
81
|
+
const node = scopeTree.referenceToNode.get(id);
|
|
82
|
+
if (node.type === "Identifier") {
|
|
83
|
+
accessMap[name] = { kind: "bare" };
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
accessMap[name] ??= {
|
|
87
|
+
kind: "paths",
|
|
88
|
+
paths: []
|
|
89
|
+
};
|
|
90
|
+
const entry = accessMap[name];
|
|
91
|
+
if (entry.kind === "paths") {
|
|
92
|
+
const path = memberExpressionToPath(node);
|
|
93
|
+
if (!entry.paths.some((existing) => existing.key === path.key)) entry.paths.push(path);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const result = [];
|
|
97
|
+
for (const [root, entry] of Object.entries(accessMap)) {
|
|
98
|
+
if (entry.kind === "bare") {
|
|
99
|
+
result.push({
|
|
100
|
+
root,
|
|
101
|
+
expr: root
|
|
102
|
+
});
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
result.push({
|
|
106
|
+
root,
|
|
107
|
+
expr: synthesizePartialObject(root, entry.paths)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
function memberExpressionToPath(node) {
|
|
113
|
+
const segments = [];
|
|
114
|
+
let current = node;
|
|
115
|
+
while (current.type === "MemberExpression") {
|
|
116
|
+
tinyassert(current.property.type === "Identifier");
|
|
117
|
+
segments.unshift(current.property.name);
|
|
118
|
+
tinyassert(current.object.type === "Identifier" || current.object.type === "MemberExpression");
|
|
119
|
+
current = current.object;
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
key: segments.join("."),
|
|
123
|
+
segments
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function synthesizePartialObject(root, bindPaths) {
|
|
127
|
+
const trie = /* @__PURE__ */ new Map();
|
|
128
|
+
const paths = dedupeByPrefix(bindPaths.map((p) => p.segments));
|
|
129
|
+
for (const path of paths) {
|
|
130
|
+
let node = trie;
|
|
131
|
+
for (let i = 0; i < path.length; i++) {
|
|
132
|
+
const segment = path[i];
|
|
133
|
+
let child = node.get(segment);
|
|
134
|
+
if (!child) {
|
|
135
|
+
child = /* @__PURE__ */ new Map();
|
|
136
|
+
node.set(segment, child);
|
|
137
|
+
}
|
|
138
|
+
node = child;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function serialize(node, segments) {
|
|
142
|
+
if (node.size === 0) return root + segments.map((segment) => `.${segment}`).join("");
|
|
143
|
+
const entries = [];
|
|
144
|
+
for (const [key, child] of node) {
|
|
145
|
+
const safeKey = key === "__proto__" ? `["__proto__"]` : key;
|
|
146
|
+
entries.push(`${safeKey}: ${serialize(child, [...segments, key])}`);
|
|
147
|
+
}
|
|
148
|
+
return `{ ${entries.join(", ")} }`;
|
|
149
|
+
}
|
|
150
|
+
return serialize(trie, []);
|
|
151
|
+
}
|
|
152
|
+
function dedupeByPrefix(paths) {
|
|
153
|
+
const sorted = [...paths].sort((a, b) => a.length - b.length);
|
|
154
|
+
const result = [];
|
|
155
|
+
for (const path of sorted) if (!result.some((existingPath) => existingPath.every((segment, i) => segment === path[i]))) result.push(path);
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/transforms/wrap-export.ts
|
|
160
|
+
function transformWrapExport(input, ast, options) {
|
|
161
|
+
const output = new MagicString(input);
|
|
162
|
+
const exportNames = [];
|
|
163
|
+
const toAppend = [];
|
|
164
|
+
const filter = options.filter ?? (() => true);
|
|
165
|
+
function wrapSimple(start, end, exports) {
|
|
166
|
+
exportNames.push(...exports.map((e) => e.name));
|
|
167
|
+
const newCode = exports.map((e) => [filter(e.name, e.meta) && `${e.name} = /* #__PURE__ */ ${options.runtime(e.name, e.name, e.meta)};\n`, `export { ${e.name} };\n`]).flat().filter(Boolean).join("");
|
|
168
|
+
output.update(start, end, newCode);
|
|
169
|
+
output.move(start, end, input.length);
|
|
170
|
+
}
|
|
171
|
+
function wrapExport(name, exportName, meta = {}) {
|
|
172
|
+
exportNames.push(exportName);
|
|
173
|
+
if (!filter(exportName, meta)) {
|
|
174
|
+
toAppend.push(`export { ${name} as ${exportName} }`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
toAppend.push(`const $$wrap_${name} = /* #__PURE__ */ ${options.runtime(name, exportName, meta)}`, `export { $$wrap_${name} as ${exportName} }`);
|
|
178
|
+
}
|
|
179
|
+
for (const node of ast.body) {
|
|
180
|
+
if (node.type === "ExportNamedDeclaration") if (node.declaration) if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
|
|
181
|
+
/**
|
|
182
|
+
* export function foo() {}
|
|
183
|
+
*/
|
|
184
|
+
validateNonAsyncFunction(options, node.declaration);
|
|
185
|
+
const name = node.declaration.id.name;
|
|
186
|
+
wrapSimple(node.start, node.declaration.start, [{
|
|
187
|
+
name,
|
|
188
|
+
meta: {
|
|
189
|
+
isFunction: true,
|
|
190
|
+
declName: name
|
|
191
|
+
}
|
|
192
|
+
}]);
|
|
193
|
+
} else if (node.declaration.type === "VariableDeclaration") {
|
|
194
|
+
/**
|
|
195
|
+
* export const foo = 1, bar = 2
|
|
196
|
+
*/
|
|
197
|
+
for (const decl of node.declaration.declarations) if (decl.init) validateNonAsyncFunction(options, decl.init);
|
|
198
|
+
if (node.declaration.kind === "const") output.update(node.declaration.start, node.declaration.start + 5, "let");
|
|
199
|
+
const names = node.declaration.declarations.flatMap((decl) => extractNames(decl.id));
|
|
200
|
+
let isFunction = false;
|
|
201
|
+
if (node.declaration.declarations.length === 1) {
|
|
202
|
+
const decl = node.declaration.declarations[0];
|
|
203
|
+
isFunction = decl.id.type === "Identifier" && (decl.init?.type === "ArrowFunctionExpression" || decl.init?.type === "FunctionExpression");
|
|
204
|
+
}
|
|
205
|
+
wrapSimple(node.start, node.declaration.start, names.map((name) => ({
|
|
206
|
+
name,
|
|
207
|
+
meta: {
|
|
208
|
+
isFunction,
|
|
209
|
+
declName: name
|
|
210
|
+
}
|
|
211
|
+
})));
|
|
212
|
+
} else node.declaration;
|
|
213
|
+
else if (node.source) {
|
|
214
|
+
/**
|
|
215
|
+
* export { foo, bar as car } from './foo'
|
|
216
|
+
*/
|
|
217
|
+
output.remove(node.start, node.end);
|
|
218
|
+
for (const spec of node.specifiers) {
|
|
219
|
+
tinyassert(spec.local.type === "Identifier");
|
|
220
|
+
tinyassert(spec.exported.type === "Identifier");
|
|
221
|
+
const name = spec.local.name;
|
|
222
|
+
toAppend.push(`import { ${name} as $$import_${name} } from ${node.source.raw}`);
|
|
223
|
+
wrapExport(`$$import_${name}`, spec.exported.name);
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
/**
|
|
227
|
+
* export { foo, bar as car }
|
|
228
|
+
*/
|
|
229
|
+
output.remove(node.start, node.end);
|
|
230
|
+
for (const spec of node.specifiers) {
|
|
231
|
+
tinyassert(spec.local.type === "Identifier");
|
|
232
|
+
tinyassert(spec.exported.type === "Identifier");
|
|
233
|
+
wrapExport(spec.local.name, spec.exported.name);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* export * from './foo'
|
|
238
|
+
*/
|
|
239
|
+
if (!options.ignoreExportAllDeclaration && node.type === "ExportAllDeclaration") throw Object.assign(/* @__PURE__ */ new Error("unsupported ExportAllDeclaration"), { pos: node.start });
|
|
240
|
+
/**
|
|
241
|
+
* export default function foo() {}
|
|
242
|
+
* export default class Foo {}
|
|
243
|
+
* export default () => {}
|
|
244
|
+
*/
|
|
245
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
246
|
+
validateNonAsyncFunction(options, node.declaration);
|
|
247
|
+
let localName;
|
|
248
|
+
let isFunction = false;
|
|
249
|
+
let declName;
|
|
250
|
+
let defaultExportIdentifierName;
|
|
251
|
+
if ((node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") && node.declaration.id) {
|
|
252
|
+
localName = node.declaration.id.name;
|
|
253
|
+
output.remove(node.start, node.declaration.start);
|
|
254
|
+
isFunction = node.declaration.type === "FunctionDeclaration";
|
|
255
|
+
declName = node.declaration.id.name;
|
|
256
|
+
} else {
|
|
257
|
+
localName = "$$default";
|
|
258
|
+
output.update(node.start, node.declaration.start, "const $$default = ");
|
|
259
|
+
if (node.declaration.type === "Identifier") defaultExportIdentifierName = node.declaration.name;
|
|
260
|
+
}
|
|
261
|
+
wrapExport(localName, "default", {
|
|
262
|
+
isFunction,
|
|
263
|
+
declName,
|
|
264
|
+
defaultExportIdentifierName
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (toAppend.length > 0) output.append([
|
|
269
|
+
"",
|
|
270
|
+
...toAppend,
|
|
271
|
+
""
|
|
272
|
+
].join(";\n"));
|
|
273
|
+
return {
|
|
274
|
+
exportNames,
|
|
275
|
+
output
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/transforms/proxy-export.ts
|
|
280
|
+
function transformDirectiveProxyExport(ast, options) {
|
|
281
|
+
if (!hasDirective(ast.body, options.directive)) return;
|
|
282
|
+
return transformProxyExport(ast, options);
|
|
283
|
+
}
|
|
284
|
+
function transformProxyExport(ast, options) {
|
|
285
|
+
if (options.keep && typeof options.code !== "string") throw new Error("`keep` option requires `code`");
|
|
286
|
+
const output = new MagicString(options.code ?? " ".repeat(ast.end));
|
|
287
|
+
const exportNames = [];
|
|
288
|
+
function createExport(node, names) {
|
|
289
|
+
exportNames.push(...names);
|
|
290
|
+
const newCode = names.map((name) => (name === "default" ? `export default` : `export const ${name} =`) + ` /* #__PURE__ */ ${options.runtime(name)};\n`).join("");
|
|
291
|
+
output.update(node.start, node.end, newCode);
|
|
292
|
+
}
|
|
293
|
+
for (const node of ast.body) {
|
|
294
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
295
|
+
if (node.declaration) if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
|
|
296
|
+
/**
|
|
297
|
+
* export function foo() {}
|
|
298
|
+
*/
|
|
299
|
+
validateNonAsyncFunction(options, node.declaration);
|
|
300
|
+
createExport(node, [node.declaration.id.name]);
|
|
301
|
+
} else if (node.declaration.type === "VariableDeclaration") {
|
|
302
|
+
/**
|
|
303
|
+
* export const foo = 1, bar = 2
|
|
304
|
+
*/
|
|
305
|
+
for (const decl of node.declaration.declarations) if (decl.init) validateNonAsyncFunction(options, decl.init);
|
|
306
|
+
if (options.keep && options.code) {
|
|
307
|
+
if (node.declaration.declarations.length === 1) {
|
|
308
|
+
const decl = node.declaration.declarations[0];
|
|
309
|
+
if (decl.id.type === "Identifier" && decl.init) {
|
|
310
|
+
const name = decl.id.name;
|
|
311
|
+
const value = options.code.slice(decl.init.start, decl.init.end);
|
|
312
|
+
const newCode = `export const ${name} = /* #__PURE__ */ ${options.runtime(name, { value })};`;
|
|
313
|
+
output.update(node.start, node.end, newCode);
|
|
314
|
+
exportNames.push(name);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
createExport(node, node.declaration.declarations.flatMap((decl) => extractNames(decl.id)));
|
|
320
|
+
} else node.declaration;
|
|
321
|
+
else {
|
|
322
|
+
/**
|
|
323
|
+
* export { foo, bar as car } from './foo'
|
|
324
|
+
* export { foo, bar as car }
|
|
325
|
+
*/
|
|
326
|
+
const names = [];
|
|
327
|
+
for (const spec of node.specifiers) {
|
|
328
|
+
tinyassert(spec.exported.type === "Identifier");
|
|
329
|
+
names.push(spec.exported.name);
|
|
330
|
+
}
|
|
331
|
+
createExport(node, names);
|
|
332
|
+
}
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* export * from './foo'
|
|
337
|
+
*/
|
|
338
|
+
if (!options.ignoreExportAllDeclaration && node.type === "ExportAllDeclaration") throw new Error("unsupported ExportAllDeclaration");
|
|
339
|
+
/**
|
|
340
|
+
* export default function foo() {}
|
|
341
|
+
* export default class Foo {}
|
|
342
|
+
* export default () => {}
|
|
343
|
+
*/
|
|
344
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
345
|
+
validateNonAsyncFunction(options, node.declaration);
|
|
346
|
+
createExport(node, ["default"]);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (options.keep) continue;
|
|
350
|
+
output.remove(node.start, node.end);
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
exportNames,
|
|
354
|
+
output
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/transforms/server-action.ts
|
|
359
|
+
function transformServerActionServer(input, ast, options) {
|
|
360
|
+
if (hasDirective(ast.body, "use server")) return transformWrapExport(input, ast, options);
|
|
361
|
+
return transformHoistInlineDirective(input, ast, {
|
|
362
|
+
...options,
|
|
363
|
+
directive: "use server"
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
367
|
+
export { extractIdentifiers, extractNames, findDirectives, getExportNames, hasDirective, transformDirectiveProxyExport, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { r as once } from "../dist-
|
|
2
|
-
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-
|
|
1
|
+
import { r as once } from "../dist-rz-Bnebz.js";
|
|
2
|
+
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-BblioYEx.js";
|
|
3
3
|
import { createFromReadableStream, renderToReadableStream } from "../react/rsc.js";
|
|
4
4
|
import encryptionKeySource from "virtual:vite-rsc/encryption-key";
|
|
5
|
-
|
|
6
5
|
//#region src/utils/encryption-runtime.ts
|
|
7
6
|
async function encryptActionBoundArgs(originalValue) {
|
|
8
7
|
return encryptBuffer(await concatArrayStream(renderToReadableStream(originalValue)), await getEncryptionKey());
|
|
@@ -15,6 +14,5 @@ const getEncryptionKey = /* @__PURE__ */ once(async () => {
|
|
|
15
14
|
const resolved = await encryptionKeySource();
|
|
16
15
|
return await crypto.subtle.importKey("raw", fromBase64(resolved), { name: "AES-GCM" }, true, ["encrypt", "decrypt"]);
|
|
17
16
|
});
|
|
18
|
-
|
|
19
17
|
//#endregion
|
|
20
|
-
export { decryptActionBoundArgs, encryptActionBoundArgs };
|
|
18
|
+
export { decryptActionBoundArgs, encryptActionBoundArgs };
|
package/dist/utils/rpc.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { decode, encode } from "turbo-stream";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/rpc.ts
|
|
4
3
|
const decodePlugins = [(type, ...rest) => {
|
|
5
4
|
switch (type) {
|
|
@@ -86,6 +85,5 @@ function createRpcClient(options) {
|
|
|
86
85
|
return (...args) => callRpc(p, args);
|
|
87
86
|
} });
|
|
88
87
|
}
|
|
89
|
-
|
|
90
88
|
//#endregion
|
|
91
|
-
export { createRpcClient, createRpcServer };
|
|
89
|
+
export { createRpcClient, createRpcServer };
|
package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.development.js
CHANGED
|
@@ -4901,10 +4901,10 @@
|
|
|
4901
4901
|
return hook.checkDCE ? !0 : !1;
|
|
4902
4902
|
})({
|
|
4903
4903
|
bundleType: 1,
|
|
4904
|
-
version: "19.2.
|
|
4904
|
+
version: "19.2.5",
|
|
4905
4905
|
rendererPackageName: "react-server-dom-webpack",
|
|
4906
4906
|
currentDispatcherRef: ReactSharedInternals,
|
|
4907
|
-
reconcilerVersion: "19.2.
|
|
4907
|
+
reconcilerVersion: "19.2.5",
|
|
4908
4908
|
getCurrentComponentInfo: function () {
|
|
4909
4909
|
return currentOwnerInDEV;
|
|
4910
4910
|
}
|
package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.development.js
CHANGED
|
@@ -4394,23 +4394,20 @@
|
|
|
4394
4394
|
function createMap(response, model) {
|
|
4395
4395
|
if (!isArrayImpl(model)) throw Error("Invalid Map initializer.");
|
|
4396
4396
|
if (!0 === model.$$consumed) throw Error("Already initialized Map.");
|
|
4397
|
-
response = new Map(model);
|
|
4398
4397
|
model.$$consumed = !0;
|
|
4399
|
-
return
|
|
4398
|
+
return new Map(model);
|
|
4400
4399
|
}
|
|
4401
4400
|
function createSet(response, model) {
|
|
4402
4401
|
if (!isArrayImpl(model)) throw Error("Invalid Set initializer.");
|
|
4403
4402
|
if (!0 === model.$$consumed) throw Error("Already initialized Set.");
|
|
4404
|
-
response = new Set(model);
|
|
4405
4403
|
model.$$consumed = !0;
|
|
4406
|
-
return
|
|
4404
|
+
return new Set(model);
|
|
4407
4405
|
}
|
|
4408
4406
|
function extractIterator(response, model) {
|
|
4409
4407
|
if (!isArrayImpl(model)) throw Error("Invalid Iterator initializer.");
|
|
4410
4408
|
if (!0 === model.$$consumed) throw Error("Already initialized Iterator.");
|
|
4411
|
-
response = model[Symbol.iterator]();
|
|
4412
4409
|
model.$$consumed = !0;
|
|
4413
|
-
return
|
|
4410
|
+
return model[Symbol.iterator]();
|
|
4414
4411
|
}
|
|
4415
4412
|
function createModel(response, model, parentObject, key) {
|
|
4416
4413
|
return "then" === key && "function" === typeof model ? null : model;
|
package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.production.js
CHANGED
|
@@ -2807,23 +2807,20 @@ function getOutlinedModel(
|
|
|
2807
2807
|
function createMap(response, model) {
|
|
2808
2808
|
if (!isArrayImpl(model)) throw Error("Invalid Map initializer.");
|
|
2809
2809
|
if (!0 === model.$$consumed) throw Error("Already initialized Map.");
|
|
2810
|
-
response = new Map(model);
|
|
2811
2810
|
model.$$consumed = !0;
|
|
2812
|
-
return
|
|
2811
|
+
return new Map(model);
|
|
2813
2812
|
}
|
|
2814
2813
|
function createSet(response, model) {
|
|
2815
2814
|
if (!isArrayImpl(model)) throw Error("Invalid Set initializer.");
|
|
2816
2815
|
if (!0 === model.$$consumed) throw Error("Already initialized Set.");
|
|
2817
|
-
response = new Set(model);
|
|
2818
2816
|
model.$$consumed = !0;
|
|
2819
|
-
return
|
|
2817
|
+
return new Set(model);
|
|
2820
2818
|
}
|
|
2821
2819
|
function extractIterator(response, model) {
|
|
2822
2820
|
if (!isArrayImpl(model)) throw Error("Invalid Iterator initializer.");
|
|
2823
2821
|
if (!0 === model.$$consumed) throw Error("Already initialized Iterator.");
|
|
2824
|
-
response = model[Symbol.iterator]();
|
|
2825
2822
|
model.$$consumed = !0;
|
|
2826
|
-
return
|
|
2823
|
+
return model[Symbol.iterator]();
|
|
2827
2824
|
}
|
|
2828
2825
|
function createModel(response, model, parentObject, key) {
|
|
2829
2826
|
return "then" === key && "function" === typeof model ? null : model;
|
package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.development.js
CHANGED
|
@@ -4465,23 +4465,20 @@
|
|
|
4465
4465
|
function createMap(response, model) {
|
|
4466
4466
|
if (!isArrayImpl(model)) throw Error("Invalid Map initializer.");
|
|
4467
4467
|
if (!0 === model.$$consumed) throw Error("Already initialized Map.");
|
|
4468
|
-
response = new Map(model);
|
|
4469
4468
|
model.$$consumed = !0;
|
|
4470
|
-
return
|
|
4469
|
+
return new Map(model);
|
|
4471
4470
|
}
|
|
4472
4471
|
function createSet(response, model) {
|
|
4473
4472
|
if (!isArrayImpl(model)) throw Error("Invalid Set initializer.");
|
|
4474
4473
|
if (!0 === model.$$consumed) throw Error("Already initialized Set.");
|
|
4475
|
-
response = new Set(model);
|
|
4476
4474
|
model.$$consumed = !0;
|
|
4477
|
-
return
|
|
4475
|
+
return new Set(model);
|
|
4478
4476
|
}
|
|
4479
4477
|
function extractIterator(response, model) {
|
|
4480
4478
|
if (!isArrayImpl(model)) throw Error("Invalid Iterator initializer.");
|
|
4481
4479
|
if (!0 === model.$$consumed) throw Error("Already initialized Iterator.");
|
|
4482
|
-
response = model[Symbol.iterator]();
|
|
4483
4480
|
model.$$consumed = !0;
|
|
4484
|
-
return
|
|
4481
|
+
return model[Symbol.iterator]();
|
|
4485
4482
|
}
|
|
4486
4483
|
function createModel(response, model, parentObject, key) {
|
|
4487
4484
|
return "then" === key && "function" === typeof model ? null : model;
|
|
@@ -2803,23 +2803,20 @@ function getOutlinedModel(
|
|
|
2803
2803
|
function createMap(response, model) {
|
|
2804
2804
|
if (!isArrayImpl(model)) throw Error("Invalid Map initializer.");
|
|
2805
2805
|
if (!0 === model.$$consumed) throw Error("Already initialized Map.");
|
|
2806
|
-
response = new Map(model);
|
|
2807
2806
|
model.$$consumed = !0;
|
|
2808
|
-
return
|
|
2807
|
+
return new Map(model);
|
|
2809
2808
|
}
|
|
2810
2809
|
function createSet(response, model) {
|
|
2811
2810
|
if (!isArrayImpl(model)) throw Error("Invalid Set initializer.");
|
|
2812
2811
|
if (!0 === model.$$consumed) throw Error("Already initialized Set.");
|
|
2813
|
-
response = new Set(model);
|
|
2814
2812
|
model.$$consumed = !0;
|
|
2815
|
-
return
|
|
2813
|
+
return new Set(model);
|
|
2816
2814
|
}
|
|
2817
2815
|
function extractIterator(response, model) {
|
|
2818
2816
|
if (!isArrayImpl(model)) throw Error("Invalid Iterator initializer.");
|
|
2819
2817
|
if (!0 === model.$$consumed) throw Error("Already initialized Iterator.");
|
|
2820
|
-
response = model[Symbol.iterator]();
|
|
2821
2818
|
model.$$consumed = !0;
|
|
2822
|
-
return
|
|
2819
|
+
return model[Symbol.iterator]();
|
|
2823
2820
|
}
|
|
2824
2821
|
function createModel(response, model, parentObject, key) {
|
|
2825
2822
|
return "then" === key && "function" === typeof model ? null : model;
|
package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.development.js
CHANGED
|
@@ -4868,23 +4868,20 @@
|
|
|
4868
4868
|
function createMap(response, model) {
|
|
4869
4869
|
if (!isArrayImpl(model)) throw Error("Invalid Map initializer.");
|
|
4870
4870
|
if (!0 === model.$$consumed) throw Error("Already initialized Map.");
|
|
4871
|
-
response = new Map(model);
|
|
4872
4871
|
model.$$consumed = !0;
|
|
4873
|
-
return
|
|
4872
|
+
return new Map(model);
|
|
4874
4873
|
}
|
|
4875
4874
|
function createSet(response, model) {
|
|
4876
4875
|
if (!isArrayImpl(model)) throw Error("Invalid Set initializer.");
|
|
4877
4876
|
if (!0 === model.$$consumed) throw Error("Already initialized Set.");
|
|
4878
|
-
response = new Set(model);
|
|
4879
4877
|
model.$$consumed = !0;
|
|
4880
|
-
return
|
|
4878
|
+
return new Set(model);
|
|
4881
4879
|
}
|
|
4882
4880
|
function extractIterator(response, model) {
|
|
4883
4881
|
if (!isArrayImpl(model)) throw Error("Invalid Iterator initializer.");
|
|
4884
4882
|
if (!0 === model.$$consumed) throw Error("Already initialized Iterator.");
|
|
4885
|
-
response = model[Symbol.iterator]();
|
|
4886
4883
|
model.$$consumed = !0;
|
|
4887
|
-
return
|
|
4884
|
+
return model[Symbol.iterator]();
|
|
4888
4885
|
}
|
|
4889
4886
|
function createModel(response, model, parentObject, key) {
|
|
4890
4887
|
return "then" === key && "function" === typeof model ? null : model;
|
|
@@ -2832,23 +2832,20 @@ function getOutlinedModel(
|
|
|
2832
2832
|
function createMap(response, model) {
|
|
2833
2833
|
if (!isArrayImpl(model)) throw Error("Invalid Map initializer.");
|
|
2834
2834
|
if (!0 === model.$$consumed) throw Error("Already initialized Map.");
|
|
2835
|
-
response = new Map(model);
|
|
2836
2835
|
model.$$consumed = !0;
|
|
2837
|
-
return
|
|
2836
|
+
return new Map(model);
|
|
2838
2837
|
}
|
|
2839
2838
|
function createSet(response, model) {
|
|
2840
2839
|
if (!isArrayImpl(model)) throw Error("Invalid Set initializer.");
|
|
2841
2840
|
if (!0 === model.$$consumed) throw Error("Already initialized Set.");
|
|
2842
|
-
response = new Set(model);
|
|
2843
2841
|
model.$$consumed = !0;
|
|
2844
|
-
return
|
|
2842
|
+
return new Set(model);
|
|
2845
2843
|
}
|
|
2846
2844
|
function extractIterator(response, model) {
|
|
2847
2845
|
if (!isArrayImpl(model)) throw Error("Invalid Iterator initializer.");
|
|
2848
2846
|
if (!0 === model.$$consumed) throw Error("Already initialized Iterator.");
|
|
2849
|
-
response = model[Symbol.iterator]();
|
|
2850
2847
|
model.$$consumed = !0;
|
|
2851
|
-
return
|
|
2848
|
+
return model[Symbol.iterator]();
|
|
2852
2849
|
}
|
|
2853
2850
|
function createModel(response, model, parentObject, key) {
|
|
2854
2851
|
return "then" === key && "function" === typeof model ? null : model;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-server-dom-webpack",
|
|
3
3
|
"description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
|
|
4
|
-
"version": "19.2.
|
|
4
|
+
"version": "19.2.5",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react"
|
|
7
7
|
],
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"node": ">=0.10.0"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"react": "^19.2.
|
|
88
|
-
"react-dom": "^19.2.
|
|
87
|
+
"react": "^19.2.5",
|
|
88
|
+
"react-dom": "^19.2.5",
|
|
89
89
|
"webpack": "^5.59.0"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-rsc",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.23",
|
|
4
4
|
"description": "React Server Components (RSC) support for Vite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -39,33 +39,32 @@
|
|
|
39
39
|
"prepack": "tsdown"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@rolldown/pluginutils": "1.0.0-rc.
|
|
42
|
+
"@rolldown/pluginutils": "1.0.0-rc.13",
|
|
43
43
|
"es-module-lexer": "^2.0.0",
|
|
44
44
|
"estree-walker": "^3.0.3",
|
|
45
45
|
"magic-string": "^0.30.21",
|
|
46
|
-
"
|
|
47
|
-
"srvx": "^0.11.7",
|
|
46
|
+
"srvx": "^0.11.15",
|
|
48
47
|
"strip-literal": "^3.1.0",
|
|
49
|
-
"turbo-stream": "^3.
|
|
50
|
-
"vitefu": "^1.1.
|
|
48
|
+
"turbo-stream": "^3.2.0",
|
|
49
|
+
"vitefu": "^1.1.3"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
52
|
"@hiogawa/utils": "^1.7.0",
|
|
54
|
-
"@playwright/test": "^1.
|
|
53
|
+
"@playwright/test": "^1.59.1",
|
|
55
54
|
"@tsconfig/strictest": "^2.0.8",
|
|
56
55
|
"@types/estree": "^1.0.8",
|
|
57
|
-
"@types/node": "^24.
|
|
56
|
+
"@types/node": "^24.12.2",
|
|
58
57
|
"@types/react": "^19.2.14",
|
|
59
58
|
"@types/react-dom": "^19.2.3",
|
|
60
59
|
"@vitejs/plugin-react": "workspace:*",
|
|
61
60
|
"@vitejs/test-dep-cjs-and-esm": "./test-dep/cjs-and-esm",
|
|
62
61
|
"@vitejs/test-dep-cjs-falsy-primitive": "./test-dep/cjs-falsy-primitive",
|
|
63
62
|
"picocolors": "^1.1.1",
|
|
64
|
-
"react": "^19.2.
|
|
65
|
-
"react-dom": "^19.2.
|
|
66
|
-
"react-server-dom-webpack": "^19.2.
|
|
67
|
-
"tinyexec": "^1.0.
|
|
68
|
-
"tsdown": "^0.
|
|
63
|
+
"react": "^19.2.5",
|
|
64
|
+
"react-dom": "^19.2.5",
|
|
65
|
+
"react-server-dom-webpack": "^19.2.5",
|
|
66
|
+
"tinyexec": "^1.0.4",
|
|
67
|
+
"tsdown": "^0.21.7"
|
|
69
68
|
},
|
|
70
69
|
"peerDependencies": {
|
|
71
70
|
"react": "*",
|