@cedarjs/prerender 7.0.0-canary.3259 → 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.
Files changed (72) 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 +98 -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 +77 -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/browserUtils/index.d.ts +1 -1
  11. package/dist/browserUtils/index.d.ts.map +1 -1
  12. package/dist/build-and-import/buildAndImport.d.ts +1 -1
  13. package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
  14. package/dist/build-and-import/buildAndImport.js +9 -2
  15. package/dist/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.d.ts.map +1 -1
  16. package/dist/cjs/apolloState.d.ts +13 -0
  17. package/dist/cjs/apolloState.d.ts.map +1 -0
  18. package/dist/cjs/apolloState.js +30 -0
  19. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +5 -0
  20. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
  21. package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +122 -0
  22. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +5 -0
  23. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +1 -0
  24. package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +101 -0
  25. package/dist/cjs/babelPlugins/utils.d.ts +2 -0
  26. package/dist/cjs/babelPlugins/utils.d.ts.map +1 -0
  27. package/dist/cjs/babelPlugins/utils.js +49 -0
  28. package/dist/cjs/browserUtils/index.d.ts +8 -0
  29. package/dist/cjs/browserUtils/index.d.ts.map +1 -0
  30. package/dist/cjs/browserUtils/index.js +47 -0
  31. package/dist/cjs/build-and-import/buildAndImport.js +193 -0
  32. package/dist/cjs/build-and-import/load-tsconfig.d.js +1 -0
  33. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +53 -0
  34. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +184 -0
  35. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +83 -0
  36. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +125 -0
  37. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +48 -0
  38. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +66 -0
  39. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +118 -0
  40. package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +146 -0
  41. package/dist/cjs/build-and-import/rollupPlugins/utils.js +78 -0
  42. package/dist/cjs/build-and-import/utils.js +68 -0
  43. package/dist/cjs/detection/detection.d.ts +11 -0
  44. package/dist/cjs/detection/detection.d.ts.map +1 -0
  45. package/dist/cjs/detection/detection.js +46 -0
  46. package/dist/cjs/errors.d.ts +19 -0
  47. package/dist/cjs/errors.d.ts.map +1 -0
  48. package/dist/cjs/errors.js +52 -0
  49. package/dist/cjs/graphql/graphql.d.ts +19 -0
  50. package/dist/cjs/graphql/graphql.d.ts.map +1 -0
  51. package/dist/cjs/graphql/graphql.js +152 -0
  52. package/dist/cjs/graphql/node-runner.js +97 -0
  53. package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +107 -0
  54. package/dist/{index.d.ts.map → cjs/index.d.ts.map} +1 -1
  55. package/dist/cjs/index.js +22 -0
  56. package/dist/cjs/internal.d.ts +28 -0
  57. package/dist/cjs/internal.d.ts.map +1 -0
  58. package/dist/cjs/internal.js +135 -0
  59. package/dist/cjs/package.json +1 -0
  60. package/dist/cjs/runPrerender.d.ts.map +1 -0
  61. package/dist/cjs/runPrerender.js +311 -0
  62. package/dist/cjs/runPrerenderEsm.js +308 -0
  63. package/dist/graphql/graphql.d.ts +2 -17
  64. package/dist/graphql/graphql.d.ts.map +1 -1
  65. package/dist/runPrerenderEsm.d.ts +9 -0
  66. package/dist/runPrerenderEsm.d.ts.map +1 -0
  67. package/dist/{runPrerender.js → runPrerenderEsm.js} +56 -65
  68. package/package.json +51 -20
  69. package/dist/index.js +0 -1
  70. package/dist/runPrerender.d.ts.map +0 -1
  71. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  72. /package/dist/{runPrerender.d.ts → cjs/runPrerender.d.ts} +0 -0
