@cedarjs/vite 6.0.0-canary.2798 → 6.0.0-canary.2800

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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { BabelOptions } from '@vitejs/plugin-react';
2
2
  import type { PluginOption } from 'vite';
3
+ export { cedarApiImportGuardPlugin } from './plugins/vite-plugin-cedar-api-import-guard.js';
3
4
  export { cedarAutoImportsPlugin } from './plugins/vite-plugin-cedar-auto-import.js';
4
5
  export { cedarCjsCompatPlugin } from './plugins/vite-plugin-cedar-cjs-compat.js';
5
6
  export { cedarCellTransform } from './plugins/vite-plugin-cedar-cell.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAoCxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAA;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,+BAA+B,EAAE,MAAM,uDAAuD,CAAA;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA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AA;IACzB,KAAK,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;CACjC,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAgDzE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  cedarVitestWebConfigPlugin,
14
14
  createAuthImportTransformPlugin
15
15
  } from "@cedarjs/testing/web/vitest";
16
+ import { cedarApiImportGuardPlugin } from "./plugins/vite-plugin-cedar-api-import-guard.js";
16
17
  import { cedarAutoImportsPlugin } from "./plugins/vite-plugin-cedar-auto-import.js";
17
18
  import { cedarCellTransform } from "./plugins/vite-plugin-cedar-cell.js";
18
19
  import { cedarDataUriShim } from "./plugins/vite-plugin-cedar-data-uri-shim.js";
@@ -27,6 +28,7 @@ import { cedarjsResolveCedarStyleImportsPlugin } from "./plugins/vite-plugin-ced
27
28
  import { cedarTransformJsAsJsx } from "./plugins/vite-plugin-jsx-loader.js";
28
29
  import { cedarMergedConfig } from "./plugins/vite-plugin-merged-config.js";
29
30
  import { cedarSwapApolloProvider } from "./plugins/vite-plugin-swap-apollo-provider.js";
31
+ import { cedarApiImportGuardPlugin as cedarApiImportGuardPlugin2 } from "./plugins/vite-plugin-cedar-api-import-guard.js";
30
32
  import { cedarAutoImportsPlugin as cedarAutoImportsPlugin2 } from "./plugins/vite-plugin-cedar-auto-import.js";
31
33
  import { cedarCjsCompatPlugin } from "./plugins/vite-plugin-cedar-cjs-compat.js";
32
34
  import { cedarCellTransform as cedarCellTransform2 } from "./plugins/vite-plugin-cedar-cell.js";
@@ -63,6 +65,9 @@ function cedar({ mode, babel } = {}) {
63
65
  plugins: [...compilerPlugins, ...babel?.plugins ?? []]
64
66
  } : void 0;
