theokit 0.2.0 → 0.2.2

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 (130) hide show
  1. package/dist/actions-virtual-module-E6PU47GV.js +175 -0
  2. package/dist/actions-virtual-module-E6PU47GV.js.map +1 -0
  3. package/dist/actions-virtual-module-E7IELVHL.js +174 -0
  4. package/dist/actions-virtual-module-E7IELVHL.js.map +1 -0
  5. package/dist/app-typed-client-RZMVWHJ3.js +289 -0
  6. package/dist/app-typed-client-RZMVWHJ3.js.map +1 -0
  7. package/dist/app-typed-client-YIBP6JWH.js +289 -0
  8. package/dist/app-typed-client-YIBP6JWH.js.map +1 -0
  9. package/dist/{aws-lambda-PONVF3UX.js → aws-lambda-XYCGZH3I.js} +2 -2
  10. package/dist/{build-IQQYCA3B.js → build-NCGIV4LL.js} +41 -14
  11. package/dist/build-NCGIV4LL.js.map +1 -0
  12. package/dist/build-request-body-preview-EOP2Y4F3.js +52 -0
  13. package/dist/build-request-body-preview-EOP2Y4F3.js.map +1 -0
  14. package/dist/build-request-body-preview-II2235E6.js +54 -0
  15. package/dist/build-request-body-preview-II2235E6.js.map +1 -0
  16. package/dist/{bun-DITMZMKL.js → bun-K73TQEWC.js} +2 -2
  17. package/dist/{chunk-GQSTRXXB.js → chunk-2BQYEBCK.js} +77 -68
  18. package/dist/chunk-2BQYEBCK.js.map +1 -0
  19. package/dist/chunk-7DHGV77J.js +140 -0
  20. package/dist/chunk-7DHGV77J.js.map +1 -0
  21. package/dist/{chunk-WQCPKA2L.js → chunk-C27AZN46.js} +570 -165
  22. package/dist/chunk-C27AZN46.js.map +1 -0
  23. package/dist/chunk-ERAZNHHR.js +73 -0
  24. package/dist/chunk-ERAZNHHR.js.map +1 -0
  25. package/dist/{chunk-ZK5JCE5J.js → chunk-EXJWO2HB.js} +201 -43
  26. package/dist/chunk-EXJWO2HB.js.map +1 -0
  27. package/dist/chunk-F3TG5FJV.js +97 -0
  28. package/dist/chunk-F3TG5FJV.js.map +1 -0
  29. package/dist/{chunk-OK2PJOLK.js → chunk-KJVEJILQ.js} +7 -3
  30. package/dist/chunk-KJVEJILQ.js.map +1 -0
  31. package/dist/{chunk-JBC7PFV4.js → chunk-M23FP2AS.js} +2 -2
  32. package/dist/chunk-M23FP2AS.js.map +1 -0
  33. package/dist/{chunk-FRBYJANT.js → chunk-M6MYZSD2.js} +195 -41
  34. package/dist/chunk-M6MYZSD2.js.map +1 -0
  35. package/dist/{chunk-S3JBIFKS.js → chunk-MG7H3LAW.js} +2 -2
  36. package/dist/chunk-MOT42NAH.js +165 -0
  37. package/dist/chunk-MOT42NAH.js.map +1 -0
  38. package/dist/{chunk-OEB3OIYP.js → chunk-OJHO2X7C.js} +497 -168
  39. package/dist/chunk-OJHO2X7C.js.map +1 -0
  40. package/dist/chunk-QLGES2HC.js +189 -0
  41. package/dist/chunk-QLGES2HC.js.map +1 -0
  42. package/dist/{chunk-JZ5WEG3S.js → chunk-SEVYARIU.js} +9 -5
  43. package/dist/chunk-SEVYARIU.js.map +1 -0
  44. package/dist/chunk-WSJKACWB.js +17 -0
  45. package/dist/chunk-WSJKACWB.js.map +1 -0
  46. package/dist/{chunk-3Q36SEDK.js → chunk-ZBWROIIO.js} +43 -2
  47. package/dist/{chunk-3Q36SEDK.js.map → chunk-ZBWROIIO.js.map} +1 -1
  48. package/dist/{chunk-Y5KE6YFP.js → chunk-ZJW5FFYJ.js} +3 -3
  49. package/dist/chunk-ZJW5FFYJ.js.map +1 -0
  50. package/dist/chunk-ZOXNJV2O.js +358 -0
  51. package/dist/chunk-ZOXNJV2O.js.map +1 -0
  52. package/dist/cli/index.js +22 -7
  53. package/dist/cli/index.js.map +1 -1
  54. package/dist/client/index.d.ts +31 -1
  55. package/dist/client/index.js +100 -0
  56. package/dist/client/index.js.map +1 -1
  57. package/dist/{cloudflare-RBANU3SE.js → cloudflare-LCAOTRYZ.js} +2 -2
  58. package/dist/{deno-deploy-J7LI6HNL.js → deno-deploy-ZN4RE5HF.js} +2 -2
  59. package/dist/{dev-VN6WS3CM.js → dev-WDXC74CK.js} +15 -7
  60. package/dist/dev-WDXC74CK.js.map +1 -0
  61. package/dist/dev-emit-3CHM73TV.js +390 -0
  62. package/dist/dev-emit-3CHM73TV.js.map +1 -0
  63. package/dist/dev-emit-I3CKOHML.js +44 -0
  64. package/dist/dev-emit-I3CKOHML.js.map +1 -0
  65. package/dist/devtools/entry.js +545 -181
  66. package/dist/devtools/entry.js.map +1 -1
  67. package/dist/{dispatcher-IK3FVMX5.js → dispatcher-AQJGI3HU.js} +2 -2
  68. package/dist/dispatcher-E6QV32BO.js +83 -0
  69. package/dist/dispatcher-E6QV32BO.js.map +1 -0
  70. package/dist/{dist-Q5VBFWVL.js → dist-R2Q7GVDW.js} +10357 -12068
  71. package/dist/dist-R2Q7GVDW.js.map +1 -0
  72. package/dist/{generate-SIO4JSKJ.js → generate-DT4IIAHF.js} +88 -22
  73. package/dist/generate-DT4IIAHF.js.map +1 -0
  74. package/dist/index.d.ts +108 -1
  75. package/dist/index.js +5 -2
  76. package/dist/index.js.map +1 -1
  77. package/dist/{info-B3UOXFUF.js → info-VM7EK4JC.js} +3 -3
  78. package/dist/{netlify-IFY6ZGFV.js → netlify-5VQ22Z2P.js} +2 -2
  79. package/dist/{node-KWZI3CKV.js → node-3APTLGWB.js} +2 -2
  80. package/dist/openapi-CBASKC7W.js +84 -0
  81. package/dist/openapi-CBASKC7W.js.map +1 -0
  82. package/dist/registry-5QFTLOL2.js +25 -0
  83. package/dist/{routes-CAGFZKUK.js → routes-7O4NUDYS.js} +9 -7
  84. package/dist/{routes-CAGFZKUK.js.map → routes-7O4NUDYS.js.map} +1 -1
  85. package/dist/{schema-Cxq2qqwh.d.ts → schema-CjVly9c_.d.ts} +43 -1
  86. package/dist/{schema-MVB2FVK6.js → schema-JAKF23GR.js} +2 -2
  87. package/dist/server/cost/index.js +1 -1
  88. package/dist/server/index.d.ts +219 -47
  89. package/dist/server/index.js +35 -116
  90. package/dist/server/index.js.map +1 -1
  91. package/dist/{start-ZGWW5MOL.js → start-5JTFWF4T.js} +20 -14
  92. package/dist/start-5JTFWF4T.js.map +1 -0
  93. package/dist/{static-BH6JQNM2.js → static-TZBVBDTB.js} +4 -4
  94. package/dist/{upgrade-readiness-OHL36FQL.js → upgrade-readiness-Q46KTG2J.js} +6 -1
  95. package/dist/upgrade-readiness-Q46KTG2J.js.map +1 -0
  96. package/dist/{vercel-RHADE5IP.js → vercel-MWW24ABC.js} +2 -2
  97. package/dist/vite-plugin/index.d.ts +25 -1
  98. package/dist/vite-plugin/index.js +5 -2
  99. package/dist/{vite-plugin-WA3G45YY.js → vite-plugin-4WZ3C2AC.js} +7 -6
  100. package/package.json +4 -2
  101. package/dist/build-IQQYCA3B.js.map +0 -1
  102. package/dist/chunk-FRBYJANT.js.map +0 -1
  103. package/dist/chunk-GQSTRXXB.js.map +0 -1
  104. package/dist/chunk-JBC7PFV4.js.map +0 -1
  105. package/dist/chunk-JZ5WEG3S.js.map +0 -1
  106. package/dist/chunk-OEB3OIYP.js.map +0 -1
  107. package/dist/chunk-OK2PJOLK.js.map +0 -1
  108. package/dist/chunk-WQCPKA2L.js.map +0 -1
  109. package/dist/chunk-Y5KE6YFP.js.map +0 -1
  110. package/dist/chunk-ZK5JCE5J.js.map +0 -1
  111. package/dist/dev-VN6WS3CM.js.map +0 -1
  112. package/dist/dist-Q5VBFWVL.js.map +0 -1
  113. package/dist/generate-SIO4JSKJ.js.map +0 -1
  114. package/dist/registry-BB3UYAOG.js +0 -25
  115. package/dist/start-ZGWW5MOL.js.map +0 -1
  116. package/dist/upgrade-readiness-OHL36FQL.js.map +0 -1
  117. /package/dist/{aws-lambda-PONVF3UX.js.map → aws-lambda-XYCGZH3I.js.map} +0 -0
  118. /package/dist/{bun-DITMZMKL.js.map → bun-K73TQEWC.js.map} +0 -0
  119. /package/dist/{chunk-S3JBIFKS.js.map → chunk-MG7H3LAW.js.map} +0 -0
  120. /package/dist/{cloudflare-RBANU3SE.js.map → cloudflare-LCAOTRYZ.js.map} +0 -0
  121. /package/dist/{deno-deploy-J7LI6HNL.js.map → deno-deploy-ZN4RE5HF.js.map} +0 -0
  122. /package/dist/{dispatcher-IK3FVMX5.js.map → dispatcher-AQJGI3HU.js.map} +0 -0
  123. /package/dist/{info-B3UOXFUF.js.map → info-VM7EK4JC.js.map} +0 -0
  124. /package/dist/{netlify-IFY6ZGFV.js.map → netlify-5VQ22Z2P.js.map} +0 -0
  125. /package/dist/{node-KWZI3CKV.js.map → node-3APTLGWB.js.map} +0 -0
  126. /package/dist/{registry-BB3UYAOG.js.map → registry-5QFTLOL2.js.map} +0 -0
  127. /package/dist/{schema-MVB2FVK6.js.map → schema-JAKF23GR.js.map} +0 -0
  128. /package/dist/{static-BH6JQNM2.js.map → static-TZBVBDTB.js.map} +0 -0
  129. /package/dist/{vercel-RHADE5IP.js.map → vercel-MWW24ABC.js.map} +0 -0
  130. /package/dist/{vite-plugin-WA3G45YY.js.map → vite-plugin-4WZ3C2AC.js.map} +0 -0
