@vitejs/plugin-rsc 0.5.21 → 0.5.22

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.
Files changed (47) hide show
  1. package/dist/browser-CUMAmYC3.d.ts +6 -0
  2. package/dist/browser.d.ts +2 -2
  3. package/dist/browser.js +1 -3
  4. package/dist/{chunk-f2BShn47.js → chunk-BYIdrdsR.js} +8 -14
  5. package/dist/cjs-BdahOUyh.js +115 -0
  6. package/dist/core/browser.d.ts +1 -5
  7. package/dist/core/browser.js +3 -5
  8. package/dist/core/plugin.js +1 -2
  9. package/dist/core/rsc.d.ts +1 -1
  10. package/dist/core/rsc.js +4 -6
  11. package/dist/core/ssr.d.ts +1 -1
  12. package/dist/core/ssr.js +3 -5
  13. package/dist/{dist-yW9-EeG1.js → dist-rz-Bnebz.js} +1 -2
  14. package/dist/{encryption-utils-Bk5eKdu6.js → encryption-utils-BblioYEx.js} +1 -2
  15. package/dist/{server-action-B2zS9t-J.d.ts → index-2GoUFmVR.d.ts} +34 -1
  16. package/dist/index-D2a5dlVU.d.ts +70 -0
  17. package/dist/index.d.ts +1 -3
  18. package/dist/index.js +2 -6
  19. package/dist/{picocolors-B0A1T24z.js → picocolors-B6RAUUd2.js} +2 -5
  20. package/dist/plugin-DGxRH4Nv.d.ts +185 -0
  21. package/dist/plugin-DMfc_Eqq.js +1944 -0
  22. package/dist/plugin.d.ts +2 -179
  23. package/dist/plugin.js +2 -1468
  24. package/dist/plugins/cjs.js +2 -64
  25. package/dist/react/browser.d.ts +6 -6
  26. package/dist/react/browser.js +1 -3
  27. package/dist/react/rsc.d.ts +7 -6
  28. package/dist/react/rsc.js +2 -6
  29. package/dist/react/ssr.d.ts +2 -1
  30. package/dist/react/ssr.js +1 -3
  31. package/dist/rsc.d.ts +1 -3
  32. package/dist/rsc.js +2 -4
  33. package/dist/scope-DKCDtt0O.js +211 -0
  34. package/dist/{shared-Dhw3vs8e.js → shared-BViDMJTQ.js} +2 -3
  35. package/dist/{shared-d80_k_tn.js → shared-DeahDSXi.js} +1 -2
  36. package/dist/ssr.d.ts +1 -3
  37. package/dist/ssr.js +2 -4
  38. package/dist/transforms/index.d.ts +2 -2
  39. package/dist/transforms/index.js +367 -3
  40. package/dist/utils/encryption-runtime.js +3 -5
  41. package/dist/utils/rpc.js +1 -3
  42. package/package.json +9 -10
  43. package/dist/cjs-v2jRTNln.js +0 -59
  44. package/dist/import-environment-B994HXEc.d.ts +0 -11
  45. package/dist/index-BIbdRBfk.d.ts +0 -26
  46. package/dist/server-action-JkEy-6yW.js +0 -344
  47. package/dist/validate-import-DJumtHRw.js +0 -498
@@ -0,0 +1,6 @@
1
+ //#region src/core/browser.d.ts
2
+ declare function setRequireModule(options: {
3
+ load: (id: string) => Promise<unknown>;
4
+ }): void;
5
+ //#endregion
6
+ export { setRequireModule as t };
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as CallServerCallback } from "./index-BIbdRBfk.js";
2
- import { setRequireModule } from "./core/browser.js";
1
+ import { n as CallServerCallback } from "./index-D2a5dlVU.js";
2
+ import { t as setRequireModule } from "./browser-CUMAmYC3.js";
3
3
  import { callServer, createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setServerCallback } from "./react/browser.js";
4
4
  export { CallServerCallback, callServer, createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setRequireModule, setServerCallback };
package/dist/browser.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { setRequireModule } from "./core/browser.js";
2
2
  import { callServer, createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setServerCallback } from "./react/browser.js";
3
3
  import * as clientReferences from "virtual:vite-rsc/client-references";
4
-
5
4
  //#region src/browser.ts
6
5
  initialize();
