@cedarjs/vite 5.0.4-next.167 → 5.0.4
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/api/vite-plugin-cedar-vitest-api-preset.d.ts.map +1 -1
- package/dist/api/vite-plugin-cedar-vitest-api-preset.js +0 -4
- package/dist/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +9 -105
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +18 -79
- package/dist/buildRouteHooks.d.ts.map +1 -1
- package/dist/buildRouteHooks.js +4 -36
- package/dist/bundled/react-server-dom-webpack.server.js +99 -192
- package/dist/cedar-unified-dev.d.ts +0 -18
- package/dist/cedar-unified-dev.d.ts.map +1 -1
- package/dist/cedar-unified-dev.js +5 -39
- package/dist/cjs/ClientRouter.d.ts +1 -0
- package/dist/cjs/api/vite-plugin-cedar-vitest-api-preset.js +37 -0
- package/dist/cjs/apiDevMiddleware.js +371 -0
- package/dist/cjs/build/build.d.ts +1 -0
- package/dist/cjs/build/build.js +58 -0
- package/dist/cjs/buildApp.js +306 -0
- package/dist/cjs/buildFeServer.d.ts +1 -0
- package/dist/cjs/buildFeServer.js +63 -0
- package/dist/cjs/buildRouteHooks.js +80 -0
- package/dist/cjs/buildRouteManifest.js +92 -0
- package/dist/cjs/buildRscClientAndServer.js +54 -0
- package/dist/cjs/cedar-unified-dev.js +310 -0
- package/dist/cjs/client.d.ts +1 -0
- package/dist/cjs/clientSsr.d.ts +1 -0
- package/dist/cjs/devFeServer.js +157 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +141 -0
- package/dist/cjs/lib/StatusError.js +37 -0
- package/dist/cjs/lib/entries.js +52 -0
- package/dist/cjs/lib/getMergedConfig.js +185 -0
- package/dist/cjs/lib/onWarn.js +36 -0
- package/dist/cjs/lib/registerFwGlobalsAndShims.js +102 -0
- package/dist/cjs/lib/workspacePackageAliases.js +107 -0
- package/dist/cjs/middleware/index.js +22 -0
- package/dist/cjs/middleware/invokeMiddleware.js +52 -0
- package/dist/cjs/middleware/register.js +105 -0
- package/dist/cjs/middleware/types.js +16 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/vite-plugin-cedar-auto-import.js +107 -0
- package/dist/cjs/plugins/vite-plugin-cedar-cell.js +183 -0
- package/dist/cjs/plugins/vite-plugin-cedar-cjs-compat.js +341 -0
- package/dist/cjs/plugins/vite-plugin-cedar-context-wrapping.js +95 -0
- package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +107 -0
- package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +67 -0
- package/dist/cjs/plugins/vite-plugin-cedar-import-dir.js +118 -0
- package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +43 -0
- package/dist/cjs/plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js +61 -0
- package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +76 -0
- package/dist/cjs/plugins/vite-plugin-cedar-routes-auto-loader.js +126 -0
- package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +346 -0
- package/dist/cjs/plugins/vite-plugin-cedar-wait-for-api-server.js +134 -0
- package/dist/cjs/plugins/vite-plugin-cedarjs-job-path-injector.js +134 -0
- package/dist/cjs/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +106 -0
- package/dist/cjs/plugins/vite-plugin-jsx-loader.js +42 -0
- package/dist/cjs/plugins/vite-plugin-merged-config.js +39 -0
- package/dist/cjs/plugins/vite-plugin-rsc-analyze.js +104 -0
- package/dist/cjs/plugins/vite-plugin-rsc-reload.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-auto-loader.js +159 -0
- package/dist/cjs/plugins/vite-plugin-rsc-routes-imports.js +125 -0
- package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +75 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-client.js +228 -0
- package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +398 -0
- package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +46 -0
- package/dist/cjs/rsc/rscBuildAnalyze.js +126 -0
- package/dist/cjs/rsc/rscBuildClient.js +91 -0
- package/dist/cjs/rsc/rscBuildCopyCssAssets.js +56 -0
- package/dist/cjs/rsc/rscBuildEntriesFile.js +115 -0
- package/dist/cjs/rsc/rscBuildForServer.js +168 -0
- package/dist/cjs/rsc/rscBuildForSsr.js +173 -0
- package/dist/cjs/rsc/rscBuildRwEnvVars.js +56 -0
- package/dist/cjs/rsc/rscRenderer.js +165 -0
- package/dist/cjs/rsc/rscRequestHandler.js +162 -0
- package/dist/cjs/rsc/rscStudioHandlers.js +156 -0
- package/dist/cjs/runFeServer.js +165 -0
- package/dist/cjs/streaming/buildForStreamingServer.js +65 -0
- package/dist/cjs/streaming/collectCss.js +52 -0
- package/dist/cjs/streaming/createReactStreamingHandler.js +173 -0
- package/dist/cjs/streaming/streamHelpers.js +230 -0
- package/dist/cjs/streaming/transforms/bufferedTransform.js +61 -0
- package/dist/cjs/streaming/transforms/cancelTimeoutTransform.js +34 -0
- package/dist/cjs/streaming/transforms/encode-decode.js +36 -0
- package/dist/cjs/streaming/transforms/serverInjectionTransform.js +84 -0
- package/dist/cjs/streaming/triggerRouteHooks.js +96 -0
- package/dist/cjs/types.js +16 -0
- package/dist/cjs/utils.js +92 -0
- package/dist/devFeServer.js +8 -3
- package/dist/index.d.ts +4 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -45
- package/dist/lib/getMergedConfig.d.ts.map +1 -1
- package/dist/lib/getMergedConfig.js +0 -4
- package/dist/package.json +1 -0
- package/dist/plugins/vite-plugin-cedar-auto-import.d.ts +1 -1
- package/dist/plugins/vite-plugin-cedar-auto-import.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-auto-import.js +1 -8
- package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-cell.js +1 -2
- package/dist/plugins/{vite-plugin-handler-als-wrapping.d.ts → vite-plugin-cedar-context-wrapping.d.ts} +12 -12
- package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +1 -0
- package/dist/plugins/{vite-plugin-handler-als-wrapping.js → vite-plugin-cedar-context-wrapping.js} +16 -16
- package/dist/plugins/vite-plugin-cedar-import-dir.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-import-dir.js +15 -33
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.js +19 -0
- package/dist/plugins/vite-plugin-cedar-universal-deploy.js +1 -1
- package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.js +0 -14
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +0 -3
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-swap-apollo-provider.js +2 -2
- package/dist/rsc/rscBuildForSsr.d.ts.map +1 -1
- package/dist/rsc/rscBuildForSsr.js +5 -3
- package/dist/streaming/buildForStreamingServer.d.ts.map +1 -1
- package/dist/streaming/buildForStreamingServer.js +5 -3
- package/package.json +52 -42
- package/dist/lib/generateDiffSourceMap.d.ts +0 -18
- package/dist/lib/generateDiffSourceMap.d.ts.map +0 -1
- package/dist/lib/generateDiffSourceMap.js +0 -151
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +0 -3
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +0 -43
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts +0 -12
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-directory-named-import.js +0 -35
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts +0 -29
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.js +0 -76
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +0 -42
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +0 -93
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts +0 -28
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-log-formatter-dev.js +0 -67
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts +0 -28
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-mock-cell-data.js +0 -247
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts +0 -39
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.js +0 -200
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +0 -1
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { getConfig } from "@cedarjs/project-config";
|
|
2
|
-
function dataUriToBuffer(uri) {
|
|
3
|
-
const match = uri.match(/^data:(.*?)(;(.*?))?(,(.*))$/);
|
|
4
|
-
if (!match) {
|
|
5
|
-
throw new Error("Invalid data URI");
|
|
6
|
-
}
|
|
7
|
-
const mediaType = match[1] || "text/plain";
|
|
8
|
-
const params = match[3] || "";
|
|
9
|
-
const data = match[5];
|
|
10
|
-
const [type] = mediaType.split(";");
|
|
11
|
-
const typeFull = params ? mediaType + ";" + params : mediaType;
|
|
12
|
-
const lowerParams = params.toLowerCase();
|
|
13
|
-
const isBase64 = lowerParams.includes("base64");
|
|
14
|
-
const charset = lowerParams.startsWith("charset=") ? lowerParams.slice(8) : "";
|
|
15
|
-
const bytes = isBase64 ? Uint8Array.from(atob(data), (c) => c.charCodeAt(0)) : new TextEncoder().encode(decodeURIComponent(data));
|
|
16
|
-
const decoder = new TextDecoder();
|
|
17
|
-
bytes.toString = () => decoder.decode(bytes);
|
|
18
|
-
return Object.assign(bytes, { type, typeFull, charset });
|
|
19
|
-
}
|
|
20
|
-
function cedarDataUriShim() {
|
|
21
|
-
if (getConfig().experimental?.rsc?.enabled) {
|
|
22
|
-
return void 0;
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
name: "cedar-data-uri-shim",
|
|
26
|
-
apply: "serve",
|
|
27
|
-
resolveId(id) {
|
|
28
|
-
if (id === "data-uri-to-buffer") {
|
|
29
|
-
return "\0cedar-data-uri-to-buffer";
|
|
30
|
-
}
|
|
31
|
-
return void 0;
|
|
32
|
-
},
|
|
33
|
-
load(id) {
|
|
34
|
-
if (id === "\0cedar-data-uri-to-buffer") {
|
|
35
|
-
return "export default " + dataUriToBuffer.toString();
|
|
36
|
-
}
|
|
37
|
-
return void 0;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
cedarDataUriShim
|
|
43
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Resolves bare directory imports to the index file or directory-named module.
|
|
4
|
-
*
|
|
5
|
-
* When you import `./Button`, this plugin checks:
|
|
6
|
-
* 1. `./Button/index.[js|ts|tsx|jsx|...]` — preferred if it exists
|
|
7
|
-
* 2. `./Button/Button.[js|ts|tsx|jsx|...]` — directory-named module fallback
|
|
8
|
-
*
|
|
9
|
-
* This mirrors the behaviour of babel-plugin-redwood-directory-named-import.
|
|
10
|
-
*/
|
|
11
|
-
export declare function cedarDirectoryNamedImportPlugin(): Plugin;
|
|
12
|
-
//# sourceMappingURL=vite-plugin-cedar-directory-named-import.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-directory-named-import.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-directory-named-import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CA0CxD"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { normalizePath } from "vite";
|
|
3
|
-
import { resolveFile } from "@cedarjs/project-config";
|
|
4
|
-
function cedarDirectoryNamedImportPlugin() {
|
|
5
|
-
return {
|
|
6
|
-
name: "vite-plugin-cedar-directory-named-import",
|
|
7
|
-
resolveId(id, importer) {
|
|
8
|
-
if (!id.startsWith(".") || !importer) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
if (normalizePath(importer).includes("/node_modules/")) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const absolutePath = path.resolve(path.dirname(importer), id);
|
|
15
|
-
if (resolveFile(absolutePath)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const basename = path.basename(absolutePath);
|
|
19
|
-
const indexPath = absolutePath + "/index";
|
|
20
|
-
const resolvedIndex = resolveFile(indexPath);
|
|
21
|
-
if (resolvedIndex) {
|
|
22
|
-
return normalizePath(resolvedIndex);
|
|
23
|
-
}
|
|
24
|
-
const dirnamedPath = absolutePath + "/" + basename;
|
|
25
|
-
const resolvedDirnamed = resolveFile(dirnamedPath);
|
|
26
|
-
if (resolvedDirnamed) {
|
|
27
|
-
return normalizePath(resolvedDirnamed);
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
cedarDirectoryNamedImportPlugin
|
|
35
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Vite plugin that injects the auto-generated gqlorm backend into
|
|
4
|
-
* `api/src/functions/graphql.ts` at build time.
|
|
5
|
-
*
|
|
6
|
-
* When `experimental.gqlorm.enabled = true` and `.cedar/gqlorm/backend.ts`
|
|
7
|
-
* exists, this plugin:
|
|
8
|
-
*
|
|
9
|
-
* 1. Adds imports at the top of graphql.ts:
|
|
10
|
-
* import * as __gqlorm_sdl__ from '../../../.cedar/gqlorm/backend'
|
|
11
|
-
* import { db as __gqlorm_db__ } from 'src/lib/db'
|
|
12
|
-
*
|
|
13
|
-
* 2. Inserts a statement immediately before the `createGraphQLHandler` call:
|
|
14
|
-
* Object.assign(sdls, {
|
|
15
|
-
* __gqlorm__: {
|
|
16
|
-
* schema: __gqlorm_sdl__.schema,
|
|
17
|
-
* resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
18
|
-
* },
|
|
19
|
-
* })
|
|
20
|
-
*
|
|
21
|
-
* The `sdls` variable is already a `let` binding because
|
|
22
|
-
* `vite-plugin-cedar-import-dir` transforms the glob import
|
|
23
|
-
* `import sdls from 'src/graphql/**\/*.sdl.{js,ts}'` into `let sdls = {}`.
|
|
24
|
-
*
|
|
25
|
-
* This plugin is a no-op when gqlorm is disabled or the backend file does
|
|
26
|
-
* not exist.
|
|
27
|
-
*/
|
|
28
|
-
export declare function cedarGqlormInjectPlugin(): Plugin;
|
|
29
|
-
//# sourceMappingURL=vite-plugin-cedar-gqlorm-inject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-gqlorm-inject.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-gqlorm-inject.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAQlC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAgHhD"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
getConfig,
|
|
5
|
-
getPaths,
|
|
6
|
-
importStatementPath
|
|
7
|
-
} from "@cedarjs/project-config";
|
|
8
|
-
function cedarGqlormInjectPlugin() {
|
|
9
|
-
return {
|
|
10
|
-
name: "cedar-gqlorm-inject",
|
|
11
|
-
transform(code, id) {
|
|
12
|
-
if (!id.endsWith("/graphql.ts") && !id.endsWith("/graphql.js")) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
if (code.includes("__gqlorm_sdl__")) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
if (!code.includes("createGraphQLHandler")) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
let config;
|
|
22
|
-
try {
|
|
23
|
-
config = getConfig();
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
if (!config.experimental?.gqlorm?.enabled) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
let paths;
|
|
31
|
-
try {
|
|
32
|
-
paths = getPaths();
|
|
33
|
-
} catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
const backendPathWithoutExt = path.join(
|
|
37
|
-
paths.generated.base,
|
|
38
|
-
"gqlorm",
|
|
39
|
-
"backend"
|
|
40
|
-
);
|
|
41
|
-
if (!fs.existsSync(backendPathWithoutExt + ".ts")) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
const handlerPattern = /^export\s+const\s+(\w+)\s*=\s*createGraphQLHandler\s*\(/m;
|
|
45
|
-
const handlerMatch = handlerPattern.exec(code);
|
|
46
|
-
if (!handlerMatch) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
const handlerLineStart = code.lastIndexOf("\n", handlerMatch.index) + 1;
|
|
50
|
-
const relPath = importStatementPath(
|
|
51
|
-
path.relative(path.dirname(id), backendPathWithoutExt)
|
|
52
|
-
) + ".ts";
|
|
53
|
-
const dbSrcPath = path.join(paths.api.src, "lib", "db");
|
|
54
|
-
const relDbPath = importStatementPath(path.relative(path.dirname(id), dbSrcPath)) + ".ts";
|
|
55
|
-
const importDb = `import { db as __gqlorm_db__ } from '${relDbPath}'`;
|
|
56
|
-
const importSdl = `import * as __gqlorm_sdl__ from '${relPath}'`;
|
|
57
|
-
const importsToAdd = `${importDb}
|
|
58
|
-
${importSdl}
|
|
59
|
-
`;
|
|
60
|
-
const sdlsMutation = `Object.assign(sdls, {
|
|
61
|
-
__gqlorm__: {
|
|
62
|
-
schema: __gqlorm_sdl__.schema,
|
|
63
|
-
resolvers: __gqlorm_sdl__.createGqlormResolvers(__gqlorm_db__),
|
|
64
|
-
},
|
|
65
|
-
})
|
|
66
|
-
`;
|
|
67
|
-
const transformed = importsToAdd + code.slice(0, handlerLineStart) + sdlsMutation + code.slice(handlerLineStart);
|
|
68
|
-
return {
|
|
69
|
-
code: transformed
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export {
|
|
75
|
-
cedarGqlormInjectPlugin
|
|
76
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { SourceMap } from 'magic-string';
|
|
2
|
-
import type { Plugin } from 'vite';
|
|
3
|
-
/**
|
|
4
|
-
* Vite plugin that extracts options passed to createGraphQLHandler into an
|
|
5
|
-
* exported variable.
|
|
6
|
-
*
|
|
7
|
-
* Transforms:
|
|
8
|
-
* export const handler = createGraphQLHandler({ options })
|
|
9
|
-
* into:
|
|
10
|
-
* export const __cedar_graphqlOptions = { options }
|
|
11
|
-
* export const handler = createGraphQLHandler(__cedar_graphqlOptions)
|
|
12
|
-
*
|
|
13
|
-
* This allows options to be imported elsewhere and enables the gqlorm-inject
|
|
14
|
-
* plugin to mutate the sdls object in-place before the call.
|
|
15
|
-
*
|
|
16
|
-
* The extraction uses an oxc-parser AST walk (see `applyGraphqlOptionsExtract`
|
|
17
|
-
* below) so the transform is robust against aliased imports, nested calls, and
|
|
18
|
-
* string escapes. The same logic is duplicated in
|
|
19
|
-
* `@cedarjs/internal` (`applyGraphqlOptionsExtract`) for the standalone esbuild
|
|
20
|
-
* API build
|
|
21
|
-
*/
|
|
22
|
-
export declare function cedarGraphqlOptionsExtractPlugin(): Plugin;
|
|
23
|
-
/**
|
|
24
|
-
* Extracts the options argument from createGraphQLHandler calls and stores
|
|
25
|
-
* them in an exported variable. Returns the transformed code with a sourcemap,
|
|
26
|
-
* or null if no transformation was needed.
|
|
27
|
-
*
|
|
28
|
-
* Transforms:
|
|
29
|
-
* export const handler = createGraphQLHandler({ options })
|
|
30
|
-
* into:
|
|
31
|
-
* export const __cedar_graphqlOptions = { options }
|
|
32
|
-
* export const handler = createGraphQLHandler(__cedar_graphqlOptions)
|
|
33
|
-
*
|
|
34
|
-
* Duplicate of `@cedarjs/internal`'s `applyGraphqlOptionsExtract` so this
|
|
35
|
-
* logic can run inside the Vite plugin pipeline without depending on internal's
|
|
36
|
-
* build output.
|
|
37
|
-
*/
|
|
38
|
-
export declare function applyGraphqlOptionsExtract(code: string): {
|
|
39
|
-
code: string;
|
|
40
|
-
map: SourceMap;
|
|
41
|
-
} | null;
|
|
42
|
-
//# sourceMappingURL=vite-plugin-cedar-graphql-options-extract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-graphql-options-extract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CA2BzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAgGzC"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import MagicString from "magic-string";
|
|
2
|
-
import { parseSync, Visitor } from "oxc-parser";
|
|
3
|
-
function cedarGraphqlOptionsExtractPlugin() {
|
|
4
|
-
return {
|
|
5
|
-
name: "cedar-graphql-options-extract",
|
|
6
|
-
transform(code, id) {
|
|
7
|
-
if (!id.endsWith("/graphql.ts") && !id.endsWith("/graphql.js")) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
if (!code.includes("createGraphQLHandler")) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const result = applyGraphqlOptionsExtract(code);
|
|
14
|
-
if (!result) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
code: result.code,
|
|
19
|
-
map: result.map
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function applyGraphqlOptionsExtract(code) {
|
|
25
|
-
if (code.includes("__cedar_graphqlOptions")) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
const { program } = parseSync("graphql.ts", code, {
|
|
29
|
-
// lang is only a parse hint; 'ts' also parses JS (the graphql handler can
|
|
30
|
-
// be graphql.js in JS projects), so this is safe for both file types.
|
|
31
|
-
lang: "ts",
|
|
32
|
-
sourceType: "module"
|
|
33
|
-
});
|
|
34
|
-
const importNames = /* @__PURE__ */ new Set();
|
|
35
|
-
for (const node of program.body) {
|
|
36
|
-
if (node.type === "ImportDeclaration") {
|
|
37
|
-
if (node.source.value !== "@cedarjs/graphql-server") {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
for (const specifier of node.specifiers) {
|
|
41
|
-
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "createGraphQLHandler") {
|
|
42
|
-
importNames.add(specifier.local.name);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (importNames.size === 0) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
const callExpressionPaths = [];
|
|
51
|
-
new Visitor({
|
|
52
|
-
CallExpression(node) {
|
|
53
|
-
if (node.callee.type === "Identifier" && importNames.has(node.callee.name)) {
|
|
54
|
-
callExpressionPaths.push(node);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}).visit(program);
|
|
58
|
-
if (callExpressionPaths.length > 1) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
const callExpression = callExpressionPaths[0];
|
|
62
|
-
if (!callExpression) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
const options = callExpression.arguments[0];
|
|
66
|
-
if (!options) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
if (options.type !== "Identifier" && options.type !== "ObjectExpression" && options.type !== "CallExpression" && options.type !== "ConditionalExpression") {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
const optionsStart = options.start;
|
|
73
|
-
const optionsEnd = options.end;
|
|
74
|
-
const lineStart = code.lastIndexOf("\n", callExpression.start) + 1;
|
|
75
|
-
const indentMatch = /^[ \t]*/.exec(code.slice(lineStart));
|
|
76
|
-
const indent = indentMatch ? indentMatch[0] : "";
|
|
77
|
-
const optionsConst = `${indent}export const __cedar_graphqlOptions = ${code.slice(
|
|
78
|
-
optionsStart,
|
|
79
|
-
optionsEnd
|
|
80
|
-
)}
|
|
81
|
-
`;
|
|
82
|
-
const s = new MagicString(code);
|
|
83
|
-
s.prependLeft(lineStart, optionsConst);
|
|
84
|
-
s.overwrite(optionsStart, optionsEnd, "__cedar_graphqlOptions");
|
|
85
|
-
return {
|
|
86
|
-
code: s.toString(),
|
|
87
|
-
map: s.generateMap({ hires: true })
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export {
|
|
91
|
-
applyGraphqlOptionsExtract,
|
|
92
|
-
cedarGraphqlOptionsExtractPlugin
|
|
93
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
import type * as apiLogger from '@cedarjs/api/logger';
|
|
3
|
-
/**
|
|
4
|
-
* Dev-only Vite plugin that makes the api's pino logger pretty-print
|
|
5
|
-
* through the same formatter plain `yarn cedar dev` gets via its
|
|
6
|
-
* `... | cedar-log-formatter` shell pipe.
|
|
7
|
-
*
|
|
8
|
-
* `--ud` mode runs the api in-process as Vite SSR middleware, so there's no
|
|
9
|
-
* separate api process whose stdout a shell pipe could format externally,
|
|
10
|
-
* and pino's default destination writes straight to file descriptor 1
|
|
11
|
-
* (bypassing `process.stdout.write`), so patching stdout wouldn't see the
|
|
12
|
-
* log lines either. Instead, this intercepts resolution of
|
|
13
|
-
* `@cedarjs/api/logger` and swaps in a wrapped `createLogger` that injects
|
|
14
|
-
* a formatting `destination` whenever the caller (the app's own
|
|
15
|
-
* `api/src/lib/logger.ts`) doesn't already supply one.
|
|
16
|
-
*
|
|
17
|
-
* Only registered in `createApiViteServer()`'s dev-only Vite instance —
|
|
18
|
-
* never touched by any production build path — so this has no effect on
|
|
19
|
-
* (and no dependency footprint added to) a deployed api.
|
|
20
|
-
*/
|
|
21
|
-
export declare function cedarApiLogFormatterDevPlugin(): Plugin;
|
|
22
|
-
export declare function createFormattingDestination(): {
|
|
23
|
-
write(chunk: string): void;
|
|
24
|
-
};
|
|
25
|
-
type CreateLoggerParams = Parameters<typeof apiLogger.createLogger>[0];
|
|
26
|
-
export declare function createLogger(params?: CreateLoggerParams): apiLogger.Logger;
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=vite-plugin-cedar-log-formatter-dev.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-log-formatter-dev.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-log-formatter-dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,OAAO,KAAK,KAAK,SAAS,MAAM,qBAAqB,CAAA;AAOrD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,IAAI,MAAM,CAoCtD;AAED,wBAAgB,2BAA2B;iBAK1B,MAAM;EAYtB;AAED,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAUtE,wBAAgB,YAAY,CAAC,MAAM,GAAE,kBAAuB,oBAS3D"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { LogFormatter } from "@cedarjs/api-server/logFormatter";
|
|
2
|
-
const INTERCEPTED_SPECIFIER = "@cedarjs/api/logger";
|
|
3
|
-
const VIRTUAL_MODULE_ID = "virtual:cedar-api-logger-dev";
|
|
4
|
-
const RESOLVED_VIRTUAL_MODULE_ID = "\0" + VIRTUAL_MODULE_ID;
|
|
5
|
-
function cedarApiLogFormatterDevPlugin() {
|
|
6
|
-
return {
|
|
7
|
-
name: "cedar-api-log-formatter-dev",
|
|
8
|
-
enforce: "pre",
|
|
9
|
-
resolveId(id, importer) {
|
|
10
|
-
if (id === INTERCEPTED_SPECIFIER && importer !== RESOLVED_VIRTUAL_MODULE_ID) {
|
|
11
|
-
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
},
|
|
15
|
-
load(id) {
|
|
16
|
-
if (id !== RESOLVED_VIRTUAL_MODULE_ID) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return `
|
|
20
|
-
import * as realLogger from ${JSON.stringify(INTERCEPTED_SPECIFIER)}
|
|
21
|
-
import { LogFormatter } from '@cedarjs/api-server/logFormatter'
|
|
22
|
-
|
|
23
|
-
export * from ${JSON.stringify(INTERCEPTED_SPECIFIER)}
|
|
24
|
-
|
|
25
|
-
${createFormattingDestination.toString()}
|
|
26
|
-
|
|
27
|
-
// toString() doesn't include the 'export' keyword
|
|
28
|
-
export ${createLogger.toString()}
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function createFormattingDestination() {
|
|
34
|
-
const format = LogFormatter();
|
|
35
|
-
let buffered = "";
|
|
36
|
-
return {
|
|
37
|
-
write(chunk) {
|
|
38
|
-
buffered += chunk;
|
|
39
|
-
const lines = buffered.split("\n");
|
|
40
|
-
buffered = lines.pop() ?? "";
|
|
41
|
-
for (const line of lines) {
|
|
42
|
-
if (line.length > 0) {
|
|
43
|
-
process.stdout.write(format(line));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const realLogger = {
|
|
50
|
-
createLogger: (_params) => {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
function createLogger(params = {}) {
|
|
55
|
-
if (params.destination) {
|
|
56
|
-
return realLogger.createLogger(params);
|
|
57
|
-
}
|
|
58
|
-
return realLogger.createLogger({
|
|
59
|
-
...params,
|
|
60
|
-
destination: createFormattingDestination()
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
cedarApiLogFormatterDevPlugin,
|
|
65
|
-
createFormattingDestination,
|
|
66
|
-
createLogger
|
|
67
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Vite plugin that automatically wraps the `standard` export in Cell mock files
|
|
4
|
-
* with `mockGraphQLQuery`.
|
|
5
|
-
*
|
|
6
|
-
* Only active in non-production environments (for Storybook and Jest).
|
|
7
|
-
*
|
|
8
|
-
* Transforms `*.Cell.mock.[js,ts]` files by:
|
|
9
|
-
* 1. Determining the query operation name from the adjacent Cell's QUERY export
|
|
10
|
-
* 2. Wrapping the `standard` function export in `mockGraphQLQuery(operationName, fn)`
|
|
11
|
-
* 3. If the Cell has an `afterQuery` export, also wraps with `afterQuery(fn())`
|
|
12
|
-
*
|
|
13
|
-
* This is a 1:1 port of `babel-plugin-redwood-mock-cell-data`.
|
|
14
|
-
*/
|
|
15
|
-
export declare function cedarMockCellDataPlugin(): Plugin;
|
|
16
|
-
export declare const getCellMetadata: (p: string) => {
|
|
17
|
-
hasDefaultExport: boolean;
|
|
18
|
-
namedExports: NamedExports[];
|
|
19
|
-
hasQueryExport: NamedExports | undefined;
|
|
20
|
-
hasAfterQueryExport: NamedExports | undefined;
|
|
21
|
-
operationName: string;
|
|
22
|
-
};
|
|
23
|
-
interface NamedExports {
|
|
24
|
-
name: string;
|
|
25
|
-
type: 're-export' | 'variable' | 'function' | 'class';
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=vite-plugin-cedar-mock-cell-data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-mock-cell-data.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-mock-cell-data.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CA2KhD;AAcD,eAAO,MAAM,eAAe,GAAI,GAAG,MAAM;;;;;;CAoFxC,CAAA;AAgCD,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAA;CACtD"}
|