@@ -13,16 +13,10 @@ import {
13
13
  resolveTransformer,
14
14
  safeAudit,
15
15
  sendError
16
- } from "./chunk-WQCPKA2L.js";
17
- import {
18
- matchRoute,
19
- scanServerActions,
20
- scanServerRoutes,
21
- scanWebSocketRoutes
22
- } from "./chunk-GQSTRXXB.js";
16
+ } from "./chunk-C27AZN46.js";
23
17
  import {
24
18
  loadConfig
25
- } from "./chunk-S3JBIFKS.js";
19
+ } from "./chunk-MG7H3LAW.js";
26
20
  import {
27
21
  broadcastToDevtools
28
22
  } from "./chunk-5ODOE6EF.js";
@@ -33,6 +27,14 @@ import {
33
27
  import {
34
28
  buildServicesProxyConfig
35
29
  } from "./chunk-WZ7CPVQB.js";
30
+ import {
31
+ matchRoute,
32
+ scanServerRoutes,
33
+ scanWebSocketRoutes
34
+ } from "./chunk-QLGES2HC.js";
35
+ import {
36
+ scanServerActions
37
+ } from "./chunk-MOT42NAH.js";
36
38
 
37
39
  // src/vite-plugin/index.ts
38
40
  import { existsSync as existsSync5 } from "fs";
@@ -468,6 +470,54 @@ function generateRouteManifest(tree) {
468
470
  return lines.join("\n");
469
471
  }
470
472
 
473
+ // src/server/security/csrf-readiness-store.ts
474
+ var CsrfReadinessStore = class _CsrfReadinessStore {
475
+ static MAX_ENTRIES = 1e3;
476
+ entries = /* @__PURE__ */ new Map();
477
+ keyFor(event) {
478
+ return `${event.method}\0${event.path}\0${event.reason}`;
479
+ }
480
+ record(event) {
481
+ const key = this.keyFor(event);
482
+ const now = (/* @__PURE__ */ new Date()).toISOString();
483
+ const existing = this.entries.get(key);
484
+ if (existing) {
485
+ existing.count++;
486
+ existing.lastSeen = now;
487
+ return;
488
+ }
489
+ if (this.entries.size >= _CsrfReadinessStore.MAX_ENTRIES) {
490
+ const firstKey = this.entries.keys().next().value;
491
+ if (firstKey !== void 0) this.entries.delete(firstKey);
492
+ }
493
+ this.entries.set(key, { count: 1, firstSeen: now, lastSeen: now });
494
+ }
495
+ summary() {
496
+ let total = 0;
497
+ const routes = [];
498
+ for (const [key, entry] of this.entries) {
499
+ const [method, path, reason] = key.split("\0");
500
+ routes.push({
501
+ method,
502
+ path,
503
+ reason,
504
+ count: entry.count,
505
+ firstSeen: entry.firstSeen,
506
+ lastSeen: entry.lastSeen
507
+ });
508
+ total += entry.count;
509
+ }
510
+ return {
511
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
512
+ totalEvents: total,
513
+ routes
514
+ };
515
+ }
516
+ reset() {
517
+ this.entries.clear();
518
+ }
519
+ };
520
+
471
521
  // src/vite-plugin/action-middleware.ts
472
522
  import { randomUUID } from "crypto";
473
523
  var PREFIX = "/api/__actions/";
@@ -536,13 +586,17 @@ function createActionMiddleware(vite, serverDir, options) {
536
586
  csrfMode,
537
587
  disallowed
538
588
  );
539
- logRequest({
540
- method: req.method ?? "POST",
541
- url,
542
- status: res.statusCode,
543
- duration: Date.now() - start,
544
- requestId
545
- });
589
+ logRequest(
590
+ {
591
+ method: req.method ?? "POST",
592
+ url,
593
+ status: res.statusCode,
594
+ duration: Date.now() - start,
595
+ requestId
596
+ },
597
+ void 0,
598
+ req
599
+ );
546
600
  })();
