@cedarjs/prerender 7.0.0-canary.2996 → 7.0.0-canary.3001
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/graphql/graphql.d.ts +17 -2
- package/dist/graphql/graphql.d.ts.map +1 -1
- package/dist/runPrerender.d.ts.map +1 -1
- package/dist/runPrerender.js +17 -16
- package/package.json +10 -10
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { DocumentNode } from 'graphql';
|
|
2
2
|
export type FileImporter = (path: string) => Promise<any>;
|
|
3
|
+
/**
|
|
4
|
+
* The project's GraphQL API handler, wrapped so it can be called with a bare
|
|
5
|
+
* GraphQL operation. Resolves to the handler's response, whose `body` holds
|
|
6
|
+
* the JSON-encoded result.
|
|
7
|
+
*/
|
|
8
|
+
export type GqlHandler = (operation: GqlOperation) => Promise<{
|
|
9
|
+
body?: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
interface GqlOperation {
|
|
12
|
+
operationName: string;
|
|
13
|
+
query: string | undefined;
|
|
14
|
+
variables?: Record<string, unknown>;
|
|
15
|
+
extensions?: Record<string, unknown>;
|
|
16
|
+
}
|
|
3
17
|
/**
|
|
4
18
|
* Loads the graphql server, with all the user's settings
|
|
5
19
|
* And execute the query against it
|
|
@@ -8,12 +22,13 @@ export type FileImporter = (path: string) => Promise<any>;
|
|
|
8
22
|
* there is a GraphQL error. Instead, it returns the result with the graphql
|
|
9
23
|
* error.
|
|
10
24
|
*/
|
|
11
|
-
export declare function executeQuery(fileImporter: FileImporter, gqlHandler:
|
|
25
|
+
export declare function executeQuery(fileImporter: FileImporter, gqlHandler: GqlHandler, query: DocumentNode, variables?: Record<string, unknown>): Promise<string | undefined>;
|
|
12
26
|
/**
|
|
13
27
|
* Finds the graphql handler, returns a function
|
|
14
28
|
* that can be used to execute queries against it
|
|
15
29
|
*
|
|
16
30
|
* Throws GqlHandlerImportError, so that we can warn the user (but not blow up)
|
|
17
31
|
*/
|
|
18
|
-
export declare function getGqlHandler(fileImporter: FileImporter): Promise<
|
|
32
|
+
export declare function getGqlHandler(fileImporter: FileImporter): Promise<GqlHandler>;
|
|
33
|
+
export {};
|
|
19
34
|
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAEzD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,SAAS,EAAE,YAAY,KACpB,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CAAA;AAE3C,UAAU,YAAY;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,YAAY,EACnB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,+BAmCpC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,UAAU,CAAC,CAgBrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../src/runPrerender.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"runPrerender.d.ts","sourceRoot":"","sources":["../src/runPrerender.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA8Q7C,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACrC,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,YAAY,GAAU,6BAGhC,eAAe,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAqIzC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,MAAM,SAchB,CAAA"}
|
package/dist/runPrerender.js
CHANGED
|
@@ -25,7 +25,17 @@ const prerenderApolloClient = new ApolloClient({
|
|
|
25
25
|
cache: new InMemoryCache(),
|
|
26
26
|
link: ApolloLink.empty()
|
|
27
27
|
});
|
|
28
|
-
async function recursivelyRender(
|
|
28
|
+
async function recursivelyRender(args) {
|
|
29
|
+
const {
|
|
30
|
+
App,
|
|
31
|
+
Routes,
|
|
32
|
+
CellCacheContextProvider,
|
|
33
|
+
LocationProvider,
|
|
34
|
+
renderPath,
|
|
35
|
+
fileImporter,
|
|
36
|
+
gqlHandler,
|
|
37
|
+
queryCache
|
|
38
|
+
} = args;
|
|
29
39
|
const { getOperationName } = await import("@cedarjs/web");
|
|
30
40
|
let shouldShowGraphqlHandlerNotFoundWarn = false;
|
|
31
41
|
await Promise.all(
|
|
@@ -42,13 +52,13 @@ async function recursivelyRender(App, Routes, CellCacheContextProvider, Location
|
|
|
42
52
|
);
|
|
43
53
|
let result;
|
|
44
54
|
try {
|
|
45
|
-
result = JSON.parse(resultString);
|
|
55
|
+
result = JSON.parse(resultString ?? "");
|
|
46
56
|
} catch (e) {
|
|
47
57
|
if (e instanceof SyntaxError) {
|
|
48
58
|
throw new JSONParseError({
|
|
49
59
|
query: value.query,
|
|
50
60
|
variables: value.variables,
|
|
51
|
-
result: resultString
|
|
61
|
+
result: resultString ?? ""
|
|
52
62
|
});
|
|
53
63
|
}
|
|
54
64
|
}
|
|
@@ -92,16 +102,7 @@ async function recursivelyRender(App, Routes, CellCacheContextProvider, Location
|
|
|
92
102
|
/* @__PURE__ */ React.createElement(LocationProvider, { location: new URL(prerenderUrl) }, /* @__PURE__ */ React.createElement(CellCacheContextProvider, { queryCache }, /* @__PURE__ */ React.createElement(App, null, /* @__PURE__ */ React.createElement(Routes, null))))
|
|
93
103
|
);
|
|
94
104
|
if (Object.values(queryCache).some((value) => !value.hasProcessed)) {
|
|
95
|
-
return recursivelyRender(
|
|
96
|
-
App,
|
|
97
|
-
Routes,
|
|
98
|
-
CellCacheContextProvider,
|
|
99
|
-
LocationProvider,
|
|
100
|
-
renderPath,
|
|
101
|
-
fileImporter,
|
|
102
|
-
gqlHandler,
|
|
103
|
-
queryCache
|
|
104
|
-
);
|
|
105
|
+
return recursivelyRender(args);
|
|
105
106
|
} else {
|
|
106
107
|
if (shouldShowGraphqlHandlerNotFoundWarn) {
|
|
107
108
|
console.warn(
|
|
@@ -218,16 +219,16 @@ const runPrerender = async ({
|
|
|
218
219
|
if (!LocationProvider) {
|
|
219
220
|
throw new Error("LocationProvider not found");
|
|
220
221
|
}
|
|
221
|
-
componentAsHtml = await recursivelyRender(
|
|
222
|
+
componentAsHtml = await recursivelyRender({
|
|
222
223
|
App,
|
|
223
224
|
Routes,
|
|
224
225
|
CellCacheContextProvider,
|
|
225
226
|
LocationProvider,
|
|
226
227
|
renderPath,
|
|
227
|
-
nodeRunner.importFile.bind(nodeRunner),
|
|
228
|
+
fileImporter: nodeRunner.importFile.bind(nodeRunner),
|
|
228
229
|
gqlHandler,
|
|
229
230
|
queryCache
|
|
230
|
-
);
|
|
231
|
+
});
|
|
231
232
|
} finally {
|
|
232
233
|
await nodeRunner.close();
|
|
233
234
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/prerender",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.3001",
|
|
4
4
|
"description": "CedarJS prerender",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@babel/parser": "7.29.8",
|
|
43
43
|
"@babel/traverse": "7.29.8",
|
|
44
44
|
"@babel/types": "7.29.8",
|
|
45
|
-
"@cedarjs/project-config": "7.0.0-canary.
|
|
46
|
-
"@cedarjs/structure": "7.0.0-canary.
|
|
47
|
-
"@cedarjs/vite": "7.0.0-canary.
|
|
45
|
+
"@cedarjs/project-config": "7.0.0-canary.3001",
|
|
46
|
+
"@cedarjs/structure": "7.0.0-canary.3001",
|
|
47
|
+
"@cedarjs/vite": "7.0.0-canary.3001",
|
|
48
48
|
"@rollup/plugin-alias": "5.1.1",
|
|
49
49
|
"@rollup/plugin-commonjs": "28.0.9",
|
|
50
50
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
51
51
|
"@rollup/plugin-replace": "6.0.3",
|
|
52
|
-
"@swc/core": "1.16.
|
|
52
|
+
"@swc/core": "1.16.1",
|
|
53
53
|
"@whatwg-node/fetch": "0.10.13",
|
|
54
54
|
"cheerio": "1.2.0",
|
|
55
55
|
"graphql": "16.14.2",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"vite": "7.3.6"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@cedarjs/framework-tools": "7.0.0-canary.
|
|
65
|
-
"@cedarjs/router": "7.0.0-canary.
|
|
66
|
-
"@cedarjs/web": "7.0.0-canary.
|
|
64
|
+
"@cedarjs/framework-tools": "7.0.0-canary.3001",
|
|
65
|
+
"@cedarjs/router": "7.0.0-canary.3001",
|
|
66
|
+
"@cedarjs/web": "7.0.0-canary.3001",
|
|
67
67
|
"@types/mime-types": "2.1.4",
|
|
68
68
|
"@types/react": "^19.2.0",
|
|
69
69
|
"concurrently": "9.2.4",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"vitest": "4.1.10"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@cedarjs/router": "7.0.0-canary.
|
|
76
|
-
"@cedarjs/web": "7.0.0-canary.
|
|
75
|
+
"@cedarjs/router": "7.0.0-canary.3001",
|
|
76
|
+
"@cedarjs/web": "7.0.0-canary.3001",
|
|
77
77
|
"react": "19.2.8",
|
|
78
78
|
"react-dom": "19.2.8"
|
|
79
79
|
},
|