7
6
  function initialize() {
@@ -18,6 +17,5 @@ function withTrailingSlash(path) {
18
17
  if (path[path.length - 1] !== "/") return `${path}/`;
19
18
  return path;
20
19
  }
21
-
22
20
  //#endregion
23
- export { callServer, createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setRequireModule, setServerCallback };
21
+ export { callServer, createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, findSourceMapURL, setRequireModule, setServerCallback };
@@ -1,5 +1,4 @@
1
- import { createRequire } from "node:module";
2
-
1
+ import "node:module";
3
2
  //#region \0rolldown/runtime.js
4
3
  var __create = Object.create;
5
4
  var __defProp = Object.defineProperty;
@@ -9,16 +8,12 @@ var __getProtoOf = Object.getPrototypeOf;
9
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
9
  var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11
10
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
- key = keys[i];
15
- if (!__hasOwnProp.call(to, key) && key !== except) {
16
- __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
20
- }
21
- }
11
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
22
17
  }
23
18
  return to;
24
19
  };
@@ -26,6 +21,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
21
  value: mod,
27
22
  enumerable: true
28
23
  }) : target, mod));
29
-
30
24
  //#endregion
31
- export { __toESM as n, __commonJSMin as t };
25
+ export { __toESM as n, __commonJSMin as t };
@@ -0,0 +1,115 @@
1
+ import { t as createDebug } from "./dist-rz-Bnebz.js";
2
+ import { t as buildScopeTree } from "./scope-DKCDtt0O.js";
3
+ import { n as parseIdQuery } from "./shared-DeahDSXi.js";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { fileURLToPath, pathToFileURL } from "node:url";
7
+ import * as esModuleLexer from "es-module-lexer";
8
+ import MagicString from "magic-string";
9
+ import { parseAstAsync } from "vite";
10
+ import { findClosestPkgJsonPath } from "vitefu";
11
+ import { walk } from "estree-walker";
12
+ //#region src/transforms/cjs.ts
13
+ function __cjs_interop__(m) {
14
+ return m.__cjs_module_runner_transform || "default" in m && Object.keys(m).every((k) => k === "default" || m[k] === m.default[k]) ? m.default : m;
15
+ }
16
+ const CJS_INTEROP_HELPER = __cjs_interop__.toString().replace(/\n\s*/g, "");
17
+ function transformCjsToEsm(code, ast, options) {
18
+ const output = new MagicString(code);
19
+ const scopeTree = buildScopeTree(ast);
20
+ const parentNodes = [];
21
+ const hoistedCodes = [];
22
+ let hoistIndex = 0;
23
+ walk(ast, {
24
+ enter(node) {
25
+ parentNodes.push(node);
26
+ if (node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "require" && node.arguments.length === 1) {
27
+ let isTopLevel = true;
28
+ for (const parent of parentNodes) {
29
+ if (parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration" || parent.type === "ArrowFunctionExpression") isTopLevel = false;
30
+ if (scopeTree.nodeScope.get(parent)?.declarations.has("require")) return;
31
+ }
32
+ if (isTopLevel) {
33
+ output.update(node.start, node.callee.end, "(__cjs_interop__(await import");
34
+ output.appendRight(node.end, "))");
35
+ } else {
36
+ const hoisted = `__cjs_to_esm_hoist_${hoistIndex}`;
37
+ const importee = code.slice(node.arguments[0].start, node.arguments[0].end);
38
+ hoistedCodes.push(`const ${hoisted} = __cjs_interop__(await import(${importee}));\n`);
39
+ output.update(node.start, node.end, hoisted);
40
+ hoistIndex++;
41
+ }
42
+ }
43
+ },
44
+ leave() {
45
+ parentNodes.pop();
46
+ }
47
+ });
48
+ for (const hoisted of hoistedCodes.reverse()) output.prepend(hoisted);
49
+ if (output.hasChanged()) output.prepend(`${CJS_INTEROP_HELPER}\n`);
50
+ output.prepend(`let exports = {}; const module = { exports };\n`);
51
+ const __filename = fileURLToPath(pathToFileURL(options.id).href);
52
+ const __dirname = path.dirname(__filename);
53
+ output.prepend(`let __filename = ${JSON.stringify(__filename)}; let __dirname = ${JSON.stringify(__dirname)};\n`);
54
+ output.append(`
55
+ ;__vite_ssr_exportAll__(module.exports);
56
+ export default module.exports;
57
+ export const __cjs_module_runner_transform = true;
58
+ `);
59
+ return { output };
60
+ }
61
+ //#endregion
62
+ //#region src/plugins/cjs.ts
63
+ const debug = createDebug("vite-rsc:cjs");
64
+ function cjsModuleRunnerPlugin() {
65
+ const warnedPackages = /* @__PURE__ */ new Set();
66
+ return [{
67
+ name: "cjs-module-runner-transform",
68
+ apply: "serve",
69
+ applyToEnvironment: (env) => env.config.dev.moduleRunnerTransform,
70
+ transform: {
71
+ filter: {
72
+ id: /\/node_modules\//,
73
+ code: /\b(require|exports)\b/
74
+ },
75
+ async handler(code, id) {
76
+ if (id.includes("/node_modules/") && !id.startsWith(this.environment.config.cacheDir) && /\b(require|exports)\b/.test(code)) {
77
+ id = parseIdQuery(id).filename;
78
+ if (!/\.[cm]?js$/.test(id)) return;
79
+ if (id.endsWith(".mjs")) return;
80
+ if (id.endsWith(".js")) {
81
+ const pkgJsonPath = await findClosestPkgJsonPath(path.dirname(id));
82
+ if (pkgJsonPath) {
83
+ if (JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")).type === "module") return;
84
+ }
85
+ }
86
+ const [, , , hasModuleSyntax] = esModuleLexer.parse(code);
87
+ if (hasModuleSyntax) return;
88
+ const packageKey = extractPackageKey(id);
89
+ if (!warnedPackages.has(packageKey)) {
90
+ debug(`non-optimized CJS dependency in '${this.environment.name}' environment: ${id}`);
91
+ warnedPackages.add(packageKey);
92
+ }
93
+ const output = transformCjsToEsm(code, await parseAstAsync(code), { id }).output;
94
+ return {
95
+ code: output.toString(),
96
+ map: output.generateMap({ hires: "boundary" })
97
+ };
98
+ }
99
+ }
100
+ }
101
+ }];
102
+ }
103
+ function extractPackageKey(id) {
104
+ const yarnMatch = id.match(/\/.yarn\/cache\/([^/]+)/);
105
+ if (yarnMatch) return yarnMatch[1];
106
+ if (id.includes("/node_modules")) {
107
+ id = id.split("/node_modules/").at(-1);
108
+ let [x, y] = id.split("/");
109
+ if (x.startsWith("@")) return `${x}/${y}`;
110
+ return x;
111
+ }
112
+ return id;
113
+ }
114
+ //#endregion
115
+ export { cjsModuleRunnerPlugin as t };
@@ -1,6 +1,2 @@
1
- //#region src/core/browser.d.ts
2
- declare function setRequireModule(options: {
3
- load: (id: string) => Promise<unknown>;
4
- }): void;
5
- //#endregion
1
+ import { t as setRequireModule } from "../browser-CUMAmYC3.js";
6
2
  export { setRequireModule };
@@ -1,6 +1,5 @@
1
- import { n as memoize } from "../dist-yW9-EeG1.js";
2
- import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-Dhw3vs8e.js";
3
-
1
+ import { n as memoize } from "../dist-rz-Bnebz.js";
2
+ import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-BViDMJTQ.js";
4
3
  //#region src/core/browser.ts
5
4
  let init = false;
6
5
  function setRequireModule(options) {
@@ -12,6 +11,5 @@ function setRequireModule(options) {
12
11
  globalThis.__vite_rsc_client_require__ = requireModule;
13
12
  setInternalRequire();
14
13
  }
15
-
16
14
  //#endregion
17
- export { setRequireModule };
15
+ export { setRequireModule };
@@ -22,6 +22,5 @@ function vitePluginRscCore() {
22
22
  }
23
23
  }];
24
24
  }
