@cedarjs/prerender 0.9.1-next.21 → 0.10.0-rc.24

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 (64) hide show
  1. package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +5 -0
  2. package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
  3. package/dist/babelPlugins/babel-plugin-redwood-cell.js +97 -0
  4. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +5 -0
  5. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -0
  6. package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +76 -0
  7. package/dist/babelPlugins/utils.d.ts +2 -0
  8. package/dist/babelPlugins/utils.d.ts.map +1 -0
  9. package/dist/babelPlugins/utils.js +15 -0
  10. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +5 -0
  11. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
  12. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +121 -0
  13. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +5 -0
  14. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -0
  15. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +100 -0
  16. package/dist/cjs/babelPlugins/utils.d.ts +2 -0
  17. package/dist/cjs/babelPlugins/utils.d.ts.map +1 -0
  18. package/dist/cjs/babelPlugins/utils.js +49 -0
  19. package/dist/cjs/browserUtils/index.d.ts +8 -0
  20. package/dist/cjs/browserUtils/index.d.ts.map +1 -0
  21. package/dist/cjs/browserUtils/index.js +47 -0
  22. package/dist/cjs/build-and-import/buildAndImport.js +173 -0
  23. package/dist/cjs/build-and-import/load-tsconfig.d.js +1 -0
  24. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +183 -0
  25. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +83 -0
  26. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +125 -0
  27. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +48 -0
  28. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +66 -0
  29. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +118 -0
  30. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +146 -0
  31. package/dist/cjs/build-and-import/rollupPlugins/utils.js +78 -0
  32. package/dist/cjs/build-and-import/utils.js +68 -0
  33. package/dist/cjs/detection/detection.d.ts +11 -0
  34. package/dist/cjs/detection/detection.d.ts.map +1 -0
  35. package/dist/cjs/detection/detection.js +48 -0
  36. package/dist/cjs/errors.d.ts +19 -0
  37. package/dist/cjs/errors.d.ts.map +1 -0
  38. package/dist/cjs/errors.js +52 -0
  39. package/dist/cjs/graphql/graphql.d.ts +19 -0
  40. package/dist/cjs/graphql/graphql.d.ts.map +1 -0
  41. package/dist/cjs/graphql/graphql.js +152 -0
  42. package/dist/cjs/graphql/node-runner.js +109 -0
  43. package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +107 -0
  44. package/dist/cjs/graphql/vite-plugin-cedar-import-dir.js +118 -0
  45. package/dist/{index.d.ts.map → cjs/index.d.ts.map} +1 -1
  46. package/dist/cjs/index.js +22 -0
  47. package/dist/cjs/internal.d.ts +28 -0
  48. package/dist/cjs/internal.d.ts.map +1 -0
  49. package/dist/cjs/internal.js +135 -0
  50. package/dist/cjs/package.json +1 -0
  51. package/dist/cjs/runPrerender.d.ts.map +1 -0
  52. package/dist/cjs/runPrerender.js +307 -0
  53. package/dist/cjs/runPrerenderEsm.js +304 -0
  54. package/dist/graphql/graphql.d.ts +3 -3
  55. package/dist/graphql/graphql.d.ts.map +1 -1
  56. package/dist/graphql/graphql.js +4 -4
  57. package/dist/runPrerenderEsm.d.ts +9 -0
  58. package/dist/runPrerenderEsm.d.ts.map +1 -0
  59. package/dist/{runPrerender.js → runPrerenderEsm.js} +5 -5
  60. package/package.json +44 -17
  61. package/dist/index.js +0 -1
  62. package/dist/runPrerender.d.ts.map +0 -1
  63. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  64. /package/dist/{runPrerender.d.ts → cjs/runPrerender.d.ts} +0 -0
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export declare function babelPluginRedwoodCell({ types: t, }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-cell.d.ts.map
@@ -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;AA+BnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAgHZ"}
@@ -0,0 +1,97 @@
1
+ import { parse } from "path";
2
+ const EXPECTED_EXPORTS_FROM_CELL = [
3
+ "beforeQuery",
4
+ "QUERY",
5
+ "data",
6
+ "isEmpty",
7
+ "afterQuery",
8
+ "Loading",
9
+ "Success",
10
+ "Failure",
11
+ "Empty"
12
+ ];
13
+ function babelPluginRedwoodCell({
14
+ types: t
15
+ }) {
16
+ let exportNames = [];
17
+ let hasDefaultExport = false;
18
+ return {
19
+ name: "babel-plugin-redwood-cell",
20
+ visitor: {
21
+ ExportDefaultDeclaration() {
22
+ hasDefaultExport = true;
23
+ },
24
+ ExportNamedDeclaration(path) {
25
+ const declaration = path.node.declaration;
26
+ if (!declaration) {
27
+ return;
28
+ }
29
+ let name;
30
+ if (declaration.type === "VariableDeclaration") {
31
+ const id = declaration.declarations[0].id;
32
+ name = id.name;
33
+ }
34
+ if (declaration.type === "FunctionDeclaration") {
35
+ name = declaration?.id?.name;
36
+ }
37
+ if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
38
+ exportNames.push(name);
39
+ }
40
+ },
41
+ Program: {
42
+ enter() {
43
+ exportNames = [];
44
+ hasDefaultExport = false;
45
+ },
46
+ exit(path) {
47
+ const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
48
+ if (hasDefaultExport || !hasQueryOrDataExport) {
49
+ return;
50
+ }
51
+ const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
52
+ const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
53
+ path.node.body.unshift(
54
+ t.importDeclaration(
55
+ [
56
+ t.importSpecifier(
57
+ t.identifier(createCellHookName),
58
+ t.identifier(createCellHookName)
59
+ )
60
+ ],
61
+ t.stringLiteral(importFrom)
62
+ )
63
+ );
64
+ path.node.body.push(
65
+ t.exportDefaultDeclaration(
66
+ t.callExpression(t.identifier(createCellHookName), [
67
+ t.objectExpression([
68
+ ...exportNames.map(
69
+ (name) => t.objectProperty(
70
+ t.identifier(name),
71
+ t.identifier(name),
72
+ false,
73
+ true
74
+ )
75
+ ),
76
+ // Add the `displayName` property so we can name the Cell
77
+ // after the filename.
78
+ t.objectProperty(
79
+ t.identifier("displayName"),
80
+ t.stringLiteral(
81
+ parse(this.file.opts.filename).name
82
+ ),
83
+ false,
84
+ true
85
+ )
86
+ ])
87
+ ])
88
+ )
89
+ );
90
+ }
91
+ }
92
+ }
93
+ };
94
+ }
95
+ export {
96
+ babelPluginRedwoodCell
97
+ };
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export declare function babelPluginRedwoodPrerenderMediaImports({ types: t, }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-prerender-media-imports.d.ts.map
@@ -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;AAyC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
@@ -0,0 +1,76 @@
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
+ // This list of extensions matches config for file-loader in
6
+ extensions: [
7
+ ".ico",
8
+ ".jpg",
9
+ ".jpeg",
10
+ ".png",
11
+ ".gif",
12
+ ".svg",
13
+ ".eot",
14
+ ".otf",
15
+ ".webp",
16
+ ".ttf",
17
+ ".woff",
18
+ ".woff2",
19
+ ".cur",
20
+ ".ani",
21
+ ".pdf",
22
+ ".bmp"
23
+ ]
24
+ };
25
+ function getVariableName(p) {
26
+ if (p.node.specifiers?.[0]?.local) {
27
+ return p.node.specifiers[0].local.name;
28
+ }
29
+ return null;
30
+ }
31
+ function babelPluginRedwoodPrerenderMediaImports({
32
+ types: t
33
+ }) {
34
+ const manifestPath = join(getPaths().web.dist, "client-build-manifest.json");
35
+ const buildManifest = require(manifestPath);
36
+ return {
37
+ name: "babel-plugin-redwood-prerender-media-imports",
38
+ visitor: {
39
+ ImportDeclaration(p, state) {
40
+ const importPath = p.node.source.value;
41
+ const ext = extname(importPath);
42
+ const options = {
43
+ ...defaultOptions,
44
+ ...state.opts
45
+ };
46
+ if (ext && options.extensions.includes(ext)) {
47
+ const importConstName = getVariableName(p);
48
+ if (state.filename === void 0) {
49
+ return;
50
+ }
51
+ const absPath = join(dirname(state.filename), p.node.source.value);
52
+ const viteManifestKey = ensurePosixPath(
53
+ relative(getPaths().web.src, absPath)
54
+ );
55
+ const copiedAssetPath = buildManifest[viteManifestKey]?.file;
56
+ const assetSrc = copiedAssetPath ?? convertToDataUrl(
57
+ join(state.file.opts.sourceRoot || "./", importPath)
58
+ );
59
+ if (importConstName) {
60
+ p.replaceWith(
61
+ t.variableDeclaration("const", [
62
+ t.variableDeclarator(
63
+ t.identifier(importConstName),
64
+ t.stringLiteral(assetSrc)
65
+ )
66
+ ])
67
+ );
68
+ }
69
+ }
70
+ }
71
+ }
72
+ };
73
+ }
74
+ export {
75
+ babelPluginRedwoodPrerenderMediaImports
76
+ };
@@ -0,0 +1,2 @@
1
+ export declare function convertToDataUrl(assetPath: string): string;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -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 "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
+ };
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export declare function babelPluginRedwoodCell({ types: t, }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-cell.d.ts.map
@@ -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;AA+BnD,wBAAgB,sBAAsB,CAAC,EACrC,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAgHZ"}
@@ -0,0 +1,121 @@
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
+ "data",
29
+ "isEmpty",
30
+ "afterQuery",
31
+ "Loading",
32
+ "Success",
33
+ "Failure",
34
+ "Empty"
35
+ ];
36
+ function babelPluginRedwoodCell({
37
+ types: t
38
+ }) {
39
+ let exportNames = [];
40
+ let hasDefaultExport = false;
41
+ return {
42
+ name: "babel-plugin-redwood-cell",
43
+ visitor: {
44
+ ExportDefaultDeclaration() {
45
+ hasDefaultExport = true;
46
+ },
47
+ ExportNamedDeclaration(path) {
48
+ const declaration = path.node.declaration;
49
+ if (!declaration) {
50
+ return;
51
+ }
52
+ let name;
53
+ if (declaration.type === "VariableDeclaration") {
54
+ const id = declaration.declarations[0].id;
55
+ name = id.name;
56
+ }
57
+ if (declaration.type === "FunctionDeclaration") {
58
+ name = declaration?.id?.name;
59
+ }
60
+ if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
61
+ exportNames.push(name);
62
+ }
63
+ },
64
+ Program: {
65
+ enter() {
66
+ exportNames = [];
67
+ hasDefaultExport = false;
68
+ },
69
+ exit(path) {
70
+ const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
71
+ if (hasDefaultExport || !hasQueryOrDataExport) {
72
+ return;
73
+ }
74
+ const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
75
+ const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
76
+ path.node.body.unshift(
77
+ t.importDeclaration(
78
+ [
79
+ t.importSpecifier(
80
+ t.identifier(createCellHookName),
81
+ t.identifier(createCellHookName)
82
+ )
83
+ ],
84
+ t.stringLiteral(importFrom)
85
+ )
86
+ );
87
+ path.node.body.push(
88
+ t.exportDefaultDeclaration(
89
+ t.callExpression(t.identifier(createCellHookName), [
90
+ t.objectExpression([
91
+ ...exportNames.map(
92
+ (name) => t.objectProperty(
93
+ t.identifier(name),
94
+ t.identifier(name),
95
+ false,
96
+ true
97
+ )
98
+ ),
99
+ // Add the `displayName` property so we can name the Cell
100
+ // after the filename.
101
+ t.objectProperty(
102
+ t.identifier("displayName"),
103
+ t.stringLiteral(
104
+ (0, import_path.parse)(this.file.opts.filename).name
105
+ ),
106
+ false,
107
+ true
108
+ )
109
+ ])
110
+ ])
111
+ )
112
+ );
113
+ }
114
+ }
115
+ }
116
+ };
117
+ }
118
+ // Annotate the CommonJS export names for ESM import in node:
119
+ 0 && (module.exports = {
120
+ babelPluginRedwoodCell
121
+ });
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export declare function babelPluginRedwoodPrerenderMediaImports({ types: t, }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-prerender-media-imports.d.ts.map
@@ -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;AAyC7D,wBAAgB,uCAAuC,CAAC,EACtD,KAAK,EAAE,CAAC,GACT,EAAE;IACD,KAAK,EAAE,OAAO,KAAK,CAAA;CACpB,GAAG,SAAS,CAqDZ"}
@@ -0,0 +1,100 @@
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
+ // This list of extensions matches config for file-loader in
29
+ extensions: [
30
+ ".ico",
31
+ ".jpg",
32
+ ".jpeg",
33
+ ".png",
34
+ ".gif",
35
+ ".svg",
36
+ ".eot",
37
+ ".otf",
38
+ ".webp",
39
+ ".ttf",
40
+ ".woff",
41
+ ".woff2",
42
+ ".cur",
43
+ ".ani",
44
+ ".pdf",
45
+ ".bmp"
46
+ ]
47
+ };
48
+ function getVariableName(p) {
49
+ if (p.node.specifiers?.[0]?.local) {
50
+ return p.node.specifiers[0].local.name;
51
+ }
52
+ return null;
53
+ }
54
+ function babelPluginRedwoodPrerenderMediaImports({
55
+ types: t
56
+ }) {
57
+ const manifestPath = (0, import_path.join)((0, import_project_config.getPaths)().web.dist, "client-build-manifest.json");
58
+ const buildManifest = require(manifestPath);
59
+ return {
60
+ name: "babel-plugin-redwood-prerender-media-imports",
61
+ visitor: {
62
+ ImportDeclaration(p, state) {
63
+ const importPath = p.node.source.value;
64
+ const ext = (0, import_path.extname)(importPath);
65
+ const options = {
66
+ ...defaultOptions,
67
+ ...state.opts
68
+ };
69
+ if (ext && options.extensions.includes(ext)) {
70
+ const importConstName = getVariableName(p);
71
+ if (state.filename === void 0) {
72
+ return;
73
+ }
74
+ const absPath = (0, import_path.join)((0, import_path.dirname)(state.filename), p.node.source.value);
75
+ const viteManifestKey = (0, import_project_config.ensurePosixPath)(
76
+ (0, import_path.relative)((0, import_project_config.getPaths)().web.src, absPath)
77
+ );
78
+ const copiedAssetPath = buildManifest[viteManifestKey]?.file;
79
+ const assetSrc = copiedAssetPath ?? (0, import_utils.convertToDataUrl)(
80
+ (0, import_path.join)(state.file.opts.sourceRoot || "./", importPath)
81
+ );
82
+ if (importConstName) {
83
+ p.replaceWith(
84
+ t.variableDeclaration("const", [
85
+ t.variableDeclarator(
86
+ t.identifier(importConstName),
87
+ t.stringLiteral(assetSrc)
88
+ )
89
+ ])
90
+ );
91
+ }
92
+ }
93
+ }
94
+ }
95
+ };
96
+ }
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ babelPluginRedwoodPrerenderMediaImports
100
+ });
@@ -0,0 +1,2 @@
1
+ export declare function convertToDataUrl(assetPath: string): string;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -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_fs = __toESM(require("fs"), 1);
35
+ var import_mime_types = __toESM(require("mime-types"), 1);
36
+ function convertToDataUrl(assetPath) {
37
+ try {
38
+ const base64AssetContents = import_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,iBAAkB;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,wEAInE,CAAA"}
@@ -0,0 +1,47 @@
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 browserUtils_exports = {};
20
+ __export(browserUtils_exports, {
21
+ BrowserOnly: () => BrowserOnly,
22
+ isBrowser: () => isBrowser,
23
+ isPrerendering: () => isPrerendering,
24
+ useIsBrowser: () => useIsBrowser
25
+ });
26
+ module.exports = __toCommonJS(browserUtils_exports);
27
+ var import_react = require("react");
28
+ const isPrerendering = () => {
29
+ return globalThis.__REDWOOD__PRERENDERING ?? false;
30
+ };
31
+ const isBrowser = !isPrerendering();
32
+ const useIsBrowser = () => {
33
+ return (0, import_react.useMemo)(() => {
34
+ return !globalThis?.__REDWOOD__PRERENDERING;
35
+ }, []);
36
+ };
37
+ const BrowserOnly = ({ children }) => {
38
+ const isBrowser2 = useIsBrowser();
39
+ return isBrowser2 ? children : null;
40
+ };
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ BrowserOnly,
44
+ isBrowser,
45
+ isPrerendering,
46
+ useIsBrowser
47
+ });