@cedarjs/prerender 7.0.0-canary.2989 → 7.0.0-canary.2994
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/build-and-import/buildAndImport.d.ts +1 -1
- package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
- package/dist/{cjs/index.d.ts.map → index.d.ts.map} +1 -1
- package/dist/index.js +1 -0
- package/dist/runPrerender.d.ts.map +1 -0
- package/dist/{runPrerenderEsm.js → runPrerender.js} +47 -41
- package/package.json +18 -40
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-cell.js +0 -98
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -77
- package/dist/babelPlugins/utils.d.ts +0 -2
- package/dist/babelPlugins/utils.d.ts.map +0 -1
- package/dist/babelPlugins/utils.js +0 -15
- package/dist/cjs/apolloState.d.ts +0 -13
- package/dist/cjs/apolloState.d.ts.map +0 -1
- package/dist/cjs/apolloState.js +0 -30
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +0 -122
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -101
- package/dist/cjs/babelPlugins/utils.d.ts +0 -2
- package/dist/cjs/babelPlugins/utils.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/utils.js +0 -49
- package/dist/cjs/browserUtils/index.d.ts +0 -8
- package/dist/cjs/browserUtils/index.d.ts.map +0 -1
- package/dist/cjs/browserUtils/index.js +0 -47
- package/dist/cjs/build-and-import/buildAndImport.js +0 -186
- package/dist/cjs/build-and-import/load-tsconfig.d.js +0 -1
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +0 -53
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +0 -184
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +0 -83
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +0 -125
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +0 -48
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +0 -66
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +0 -118
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +0 -146
- package/dist/cjs/build-and-import/rollupPlugins/utils.js +0 -78
- package/dist/cjs/build-and-import/utils.js +0 -68
- package/dist/cjs/detection/detection.d.ts +0 -11
- package/dist/cjs/detection/detection.d.ts.map +0 -1
- package/dist/cjs/detection/detection.js +0 -46
- package/dist/cjs/errors.d.ts +0 -19
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -52
- package/dist/cjs/graphql/graphql.d.ts +0 -19
- package/dist/cjs/graphql/graphql.d.ts.map +0 -1
- package/dist/cjs/graphql/graphql.js +0 -152
- package/dist/cjs/graphql/node-runner.js +0 -97
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +0 -107
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/internal.d.ts +0 -28
- package/dist/cjs/internal.d.ts.map +0 -1
- package/dist/cjs/internal.js +0 -135
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/runPrerender.d.ts.map +0 -1
- package/dist/cjs/runPrerender.js +0 -313
- package/dist/cjs/runPrerenderEsm.js +0 -310
- package/dist/runPrerenderEsm.d.ts +0 -9
- package/dist/runPrerenderEsm.d.ts.map +0 -1
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dist/{cjs/runPrerender.d.ts → runPrerender.d.ts} +0 -0
|
@@ -7,6 +7,6 @@ interface Options {
|
|
|
7
7
|
*/
|
|
8
8
|
preserveTemporaryFile?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare function buildAndImport(options: Options): Promise<Record<string, React.
|
|
10
|
+
export declare function buildAndImport(options: Options): Promise<Record<string, React.ElementType>>;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=buildAndImport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAndImport.d.ts","sourceRoot":"","sources":["../../src/build-and-import/buildAndImport.ts"],"names":[],"mappings":"AAqCA,UAAU,OAAO;IACf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"buildAndImport.d.ts","sourceRoot":"","sources":["../../src/build-and-import/buildAndImport.ts"],"names":[],"mappings":"AAqCA,UAAU,OAAO;IACf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CA4I5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./runPrerender.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../src/runPrerender.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAuQ7C,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACrC,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,YAAY,GAAU,6BAGhC,eAAe,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAqIzC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,MAAM,SAchB,CAAA"}
|
|
@@ -183,48 +183,54 @@ const runPrerender = async ({
|
|
|
183
183
|
}) => {
|
|
184
184
|
registerShims(renderPath);
|
|
185
185
|
const nodeRunner = new NodeRunner();
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
186
|
+
let componentAsHtml;
|
|
187
|
+
try {
|
|
188
|
+
const gqlHandler = await getGqlHandler(
|
|
189
|
+
nodeRunner.importFile.bind(nodeRunner)
|
|
190
|
+
);
|
|
191
|
+
const prerenderDistPath = path.join(getPaths().web.dist, "__prerender");
|
|
192
|
+
fs.mkdirSync(prerenderDistPath, { recursive: true });
|
|
193
|
+
if (!renderCache.App) {
|
|
194
|
+
const entryPath = await createCombinedEntry({
|
|
195
|
+
appPath: getPaths().web.app,
|
|
196
|
+
routesPath: getPaths().web.routes,
|
|
197
|
+
outDir: prerenderDistPath
|
|
198
|
+
});
|
|
199
|
+
const required = await buildAndImport({
|
|
200
|
+
filepath: entryPath,
|
|
201
|
+
preserveTemporaryFile: true
|
|
202
|
+
});
|
|
203
|
+
renderCache.App = required.App;
|
|
204
|
+
renderCache.Routes = required.Routes;
|
|
205
|
+
renderCache.CellCacheContextProvider = required.CellCacheContextProvider;
|
|
206
|
+
renderCache.LocationProvider = required.LocationProvider;
|
|
207
|
+
}
|
|
208
|
+
const { LocationProvider, App, Routes, CellCacheContextProvider } = renderCache;
|
|
209
|
+
if (!App) {
|
|
210
|
+
throw new Error("App not found");
|
|
211
|
+
}
|
|
212
|
+
if (!Routes) {
|
|
213
|
+
throw new Error("Routes not found");
|
|
214
|
+
}
|
|
215
|
+
if (!CellCacheContextProvider) {
|
|
216
|
+
throw new Error("CellCacheContextProvider not found");
|
|
217
|
+
}
|
|
218
|
+
if (!LocationProvider) {
|
|
219
|
+
throw new Error("LocationProvider not found");
|
|
220
|
+
}
|
|
221
|
+
componentAsHtml = await recursivelyRender(
|
|
222
|
+
App,
|
|
223
|
+
Routes,
|
|
224
|
+
CellCacheContextProvider,
|
|
225
|
+
LocationProvider,
|
|
226
|
+
renderPath,
|
|
227
|
+
nodeRunner.importFile.bind(nodeRunner),
|
|
228
|
+
gqlHandler,
|
|
229
|
+
queryCache
|
|
230
|
+
);
|
|
231
|
+
} finally {
|
|
232
|
+
await nodeRunner.close();
|
|
216
233
|
}
|
|
217
|
-
const componentAsHtml = await recursivelyRender(
|
|
218
|
-
App,
|
|
219
|
-
Routes,
|
|
220
|
-
CellCacheContextProvider,
|
|
221
|
-
LocationProvider,
|
|
222
|
-
renderPath,
|
|
223
|
-
nodeRunner.importFile.bind(nodeRunner),
|
|
224
|
-
gqlHandler,
|
|
225
|
-
queryCache
|
|
226
|
-
);
|
|
227
|
-
nodeRunner.close();
|
|
228
234
|
const { helmet } = globalThis.__REDWOOD__HELMET_CONTEXT;
|
|
229
235
|
Object.keys(queryCache).forEach((queryKey) => {
|
|
230
236
|
const { query, variables, data } = queryCache[queryKey];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/prerender",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.2994",
|
|
4
4
|
"description": "CedarJS prerender",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,38 +11,18 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"default": "./dist/runPrerenderEsm.js"
|
|
17
|
-
},
|
|
18
|
-
"require": {
|
|
19
|
-
"types": "./dist/cjs/runPrerender.d.ts",
|
|
20
|
-
"default": "./dist/cjs/runPrerender.js"
|
|
21
|
-
}
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
22
16
|
},
|
|
23
17
|
"./browserUtils": {
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"default": "./dist/browserUtils/index.js"
|
|
27
|
-
},
|
|
28
|
-
"require": {
|
|
29
|
-
"types": "./dist/cjs/browserUtils/index.d.ts",
|
|
30
|
-
"default": "./dist/cjs/browserUtils/index.js"
|
|
31
|
-
}
|
|
18
|
+
"types": "./dist/browserUtils/index.d.ts",
|
|
19
|
+
"default": "./dist/browserUtils/index.js"
|
|
32
20
|
},
|
|
33
21
|
"./detection": {
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"default": "./dist/detection/detection.js"
|
|
37
|
-
},
|
|
38
|
-
"require": {
|
|
39
|
-
"types": "./dist/cjs/detection/detection.d.ts",
|
|
40
|
-
"default": "./dist/cjs/detection/detection.js"
|
|
41
|
-
}
|
|
22
|
+
"types": "./dist/detection/detection.d.ts",
|
|
23
|
+
"default": "./dist/detection/detection.js"
|
|
42
24
|
}
|
|
43
25
|
},
|
|
44
|
-
"main": "dist/cjs/index.js",
|
|
45
|
-
"types": "./dist/cjs/index.d.ts",
|
|
46
26
|
"files": [
|
|
47
27
|
"dist"
|
|
48
28
|
],
|
|
@@ -50,7 +30,6 @@
|
|
|
50
30
|
"build": "node ./build.mts && yarn build:types",
|
|
51
31
|
"build:pack": "yarn pack -o cedarjs-prerender.tgz",
|
|
52
32
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
53
|
-
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
54
33
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
|
|
55
34
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
56
35
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
@@ -62,10 +41,10 @@
|
|
|
62
41
|
"@babel/generator": "7.29.8",
|
|
63
42
|
"@babel/parser": "7.29.8",
|
|
64
43
|
"@babel/traverse": "7.29.8",
|
|
65
|
-
"@cedarjs/babel-config": "7.0.0-canary.
|
|
66
|
-
"@cedarjs/project-config": "7.0.0-canary.
|
|
67
|
-
"@cedarjs/structure": "7.0.0-canary.
|
|
68
|
-
"@cedarjs/vite": "7.0.0-canary.
|
|
44
|
+
"@cedarjs/babel-config": "7.0.0-canary.2994",
|
|
45
|
+
"@cedarjs/project-config": "7.0.0-canary.2994",
|
|
46
|
+
"@cedarjs/structure": "7.0.0-canary.2994",
|
|
47
|
+
"@cedarjs/vite": "7.0.0-canary.2994",
|
|
69
48
|
"@rollup/plugin-alias": "5.1.1",
|
|
70
49
|
"@rollup/plugin-commonjs": "28.0.9",
|
|
71
50
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
@@ -83,22 +62,21 @@
|
|
|
83
62
|
"vite": "7.3.6"
|
|
84
63
|
},
|
|
85
64
|
"devDependencies": {
|
|
86
|
-
"@cedarjs/framework-tools": "7.0.0-canary.
|
|
87
|
-
"@cedarjs/router": "7.0.0-canary.
|
|
88
|
-
"@cedarjs/web": "7.0.0-canary.
|
|
65
|
+
"@cedarjs/framework-tools": "7.0.0-canary.2994",
|
|
66
|
+
"@cedarjs/router": "7.0.0-canary.2994",
|
|
67
|
+
"@cedarjs/web": "7.0.0-canary.2994",
|
|
89
68
|
"@types/mime-types": "2.1.4",
|
|
90
69
|
"@types/react": "^19.2.0",
|
|
91
|
-
"babel-plugin-tester": "11.0.4",
|
|
92
70
|
"concurrently": "9.2.4",
|
|
93
71
|
"publint": "0.3.23",
|
|
94
72
|
"typescript": "5.9.3",
|
|
95
73
|
"vitest": "4.1.10"
|
|
96
74
|
},
|
|
97
75
|
"peerDependencies": {
|
|
98
|
-
"@cedarjs/router": "7.0.0-canary.
|
|
99
|
-
"@cedarjs/web": "7.0.0-canary.
|
|
100
|
-
"react": "19.2.
|
|
101
|
-
"react-dom": "19.2.
|
|
76
|
+
"@cedarjs/router": "7.0.0-canary.2994",
|
|
77
|
+
"@cedarjs/web": "7.0.0-canary.2994",
|
|
78
|
+
"react": "19.2.8",
|
|
79
|
+
"react-dom": "19.2.8"
|
|
102
80
|
},
|
|
103
81
|
"engines": {
|
|
104
82
|
"node": ">=24"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAgCnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAmHZ"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { parse } from "path";
|
|
2
|
-
const EXPECTED_EXPORTS_FROM_CELL = [
|
|
3
|
-
"beforeQuery",
|
|
4
|
-
"QUERY",
|
|
5
|
-
"FRAGMENT",
|
|
6
|
-
"data",
|
|
7
|
-
"isEmpty",
|
|
8
|
-
"afterQuery",
|
|
9
|
-
"Loading",
|
|
10
|
-
"Success",
|
|
11
|
-
"Failure",
|
|
12
|
-
"Empty"
|
|
13
|
-
];
|
|
14
|
-
function babelPluginRedwoodCell({
|
|
15
|
-
types: t
|
|
16
|
-
}) {
|
|
17
|
-
let exportNames = [];
|
|
18
|
-
let hasDefaultExport = false;
|
|
19
|
-
return {
|
|
20
|
-
name: "babel-plugin-redwood-cell",
|
|
21
|
-
visitor: {
|
|
22
|
-
ExportDefaultDeclaration() {
|
|
23
|
-
hasDefaultExport = true;
|
|
24
|
-
},
|
|
25
|
-
ExportNamedDeclaration(path) {
|
|
26
|
-
const declaration = path.node.declaration;
|
|
27
|
-
if (!declaration) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
let name;
|
|
31
|
-
if (declaration.type === "VariableDeclaration") {
|
|
32
|
-
const id = declaration.declarations[0].id;
|
|
33
|
-
name = id.name;
|
|
34
|
-
}
|
|
35
|
-
if (declaration.type === "FunctionDeclaration") {
|
|
36
|
-
name = declaration?.id?.name;
|
|
37
|
-
}
|
|
38
|
-
if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
|
|
39
|
-
exportNames.push(name);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
Program: {
|
|
43
|
-
enter() {
|
|
44
|
-
exportNames = [];
|
|
45
|
-
hasDefaultExport = false;
|
|
46
|
-
},
|
|
47
|
-
exit(path) {
|
|
48
|
-
const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
|
|
49
|
-
if (hasDefaultExport || !hasQueryOrDataExport) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
|
|
53
|
-
const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
|
|
54
|
-
path.node.body.unshift(
|
|
55
|
-
t.importDeclaration(
|
|
56
|
-
[
|
|
57
|
-
t.importSpecifier(
|
|
58
|
-
t.identifier(createCellHookName),
|
|
59
|
-
t.identifier(createCellHookName)
|
|
60
|
-
)
|
|
61
|
-
],
|
|
62
|
-
t.stringLiteral(importFrom)
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
path.node.body.push(
|
|
66
|
-
t.exportDefaultDeclaration(
|
|
67
|
-
t.callExpression(t.identifier(createCellHookName), [
|
|
68
|
-
t.objectExpression([
|
|
69
|
-
...exportNames.map(
|
|
70
|
-
(name) => t.objectProperty(
|
|
71
|
-
t.identifier(name),
|
|
72
|
-
t.identifier(name),
|
|
73
|
-
false,
|
|
74
|
-
true
|
|
75
|
-
)
|
|
76
|
-
),
|
|
77
|
-
// Add the `displayName` property so we can name the Cell
|
|
78
|
-
// after the filename.
|
|
79
|
-
t.objectProperty(
|
|
80
|
-
t.identifier("displayName"),
|
|
81
|
-
t.stringLiteral(
|
|
82
|
-
parse(this.file.opts.filename).name
|
|
83
|
-
),
|
|
84
|
-
false,
|
|
85
|
-
true
|
|
86
|
-
)
|
|
87
|
-
])
|
|
88
|
-
])
|
|
89
|
-
)
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
export {
|
|
97
|
-
babelPluginRedwoodCell
|
|
98
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-redwood-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/babel-plugin-redwood-prerender-media-imports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,aAAa,CAAA;AAuC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { extname, join, relative, dirname } from "path";
|
|
2
|
-
import { ensurePosixPath, getPaths } from "@cedarjs/project-config";
|
|
3
|
-
import { convertToDataUrl } from "./utils.js";
|
|
4
|
-
const defaultOptions = {
|
|
5
|
-
// Media file extensions that Vite emits as assets, and that we therefore
|
|
6
|
-
// have to resolve to their built asset path (or a data URL) when prerendering
|
|
7
|
-
extensions: [
|
|
8
|
-
".ico",
|
|
9
|
-
".jpg",
|
|
10
|
-
".jpeg",
|
|
11
|
-
".png",
|
|
12
|
-
".gif",
|
|
13
|
-
".svg",
|
|
14
|
-
".eot",
|
|
15
|
-
".otf",
|
|
16
|
-
".webp",
|
|
17
|
-
".ttf",
|
|
18
|
-
".woff",
|
|
19
|
-
".woff2",
|
|
20
|
-
".cur",
|
|
21
|
-
".ani",
|
|
22
|
-
".pdf",
|
|
23
|
-
".bmp"
|
|
24
|
-
]
|
|
25
|
-
};
|
|
26
|
-
function getVariableName(p) {
|
|
27
|
-
if (p.node.specifiers?.[0]?.local) {
|
|
28
|
-
return p.node.specifiers[0].local.name;
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
function babelPluginRedwoodPrerenderMediaImports({
|
|
33
|
-
types: t
|
|
34
|
-
}) {
|
|
35
|
-
const manifestPath = join(getPaths().web.dist, "client-build-manifest.json");
|
|
36
|
-
const buildManifest = require(manifestPath);
|
|
37
|
-
return {
|
|
38
|
-
name: "babel-plugin-redwood-prerender-media-imports",
|
|
39
|
-
visitor: {
|
|
40
|
-
ImportDeclaration(p, state) {
|
|
41
|
-
const importPath = p.node.source.value;
|
|
42
|
-
const ext = extname(importPath);
|
|
43
|
-
const options = {
|
|
44
|
-
...defaultOptions,
|
|
45
|
-
...state.opts
|
|
46
|
-
};
|
|
47
|
-
if (ext && options.extensions.includes(ext)) {
|
|
48
|
-
const importConstName = getVariableName(p);
|
|
49
|
-
if (state.filename === void 0) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const absPath = join(dirname(state.filename), p.node.source.value);
|
|
53
|
-
const viteManifestKey = ensurePosixPath(
|
|
54
|
-
relative(getPaths().web.src, absPath)
|
|
55
|
-
);
|
|
56
|
-
const copiedAssetPath = buildManifest[viteManifestKey]?.file;
|
|
57
|
-
const assetSrc = copiedAssetPath ?? convertToDataUrl(
|
|
58
|
-
join(state.file.opts.sourceRoot || "./", importPath)
|
|
59
|
-
);
|
|
60
|
-
if (importConstName) {
|
|
61
|
-
p.replaceWith(
|
|
62
|
-
t.variableDeclaration("const", [
|
|
63
|
-
t.variableDeclarator(
|
|
64
|
-
t.identifier(importConstName),
|
|
65
|
-
t.stringLiteral(assetSrc)
|
|
66
|
-
)
|
|
67
|
-
])
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
babelPluginRedwoodPrerenderMediaImports
|
|
77
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,UASjD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import mime from "mime-types";
|
|
3
|
-
function convertToDataUrl(assetPath) {
|
|
4
|
-
try {
|
|
5
|
-
const base64AssetContents = fs.readFileSync(assetPath, "base64");
|
|
6
|
-
const mimeType = mime.lookup(assetPath);
|
|
7
|
-
return `data:${mimeType};base64,${base64AssetContents}`;
|
|
8
|
-
} catch {
|
|
9
|
-
console.warn(`Could not read file ${assetPath} for conversion to data uri`);
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
convertToDataUrl
|
|
15
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether an extracted Apollo cache state is non-empty and worth inlining
|
|
3
|
-
* into the prerendered HTML as a bootstrap `<script>`.
|
|
4
|
-
*
|
|
5
|
-
* Only emit the Apollo state bootstrap when there is state to restore. Both
|
|
6
|
-
* consumers (`CedarApolloProvider` and the suspense provider) already do
|
|
7
|
-
* `.restore(globalThis?.__CEDAR__APOLLO_STATE ?? {})`, so an empty payload is
|
|
8
|
-
* a no-op. It is still an inline `<script>` though, which every strict-CSP app
|
|
9
|
-
* has to allow-list with a hash that goes stale whenever the payload changes.
|
|
10
|
-
* A page that prerenders no Cells emits nothing.
|
|
11
|
-
*/
|
|
12
|
-
export declare function hasApolloState(state: unknown): state is Record<string, unknown>;
|
|
13
|
-
//# sourceMappingURL=apolloState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apolloState.d.ts","sourceRoot":"","sources":["../../src/apolloState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIlC"}
|
package/dist/cjs/apolloState.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var apolloState_exports = {};
|
|
20
|
-
__export(apolloState_exports, {
|
|
21
|
-
hasApolloState: () => hasApolloState
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(apolloState_exports);
|
|
24
|
-
function hasApolloState(state) {
|
|
25
|
-
return typeof state === "object" && state !== null && Object.keys(state).length > 0;
|
|
26
|
-
}
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
hasApolloState
|
|
30
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAgCnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAmHZ"}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var babel_plugin_redwood_cell_exports = {};
|
|
20
|
-
__export(babel_plugin_redwood_cell_exports, {
|
|
21
|
-
babelPluginRedwoodCell: () => babelPluginRedwoodCell
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(babel_plugin_redwood_cell_exports);
|
|
24
|
-
var import_path = require("path");
|
|
25
|
-
const EXPECTED_EXPORTS_FROM_CELL = [
|
|
26
|
-
"beforeQuery",
|
|
27
|
-
"QUERY",
|
|
28
|
-
"FRAGMENT",
|
|
29
|
-
"data",
|
|
30
|
-
"isEmpty",
|
|
31
|
-
"afterQuery",
|
|
32
|
-
"Loading",
|
|
33
|
-
"Success",
|
|
34
|
-
"Failure",
|
|
35
|
-
"Empty"
|
|
36
|
-
];
|
|
37
|
-
function babelPluginRedwoodCell({
|
|
38
|
-
types: t
|
|
39
|
-
}) {
|
|
40
|
-
let exportNames = [];
|
|
41
|
-
let hasDefaultExport = false;
|
|
42
|
-
return {
|
|
43
|
-
name: "babel-plugin-redwood-cell",
|
|
44
|
-
visitor: {
|
|
45
|
-
ExportDefaultDeclaration() {
|
|
46
|
-
hasDefaultExport = true;
|
|
47
|
-
},
|
|
48
|
-
ExportNamedDeclaration(path) {
|
|
49
|
-
const declaration = path.node.declaration;
|
|
50
|
-
if (!declaration) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
let name;
|
|
54
|
-
if (declaration.type === "VariableDeclaration") {
|
|
55
|
-
const id = declaration.declarations[0].id;
|
|
56
|
-
name = id.name;
|
|
57
|
-
}
|
|
58
|
-
if (declaration.type === "FunctionDeclaration") {
|
|
59
|
-
name = declaration?.id?.name;
|
|
60
|
-
}
|
|
61
|
-
if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
|
|
62
|
-
exportNames.push(name);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
Program: {
|
|
66
|
-
enter() {
|
|
67
|
-
exportNames = [];
|
|
68
|
-
hasDefaultExport = false;
|
|
69
|
-
},
|
|
70
|
-
exit(path) {
|
|
71
|
-
const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
|
|
72
|
-
if (hasDefaultExport || !hasQueryOrDataExport) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
|
|
76
|
-
const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
|
|
77
|
-
path.node.body.unshift(
|
|
78
|
-
t.importDeclaration(
|
|
79
|
-
[
|
|
80
|
-
t.importSpecifier(
|
|
81
|
-
t.identifier(createCellHookName),
|
|
82
|
-
t.identifier(createCellHookName)
|
|
83
|
-
)
|
|
84
|
-
],
|
|
85
|
-
t.stringLiteral(importFrom)
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
path.node.body.push(
|
|
89
|
-
t.exportDefaultDeclaration(
|
|
90
|
-
t.callExpression(t.identifier(createCellHookName), [
|
|
91
|
-
t.objectExpression([
|
|
92
|
-
...exportNames.map(
|
|
93
|
-
(name) => t.objectProperty(
|
|
94
|
-
t.identifier(name),
|
|
95
|
-
t.identifier(name),
|
|
96
|
-
false,
|
|
97
|
-
true
|
|
98
|
-
)
|
|
99
|
-
),
|
|
100
|
-
// Add the `displayName` property so we can name the Cell
|
|
101
|
-
// after the filename.
|
|
102
|
-
t.objectProperty(
|
|
103
|
-
t.identifier("displayName"),
|
|
104
|
-
t.stringLiteral(
|
|
105
|
-
(0, import_path.parse)(this.file.opts.filename).name
|
|
106
|
-
),
|
|
107
|
-
false,
|
|
108
|
-
true
|
|
109
|
-
)
|
|
110
|
-
])
|
|
111
|
-
])
|
|
112
|
-
)
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
-
0 && (module.exports = {
|
|
121
|
-
babelPluginRedwoodCell
|
|
122
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-redwood-prerender-media-imports.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/babel-plugin-redwood-prerender-media-imports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,aAAa,CAAA;AAuC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
|