@vitejs/plugin-rsc 0.5.26 → 0.5.28
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 +34 -18
- package/dist/browser.d.ts +3 -3
- package/dist/{cjs-BdahOUyh.js → cjs-Cxg_7upE.js} +3 -3
- package/dist/client-BrwlzXgg.d.ts +19 -0
- package/dist/core/browser.d.ts +1 -1
- package/dist/core/browser.js +2 -2
- package/dist/core/plugin.d.ts +0 -1
- package/dist/core/rsc.d.ts +1 -19
- package/dist/core/rsc.js +20 -4
- package/dist/core/ssr.d.ts +1 -2
- package/dist/core/ssr.js +2 -2
- package/dist/{encryption-utils-BblioYEx.js → encryption-utils-BNbYHtC4.js} +1 -1
- package/dist/{index-2GoUFmVR.d.ts → index-BjJe9jqG.d.ts} +52 -20
- package/dist/{index-D2a5dlVU.d.ts → index-CqNlZcWp.d.ts} +12 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{picocolors-BDx0CW3k.js → picocolors-DFVOi1sR.js} +4 -2
- package/dist/{plugin-BhzHKRFo.js → plugin-BOTpkess.js} +89 -20
- package/dist/{plugin-DGxRH4Nv.d.ts → plugin-CaLiN8ED.d.ts} +71 -64
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.js +1 -1
- package/dist/plugins/cjs.d.ts +0 -1
- package/dist/plugins/cjs.js +1 -1
- package/dist/react/browser.d.ts +2 -3
- package/dist/react/rsc/client.d.ts +2 -0
- package/dist/react/rsc/client.js +16 -0
- package/dist/react/rsc/server.d.ts +3 -0
- package/dist/react/rsc/server.js +20 -0
- package/dist/react/rsc.d.ts +3 -24
- package/dist/react/rsc.js +3 -31
- package/dist/react/ssr.d.ts +4 -3
- package/dist/react/ssr.js +3 -1
- package/dist/rsc/client.d.ts +2 -0
- package/dist/rsc/client.js +3 -0
- package/dist/rsc/server.d.ts +16 -0
- package/dist/rsc/server.js +20 -0
- package/dist/rsc-CGkkhLG3.d.ts +21 -0
- package/dist/rsc.d.ts +4 -16
- package/dist/rsc.js +4 -41
- package/dist/{scope-DKCDtt0O.js → scope-Do08R7C2.js} +4 -38
- package/dist/server-DTkvSyJT.d.ts +20 -0
- package/dist/shared-D42sHPD1.js +25 -0
- package/dist/{shared-BViDMJTQ.js → shared-Y4B6DJ99.js} +2 -1
- package/dist/ssr.d.ts +12 -12
- package/dist/ssr.js +12 -7
- package/dist/transforms/index.d.ts +2 -2
- package/dist/transforms/index.js +133 -34
- package/dist/utils/encryption-runtime.js +5 -5
- 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.node.development.js +70 -33
- package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.production.js +69 -29
- package/dist/vendor/react-server-dom/package.json +3 -3
- package/package.json +13 -13
- package/dist/chunk-DpdyVxdi.js +0 -25
- /package/dist/{browser-CUMAmYC3.d.ts → browser-DI_Wyg5Y.d.ts} +0 -0
- /package/dist/{dist-rz-Bnebz.js → dist-uqdtSkzK.js} +0 -0
- /package/dist/{shared-DeahDSXi.js → shared-B6H2TbnP.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createClientManifest, createServerManifest, loadServerAction, setRequireModule } from "../core/rsc.js";
|
|
2
|
+
import { createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, registerClientReference, registerServerReference, renderToReadableStream as renderToReadableStream$1 } from "../react/rsc/server.js";
|
|
3
|
+
import "../shared-D42sHPD1.js";
|
|
4
|
+
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
5
|
+
//#region src/rsc/server.tsx
|
|
6
|
+
function renderToReadableStream(data, options, extraOptions) {
|
|
7
|
+
return renderToReadableStream$1(data, options, { onClientReference(metadata) {
|
|
8
|
+
const deps = assetsManifest.clientReferenceDeps[metadata.id] ?? {
|
|
9
|
+
js: [],
|
|
10
|
+
css: []
|
|
11
|
+
};
|
|
12
|
+
extraOptions?.onClientReference?.({
|
|
13
|
+
id: metadata.id,
|
|
14
|
+
name: metadata.name,
|
|
15
|
+
deps
|
|
16
|
+
});
|
|
17
|
+
} });
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { createClientManifest, createServerManifest, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, loadServerAction, registerClientReference, registerServerReference, renderToReadableStream, setRequireModule };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { l as ModuleMap, t as BundlerConfig } from "./index-CqNlZcWp.js";
|
|
2
|
+
//#region src/core/rsc.d.ts
|
|
3
|
+
declare function setRequireModule(options: {
|
|
4
|
+
load: (id: string) => unknown;
|
|
5
|
+
}): void;
|
|
6
|
+
declare function loadServerAction(id: string): Promise<Function>;
|
|
7
|
+
declare function createServerManifest(options?: {
|
|
8
|
+
preserveServerReferences?: boolean;
|
|
9
|
+
}): BundlerConfig;
|
|
10
|
+
declare function createServerDecodeClientManifest(): ModuleMap;
|
|
11
|
+
declare function createClientManifest(options?: {
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
onClientReference?: (metadata: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
}): BundlerConfig;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { setRequireModule as a, loadServerAction as i, createServerDecodeClientManifest as n, createServerManifest as r, createClientManifest as t };
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
1
|
+
import { a as setRequireModule, i as loadServerAction, r as createServerManifest, t as createClientManifest } from "./rsc-CGkkhLG3.js";
|
|
2
|
+
import { a as registerClientReference, i as decodeReply, n as decodeAction, o as registerServerReference, r as decodeFormState, t as createTemporaryReferenceSet } from "./server-DTkvSyJT.js";
|
|
3
|
+
import { n as createFromReadableStream, r as encodeReply, t as createClientTemporaryReferenceSet } from "./client-BrwlzXgg.js";
|
|
4
4
|
import { decryptActionBoundArgs, encryptActionBoundArgs } from "./utils/encryption-runtime.js";
|
|
5
|
-
|
|
6
|
-
//#region src/rsc.d.ts
|
|
7
|
-
declare function renderToReadableStream<T>(data: T, options?: object, extraOptions?: {
|
|
8
|
-
/**
|
|
9
|
-
* @experimental
|
|
10
|
-
*/
|
|
11
|
-
onClientReference?: (metadata: {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
deps: ResolvedAssetDeps;
|
|
15
|
-
}) => void;
|
|
16
|
-
}): ReadableStream<Uint8Array>;
|
|
17
|
-
//#endregion
|
|
5
|
+
import { renderToReadableStream } from "./rsc/server.js";
|
|
18
6
|
export { createClientManifest, createClientTemporaryReferenceSet, createFromReadableStream, createServerManifest, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decryptActionBoundArgs, encodeReply, encryptActionBoundArgs, loadServerAction, registerClientReference, registerServerReference, renderToReadableStream, setRequireModule };
|
package/dist/rsc.js
CHANGED
|
@@ -1,44 +1,7 @@
|
|
|
1
|
-
import { a as toReferenceValidationVirtual } from "./shared-DeahDSXi.js";
|
|
2
1
|
import { createClientManifest, createServerManifest, loadServerAction, setRequireModule } from "./core/rsc.js";
|
|
3
|
-
import {
|
|
2
|
+
import { createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, registerClientReference, registerServerReference } from "./react/rsc/server.js";
|
|
4
3
|
import { decryptActionBoundArgs, encryptActionBoundArgs } from "./utils/encryption-runtime.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
initialize();
|
|
9
|
-
function initialize() {
|
|
10
|
-
setRequireModule({ load: async (id) => {
|
|
11
|
-
if (!import.meta.env.__vite_rsc_build__) {
|
|
12
|
-
await import(
|
|
13
|
-
/* @vite-ignore */
|
|
14
|
-
"/@id/__x00__" + toReferenceValidationVirtual({
|
|
15
|
-
id,
|
|
16
|
-
type: "server"
|
|
17
|
-
})
|
|
18
|
-
);
|
|
19
|
-
return import(
|
|
20
|
-
/* @vite-ignore */
|
|
21
|
-
id
|
|
22
|
-
);
|
|
23
|
-
} else {
|
|
24
|
-
const import_ = serverReferences[id];
|
|
25
|
-
if (!import_) throw new Error(`server reference not found '${id}'`);
|
|
26
|
-
return import_();
|
|
27
|
-
}
|
|
28
|
-
} });
|
|
29
|
-
}
|
|
30
|
-
function renderToReadableStream(data, options, extraOptions) {
|
|
31
|
-
return renderToReadableStream$1(data, options, { onClientReference(metadata) {
|
|
32
|
-
const deps = assetsManifest.clientReferenceDeps[metadata.id] ?? {
|
|
33
|
-
js: [],
|
|
34
|
-
css: []
|
|
35
|
-
};
|
|
36
|
-
extraOptions?.onClientReference?.({
|
|
37
|
-
id: metadata.id,
|
|
38
|
-
name: metadata.name,
|
|
39
|
-
deps
|
|
40
|
-
});
|
|
41
|
-
} });
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
4
|
+
import { renderToReadableStream } from "./rsc/server.js";
|
|
5
|
+
import { createClientTemporaryReferenceSet, createFromReadableStream, encodeReply } from "./react/rsc/client.js";
|
|
6
|
+
import "./rsc/client.js";
|
|
44
7
|
export { createClientManifest, createClientTemporaryReferenceSet, createFromReadableStream, createServerManifest, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decryptActionBoundArgs, encodeReply, encryptActionBoundArgs, loadServerAction, registerClientReference, registerServerReference, renderToReadableStream, setRequireModule };
|
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
import { i as tinyassert } from "./dist-
|
|
1
|
+
import { i as tinyassert } from "./dist-uqdtSkzK.js";
|
|
2
2
|
import { walk } from "estree-walker";
|
|
3
3
|
//#region src/transforms/utils.ts
|
|
4
4
|
function hasDirective(body, directive) {
|
|
5
5
|
return !!body.find((stmt) => stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && stmt.expression.value === directive);
|
|
6
6
|
}
|
|
7
|
-
function getExportNames(ast, options) {
|
|
8
|
-
const exportNames = [];
|
|
9
|
-
for (const node of ast.body) {
|
|
10
|
-
if (node.type === "ExportNamedDeclaration") if (node.declaration) if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration")
|
|
11
|
-
/**
|
|
12
|
-
* export function foo() {}
|
|
13
|
-
*/
|
|
14
|
-
exportNames.push(node.declaration.id.name);
|
|
15
|
-
else if (node.declaration.type === "VariableDeclaration")
|
|
16
|
-
/**
|
|
17
|
-
* export const foo = 1, bar = 2
|
|
18
|
-
*/
|
|
19
|
-
for (const decl of node.declaration.declarations) exportNames.push(...extractNames(decl.id));
|
|
20
|
-
else node.declaration;
|
|
21
|
-
else
|
|
22
|
-
/**
|
|
23
|
-
* export { foo, bar as car } from './foo'
|
|
24
|
-
* export { foo, bar as car }
|
|
25
|
-
*/
|
|
26
|
-
for (const spec of node.specifiers) {
|
|
27
|
-
tinyassert(spec.exported.type === "Identifier");
|
|
28
|
-
exportNames.push(spec.exported.name);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* export * from './foo'
|
|
32
|
-
*/
|
|
33
|
-
if (!options.ignoreExportAllDeclaration && node.type === "ExportAllDeclaration") throw new Error("unsupported ExportAllDeclaration");
|
|
34
|
-
/**
|
|
35
|
-
* export default function foo() {}
|
|
36
|
-
* export default class Foo {}
|
|
37
|
-
* export default () => {}
|
|
38
|
-
*/
|
|
39
|
-
if (node.type === "ExportDefaultDeclaration") exportNames.push("default");
|
|
40
|
-
}
|
|
41
|
-
return { exportNames };
|
|
42
|
-
}
|
|
43
7
|
function extractNames(param) {
|
|
44
8
|
return extractIdentifiers(param).map((n) => n.name);
|
|
45
9
|
}
|
|
@@ -76,6 +40,8 @@ function validateNonAsyncFunction(opts, node) {
|
|
|
76
40
|
//#endregion
|
|
77
41
|
//#region src/transforms/scope.ts
|
|
78
42
|
var Scope = class {
|
|
43
|
+
parent;
|
|
44
|
+
isFunction;
|
|
79
45
|
declarations = /* @__PURE__ */ new Set();
|
|
80
46
|
constructor(parent, isFunction) {
|
|
81
47
|
this.parent = parent;
|
|
@@ -208,4 +174,4 @@ function getOutermostBindableReference(id, parentStack) {
|
|
|
208
174
|
return current;
|
|
209
175
|
}
|
|
210
176
|
//#endregion
|
|
211
|
-
export {
|
|
177
|
+
export { validateNonAsyncFunction as a, hasDirective as i, extractIdentifiers as n, extractNames as r, buildScopeTree as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { f as ServerTemporaryReferenceSet, o as DecodeReplyFunction, u as RenderToReadableStreamOptions } from "./index-CqNlZcWp.js";
|
|
2
|
+
import { ReactFormState } from "react-dom/client";
|
|
3
|
+
//#region src/react/rsc/server.d.ts
|
|
4
|
+
declare function renderToReadableStream<T>(data: T, options?: RenderToReadableStreamOptions, extraOptions?: {
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
onClientReference?: (metadata: {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}) => void;
|
|
12
|
+
}): ReadableStream<Uint8Array>;
|
|
13
|
+
declare function registerClientReference<T>(proxy: T, id: string, name: string): T;
|
|
14
|
+
declare const registerServerReference: <T>(ref: T, id: string, name: string) => T;
|
|
15
|
+
declare const decodeReply: DecodeReplyFunction;
|
|
16
|
+
declare function decodeAction(body: FormData): Promise<() => Promise<void>>;
|
|
17
|
+
declare function decodeFormState(actionResult: unknown, body: FormData): Promise<ReactFormState | undefined>;
|
|
18
|
+
declare const createTemporaryReferenceSet: () => ServerTemporaryReferenceSet;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { registerClientReference as a, decodeReply as i, decodeAction as n, registerServerReference as o, decodeFormState as r, renderToReadableStream as s, createTemporaryReferenceSet as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { a as toReferenceValidationVirtual } from "./shared-B6H2TbnP.js";
|
|
2
|
+
import { setRequireModule } from "./core/rsc.js";
|
|
3
|
+
import serverReferences from "virtual:vite-rsc/server-references";
|
|
4
|
+
//#region src/rsc/shared.ts
|
|
5
|
+
setRequireModule({ load: async (id) => {
|
|
6
|
+
if (!import.meta.env.__vite_rsc_build__) {
|
|
7
|
+
await import(
|
|
8
|
+
/* @vite-ignore */
|
|
9
|
+
"/@id/__x00__" + toReferenceValidationVirtual({
|
|
10
|
+
id,
|
|
11
|
+
type: "server"
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
return import(
|
|
15
|
+
/* @vite-ignore */
|
|
16
|
+
id
|
|
17
|
+
);
|
|
18
|
+
} else {
|
|
19
|
+
const import_ = serverReferences[id];
|
|
20
|
+
if (!import_) throw new Error(`server reference not found '${id}'`);
|
|
21
|
+
return import_();
|
|
22
|
+
}
|
|
23
|
+
} });
|
|
24
|
+
//#endregion
|
|
25
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/core/shared.ts
|
|
2
2
|
const SERVER_REFERENCE_PREFIX = "$$server:";
|
|
3
3
|
const SERVER_DECODE_CLIENT_PREFIX = "$$decode-client:";
|
|
4
|
+
const SERVER_REFERENCE_PRESERVE_PREFIX = "$$preserve:";
|
|
4
5
|
function createReferenceCacheTag() {
|
|
5
6
|
return "$$cache=" + Math.random().toString(36).slice(2);
|
|
6
7
|
}
|
|
@@ -17,4 +18,4 @@ function setInternalRequire() {
|
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
//#endregion
|
|
20
|
-
export {
|
|
21
|
+
export { removeReferenceCacheTag as a, createReferenceCacheTag as i, SERVER_REFERENCE_PREFIX as n, setInternalRequire as o, SERVER_REFERENCE_PRESERVE_PREFIX as r, SERVER_DECODE_CLIENT_PREFIX as t };
|
package/dist/ssr.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import { s as EncodeFormActionCallback } from "./index-CqNlZcWp.js";
|
|
1
2
|
import { createServerConsumerManifest, setRequireModule } from "./core/ssr.js";
|
|
2
|
-
import { i as ResolvedAssetDeps } from "./plugin-
|
|
3
|
-
import { callServer, createFromReadableStream, createServerReference, findSourceMapURL } from "./react/ssr.js";
|
|
4
|
-
|
|
3
|
+
import { i as ResolvedAssetDeps } from "./plugin-CaLiN8ED.js";
|
|
4
|
+
import { callServer, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL } from "./react/ssr.js";
|
|
5
5
|
//#region src/ssr.d.ts
|
|
6
6
|
/**
|
|
7
|
-
* Callback type for client reference dependency notifications.
|
|
8
|
-
* Called during SSR when a client component's dependencies are loaded.
|
|
9
|
-
* @experimental
|
|
10
|
-
*/
|
|
7
|
+
* Callback type for client reference dependency notifications.
|
|
8
|
+
* Called during SSR when a client component's dependencies are loaded.
|
|
9
|
+
* @experimental
|
|
10
|
+
*/
|
|
11
11
|
type OnClientReference = (reference: {
|
|
12
12
|
id: string;
|
|
13
13
|
deps: ResolvedAssetDeps;
|
|
14
14
|
}) => void;
|
|
15
15
|
/**
|
|
16
|
-
* Register a callback to be notified when client reference dependencies are loaded.
|
|
17
|
-
* Called during SSR when a client component is accessed.
|
|
18
|
-
* @experimental
|
|
19
|
-
*/
|
|
16
|
+
* Register a callback to be notified when client reference dependencies are loaded.
|
|
17
|
+
* Called during SSR when a client component is accessed.
|
|
18
|
+
* @experimental
|
|
19
|
+
*/
|
|
20
20
|
declare function setOnClientReference(callback: OnClientReference | undefined): void;
|
|
21
21
|
//#endregion
|
|
22
|
-
export { OnClientReference, callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, findSourceMapURL, setOnClientReference, setRequireModule };
|
|
22
|
+
export { type EncodeFormActionCallback, OnClientReference, callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setOnClientReference, setRequireModule };
|
package/dist/ssr.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as toReferenceValidationVirtual, i as toCssVirtual } from "./shared-
|
|
1
|
+
import { a as toReferenceValidationVirtual, i as toCssVirtual } from "./shared-B6H2TbnP.js";
|
|
2
2
|
import { createServerConsumerManifest, setRequireModule } from "./core/ssr.js";
|
|
3
|
-
import { callServer, createFromReadableStream, createServerReference, findSourceMapURL } from "./react/ssr.js";
|
|
3
|
+
import { callServer, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL } from "./react/ssr.js";
|
|
4
4
|
import * as clientReferences from "virtual:vite-rsc/client-references";
|
|
5
5
|
import * as ReactDOM from "react-dom";
|
|
6
6
|
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
@@ -67,14 +67,19 @@ function wrapResourceProxy(mod, id, deps) {
|
|
|
67
67
|
} });
|
|
68
68
|
}
|
|
69
69
|
function preloadDeps(deps) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
const clientEntryJsSet = new Set(assetsManifest.clientEntryDeps?.js ?? []);
|
|
71
|
+
for (const href of deps.js) {
|
|
72
|
+
const options = {
|
|
73
|
+
as: "script",
|
|
74
|
+
crossOrigin: ""
|
|
75
|
+
};
|
|
76
|
+
if (!clientEntryJsSet.has(href)) options.fetchPriority = "low";
|
|
77
|
+
ReactDOM.preloadModule(href, options);
|
|
78
|
+
}
|
|
74
79
|
for (const href of deps.css) ReactDOM.preinit(href, {
|
|
75
80
|
as: "style",
|
|
76
81
|
precedence: assetsManifest.cssLinkPrecedence !== false ? "vite-rsc/client-reference" : void 0
|
|
77
82
|
});
|
|
78
83
|
}
|
|
79
84
|
//#endregion
|
|
80
|
-
export { callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, findSourceMapURL, setOnClientReference, setRequireModule };
|
|
85
|
+
export { callServer, createFromReadableStream, createServerConsumerManifest, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setOnClientReference, setRequireModule };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, extractIdentifiers, extractNames, findDirectives,
|
|
1
|
+
import { a as extractIdentifiers, c as validateNonAsyncFunction, d as transformProxyExport, f as TransformWrapExportFilter, g as transformHoistInlineDirective, h as findDirectives, i as transformServerActionServer, l as TransformProxyExportOptions, m as transformWrapExport, n as TransformExpandExportAllOptions, o as extractNames, p as TransformWrapExportOptions, r as transformExpandExportAll, s as hasDirective, t as TransformExpandExportAllContext, u as transformDirectiveProxyExport } from "../index-BjJe9jqG.js";
|
|
2
|
+
export { TransformExpandExportAllContext, TransformExpandExportAllOptions, TransformProxyExportOptions, TransformWrapExportFilter, TransformWrapExportOptions, extractIdentifiers, extractNames, findDirectives, hasDirective, transformDirectiveProxyExport, transformExpandExportAll, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
|
package/dist/transforms/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as tinyassert } from "../dist-
|
|
2
|
-
import { a as
|
|
1
|
+
import { i as tinyassert } from "../dist-uqdtSkzK.js";
|
|
2
|
+
import { a as validateNonAsyncFunction, i as hasDirective, n as extractIdentifiers, r as extractNames, t as buildScopeTree } from "../scope-Do08R7C2.js";
|
|
3
3
|
import MagicString from "magic-string";
|
|
4
4
|
import { walk } from "estree-walker";
|
|
5
5
|
//#region src/transforms/hoist.ts
|
|
@@ -163,17 +163,21 @@ function transformWrapExport(input, ast, options) {
|
|
|
163
163
|
const toAppend = [];
|
|
164
164
|
const filter = options.filter ?? (() => true);
|
|
165
165
|
function wrapSimple(start, end, exports) {
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
const filteredExports = exports.map((item) => ({
|
|
167
|
+
...item,
|
|
168
|
+
shouldWrap: filter(item.name, item.meta)
|
|
169
|
+
}));
|
|
170
|
+
exportNames.push(...filteredExports.filter((item) => item.shouldWrap).map((item) => item.name));
|
|
171
|
+
const newCode = filteredExports.map((e) => [e.shouldWrap && `${e.name} = /* #__PURE__ */ ${options.runtime(e.name, e.name, e.meta)};\n`, `export { ${e.name} };\n`]).flat().filter(Boolean).join("");
|
|
168
172
|
output.update(start, end, newCode);
|
|
169
173
|
output.move(start, end, input.length);
|
|
170
174
|
}
|
|
171
175
|
function wrapExport(name, exportName, meta = {}) {
|
|
172
|
-
exportNames.push(exportName);
|
|
173
176
|
if (!filter(exportName, meta)) {
|
|
174
177
|
toAppend.push(`export { ${name} as ${exportName} }`);
|
|
175
178
|
return;
|
|
176
179
|
}
|
|
180
|
+
exportNames.push(exportName);
|
|
177
181
|
toAppend.push(`const $$wrap_${name} = /* #__PURE__ */ ${options.runtime(name, exportName, meta)}`, `export { $$wrap_${name} as ${exportName} }`);
|
|
178
182
|
}
|
|
179
183
|
for (const node of ast.body) {
|
|
@@ -181,34 +185,35 @@ function transformWrapExport(input, ast, options) {
|
|
|
181
185
|
/**
|
|
182
186
|
* export function foo() {}
|
|
183
187
|
*/
|
|
184
|
-
validateNonAsyncFunction(options, node.declaration);
|
|
185
188
|
const name = node.declaration.id.name;
|
|
189
|
+
const meta = {
|
|
190
|
+
isFunction: getIsFunction(node.declaration),
|
|
191
|
+
declName: name
|
|
192
|
+
};
|
|
193
|
+
if (filter(name, meta)) validateNonAsyncFunction(options, node.declaration);
|
|
186
194
|
wrapSimple(node.start, node.declaration.start, [{
|
|
187
195
|
name,
|
|
188
|
-
meta
|
|
189
|
-
isFunction: true,
|
|
190
|
-
declName: name
|
|
191
|
-
}
|
|
196
|
+
meta
|
|
192
197
|
}]);
|
|
193
198
|
} else if (node.declaration.type === "VariableDeclaration") {
|
|
194
199
|
/**
|
|
195
200
|
* export const foo = 1, bar = 2
|
|
196
201
|
*/
|
|
197
|
-
for (const decl of node.declaration.declarations) if (decl.init) validateNonAsyncFunction(options, decl.init);
|
|
198
202
|
if (node.declaration.kind === "const") output.update(node.declaration.start, node.declaration.start + 5, "let");
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
203
|
+
const exports = [];
|
|
204
|
+
for (const decl of node.declaration.declarations) {
|
|
205
|
+
const isFunction = decl.id.type === "Identifier" && decl.init ? getIsFunction(decl.init) : void 0;
|
|
206
|
+
const declarationExports = extractNames(decl.id).map((name) => ({
|
|
207
|
+
name,
|
|
208
|
+
meta: {
|
|
209
|
+
isFunction,
|
|
210
|
+
declName: name
|
|
211
|
+
}
|
|
212
|
+
}));
|
|
213
|
+
exports.push(...declarationExports);
|
|
214
|
+
if (decl.init && declarationExports.some(({ name, meta }) => filter(name, meta))) validateNonAsyncFunction(options, decl.init);
|
|
204
215
|
}
|
|
205
|
-
wrapSimple(node.start, node.declaration.start,
|
|
206
|
-
name,
|
|
207
|
-
meta: {
|
|
208
|
-
isFunction,
|
|
209
|
-
declName: name
|
|
210
|
-
}
|
|
211
|
-
})));
|
|
216
|
+
wrapSimple(node.start, node.declaration.start, exports);
|
|
212
217
|
} else node.declaration;
|
|
213
218
|
else if (node.source) {
|
|
214
219
|
/**
|
|
@@ -217,7 +222,7 @@ function transformWrapExport(input, ast, options) {
|
|
|
217
222
|
output.remove(node.start, node.end);
|
|
218
223
|
for (const spec of node.specifiers) {
|
|
219
224
|
tinyassert(spec.local.type === "Identifier");
|
|
220
|
-
|
|
225
|
+
if (spec.exported.type !== "Identifier") throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
|
|
221
226
|
const name = spec.local.name;
|
|
222
227
|
toAppend.push(`import { ${name} as $$import_${name} } from ${node.source.raw}`);
|
|
223
228
|
wrapExport(`$$import_${name}`, spec.exported.name);
|
|
@@ -229,40 +234,45 @@ function transformWrapExport(input, ast, options) {
|
|
|
229
234
|
output.remove(node.start, node.end);
|
|
230
235
|
for (const spec of node.specifiers) {
|
|
231
236
|
tinyassert(spec.local.type === "Identifier");
|
|
232
|
-
|
|
237
|
+
if (spec.exported.type !== "Identifier") throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
|
|
233
238
|
wrapExport(spec.local.name, spec.exported.name);
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
241
|
/**
|
|
242
|
+
* export * as ns from './foo'
|
|
237
243
|
* export * from './foo'
|
|
238
244
|
*/
|
|
239
|
-
if (
|
|
245
|
+
if (node.type === "ExportAllDeclaration") {
|
|
246
|
+
if (!options.ignoreExportAllDeclaration) throw Object.assign(/* @__PURE__ */ new Error("unsupported ExportAllDeclaration"), { pos: node.start });
|
|
247
|
+
}
|
|
240
248
|
/**
|
|
241
249
|
* export default function foo() {}
|
|
242
250
|
* export default class Foo {}
|
|
243
251
|
* export default () => {}
|
|
244
252
|
*/
|
|
245
253
|
if (node.type === "ExportDefaultDeclaration") {
|
|
246
|
-
validateNonAsyncFunction(options, node.declaration);
|
|
247
254
|
let localName;
|
|
248
|
-
let isFunction
|
|
255
|
+
let isFunction;
|
|
249
256
|
let declName;
|
|
250
257
|
let defaultExportIdentifierName;
|
|
251
258
|
if ((node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") && node.declaration.id) {
|
|
252
259
|
localName = node.declaration.id.name;
|
|
253
260
|
output.remove(node.start, node.declaration.start);
|
|
254
|
-
isFunction = node.declaration
|
|
261
|
+
isFunction = getIsFunction(node.declaration);
|
|
255
262
|
declName = node.declaration.id.name;
|
|
256
263
|
} else {
|
|
257
264
|
localName = "$$default";
|
|
258
265
|
output.update(node.start, node.declaration.start, "const $$default = ");
|
|
259
266
|
if (node.declaration.type === "Identifier") defaultExportIdentifierName = node.declaration.name;
|
|
267
|
+
else isFunction = getIsFunction(node.declaration);
|
|
260
268
|
}
|
|
261
|
-
|
|
269
|
+
const defaultMeta = {
|
|
262
270
|
isFunction,
|
|
263
271
|
declName,
|
|
264
272
|
defaultExportIdentifierName
|
|
265
|
-
}
|
|
273
|
+
};
|
|
274
|
+
if (filter("default", defaultMeta)) validateNonAsyncFunction(options, node.declaration);
|
|
275
|
+
wrapExport(localName, "default", defaultMeta);
|
|
266
276
|
}
|
|
267
277
|
}
|
|
268
278
|
if (toAppend.length > 0) output.append([
|
|
@@ -275,6 +285,10 @@ function transformWrapExport(input, ast, options) {
|
|
|
275
285
|
output
|
|
276
286
|
};
|
|
277
287
|
}
|
|
288
|
+
function getIsFunction(node) {
|
|
289
|
+
if (node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression") return true;
|
|
290
|
+
if (node.type === "ClassDeclaration" || node.type === "Literal" || node.type === "ObjectExpression" || node.type === "ArrayExpression" || node.type === "ClassExpression") return false;
|
|
291
|
+
}
|
|
278
292
|
//#endregion
|
|
279
293
|
//#region src/transforms/proxy-export.ts
|
|
280
294
|
function transformDirectiveProxyExport(ast, options) {
|
|
@@ -325,7 +339,7 @@ function transformProxyExport(ast, options) {
|
|
|
325
339
|
*/
|
|
326
340
|
const names = [];
|
|
327
341
|
for (const spec of node.specifiers) {
|
|
328
|
-
|
|
342
|
+
if (spec.exported.type !== "Identifier") throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
|
|
329
343
|
names.push(spec.exported.name);
|
|
330
344
|
}
|
|
331
345
|
createExport(node, names);
|
|
@@ -333,9 +347,16 @@ function transformProxyExport(ast, options) {
|
|
|
333
347
|
continue;
|
|
334
348
|
}
|
|
335
349
|
/**
|
|
350
|
+
* export * as ns from './foo'
|
|
336
351
|
* export * from './foo'
|
|
337
352
|
*/
|
|
338
|
-
if (
|
|
353
|
+
if (node.type === "ExportAllDeclaration") {
|
|
354
|
+
if (node.exported?.type === "Identifier") {
|
|
355
|
+
createExport(node, [node.exported.name]);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (!options.ignoreExportAllDeclaration) throw new Error("unsupported ExportAllDeclaration");
|
|
359
|
+
}
|
|
339
360
|
/**
|
|
340
361
|
* export default function foo() {}
|
|
341
362
|
* export default class Foo {}
|
|
@@ -364,4 +385,82 @@ function transformServerActionServer(input, ast, options) {
|
|
|
364
385
|
});
|
|
365
386
|
}
|
|
366
387
|
//#endregion
|
|
367
|
-
export
|
|
388
|
+
//#region src/transforms/expand-export-all.ts
|
|
389
|
+
async function transformExpandExportAll(options) {
|
|
390
|
+
const { plans } = resolveStarExports(await scanModuleExports(options.ast, options.importer, options));
|
|
391
|
+
if (plans.length === 0) return;
|
|
392
|
+
const output = new MagicString(options.code);
|
|
393
|
+
for (const item of plans) {
|
|
394
|
+
const newExport = `export {${item.names.join(", ")}} from ${JSON.stringify(item.node.source.value)};`;
|
|
395
|
+
output.update(item.node.start, item.node.end, newExport);
|
|
396
|
+
}
|
|
397
|
+
return { code: output.toString() };
|
|
398
|
+
}
|
|
399
|
+
async function scanModuleExports(ast, importer, context, seen = /* @__PURE__ */ new Set()) {
|
|
400
|
+
const starSources = [];
|
|
401
|
+
const bareStars = ast.body.filter((n) => n.type === "ExportAllDeclaration" && !n.exported);
|
|
402
|
+
for (const node of bareStars) {
|
|
403
|
+
const source = node.source.value;
|
|
404
|
+
const resolved = await context.resolve(source, importer);
|
|
405
|
+
if (!resolved) throw Object.assign(/* @__PURE__ */ new Error(`failed to resolve export-all source ${JSON.stringify(source)}`), { pos: node.start });
|
|
406
|
+
starSources.push({
|
|
407
|
+
node,
|
|
408
|
+
scan: await collectExportScan(resolved, context, new Set(seen))
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
explicitNames: collectExplicitExportNames(ast),
|
|
413
|
+
starSources
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
async function collectExportScan(resolvedId, context, seen) {
|
|
417
|
+
if (seen.has(resolvedId)) return {
|
|
418
|
+
names: [],
|
|
419
|
+
ambiguousNames: /* @__PURE__ */ new Set()
|
|
420
|
+
};
|
|
421
|
+
seen.add(resolvedId);
|
|
422
|
+
const scan = await scanModuleExports(await context.load(resolvedId), resolvedId, context, seen);
|
|
423
|
+
const resolved = resolveStarExports(scan);
|
|
424
|
+
return {
|
|
425
|
+
names: [...scan.explicitNames, ...resolved.plans.flatMap((item) => item.names)],
|
|
426
|
+
ambiguousNames: resolved.ambiguousNames
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function collectExplicitExportNames(ast) {
|
|
430
|
+
const names = /* @__PURE__ */ new Set();
|
|
431
|
+
for (const node of ast.body) if (node.type === "ExportNamedDeclaration") if (node.declaration) {
|
|
432
|
+
if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
|
|
433
|
+
if (node.declaration.id) names.add(node.declaration.id.name);
|
|
434
|
+
} else if (node.declaration.type === "VariableDeclaration") for (const decl of node.declaration.declarations) for (const name of extractNames(decl.id)) names.add(name);
|
|
435
|
+
} else for (const spec of node.specifiers) if (spec.exported.type === "Identifier") names.add(spec.exported.name);
|
|
436
|
+
else throw Object.assign(/* @__PURE__ */ new Error("unsupported string literal export name"), { pos: spec.exported.start });
|
|
437
|
+
else if (node.type === "ExportDefaultDeclaration") names.add("default");
|
|
438
|
+
else if (node.type === "ExportAllDeclaration") {
|
|
439
|
+
if (node.exported?.type === "Identifier") names.add(node.exported.name);
|
|
440
|
+
}
|
|
441
|
+
return names;
|
|
442
|
+
}
|
|
443
|
+
function resolveStarExports(scan) {
|
|
444
|
+
const seenStarNames = /* @__PURE__ */ new Set();
|
|
445
|
+
const ambiguousNames = /* @__PURE__ */ new Set();
|
|
446
|
+
for (const source of scan.starSources) for (const name of source.scan.names) {
|
|
447
|
+
if (name === "default" || scan.explicitNames.has(name)) continue;
|
|
448
|
+
if (seenStarNames.has(name)) ambiguousNames.add(name);
|
|
449
|
+
else seenStarNames.add(name);
|
|
450
|
+
}
|
|
451
|
+
for (const source of scan.starSources) for (const name of source.scan.ambiguousNames) if (!scan.explicitNames.has(name)) ambiguousNames.add(name);
|
|
452
|
+
const plans = [];
|
|
453
|
+
for (const source of scan.starSources) {
|
|
454
|
+
const names = source.scan.names.filter((name) => name !== "default" && !scan.explicitNames.has(name) && !ambiguousNames.has(name));
|
|
455
|
+
plans.push({
|
|
456
|
+
node: source.node,
|
|
457
|
+
names
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return {
|
|
461
|
+
ambiguousNames,
|
|
462
|
+
plans
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
//#endregion
|
|
466
|
+
export { extractIdentifiers, extractNames, findDirectives, hasDirective, transformDirectiveProxyExport, transformExpandExportAll, transformHoistInlineDirective, transformProxyExport, transformServerActionServer, transformWrapExport, validateNonAsyncFunction };
|
|
@@ -1,16 +1,16 @@
|
|
|
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-
|
|
3
|
-
import {
|
|
1
|
+
import { r as once } from "../dist-uqdtSkzK.js";
|
|
2
|
+
import { a as fromBase64, i as encryptBuffer, n as concatArrayStream, r as decryptBuffer, t as arrayToStream } from "../encryption-utils-BNbYHtC4.js";
|
|
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
|
return encryptBuffer(await concatArrayStream(renderToReadableStream(originalValue)), await getEncryptionKey());
|
|
8
8
|
}
|
|
9
9
|
async function decryptActionBoundArgs(encrypted) {
|
|
10
|
-
const serializedBuffer = await decryptBuffer(await encrypted, await getEncryptionKey());
|
|
10
|
+
const [{ createFromReadableStream }, serializedBuffer] = await Promise.all([import("../react/rsc/client.js"), decryptBuffer(await encrypted, await getEncryptionKey())]);
|
|
11
11
|
return createFromReadableStream(arrayToStream(new Uint8Array(serializedBuffer)));
|
|
12
12
|
}
|
|
13
|
-
const getEncryptionKey = /*
|
|
13
|
+
const getEncryptionKey = /* #__PURE__ */ once(async () => {
|
|
14
14
|
const resolved = await encryptionKeySource();
|
|
15
15
|
return await crypto.subtle.importKey("raw", fromBase64(resolved), { name: "AES-GCM" }, true, ["encrypt", "decrypt"]);
|
|
16
16
|
});
|
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.7",
|
|
4905
4905
|
rendererPackageName: "react-server-dom-webpack",
|
|
4906
4906
|
currentDispatcherRef: ReactSharedInternals,
|
|
4907
|
-
reconcilerVersion: "19.2.
|
|
4907
|
+
reconcilerVersion: "19.2.7",
|
|
4908
4908
|
getCurrentComponentInfo: function () {
|
|
4909
4909
|
return currentOwnerInDEV;
|
|
4910
4910
|
}
|