@cedarjs/prerender 7.0.0-canary.3258 → 7.0.0-rc.123
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/babelPlugins/babel-plugin-redwood-cell.d.ts +5 -0
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/babelPlugins/babel-plugin-redwood-cell.js +98 -0
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +5 -0
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -0
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +77 -0
- package/dist/babelPlugins/utils.d.ts +2 -0
- package/dist/babelPlugins/utils.d.ts.map +1 -0
- package/dist/babelPlugins/utils.js +15 -0
- package/dist/browserUtils/index.d.ts +1 -1
- package/dist/browserUtils/index.d.ts.map +1 -1
- package/dist/build-and-import/buildAndImport.d.ts +1 -1
- package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
- package/dist/build-and-import/buildAndImport.js +9 -2
- package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map +1 -1
- package/dist/cjs/apolloState.d.ts +13 -0
- package/dist/cjs/apolloState.d.ts.map +1 -0
- package/dist/cjs/apolloState.js +30 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +5 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +122 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +5 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -0
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +101 -0
- package/dist/cjs/babelPlugins/utils.d.ts +2 -0
- package/dist/cjs/babelPlugins/utils.d.ts.map +1 -0
- package/dist/cjs/babelPlugins/utils.js +49 -0
- package/dist/cjs/browserUtils/index.d.ts +8 -0
- package/dist/cjs/browserUtils/index.d.ts.map +1 -0
- package/dist/cjs/browserUtils/index.js +47 -0
- package/dist/cjs/build-and-import/buildAndImport.js +193 -0
- package/dist/cjs/build-and-import/load-tsconfig.d.js +1 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +53 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +184 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +83 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +125 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +48 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +66 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +118 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +146 -0
- package/dist/cjs/build-and-import/rollupPlugins/utils.js +78 -0
- package/dist/cjs/build-and-import/utils.js +68 -0
- package/dist/cjs/detection/detection.d.ts +11 -0
- package/dist/cjs/detection/detection.d.ts.map +1 -0
- package/dist/cjs/detection/detection.js +46 -0
- package/dist/cjs/errors.d.ts +19 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +52 -0
- package/dist/cjs/graphql/graphql.d.ts +19 -0
- package/dist/cjs/graphql/graphql.d.ts.map +1 -0
- package/dist/cjs/graphql/graphql.js +152 -0
- package/dist/cjs/graphql/node-runner.js +97 -0
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +107 -0
- package/dist/{index.d.ts.map → cjs/index.d.ts.map} +1 -1
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/internal.d.ts +28 -0
- package/dist/cjs/internal.d.ts.map +1 -0
- package/dist/cjs/internal.js +135 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/runPrerender.d.ts.map +1 -0
- package/dist/cjs/runPrerender.js +311 -0
- package/dist/cjs/runPrerenderEsm.js +308 -0
- package/dist/graphql/graphql.d.ts +2 -17
- package/dist/graphql/graphql.d.ts.map +1 -1
- package/dist/runPrerenderEsm.d.ts +9 -0
- package/dist/runPrerenderEsm.d.ts.map +1 -0
- package/dist/{runPrerender.js → runPrerenderEsm.js} +56 -65
- package/package.json +51 -20
- package/dist/index.js +0 -1
- package/dist/runPrerender.d.ts.map +0 -1
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{runPrerender.d.ts → cjs/runPrerender.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,UASjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
@@ -4,5 +4,5 @@ export declare const isBrowser: boolean;
|
|
|
4
4
|
export declare const useIsBrowser: () => boolean;
|
|
5
5
|
export declare const BrowserOnly: ({ children }: {
|
|
6
6
|
children: ReactElement;
|
|
7
|
-
}) => ReactElement<
|
|
7
|
+
}) => ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browserUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,eAAO,MAAM,cAAc,QAAO,OAEjC,CAAA;AAED,eAAO,MAAM,SAAS,SAAoB,CAAA;AAE1C,eAAO,MAAM,YAAY,eAIxB,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browserUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,eAAO,MAAM,cAAc,QAAO,OAEjC,CAAA;AAED,eAAO,MAAM,SAAS,SAAoB,CAAA;AAE1C,eAAO,MAAM,YAAY,eAIxB,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,wEAInE,CAAA"}
|
|
@@ -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.FunctionComponent>>;
|
|
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,iBAAiB,CAAC,CAAC,CAsJlD"}
|
|
@@ -7,7 +7,7 @@ import replace from "@rollup/plugin-replace";
|
|
|
7
7
|
import { rollup } from "rollup";
|
|
8
8
|
import { swc } from "rollup-plugin-swc3";
|
|
9
9
|
import unimportPlugin from "unimport/unplugin";
|
|
10
|
-
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
10
|
+
import { getConfig, getPaths, projectIsEsm } from "@cedarjs/project-config";
|
|
11
11
|
import {
|
|
12
12
|
getPathsFromTypeScriptConfig,
|
|
13
13
|
parseTypeScriptConfigFiles
|
|
@@ -42,6 +42,7 @@ async function buildAndImport(options) {
|
|
|
42
42
|
if (!fs.existsSync(outDir)) {
|
|
43
43
|
fs.mkdirSync(outDir, { recursive: true });
|
|
44
44
|
}
|
|
45
|
+
const isEsm = projectIsEsm();
|
|
45
46
|
const build = await rollup({
|
|
46
47
|
input: [options.filepath],
|
|
47
48
|
output: {
|
|
@@ -113,10 +114,16 @@ async function buildAndImport(options) {
|
|
|
113
114
|
from: "react"
|
|
114
115
|
},
|
|
115
116
|
// import { gql } from 'graphql-tag'
|
|
116
|
-
!useTrustedDocumentsGqlTag && {
|
|
117
|
+
!useTrustedDocumentsGqlTag && isEsm && {
|
|
117
118
|
name: "gql",
|
|
118
119
|
from: "graphql-tag"
|
|
119
120
|
},
|
|
121
|
+
// import gql from 'graphql-tag'
|
|
122
|
+
!useTrustedDocumentsGqlTag && !isEsm && {
|
|
123
|
+
name: "default",
|
|
124
|
+
as: "gql",
|
|
125
|
+
from: "graphql-tag"
|
|
126
|
+
},
|
|
120
127
|
// import { gql } from 'src/graphql/gql'
|
|
121
128
|
useTrustedDocumentsGqlTag && {
|
|
122
129
|
name: "gql",
|
package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-plugin-cedarjs-routes-auto-loader.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAYpC,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;
|
|
1
|
+
{"version":3,"file":"rollup-plugin-cedarjs-routes-auto-loader.d.ts","sourceRoot":"","sources":["../../../src/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAYpC,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAuBD,wBAAgB,6BAA6B,IAAI,MAAM,CAoJtD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,101 @@
|
|
|
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_prerender_media_imports_exports = {};
|
|
20
|
+
__export(babel_plugin_redwood_prerender_media_imports_exports, {
|
|
21
|
+
babelPluginRedwoodPrerenderMediaImports: () => babelPluginRedwoodPrerenderMediaImports
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(babel_plugin_redwood_prerender_media_imports_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
26
|
+
var import_utils = require("./utils.js");
|
|
27
|
+
const defaultOptions = {
|
|
28
|
+
// Media file extensions that Vite emits as assets, and that we therefore
|
|
29
|
+
// have to resolve to their built asset path (or a data URL) when prerendering
|
|
30
|
+
extensions: [
|
|
31
|
+
".ico",
|
|
32
|
+
".jpg",
|
|
33
|
+
".jpeg",
|
|
34
|
+
".png",
|
|
35
|
+
".gif",
|
|
36
|
+
".svg",
|
|
37
|
+
".eot",
|
|
38
|
+
".otf",
|
|
39
|
+
".webp",
|
|
40
|
+
".ttf",
|
|
41
|
+
".woff",
|
|
42
|
+
".woff2",
|
|
43
|
+
".cur",
|
|
44
|
+
".ani",
|
|
45
|
+
".pdf",
|
|
46
|
+
".bmp"
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
function getVariableName(p) {
|
|
50
|
+
if (p.node.specifiers?.[0]?.local) {
|
|
51
|
+
return p.node.specifiers[0].local.name;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
function babelPluginRedwoodPrerenderMediaImports({
|
|
56
|
+
types: t
|
|
57
|
+
}) {
|
|
58
|
+
const manifestPath = (0, import_path.join)((0, import_project_config.getPaths)().web.dist, "client-build-manifest.json");
|
|
59
|
+
const buildManifest = require(manifestPath);
|
|
60
|
+
return {
|
|
61
|
+
name: "babel-plugin-redwood-prerender-media-imports",
|
|
62
|
+
visitor: {
|
|
63
|
+
ImportDeclaration(p, state) {
|
|
64
|
+
const importPath = p.node.source.value;
|
|
65
|
+
const ext = (0, import_path.extname)(importPath);
|
|
66
|
+
const options = {
|
|
67
|
+
...defaultOptions,
|
|
68
|
+
...state.opts
|
|
69
|
+
};
|
|
70
|
+
if (ext && options.extensions.includes(ext)) {
|
|
71
|
+
const importConstName = getVariableName(p);
|
|
72
|
+
if (state.filename === void 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const absPath = (0, import_path.join)((0, import_path.dirname)(state.filename), p.node.source.value);
|
|
76
|
+
const viteManifestKey = (0, import_project_config.ensurePosixPath)(
|
|
77
|
+
(0, import_path.relative)((0, import_project_config.getPaths)().web.src, absPath)
|
|
78
|
+
);
|
|
79
|
+
const copiedAssetPath = buildManifest[viteManifestKey]?.file;
|
|
80
|
+
const assetSrc = copiedAssetPath ?? (0, import_utils.convertToDataUrl)(
|
|
81
|
+
(0, import_path.join)(state.file.opts.sourceRoot || "./", importPath)
|
|
82
|
+
);
|
|
83
|
+
if (importConstName) {
|
|
84
|
+
p.replaceWith(
|
|
85
|
+
t.variableDeclaration("const", [
|
|
86
|
+
t.variableDeclarator(
|
|
87
|
+
t.identifier(importConstName),
|
|
88
|
+
t.stringLiteral(assetSrc)
|
|
89
|
+
)
|
|
90
|
+
])
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
babelPluginRedwoodPrerenderMediaImports
|
|
101
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,UASjD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
convertToDataUrl: () => convertToDataUrl
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(utils_exports);
|
|
34
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
35
|
+
var import_mime_types = __toESM(require("mime-types"), 1);
|
|
36
|
+
function convertToDataUrl(assetPath) {
|
|
37
|
+
try {
|
|
38
|
+
const base64AssetContents = import_node_fs.default.readFileSync(assetPath, "base64");
|
|
39
|
+
const mimeType = import_mime_types.default.lookup(assetPath);
|
|
40
|
+
return `data:${mimeType};base64,${base64AssetContents}`;
|
|
41
|
+
} catch {
|
|
42
|
+
console.warn(`Could not read file ${assetPath} for conversion to data uri`);
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
convertToDataUrl
|
|
49
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
export declare const isPrerendering: () => boolean;
|
|
3
|
+
export declare const isBrowser: boolean;
|
|
4
|
+
export declare const useIsBrowser: () => boolean;
|
|
5
|
+
export declare const BrowserOnly: ({ children }: {
|
|
6
|
+
children: ReactElement;
|
|
7
|
+
}) => ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/browserUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAKzC,eAAO,MAAM,cAAc,QAAO,OAEjC,CAAA;AAED,eAAO,MAAM,SAAS,SAAoB,CAAA;AAE1C,eAAO,MAAM,YAAY,eAIxB,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,wEAInE,CAAA"}
|