@@ -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
+ });
@@ -0,0 +1,193 @@
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 buildAndImport_exports = {};
30
+ __export(buildAndImport_exports, {
31
+ buildAndImport: () => buildAndImport
32
+ });
33
+ module.exports = __toCommonJS(buildAndImport_exports);
34
+ var import_node_fs = __toESM(require("node:fs"), 1);
35
+ var import_node_path = __toESM(require("node:path"), 1);
36
+ var import_plugin_alias = __toESM(require("@rollup/plugin-alias"), 1);
37
+ var import_plugin_commonjs = __toESM(require("@rollup/plugin-commonjs"), 1);
38
+ var import_plugin_node_resolve = require("@rollup/plugin-node-resolve");
39
+ var import_plugin_replace = __toESM(require("@rollup/plugin-replace"), 1);
40
+ var import_rollup = require("rollup");
41
+ var import_rollup_plugin_swc3 = require("rollup-plugin-swc3");
42
+ var import_unplugin = __toESM(require("unimport/unplugin"), 1);
43
+ var import_project_config = require("@cedarjs/project-config");
44
+ var import_internal = require("../internal.js");
45
+ var import_rollup_plugin_cedar_remove_dev_fatal_error_page = require("./rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js");
46
+ var import_rollup_plugin_cedarjs_cell = require("./rollupPlugins/rollup-plugin-cedarjs-cell.js");
47
+ var import_rollup_plugin_cedarjs_directory_named_imports = require("./rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js");
48
+ var import_rollup_plugin_cedarjs_external = require("./rollupPlugins/rollup-plugin-cedarjs-external.js");
49
+ var import_rollup_plugin_cedarjs_ignore_html_and_css_imports = require("./rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js");
50
+ var import_rollup_plugin_cedarjs_inject_file_globals = require("./rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js");
51
+ var import_rollup_plugin_cedarjs_prerender_media_imports = require("./rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js");
52
+ var import_rollup_plugin_cedarjs_routes_auto_loader = require("./rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js");
53
+ var import_utils = require("./utils.js");
54
+ const fix = (f) => f;
55
+ const tsconfigPathsToRegExp = (paths) => {
56
+ return Object.keys(paths || {}).map((key) => {
57
+ return new RegExp(`^${key.replace(/\*/g, ".*")}$`);
58
+ });
59
+ };
60
+ async function buildAndImport(options) {
61
+ if (!(0, import_utils.isValidJsFile)(options.filepath)) {
62
+ throw new Error(`${options.filepath} is not a valid JS file`);
63
+ }
64
+ const tsConfigs = (0, import_internal.parseTypeScriptConfigFiles)();
65
+ const resolvePaths = tsconfigPathsToRegExp(
66
+ tsConfigs.web?.compilerOptions?.paths || {}
67
+ );
68
+ const config = (0, import_project_config.getConfig)();
69
+ const useTrustedDocumentsGqlTag = config.graphql.trustedDocuments;
70
+ const webBase = (0, import_project_config.getPaths)().web.base;
71
+ const outDir = import_node_path.default.join((0, import_project_config.getPaths)().web.dist, "__prerender");
72
+ if (!import_node_fs.default.existsSync(outDir)) {
73
+ import_node_fs.default.mkdirSync(outDir, { recursive: true });
74
+ }
75
+ const isEsm = (0, import_project_config.projectIsEsm)();
76
+ const build = await (0, import_rollup.rollup)({
77
+ input: [options.filepath],
78
+ output: {
79
+ dir: outDir
80
+ },
81
+ jsx: "react-jsx",
82
+ logLevel: "debug",
83
+ external: ["react", "react-dom"],
84
+ plugins: [
85
+ (0, import_rollup_plugin_cedarjs_external.externalPlugin)({
86
+ notExternal: resolvePaths,
87
+ filepath: options.filepath
88
+ }),
89
+ (0, import_plugin_node_resolve.nodeResolve)({
90
+ preferBuiltins: true,
91
+ exportConditions: ["node"],
92
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]
93
+ }),
94
+ // @ts-expect-error - Ignore type errors for now
95
+ (0, import_plugin_replace.default)({
96
+ preventAssignment: true,
97
+ "process.env.NODE_ENV": '"production"'
98
+ }),
99
+ fix(import_plugin_alias.default)({
100
+ entries: [
101
+ {
102
+ find: "src",
103
+ replacement: (0, import_project_config.getPaths)().web.src
104
+ },
105
+ {
106
+ find: "$api",
107
+ replacement: (0, import_project_config.getPaths)().api.base
108
+ },
109
+ ...(0, import_internal.getPathsFromTypeScriptConfig)(tsConfigs.web, webBase)
110
+ ]
111
+ }),
112
+ // Handle JSON imports (e.g. .cedar/gqlorm-schema.json)
113
+ {
114
+ name: "json",
115
+ transform(code, id) {
116
+ if (!id.endsWith(".json")) {
117
+ return null;
118
+ }
119
+ try {
120
+ const parsed = JSON.parse(code);
121
+ return {
122
+ code: `export default ${JSON.stringify(parsed)}`,
123
+ map: { mappings: "" }
124
+ };
125
+ } catch {
126
+ return null;
127
+ }
128
+ }
129
+ },
130
+ (0, import_rollup_plugin_cedar_remove_dev_fatal_error_page.cedarRemoveDevFatalErrorPagePlugin)(),
131
+ (0, import_rollup_plugin_cedarjs_ignore_html_and_css_imports.ignoreHtmlAndCssImportsPlugin)(),
132
+ (0, import_rollup_plugin_cedarjs_cell.cellTransformPlugin)(),
133
+ (0, import_rollup_plugin_cedarjs_routes_auto_loader.cedarjsRoutesAutoLoaderPlugin)(),
134
+ (0, import_rollup_plugin_cedarjs_directory_named_imports.cedarjsDirectoryNamedImportPlugin)(),
135
+ (0, import_rollup_plugin_cedarjs_prerender_media_imports.cedarjsPrerenderMediaImportsPlugin)(),
136
+ fix(import_plugin_commonjs.default)(),
137
+ (0, import_rollup_plugin_swc3.swc)({ sourceMaps: true }),
138
+ import_unplugin.default.rollup({
139
+ imports: [
140
+ // import React from 'react'
141
+ {
142
+ name: "default",
143
+ as: "React",
144
+ from: "react"
145
+ },
146
+ // import { gql } from 'graphql-tag'
147
+ !useTrustedDocumentsGqlTag && isEsm && {
148
+ name: "gql",
149
+ from: "graphql-tag"
150
+ },
151
+ // import gql from 'graphql-tag'
152
+ !useTrustedDocumentsGqlTag && !isEsm && {
153
+ name: "default",
154
+ as: "gql",
155
+ from: "graphql-tag"
156
+ },
157
+ // import { gql } from 'src/graphql/gql'
158
+ useTrustedDocumentsGqlTag && {
159
+ name: "gql",
160
+ from: `src/graphql/gql.js`
161
+ }
162
+ ].filter((v) => Boolean(v))
163
+ }),
164
+ (0, import_rollup_plugin_cedarjs_inject_file_globals.injectFileGlobalsPlugin)()
165
+ ]
166
+ });
167
+ try {
168
+ const { output } = await build.generate({
169
+ dir: outDir,
170
+ format: (0, import_utils.getPkgType)() === "module" ? "es" : "cjs",
171
+ exports: "auto",
172
+ sourcemap: "inline"
173
+ });
174
+ for (const chunk of output) {
175
+ if (chunk.type !== "chunk") {
176
+ throw new Error("[bundle-require] Expected chunk output");
177
+ }
178
+ const chunkPath = import_node_path.default.join(outDir, chunk.fileName);
179
+ await import_node_fs.default.promises.writeFile(chunkPath, chunk.code, "utf8");
180
+ }
181
+ const importPath = (0, import_utils.makeFilePath)(import_node_path.default.join(outDir, output[0].fileName));
182
+ return import(importPath);
183
+ } finally {
184
+ if (!options.preserveTemporaryFile) {
185
+ await import_node_fs.default.promises.rm(outDir, { recursive: true, force: true });
186
+ }
187
+ await build.close();
188
+ }
189
+ }
190
+ // Annotate the CommonJS export names for ESM import in node:
191
+ 0 && (module.exports = {
192
+ buildAndImport
193
+ });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,53 @@
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 rollup_plugin_cedar_remove_dev_fatal_error_page_exports = {};
20
+ __export(rollup_plugin_cedar_remove_dev_fatal_error_page_exports, {
21
+ cedarRemoveDevFatalErrorPagePlugin: () => cedarRemoveDevFatalErrorPagePlugin
22
+ });
23
+ module.exports = __toCommonJS(rollup_plugin_cedar_remove_dev_fatal_error_page_exports);
24
+ const DEV_FATAL_ERROR_PAGE_MODULE = "@cedarjs/web/dist/components/DevFatalErrorPage";
25
+ function escapeRegExp(s) {
26
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27
+ }
28
+ const ESCAPED_MODULE = escapeRegExp(DEV_FATAL_ERROR_PAGE_MODULE);
29
+ const IMPORT_PATTERN = new RegExp(
30
+ `import\\s*\\{[^}]*\\bDevFatalErrorPage\\b[^}]*\\}\\s*from\\s*['"]${ESCAPED_MODULE}['"]`
31
+ );
32
+ const cedarRemoveDevFatalErrorPagePlugin = () => {
33
+ return {
34
+ name: "cedar-remove-dev-fatal-error-page",
35
+ transform(code) {
36
+ if (!code.includes(DEV_FATAL_ERROR_PAGE_MODULE)) {
37
+ return null;
38
+ }
39
+ const newCode = code.replace(
40
+ IMPORT_PATTERN,
41
+ "const DevFatalErrorPage = undefined"
42
+ );
43
+ if (newCode === code) {
44
+ return null;
45
+ }
46
+ return { code: newCode, map: null };
47
+ }
48
+ };
49
+ };
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ cedarRemoveDevFatalErrorPagePlugin
53
+ });
@@ -0,0 +1,184 @@
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 rollup_plugin_cedarjs_cell_exports = {};
30
+ __export(rollup_plugin_cedarjs_cell_exports, {
31
+ cellTransformPlugin: () => cellTransformPlugin
32
+ });
33
+ module.exports = __toCommonJS(rollup_plugin_cedarjs_cell_exports);
34
+ var import_node_path = require("node:path");
35
+ var import_generator = __toESM(require("@babel/generator"), 1);
36
+ var import_parser = require("@babel/parser");
37
+ var import_traverse = __toESM(require("@babel/traverse"), 1);
38
+ const traverse = import_traverse.default.default;
39
+ const generate = import_generator.default.default;
40
+ const EXPECTED_EXPORTS_FROM_CELL = [
41
+ "beforeQuery",
42
+ "QUERY",
43
+ "FRAGMENT",
44
+ "data",
45
+ "isEmpty",
46
+ "afterQuery",
47
+ "Loading",
48
+ "Success",
49
+ "Failure",
50
+ "Empty"
51
+ ];
52
+ function cellTransformPlugin() {
53
+ return {
54
+ name: "cedar-cell-transform",
55
+ transform(code, id) {
56
+ if (!id.match(/Cell\.[jt]sx?$/)) {
57
+ return null;
58
+ }
59
+ try {
60
+ const ast = (0, import_parser.parse)(code, {
61
+ sourceType: "module",
62
+ plugins: [
63
+ "jsx",
64
+ "typescript",
65
+ "decorators-legacy",
66
+ "classProperties",
67
+ "objectRestSpread",
68
+ "asyncGenerators",
69
+ "functionBind",
70
+ "exportDefaultFrom",
71
+ "exportNamespaceFrom",
72
+ "dynamicImport",
73
+ "nullishCoalescingOperator",
74
+ "optionalChaining"
75
+ ]
76
+ });
77
+ const exportNames = [];
78
+ let hasDefaultExport = false;
79
+ traverse(ast, {
80
+ ExportDefaultDeclaration() {
81
+ hasDefaultExport = true;
82
+ },
83
+ ExportNamedDeclaration(path) {
84
+ const declaration = path.node.declaration;
85
+ if (!declaration) {
86
+ return;
87
+ }
88
+ let name;
89
+ if (declaration.type === "VariableDeclaration") {
90
+ const id2 = declaration.declarations[0].id;
91
+ name = id2.name;
92
+ }
93
+ if (declaration.type === "FunctionDeclaration") {
94
+ name = declaration?.id?.name;
95
+ }
96
+ if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
97
+ exportNames.push(name);
98
+ }
99
+ }
100
+ });
101
+ const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("FRAGMENT") || exportNames.includes("data");
102
+ if (hasDefaultExport || !hasQueryOrDataExport) {
103
+ return null;
104
+ }
105
+ const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
106
+ const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
107
+ traverse(ast, {
108
+ Program(path) {
109
+ const importDeclaration = {
110
+ type: "ImportDeclaration",
111
+ specifiers: [
112
+ {
113
+ type: "ImportSpecifier",
114
+ imported: {
115
+ type: "Identifier",
116
+ name: createCellHookName
117
+ },
118
+ local: {
119
+ type: "Identifier",
120
+ name: createCellHookName
121
+ }
122
+ }
123
+ ],
124
+ source: { type: "StringLiteral", value: importFrom }
125
+ };
126
+ path.node.body.unshift(importDeclaration);
127
+ const objectProperties = [
128
+ ...exportNames.map((name) => ({
129
+ type: "ObjectProperty",
130
+ key: { type: "Identifier", name },
131
+ value: { type: "Identifier", name },
132
+ shorthand: true,
133
+ computed: false
134
+ })),
135
+ // Add the displayName property
136
+ {
137
+ type: "ObjectProperty",
138
+ key: { type: "Identifier", name: "displayName" },
139
+ value: {
140
+ type: "StringLiteral",
141
+ value: (0, import_node_path.parse)(id).name
142
+ },
143
+ shorthand: false,
144
+ computed: false
145
+ }
146
+ ];
147
+ const exportDefaultDeclaration = {
148
+ type: "ExportDefaultDeclaration",
149
+ declaration: {
150
+ type: "CallExpression",
151
+ callee: {
152
+ type: "Identifier",
153
+ name: createCellHookName
154
+ },
155
+ arguments: [
156
+ {
157
+ type: "ObjectExpression",
158
+ properties: objectProperties
159
+ }
160
+ ]
161
+ }
162
+ };
163
+ path.node.body.push(exportDefaultDeclaration);
164
+ }
165
+ });
166
+ const result = generate(ast, {
167
+ retainLines: true,
168
+ compact: false
169
+ });
170
+ return {
171
+ code: result.code,
172
+ map: result.map
173
+ };
174
+ } catch (error) {
175
+ console.warn(`Failed to transform Cell file ${id}:`, error);
176
+ return null;
177
+ }
178
+ }
179
+ };
180
+ }
181
+ // Annotate the CommonJS export names for ESM import in node:
182
+ 0 && (module.exports = {
183
+ cellTransformPlugin
184
+ });
@@ -0,0 +1,83 @@
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 rollup_plugin_cedarjs_directory_named_imports_exports = {};
30
+ __export(rollup_plugin_cedarjs_directory_named_imports_exports, {
31
+ cedarjsDirectoryNamedImportPlugin: () => cedarjsDirectoryNamedImportPlugin
32
+ });
33
+ module.exports = __toCommonJS(rollup_plugin_cedarjs_directory_named_imports_exports);
34
+ var import_node_fs = __toESM(require("node:fs"), 1);
35
+ var import_node_path = __toESM(require("node:path"), 1);
36
+ var import_project_config = require("@cedarjs/project-config");
37
+ function getNewPath(value, filename) {
38
+ const dirname = import_node_path.default.dirname(value);
39
+ const basename = import_node_path.default.basename(value);
40
+ const indexImportPath = [dirname, basename, "index"].join("/");
41
+ const resolvedFile = (0, import_project_config.resolveFile)(
42
+ import_node_path.default.resolve(import_node_path.default.dirname(filename), indexImportPath)
43
+ );
44
+ if (resolvedFile) {
45
+ return resolvedFile;
46
+ } else {
47
+ const dirnameImportPath = [dirname, basename, basename].join("/");
48
+ const dirnameResolvedFile = (0, import_project_config.resolveFile)(
49
+ import_node_path.default.resolve(import_node_path.default.dirname(filename), dirnameImportPath)
50
+ );
51
+ if (dirnameResolvedFile) {
52
+ return dirnameResolvedFile;
53
+ }
54
+ }
55
+ return null;
56
+ }
57
+ function cedarjsDirectoryNamedImportPlugin() {
58
+ return {
59
+ name: "cedarjs-directory-named-import",
60
+ resolveId(id, importer) {
61
+ if (!importer || importer.includes("/node_modules/")) {
62
+ return null;
63
+ }
64
+ const resolvedPath = import_node_path.default.resolve(import_node_path.default.dirname(importer), id);
65
+ if (import_node_fs.default.existsSync(resolvedPath)) {
66
+ const stats = import_node_fs.default.statSync(resolvedPath);
67
+ if (stats.isFile()) {
68
+ return null;
69
+ }
70
+ }
71
+ const newPath = getNewPath(id, importer);
72
+ if (!newPath) {
73
+ return null;
74
+ }
75
+ const resolvedDirnamePath = import_node_path.default.resolve(import_node_path.default.dirname(importer), newPath);
76
+ return resolvedDirnamePath;
77
+ }
78
+ };
79
+ }
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ cedarjsDirectoryNamedImportPlugin
83
+ });
@@ -0,0 +1,125 @@
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 rollup_plugin_cedarjs_external_exports = {};
30
+ __export(rollup_plugin_cedarjs_external_exports, {
31
+ externalPlugin: () => externalPlugin
32
+ });
33
+ module.exports = __toCommonJS(rollup_plugin_cedarjs_external_exports);
34
+ var import_node_path = __toESM(require("node:path"), 1);
35
+ var import_node_url = require("node:url");
36
+ const PATH_NODE_MODULES_RE = /[\/\\]node_modules[\/\\]/;
37
+ const externalPlugin = ({
38
+ external,
39
+ notExternal,
40
+ filepath,
41
+ externalNodeModules = true
42
+ }) => {
43
+ const extNodeModules = externalNodeModules ?? !filepath.match(PATH_NODE_MODULES_RE);
44
+ const builtinModules = /* @__PURE__ */ new Set([
45
+ "assert",
46
+ "buffer",
47
+ "child_process",
48
+ "cluster",
49
+ "crypto",
50
+ "dgram",
51
+ "dns",
52
+ "domain",
53
+ "events",
54
+ "fs",
55
+ "http",
56
+ "https",
57
+ "net",
58
+ "os",
59
+ "path",
60
+ "punycode",
61
+ "querystring",
62
+ "readline",
63
+ "stream",
64
+ "string_decoder",
65
+ "tls",
66
+ "tty",
67
+ "url",
68
+ "util",
69
+ "v8",
70
+ "vm",
71
+ "zlib",
72
+ "constants",
73
+ "sys",
74
+ "module",
75
+ "process",
76
+ "inspector",
77
+ "async_hooks",
78
+ "http2",
79
+ "perf_hooks",
80
+ "trace_events",
81
+ "worker_threads",
82
+ "repl",
83
+ "timers"
84
+ ]);
85
+ return {
86
+ name: "bundle-require:external",
87
+ resolveId(id, importer) {
88
+ if (builtinModules.has(id) || id.startsWith("node:")) {
89
+ return { id, external: true };
90
+ }
91
+ if (match(id, external)) {
92
+ return { id, external: true };
93
+ }
94
+ if (match(id, notExternal)) {
95
+ return null;
96
+ }
97
+ if (extNodeModules && id.match(PATH_NODE_MODULES_RE)) {
98
+ const resolved = id.startsWith(".") && importer ? import_node_path.default.resolve(import_node_path.default.dirname(importer), id) : id;
99
+ return {
100
+ id: (0, import_node_url.pathToFileURL)(resolved).toString(),
101
+ external: true
102
+ };
103
+ }
104
+ if (id.startsWith(".") || import_node_path.default.isAbsolute(id)) {
105
+ return null;
106
+ }
107
+ return { id, external: true };
108
+ }
109
+ };
110
+ };
111
+ function match(id, patterns) {
112
+ if (!patterns) {
113
+ return false;
114
+ }
115
+ return patterns.some((p) => {
116
+ if (p instanceof RegExp) {
117
+ return p.test(id);
118
+ }
119
+ return id === p || id.startsWith(p + "/");
120
+ });
121
+ }
122
+ // Annotate the CommonJS export names for ESM import in node:
123
+ 0 && (module.exports = {
124
+ externalPlugin
125
+ });