547
601
  };
548
602
  }
@@ -974,6 +1028,35 @@ async function handleBatchInline(req, res, batching, requestId) {
974
1028
  sendError(res, "BATCH_ERROR", message, 400, void 0, requestId);
975
1029
  }
976
1030
  }
1031
+ async function runPluginsBeforeRouteMatch(pluginRunner, reqCtx) {
1032
+ const { req, res, requestId, start, url } = reqCtx;
1033
+ try {
1034
+ const hookResult = await pluginRunner.runOnRequest({
1035
+ request: req,
1036
+ response: res,
1037
+ ctx: {},
1038
+ requestId
1039
+ });
1040
+ if (hookResult.shortCircuited) {
1041
+ logRequest(
1042
+ {
1043
+ method: req.method ?? "GET",
1044
+ url,
1045
+ status: res.statusCode,
1046
+ duration: Date.now() - start,
1047
+ requestId
1048
+ },
1049
+ void 0,
1050
+ req
1051
+ );
1052
+ return true;
1053
+ }
1054
+ } catch (err) {
1055
+ sendError(res, "PLUGIN_ERROR", err.message, 500, void 0, requestId);
1056
+ return true;
1057
+ }
1058
+ return false;
1059
+ }
977
1060
  function createApiMiddleware(vite, serverDir, rateLimitConfigOrOptions) {
978
1061
  const opts = rateLimitConfigOrOptions && "windowMs" in rateLimitConfigOrOptions ? { rateLimitConfig: rateLimitConfigOrOptions } : rateLimitConfigOrOptions ?? {};
979
1062
  const loadModule = createViteLoader(vite);
@@ -991,7 +1074,7 @@ function createApiMiddleware(vite, serverDir, rateLimitConfigOrOptions) {
991
1074
  const csrfReadinessStore = opts.csrfReadinessStore;
992
1075
  const servicesProxyPrefixes = opts.servicesProxyPrefixes ?? [];
993
1076
  return (req, res, next) => {
994
- void (async () => {
1077
+ const handle = async () => {
995
1078
  const url = req.url ?? "";
996
1079
  if (await handleCspReportIfMatch(req, res, url, { auditLogger, onCspViolation })) {
997
1080
  return;
@@ -1015,6 +1098,9 @@ function createApiMiddleware(vite, serverDir, rateLimitConfigOrOptions) {
1015
1098
  if (applyRateLimitOr429(req, res, { rateLimiter, requestId, url, start })) {
1016
1099
  return;
1017
1100
  }
1101
+ if (pluginRunner && await runPluginsBeforeRouteMatch(pluginRunner, { req, res, requestId, start, url })) {
1102
+ return;
1103
+ }
1018
1104
  if (await handleBatchIfMatch(req, res, { url, batching, requestId, start })) {
1019
1105
  return;
1020
1106
  }
@@ -1026,13 +1112,17 @@ function createApiMiddleware(vite, serverDir, rateLimitConfigOrOptions) {
1026
1112
  const suggestion = findSuggestion(urlPath, routePaths);
1027
1113
  const msg = suggestion ? `API route not found: ${urlPath}. Did you mean: ${suggestion}?` : "API route not found";
1028
1114
  sendError(res, "NOT_FOUND", msg, 404, void 0, requestId);
1029
- logRequest({
1030
- method: req.method ?? "GET",
1031
- url,
1032
- status: 404,
1033
- duration: Date.now() - start,
1034
- requestId
1035
- });
1115
+ logRequest(
1116
+ {
1117
+ method: req.method ?? "GET",
1118
+ url,
1119
+ status: 404,
1120
+ duration: Date.now() - start,
1121
+ requestId
1122
+ },
1123
+ void 0,
1124
+ req
1125
+ );
1036
1126
  return;
1037
1127
  }
1038
1128
  const method = (req.method ?? "GET").toUpperCase();
@@ -1050,8 +1140,13 @@ function createApiMiddleware(vite, serverDir, rateLimitConfigOrOptions) {
1050
1140
  csrfMode,
1051
1141
  disallowed
1052
1142
  });
1053
- logRequest({ method, url, status: res.statusCode, duration: Date.now() - start, requestId });
1054
- })();
1143
+ logRequest(
1144
+ { method, url, status: res.statusCode, duration: Date.now() - start, requestId },
1145
+ void 0,
1146
+ req
1147
+ );
1148
+ };
1149
+ void handle();
1055
1150
  };
1056
1151
  }
1057
1152
 
@@ -1077,7 +1172,7 @@ function resolveExportSubpath(pkgRoot, subpath) {
1077
1172
  }
1078
1173
  let target;
1079
1174
  if (typeof exp === "string") target = exp;
1080
- else if (exp && typeof exp === "object") {
1175
+ else if (typeof exp === "object") {
1081
1176
  const e = exp;
1082
1177
  target = e.import ?? e.default;
1083
1178
  }
@@ -1147,7 +1242,9 @@ var DEFAULT_RESOLVED = {
1147
1242
  disallowed: void 0,
1148
1243
  cors: void 0,
1149
1244
  auditLogger: void 0,
1150
- devtoolsEnabled: true
1245
+ devtoolsEnabled: true,
1246
+ openapi: void 0,
1247
+ distDir: ".theo"
1151
1248
  };
1152
1249
  async function resolvePluginConfig(projectRoot) {
1153
1250
  try {
@@ -1176,7 +1273,9 @@ async function resolvePluginConfig(projectRoot) {
1176
1273
  disallowed: userConfig.security?.disallowed,
1177
1274
  cors: userConfig.security?.cors,
1178
1275
  auditLogger,
1179
- devtoolsEnabled: userConfig.devtools !== false
1276
+ devtoolsEnabled: userConfig.devtools !== false,
1277
+ openapi: userConfig.openapi,
1278
+ distDir: userConfig.distDir
1180
1279
  };
1181
1280
  } catch {
1182
1281
  return DEFAULT_RESOLVED;
@@ -1513,9 +1612,7 @@ async function integrateUseTheoUI(cwd, opts) {
1513
1612
  }
1514
1613
  const tailwindPlugins = normalizePluginReturn(tailwindPlugin);
1515
1614
  if (tailwindPlugins === null) {
1516
- console.warn(
1517
- `[theokit] @tailwindcss/vite returned unexpected shape. Skipping auto-config.`
1518
- );
1615
+ console.warn(`[theokit] @tailwindcss/vite returned unexpected shape. Skipping auto-config.`);
1519
1616
  return [];
1520
1617
  }
1521
1618
  const uiPlugins = normalizePluginReturn(uiPlugin);
@@ -1789,7 +1886,42 @@ async function theoPluginAsync(rootOrOptions) {
1789
1886
  })
1790
1887
  );
1791
1888
  }
1792
- return [theoPlugin(rootOrOptions), ...uiPlugins, ...servicesPlugins];
1889
+ const { appTypedClientPlugin } = await import("./app-typed-client-YIBP6JWH.js");
1890
+ const appClientPlugin = appTypedClientPlugin({
1891
+ cwd: projectRoot,
1892
+ serverDir: resolve4(projectRoot, "server"),
1893
+ distDir: resolve4(projectRoot, ".theo")
1894
+ });
1895
+ const { actionsVirtualModule } = await import("./actions-virtual-module-E6PU47GV.js");
1896
+ const actionsPlugin = actionsVirtualModule({
1897
+ serverDir: resolve4(projectRoot, "server"),
1898
+ distDir: resolve4(projectRoot, ".theo")
1899
+ });
1900
+ return [
1901
+ theoPlugin(rootOrOptions),
1902
+ ...uiPlugins,
1903
+ ...servicesPlugins,
1904
+ appClientPlugin,
1905
+ actionsPlugin
1906
+ ];
1907
+ }
1908
+ function buildOptimizeDepsInclude(projectRoot, viteOptimizeDeps) {
1909
+ const include = [];
1910
+ if (existsSync5(resolve4(projectRoot, "node_modules", "@usetheo", "ui"))) {
1911
+ include.push("@usetheo/ui");
1912
+ }
1913
+ if (existsSync5(resolve4(projectRoot, "node_modules", "lucide-react"))) {
1914
+ include.push("lucide-react");
1915
+ }
1916
+ include.push("devalue");
1917
+ if (Array.isArray(viteOptimizeDeps)) {
1918
+ for (const pkg of viteOptimizeDeps) {
1919
+ if (typeof pkg === "string" && pkg.length > 0 && !include.includes(pkg)) {
1920
+ include.push(pkg);
1921
+ }
1922
+ }
1923
+ }
1924
+ return include;
1793
1925
  }
1794
1926
  function theoPlugin(rootOrOptions) {
1795
1927
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
@@ -1808,6 +1940,8 @@ function theoPlugin(rootOrOptions) {
1808
1940
  let cors;
1809
1941
  let auditLogger;
1810
1942
  let devtoolsEnabled = true;
1943
+ let resolvedOpenApi;
1944
+ let resolvedDistDir = ".theo";
1811
1945
  let isDevMode = false;
1812
1946
  let configLoadedOnce = false;
1813
1947
  return {
@@ -1826,6 +1960,8 @@ function theoPlugin(rootOrOptions) {
1826
1960
  cors = resolved.cors;
1827
1961
  auditLogger = resolved.auditLogger;
1828
1962
  devtoolsEnabled = resolved.devtoolsEnabled;
1963
+ resolvedOpenApi = resolved.openapi;
1964
+ resolvedDistDir = resolved.distDir;
1829
1965
  },
1830
1966
  // Vite calls this hook (sync return is fine — no awaits left after
1831
1967
  // the auto-chain moved to theoPluginAsync). The @usetheo/ui +
@@ -1833,13 +1969,7 @@ function theoPlugin(rootOrOptions) {
1833
1969
  // Vite drops plugins returned from a child plugin's config() hook.
1834
1970
  config() {
1835
1971
  const ext = existsSync5(resolve4(theoSrcDir, "index.ts")) ? ".ts" : ".js";
1836
- const optimizeDepsInclude = [];
1837
- if (existsSync5(resolve4(projectRoot, "node_modules", "@usetheo", "ui"))) {
1838
- optimizeDepsInclude.push("@usetheo/ui");
1839
- }
1840
- if (existsSync5(resolve4(projectRoot, "node_modules", "lucide-react"))) {
1841
- optimizeDepsInclude.push("lucide-react");
1842
- }
1972
+ const optimizeDepsInclude = buildOptimizeDepsInclude(projectRoot, options.viteOptimizeDeps);
1843
1973
  const warmupClientFiles = [];
1844
1974
  for (const candidate of ["app/layout.tsx", "app/page.tsx", "app/page.jsx"]) {
1845
1975
  const full = resolve4(projectRoot, candidate);
@@ -1848,7 +1978,10 @@ function theoPlugin(rootOrOptions) {
1848
1978
  const servicesProxy = options.services && Object.keys(options.services).length > 0 ? buildServicesProxyConfig(options.services) : void 0;
1849
1979
  return {
1850
1980
  envPrefix: "THEO_PUBLIC_",
1851
- optimizeDeps: optimizeDepsInclude.length > 0 ? { include: optimizeDepsInclude } : void 0,
1981
+ optimizeDeps: {
1982
+ ...optimizeDepsInclude.length > 0 ? { include: optimizeDepsInclude } : {},
1983
+ force: true
1984
+ },
1852
1985
  server: {
1853
1986
  ...warmupClientFiles.length > 0 ? { warmup: { clientFiles: warmupClientFiles } } : {},
1854
1987
  ...servicesProxy !== void 0 ? { proxy: servicesProxy } : {},
@@ -1963,7 +2096,7 @@ function theoPlugin(rootOrOptions) {
1963
2096
  ].join("\n");
1964
2097
  }
1965
2098
  },
1966
- configureServer(server) {
2099
+ async configureServer(server) {
1967
2100
  isDevMode = true;
1968
2101
  globalThis.__theoViteHotServer = server;
1969
2102
  server.ws.on("theo:devtools:request-manifest", () => {
@@ -1978,6 +2111,7 @@ function theoPlugin(rootOrOptions) {
1978
2111
  createActionMiddleware(server, serverDir, { pluginRunner, csrfMode, disallowed })
1979
2112
  );
1980
2113
  const servicesProxyPrefixes = options.services && Object.keys(options.services).length > 0 ? Object.values(options.services).map((s) => s.proxy) : [];
2114
+ const csrfReadinessStore = options.csrfReadinessStore ?? new CsrfReadinessStore();
1981
2115
  server.middlewares.use(
1982
2116
  createApiMiddleware(server, serverDir, {
1983
2117
  rateLimitConfig: options.rateLimit,
@@ -1989,7 +2123,8 @@ function theoPlugin(rootOrOptions) {
1989
2123
  disallowed,
1990
2124
  cors,
1991
2125
  auditLogger,
1992
- servicesProxyPrefixes
2126
+ servicesProxyPrefixes,
2127
+ csrfReadinessStore
1993
2128
  })
1994
2129
  );
1995
2130
  const configPath = resolve4(projectRoot, "theo.config.ts");
@@ -2018,6 +2153,29 @@ function theoPlugin(rootOrOptions) {
2018
2153
  }
2019
2154
  server.watcher.on("add", handleRouteChange);
2020
2155
  server.watcher.on("unlink", handleRouteChange);
2156
+ if (resolvedOpenApi !== void 0) {
2157
+ const openApiCfg = resolvedOpenApi;
2158
+ const { reEmitOpenApi } = await import("./dev-emit-I3CKOHML.js");
2159
+ const openApiServerDir = resolve4(projectRoot, "server");
2160
+ const openApiDistDir = resolve4(projectRoot, resolvedDistDir);
2161
+ const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
2162
+ void reEmitOpenApi(openApiServerDir, openApiDistDir, openApiCfg);
2163
+ server.watcher.on("change", (file) => {
2164
+ if (isRouteFileForOpenApi(file)) {
2165
+ void reEmitOpenApi(openApiServerDir, openApiDistDir, openApiCfg);
2166
+ }
2167
+ });
2168
+ server.watcher.on("add", (file) => {
2169
+ if (isRouteFileForOpenApi(file)) {
2170
+ void reEmitOpenApi(openApiServerDir, openApiDistDir, openApiCfg);
2171
+ }
2172
+ });
2173
+ server.watcher.on("unlink", (file) => {
2174
+ if (isRouteFileForOpenApi(file)) {
2175
+ void reEmitOpenApi(openApiServerDir, openApiDistDir, openApiCfg);
2176
+ }
2177
+ });
2178
+ }
2021
2179
  setupWsUpgrade(server, projectRoot);
2022
2180
  server.httpServer?.once("close", () => {
2023
2181
  ;
@@ -2035,4 +2193,4 @@ export {
2035
2193
  theoPluginAsync,
2036
2194
  theoPlugin
2037
2195
  };
2038
- //# sourceMappingURL=chunk-ZK5JCE5J.js.map
2196
+ //# sourceMappingURL=chunk-EXJWO2HB.js.map