65
67
  return [
68
+ // Has to come before tsconfigPaths(), which would otherwise resolve
69
+ // `$api/*` imports using the project's web/tsconfig.json `paths` mapping
70
+ cedarApiImportGuardPlugin(),
66
71
  tsconfigPaths(),
67
72
  gqlTagPlugin(),
68
73
  mode === "test" && cedarJsRouterImportTransformPlugin(),
@@ -91,6 +96,7 @@ var index_default = cedar;
91
96
  export {
92
97
  applyHandlerAlsWrapping,
93
98
  cedar,
99
+ cedarApiImportGuardPlugin2 as cedarApiImportGuardPlugin,
94
100
  cedarAutoImportsPlugin2 as cedarAutoImportsPlugin,
95
101
  cedarCellTransform2 as cedarCellTransform,
96
102
  cedarCjsCompatPlugin,
@@ -0,0 +1,13 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * `$api/` imports resolve to files on the api side. They're only supported in
4
+ * `*.routeHooks.{js,ts}` files and in scripts run with `yarn cedar exec` – both
5
+ * of which run on the server. This plugin makes a `$api/` import from code that
6
+ * ends up in the browser bundle fail with an explanatory error instead of
7
+ * silently bundling server-only code (like the Prisma client) into the browser.
8
+ *
9
+ * Has to run before `vite-tsconfig-paths`, which would otherwise resolve
10
+ * `$api/*` using the `paths` mapping in the project's `web/tsconfig.json`.
11
+ */
12
+ export declare function cedarApiImportGuardPlugin(): Plugin;
13
+ //# sourceMappingURL=vite-plugin-cedar-api-import-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-cedar-api-import-guard.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-api-import-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CA0BlD"}
@@ -0,0 +1,17 @@
1
+ function cedarApiImportGuardPlugin() {
2
+ return {
3
+ name: "cedar-api-import-guard",
4
+ enforce: "pre",
5
+ resolveId(id, importer) {
6
+ if (this.environment?.name !== "client" || !id.startsWith("$api/")) {
7
+ return null;
8
+ }
9
+ throw new Error(
10
+ `Cannot import "${id}" from client-side code` + (importer ? ` (imported by "${importer}")` : "") + '.\n\n"$api/" imports resolve to your api side, which must never end up in the browser bundle. They\'re only supported in server-side code, like *.routeHooks.{js,ts} files and scripts run with `yarn cedar exec`.\n\nIf you need this data in the browser, fetch it through GraphQL instead.'
11
+ );
12
+ }
13
+ };
14
+ }
15
+ export {
16
+ cedarApiImportGuardPlugin
17
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-cedar-import-dir.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-import-dir.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAqI7C"}
1
+ {"version":3,"file":"vite-plugin-cedar-import-dir.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-import-dir.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA4H7C"}
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { parse, Lang } from "@ast-grep/napi";
4
3
  import MagicString from "magic-string";
4
+ import { parseSync } from "oxc-parser";
5
5
  import { normalizePath } from "vite";
6
6
  import { importStatementPath, getPaths } from "@cedarjs/project-config";
7
7
  function cedarImportDirPlugin() {
@@ -12,36 +12,32 @@ function cedarImportDirPlugin() {
12
12
  if (!code.includes("/**/")) {
13
13
  return null;
14
14
  }
15
- const ext = path.extname(id);
16
- const language = ext === ".ts" || ext === ".tsx" ? Lang.TypeScript : Lang.JavaScript;
17
- let ast;
15
+ let program;
18
16
  try {
19
- ast = parse(language, code);
17
+ program = parseSync(id, code).program;
20
18
  } catch (error) {
21
19
  console.warn("Failed to parse file:", id);
22
20
  console.warn(error);
23
21
  return null;
24
22
  }
25
- const root = ast.root();
26
23
  let hasTransformations = false;
27
24
  const s = new MagicString(code);
28
- const globImports = root.findAll({
29
- rule: {
30
- pattern: "import $DEFAULT_IMPORT from $SOURCE"
25
+ for (const node of program.body) {
26
+ if (node.type !== "ImportDeclaration") {
27
+ continue;
31
28
  }
32
- });
33
- for (const importNode of globImports) {
34
- const sourceNode = importNode.getMatch("SOURCE");
35
- const defaultImportNode = importNode.getMatch("DEFAULT_IMPORT");
36
- if (!sourceNode || !defaultImportNode) {
29
+ const defaultSpecifier = node.specifiers.find(
30
+ (specifier) => specifier.type === "ImportDefaultSpecifier"
31
+ );
32
+ if (!defaultSpecifier) {
37
33
  continue;
38
34
  }
39
- const sourceValue = sourceNode.text().slice(1, -1);
35
+ const sourceValue = node.source.value;
40
36
  if (!sourceValue.includes("/**/")) {
41
37
  continue;
42
38
  }
43
39
  hasTransformations = true;
44
- const importName = defaultImportNode.text();
40
+ const importName = defaultSpecifier.local.name;
45
41
  const importGlob = importStatementPath(sourceValue);
46
42
  let cwd = path.dirname(id);
47
43
  if (importGlob.startsWith("src/")) {
@@ -81,8 +77,7 @@ function cedarImportDirPlugin() {
81
77
  replacement += `${importName}.${filePathVarName} = ${namespaceImportName};
82
78
  `;
83
79
  }
84
- const range = importNode.range();
85
- s.overwrite(range.start.index, range.end.index, replacement.trim());
80
+ s.overwrite(node.start, node.end, replacement.trim());
86
81
  } catch (error) {
87
82
  console.warn(`Failed to process glob import: ${sourceValue}`, error);
88
83
  }
@@ -1,3 +1,32 @@
1
+ import type { SourceMap } from 'magic-string';
1
2
  import type { Plugin } from 'vite';
3
+ /**
4
+ * Vite plugin that injects `path` and `name` properties into `createJob()`
5
+ * definitions so the jobs runner can locate and identify the job's module at
6
+ * runtime.
7
+ *
8
+ * Transforms:
9
+ * export const myJob = jobs.createJob({ perform: ... })
10
+ * into:
11
+ * export const myJob = jobs.createJob({ perform: ..., path: "...", name: "myJob" })
12
+ *
13
+ * The extraction uses an oxc-parser AST walk so the transform is robust
14
+ * against nested object properties, aliased imports, and TypeScript syntax.
15
+ * The same logic is duplicated in `@cedarjs/internal`
16
+ * (`applyJobPathInjector`) for the standalone esbuild API build.
17
+ */
2
18
  export declare function cedarjsJobPathInjectorPlugin(): Plugin;
19
+ /**
20
+ * Injects `path` and `name` properties into `createJob()` definitions.
21
+ * Returns the transformed code with a sourcemap, or null if no
22
+ * transformation was needed.
23
+ *
24
+ * Duplicate of `@cedarjs/internal`'s `applyJobPathInjector` so this logic can
25
+ * run inside the Vite plugin pipeline without depending on internal's build
26
+ * output.
27
+ */
28
+ export declare function applyJobPathInjector(code: string, filePath: string, jobsDir: string): {
29
+ code: string;
30
+ map: SourceMap;
31
+ } | null;
3
32
  //# sourceMappingURL=vite-plugin-cedarjs-job-path-injector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-cedarjs-job-path-injector.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedarjs-job-path-injector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC,wBAAgB,4BAA4B,IAAI,MAAM,CAqHrD"}
1
+ {"version":3,"file":"vite-plugin-cedarjs-job-path-injector.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedarjs-job-path-injector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,CAoBrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAiFzC"}
@@ -1,5 +1,6 @@
1
1
  import path from "node:path";
2
- import { parse, Lang } from "@ast-grep/napi";
2
+ import MagicString from "magic-string";
3
+ import { parseSync } from "oxc-parser";
3
4
  import { getPaths } from "@cedarjs/project-config";
4
5
  function cedarjsJobPathInjectorPlugin() {
5
6
  return {
@@ -8,93 +9,74 @@ function cedarjsJobPathInjectorPlugin() {
8
9
  if (!code.includes("createJob")) {
9
10
  return null;
10
11
  }
11
- const isTypescript = id.endsWith(".ts") || id.endsWith(".tsx");
12
- const language = isTypescript ? Lang.TypeScript : Lang.JavaScript;
13
- let ast;
14
- try {
15
- ast = parse(language, code);
16
- } catch (error) {
17
- console.warn("Failed to parse file:", id);
18
- console.warn(error);
12
+ const result = applyJobPathInjector(code, id, getPaths().api.jobs);
13
+ if (!result) {
19
14
  return null;
20
15
  }
21
- const paths = getPaths();
22
- const edits = [];
23
- const root = ast.root();
24
- const createJobCalls = root.findAll({
25
- rule: {
26
- pattern: "export const $VAR_NAME = $OBJ.createJob({ $$$PROPS })"
27
- }
28
- });
29
- for (const callNode of createJobCalls) {
30
- const varNameNode = callNode.getMatch("VAR_NAME");
31
- const propsNodes = callNode.getMultipleMatches("PROPS");
32
- if (!varNameNode) {
33
- continue;
34
- }
35
- const importName = varNameNode.text();
36
- const importPath = path.relative(paths.api.jobs, id);
37
- const importPathWithoutExtension = importPath.replace(/\.[^/.]+$/, "");
38
- const pathProperty = `path: ${JSON.stringify(importPathWithoutExtension)}`;
39
- const nameProperty = `name: ${JSON.stringify(importName)}`;
40
- let insertText = "";
41
- if (propsNodes.length > 0) {
42
- const objectLiteral = callNode.find({
43
- rule: {
44
- kind: "object",
45
- inside: {
46
- kind: "arguments"
47
- }
48
- }
49
- });
50
- if (objectLiteral) {
51
- insertText = `, ${pathProperty}, ${nameProperty}`;
52
- const objectText = objectLiteral.text();
53
- const closeBraceIndex = objectText.lastIndexOf("}");
54
- if (closeBraceIndex !== -1) {
55
- const range = objectLiteral.range();
56
- edits.push({
57
- startPos: range.start.index + closeBraceIndex,
58
- endPos: range.start.index + closeBraceIndex,
59
- insertedText: insertText
60
- });
61
- }
62
- }
63
- } else {
64
- const objectLiteral = callNode.find({
65
- rule: {
66
- kind: "object",
67
- inside: {
68
- kind: "arguments"
69
- }
70
- }
71
- });
72
- if (objectLiteral) {
73
- insertText = `${pathProperty}, ${nameProperty}`;
74
- const objectText = objectLiteral.text();
75
- const openBraceIndex = objectText.indexOf("{");
76
- if (openBraceIndex !== -1) {
77
- const range = objectLiteral.range();
78
- edits.push({
79
- startPos: range.start.index + openBraceIndex + 1,
80
- endPos: range.start.index + openBraceIndex + 1,
81
- insertedText: insertText
82
- });
83
- }
84
- }
85
- }
86
- }
87
- if (edits.length === 0) {
88
- return null;
89
- }
90
- const modifiedCode = root.commitEdits(edits);
91
16
  return {
92
- code: modifiedCode,
93
- map: null
17
+ code: result.code,
18
+ map: result.map
94
19
  };
95
20
  }
96
21
  };
97
22
  }
23
+ function applyJobPathInjector(code, filePath, jobsDir) {
24
+ let program;
25
+ try {
26
+ program = parseSync(filePath, code, { sourceType: "module" }).program;
27
+ } catch (error) {
28
+ console.warn("Failed to parse file:", filePath);
29
+ console.warn(error);
30
+ return null;
31
+ }
32
+ const importPath = path.relative(jobsDir, filePath);
33
+ const importPathWithoutExtension = importPath.replace(/\.[^/.]+$/, "");
34
+ const s = new MagicString(code);
35
+ let hasTransformations = false;
36
+ for (const node of program.body) {
37
+ if (node.type !== "ExportNamedDeclaration") {
38
+ continue;
39
+ }
40
+ const decl = node.declaration;
41
+ if (decl?.type !== "VariableDeclaration") {
42
+ continue;
43
+ }
44
+ for (const declarator of decl.declarations) {
45
+ if (declarator.id.type !== "Identifier") {
46
+ continue;
47
+ }
48
+ const init = declarator.init;
49
+ if (init?.type !== "CallExpression") {
50
+ continue;
51
+ }
52
+ const callee = init.callee;
53
+ if (callee.type !== "MemberExpression" || callee.computed || callee.property.type !== "Identifier" || callee.property.name !== "createJob") {
54
+ continue;
55
+ }
56
+ const configArg = init.arguments[0];
57
+ if (configArg?.type !== "ObjectExpression") {
58
+ continue;
59
+ }
60
+ hasTransformations = true;
61
+ const pathProperty = `path: ${JSON.stringify(importPathWithoutExtension)}`;
62
+ const nameProperty = `name: ${JSON.stringify(declarator.id.name)}`;
63
+ const lastProperty = configArg.properties.at(-1);
64
+ if (lastProperty) {
65
+ s.appendLeft(lastProperty.end, `, ${pathProperty}, ${nameProperty}`);
66
+ } else {
67
+ s.appendLeft(configArg.start + 1, `${pathProperty}, ${nameProperty}`);
68
+ }
69
+ }
70
+ }
71
+ if (!hasTransformations) {
72
+ return null;
73
+ }
74
+ return {
75
+ code: s.toString(),
76
+ map: s.generateMap({ hires: true })
77
+ };
78
+ }
98
79
  export {
80
+ applyJobPathInjector,
99
81
  cedarjsJobPathInjectorPlugin
100
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAiClC,wBAAgB,qCAAqC,IAAI,MAAM,CA2F9D"}
1
+ {"version":3,"file":"vite-plugin-cedarjs-resolve-cedar-style-imports.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAiClC,wBAAgB,qCAAqC,IAAI,MAAM,CAwG9D"}
@@ -52,7 +52,7 @@ function cedarjsResolveCedarStyleImportsPlugin() {
52
52
  }
53
53
  }
54
54
  }
55
- if (cedarPaths && id.startsWith("$api/")) {
55
+ if (cedarPaths && id.startsWith("$api/") && this.environment?.name !== "client") {
56
56
  const resolved = resolveFromAbsolutePath(
57
57
  path.join(cedarPaths.api.base, id.slice("$api/".length))
58
58
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/vite",
3
- "version": "6.0.0-canary.2798",
3
+ "version": "6.0.0-canary.2800",
4
4
  "description": "Vite configuration package for CedarJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,21 +48,20 @@
48
48
  "test:watch": "vitest watch"
49
49
  },
50
50
  "dependencies": {
51
- "@ast-grep/napi": "0.45.0",
52
51
  "@babel/generator": "7.29.7",
53
52
  "@babel/parser": "7.29.7",
54
53
  "@babel/traverse": "7.29.7",
55
54
  "@babel/types": "7.29.7",
56
- "@cedarjs/api": "6.0.0-canary.2798",
57
- "@cedarjs/api-server": "6.0.0-canary.2798",
58
- "@cedarjs/babel-config": "6.0.0-canary.2798",
59
- "@cedarjs/context": "6.0.0-canary.2798",
60
- "@cedarjs/graphql-server": "6.0.0-canary.2798",
61
- "@cedarjs/internal": "6.0.0-canary.2798",
62
- "@cedarjs/project-config": "6.0.0-canary.2798",
63
- "@cedarjs/server-store": "6.0.0-canary.2798",
64
- "@cedarjs/structure": "6.0.0-canary.2798",
65
- "@cedarjs/testing": "6.0.0-canary.2798",
55
+ "@cedarjs/api": "6.0.0-canary.2800",
56
+ "@cedarjs/api-server": "6.0.0-canary.2800",
57
+ "@cedarjs/babel-config": "6.0.0-canary.2800",
58
+ "@cedarjs/context": "6.0.0-canary.2800",
59
+ "@cedarjs/graphql-server": "6.0.0-canary.2800",
60
+ "@cedarjs/internal": "6.0.0-canary.2800",
61
+ "@cedarjs/project-config": "6.0.0-canary.2800",
62
+ "@cedarjs/server-store": "6.0.0-canary.2800",
63
+ "@cedarjs/structure": "6.0.0-canary.2800",
64
+ "@cedarjs/testing": "6.0.0-canary.2800",
66
65
  "@swc/core": "1.15.46",
67
66
  "@universal-deploy/store": "^0.2.1",
68
67
  "@universal-deploy/vite": "^0.1.9",
@@ -93,10 +92,10 @@
93
92
  "yargs-parser": "21.1.1"
94
93
  },
95
94
  "devDependencies": {
96
- "@cedarjs/auth": "6.0.0-canary.2798",
97
- "@cedarjs/framework-tools": "6.0.0-canary.2798",
98
- "@cedarjs/router": "6.0.0-canary.2798",
99
- "@cedarjs/web": "6.0.0-canary.2798",
95
+ "@cedarjs/auth": "6.0.0-canary.2800",
96
+ "@cedarjs/framework-tools": "6.0.0-canary.2800",
97
+ "@cedarjs/router": "6.0.0-canary.2800",
98
+ "@cedarjs/web": "6.0.0-canary.2800",
100
99
  "@dr.pogodin/react-helmet": "2.0.4",
101
100
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",
102
101
  "@jridgewell/trace-mapping": "0.3.31",
@@ -116,9 +115,9 @@
116
115
  "vitest": "4.1.10"
117
116
  },
118
117
  "peerDependencies": {
119
- "@cedarjs/auth": "6.0.0-canary.2798",
120
- "@cedarjs/router": "6.0.0-canary.2798",
121
- "@cedarjs/web": "6.0.0-canary.2798"
118
+ "@cedarjs/auth": "6.0.0-canary.2800",
119
+ "@cedarjs/router": "6.0.0-canary.2800",
120
+ "@cedarjs/web": "6.0.0-canary.2800"
122
121
  },
123
122
  "engines": {
124
123
  "node": ">=24"