@cedarjs/vite 4.2.1-next.0 → 4.2.1-next.269

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 (73) hide show
  1. package/bins/cedar-unified-dev.mjs +7 -0
  2. package/dist/apiDevMiddleware.d.ts.map +1 -1
  3. package/dist/apiDevMiddleware.js +18 -5
  4. package/dist/buildApp.d.ts +2 -1
  5. package/dist/buildApp.d.ts.map +1 -1
  6. package/dist/buildApp.js +151 -26
  7. package/dist/buildFeServer.d.ts.map +1 -1
  8. package/dist/buildFeServer.js +1 -1
  9. package/dist/buildRouteHooks.d.ts.map +1 -1
  10. package/dist/buildRouteHooks.js +7 -3
  11. package/dist/cedar-unified-dev.d.ts +13 -2
  12. package/dist/cedar-unified-dev.d.ts.map +1 -1
  13. package/dist/cedar-unified-dev.js +171 -16
  14. package/dist/cjs/apiDevMiddleware.js +18 -5
  15. package/dist/cjs/buildApp.js +154 -29
  16. package/dist/cjs/buildFeServer.js +1 -1
  17. package/dist/cjs/buildRouteHooks.js +17 -3
  18. package/dist/cjs/cedar-unified-dev.js +184 -16
  19. package/dist/cjs/devFeServer.js +2 -1
  20. package/dist/cjs/index.js +18 -8
  21. package/dist/cjs/lib/getMergedConfig.js +12 -4
  22. package/dist/cjs/lib/workspacePackageAliases.js +2 -8
  23. package/dist/cjs/plugins/vite-plugin-cedar-context-wrapping.js +95 -0
  24. package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +20 -5
  25. package/dist/cjs/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +61 -0
  26. package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +126 -0
  27. package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +202 -14
  28. package/dist/cjs/runFeServer.js +2 -1
  29. package/dist/cjs/utils.js +2 -1
  30. package/dist/devFeServer.d.ts +1 -0
  31. package/dist/devFeServer.js +2 -1
  32. package/dist/index.d.ts +4 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +14 -8
  35. package/dist/lib/getMergedConfig.d.ts.map +1 -1
  36. package/dist/lib/getMergedConfig.js +12 -4
  37. package/dist/lib/workspacePackageAliases.d.ts.map +1 -1
  38. package/dist/lib/workspacePackageAliases.js +2 -8
  39. package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts +44 -0
  40. package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +1 -0
  41. package/dist/plugins/vite-plugin-cedar-context-wrapping.js +60 -0
  42. package/dist/plugins/vite-plugin-cedar-entry-injection.d.ts.map +1 -1
  43. package/dist/plugins/vite-plugin-cedar-entry-injection.js +20 -5
  44. package/dist/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.d.ts +15 -0
  45. package/dist/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.d.ts.map +1 -0
  46. package/dist/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +37 -0
  47. package/dist/plugins/vite-plugin-cedar-routes-auto-loader.d.ts +24 -0
  48. package/dist/plugins/vite-plugin-cedar-routes-auto-loader.d.ts.map +1 -0
  49. package/dist/plugins/vite-plugin-cedar-routes-auto-loader.js +98 -0
  50. package/dist/plugins/vite-plugin-cedar-universal-deploy.d.ts.map +1 -1
  51. package/dist/plugins/vite-plugin-cedar-universal-deploy.js +202 -14
  52. package/dist/runFeServer.d.ts +1 -0
  53. package/dist/runFeServer.d.ts.map +1 -1
  54. package/dist/runFeServer.js +2 -1
  55. package/dist/utils.d.ts.map +1 -1
  56. package/dist/utils.js +2 -1
  57. package/package.json +31 -61
  58. package/dist/buildUDApiServer.d.ts +0 -24
  59. package/dist/buildUDApiServer.d.ts.map +0 -1
  60. package/dist/buildUDApiServer.js +0 -41
  61. package/dist/cjs/buildUDApiServer.js +0 -75
  62. package/dist/cjs/ud-handlers/catch-all.js +0 -65
  63. package/dist/cjs/ud-handlers/function.js +0 -47
  64. package/dist/cjs/ud-handlers/graphql.js +0 -59
  65. package/dist/ud-handlers/catch-all.d.ts +0 -15
  66. package/dist/ud-handlers/catch-all.d.ts.map +0 -1
  67. package/dist/ud-handlers/catch-all.js +0 -41
  68. package/dist/ud-handlers/function.d.ts +0 -5
  69. package/dist/ud-handlers/function.d.ts.map +0 -1
  70. package/dist/ud-handlers/function.js +0 -23
  71. package/dist/ud-handlers/graphql.d.ts +0 -7
  72. package/dist/ud-handlers/graphql.d.ts.map +0 -1
  73. package/dist/ud-handlers/graphql.js +0 -35
