@cedarjs/vite 6.0.0-canary.2811 → 6.0.0-canary.2813
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-universal-deploy.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-universal-deploy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-universal-deploy.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-universal-deploy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAalC,MAAM,WAAW,iCAAiC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AA6GD,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,iCAAsC,GAC9C,MAAM,CA0GR"}
|
|
@@ -196,60 +196,9 @@ async function generateGraphQLModule(distPath) {
|
|
|
196
196
|
// Inlined bundle of ${path.basename(distPath)} (node_modules kept external)
|
|
197
197
|
${bundledCode}
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
${createGraphQLFetch.toString()}
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
if (!yogaInitPromise) {
|
|
203
|
-
yogaInitPromise = createGraphQLYoga(__cedar_graphqlOptions).then(
|
|
204
|
-
({ yoga }) => ({ yoga, graphqlOptions: __cedar_graphqlOptions })
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
return yogaInitPromise;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export default {
|
|
211
|
-
async fetch(request) {
|
|
212
|
-
const { yoga, graphqlOptions } = await getYoga();
|
|
213
|
-
const cedarContext = await buildCedarContext(request, {
|
|
214
|
-
authDecoder: graphqlOptions?.authDecoder ?? noopAuthDecoder,
|
|
215
|
-
});
|
|
216
|
-
const event = await requestToLegacyEvent(request, cedarContext);
|
|
217
|
-
// Wrap yoga.handle in an AsyncLocalStorage run so directive
|
|
218
|
-
// validators can read from the global @cedarjs/context. Without
|
|
219
|
-
// this, the auth plugin's setContext() call writes to a store
|
|
220
|
-
// that's only visible inside the plugin's own callback \u2014 not
|
|
221
|
-
// during directive validation.
|
|
222
|
-
const { getAsyncStoreInstance } = await import('@cedarjs/context/dist/store')
|
|
223
|
-
const store = getAsyncStoreInstance()
|
|
224
|
-
|
|
225
|
-
return store.run(new Map(), () => {
|
|
226
|
-
return yoga.handle(request, {
|
|
227
|
-
request,
|
|
228
|
-
cedarContext,
|
|
229
|
-
event,
|
|
230
|
-
requestContext: undefined,
|
|
231
|
-
})
|
|
232
|
-
}).then((response) => {
|
|
233
|
-
// GraphQL Yoga returns a PonyfillResponse from @whatwg-node/fetch
|
|
234
|
-
// which is not an instanceof the native Response class. Netlify's
|
|
235
|
-
// bootstrap checks instanceof Response, so we wrap it.
|
|
236
|
-
return new Response(response.body, {
|
|
237
|
-
status: response.status,
|
|
238
|
-
statusText: response.statusText,
|
|
239
|
-
headers: response.headers,
|
|
240
|
-
})
|
|
241
|
-
}).catch((e) => {
|
|
242
|
-
if (e?.code === 'ERR_STREAM_PREMATURE_CLOSE') {
|
|
243
|
-
// Client disconnected while the request was being processed (e.g.,
|
|
244
|
-
// page navigation, tab close). Return a 499 so the runtime doesn't
|
|
245
|
-
// treat this as a 500.
|
|
246
|
-
return new Response(null, { status: 499 })
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
throw e
|
|
250
|
-
})
|
|
251
|
-
}
|
|
252
|
-
};
|
|
201
|
+
export default { fetch: createGraphQLFetch(__cedar_graphqlOptions) };
|
|
253
202
|
`;
|
|
254
203
|
}
|
|
255
204
|
async function generateFunctionModule(distPath) {
|
|
@@ -263,50 +212,103 @@ async function generateFunctionModule(distPath) {
|
|
|
263
212
|
// Inlined bundle of ${path.basename(distPath)} (node_modules kept external)
|
|
264
213
|
${bundledCode}
|
|
265
214
|
|
|
266
|
-
|
|
267
|
-
// Prefer named handleRequest export
|
|
268
|
-
if (typeof handleRequest !== 'undefined') { return handleRequest; }
|
|
269
|
-
// Handle export default { handleRequest } pattern
|
|
270
|
-
if (typeof __cedar_default !== 'undefined' && __cedar_default && typeof __cedar_default.handleRequest === 'function') {
|
|
271
|
-
return __cedar_default.handleRequest;
|
|
272
|
-
}
|
|
273
|
-
// Handle plain default-exported async function: export default async (req) => Response
|
|
274
|
-
if (typeof __cedar_default !== 'undefined' && typeof __cedar_default === 'function') {
|
|
275
|
-
return __cedar_default;
|
|
276
|
-
}
|
|
277
|
-
return undefined;
|
|
278
|
-
})();
|
|
215
|
+
${resolveNativeHandler.toString()}
|
|
279
216
|
|
|
280
|
-
|
|
281
|
-
if (typeof handler !== 'undefined') { return handler; }
|
|
282
|
-
if (typeof __cedar_default !== 'undefined' && __cedar_default && typeof __cedar_default.handler === 'function') {
|
|
283
|
-
return __cedar_default.handler;
|
|
284
|
-
}
|
|
285
|
-
return undefined;
|
|
286
|
-
})();
|
|
217
|
+
${resolveLegacyHandler.toString()}
|
|
287
218
|
|
|
288
|
-
|
|
289
|
-
throw new Error(${notFoundMsg});
|
|
290
|
-
}
|
|
219
|
+
${resolveCedarHandler.toString()}
|
|
291
220
|
|
|
292
|
-
|
|
221
|
+
${createFunctionFetch.toString()}
|
|
293
222
|
|
|
294
223
|
export default {
|
|
295
|
-
|
|
296
|
-
const ctx = await buildCedarContext(request);
|
|
297
|
-
// Wrap the handler in an AsyncLocalStorage run so the global
|
|
298
|
-
// @cedarjs/context is available inside it (and isolated per request).
|
|
299
|
-
// Mirrors the GraphQL module above and the handlerAlsWrappingPlugin
|
|
300
|
-
// used for non-UD builds.
|
|
301
|
-
const { getAsyncStoreInstance } = await import(
|
|
302
|
-
'@cedarjs/context/dist/store'
|
|
303
|
-
);
|
|
304
|
-
const store = getAsyncStoreInstance();
|
|
305
|
-
return store.run(new Map(), () => _handler(request, ctx));
|
|
306
|
-
}
|
|
224
|
+
fetch: createFunctionFetch(resolveCedarHandler(${notFoundMsg})),
|
|
307
225
|
};
|
|
308
226
|
`;
|
|
309
227
|
}
|
|
228
|
+
function resolveNativeHandler() {
|
|
229
|
+
if (typeof handleRequest !== "undefined") {
|
|
230
|
+
return handleRequest;
|
|
231
|
+
}
|
|
232
|
+
if (typeof __cedar_default === "undefined" || !__cedar_default) {
|
|
233
|
+
return void 0;
|
|
234
|
+
}
|
|
235
|
+
if (typeof __cedar_default === "object" && typeof __cedar_default.handleRequest === "function") {
|
|
236
|
+
return __cedar_default.handleRequest;
|
|
237
|
+
}
|
|
238
|
+
if (typeof __cedar_default === "function") {
|
|
239
|
+
return __cedar_default;
|
|
240
|
+
}
|
|
241
|
+
return void 0;
|
|
242
|
+
}
|
|
243
|
+
function resolveLegacyHandler() {
|
|
244
|
+
if (typeof handler !== "undefined") {
|
|
245
|
+
return handler;
|
|
246
|
+
}
|
|
247
|
+
if (typeof __cedar_default === "undefined" || !__cedar_default) {
|
|
248
|
+
return void 0;
|
|
249
|
+
}
|
|
250
|
+
if (typeof __cedar_default === "object" && typeof __cedar_default.handler === "function") {
|
|
251
|
+
return __cedar_default.handler;
|
|
252
|
+
}
|
|
253
|
+
return void 0;
|
|
254
|
+
}
|
|
255
|
+
function resolveCedarHandler(notFoundMessage) {
|
|
256
|
+
const nativeHandler = resolveNativeHandler();
|
|
257
|
+
if (nativeHandler) {
|
|
258
|
+
return nativeHandler;
|
|
259
|
+
}
|
|
260
|
+
const legacyFn = resolveLegacyHandler();
|
|
261
|
+
if (!legacyFn) {
|
|
262
|
+
throw new Error(notFoundMessage);
|
|
263
|
+
}
|
|
264
|
+
return wrapLegacyHandler(legacyFn);
|
|
265
|
+
}
|
|
266
|
+
function createFunctionFetch(cedarHandler) {
|
|
267
|
+
return async function fetch(request) {
|
|
268
|
+
const ctx = await buildCedarContext(request);
|
|
269
|
+
const { getAsyncStoreInstance } = await import("@cedarjs/context/dist/store");
|
|
270
|
+
const store = getAsyncStoreInstance();
|
|
271
|
+
return store.run(/* @__PURE__ */ new Map(), () => cedarHandler(request, ctx));
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function createGraphQLFetch(graphqlOptions) {
|
|
275
|
+
let yogaInitPromise = null;
|
|
276
|
+
function getYoga() {
|
|
277
|
+
if (!yogaInitPromise) {
|
|
278
|
+
yogaInitPromise = createGraphQLYoga(graphqlOptions);
|
|
279
|
+
}
|
|
280
|
+
return yogaInitPromise;
|
|
281
|
+
}
|
|
282
|
+
return async function fetch(request) {
|
|
283
|
+
const { yoga } = await getYoga();
|
|
284
|
+
const cedarContext = await buildCedarContext(request, {
|
|
285
|
+
authDecoder: graphqlOptions?.authDecoder ?? noopAuthDecoder
|
|
286
|
+
});
|
|
287
|
+
const event = await requestToLegacyEvent(request, cedarContext);
|
|
288
|
+
const { getAsyncStoreInstance } = await import("@cedarjs/context/dist/store");
|
|
289
|
+
const store = getAsyncStoreInstance();
|
|
290
|
+
try {
|
|
291
|
+
const response = await store.run(/* @__PURE__ */ new Map(), () => {
|
|
292
|
+
return yoga.handle(request, {
|
|
293
|
+
request,
|
|
294
|
+
cedarContext,
|
|
295
|
+
event,
|
|
296
|
+
requestContext: void 0
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
return new Response(response.body, {
|
|
300
|
+
status: response.status,
|
|
301
|
+
statusText: response.statusText,
|
|
302
|
+
headers: response.headers
|
|
303
|
+
});
|
|
304
|
+
} catch (e) {
|
|
305
|
+
if (!!e && typeof e === "object" && "code" in e && e.code === "ERR_STREAM_PREMATURE_CLOSE") {
|
|
306
|
+
return new Response(null, { status: 499 });
|
|
307
|
+
}
|
|
308
|
+
throw e;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
310
312
|
export {
|
|
311
313
|
cedarUniversalDeployPlugin
|
|
312
314
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2813",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"@babel/parser": "7.29.7",
|
|
53
53
|
"@babel/traverse": "7.29.7",
|
|
54
54
|
"@babel/types": "7.29.7",
|
|
55
|
-
"@cedarjs/api": "6.0.0-canary.
|
|
56
|
-
"@cedarjs/api-server": "6.0.0-canary.
|
|
57
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
58
|
-
"@cedarjs/context": "6.0.0-canary.
|
|
59
|
-
"@cedarjs/graphql-server": "6.0.0-canary.
|
|
60
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
61
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
62
|
-
"@cedarjs/server-store": "6.0.0-canary.
|
|
63
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
64
|
-
"@cedarjs/testing": "6.0.0-canary.
|
|
55
|
+
"@cedarjs/api": "6.0.0-canary.2813",
|
|
56
|
+
"@cedarjs/api-server": "6.0.0-canary.2813",
|
|
57
|
+
"@cedarjs/babel-config": "6.0.0-canary.2813",
|
|
58
|
+
"@cedarjs/context": "6.0.0-canary.2813",
|
|
59
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2813",
|
|
60
|
+
"@cedarjs/internal": "6.0.0-canary.2813",
|
|
61
|
+
"@cedarjs/project-config": "6.0.0-canary.2813",
|
|
62
|
+
"@cedarjs/server-store": "6.0.0-canary.2813",
|
|
63
|
+
"@cedarjs/structure": "6.0.0-canary.2813",
|
|
64
|
+
"@cedarjs/testing": "6.0.0-canary.2813",
|
|
65
65
|
"@swc/core": "1.15.46",
|
|
66
66
|
"@universal-deploy/store": "^0.2.1",
|
|
67
67
|
"@universal-deploy/vite": "^0.1.9",
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
"yargs-parser": "21.1.1"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
96
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
97
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
98
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
95
|
+
"@cedarjs/auth": "6.0.0-canary.2813",
|
|
96
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2813",
|
|
97
|
+
"@cedarjs/router": "6.0.0-canary.2813",
|
|
98
|
+
"@cedarjs/web": "6.0.0-canary.2813",
|
|
99
99
|
"@dr.pogodin/react-helmet": "2.0.4",
|
|
100
100
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
101
101
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
@@ -115,9 +115,9 @@
|
|
|
115
115
|
"vitest": "4.1.10"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
119
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
120
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
118
|
+
"@cedarjs/auth": "6.0.0-canary.2813",
|
|
119
|
+
"@cedarjs/router": "6.0.0-canary.2813",
|
|
120
|
+
"@cedarjs/web": "6.0.0-canary.2813"
|
|
121
121
|
},
|
|
122
122
|
"engines": {
|
|
123
123
|
"node": ">=24"
|