25
-
26
25
  //#endregion
27
- export { vitePluginRscCore as default };
26
+ export { vitePluginRscCore as default };
@@ -1,4 +1,4 @@
1
- import { r as ModuleMap, t as BundlerConfig } from "../index-BIbdRBfk.js";
1
+ import { c as ModuleMap, t as BundlerConfig } from "../index-D2a5dlVU.js";
2
2
 
3
3
  //#region src/core/rsc.d.ts
4
4
  declare function setRequireModule(options: {
package/dist/core/rsc.js CHANGED
@@ -1,7 +1,6 @@
1
- import { i as tinyassert, n as memoize } from "../dist-yW9-EeG1.js";
2
- import { a as setInternalRequire, i as removeReferenceCacheTag, n as SERVER_REFERENCE_PREFIX, r as createReferenceCacheTag, t as SERVER_DECODE_CLIENT_PREFIX } from "../shared-Dhw3vs8e.js";
1
+ import { i as tinyassert, n as memoize } from "../dist-rz-Bnebz.js";
2
+ import { a as setInternalRequire, i as removeReferenceCacheTag, n as SERVER_REFERENCE_PREFIX, r as createReferenceCacheTag, t as SERVER_DECODE_CLIENT_PREFIX } from "../shared-BViDMJTQ.js";
3
3
  import * as ReactServer from "@vitejs/plugin-rsc/vendor/react-server-dom/server.edge";
4
-
5
4
  //#region src/core/rsc.ts
6
5
  let init = false;
7
6
  let requireModule;
@@ -12,7 +11,7 @@ function setRequireModule(options) {
12
11
  return options.load(removeReferenceCacheTag(id));
13
12
  };
14
13
  globalThis.__vite_rsc_server_require__ = memoize(async (id) => {
15
- if (id.startsWith(SERVER_DECODE_CLIENT_PREFIX)) {
14
+ if (id.startsWith("$$decode-client:")) {
16
15
  id = id.slice(SERVER_DECODE_CLIENT_PREFIX.length);
17
16
  id = removeReferenceCacheTag(id);
18
17
  const target = {};
@@ -81,6 +80,5 @@ function createClientManifest(options) {
81
80
  };
82
81
  } });
83
82
  }
84
-
85
83
  //#endregion
86
- export { createClientManifest, createServerDecodeClientManifest, createServerManifest, loadServerAction, setRequireModule };
84
+ export { createClientManifest, createServerDecodeClientManifest, createServerManifest, loadServerAction, setRequireModule };
@@ -1,4 +1,4 @@
1
- import { i as ServerConsumerManifest } from "../index-BIbdRBfk.js";
1
+ import { u as ServerConsumerManifest } from "../index-D2a5dlVU.js";
2
2
 
3
3
  //#region src/core/ssr.d.ts
4
4
  declare function setRequireModule(options: {
package/dist/core/ssr.js CHANGED
@@ -1,6 +1,5 @@
1
- import { n as memoize } from "../dist-yW9-EeG1.js";
2
- import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-Dhw3vs8e.js";
3
-
1
+ import { n as memoize } from "../dist-rz-Bnebz.js";
2
+ import { a as setInternalRequire, i as removeReferenceCacheTag } from "../shared-BViDMJTQ.js";
4
3
  //#region src/core/ssr.ts
5
4
  let init = false;
6
5
  function setRequireModule(options) {
@@ -15,6 +14,5 @@ function setRequireModule(options) {
15
14
  function createServerConsumerManifest() {
16
15
  return {};
17
16
  }
18
-
19
17
  //#endregion
20
- export { createServerConsumerManifest, setRequireModule };
18
+ export { createServerConsumerManifest, setRequireModule };
@@ -60,6 +60,5 @@ function createDebugPattern(namespace) {
60
60
  const pattern = alts.map((pattern2) => escapeRegExp(pattern2)).join("|");
61
61
  return new RegExp(`(^|,)(${pattern})($|,)`);
62
62
  }
63
-
64
63
  //#endregion
65
- export { tinyassert as i, memoize as n, once as r, createDebug as t };
64
+ export { tinyassert as i, memoize as n, once as r, createDebug as t };
@@ -68,6 +68,5 @@ async function decryptBuffer(encryptedString, key) {
68
68
  iv
69
69
  }, key, encrypted);
70
70
  }
71
-
72
71
  //#endregion
73
- export { fromBase64 as a, encryptBuffer as i, concatArrayStream as n, generateEncryptionKey as o, decryptBuffer as r, toBase64 as s, arrayToStream as t };
72
+ export { fromBase64 as a, encryptBuffer as i, concatArrayStream as n, generateEncryptionKey as o, decryptBuffer as r, toBase64 as s, arrayToStream as t };
@@ -30,6 +30,31 @@ interface BaseNode extends BaseNodeWithoutComments {
30
30
  leadingComments?: Comment[] | undefined;
31
31
  trailingComments?: Comment[] | undefined;
32
32
  }
33
+ interface NodeMap {
34
+ AssignmentProperty: AssignmentProperty;
35
+ CatchClause: CatchClause;
36
+ Class: Class;
37
+ ClassBody: ClassBody;
38
+ Expression: Expression;
39
+ Function: Function;
40
+ Identifier: Identifier;
41
+ Literal: Literal;
42
+ MethodDefinition: MethodDefinition;
43
+ ModuleDeclaration: ModuleDeclaration;
44
+ ModuleSpecifier: ModuleSpecifier;
45
+ Pattern: Pattern;
46
+ PrivateIdentifier: PrivateIdentifier;
47
+ Program: Program;
48
+ Property: Property;
49
+ PropertyDefinition: PropertyDefinition;
50
+ SpreadElement: SpreadElement;
51
+ Statement: Statement;
52
+ Super: Super;
53
+ SwitchCase: SwitchCase;
54
+ TemplateElement: TemplateElement;
55
+ VariableDeclarator: VariableDeclarator;
56
+ }
57
+ type Node = NodeMap[keyof NodeMap];
33
58
  interface Comment extends BaseNodeWithoutComments {
34
59
  type: "Line" | "Block";
35
60
  value: string;
@@ -64,6 +89,7 @@ interface BaseFunction extends BaseNode {
64
89
  // FunctionExpressions have only BlockStatement bodies.
65
90
  body: BlockStatement | Expression;
66
91
  }
92
+ type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
67
93
  type Statement = ExpressionStatement | BlockStatement | StaticBlock | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
68
94
  interface BaseStatement extends BaseNode {}
69
95
  interface EmptyStatement extends BaseStatement {
@@ -405,6 +431,7 @@ interface AssignmentPattern extends BasePattern {
405
431
  left: Pattern;
406
432
  right: Expression;
407
433
  }
434
+ type Class = ClassDeclaration | ClassExpression;
408
435
  interface BaseClass extends BaseNode {
409
436
  superClass?: Expression | null | undefined;
410
437
  body: ClassBody;
@@ -440,6 +467,7 @@ interface MetaProperty extends BaseExpression {
440
467
  }
441
468
  type ModuleDeclaration = ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration;
442
469
  interface BaseModuleDeclaration extends BaseNode {}
470
+ type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
443
471
  interface BaseModuleSpecifier extends BaseNode {
444
472
  local: Identifier;
445
473
  }
@@ -566,6 +594,11 @@ declare function getExportNames(ast: Program, options: {
566
594
  }): {
567
595
  exportNames: string[];
568
596
  };
597
+ declare function extractNames(param: Pattern): string[];
598
+ declare function extractIdentifiers(param: Pattern, nodes?: Identifier[]): Identifier[];
599
+ declare function validateNonAsyncFunction(opts: {
600
+ rejectNonAsyncFunction?: boolean;
601
+ }, node: Node | ExportDefaultDeclaration["declaration"]): void;
569
602
  //#endregion
570
603
  //#region src/transforms/server-action.d.ts
571
604
  declare function transformServerActionServer(input: string, ast: Program, options: {
@@ -581,4 +614,4 @@ declare function transformServerActionServer(input: string, ast: Program, option
581
614
  names: string[];
582
615
  };
583
616
  //#endregion
584
- export { transformDirectiveProxyExport as a, TransformWrapExportOptions as c, transformHoistInlineDirective as d, TransformProxyExportOptions as i, transformWrapExport as l, getExportNames as n, transformProxyExport as o, hasDirective as r, TransformWrapExportFilter as s, transformServerActionServer as t, findDirectives as u };
617
+ export { hasDirective as a, transformDirectiveProxyExport as c, TransformWrapExportOptions as d, transformWrapExport as f, getExportNames as i, transformProxyExport as l, transformHoistInlineDirective as m, extractIdentifiers as n, validateNonAsyncFunction as o, findDirectives as p, extractNames as r, TransformProxyExportOptions as s, transformServerActionServer as t, TransformWrapExportFilter as u };
@@ -0,0 +1,70 @@
1
+ //#region src/types/index.d.ts
2
+ interface ImportManifestEntry {
3
+ id: string;
4
+ name: string;
5
+ chunks: string[];
6
+ async?: boolean;
7
+ }
8
+ interface BundlerConfig {
9
+ [bundlerId: string]: ImportManifestEntry;
10
+ }
11
+ type ModuleMap = {
12
+ [id: string]: {
13
+ [exportName: string]: ImportManifestEntry;
14
+ };
15
+ };
16
+ interface ServerConsumerManifest {
17
+ moduleMap?: ModuleMap;
18
+ serverModuleMap?: BundlerConfig;
19
+ moduleLoading?: {
20
+ prefix: string;
21
+ crossOriign?: string;
22
+ };
23
+ }
24
+ type CallServerCallback = (id: string, args: unknown[]) => Promise<unknown>;
25
+ interface RenderToReadableStreamOptions {
26
+ debugChannel?: DebugChannel;
27
+ environmentName?: string | (() => string);
28
+ filterStackFrame?: (url: string, functionName: string) => boolean;
29
+ identifierPrefix?: string;
30
+ signal?: AbortSignal;
31
+ startTime?: number;
32
+ temporaryReferences?: ServerTemporaryReferenceSet;
33
+ onError?: (error: unknown) => void;
34
+ }
35
+ interface CreateFromReadableStreamBrowserOptions {
36
+ callServer?: CallServerCallback;
37
+ debugChannel?: DebugChannel;
38
+ endTime?: number;
39
+ environmentName?: string;
40
+ replayConsoleLogs?: boolean;
41
+ startTime?: number;
42
+ temporaryReferences?: ClientTemporaryReferenceSet;
43
+ }
44
+ interface CreateFromReadableStreamEdgeOptions {
45
+ debugChannel?: DebugChannel;
46
+ endTime?: number;
47
+ environmentName?: string;
48
+ nonce?: string;
49
+ replayConsoleLogs?: boolean;
50
+ startTime?: number;
51
+ temporaryReferences?: ClientTemporaryReferenceSet;
52
+ }
53
+ interface DecodeReplyOptions {
54
+ temporaryReferences?: ServerTemporaryReferenceSet;
55
+ arraySizeLimit?: number;
56
+ }
57
+ interface EncodeReplyOptions {
58
+ temporaryReferences?: ClientTemporaryReferenceSet;
59
+ signal?: AbortSignal;
60
+ }
61
+ type EncodeReplyFunction = (value: unknown[], options?: EncodeReplyOptions) => Promise<string | FormData>;
62
+ type DecodeReplyFunction = (body: string | FormData, options?: DecodeReplyOptions) => Promise<unknown[]>;
63
+ type DebugChannel = {
64
+ readable?: ReadableStream<Uint8Array>;
65
+ writable?: WritableStream<Uint8Array>;
66
+ };
67
+ type ServerTemporaryReferenceSet = unknown;
68
+ type ClientTemporaryReferenceSet = unknown;
69
+ //#endregion
70
+ export { CreateFromReadableStreamEdgeOptions as a, ModuleMap as c, ServerTemporaryReferenceSet as d, CreateFromReadableStreamBrowserOptions as i, RenderToReadableStreamOptions as l, CallServerCallback as n, DecodeReplyFunction as o, ClientTemporaryReferenceSet as r, EncodeReplyFunction as s, BundlerConfig as t, ServerConsumerManifest as u };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import "./import-environment-B994HXEc.js";
2
- import "./server-action-B2zS9t-J.js";
3
- import vitePluginRsc, { PluginApi, RscPluginOptions, getPluginApi } from "./plugin.js";
1
+ import { c as getPluginApi, r as PluginApi, s as RscPluginOptions, u as vitePluginRsc } from "./plugin-DGxRH4Nv.js";
4
2
  export { type PluginApi, type RscPluginOptions, vitePluginRsc as default, getPluginApi };
package/dist/index.js CHANGED
@@ -1,6 +1,2 @@
1
- import "./cjs-v2jRTNln.js";
2
- import "./validate-import-DJumtHRw.js";
3
- import "./server-action-JkEy-6yW.js";
4
- import vitePluginRsc, { getPluginApi } from "./plugin.js";
5
-
6
- export { vitePluginRsc as default, getPluginApi };
1
+ import { r as vitePluginRsc, t as getPluginApi } from "./plugin-DMfc_Eqq.js";
2
+ export { vitePluginRsc as default, getPluginApi };
@@ -1,5 +1,4 @@
1
- import { t as __commonJSMin } from "./chunk-f2BShn47.js";
2
-
1
+ import { t as __commonJSMin } from "./chunk-BYIdrdsR.js";
3
2
  //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
4
3
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
4
  let p = process || {}, argv = p.argv || [], env = p.env || {};
@@ -67,8 +66,6 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
67
66
  module.exports = createColors();
68
67
  module.exports.createColors = createColors;
69
68
  }));
70
-
71
69
  //#endregion
72
70
  export default require_picocolors();
73
-
74
- export { };
71
+ export {};
@@ -0,0 +1,185 @@
1
+ import { u as TransformWrapExportFilter } from "./index-2GoUFmVR.js";
2
+ import MagicString from "magic-string";
3
+ import { Plugin, ResolvedConfig, Rollup, ViteDevServer, parseAstAsync } from "vite";
4
+
5
+ //#region src/plugins/import-environment.d.ts
6
+ type EnvironmentImportMeta = {
7
+ resolvedId: string;
8
+ targetEnv: string;
9
+ sourceEnv: string;
10
+ specifier: string;
11
+ };
12
+ //#endregion
13
+ //#region src/plugin.d.ts
14
+ type ClientReferenceMeta = {
15
+ importId: string;
16
+ referenceKey: string;
17
+ packageSource?: string;
18
+ exportNames: string[];
19
+ renderedExports: string[];
20
+ serverChunk?: string;
21
+ groupChunkId?: string;
22
+ };
23
+ type ServerRerferenceMeta = {
24
+ importId: string;
25
+ referenceKey: string;
26
+ exportNames: string[];
27
+ };
28
+ /**
29
+ * @experimental
30
+ */
31
+ declare class RscPluginManager {
32
+ server!: ViteDevServer;
33
+ config!: ResolvedConfig;
34
+ bundles: Record<string, Rollup.OutputBundle>;
35
+ buildAssetsManifest: AssetsManifest | undefined;
36
+ isScanBuild: boolean;
37
+ clientReferenceMetaMap: Record<string, ClientReferenceMeta>;
38
+ clientReferenceGroups: Record<string, ClientReferenceMeta[]>;
39
+ serverReferenceMetaMap: Record<string, ServerRerferenceMeta>;
40
+ serverResourcesMetaMap: Record<string, {
41
+ key: string;
42
+ }>;
43
+ environmentImportMetaMap: Record<string, Record<string, Record<string, EnvironmentImportMeta>>>;
44
+ stabilize(): void;
45
+ toRelativeId(id: string): string;
46
+ writeAssetsManifest(environmentNames: string[]): void;
47
+ writeEnvironmentImportsManifest(): void;
48
+ }
49
+ type RscPluginOptions = {
50
+ /**
51
+ * shorthand for configuring `environments.(name).build.rollupOptions.input.index`
52
+ */
53
+ entries?: Partial<Record<"client" | "ssr" | "rsc", string>>; /** @default { enviornmentName: "rsc", entryName: "index" } */
54
+ serverHandler?: {
55
+ environmentName: string;
56
+ entryName: string;
57
+ } | false; /** @default false */
58
+ loadModuleDevProxy?: boolean;
59
+ rscCssTransform?: false | {
60
+ filter?: (id: string) => boolean;
61
+ };
62
+ /**
63
+ * @deprecated This option is a no-op and will be removed in a future major.
64
+ */
65
+ copyServerAssetsToClient?: (fileName: string) => boolean;
66
+ /**
67
+ * This option allows disabling action closure encryption for debugging purpose.
68
+ * @default true
69
+ */
70
+ enableActionEncryption?: boolean;
71
+ /**
72
+ * By default, the plugin uses a build-time generated encryption key for
73
+ * "use server" closure argument binding.
74
+ * This can be overwritten by configuring `defineEncryptionKey` option,
75
+ * for example, to obtain a key through environment variable during runtime.
76
+ * cf. https://nextjs.org/docs/app/guides/data-security#overwriting-encryption-keys-advanced
77
+ */
78
+ defineEncryptionKey?: string; /** Escape hatch for Waku's `allowServer` */
79
+ keepUseCientProxy?: boolean;
80
+ /**
81
+ * Enable build-time validation of 'client-only' and 'server-only' imports
82
+ * @default true
83
+ */
84
+ validateImports?: boolean;
85
+ /**
86
+ * use `Plugin.buildApp` hook (introduced on Vite 7) instead of `builder.buildApp` configuration
87
+ * for better composability with other plugins.
88
+ * @default true since Vite 7
89
+ */
90
+ useBuildAppHook?: boolean;
91
+ /**
92
+ * Skip the default buildApp orchestration for downstream frameworks
93
+ * to implement custom build pipelines using `getPluginApi()`.
94
+ * @experimental
95
+ * @default false
96
+ */
97
+ customBuildApp?: boolean;
98
+ /**
99
+ * Custom environment configuration
100
+ * @experimental
101
+ * @default { browser: 'client', ssr: 'ssr', rsc: 'rsc' }
102
+ */
103
+ environment?: {
104
+ browser?: string;
105
+ ssr?: string;
106
+ rsc?: string;
107
+ };
108
+ /**
109
+ * Custom chunking strategy for client reference modules.
110
+ *
111
+ * This function allows you to group multiple client components into
112
+ * custom chunks instead of having each module in its own chunk.
113
+ * By default, client chunks are grouped by `meta.serverChunk`.
114
+ */
115
+ clientChunks?: (meta: {
116
+ /** client reference module id */id: string; /** normalized client reference module id */
117
+ normalizedId: string; /** server chunk which includes a corresponding client reference proxy module */
118
+ serverChunk: string;
119
+ }) => string | undefined;
120
+ /**
121
+ * Controls whether CSS links use React's `precedence` attribute.
122
+ * @experimental
123
+ * @default true
124
+ */
125
+ cssLinkPrecedence?: boolean;
126
+ /**
127
+ * Opt out of the default "index" client entry convention.
128
+ * When enabled, the plugin will not:
129
+ * - Require an entry chunk named "index"
130
+ * - Automatically include client entry deps in each client reference's dependencies
131
+ *
132
+ * Note: `import.meta.viteRsc.loadBootstrapScriptContent` cannot be used with this option.
133
+ *
134
+ * Use this when you manually handle client entry setup and preloading.
135
+ *
136
+ * @experimental
137
+ * @default false
138
+ */
139
+ customClientEntry?: boolean;
140
+ };
141
+ type PluginApi = {
142
+ manager: RscPluginManager;
143
+ };
144
+ /** @experimental */
145
+ declare function getPluginApi(config: Pick<ResolvedConfig, "plugins">): PluginApi | undefined;
146
+ /** @experimental */
147
+ declare function vitePluginRscMinimal(rscPluginOptions?: RscPluginOptions, manager?: RscPluginManager): Plugin[];
148
+ declare global {
149
+ function __VITE_ENVIRONMENT_RUNNER_IMPORT__(environmentName: string, id: string): Promise<any>;
150
+ }
151
+ declare function vitePluginRsc(rscPluginOptions?: RscPluginOptions): Plugin[];
152
+ declare class RuntimeAsset {
153
+ runtime: string;
154
+ constructor(value: string);
155
+ }
156
+ type AssetsManifest = {
157
+ bootstrapScriptContent: string | RuntimeAsset;
158
+ clientReferenceDeps: Record<string, AssetDeps>;
159
+ serverResources?: Record<string, Pick<AssetDeps, "css">>;
160
+ cssLinkPrecedence?: boolean;
161
+ };
162
+ type AssetDeps = {
163
+ js: (string | RuntimeAsset)[];
164
+ css: (string | RuntimeAsset)[];
165
+ };
166
+ type ResolvedAssetsManifest = {
167
+ bootstrapScriptContent: string;
168
+ clientReferenceDeps: Record<string, ResolvedAssetDeps>;
169
+ serverResources?: Record<string, Pick<ResolvedAssetDeps, "css">>;
170
+ cssLinkPrecedence?: boolean;
171
+ };
172
+ type ResolvedAssetDeps = {
173
+ js: string[];
174
+ css: string[];
175
+ };
176
+ declare function transformRscCssExport(options: {
177
+ ast: Awaited<ReturnType<typeof parseAstAsync>>;
178
+ code: string;
179
+ id?: string;
180
+ filter: TransformWrapExportFilter;
181
+ }): Promise<{
182
+ output: MagicString;
183
+ } | undefined>;
184
+ //#endregion
185
+ export { ResolvedAssetsManifest as a, getPluginApi as c, vitePluginRscMinimal as d, ResolvedAssetDeps as i, transformRscCssExport as l, AssetsManifest as n, RscPluginManager as o, PluginApi as r, RscPluginOptions as s, AssetDeps as t, vitePluginRsc as u };