@@ -1,65 +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 catch_all_exports = {};
20
- __export(catch_all_exports, {
21
- createCatchAllHandler: () => createCatchAllHandler
22
- });
23
- module.exports = __toCommonJS(catch_all_exports);
24
- var import_rou3 = require("rou3");
25
- function createCatchAllHandler(options) {
26
- const router = (0, import_rou3.createRouter)();
27
- for (const route of options.routes) {
28
- const methods = route.methods.length > 0 ? route.methods : ["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
29
- for (const method of methods) {
30
- (0, import_rou3.addRoute)(router, method, route.path, route.module);
31
- (0, import_rou3.addRoute)(router, method, `${route.path}/**`, route.module);
32
- }
33
- }
34
- const apiRootPath = options.apiRootPath;
35
- function normalizePathname(requestUrl) {
36
- const url = new URL(requestUrl);
37
- let pathname = url.pathname;
38
- if (apiRootPath !== "/" && pathname.startsWith(apiRootPath)) {
39
- pathname = pathname.slice(apiRootPath.length - 1);
40
- }
41
- if (!pathname.startsWith("/")) {
42
- pathname = "/" + pathname;
43
- }
44
- return pathname;
45
- }
46
- return {
47
- async fetch(request) {
48
- const pathname = normalizePathname(request.url);
49
- const match = (0, import_rou3.findRoute)(router, request.method, pathname);
50
- if (!match) {
51
- return new Response("Not Found", { status: 404 });
52
- }
53
- try {
54
- return await match.data.fetch(request);
55
- } catch (err) {
56
- console.error("Unhandled error in fetch handler for", pathname, err);
57
- return new Response("Internal Server Error", { status: 500 });
58
- }
59
- }
60
- };
61
- }
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- createCatchAllHandler
65
- });
@@ -1,47 +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 function_exports = {};
20
- __export(function_exports, {
21
- createFunctionHandler: () => createFunctionHandler
22
- });
23
- module.exports = __toCommonJS(function_exports);
24
- var import_node_url = require("node:url");
25
- var import_runtime = require("@cedarjs/api/runtime");
26
- var import_udFetchable = require("@cedarjs/api-server/udFetchable");
27
- function createFunctionHandler(options) {
28
- const handleRequest = async (request, ctx) => {
29
- const mod = await import((0, import_node_url.pathToFileURL)(options.distPath).href);
30
- const nativeHandler = mod.handleRequest || mod.default?.handleRequest;
31
- if (nativeHandler) {
32
- return nativeHandler(request, ctx);
33
- }
34
- const legacyHandler = mod.handler || mod.default?.handler;
35
- if (legacyHandler) {
36
- return (0, import_runtime.wrapLegacyHandler)(legacyHandler)(request, ctx);
37
- }
38
- throw new Error(
39
- `Handler not found in ${options.distPath}. Expected \`export async function handleRequest(request, ctx)\`, \`export default { handleRequest }\`, or a legacy Lambda-shaped \`handler\`.`
40
- );
41
- };
42
- return (0, import_udFetchable.createCedarFetchable)(handleRequest);
43
- }
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- createFunctionHandler
47
- });
@@ -1,59 +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 graphql_exports = {};
20
- __export(graphql_exports, {
21
- createGraphQLHandler: () => createGraphQLHandler
22
- });
23
- module.exports = __toCommonJS(graphql_exports);
24
- var import_node_url = require("node:url");
25
- var import_runtime = require("@cedarjs/api/runtime");
26
- var import_graphql_server = require("@cedarjs/graphql-server");
27
- function createGraphQLHandler(options) {
28
- let yogaInitPromise = null;
29
- async function getYoga() {
30
- if (!yogaInitPromise) {
31
- yogaInitPromise = (async () => {
32
- const mod = await import((0, import_node_url.pathToFileURL)(options.distPath).href);
33
- const opts = mod.__rw_graphqlOptions;
34
- const { yoga } = await (0, import_graphql_server.createGraphQLYoga)(opts);
35
- return { yoga, graphqlOptions: opts };
36
- })();
37
- }
38
- return yogaInitPromise;
39
- }
40
- return {
41
- async fetch(request) {
42
- const { yoga, graphqlOptions } = await getYoga();
43
- const cedarContext = await (0, import_runtime.buildCedarContext)(request, {
44
- authDecoder: graphqlOptions?.authDecoder
45
- });
46
- const event = await (0, import_runtime.requestToLegacyEvent)(request, cedarContext);
47
- return yoga.handle(request, {
48
- request,
49
- cedarContext,
50
- event,
51
- requestContext: void 0
52
- });
53
- }
54
- };
55
- }
56
- // Annotate the CommonJS export names for ESM import in node:
57
- 0 && (module.exports = {
58
- createGraphQLHandler
59
- });
@@ -1,15 +0,0 @@
1
- export interface CatchAllRoute {
2
- path: string;
3
- methods: string[];
4
- module: {
5
- fetch: (request: Request) => Promise<Response> | Response;
6
- };
7
- }
8
- export interface CatchAllHandlerOptions {
9
- routes: CatchAllRoute[];
10
- apiRootPath: string;
11
- }
12
- export declare function createCatchAllHandler(options: CatchAllHandlerOptions): {
13
- fetch(request: Request): Promise<Response>;
14
- };
15
- //# sourceMappingURL=catch-all.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catch-all.d.ts","sourceRoot":"","sources":["../../src/ud-handlers/catch-all.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;KAAE,CAAA;CACtE;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB;mBAiC5C,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;EAgBnD"}
@@ -1,41 +0,0 @@
1
- import { createRouter, addRoute, findRoute } from "rou3";
2
- function createCatchAllHandler(options) {
3
- const router = createRouter();
4
- for (const route of options.routes) {
5
- const methods = route.methods.length > 0 ? route.methods : ["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"];
6
- for (const method of methods) {
7
- addRoute(router, method, route.path, route.module);
8
- addRoute(router, method, `${route.path}/**`, route.module);
9
- }
10
- }
11
- const apiRootPath = options.apiRootPath;
12
- function normalizePathname(requestUrl) {
13
- const url = new URL(requestUrl);
14
- let pathname = url.pathname;
15
- if (apiRootPath !== "/" && pathname.startsWith(apiRootPath)) {
16
- pathname = pathname.slice(apiRootPath.length - 1);
17
- }
18
- if (!pathname.startsWith("/")) {
19
- pathname = "/" + pathname;
20
- }
21
- return pathname;
22
- }
23
- return {
24
- async fetch(request) {
25
- const pathname = normalizePathname(request.url);
26
- const match = findRoute(router, request.method, pathname);
27
- if (!match) {
28
- return new Response("Not Found", { status: 404 });
29
- }
30
- try {
31
- return await match.data.fetch(request);
32
- } catch (err) {
33
- console.error("Unhandled error in fetch handler for", pathname, err);
34
- return new Response("Internal Server Error", { status: 500 });
35
- }
36
- }
37
- };
38
- }
39
- export {
40
- createCatchAllHandler
41
- };
@@ -1,5 +0,0 @@
1
- export interface FunctionHandlerOptions {
2
- distPath: string;
3
- }
4
- export declare function createFunctionHandler(options: FunctionHandlerOptions): import("@cedarjs/api-server/udFetchable").Fetchable;
5
- //# sourceMappingURL=function.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/ud-handlers/function.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,uDAyBpE"}
@@ -1,23 +0,0 @@
1
- import { pathToFileURL } from "node:url";
2
- import { wrapLegacyHandler } from "@cedarjs/api/runtime";
3
- import { createCedarFetchable } from "@cedarjs/api-server/udFetchable";
4
- function createFunctionHandler(options) {
5
- const handleRequest = async (request, ctx) => {
6
- const mod = await import(pathToFileURL(options.distPath).href);
7
- const nativeHandler = mod.handleRequest || mod.default?.handleRequest;
8
- if (nativeHandler) {
9
- return nativeHandler(request, ctx);
10
- }
11
- const legacyHandler = mod.handler || mod.default?.handler;
12
- if (legacyHandler) {
13
- return wrapLegacyHandler(legacyHandler)(request, ctx);
14
- }
15
- throw new Error(
16
- `Handler not found in ${options.distPath}. Expected \`export async function handleRequest(request, ctx)\`, \`export default { handleRequest }\`, or a legacy Lambda-shaped \`handler\`.`
17
- );
18
- };
19
- return createCedarFetchable(handleRequest);
20
- }
21
- export {
22
- createFunctionHandler
23
- };
@@ -1,7 +0,0 @@
1
- export interface GraphQLHandlerOptions {
2
- distPath: string;
3
- }
4
- export declare function createGraphQLHandler(options: GraphQLHandlerOptions): {
5
- fetch(request: Request): Promise<Response>;
6
- };
7
- //# sourceMappingURL=graphql.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/ud-handlers/graphql.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB;mBAiB1C,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;EAenD"}
@@ -1,35 +0,0 @@
1
- import { pathToFileURL } from "node:url";
2
- import { buildCedarContext, requestToLegacyEvent } from "@cedarjs/api/runtime";
3
- import { createGraphQLYoga } from "@cedarjs/graphql-server";
4
- function createGraphQLHandler(options) {
5
- let yogaInitPromise = null;
6
- async function getYoga() {
7
- if (!yogaInitPromise) {
8
- yogaInitPromise = (async () => {
9
- const mod = await import(pathToFileURL(options.distPath).href);
10
- const opts = mod.__rw_graphqlOptions;
11
- const { yoga } = await createGraphQLYoga(opts);
12
- return { yoga, graphqlOptions: opts };
13
- })();
14
- }
15
- return yogaInitPromise;
16
- }
17
- return {
18
- async fetch(request) {
19
- const { yoga, graphqlOptions } = await getYoga();
20
- const cedarContext = await buildCedarContext(request, {
21
- authDecoder: graphqlOptions?.authDecoder
22
- });
23
- const event = await requestToLegacyEvent(request, cedarContext);
24
- return yoga.handle(request, {
25
- request,
26
- cedarContext,
27
- event,
28
- requestContext: void 0
29
- });
30
- }
31
- };
32
- }
33
- export {
34
- createGraphQLHandler
35
- };