@cedarjs/prerender 7.0.0-canary.2989 → 7.0.0-canary.2994
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-and-import/buildAndImport.d.ts +1 -1
- package/dist/build-and-import/buildAndImport.d.ts.map +1 -1
- package/dist/{cjs/index.d.ts.map → index.d.ts.map} +1 -1
- package/dist/index.js +1 -0
- package/dist/runPrerender.d.ts.map +1 -0
- package/dist/{runPrerenderEsm.js → runPrerender.js} +47 -41
- package/package.json +18 -40
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-cell.js +0 -98
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -77
- package/dist/babelPlugins/utils.d.ts +0 -2
- package/dist/babelPlugins/utils.d.ts.map +0 -1
- package/dist/babelPlugins/utils.js +0 -15
- package/dist/cjs/apolloState.d.ts +0 -13
- package/dist/cjs/apolloState.d.ts.map +0 -1
- package/dist/cjs/apolloState.js +0 -30
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-cell.js +0 -122
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts +0 -5
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/babel-plugin-redwood-prerender-media-imports.js +0 -101
- package/dist/cjs/babelPlugins/utils.d.ts +0 -2
- package/dist/cjs/babelPlugins/utils.d.ts.map +0 -1
- package/dist/cjs/babelPlugins/utils.js +0 -49
- package/dist/cjs/browserUtils/index.d.ts +0 -8
- package/dist/cjs/browserUtils/index.d.ts.map +0 -1
- package/dist/cjs/browserUtils/index.js +0 -47
- package/dist/cjs/build-and-import/buildAndImport.js +0 -186
- package/dist/cjs/build-and-import/load-tsconfig.d.js +0 -1
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedar-remove-dev-fatal-error-page.js +0 -53
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-cell.js +0 -184
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-directory-named-imports.js +0 -83
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-external.js +0 -125
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-ignore-html-and-css-imports.js +0 -48
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-inject-file-globals.js +0 -66
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-prerender-media-imports.js +0 -118
- package/dist/cjs/build-and-import/rollupPlugins/rollup-plugin-cedarjs-routes-auto-loader.js +0 -146
- package/dist/cjs/build-and-import/rollupPlugins/utils.js +0 -78
- package/dist/cjs/build-and-import/utils.js +0 -68
- package/dist/cjs/detection/detection.d.ts +0 -11
- package/dist/cjs/detection/detection.d.ts.map +0 -1
- package/dist/cjs/detection/detection.js +0 -46
- package/dist/cjs/errors.d.ts +0 -19
- package/dist/cjs/errors.d.ts.map +0 -1
- package/dist/cjs/errors.js +0 -52
- package/dist/cjs/graphql/graphql.d.ts +0 -19
- package/dist/cjs/graphql/graphql.d.ts.map +0 -1
- package/dist/cjs/graphql/graphql.js +0 -152
- package/dist/cjs/graphql/node-runner.js +0 -97
- package/dist/cjs/graphql/vite-plugin-cedar-auto-import.js +0 -107
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/internal.d.ts +0 -28
- package/dist/cjs/internal.d.ts.map +0 -1
- package/dist/cjs/internal.js +0 -135
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/runPrerender.d.ts.map +0 -1
- package/dist/cjs/runPrerender.js +0 -313
- package/dist/cjs/runPrerenderEsm.js +0 -310
- package/dist/runPrerenderEsm.d.ts +0 -9
- package/dist/runPrerenderEsm.d.ts.map +0 -1
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dist/{cjs/runPrerender.d.ts → runPrerender.d.ts} +0 -0
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
JS_EXT_RE: () => JS_EXT_RE,
|
|
32
|
-
getPkgType: () => getPkgType,
|
|
33
|
-
getRandomId: () => getRandomId,
|
|
34
|
-
isValidJsFile: () => isValidJsFile,
|
|
35
|
-
makeFilePath: () => makeFilePath
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(utils_exports);
|
|
38
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
39
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
40
|
-
var import_node_url = require("node:url");
|
|
41
|
-
const JS_EXT_RE = /\.([mc]?[tj]s|[tj]sx)$/;
|
|
42
|
-
function getPkgType() {
|
|
43
|
-
try {
|
|
44
|
-
const pkg = JSON.parse(
|
|
45
|
-
import_node_fs.default.readFileSync(import_node_path.default.resolve("package.json"), "utf-8")
|
|
46
|
-
);
|
|
47
|
-
return pkg.type;
|
|
48
|
-
} catch {
|
|
49
|
-
}
|
|
50
|
-
return void 0;
|
|
51
|
-
}
|
|
52
|
-
const getRandomId = () => {
|
|
53
|
-
return Math.random().toString(36).substring(2, 15);
|
|
54
|
-
};
|
|
55
|
-
function isValidJsFile(filepath) {
|
|
56
|
-
return JS_EXT_RE.test(filepath);
|
|
57
|
-
}
|
|
58
|
-
function makeFilePath(path2) {
|
|
59
|
-
return (0, import_node_url.pathToFileURL)(path2).href;
|
|
60
|
-
}
|
|
61
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
JS_EXT_RE,
|
|
64
|
-
getPkgType,
|
|
65
|
-
getRandomId,
|
|
66
|
-
isValidJsFile,
|
|
67
|
-
makeFilePath
|
|
68
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const detectPrerenderRoutes: () => {
|
|
2
|
-
name: string | undefined;
|
|
3
|
-
path: string | undefined;
|
|
4
|
-
routePath: string | undefined;
|
|
5
|
-
hasParams: boolean;
|
|
6
|
-
id: string;
|
|
7
|
-
isNotFound: boolean;
|
|
8
|
-
filePath: string | undefined;
|
|
9
|
-
pageIdentifier: string | undefined;
|
|
10
|
-
}[];
|
|
11
|
-
//# sourceMappingURL=detection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detection.d.ts","sourceRoot":"","sources":["../../../src/detection/detection.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB;;;;;;;;;GAqBjC,CAAA"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var detection_exports = {};
|
|
20
|
-
__export(detection_exports, {
|
|
21
|
-
detectPrerenderRoutes: () => detectPrerenderRoutes
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(detection_exports);
|
|
24
|
-
var import_structure = require("@cedarjs/structure");
|
|
25
|
-
const detectPrerenderRoutes = () => {
|
|
26
|
-
const routes = (0, import_structure.getProject)().getRouter().routes;
|
|
27
|
-
const prerenderRoutes = routes.filter((route) => route.prerender).map((route) => ({
|
|
28
|
-
name: route.isNotFound ? "404" : route.name,
|
|
29
|
-
// `path` will be updated/expanded later where route parameters will be
|
|
30
|
-
// replaced with actual values
|
|
31
|
-
path: route.isNotFound ? "/404" : route.path,
|
|
32
|
-
// `routePath` is always the path specified on the <Route> component
|
|
33
|
-
// (or the special /404 path)
|
|
34
|
-
routePath: route.isNotFound ? "/404" : route.path,
|
|
35
|
-
hasParams: route.hasParameters,
|
|
36
|
-
id: route.id,
|
|
37
|
-
isNotFound: route.isNotFound,
|
|
38
|
-
filePath: route.page?.filePath,
|
|
39
|
-
pageIdentifier: route.page_identifier_str
|
|
40
|
-
}));
|
|
41
|
-
return prerenderRoutes;
|
|
42
|
-
};
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
detectPrerenderRoutes
|
|
46
|
-
});
|
package/dist/cjs/errors.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode } from 'graphql';
|
|
2
|
-
export declare class PrerenderGqlError extends Error {
|
|
3
|
-
stack: string;
|
|
4
|
-
constructor(message: string);
|
|
5
|
-
}
|
|
6
|
-
export declare class GqlHandlerImportError extends Error {
|
|
7
|
-
stack: string;
|
|
8
|
-
constructor(message: string);
|
|
9
|
-
}
|
|
10
|
-
interface JSONParseErrorArgs {
|
|
11
|
-
query: DocumentNode;
|
|
12
|
-
variables?: Record<string, unknown>;
|
|
13
|
-
result: string;
|
|
14
|
-
}
|
|
15
|
-
export declare class JSONParseError extends Error {
|
|
16
|
-
constructor({ query, variables, result }: JSONParseErrorArgs);
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/cjs/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,KAAK,EAAE,MAAM,CAAA;gBAED,OAAO,EAAE,MAAM;CAO5B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,KAAK,EAAE,MAAM,CAAA;gBAED,OAAO,EAAE,MAAM;CAO5B;AAED,UAAU,kBAAkB;IAC1B,KAAK,EAAE,YAAY,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,kBAAkB;CAY7D"}
|
package/dist/cjs/errors.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var errors_exports = {};
|
|
20
|
-
__export(errors_exports, {
|
|
21
|
-
GqlHandlerImportError: () => GqlHandlerImportError,
|
|
22
|
-
JSONParseError: () => JSONParseError,
|
|
23
|
-
PrerenderGqlError: () => PrerenderGqlError
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(errors_exports);
|
|
26
|
-
var import_graphql = require("graphql");
|
|
27
|
-
class PrerenderGqlError extends Error {
|
|
28
|
-
stack;
|
|
29
|
-
constructor(message) {
|
|
30
|
-
super("GQL error: " + message);
|
|
31
|
-
this.stack = this.message;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
class GqlHandlerImportError extends Error {
|
|
35
|
-
stack;
|
|
36
|
-
constructor(message) {
|
|
37
|
-
super("Gql Handler Import Error: " + message);
|
|
38
|
-
this.stack = this.message;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
class JSONParseError extends Error {
|
|
42
|
-
constructor({ query, variables, result }) {
|
|
43
|
-
const message = "Could not parse the GraphQL response.\n Request: " + (0, import_graphql.print)(query).split("\n").join("\n ") + "\n Variables: " + JSON.stringify(variables) + "\n Response: " + result;
|
|
44
|
-
super(message);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
-
0 && (module.exports = {
|
|
49
|
-
GqlHandlerImportError,
|
|
50
|
-
JSONParseError,
|
|
51
|
-
PrerenderGqlError
|
|
52
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode } from 'graphql';
|
|
2
|
-
export type FileImporter = (path: string) => Promise<any>;
|
|
3
|
-
/**
|
|
4
|
-
* Loads the graphql server, with all the user's settings
|
|
5
|
-
* And execute the query against it
|
|
6
|
-
*
|
|
7
|
-
* Note that this function does NOT throw errors, even when
|
|
8
|
-
* there is a GraphQL error. Instead, it returns the result with the graphql
|
|
9
|
-
* error.
|
|
10
|
-
*/
|
|
11
|
-
export declare function executeQuery(fileImporter: FileImporter, gqlHandler: (args: any) => Promise<any>, query: DocumentNode, variables?: Record<string, unknown>): Promise<any>;
|
|
12
|
-
/**
|
|
13
|
-
* Finds the graphql handler, returns a function
|
|
14
|
-
* that can be used to execute queries against it
|
|
15
|
-
*
|
|
16
|
-
* Throws GqlHandlerImportError, so that we can warn the user (but not blow up)
|
|
17
|
-
*/
|
|
18
|
-
export declare function getGqlHandler(fileImporter: FileImporter): Promise<(operation: Record<string, unknown>) => Promise<any>>;
|
|
19
|
-
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/graphql/graphql.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AASzD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACvC,KAAK,EAAE,YAAY,EACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,gBAmCpC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,YAAY,EAAE,YAAY,uBAMjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,mBAUnD"}
|
|
@@ -1,152 +0,0 @@
|
|
|
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 graphql_exports = {};
|
|
30
|
-
__export(graphql_exports, {
|
|
31
|
-
executeQuery: () => executeQuery,
|
|
32
|
-
getGqlHandler: () => getGqlHandler
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(graphql_exports);
|
|
35
|
-
var import_path = __toESM(require("path"), 1);
|
|
36
|
-
var import_graphql = require("graphql");
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
var import_graphql2 = require("@cedarjs/web/dist/graphql.js");
|
|
39
|
-
var import_errors = require("../errors.js");
|
|
40
|
-
async function executeQuery(fileImporter, gqlHandler, query, variables) {
|
|
41
|
-
const config = (0, import_project_config.getConfig)();
|
|
42
|
-
const operationName = (0, import_graphql2.getOperationName)(query);
|
|
43
|
-
const operation = {
|
|
44
|
-
operationName,
|
|
45
|
-
query: (0, import_graphql.print)(query),
|
|
46
|
-
variables
|
|
47
|
-
};
|
|
48
|
-
if (config.graphql.trustedDocuments) {
|
|
49
|
-
const documentsPath = import_path.default.join((0, import_project_config.getPaths)().web.graphql, "graphql");
|
|
50
|
-
const documents = await fileImporter(documentsPath);
|
|
51
|
-
const documentName = operationName[0].toUpperCase() + operationName.slice(1) + "Document";
|
|
52
|
-
const queryHash = documents?.[documentName]?.__meta__?.hash;
|
|
53
|
-
operation.query = void 0;
|
|
54
|
-
operation.extensions = {
|
|
55
|
-
persistedQuery: {
|
|
56
|
-
version: 1,
|
|
57
|
-
sha256Hash: queryHash
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const handlerResult = await gqlHandler(operation);
|
|
62
|
-
return handlerResult?.body;
|
|
63
|
-
}
|
|
64
|
-
async function getGqlHandler(fileImporter) {
|
|
65
|
-
const gqlPath = import_path.default.join((0, import_project_config.getPaths)().api.functions, "graphql");
|
|
66
|
-
try {
|
|
67
|
-
const { handler } = await fileImporter(gqlPath);
|
|
68
|
-
return async (operation) => {
|
|
69
|
-
return await handler(buildApiEvent(operation), buildContext());
|
|
70
|
-
};
|
|
71
|
-
} catch {
|
|
72
|
-
return () => {
|
|
73
|
-
throw new import_errors.GqlHandlerImportError(
|
|
74
|
-
`Unable to import GraphQL handler at ${gqlPath}`
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function buildApiEvent(body) {
|
|
80
|
-
return {
|
|
81
|
-
body: JSON.stringify(body),
|
|
82
|
-
headers: {
|
|
83
|
-
origin: "http://localhost:8910",
|
|
84
|
-
"content-type": "application/json",
|
|
85
|
-
accept: "*/*",
|
|
86
|
-
host: "localhost:8910"
|
|
87
|
-
},
|
|
88
|
-
multiValueHeaders: {},
|
|
89
|
-
httpMethod: "POST",
|
|
90
|
-
isBase64Encoded: false,
|
|
91
|
-
path: "/graphql",
|
|
92
|
-
pathParameters: null,
|
|
93
|
-
queryStringParameters: {},
|
|
94
|
-
multiValueQueryStringParameters: null,
|
|
95
|
-
stageVariables: null,
|
|
96
|
-
resource: "",
|
|
97
|
-
requestContext: {
|
|
98
|
-
requestId: "req-3",
|
|
99
|
-
identity: {
|
|
100
|
-
sourceIp: "::1",
|
|
101
|
-
accessKey: null,
|
|
102
|
-
accountId: null,
|
|
103
|
-
apiKey: null,
|
|
104
|
-
apiKeyId: null,
|
|
105
|
-
caller: null,
|
|
106
|
-
clientCert: null,
|
|
107
|
-
cognitoAuthenticationProvider: null,
|
|
108
|
-
cognitoAuthenticationType: null,
|
|
109
|
-
cognitoIdentityId: null,
|
|
110
|
-
cognitoIdentityPoolId: null,
|
|
111
|
-
principalOrgId: null,
|
|
112
|
-
user: null,
|
|
113
|
-
userAgent: null,
|
|
114
|
-
userArn: null
|
|
115
|
-
},
|
|
116
|
-
authorizer: {},
|
|
117
|
-
protocol: "http",
|
|
118
|
-
httpMethod: "POST",
|
|
119
|
-
path: "/graphql",
|
|
120
|
-
stage: "",
|
|
121
|
-
requestTimeEpoch: 0,
|
|
122
|
-
resourceId: "",
|
|
123
|
-
resourcePath: "",
|
|
124
|
-
accountId: "",
|
|
125
|
-
apiId: ""
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function buildContext() {
|
|
130
|
-
return {
|
|
131
|
-
callbackWaitsForEmptyEventLoop: false,
|
|
132
|
-
functionName: "",
|
|
133
|
-
functionVersion: "",
|
|
134
|
-
invokedFunctionArn: "",
|
|
135
|
-
memoryLimitInMB: "",
|
|
136
|
-
awsRequestId: "",
|
|
137
|
-
logGroupName: "",
|
|
138
|
-
logStreamName: "",
|
|
139
|
-
getRemainingTimeInMillis: () => 100,
|
|
140
|
-
done: () => {
|
|
141
|
-
},
|
|
142
|
-
fail: () => {
|
|
143
|
-
},
|
|
144
|
-
succeed: () => {
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
-
0 && (module.exports = {
|
|
150
|
-
executeQuery,
|
|
151
|
-
getGqlHandler
|
|
152
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var node_runner_exports = {};
|
|
20
|
-
__export(node_runner_exports, {
|
|
21
|
-
NodeRunner: () => NodeRunner
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(node_runner_exports);
|
|
24
|
-
var import_vite = require("vite");
|
|
25
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
26
|
-
var import_vite2 = require("@cedarjs/vite");
|
|
27
|
-
var import_vite_plugin_cedar_auto_import = require("./vite-plugin-cedar-auto-import.js");
|
|
28
|
-
async function createViteServer(customConfig = {}) {
|
|
29
|
-
const defaultConfig = {
|
|
30
|
-
mode: "production",
|
|
31
|
-
optimizeDeps: {
|
|
32
|
-
noDiscovery: true,
|
|
33
|
-
include: void 0
|
|
34
|
-
},
|
|
35
|
-
server: {
|
|
36
|
-
hmr: false,
|
|
37
|
-
watch: null
|
|
38
|
-
},
|
|
39
|
-
environments: {
|
|
40
|
-
nodeRunnerEnv: {}
|
|
41
|
-
},
|
|
42
|
-
resolve: {
|
|
43
|
-
alias: [
|
|
44
|
-
{
|
|
45
|
-
find: /^src\/(.*?)(\.([jt]sx?))?$/,
|
|
46
|
-
replacement: (0, import_project_config.getPaths)().api.src + "/$1"
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
plugins: [
|
|
51
|
-
(0, import_vite2.cedarCjsCompatPlugin)(),
|
|
52
|
-
(0, import_vite2.cedarImportDirPlugin)(),
|
|
53
|
-
(0, import_vite_plugin_cedar_auto_import.cedarAutoImportsPlugin)(),
|
|
54
|
-
(0, import_vite2.cedarjsResolveCedarStyleImportsPlugin)(),
|
|
55
|
-
(0, import_vite2.cedarCellTransform)(),
|
|
56
|
-
(0, import_vite2.cedarjsJobPathInjectorPlugin)(),
|
|
57
|
-
(0, import_vite2.cedarSwapApolloProvider)()
|
|
58
|
-
]
|
|
59
|
-
};
|
|
60
|
-
const mergedConfig = (0, import_vite.mergeConfig)(defaultConfig, customConfig);
|
|
61
|
-
const server = await (0, import_vite.createServer)(mergedConfig);
|
|
62
|
-
return server;
|
|
63
|
-
}
|
|
64
|
-
class NodeRunner {
|
|
65
|
-
viteServer = void 0;
|
|
66
|
-
env = void 0;
|
|
67
|
-
customViteConfig;
|
|
68
|
-
constructor(customViteConfig = {}) {
|
|
69
|
-
this.customViteConfig = customViteConfig;
|
|
70
|
-
}
|
|
71
|
-
async init() {
|
|
72
|
-
this.viteServer = await createViteServer(this.customViteConfig);
|
|
73
|
-
const env = this.viteServer.environments.nodeRunnerEnv;
|
|
74
|
-
if (!env || !(0, import_vite.isRunnableDevEnvironment)(env)) {
|
|
75
|
-
await this.viteServer.close();
|
|
76
|
-
throw new Error("Vite environment is not runnable.");
|
|
77
|
-
}
|
|
78
|
-
this.env = env;
|
|
79
|
-
}
|
|
80
|
-
async importFile(filePath) {
|
|
81
|
-
if (!this.env) {
|
|
82
|
-
await this.init();
|
|
83
|
-
}
|
|
84
|
-
const env = this.env;
|
|
85
|
-
if (!env) {
|
|
86
|
-
throw new Error("NodeRunner failed to initialize");
|
|
87
|
-
}
|
|
88
|
-
return env.runner.import(filePath);
|
|
89
|
-
}
|
|
90
|
-
async close() {
|
|
91
|
-
await this.viteServer?.close();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
-
0 && (module.exports = {
|
|
96
|
-
NodeRunner
|
|
97
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
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 vite_plugin_cedar_auto_import_exports = {};
|
|
30
|
-
__export(vite_plugin_cedar_auto_import_exports, {
|
|
31
|
-
cedarAutoImportsPlugin: () => cedarAutoImportsPlugin
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(vite_plugin_cedar_auto_import_exports);
|
|
34
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
-
var import_unplugin = __toESM(require("unimport/unplugin"), 1);
|
|
36
|
-
var import_vite = __toESM(require("unplugin-auto-import/vite"), 1);
|
|
37
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
-
function cedarAutoImportsPlugin() {
|
|
39
|
-
const config = (0, import_project_config.getConfig)();
|
|
40
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
41
|
-
const useTrustedDocumentsGqlTag = config?.graphql?.trustedDocuments;
|
|
42
|
-
return [
|
|
43
|
-
(0, import_vite.default)({
|
|
44
|
-
// targets to transform
|
|
45
|
-
include: [
|
|
46
|
-
/web\/.*\.[tj]sx?$/,
|
|
47
|
-
// Assume we want the trusted documents gql tag import in all .jsx and
|
|
48
|
-
// .tsx files
|
|
49
|
-
/\.[tj]sx$/
|
|
50
|
-
],
|
|
51
|
-
// global imports to register
|
|
52
|
-
imports: [
|
|
53
|
-
// import gql from 'graphql-tag'
|
|
54
|
-
!useTrustedDocumentsGqlTag && {
|
|
55
|
-
"graphql-tag": ["gql"]
|
|
56
|
-
},
|
|
57
|
-
// import { gql } from 'src/graphql/gql'
|
|
58
|
-
useTrustedDocumentsGqlTag && {
|
|
59
|
-
[(0, import_project_config.importStatementPath)(
|
|
60
|
-
import_node_path.default.join(cedarPaths.web.base, "src", "graphql", "gql")
|
|
61
|
-
)]: ["gql"]
|
|
62
|
-
}
|
|
63
|
-
].filter((v) => Boolean(v)),
|
|
64
|
-
// Types aren't important since the output is ephemeral
|
|
65
|
-
dts: false
|
|
66
|
-
}),
|
|
67
|
-
(0, import_vite.default)({
|
|
68
|
-
// targets to transform
|
|
69
|
-
include: [/\.[tj]sx?$/],
|
|
70
|
-
// global imports to register
|
|
71
|
-
imports: [
|
|
72
|
-
{
|
|
73
|
-
"@cedarjs/context": ["context"]
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
// Types aren't important since the output is ephemeral
|
|
77
|
-
dts: false
|
|
78
|
-
}),
|
|
79
|
-
(0, import_vite.default)({
|
|
80
|
-
// targets to transform
|
|
81
|
-
include: [/api\/.*\.[tj]sx?$/],
|
|
82
|
-
// global imports to register
|
|
83
|
-
imports: [
|
|
84
|
-
// import gql from 'graphql-tag'
|
|
85
|
-
{
|
|
86
|
-
"graphql-tag": ["gql"]
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
// Types aren't important since the output is ephemeral
|
|
90
|
-
dts: false
|
|
91
|
-
}),
|
|
92
|
-
import_unplugin.default.vite({
|
|
93
|
-
imports: [
|
|
94
|
-
// import React from 'react'
|
|
95
|
-
{
|
|
96
|
-
name: "default",
|
|
97
|
-
as: "React",
|
|
98
|
-
from: "react"
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
})
|
|
102
|
-
];
|
|
103
|
-
}
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
cedarAutoImportsPlugin
|
|
107
|
-
});
|
package/dist/cjs/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var index_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(index_exports);
|
|
18
|
-
__reExport(index_exports, require("./runPrerender.js"), module.exports);
|
|
19
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
-
0 && (module.exports = {
|
|
21
|
-
...require("./runPrerender.js")
|
|
22
|
-
});
|
package/dist/cjs/internal.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare const getRootHtmlPath: () => string;
|
|
2
|
-
export declare const registerShims: (routerPath: string) => void;
|
|
3
|
-
export declare const writeToDist: (outputHtmlPath: string, renderOutput: string) => void;
|
|
4
|
-
/**
|
|
5
|
-
* Finds, reads and parses the [ts|js]config.json file
|
|
6
|
-
* @returns The config object
|
|
7
|
-
*/
|
|
8
|
-
export declare const parseTypeScriptConfigFiles: () => {
|
|
9
|
-
api: any;
|
|
10
|
-
web: any;
|
|
11
|
-
};
|
|
12
|
-
type CompilerOptionsForPaths = {
|
|
13
|
-
compilerOptions: {
|
|
14
|
-
baseUrl: string;
|
|
15
|
-
paths: Record<string, string[]>;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Extracts and formats the paths from the [ts|js]config.json file
|
|
20
|
-
* @param config The config object
|
|
21
|
-
* @param rootDir {string} Where the jsconfig/tsconfig is loaded from
|
|
22
|
-
*/
|
|
23
|
-
export declare function getPathsFromTypeScriptConfig(config: CompilerOptionsForPaths, rootDir: string): {
|
|
24
|
-
find: string;
|
|
25
|
-
replacement: string;
|
|
26
|
-
}[];
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,eAAe,cAM3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,YAAY,MAAM,SAiC/C,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,gBAAgB,MAAM,EAAE,cAAc,MAAM,SAQvE,CAAA;AAGD;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;CA0BtC,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CACtE,CAAA;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,MAAM;UAsBQ,MAAM;iBAAe,MAAM;IAkBnD"}
|