@vitejs/plugin-rsc 0.5.34 → 0.5.35
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/README.md +15 -0
- package/dist/browser.d.ts +1 -1
- package/dist/{cjs-AWVWfddx.js → cjs-DhDj_zQT.js} +2 -2
- package/dist/client-Dq3oGLRS.d.ts +8 -0
- package/dist/{client-reference-DEZtXTv1.d.ts → client-reference-Bk5pzNGN.d.ts} +1 -1
- package/dist/client.node-BEQT2PT-.d.ts +9 -0
- package/dist/client.shared-D1HxyClg.js +10 -0
- package/dist/client.shared-VT232QCM.d.ts +16 -0
- package/dist/core/browser.js +1 -1
- package/dist/core/plugin.d.ts +2 -3
- package/dist/core/rsc.d.ts +1 -1
- package/dist/core/rsc.js +1 -1
- package/dist/core/ssr.d.ts +1 -7
- package/dist/core/ssr.js +1 -1
- package/dist/{index-C5IY2S-e.d.ts → index-CROaL0MT.d.ts} +34 -8
- package/dist/index.js +1 -1
- package/dist/{picocolors-391UXIDd.js → picocolors-DCTC64Zv.js} +1 -1
- package/dist/{plugin-Cbs9j6lP.js → plugin-CLvIS10V.js} +37 -27
- package/dist/plugin.js +1 -1
- package/dist/plugins/cjs.d.ts +2 -3
- package/dist/plugins/cjs.js +1 -1
- package/dist/react/browser.d.ts +10 -10
- package/dist/react/rsc/client.d.ts +1 -1
- package/dist/react/rsc/client.js +2 -5
- package/dist/react/rsc/client.node.d.ts +2 -0
- package/dist/react/rsc/client.node.js +16 -0
- package/dist/react/rsc/server.d.ts +2 -2
- package/dist/react/rsc/server.node.d.ts +3 -0
- package/dist/react/rsc/server.node.js +24 -0
- package/dist/react/rsc/static.d.ts +4 -5
- package/dist/react/rsc/static.node.d.ts +6 -0
- package/dist/react/rsc/static.node.js +11 -0
- package/dist/react/rsc.d.ts +3 -3
- package/dist/react/ssr.d.ts +9 -9
- package/dist/react/ssr.node.d.ts +12 -0
- package/dist/react/ssr.node.js +21 -0
- package/dist/rsc/client.d.ts +1 -1
- package/dist/rsc/client.node.d.ts +2 -0
- package/dist/rsc/client.node.js +3 -0
- package/dist/rsc/server.d.ts +5 -5
- package/dist/rsc/server.node.d.ts +19 -0
- package/dist/rsc/server.node.js +13 -0
- package/dist/rsc/static.d.ts +4 -5
- package/dist/rsc/static.node.d.ts +16 -0
- package/dist/rsc/static.node.js +12 -0
- package/dist/{rsc-C3UdJLOW.d.ts → rsc-D8UlANI2.d.ts} +1 -1
- package/dist/rsc.d.ts +3 -3
- package/dist/rsc.node.d.ts +6 -0
- package/dist/rsc.node.js +7 -0
- package/dist/{scope-Bdx33sQv.js → scope-Ck0n25my.js} +2 -4
- package/dist/{server-ZBjqNTqU.d.ts → server-YwgjVtsE.d.ts} +2 -2
- package/dist/server.node-DU77AeKU.d.ts +15 -0
- package/dist/shared-BWJvctW6.js +34 -0
- package/dist/shared-CXQb6hk9.js +89 -0
- package/dist/shared-DJBuYpZL.d.ts +20 -0
- package/dist/ssr-C-U7jY5S.d.ts +8 -0
- package/dist/ssr.d.ts +3 -21
- package/dist/ssr.js +1 -87
- package/dist/ssr.node.d.ts +5 -0
- package/dist/ssr.node.js +4 -0
- package/dist/transforms/index.js +67 -60
- package/dist/utils/encryption-runtime.d.ts +3 -4
- package/dist/utils/encryption-runtime.js +4 -2
- package/dist/utils/rpc.d.ts +3 -4
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.development.js +909 -495
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.production.js +399 -265
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.development.js +901 -477
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.production.js +380 -219
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.development.js +925 -484
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.production.js +385 -221
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.development.js +726 -388
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.production.js +566 -397
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.development.js +734 -397
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.production.js +477 -238
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.development.js +1029 -620
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.production.js +481 -261
- package/dist/vendor/react-server-dom/esm/react-server-dom-webpack-node-loader.production.js +2 -2
- package/dist/vendor/react-server-dom/package.json +3 -3
- package/package.json +15 -15
- package/dist/client-Bhch3O41.d.ts +0 -19
- package/dist/dist-uqdtSkzK.js +0 -64
package/dist/transforms/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as isDirective, i as hasDirective, n as extractIdentifiers, o as rejectNonAsyncFunction, r as extractNames, s as validateNonAsyncFunction, t as buildScopeTree } from "../scope-
|
|
1
|
+
import { r as tinyassert } from "../shared-BWJvctW6.js";
|
|
2
|
+
import { a as isDirective, i as hasDirective, n as extractIdentifiers, o as rejectNonAsyncFunction, r as extractNames, s as validateNonAsyncFunction, t as buildScopeTree } from "../scope-Ck0n25my.js";
|
|
3
3
|
import MagicString from "magic-string";
|
|
4
4
|
import { walk } from "estree-walker";
|
|
5
5
|
//#region src/transforms/hoist.ts
|
|
@@ -268,59 +268,61 @@ function dedupeByPrefix(paths) {
|
|
|
268
268
|
function scanModuleExports(viteAst) {
|
|
269
269
|
const ast = viteAst;
|
|
270
270
|
const groups = [];
|
|
271
|
-
for (const node of ast.body) if (node.type === "ExportNamedDeclaration")
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
271
|
+
for (const node of ast.body) if (node.type === "ExportNamedDeclaration") {
|
|
272
|
+
if (node.declaration) {
|
|
273
|
+
if (node.declaration.type === "VariableDeclaration") {
|
|
274
|
+
const declaration = node.declaration;
|
|
275
|
+
groups.push({
|
|
276
|
+
type: "variable-declaration",
|
|
277
|
+
node,
|
|
278
|
+
declaration,
|
|
279
|
+
declarators: declaration.declarations.map((declarator) => {
|
|
280
|
+
const isFunction = declarator.id.type === "Identifier" && declarator.init ? getIsFunction(declarator.init) : void 0;
|
|
281
|
+
return {
|
|
282
|
+
node: declarator,
|
|
283
|
+
exports: extractNames(declarator.id).map((name) => ({
|
|
284
|
+
localName: name,
|
|
285
|
+
exportName: name,
|
|
286
|
+
meta: {
|
|
287
|
+
declName: name,
|
|
288
|
+
isFunction,
|
|
289
|
+
valueNode: declarator.init ?? void 0
|
|
290
|
+
}
|
|
291
|
+
}))
|
|
292
|
+
};
|
|
293
|
+
})
|
|
294
|
+
});
|
|
295
|
+
} else {
|
|
296
|
+
tinyassert(node.declaration.id);
|
|
297
|
+
const name = node.declaration.id.name;
|
|
298
|
+
groups.push({
|
|
299
|
+
type: "declaration",
|
|
300
|
+
node,
|
|
301
|
+
declaration: node.declaration,
|
|
302
|
+
export: {
|
|
282
303
|
localName: name,
|
|
283
304
|
exportName: name,
|
|
284
305
|
meta: {
|
|
285
306
|
declName: name,
|
|
286
|
-
isFunction,
|
|
287
|
-
valueNode:
|
|
307
|
+
isFunction: getIsFunction(node.declaration),
|
|
308
|
+
valueNode: node.declaration
|
|
288
309
|
}
|
|
289
|
-
}
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
} else groups.push({
|
|
314
|
+
type: "specifiers",
|
|
315
|
+
node,
|
|
316
|
+
exports: node.specifiers.map((specifier) => {
|
|
317
|
+
return {
|
|
318
|
+
node: specifier,
|
|
319
|
+
localName: specifier.local.type === "Identifier" ? specifier.local.name : "__unsupported_string_export__",
|
|
320
|
+
exportName: specifier.exported.type === "Identifier" ? specifier.exported.name : "__unsupported_string_export__",
|
|
321
|
+
meta: {}
|
|
290
322
|
};
|
|
291
323
|
})
|
|
292
324
|
});
|
|
293
|
-
} else {
|
|
294
|
-
tinyassert(node.declaration.id);
|
|
295
|
-
const name = node.declaration.id.name;
|
|
296
|
-
groups.push({
|
|
297
|
-
type: "declaration",
|
|
298
|
-
node,
|
|
299
|
-
declaration: node.declaration,
|
|
300
|
-
export: {
|
|
301
|
-
localName: name,
|
|
302
|
-
exportName: name,
|
|
303
|
-
meta: {
|
|
304
|
-
declName: name,
|
|
305
|
-
isFunction: getIsFunction(node.declaration),
|
|
306
|
-
valueNode: node.declaration
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
else groups.push({
|
|
312
|
-
type: "specifiers",
|
|
313
|
-
node,
|
|
314
|
-
exports: node.specifiers.map((specifier) => {
|
|
315
|
-
return {
|
|
316
|
-
node: specifier,
|
|
317
|
-
localName: specifier.local.type === "Identifier" ? specifier.local.name : "__unsupported_string_export__",
|
|
318
|
-
exportName: specifier.exported.type === "Identifier" ? specifier.exported.name : "__unsupported_string_export__",
|
|
319
|
-
meta: {}
|
|
320
|
-
};
|
|
321
|
-
})
|
|
322
|
-
});
|
|
323
|
-
else if (node.type === "ExportAllDeclaration") groups.push({
|
|
325
|
+
} else if (node.type === "ExportAllDeclaration") groups.push({
|
|
324
326
|
type: "export-all",
|
|
325
327
|
node
|
|
326
328
|
});
|
|
@@ -589,8 +591,10 @@ function transformWrapExport(input, viteAst, options) {
|
|
|
589
591
|
const selectedExportNames = new Set(exports.filter((entry) => filter(entry.exportName, entry.meta)).map((entry) => entry.exportName));
|
|
590
592
|
if (selectedExportNames.size === 0) continue;
|
|
591
593
|
if (group.declaration.kind === "const") output.update(group.declaration.start, group.declaration.start + 5, "let");
|
|
592
|
-
for (const declarator of group.declarators) if (declarator.exports.some(({ exportName }) => selectedExportNames.has(exportName)))
|
|
593
|
-
|
|
594
|
+
for (const declarator of group.declarators) if (declarator.exports.some(({ exportName }) => selectedExportNames.has(exportName))) {
|
|
595
|
+
if (declarator.node.init) validateNonAsyncFunction(options, declarator.node.init);
|
|
596
|
+
else rejectNonAsyncFunction(options, declarator.node.start);
|
|
597
|
+
}
|
|
594
598
|
emitWrappedAssignments(group.node.start, group.declaration.start, exports, selectedExportNames);
|
|
595
599
|
} else if (group.type === "specifiers") {
|
|
596
600
|
const skippedExports = [];
|
|
@@ -729,10 +733,12 @@ function transformProxyExport(viteAst, options) {
|
|
|
729
733
|
else removeNode(node);
|
|
730
734
|
} else if (!options.ignoreExportAllDeclaration) throw new Error("unsupported ExportAllDeclaration");
|
|
731
735
|
else if (!options.keep) removeNode(node);
|
|
732
|
-
} else if (group.type === "default")
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
+
} else if (group.type === "default") {
|
|
737
|
+
if (filter("default", group.meta)) {
|
|
738
|
+
validateNonAsyncFunction(options, group.node.declaration);
|
|
739
|
+
createExport(node, ["default"]);
|
|
740
|
+
} else removeNode(node);
|
|
741
|
+
}
|
|
736
742
|
}
|
|
737
743
|
if (!options.keep) {
|
|
738
744
|
for (const node of ast.body) if (!exportNodes.has(node)) removeNode(node);
|
|
@@ -810,13 +816,14 @@ async function collectExportScan(resolvedId, context, seen) {
|
|
|
810
816
|
}
|
|
811
817
|
function collectExplicitExportNames(ast) {
|
|
812
818
|
const names = /* @__PURE__ */ new Set();
|
|
813
|
-
for (const node of ast.body) if (node.type === "ExportNamedDeclaration")
|
|
814
|
-
if (node.declaration
|
|
815
|
-
if (node.declaration.
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
819
|
+
for (const node of ast.body) if (node.type === "ExportNamedDeclaration") {
|
|
820
|
+
if (node.declaration) {
|
|
821
|
+
if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
|
|
822
|
+
if (node.declaration.id) names.add(node.declaration.id.name);
|
|
823
|
+
} else if (node.declaration.type === "VariableDeclaration") for (const decl of node.declaration.declarations) for (const name of extractNames(decl.id)) names.add(name);
|
|
824
|
+
} else for (const spec of node.specifiers) if (spec.exported.type === "Identifier") names.add(spec.exported.name);
|
|
825
|
+
else throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
|
|
826
|
+
} else if (node.type === "ExportDefaultDeclaration") names.add("default");
|
|
820
827
|
else if (node.type === "ExportAllDeclaration") {
|
|
821
828
|
if (node.exported?.type === "Identifier") names.add(node.exported.name);
|
|
822
829
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/utils/encryption-runtime.d.ts
|
|
2
|
-
declare function encryptActionBoundArgs(originalValue: unknown): Promise<string>;
|
|
3
|
-
declare function decryptActionBoundArgs(encrypted: ReturnType<typeof encryptActionBoundArgs>): Promise<unknown>;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { decryptActionBoundArgs, encryptActionBoundArgs };
|
|
2
|
+
export declare function encryptActionBoundArgs(originalValue: unknown): Promise<string>;
|
|
3
|
+
export declare function decryptActionBoundArgs(encrypted: ReturnType<typeof encryptActionBoundArgs>): Promise<unknown>;
|
|
4
|
+
//#endregion
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as once } from "../shared-BWJvctW6.js";
|
|
2
2
|
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-BNbYHtC4.js";
|
|
3
3
|
import { renderToReadableStream } from "../react/rsc/server.js";
|
|
4
4
|
import encryptionKeySource from "virtual:vite-rsc/encryption-key";
|
|
5
5
|
//#region src/utils/encryption-runtime.ts
|
|
6
6
|
async function encryptActionBoundArgs(originalValue) {
|
|
7
|
-
|
|
7
|
+
const serialized = renderToReadableStream(originalValue);
|
|
8
|
+
const serializedBuffer = await concatArrayStream(serialized);
|
|
9
|
+
return encryptBuffer(serializedBuffer, await getEncryptionKey());
|
|
8
10
|
}
|
|
9
11
|
async function decryptActionBoundArgs(encrypted) {
|
|
10
12
|
const [{ createFromReadableStream }, serializedBuffer] = await Promise.all([import("../react/rsc/client.js"), decryptBuffer(await encrypted, await getEncryptionKey())]);
|
package/dist/utils/rpc.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
//#region src/utils/rpc.d.ts
|
|
2
|
-
declare function createRpcServer<T extends object>(handlers: T): (request: Request) => Promise<Response>;
|
|
3
|
-
declare function createRpcClient<T>(options: {
|
|
2
|
+
export declare function createRpcServer<T extends object>(handlers: T): (request: Request) => Promise<Response>;
|
|
3
|
+
export declare function createRpcClient<T>(options: {
|
|
4
4
|
endpoint: string;
|
|
5
5
|
}): T;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { createRpcClient, createRpcServer };
|
|
6
|
+
//#endregion
|