@cedarjs/vite 5.0.0-canary.2595 → 5.0.0-rc.261
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/bundled/react-server-dom-webpack.server.js +28528 -1231
- package/dist/cjs/devFeServer.js +15 -280
- package/dist/cjs/index.js +8 -7
- package/dist/cjs/lib/registerFwGlobalsAndShims.js +0 -9
- package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +2 -2
- package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +0 -4
- package/dist/cjs/rsc/rscRenderer.js +9 -23
- package/dist/cjs/rsc/rscRequestHandler.js +6 -6
- package/dist/cjs/runFeServer.js +22 -3
- package/dist/cjs/streaming/createReactStreamingHandler.js +10 -13
- package/dist/cjs/streaming/streamHelpers.js +32 -49
- package/dist/cjs/streaming/triggerRouteHooks.js +3 -3
- package/dist/devFeServer.js +16 -284
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/lib/registerFwGlobalsAndShims.js +0 -9
- package/dist/plugins/vite-plugin-rsc-ssr-router-import.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-rsc-ssr-router-import.js +2 -2
- package/dist/plugins/vite-plugin-rsc-transform-server.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-rsc-transform-server.js +0 -4
- package/dist/rsc/rscRenderer.d.ts.map +1 -1
- package/dist/rsc/rscRenderer.js +5 -19
- package/dist/rsc/rscRequestHandler.d.ts +2 -2
- package/dist/rsc/rscRequestHandler.d.ts.map +1 -1
- package/dist/rsc/rscRequestHandler.js +4 -4
- package/dist/runFeServer.js +21 -2
- package/dist/streaming/createReactStreamingHandler.d.ts +1 -1
- package/dist/streaming/createReactStreamingHandler.d.ts.map +1 -1
- package/dist/streaming/createReactStreamingHandler.js +10 -13
- package/dist/streaming/streamHelpers.d.ts +2 -2
- package/dist/streaming/streamHelpers.d.ts.map +1 -1
- package/dist/streaming/streamHelpers.js +31 -49
- package/dist/streaming/triggerRouteHooks.d.ts +2 -2
- package/dist/streaming/triggerRouteHooks.d.ts.map +1 -1
- package/dist/streaming/triggerRouteHooks.js +3 -3
- package/package.json +18 -18
- package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +0 -126
- package/dist/cjs/rsc/rscWebSocketServer.js +0 -56
- package/dist/cjs/rsc/utils.js +0 -56
- package/dist/plugins/vite-plugin-cedar-routes-auto-loader.d.ts +0 -24
- package/dist/plugins/vite-plugin-cedar-routes-auto-loader.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-routes-auto-loader.js +0 -98
- package/dist/rsc/rscWebSocketServer.d.ts +0 -2
- package/dist/rsc/rscWebSocketServer.d.ts.map +0 -1
- package/dist/rsc/rscWebSocketServer.js +0 -22
- package/dist/rsc/utils.d.ts +0 -10
- package/dist/rsc/utils.d.ts.map +0 -1
- package/dist/rsc/utils.js +0 -21
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var vite_plugin_cedar_routes_auto_loader_exports = {};
|
|
30
|
-
__export(vite_plugin_cedar_routes_auto_loader_exports, {
|
|
31
|
-
cedarRoutesAutoLoaderPlugin: () => cedarRoutesAutoLoaderPlugin
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(vite_plugin_cedar_routes_auto_loader_exports);
|
|
34
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
36
|
-
var import_vite = require("vite");
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
function getPathRelativeToSrc(maybeAbsolutePath) {
|
|
39
|
-
const withoutExt = maybeAbsolutePath.replace(/\.[^/.]+$/, "");
|
|
40
|
-
if (withoutExt.startsWith("src/")) {
|
|
41
|
-
const basePath = import_node_path.default.join((0, import_project_config.getPaths)().web.base, withoutExt);
|
|
42
|
-
const resolved = (0, import_project_config.resolveFile)(basePath) || (0, import_project_config.resolveFile)(import_node_path.default.join(basePath, "index")) || (0, import_project_config.resolveFile)(import_node_path.default.join(basePath, import_node_path.default.basename(basePath)));
|
|
43
|
-
if (resolved) {
|
|
44
|
-
const resolvedWithoutExt = resolved.replace(/\.[^/.]+$/, "");
|
|
45
|
-
return "./" + import_node_path.default.relative((0, import_project_config.getPaths)().web.src, resolvedWithoutExt);
|
|
46
|
-
}
|
|
47
|
-
return "./" + withoutExt.slice("src/".length);
|
|
48
|
-
}
|
|
49
|
-
if (!import_node_path.default.isAbsolute(withoutExt)) {
|
|
50
|
-
return withoutExt;
|
|
51
|
-
}
|
|
52
|
-
return `./${import_node_path.default.relative((0, import_project_config.getPaths)().web.src, withoutExt)}`;
|
|
53
|
-
}
|
|
54
|
-
function withRelativeImports(page) {
|
|
55
|
-
return {
|
|
56
|
-
...page,
|
|
57
|
-
relativeImport: (0, import_project_config.ensurePosixPath)(getPathRelativeToSrc(page.importPath))
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function cedarRoutesAutoLoaderPlugin() {
|
|
61
|
-
const routesFileId = (0, import_vite.normalizePath)((0, import_project_config.getPaths)().web.routes);
|
|
62
|
-
const initialPages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
|
|
63
|
-
const duplicatePageImportNames = /* @__PURE__ */ new Set();
|
|
64
|
-
const sortedPageImportNames = initialPages.map((page) => page.importName).sort();
|
|
65
|
-
for (let i = 0; i < sortedPageImportNames.length - 1; i++) {
|
|
66
|
-
if (sortedPageImportNames[i + 1] === sortedPageImportNames[i]) {
|
|
67
|
-
duplicatePageImportNames.add(sortedPageImportNames[i]);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (duplicatePageImportNames.size > 0) {
|
|
71
|
-
const pageNames = Array.from(duplicatePageImportNames).map((name) => `'${name}'`).join(", ");
|
|
72
|
-
throw new Error(
|
|
73
|
-
`Unable to find only a single file ending in 'Page.{js,jsx,ts,tsx}' in the following page directories: ${pageNames}`
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
name: "cedar-routes-auto-loader",
|
|
78
|
-
transform(code, id) {
|
|
79
|
-
if ((0, import_vite.normalizePath)(id) !== routesFileId) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
let pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
|
|
83
|
-
const importRe = /^import\s+\w+\s+from\s+['"]([^'"]+)['"]/gm;
|
|
84
|
-
const appPath = (0, import_project_config.resolveFile)(import_node_path.default.join((0, import_project_config.getPaths)().web.src, "App"));
|
|
85
|
-
if (appPath) {
|
|
86
|
-
const appSource = import_node_fs.default.readFileSync(appPath, "utf8");
|
|
87
|
-
let appMatch;
|
|
88
|
-
while ((appMatch = importRe.exec(appSource)) !== null) {
|
|
89
|
-
const rel = (0, import_project_config.ensurePosixPath)(
|
|
90
|
-
getPathRelativeToSrc((0, import_project_config.importStatementPath)(appMatch[1]))
|
|
91
|
-
);
|
|
92
|
-
pages = pages.filter((page) => page.relativeImport !== rel);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
importRe.lastIndex = 0;
|
|
96
|
-
let routesMatch;
|
|
97
|
-
while ((routesMatch = importRe.exec(code)) !== null) {
|
|
98
|
-
const rel = (0, import_project_config.ensurePosixPath)(
|
|
99
|
-
getPathRelativeToSrc((0, import_project_config.importStatementPath)(routesMatch[1]))
|
|
100
|
-
);
|
|
101
|
-
pages = pages.filter((page) => page.relativeImport !== rel);
|
|
102
|
-
}
|
|
103
|
-
if (pages.length === 0) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const lines = [`import { lazy } from 'react'`];
|
|
107
|
-
for (const { importName, relativeImport } of pages) {
|
|
108
|
-
lines.push(
|
|
109
|
-
`const ${importName} = {`,
|
|
110
|
-
` name: "${importName}",`,
|
|
111
|
-
` prerenderLoader: (name) => ({ default: globalThis.__REDWOOD__PRERENDER_PAGES[name] }),`,
|
|
112
|
-
` LazyComponent: lazy(() => import("${relativeImport}")),`,
|
|
113
|
-
`}`
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
code: lines.join("\n") + "\n\n" + code,
|
|
118
|
-
map: null
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
-
0 && (module.exports = {
|
|
125
|
-
cedarRoutesAutoLoaderPlugin
|
|
126
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var rscWebSocketServer_exports = {};
|
|
30
|
-
__export(rscWebSocketServer_exports, {
|
|
31
|
-
createWebSocketServer: () => createWebSocketServer
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(rscWebSocketServer_exports);
|
|
34
|
-
var import_ws = __toESM(require("ws"), 1);
|
|
35
|
-
function createWebSocketServer() {
|
|
36
|
-
const wsServer = new import_ws.WebSocketServer({ port: 18998 });
|
|
37
|
-
wsServer.on("connection", (ws) => {
|
|
38
|
-
console.log("A new client connected.");
|
|
39
|
-
ws.on("message", (data) => {
|
|
40
|
-
const message = data.toString();
|
|
41
|
-
console.log("Received message:", message);
|
|
42
|
-
wsServer.clients.forEach((client) => {
|
|
43
|
-
if (client.readyState === import_ws.default.OPEN) {
|
|
44
|
-
client.send(message);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
ws.on("close", () => {
|
|
49
|
-
console.log("A client disconnected.");
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
createWebSocketServer
|
|
56
|
-
});
|
package/dist/cjs/rsc/utils.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var utils_exports = {};
|
|
30
|
-
__export(utils_exports, {
|
|
31
|
-
importRscReact: () => importRscReact,
|
|
32
|
-
importRsdwServer: () => importRsdwServer
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(utils_exports);
|
|
35
|
-
async function importRscReact() {
|
|
36
|
-
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
37
|
-
const reactMod = await globalThis.__cedarjs__vite_rsc_runtime.import("react");
|
|
38
|
-
return reactMod.default;
|
|
39
|
-
}
|
|
40
|
-
return import("react");
|
|
41
|
-
}
|
|
42
|
-
async function importRsdwServer() {
|
|
43
|
-
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
44
|
-
const rsdwServerMod = await globalThis.__cedarjs__vite_rsc_runtime.import(
|
|
45
|
-
"react-server-dom-webpack/server.edge"
|
|
46
|
-
);
|
|
47
|
-
return rsdwServerMod.default;
|
|
48
|
-
} else {
|
|
49
|
-
return import("react-server-dom-webpack/server.edge");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
-
0 && (module.exports = {
|
|
54
|
-
importRscReact,
|
|
55
|
-
importRsdwServer
|
|
56
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Vite plugin to auto-load page components into the Routes file.
|
|
4
|
-
*
|
|
5
|
-
* For each page found in `web/src/pages` that is not already explicitly
|
|
6
|
-
* imported in Routes.tsx, this plugin prepends a lazy-loaded declaration:
|
|
7
|
-
*
|
|
8
|
-
* ```js
|
|
9
|
-
* const PageName = {
|
|
10
|
-
* name: "PageName",
|
|
11
|
-
* prerenderLoader: (name) => ({ default: globalThis.__REDWOOD__PRERENDER_PAGES[name] }),
|
|
12
|
-
* LazyComponent: lazy(() => import("./pages/PageName/PageName")),
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Pages already imported by App.tsx are also excluded to avoid Vite's
|
|
17
|
-
* "dynamically imported by Routes.tsx but also statically imported by App.tsx"
|
|
18
|
-
* warning.
|
|
19
|
-
*
|
|
20
|
-
* This replaces `babel-plugin-redwood-routes-auto-loader` for Vite builds.
|
|
21
|
-
* The babel plugin is still used for Jest and prerender.
|
|
22
|
-
*/
|
|
23
|
-
export declare function cedarRoutesAutoLoaderPlugin(): Plugin;
|
|
24
|
-
//# sourceMappingURL=vite-plugin-cedar-routes-auto-loader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-routes-auto-loader.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-routes-auto-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAqDlC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAsFpD"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { normalizePath } from "vite";
|
|
4
|
-
import {
|
|
5
|
-
ensurePosixPath,
|
|
6
|
-
getPaths,
|
|
7
|
-
importStatementPath,
|
|
8
|
-
processPagesDir,
|
|
9
|
-
resolveFile
|
|
10
|
-
} from "@cedarjs/project-config";
|
|
11
|
-
function getPathRelativeToSrc(maybeAbsolutePath) {
|
|
12
|
-
const withoutExt = maybeAbsolutePath.replace(/\.[^/.]+$/, "");
|
|
13
|
-
if (withoutExt.startsWith("src/")) {
|
|
14
|
-
const basePath = path.join(getPaths().web.base, withoutExt);
|
|
15
|
-
const resolved = resolveFile(basePath) || resolveFile(path.join(basePath, "index")) || resolveFile(path.join(basePath, path.basename(basePath)));
|
|
16
|
-
if (resolved) {
|
|
17
|
-
const resolvedWithoutExt = resolved.replace(/\.[^/.]+$/, "");
|
|
18
|
-
return "./" + path.relative(getPaths().web.src, resolvedWithoutExt);
|
|
19
|
-
}
|
|
20
|
-
return "./" + withoutExt.slice("src/".length);
|
|
21
|
-
}
|
|
22
|
-
if (!path.isAbsolute(withoutExt)) {
|
|
23
|
-
return withoutExt;
|
|
24
|
-
}
|
|
25
|
-
return `./${path.relative(getPaths().web.src, withoutExt)}`;
|
|
26
|
-
}
|
|
27
|
-
function withRelativeImports(page) {
|
|
28
|
-
return {
|
|
29
|
-
...page,
|
|
30
|
-
relativeImport: ensurePosixPath(getPathRelativeToSrc(page.importPath))
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function cedarRoutesAutoLoaderPlugin() {
|
|
34
|
-
const routesFileId = normalizePath(getPaths().web.routes);
|
|
35
|
-
const initialPages = processPagesDir().map(withRelativeImports);
|
|
36
|
-
const duplicatePageImportNames = /* @__PURE__ */ new Set();
|
|
37
|
-
const sortedPageImportNames = initialPages.map((page) => page.importName).sort();
|
|
38
|
-
for (let i = 0; i < sortedPageImportNames.length - 1; i++) {
|
|
39
|
-
if (sortedPageImportNames[i + 1] === sortedPageImportNames[i]) {
|
|
40
|
-
duplicatePageImportNames.add(sortedPageImportNames[i]);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (duplicatePageImportNames.size > 0) {
|
|
44
|
-
const pageNames = Array.from(duplicatePageImportNames).map((name) => `'${name}'`).join(", ");
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Unable to find only a single file ending in 'Page.{js,jsx,ts,tsx}' in the following page directories: ${pageNames}`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
name: "cedar-routes-auto-loader",
|
|
51
|
-
transform(code, id) {
|
|
52
|
-
if (normalizePath(id) !== routesFileId) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
let pages = processPagesDir().map(withRelativeImports);
|
|
56
|
-
const importRe = /^import\s+\w+\s+from\s+['"]([^'"]+)['"]/gm;
|
|
57
|
-
const appPath = resolveFile(path.join(getPaths().web.src, "App"));
|
|
58
|
-
if (appPath) {
|
|
59
|
-
const appSource = fs.readFileSync(appPath, "utf8");
|
|
60
|
-
let appMatch;
|
|
61
|
-
while ((appMatch = importRe.exec(appSource)) !== null) {
|
|
62
|
-
const rel = ensurePosixPath(
|
|
63
|
-
getPathRelativeToSrc(importStatementPath(appMatch[1]))
|
|
64
|
-
);
|
|
65
|
-
pages = pages.filter((page) => page.relativeImport !== rel);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
importRe.lastIndex = 0;
|
|
69
|
-
let routesMatch;
|
|
70
|
-
while ((routesMatch = importRe.exec(code)) !== null) {
|
|
71
|
-
const rel = ensurePosixPath(
|
|
72
|
-
getPathRelativeToSrc(importStatementPath(routesMatch[1]))
|
|
73
|
-
);
|
|
74
|
-
pages = pages.filter((page) => page.relativeImport !== rel);
|
|
75
|
-
}
|
|
76
|
-
if (pages.length === 0) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const lines = [`import { lazy } from 'react'`];
|
|
80
|
-
for (const { importName, relativeImport } of pages) {
|
|
81
|
-
lines.push(
|
|
82
|
-
`const ${importName} = {`,
|
|
83
|
-
` name: "${importName}",`,
|
|
84
|
-
` prerenderLoader: (name) => ({ default: globalThis.__REDWOOD__PRERENDER_PAGES[name] }),`,
|
|
85
|
-
` LazyComponent: lazy(() => import("${relativeImport}")),`,
|
|
86
|
-
`}`
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
code: lines.join("\n") + "\n\n" + code,
|
|
91
|
-
map: null
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
export {
|
|
97
|
-
cedarRoutesAutoLoaderPlugin
|
|
98
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rscWebSocketServer.d.ts","sourceRoot":"","sources":["../../src/rsc/rscWebSocketServer.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,SAwBpC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import WebSocket, { WebSocketServer } from "ws";
|
|
2
|
-
function createWebSocketServer() {
|
|
3
|
-
const wsServer = new WebSocketServer({ port: 18998 });
|
|
4
|
-
wsServer.on("connection", (ws) => {
|
|
5
|
-
console.log("A new client connected.");
|
|
6
|
-
ws.on("message", (data) => {
|
|
7
|
-
const message = data.toString();
|
|
8
|
-
console.log("Received message:", message);
|
|
9
|
-
wsServer.clients.forEach((client) => {
|
|
10
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
11
|
-
client.send(message);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
ws.on("close", () => {
|
|
16
|
-
console.log("A client disconnected.");
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
createWebSocketServer
|
|
22
|
-
};
|
package/dist/rsc/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { default as RSDWServerModule } from 'react-server-dom-webpack/server.edge';
|
|
2
|
-
type RSDWServerType = typeof RSDWServerModule;
|
|
3
|
-
/**
|
|
4
|
-
* This function ensures we load the version of React that's been imported with
|
|
5
|
-
* the react-server condition.
|
|
6
|
-
*/
|
|
7
|
-
export declare function importRscReact(): Promise<any>;
|
|
8
|
-
export declare function importRsdwServer(): Promise<RSDWServerType>;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/rsc/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/rsc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAEvF,KAAK,cAAc,GAAG,OAAO,gBAAgB,CAAA;AAE7C;;;GAGG;AACH,wBAAsB,cAAc,iBAQnC;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,cAAc,CAAC,CAUhE"}
|
package/dist/rsc/utils.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
async function importRscReact() {
|
|
2
|
-
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
3
|
-
const reactMod = await globalThis.__cedarjs__vite_rsc_runtime.import("react");
|
|
4
|
-
return reactMod.default;
|
|
5
|
-
}
|
|
6
|
-
return import("react");
|
|
7
|
-
}
|
|
8
|
-
async function importRsdwServer() {
|
|
9
|
-
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
10
|
-
const rsdwServerMod = await globalThis.__cedarjs__vite_rsc_runtime.import(
|
|
11
|
-
"react-server-dom-webpack/server.edge"
|
|
12
|
-
);
|
|
13
|
-
return rsdwServerMod.default;
|
|
14
|
-
} else {
|
|
15
|
-
return import("react-server-dom-webpack/server.edge");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
importRscReact,
|
|
20
|
-
importRsdwServer
|
|
21
|
-
};
|