@cedarjs/prerender 0.9.1-next.21 → 0.9.1-next.23
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 +97 -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 +76 -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/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 +121 -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 +100 -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 +173 -0
- package/dist/cjs/build-and-import/load-tsconfig.d.js +1 -0
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +183 -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 +48 -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 +109 -0
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +107 -0
- package/dist/cjs/graphql/vite-plugin-cedar-import-dir.js +118 -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 +307 -0
- package/dist/cjs/runPrerenderEsm.js +304 -0
- package/dist/graphql/graphql.d.ts +3 -3
- package/dist/graphql/graphql.d.ts.map +1 -1
- package/dist/graphql/graphql.js +4 -4
- package/dist/runPrerenderEsm.d.ts +9 -0
- package/dist/runPrerenderEsm.d.ts.map +1 -0
- package/dist/{runPrerender.js → runPrerenderEsm.js} +5 -5
- package/package.json +44 -17
- 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,173 @@
|
|
|
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_cedarjs_cell = require("./rollupPlugins/rollup-plugin-cedarjs-cell.js");
|
|
46
|
+
var import_rollup_plugin_cedarjs_directory_named_imports = require("./rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js");
|
|
47
|
+
var import_rollup_plugin_cedarjs_external = require("./rollupPlugins/rollup-plugin-cedarjs-external.js");
|
|
48
|
+
var import_rollup_plugin_cedarjs_ignore_html_and_css_imports = require("./rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js");
|
|
49
|
+
var import_rollup_plugin_cedarjs_inject_file_globals = require("./rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js");
|
|
50
|
+
var import_rollup_plugin_cedarjs_prerender_media_imports = require("./rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js");
|
|
51
|
+
var import_rollup_plugin_cedarjs_routes_auto_loader = require("./rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js");
|
|
52
|
+
var import_utils = require("./utils.js");
|
|
53
|
+
const fix = (f) => f;
|
|
54
|
+
const tsconfigPathsToRegExp = (paths) => {
|
|
55
|
+
return Object.keys(paths || {}).map((key) => {
|
|
56
|
+
return new RegExp(`^${key.replace(/\*/g, ".*")}$`);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
async function buildAndImport(options) {
|
|
60
|
+
if (!(0, import_utils.isValidJsFile)(options.filepath)) {
|
|
61
|
+
throw new Error(`${options.filepath} is not a valid JS file`);
|
|
62
|
+
}
|
|
63
|
+
const tsConfigs = (0, import_internal.parseTypeScriptConfigFiles)();
|
|
64
|
+
const resolvePaths = tsconfigPathsToRegExp(
|
|
65
|
+
tsConfigs.web?.compilerOptions?.paths || {}
|
|
66
|
+
);
|
|
67
|
+
const config = (0, import_project_config.getConfig)();
|
|
68
|
+
const useTrustedDocumentsGqlTag = config.graphql.trustedDocuments;
|
|
69
|
+
const webBase = (0, import_project_config.getPaths)().web.base;
|
|
70
|
+
const outDir = import_node_path.default.join((0, import_project_config.getPaths)().web.dist, "__prerender");
|
|
71
|
+
if (!import_node_fs.default.existsSync(outDir)) {
|
|
72
|
+
import_node_fs.default.mkdirSync(outDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
const isEsm = (0, import_project_config.projectIsEsm)();
|
|
75
|
+
const build = await (0, import_rollup.rollup)({
|
|
76
|
+
input: [options.filepath],
|
|
77
|
+
output: {
|
|
78
|
+
dir: outDir
|
|
79
|
+
},
|
|
80
|
+
jsx: "react-jsx",
|
|
81
|
+
logLevel: "debug",
|
|
82
|
+
external: ["react", "react-dom"],
|
|
83
|
+
plugins: [
|
|
84
|
+
(0, import_rollup_plugin_cedarjs_external.externalPlugin)({
|
|
85
|
+
notExternal: resolvePaths,
|
|
86
|
+
filepath: options.filepath
|
|
87
|
+
}),
|
|
88
|
+
(0, import_plugin_node_resolve.nodeResolve)({
|
|
89
|
+
preferBuiltins: true,
|
|
90
|
+
exportConditions: ["node"],
|
|
91
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]
|
|
92
|
+
}),
|
|
93
|
+
// @ts-expect-error - Ignore type errors for now
|
|
94
|
+
(0, import_plugin_replace.default)({
|
|
95
|
+
preventAssignment: true,
|
|
96
|
+
"process.env.NODE_ENV": '"production"'
|
|
97
|
+
}),
|
|
98
|
+
fix(import_plugin_alias.default)({
|
|
99
|
+
entries: [
|
|
100
|
+
{
|
|
101
|
+
find: "src",
|
|
102
|
+
replacement: (0, import_project_config.getPaths)().web.src
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
find: "$api",
|
|
106
|
+
replacement: (0, import_project_config.getPaths)().api.base
|
|
107
|
+
},
|
|
108
|
+
...(0, import_internal.getPathsFromTypeScriptConfig)(tsConfigs.web, webBase)
|
|
109
|
+
]
|
|
110
|
+
}),
|
|
111
|
+
(0, import_rollup_plugin_cedarjs_ignore_html_and_css_imports.ignoreHtmlAndCssImportsPlugin)(),
|
|
112
|
+
(0, import_rollup_plugin_cedarjs_cell.cellTransformPlugin)(),
|
|
113
|
+
(0, import_rollup_plugin_cedarjs_routes_auto_loader.cedarjsRoutesAutoLoaderPlugin)(),
|
|
114
|
+
(0, import_rollup_plugin_cedarjs_directory_named_imports.cedarjsDirectoryNamedImportPlugin)(),
|
|
115
|
+
(0, import_rollup_plugin_cedarjs_prerender_media_imports.cedarjsPrerenderMediaImportsPlugin)(),
|
|
116
|
+
fix(import_plugin_commonjs.default)(),
|
|
117
|
+
(0, import_rollup_plugin_swc3.swc)({ sourceMaps: true }),
|
|
118
|
+
import_unplugin.default.rollup({
|
|
119
|
+
imports: [
|
|
120
|
+
// import React from 'react'
|
|
121
|
+
{
|
|
122
|
+
name: "default",
|
|
123
|
+
as: "React",
|
|
124
|
+
from: "react"
|
|
125
|
+
},
|
|
126
|
+
// import { gql } from 'graphql-tag'
|
|
127
|
+
!useTrustedDocumentsGqlTag && isEsm && {
|
|
128
|
+
name: "gql",
|
|
129
|
+
from: "graphql-tag"
|
|
130
|
+
},
|
|
131
|
+
// import gql from 'graphql-tag'
|
|
132
|
+
!useTrustedDocumentsGqlTag && !isEsm && {
|
|
133
|
+
name: "default",
|
|
134
|
+
as: "gql",
|
|
135
|
+
from: "graphql-tag"
|
|
136
|
+
},
|
|
137
|
+
// import { gql } from 'src/graphql/gql'
|
|
138
|
+
useTrustedDocumentsGqlTag && {
|
|
139
|
+
name: "gql",
|
|
140
|
+
from: `src/graphql/gql.js`
|
|
141
|
+
}
|
|
142
|
+
].filter((v) => Boolean(v))
|
|
143
|
+
}),
|
|
144
|
+
(0, import_rollup_plugin_cedarjs_inject_file_globals.injectFileGlobalsPlugin)()
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
try {
|
|
148
|
+
const { output } = await build.generate({
|
|
149
|
+
dir: outDir,
|
|
150
|
+
format: (0, import_utils.getPkgType)() === "module" ? "es" : "cjs",
|
|
151
|
+
exports: "auto",
|
|
152
|
+
sourcemap: "inline"
|
|
153
|
+
});
|
|
154
|
+
for (const chunk of output) {
|
|
155
|
+
if (chunk.type !== "chunk") {
|
|
156
|
+
throw new Error("[bundle-require] Expected chunk output");
|
|
157
|
+
}
|
|
158
|
+
const chunkPath = import_node_path.default.join(outDir, chunk.fileName);
|
|
159
|
+
await import_node_fs.default.promises.writeFile(chunkPath, chunk.code, "utf8");
|
|
160
|
+
}
|
|
161
|
+
const importPath = (0, import_utils.makeFilePath)(import_node_path.default.join(outDir, output[0].fileName));
|
|
162
|
+
return import(importPath);
|
|
163
|
+
} finally {
|
|
164
|
+
if (!options.preserveTemporaryFile) {
|
|
165
|
+
await import_node_fs.default.promises.rm(outDir, { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
await build.close();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
+
0 && (module.exports = {
|
|
172
|
+
buildAndImport
|
|
173
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
"data",
|
|
44
|
+
"isEmpty",
|
|
45
|
+
"afterQuery",
|
|
46
|
+
"Loading",
|
|
47
|
+
"Success",
|
|
48
|
+
"Failure",
|
|
49
|
+
"Empty"
|
|
50
|
+
];
|
|
51
|
+
function cellTransformPlugin() {
|
|
52
|
+
return {
|
|
53
|
+
name: "cedar-cell-transform",
|
|
54
|
+
transform(code, id) {
|
|
55
|
+
if (!id.match(/Cell\.[jt]sx?$/)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const ast = (0, import_parser.parse)(code, {
|
|
60
|
+
sourceType: "module",
|
|
61
|
+
plugins: [
|
|
62
|
+
"jsx",
|
|
63
|
+
"typescript",
|
|
64
|
+
"decorators-legacy",
|
|
65
|
+
"classProperties",
|
|
66
|
+
"objectRestSpread",
|
|
67
|
+
"asyncGenerators",
|
|
68
|
+
"functionBind",
|
|
69
|
+
"exportDefaultFrom",
|
|
70
|
+
"exportNamespaceFrom",
|
|
71
|
+
"dynamicImport",
|
|
72
|
+
"nullishCoalescingOperator",
|
|
73
|
+
"optionalChaining"
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
const exportNames = [];
|
|
77
|
+
let hasDefaultExport = false;
|
|
78
|
+
traverse(ast, {
|
|
79
|
+
ExportDefaultDeclaration() {
|
|
80
|
+
hasDefaultExport = true;
|
|
81
|
+
},
|
|
82
|
+
ExportNamedDeclaration(path) {
|
|
83
|
+
const declaration = path.node.declaration;
|
|
84
|
+
if (!declaration) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let name;
|
|
88
|
+
if (declaration.type === "VariableDeclaration") {
|
|
89
|
+
const id2 = declaration.declarations[0].id;
|
|
90
|
+
name = id2.name;
|
|
91
|
+
}
|
|
92
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
93
|
+
name = declaration?.id?.name;
|
|
94
|
+
}
|
|
95
|
+
if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
|
|
96
|
+
exportNames.push(name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
|
|
101
|
+
if (hasDefaultExport || !hasQueryOrDataExport) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
|
|
105
|
+
const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
|
|
106
|
+
traverse(ast, {
|
|
107
|
+
Program(path) {
|
|
108
|
+
const importDeclaration = {
|
|
109
|
+
type: "ImportDeclaration",
|
|
110
|
+
specifiers: [
|
|
111
|
+
{
|
|
112
|
+
type: "ImportSpecifier",
|
|
113
|
+
imported: {
|
|
114
|
+
type: "Identifier",
|
|
115
|
+
name: createCellHookName
|
|
116
|
+
},
|
|
117
|
+
local: {
|
|
118
|
+
type: "Identifier",
|
|
119
|
+
name: createCellHookName
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
source: { type: "StringLiteral", value: importFrom }
|
|
124
|
+
};
|
|
125
|
+
path.node.body.unshift(importDeclaration);
|
|
126
|
+
const objectProperties = [
|
|
127
|
+
...exportNames.map((name) => ({
|
|
128
|
+
type: "ObjectProperty",
|
|
129
|
+
key: { type: "Identifier", name },
|
|
130
|
+
value: { type: "Identifier", name },
|
|
131
|
+
shorthand: true,
|
|
132
|
+
computed: false
|
|
133
|
+
})),
|
|
134
|
+
// Add the displayName property
|
|
135
|
+
{
|
|
136
|
+
type: "ObjectProperty",
|
|
137
|
+
key: { type: "Identifier", name: "displayName" },
|
|
138
|
+
value: {
|
|
139
|
+
type: "StringLiteral",
|
|
140
|
+
value: (0, import_node_path.parse)(id).name
|
|
141
|
+
},
|
|
142
|
+
shorthand: false,
|
|
143
|
+
computed: false
|
|
144
|
+
}
|
|
145
|
+
];
|
|
146
|
+
const exportDefaultDeclaration = {
|
|
147
|
+
type: "ExportDefaultDeclaration",
|
|
148
|
+
declaration: {
|
|
149
|
+
type: "CallExpression",
|
|
150
|
+
callee: {
|
|
151
|
+
type: "Identifier",
|
|
152
|
+
name: createCellHookName
|
|
153
|
+
},
|
|
154
|
+
arguments: [
|
|
155
|
+
{
|
|
156
|
+
type: "ObjectExpression",
|
|
157
|
+
properties: objectProperties
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
path.node.body.push(exportDefaultDeclaration);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const result = generate(ast, {
|
|
166
|
+
retainLines: true,
|
|
167
|
+
compact: false
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
code: result.code,
|
|
171
|
+
map: result.map
|
|
172
|
+
};
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.warn(`Failed to transform Cell file ${id}:`, error);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
cellTransformPlugin
|
|
183
|
+
});
|
package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js
ADDED
|
@@ -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
|
+
});
|
package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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_cedarjs_ignore_html_and_css_imports_exports = {};
|
|
20
|
+
__export(rollup_plugin_cedarjs_ignore_html_and_css_imports_exports, {
|
|
21
|
+
ignoreHtmlAndCssImportsPlugin: () => ignoreHtmlAndCssImportsPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(rollup_plugin_cedarjs_ignore_html_and_css_imports_exports);
|
|
24
|
+
const ignoreHtmlAndCssImportsPlugin = () => {
|
|
25
|
+
const fileTypes = [".html", ".scss", ".css"];
|
|
26
|
+
return {
|
|
27
|
+
name: "ignore-html-and-css-imports",
|
|
28
|
+
resolveId(id) {
|
|
29
|
+
if (fileTypes.some((ext) => id.endsWith(ext))) {
|
|
30
|
+
return {
|
|
31
|
+
id: `\0virtual:ignore-${id}`,
|
|
32
|
+
external: false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
},
|
|
37
|
+
load(id) {
|
|
38
|
+
if (id.startsWith("\0virtual:ignore-")) {
|
|
39
|
+
return "export default {};";
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
ignoreHtmlAndCssImportsPlugin
|
|
48
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
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_inject_file_globals_exports = {};
|
|
30
|
+
__export(rollup_plugin_cedarjs_inject_file_globals_exports, {
|
|
31
|
+
injectFileGlobalsPlugin: () => injectFileGlobalsPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(rollup_plugin_cedarjs_inject_file_globals_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var import_node_url = require("node:url");
|
|
36
|
+
var import_utils = require("../utils.js");
|
|
37
|
+
const DIRNAME_VAR_NAME = "__injected_dirname__";
|
|
38
|
+
const FILENAME_VAR_NAME = "__injected_filename__";
|
|
39
|
+
const IMPORT_META_URL_VAR_NAME = "__injected_import_meta_url__";
|
|
40
|
+
const injectFileGlobalsPlugin = () => {
|
|
41
|
+
return {
|
|
42
|
+
name: "bundle-require:inject-file-globals",
|
|
43
|
+
transform(code, id) {
|
|
44
|
+
if (!import_utils.JS_EXT_RE.test(id)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const transformedCode = code.replace(/\b__filename\b/g, FILENAME_VAR_NAME).replace(/\b__dirname\b/g, DIRNAME_VAR_NAME).replace(/\bimport\.meta\.url\b/g, IMPORT_META_URL_VAR_NAME);
|
|
48
|
+
const injectLines = [
|
|
49
|
+
`const ${FILENAME_VAR_NAME} = ${JSON.stringify(id)};`,
|
|
50
|
+
`const ${DIRNAME_VAR_NAME} = ${JSON.stringify(import_node_path.default.dirname(id))};`,
|
|
51
|
+
`const ${IMPORT_META_URL_VAR_NAME} = ${JSON.stringify(
|
|
52
|
+
(0, import_node_url.pathToFileURL)(id).href
|
|
53
|
+
)};`
|
|
54
|
+
];
|
|
55
|
+
return {
|
|
56
|
+
code: injectLines.join("\n") + "\n" + transformedCode,
|
|
57
|
+
// TODO: Generate a proper source map
|
|
58
|
+
map: { mappings: "" }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
injectFileGlobalsPlugin
|
|
66
|
+
});
|