wcz-layout 10.2.1 → 11.0.0

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 (122) hide show
  1. package/dist/ChatLayout-B0MBrI-Y.mjs +2394 -0
  2. package/dist/ChatLayout-B0MBrI-Y.mjs.map +1 -0
  3. package/dist/{Employee-C8xIlBxY.d.mts → ExtractFile-BQUXpuBS.d.mts} +44 -3
  4. package/dist/FileMeta-B5VU-eCi.d.mts +55 -0
  5. package/dist/FileMeta-BexXC_45.mjs +35 -0
  6. package/dist/FileMeta-BexXC_45.mjs.map +1 -0
  7. package/dist/QueryClientParam-BG9Q_9XU.d.mts +6 -0
  8. package/dist/Translate-Ad784Dps.d.mts +24 -0
  9. package/dist/{Approval-D1TfISUL.mjs → Translate-C43AmXYW.mjs} +44 -36
  10. package/dist/Translate-C43AmXYW.mjs.map +1 -0
  11. package/dist/User-CvLutatT.d.mts +10 -0
  12. package/dist/ai.d.mts +31 -4
  13. package/dist/ai.mjs +154 -10
  14. package/dist/ai.mjs.map +1 -1
  15. package/dist/auth.d.mts +7 -14
  16. package/dist/auth.mjs +15 -38
  17. package/dist/auth.mjs.map +1 -1
  18. package/dist/authMiddleware-ANa9Tlmp.mjs +45 -0
  19. package/dist/authMiddleware-ANa9Tlmp.mjs.map +1 -0
  20. package/dist/{ChatLayout-BmLySLXy.d.mts → components-2HKj8GpC.d.mts} +219 -255
  21. package/dist/components.d.mts +2 -126
  22. package/dist/components.mjs +876 -916
  23. package/dist/components.mjs.map +1 -1
  24. package/dist/data/client.d.mts +313 -55
  25. package/dist/data/client.mjs +10 -5
  26. package/dist/data/client.mjs.map +1 -1
  27. package/dist/data/server.d.mts +19 -3
  28. package/dist/data/server.mjs +3 -5
  29. package/dist/data/server.mjs.map +1 -1
  30. package/dist/env-C4WLVJMm.mjs +32 -0
  31. package/dist/env-C4WLVJMm.mjs.map +1 -0
  32. package/dist/file-DBqTibcr.mjs +176 -0
  33. package/dist/file-DBqTibcr.mjs.map +1 -0
  34. package/dist/file-hecCQszp.mjs +114 -0
  35. package/dist/file-hecCQszp.mjs.map +1 -0
  36. package/dist/generatedChart-k7NEdi5Z.mjs.map +1 -1
  37. package/dist/hooks.d.mts +13 -93
  38. package/dist/hooks.mjs +353 -1059
  39. package/dist/hooks.mjs.map +1 -1
  40. package/dist/i18n-ZRiIIdpb.mjs +563 -0
  41. package/dist/i18n-ZRiIIdpb.mjs.map +1 -0
  42. package/dist/index.d.mts +3 -35
  43. package/dist/index.mjs +630 -680
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/layout-DeTB6Ai1.mjs +224 -0
  46. package/dist/layout-DeTB6Ai1.mjs.map +1 -0
  47. package/dist/middleware.d.mts +1 -1
  48. package/dist/middleware.mjs +2 -46
  49. package/dist/middleware.mjs.map +1 -1
  50. package/dist/models.d.mts +35 -43
  51. package/dist/models.mjs +4 -6
  52. package/dist/models.mjs.map +1 -1
  53. package/dist/oidc--D2ox365.mjs +97 -0
  54. package/dist/oidc--D2ox365.mjs.map +1 -0
  55. package/dist/peoplesoft-DhwB8jrM.d.mts +204 -0
  56. package/dist/tokens-C4djIAhl.mjs +97 -0
  57. package/dist/tokens-C4djIAhl.mjs.map +1 -0
  58. package/dist/useDialogs-QER-2rVG.mjs +297 -0
  59. package/dist/useDialogs-QER-2rVG.mjs.map +1 -0
  60. package/dist/user-DQx1BanQ.mjs +120 -0
  61. package/dist/user-DQx1BanQ.mjs.map +1 -0
  62. package/dist/{utils-CNYCSgip.d.mts → utils-BnyAEKW7.d.mts} +7 -9
  63. package/dist/utils-H4BskGF8.mjs +132 -0
  64. package/dist/utils-H4BskGF8.mjs.map +1 -0
  65. package/dist/utils.d.mts +21 -4
  66. package/dist/utils.mjs +5 -4
  67. package/dist/vite.mjs +98 -32
  68. package/dist/vite.mjs.map +1 -1
  69. package/package.json +23 -29
  70. package/skills/ai/SKILL.md +105 -75
  71. package/skills/general/SKILL.md +15 -8
  72. package/skills/general/references/auth.md +15 -17
  73. package/skills/general/references/languages.md +56 -0
  74. package/skills/migrations/versions/migrate-v10-to-v11.md +98 -22
  75. package/skills/migrations/versions/migrate-v9-to-v10.md +22 -22
  76. package/skills/services/SKILL.md +41 -7
  77. package/skills/services/docs/email.md +2 -2
  78. package/skills/services/docs/file.md +100 -85
  79. package/skills/services/docs/layout.md +129 -0
  80. package/skills/start/steps/02-project-name-setup.md +1 -1
  81. package/skills/start/steps/03-apm-setup.md +8 -1
  82. package/skills/start/steps/06-entra-setup.md +1 -1
  83. package/skills/start/steps/08-generate-favicon.md +1 -1
  84. package/skills/table/SKILL.md +18 -5
  85. package/src/lib/locales/cs.json +120 -0
  86. package/src/lib/locales/en.json +119 -0
  87. package/src/lib/locales/uk.json +121 -0
  88. package/src/lib/locales/zh-TW.json +118 -0
  89. package/dist/Approval-D1TfISUL.mjs.map +0 -1
  90. package/dist/ChatLayout-BpRj5rlH.mjs +0 -1639
  91. package/dist/ChatLayout-BpRj5rlH.mjs.map +0 -1
  92. package/dist/DialogsContext-D23fJjYR.mjs +0 -6
  93. package/dist/DialogsContext-D23fJjYR.mjs.map +0 -1
  94. package/dist/Email-Dz5k0UWE.d.mts +0 -15
  95. package/dist/FileMeta-B39e2FLC.d.mts +0 -17
  96. package/dist/FileMeta-CPBWI_jA.mjs +0 -18
  97. package/dist/FileMeta-CPBWI_jA.mjs.map +0 -1
  98. package/dist/QueryClientParam-CTV1vj76.d.mts +0 -8
  99. package/dist/RouterListItemButton-CF-8w-08.mjs +0 -62
  100. package/dist/RouterListItemButton-CF-8w-08.mjs.map +0 -1
  101. package/dist/User-aJksXItw.d.mts +0 -12
  102. package/dist/approval-B3ZQn9aH.mjs +0 -83
  103. package/dist/approval-B3ZQn9aH.mjs.map +0 -1
  104. package/dist/createApi-BXjkj4fM.mjs +0 -25
  105. package/dist/createApi-BXjkj4fM.mjs.map +0 -1
  106. package/dist/env-BwFl7nWc.mjs +0 -48
  107. package/dist/env-BwFl7nWc.mjs.map +0 -1
  108. package/dist/file-BQ-Bu2g8.mjs +0 -150
  109. package/dist/file-BQ-Bu2g8.mjs.map +0 -1
  110. package/dist/file-DZ0KYhoB.mjs +0 -151
  111. package/dist/file-DZ0KYhoB.mjs.map +0 -1
  112. package/dist/peoplesoft-C-zPdRVj.d.mts +0 -161
  113. package/dist/peoplesoft-CvwdApCK.mjs +0 -125
  114. package/dist/peoplesoft-CvwdApCK.mjs.map +0 -1
  115. package/dist/providers-BfFg_3eo.mjs +0 -56
  116. package/dist/providers-BfFg_3eo.mjs.map +0 -1
  117. package/dist/session-B_jK90RC.mjs +0 -23
  118. package/dist/session-B_jK90RC.mjs.map +0 -1
  119. package/dist/tokens-CkWpu7Qp.mjs +0 -150
  120. package/dist/tokens-CkWpu7Qp.mjs.map +0 -1
  121. package/dist/utils-DJx-7b4M.mjs +0 -244
  122. package/dist/utils-DJx-7b4M.mjs.map +0 -1
@@ -0,0 +1,120 @@
1
+ import { r as serverEnv } from "./env-C4WLVJMm.mjs";
2
+ import { queryOptions } from "@tanstack/react-query";
3
+ import { createServerFn } from "@tanstack/react-start";
4
+ // src/lib/auth/offline.ts
5
+ /**
6
+ * Offline fallback for identity. The refresh token never leaves the sealed
7
+ * httpOnly cookie — what is cached here is only the display snapshot (user
8
+ * claims and avatar) so the UI and offline route permissions can still work
9
+ * while the server is unreachable. Server requests remain independently
10
+ * authorized. At-rest protection is the device's OS login and disk encryption.
11
+ */
12
+ const OFFLINE_USER_KEY = "auth-user";
13
+ const OFFLINE_PHOTO_KEY = "auth-photo";
14
+ /** One shift — matches Intune's default offline grace period. */
15
+ const GRACE_PERIOD = 432e5;
16
+ const recall = (key) => {
17
+ if (typeof localStorage === "undefined") return null;
18
+ try {
19
+ const raw = localStorage.getItem(key);
20
+ if (!raw) return null;
21
+ const { value, savedAt } = JSON.parse(raw);
22
+ if (Date.now() - savedAt > GRACE_PERIOD) {
23
+ localStorage.removeItem(key);
24
+ return null;
25
+ }
26
+ return value;
27
+ } catch {
28
+ localStorage.removeItem(key);
29
+ return null;
30
+ }
31
+ };
32
+ const remember = (key, value) => {
33
+ if (typeof localStorage === "undefined") return;
34
+ try {
35
+ if (value === null || value === void 0) localStorage.removeItem(key);
36
+ else localStorage.setItem(key, JSON.stringify({
37
+ value,
38
+ savedAt: Date.now()
39
+ }));
40
+ } catch {}
41
+ };
42
+ const isOfflineFailure = (error) => typeof navigator !== "undefined" && !navigator.onLine || error instanceof TypeError;
43
+ /**
44
+ * Answers from the server when reachable, remembering the result; when the call
45
+ * has a transport failure, replays the last result instead, for up to
46
+ * {@link GRACE_PERIOD} since it was last confirmed.
47
+ *
48
+ * Cached values are untrusted client state. Server authorization must never
49
+ * depend on them.
50
+ */
51
+ const withOfflineFallback = async (key, fetchFresh) => {
52
+ try {
53
+ const fresh = await fetchFresh();
54
+ remember(key, fresh);
55
+ return fresh;
56
+ } catch (error) {
57
+ if (!isOfflineFailure(error)) throw error;
58
+ return recall(key);
59
+ }
60
+ };
61
+ /** Drops the cached identity. Call on logout, before leaving the page. */
62
+ const clearSessionSnapshot = () => {
63
+ if (typeof localStorage === "undefined") return;
64
+ localStorage.removeItem(OFFLINE_USER_KEY);
65
+ localStorage.removeItem(OFFLINE_PHOTO_KEY);
66
+ localStorage.setItem("auth-logout", String(Date.now()));
67
+ };
68
+ if (typeof window !== "undefined") window.addEventListener("storage", (event) => {
69
+ if (event.key === "auth-logout") location.href = "/auth/logout";
70
+ });
71
+ // src/lib/auth/session.ts
72
+ const getAppSession = async () => {
73
+ const [{ getIronSession }, { getCookie, setCookie }] = await Promise.all([import("iron-session"), import("@tanstack/react-start/server")]);
74
+ return getIronSession({
75
+ read: getCookie,
76
+ write: setCookie
77
+ }, {
78
+ cookieName: "app-session",
79
+ password: serverEnv.SESSION_SECRET,
80
+ chunk: true,
81
+ ttl: 0,
82
+ cookieOptions: {
83
+ secure: process.env.NODE_ENV === "production",
84
+ sameSite: "lax",
85
+ httpOnly: true,
86
+ path: "/",
87
+ maxAge: void 0
88
+ }
89
+ });
90
+ };
91
+ // src/lib/auth/user.ts
92
+ /**
93
+ * Reads the signed-in user from the session cookie, or null. As a server function
94
+ * it runs in-process when called on the server (SSR, middleware) and as an RPC
95
+ * when called from the client — so it doubles as the client `queryFn`.
96
+ */
97
+ const getSessionUser = createServerFn({ method: "GET" }).handler(async () => {
98
+ return (await getAppSession()).user ?? null;
99
+ });
100
+ /**
101
+ * Client-side query for the signed-in user. Shared between `getUser` (route
102
+ * `beforeLoad`) and the always-mounted observer in `LayoutProvider` — the
103
+ * observer is what seeds the offline snapshot on the very first page load
104
+ * (`beforeLoad` does not re-run after SSR hydration) and what makes
105
+ * `refetchOnReconnect` fire once connectivity returns.
106
+ */
107
+ const userQueryOptions = queryOptions({
108
+ queryKey: ["auth", "user"],
109
+ queryFn: () => withOfflineFallback(OFFLINE_USER_KEY, () => getSessionUser()),
110
+ staleTime: Infinity,
111
+ networkMode: "offlineFirst",
112
+ refetchOnReconnect: "always"
113
+ });
114
+ const getUser = ({ queryClient }) => {
115
+ if (import.meta.env.SSR) return getSessionUser();
116
+ return queryClient.ensureQueryData(userQueryOptions);
117
+ };
118
+ export { OFFLINE_PHOTO_KEY as a, getAppSession as i, getUser as n, clearSessionSnapshot as o, userQueryOptions as r, withOfflineFallback as s, getSessionUser as t };
119
+
120
+ //# sourceMappingURL=user-DQx1BanQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-DQx1BanQ.mjs","names":[],"sources":["../src/lib/auth/offline.ts","../src/lib/auth/session.ts","../src/lib/auth/user.ts"],"sourcesContent":["/**\n * Offline fallback for identity. The refresh token never leaves the sealed\n * httpOnly cookie — what is cached here is only the display snapshot (user\n * claims and avatar) so the UI and offline route permissions can still work\n * while the server is unreachable. Server requests remain independently\n * authorized. At-rest protection is the device's OS login and disk encryption.\n */\n\nexport const OFFLINE_USER_KEY = \"auth-user\";\nexport const OFFLINE_PHOTO_KEY = \"auth-photo\";\n\n/** One shift — matches Intune's default offline grace period. */\nconst GRACE_PERIOD = 12 * 60 * 60 * 1000;\n\ntype Cached<T> = { value: T; savedAt: number };\n\nconst recall = <T>(key: string): T | null => {\n if (typeof localStorage === \"undefined\") return null;\n try {\n const raw = localStorage.getItem(key);\n if (!raw) return null;\n const { value, savedAt } = JSON.parse(raw) as Cached<T>;\n if (Date.now() - savedAt > GRACE_PERIOD) {\n localStorage.removeItem(key);\n return null;\n }\n return value;\n } catch {\n localStorage.removeItem(key);\n return null;\n }\n};\n\nconst remember = (key: string, value: unknown): void => {\n if (typeof localStorage === \"undefined\") return;\n try {\n if (value === null || value === undefined) localStorage.removeItem(key);\n else localStorage.setItem(key, JSON.stringify({ value, savedAt: Date.now() }));\n } catch {\n // Storage full or blocked — the offline fallback is best-effort.\n }\n};\n\nconst isOfflineFailure = (error: unknown): boolean =>\n (typeof navigator !== \"undefined\" && !navigator.onLine) || error instanceof TypeError;\n\n/**\n * Answers from the server when reachable, remembering the result; when the call\n * has a transport failure, replays the last result instead, for up to\n * {@link GRACE_PERIOD} since it was last confirmed.\n *\n * Cached values are untrusted client state. Server authorization must never\n * depend on them.\n */\nexport const withOfflineFallback = async <T>(\n key: string,\n fetchFresh: () => Promise<T>,\n): Promise<T | null> => {\n try {\n const fresh = await fetchFresh();\n remember(key, fresh);\n return fresh;\n } catch (error) {\n if (!isOfflineFailure(error)) throw error;\n return recall<T>(key);\n }\n};\n\n/** Drops the cached identity. Call on logout, before leaving the page. */\nexport const clearSessionSnapshot = (): void => {\n if (typeof localStorage === \"undefined\") return;\n localStorage.removeItem(OFFLINE_USER_KEY);\n localStorage.removeItem(OFFLINE_PHOTO_KEY);\n localStorage.setItem(\"auth-logout\", String(Date.now()));\n};\n\nif (typeof window !== \"undefined\")\n window.addEventListener(\"storage\", (event) => {\n if (event.key === \"auth-logout\") location.href = \"/auth/logout\";\n });\n","import type { IronSession } from \"iron-session\";\nimport { serverEnv } from \"~/lib/env\";\nimport type { User } from \"~/models/User\";\n\nexport interface AppSessionData {\n /** The only token persisted; delegated access tokens are minted from it. */\n refreshToken?: string;\n user?: User;\n /** Transient, only between /auth/login and /auth/callback. */\n pkceVerifier?: string;\n state?: string;\n returnTo?: string;\n}\n\nexport type AppSession = IronSession<AppSessionData>;\n\nexport const getAppSession = async (): Promise<AppSession> => {\n // Dynamic import: `@tanstack/react-start/server` is the server entry and drags\n // in the SSR renderer (`react-dom/server`). Keep it out of the client graph —\n // this helper is only ever called server-side, and all callers already await it.\n const [{ getIronSession }, { getCookie, setCookie }] = await Promise.all([\n import(\"iron-session\"),\n import(\"@tanstack/react-start/server\"),\n ]);\n\n return getIronSession<AppSessionData>(\n { read: getCookie, write: setCookie },\n {\n // Not `session`: that name holds the pre-stable `useSession` seal, which\n // iron-session can't read. Users sign in once more after the upgrade.\n cookieName: \"app-session\",\n password: serverEnv.SESSION_SECRET,\n chunk: true,\n // A seal that never expires, like `useSession`: users who keep the browser\n // open stay signed in. Since iron-session 9.1 `maxAge: undefined` no longer\n // implies this; without it seals die after iron's 14-day default.\n ttl: 0,\n cookieOptions: {\n secure: process.env.NODE_ENV === \"production\",\n sameSite: \"lax\",\n httpOnly: true,\n path: \"/\",\n // Explicit `undefined`: a browser-session cookie with no Max-Age. Omitted,\n // iron derives one from `ttl`, about 68 years for `ttl: 0`.\n maxAge: undefined,\n },\n },\n );\n};\n","import { queryOptions } from \"@tanstack/react-query\";\nimport { createServerFn } from \"@tanstack/react-start\";\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\nimport type { User } from \"~/models/User\";\nimport { OFFLINE_USER_KEY, withOfflineFallback } from \"./offline\";\nimport { getAppSession } from \"./session\";\n\n/**\n * Reads the signed-in user from the session cookie, or null. As a server function\n * it runs in-process when called on the server (SSR, middleware) and as an RPC\n * when called from the client — so it doubles as the client `queryFn`.\n */\nexport const getSessionUser = createServerFn({ method: \"GET\" }).handler(\n async (): Promise<User | null> => {\n const session = await getAppSession();\n return session.user ?? null;\n },\n);\n\n/**\n * Client-side query for the signed-in user. Shared between `getUser` (route\n * `beforeLoad`) and the always-mounted observer in `LayoutProvider` — the\n * observer is what seeds the offline snapshot on the very first page load\n * (`beforeLoad` does not re-run after SSR hydration) and what makes\n * `refetchOnReconnect` fire once connectivity returns.\n */\nexport const userQueryOptions = queryOptions({\n queryKey: [\"auth\", \"user\"],\n queryFn: () => withOfflineFallback(OFFLINE_USER_KEY, () => getSessionUser()),\n staleTime: Infinity,\n // Default \"online\" pauses the query (never calling queryFn) once the browser\n // reports no connection — which is exactly when the fallback is needed.\n networkMode: \"offlineFirst\",\n // Back online: re-confirm the session and re-stamp the snapshot's grace period.\n refetchOnReconnect: \"always\",\n});\n\nexport const getUser = ({ queryClient }: QueryClientParam): Promise<User | null> => {\n if (import.meta.env.SSR) return getSessionUser();\n\n return queryClient.ensureQueryData(userQueryOptions);\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,mBAAmB;AAChC,MAAa,oBAAoB;;AAGjC,MAAM,eAAe;AAIrB,MAAM,UAAa,QAA0B;CAC3C,IAAI,OAAO,iBAAiB,aAAa,OAAO;CAChD,IAAI;EACF,MAAM,MAAM,aAAa,QAAQ,GAAG;EACpC,IAAI,CAAC,KAAK,OAAO;EACjB,MAAM,EAAE,OAAO,YAAY,KAAK,MAAM,GAAG;EACzC,IAAI,KAAK,IAAI,IAAI,UAAU,cAAc;GACvC,aAAa,WAAW,GAAG;GAC3B,OAAO;EACT;EACA,OAAO;CACT,QAAQ;EACN,aAAa,WAAW,GAAG;EAC3B,OAAO;CACT;AACF;AAEA,MAAM,YAAY,KAAa,UAAyB;CACtD,IAAI,OAAO,iBAAiB,aAAa;CACzC,IAAI;EACF,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,aAAa,WAAW,GAAG;OACjE,aAAa,QAAQ,KAAK,KAAK,UAAU;GAAE;GAAO,SAAS,KAAK,IAAI;EAAE,CAAC,CAAC;CAC/E,QAAQ,CAER;AACF;AAEA,MAAM,oBAAoB,UACvB,OAAO,cAAc,eAAe,CAAC,UAAU,UAAW,iBAAi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eAAe;CAE/C,OAAO,YAAY,gBAAgB,gBAAgB;AACrD"}
@@ -1,8 +1,8 @@
1
- import { t as QueryClientParam } from "./QueryClientParam-CTV1vj76.mjs";
2
- import { n as User } from "./User-aJksXItw.mjs";
1
+ import { t as QueryClientParam } from "./QueryClientParam-BG9Q_9XU.mjs";
2
+ import { t as User } from "./User-CvLutatT.mjs";
3
3
  import { permissions } from "virtual:wcz-layout";
4
4
  import { ParsedLocation } from "@tanstack/react-router";
5
- import "@tanstack/react-form";
5
+ import { AnyFieldApi } from "@tanstack/react-form";
6
6
  declare const WISTRON_PRIMARY_COLOR = "#00506E";
7
7
  declare const WISTRON_SECONDARY_COLOR = "#64DC00";
8
8
  declare class Platform {
@@ -56,13 +56,11 @@ type GuardArgs = {
56
56
  /**
57
57
  * Route guard for `beforeLoad`. Routes are public by default; add this to close one.
58
58
  *
59
- * - `requireAuth()` — signed in with any provider. The only gate a population
60
- * without permission groups (e.g. AWS users) can pass.
59
+ * - `requireAuth()` — signed in.
61
60
  * - `requireAuth("admin")` — signed in *and* in a group listed under that key.
62
61
  *
63
- * `reloadDocument` is required: `/auth/login` is a component-less server route and
64
- * must be reached with a full-document navigation. It starts the login directly when
65
- * only one provider is registered, otherwise it forwards to the `/login` chooser.
62
+ * `reloadDocument` is required: `/auth/login` is a component-less server route that
63
+ * redirects to Entra, so it must be reached with a full-document navigation.
66
64
  */
67
65
  declare const requireAuth: (permissionKey?: keyof typeof permissions) => ({ location, context }: GuardArgs) => Promise<{
68
66
  user: User;
@@ -70,4 +68,4 @@ declare const requireAuth: (permissionKey?: keyof typeof permissions) => ({ loca
70
68
  type FormOmittedProps = "name" | "value" | "onChange" | "onBlur" | "error" | "helperText" | "renderInput" | "type" | "aria-label";
71
69
  declare const hasPermission: (user: User | null, key: keyof typeof permissions) => boolean;
72
70
  export { hasPermission as a, WISTRON_SECONDARY_COLOR as i, Platform as n, requireAuth as o, WISTRON_PRIMARY_COLOR as r, rootRouteHead as s, FormOmittedProps as t };
73
- //# sourceMappingURL=utils-CNYCSgip.d.mts.map
71
+ //# sourceMappingURL=utils-BnyAEKW7.d.mts.map
@@ -0,0 +1,132 @@
1
+ import { n as getUser } from "./user-DQx1BanQ.mjs";
2
+ import { manifest, permissions } from "virtual:wcz-layout";
3
+ import { redirect } from "@tanstack/react-router";
4
+ // src/lib/utils.ts
5
+ const WISTRON_PRIMARY_COLOR = "#00506E";
6
+ const WISTRON_SECONDARY_COLOR = "#64DC00";
7
+ var Platform = class {
8
+ static get isAndroid() {
9
+ return /android/i.test(this.userAgent);
10
+ }
11
+ static get isIOS() {
12
+ return /iPad|iPhone|iPod/.test(this.userAgent);
13
+ }
14
+ static get isWindows() {
15
+ return /windows/i.test(this.userAgent);
16
+ }
17
+ static get isMacOS() {
18
+ return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);
19
+ }
20
+ static get userAgent() {
21
+ return typeof navigator === "undefined" ? "" : navigator.userAgent;
22
+ }
23
+ };
24
+ const rootRouteHead = (options) => ({
25
+ meta: [
26
+ { charSet: "utf-8" },
27
+ {
28
+ name: "viewport",
29
+ content: "width=device-width, initial-scale=1"
30
+ },
31
+ { title: manifest.name },
32
+ ...manifest.theme_color ? [{
33
+ name: "theme-color",
34
+ content: manifest.theme_color
35
+ }] : [],
36
+ {
37
+ name: "og:type",
38
+ content: "website"
39
+ },
40
+ {
41
+ name: "og:title",
42
+ content: manifest.name
43
+ },
44
+ {
45
+ name: "og:image",
46
+ content: "/favicon-32x32.png"
47
+ }
48
+ ],
49
+ links: [
50
+ {
51
+ rel: "apple-touch-icon",
52
+ sizes: "180x180",
53
+ href: "/apple-touch-icon.png"
54
+ },
55
+ {
56
+ rel: "icon",
57
+ type: "image/png",
58
+ sizes: "32x32",
59
+ href: "/favicon-32x32.png"
60
+ },
61
+ {
62
+ rel: "icon",
63
+ type: "image/png",
64
+ sizes: "16x16",
65
+ href: "/favicon-16x16.png"
66
+ },
67
+ {
68
+ rel: "manifest",
69
+ href: options?.manifest || "/manifest.webmanifest"
70
+ },
71
+ {
72
+ rel: "icon",
73
+ href: "/favicon.ico"
74
+ }
75
+ ]
76
+ });
77
+ /**
78
+ * Route guard for `beforeLoad`. Routes are public by default; add this to close one.
79
+ *
80
+ * - `requireAuth()` — signed in.
81
+ * - `requireAuth("admin")` — signed in *and* in a group listed under that key.
82
+ *
83
+ * `reloadDocument` is required: `/auth/login` is a component-less server route that
84
+ * redirects to Entra, so it must be reached with a full-document navigation.
85
+ */
86
+ const requireAuth = (permissionKey) => {
87
+ return async ({ location, context }) => {
88
+ const user = await getUser({ queryClient: context.queryClient });
89
+ if (!user) throw redirect({
90
+ href: `/auth/login?returnTo=${encodeURIComponent(location.href)}`,
91
+ reloadDocument: true
92
+ });
93
+ if (permissionKey && !hasPermission(user, permissionKey)) throw new Error("You do not have permission to access this page.");
94
+ return { user };
95
+ };
96
+ };
97
+ const NON_PRODUCTION = /(?:^|[.-])(?:dev|qas|uat|test)(?:[.-]|$)/i;
98
+ /** True only for a dev/qas/uat/test domain — localhost and production are not. */
99
+ const isTestEnv = (origin) => NON_PRODUCTION.test((origin ?? "").split(".").slice(1).join("."));
100
+ /** The field's error state and message, shown only once the user has touched it. */
101
+ const getFieldStatus = (field) => {
102
+ const { isTouched, errors } = field.state.meta;
103
+ return {
104
+ error: isTouched && errors.length > 0,
105
+ helperText: isTouched ? errors[0]?.message : void 0
106
+ };
107
+ };
108
+ /**
109
+ * Only same-origin paths are allowed, so `returnTo` cannot become an open
110
+ * redirect. Backslash counts as a separator too: browsers normalize `/\evil`
111
+ * to the protocol-relative `//evil`.
112
+ */
113
+ const sanitizeReturnTo = (value) => value && /^\/(?![/\\])/.test(value) ? value : "/";
114
+ const foldForSearch = (value) => String(value ?? "").toLowerCase().normalize("NFD").replaceAll(/[\u{300}-\u{36F}]/gu, "").normalize("NFC");
115
+ const permissionGroups = new Set(Object.values(permissions).flat());
116
+ /**
117
+ * Maps id/access-token claims to the serializable `User`. Groups are trimmed to
118
+ * those named in `permissions.ts` — an unfiltered group list would blow the
119
+ * cookie.
120
+ */
121
+ const buildUser = (payload) => ({
122
+ name: (payload.name ?? "").split("/")[0],
123
+ email: (payload.preferred_username ?? "").toLowerCase(),
124
+ department: payload.department?.toUpperCase() || "",
125
+ employeeId: payload.employeeId?.toUpperCase() || "",
126
+ companyName: ["WCZ", "WSCZ"].find((c) => c === payload.companyName?.toUpperCase()),
127
+ groups: payload.groups?.filter((group) => permissionGroups.has(group)) ?? []
128
+ });
129
+ const hasPermission = (user, key) => user ? permissions[key].some((group) => user.groups.includes(group)) : false;
130
+ export { foldForSearch as a, isTestEnv as c, sanitizeReturnTo as d, buildUser as i, requireAuth as l, WISTRON_PRIMARY_COLOR as n, getFieldStatus as o, WISTRON_SECONDARY_COLOR as r, hasPermission as s, Platform as t, rootRouteHead as u };
131
+
132
+ //# sourceMappingURL=utils-H4BskGF8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-H4BskGF8.mjs","names":[],"sources":["../src/lib/utils.ts"],"sourcesContent":["import type { AnyFieldApi } from \"@tanstack/react-form\";\nimport { redirect } from \"@tanstack/react-router\";\nimport type { ParsedLocation } from \"@tanstack/react-router\";\nimport { manifest, permissions } from \"virtual:wcz-layout\";\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\nimport type { TokenPayload } from \"~/models/TokenPayload\";\nimport type { User } from \"~/models/User\";\nimport { getUser } from \"./auth/user\";\n\nexport const WISTRON_PRIMARY_COLOR = \"#00506E\";\nexport const WISTRON_SECONDARY_COLOR = \"#64DC00\";\n\nexport class Platform {\n static get isAndroid() {\n return /android/i.test(this.userAgent);\n }\n static get isIOS() {\n return /iPad|iPhone|iPod/.test(this.userAgent);\n }\n static get isWindows() {\n return /windows/i.test(this.userAgent);\n }\n static get isMacOS() {\n return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);\n }\n\n private static get userAgent() {\n return typeof navigator === \"undefined\" ? \"\" : navigator.userAgent;\n }\n}\n\ninterface RootRouteHeadOptions {\n manifest?: string;\n}\n\nexport const rootRouteHead = (options?: RootRouteHeadOptions) => ({\n meta: [\n { charSet: \"utf-8\" },\n { name: \"viewport\", content: \"width=device-width, initial-scale=1\" },\n { title: manifest.name },\n ...(manifest.theme_color ? [{ name: \"theme-color\", content: manifest.theme_color }] : []),\n { name: \"og:type\", content: \"website\" },\n { name: \"og:title\", content: manifest.name },\n { name: \"og:image\", content: \"/favicon-32x32.png\" },\n ],\n links: [\n { rel: \"apple-touch-icon\", sizes: \"180x180\", href: \"/apple-touch-icon.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"32x32\", href: \"/favicon-32x32.png\" },\n { rel: \"icon\", type: \"image/png\", sizes: \"16x16\", href: \"/favicon-16x16.png\" },\n { rel: \"manifest\", href: options?.manifest || \"/manifest.webmanifest\" },\n { rel: \"icon\", href: \"/favicon.ico\" },\n ],\n});\n\ntype GuardArgs = { location: ParsedLocation; context: QueryClientParam };\n\n/**\n * Route guard for `beforeLoad`. Routes are public by default; add this to close one.\n *\n * - `requireAuth()` — signed in.\n * - `requireAuth(\"admin\")` — signed in *and* in a group listed under that key.\n *\n * `reloadDocument` is required: `/auth/login` is a component-less server route that\n * redirects to Entra, so it must be reached with a full-document navigation.\n */\nexport const requireAuth = (permissionKey?: keyof typeof permissions) => {\n return async ({ location, context }: GuardArgs) => {\n const user = await getUser({ queryClient: context.queryClient });\n\n if (!user)\n throw redirect({\n href: `/auth/login?returnTo=${encodeURIComponent(location.href)}`,\n reloadDocument: true,\n });\n\n if (permissionKey && !hasPermission(user, permissionKey))\n throw new Error(\"You do not have permission to access this page.\");\n\n return { user };\n };\n};\n\n/* Internal Utils */\nconst NON_PRODUCTION = /(?:^|[.-])(?:dev|qas|uat|test)(?:[.-]|$)/i;\n\n/** True only for a dev/qas/uat/test domain — localhost and production are not. */\nexport const isTestEnv = (origin: string | undefined) =>\n NON_PRODUCTION.test((origin ?? \"\").split(\".\").slice(1).join(\".\"));\n\nexport type FormOmittedProps =\n | \"name\"\n | \"value\"\n | \"onChange\"\n | \"onBlur\"\n | \"error\"\n | \"helperText\"\n | \"renderInput\"\n | \"type\"\n | \"aria-label\";\n\n/** The field's error state and message, shown only once the user has touched it. */\nexport const getFieldStatus = (field: AnyFieldApi) => {\n const { isTouched, errors } = field.state.meta;\n\n return {\n error: isTouched && errors.length > 0,\n helperText: isTouched ? (errors[0]?.message as string | undefined) : undefined,\n };\n};\n\n/**\n * Only same-origin paths are allowed, so `returnTo` cannot become an open\n * redirect. Backslash counts as a separator too: browsers normalize `/\\evil`\n * to the protocol-relative `//evil`.\n */\nexport const sanitizeReturnTo = (value: string | null | undefined): string =>\n value && /^\\/(?![/\\\\])/.test(value) ? value : \"/\";\n\nexport const foldForSearch = (value: unknown): string =>\n String(value ?? \"\")\n .toLowerCase()\n .normalize(\"NFD\")\n .replaceAll(/[\\u{300}-\\u{36F}]/gu, \"\")\n .normalize(\"NFC\");\n\nconst permissionGroups = new Set<string>(Object.values(permissions).flat());\n\n/**\n * Maps id/access-token claims to the serializable `User`. Groups are trimmed to\n * those named in `permissions.ts` — an unfiltered group list would blow the\n * cookie.\n */\nexport const buildUser = (payload: TokenPayload): User => ({\n name: (payload.name ?? \"\").split(\"/\")[0],\n email: (payload.preferred_username ?? \"\").toLowerCase(),\n department: payload.department?.toUpperCase() || \"\",\n employeeId: payload.employeeId?.toUpperCase() || \"\",\n companyName: ([\"WCZ\", \"WSCZ\"] as const).find((c) => c === payload.companyName?.toUpperCase()),\n groups: payload.groups?.filter((group) => permissionGroups.has(group)) ?? [],\n});\n\nexport const hasPermission = (user: User | null, key: keyof typeof permissions): boolean =>\n user ? permissions[key].some((group) => user.groups.includes(group)) : false;\n"],"mappings":";;;;AASA,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AAEvC,IAAa,WAAb,MAAsB;CACpB,WAAW,YAAY;EACrB,OAAO,WAAW,KAAK,KAAK,SAAS;CACvC;CACA,WAAW,QAAQ;EACjB,OAAO,mBAAmB,KAA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aAAa,WACxB,eAAe,MAAM,UAAU,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;;AAclE,MAAa,kBAAkB,UAAuB;CACpD,MAAM,EAAE,WAAW,WAAW,MAAM,MAAM;CAE1C,OAAO;EACL,OAAO,aAAa,OAAO,SAAS;EACpC,YAAY,YAAa,OAAO,EAAE,EAAE,UAAiC,KAAA;CACvE;AACF;;;;;;AAOA,MAAa,oBAAoB,UAC/B,SAAS,eAAe,KAAK,KAAK,IAAI,QAAQ;AAEhD,MAAa,iBAAiB,UAC5B,OAAO,SAAS,EAAE,CAAC,CAChB,YAAY,CAAC,CACb,UAAU,KAAK,CAAC,CAChB,WAAW,uBAAuB,EAAE,CAAC,CACrC,UAAU,KAAK;AAEpB,MAAM,mBAAmB,IAAI,IAAY,OAAO,OAAO,WAAW,CAAC,CAAC,KAAK,CAAC;;;;;;AAO1E,MAAa,aAAa,aAAiC;CACzD,OAAO,QAAQ,QAAQ,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC;CACtC,QAAQ,QAAQ,sBAAsB,GAAA,CAAI,YAAY;CACtD,YAAY,QAAQ,YAAY,YAAY,KAAK;CACjD,YAAY,QAAQ,YAAY,YAAY,KAAK;CACjD,aAAc,CAAC,OAAO,MAAM,CAAC,CAAW,MAAM,MAAM,MAAM,QAAQ,aAAa,YAAY,CAAC;CAC5F,QAAQ,QAAQ,QAAQ,QAAQ,UAAU,iBAAiB,IAAI,KAAK,CAAC,KAAK,CAAC;AAC7E;AAEA,MAAa,iBAAiB,MAAmB,QAC/C,OAAO,YAAY,IAAI,CAAC,MAAM,UAAU,KAAK,OAAO,SAAS,KAAK,CAAC,IAAI"}
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,22 @@
1
- import { a as hasPermission, n as Platform, o as requireAuth } from "./utils-CNYCSgip.mjs";
2
- import i18next, { t } from "i18next";
3
- import { createEnv } from "@t3-oss/env-core";
1
+ import { a as hasPermission, n as Platform, o as requireAuth } from "./utils-BnyAEKW7.mjs";
2
+ import { env } from "virtual:wcz-layout";
3
+ import { z as z$1 } from "zod";
4
+ import i18next from "i18next";
4
5
  import { uuidv7 } from "uuidv7";
5
- export { Platform, createEnv, hasPermission, i18next, requireAuth, t, uuidv7 };
6
+ type Values<Shape extends z$1.core.$ZodShape> = keyof Shape extends never ? Record<never, never> : z$1.output<z$1.ZodObject<Shape>>;
7
+ /**
8
+ * `server` of `src/env.ts`, validated on the server. Bundling also loads this module in the
9
+ * browser, where reading one throws.
10
+ */
11
+ export declare const serverEnv: Values<typeof env.server>;
12
+ /** `client` of `src/env.ts`, validated on the server and in the browser. */
13
+ export declare const clientEnv: Values<typeof env.client>;
14
+ /**
15
+ * The user's language. On the server it comes from the request: the `i18next` cookie the
16
+ * language menu writes, else `Accept-Language`. In the browser it is the current one.
17
+ */
18
+ export declare const getLanguage: () => string;
19
+ /** `i18next.t` in the user's language: the request's on the server (`getLanguage`). */
20
+ export declare const t: import("i18next").TFunction<["translation", ...never[]], undefined>;
21
+ export { Platform, hasPermission, i18next, requireAuth, uuidv7 };
22
+ //# sourceMappingURL=utils.d.mts.map
package/dist/utils.mjs CHANGED
@@ -1,5 +1,6 @@
1
- import { l as requireAuth, s as hasPermission, t as Platform } from "./utils-DJx-7b4M.mjs";
2
- import i18next, { t } from "i18next";
3
- import { createEnv } from "@t3-oss/env-core";
1
+ import { r as serverEnv, t as clientEnv } from "./env-C4WLVJMm.mjs";
2
+ import { a as t, i as getLanguage } from "./i18n-ZRiIIdpb.mjs";
3
+ import { l as requireAuth, s as hasPermission, t as Platform } from "./utils-H4BskGF8.mjs";
4
+ import i18next from "i18next";
4
5
  import { uuidv7 } from "uuidv7";
5
- export { Platform, createEnv, hasPermission, i18next, requireAuth, t, uuidv7 };
6
+ export { Platform, clientEnv, getLanguage, hasPermission, i18next, requireAuth, serverEnv, t, uuidv7 };
package/dist/vite.mjs CHANGED
@@ -69,22 +69,84 @@ function dayjsLocaleImports(resources) {
69
69
  }
70
70
  }).map((lang) => `import "dayjs/locale/${lang}";`).join("\n");
71
71
  }
72
- function ensurePermissionsFile(permissionsPath, addWatchFile) {
73
- const dir = path.dirname(permissionsPath);
74
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
75
- if (!fs.existsSync(permissionsPath)) fs.writeFileSync(permissionsPath, "import type { Permissions } from \"wcz-layout/models\";\n\nexport const permissions = {\n admin: [\"wcz-developers\"],\n} as const satisfies Permissions;\n");
76
- addWatchFile(permissionsPath);
72
+ async function muiLocaleModule(languages) {
73
+ const sources = Object.entries({
74
+ "@mui/material/locale": await import("@mui/material/locale"),
75
+ "@mui/x-date-pickers/locales": await import("@mui/x-date-pickers/locales")
76
+ });
77
+ const imports = [];
78
+ const locales = {};
79
+ for (const [source, module] of sources) {
80
+ const names = Object.keys(module);
81
+ for (const language of languages) {
82
+ const [base, region = ""] = language.split("-");
83
+ const name = names.find((n) => n === base + region.toUpperCase()) ?? names.find((n) => new RegExp(`^${base}(?:[A-Z]|$)`).test(n));
84
+ if (!name) continue;
85
+ const alias = `mui${imports.length}`;
86
+ imports.push(`import { ${name} as ${alias} } from "${source}";`);
87
+ (locales[language] ??= []).push(alias);
88
+ }
89
+ }
90
+ const entries = Object.entries(locales).map(([language, aliases]) => `${JSON.stringify(language)}: [${aliases.join(", ")}]`);
91
+ return `${imports.join("\n")}\nexport const muiLocales = { ${entries.join(", ")} };`;
77
92
  }
78
- function ensureScopesFile(scopesPath, addWatchFile) {
79
- const dir = path.dirname(scopesPath);
80
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
81
- if (!fs.existsSync(scopesPath)) fs.writeFileSync(scopesPath, "import type { Scopes } from \"wcz-layout/models\";\n\nexport const scopes = {\n graph: \"User.Read\",\n api: \"api://wistron.com/app-scope/access_as_user\",\n} as const satisfies Scopes;\n");
82
- addWatchFile(scopesPath);
93
+ function writeLocaleTypes(typesPath, languages) {
94
+ const others = languages.filter((language) => language !== "en");
95
+ const id = (language) => `locale_${language.replace(/\W/g, "_")}`;
96
+ const lines = [
97
+ "// Generated by wcz-layout from src/lib/locales/*.json. Do not edit.",
98
+ ...["en", ...others].map((l) => `import type ${id(l)} from "../lib/locales/${l}.json";`),
99
+ "",
100
+ "declare module \"i18next\" {",
101
+ " interface CustomTypeOptions {",
102
+ " resources: { translation: typeof locale_en };",
103
+ " }",
104
+ "}"
105
+ ];
106
+ if (others.length) lines.push("", "type Plural = \"zero\" | \"one\" | \"two\" | \"few\" | \"many\" | \"other\";", "type Keys<T, Prefix extends string = \"\"> = {", " [K in keyof T & string]: T[K] extends string", " ? `${Prefix}${K extends `${infer Key}_${Plural}` ? Key : K}`", " : Keys<T[K], `${Prefix}${K}.`>;", "}[keyof T & string];", "type Missing<Locale> = Exclude<Keys<typeof locale_en>, Keys<Locale>>;", "type Complete<MissingKeys extends never> = MissingKeys;", "", "export type Locales = {", ...others.map((l) => ` ${/^\w+$/.test(l) ? l : JSON.stringify(l)}: Complete<Missing<typeof ${id(l)}>>;`), "};");
107
+ const content = `${lines.join("\n")}\n`;
108
+ if (fs.existsSync(typesPath) && fs.readFileSync(typesPath, "utf-8") === content) return;
109
+ fs.mkdirSync(path.dirname(typesPath), { recursive: true });
110
+ fs.writeFileSync(typesPath, content);
111
+ }
112
+ const permissionsFile = `import type { Permissions } from "wcz-layout/models";
113
+
114
+ export const permissions = {
115
+ admin: ["wcz-developers"],
116
+ } as const satisfies Permissions;
117
+ `;
118
+ const scopesFile = `import type { Scopes } from "wcz-layout/models";
119
+
120
+ export const scopes = {
121
+ graph: "User.Read",
122
+ api: "api://wistron.com/app-scope/access_as_user",
123
+ } as const satisfies Scopes;
124
+ `;
125
+ const envFile = `import type { Env } from "wcz-layout/models";
126
+ import { z } from "zod";
127
+
128
+ export const env = {
129
+ server: {
130
+ ENTRA_CLIENT_ID: z.string(),
131
+ ENTRA_TENANT_ID: z.string(),
132
+ ENTRA_CLIENT_SECRET: z.string(),
133
+ SESSION_SECRET: z.string().min(32),
134
+ },
135
+ client: {},
136
+ } satisfies Env;
137
+ `;
138
+ function ensureFile(filePath, content, addWatchFile) {
139
+ if (!fs.existsSync(filePath)) {
140
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
141
+ fs.writeFileSync(filePath, content);
142
+ }
143
+ addWatchFile(filePath);
144
+ return filePath.split(path.sep).join(path.posix.sep);
83
145
  }
84
- function loadManifest(manifestPath, addWatchFile) {
85
- addWatchFile(manifestPath);
146
+ function loadNamedJson(filePath, addWatchFile) {
147
+ addWatchFile(filePath);
86
148
  try {
87
- return JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
149
+ return JSON.parse(fs.readFileSync(filePath, "utf-8"));
88
150
  } catch {
89
151
  return { name: "" };
90
152
  }
@@ -104,8 +166,10 @@ function viteWczLayout() {
104
166
  let localesPath;
105
167
  let permissionsPath;
106
168
  let scopesPath;
107
- let envPath;
108
169
  let manifestPath;
170
+ let packagePath;
171
+ let localeTypesPath;
172
+ let envPath;
109
173
  return {
110
174
  name: "vite:wcz-layout",
111
175
  enforce: "pre",
@@ -113,8 +177,10 @@ function viteWczLayout() {
113
177
  localesPath = path.resolve(resolvedConfig.root, "src/lib/locales");
114
178
  permissionsPath = path.resolve(resolvedConfig.root, "src/lib/auth/permissions.ts");
115
179
  scopesPath = path.resolve(resolvedConfig.root, "src/lib/auth/scopes.ts");
180
+ manifestPath = path.resolve(resolvedConfig.root, "public/manifest.webmanifest");
181
+ packagePath = path.resolve(resolvedConfig.root, "package.json");
182
+ localeTypesPath = path.resolve(resolvedConfig.root, "src/types/i18next.gen.ts");
116
183
  envPath = path.resolve(resolvedConfig.root, "src/env.ts");
117
- manifestPath = path.resolve(resolvedConfig.root, "public/manifest.json");
118
184
  },
119
185
  async config(_, { command }) {
120
186
  await loadVaultSecrets(command);
@@ -122,10 +188,10 @@ function viteWczLayout() {
122
188
  },
123
189
  configureServer(server) {
124
190
  const refresh = (filePath) => {
125
- if (filePath.includes(localesPath) || filePath === permissionsPath || filePath === scopesPath || filePath === envPath || filePath === manifestPath) {
126
- const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);
127
- if (module) server.moduleGraph.invalidateModule(module);
128
- server.ws.send({
191
+ if (filePath.includes(localesPath) || filePath === permissionsPath || filePath === scopesPath || filePath === manifestPath || filePath === envPath) for (const environment of Object.values(server.environments)) {
192
+ const module = environment.moduleGraph.getModuleById(resolvedVirtualModuleId);
193
+ if (module) environment.moduleGraph.invalidateModule(module);
194
+ environment.hot.send({
129
195
  type: "full-reload",
130
196
  path: "*"
131
197
  });
@@ -135,8 +201,8 @@ function viteWczLayout() {
135
201
  localesPath,
136
202
  permissionsPath,
137
203
  scopesPath,
138
- envPath,
139
- manifestPath
204
+ manifestPath,
205
+ envPath
140
206
  ]);
141
207
  server.watcher.on("add", refresh);
142
208
  server.watcher.on("change", refresh);
@@ -146,22 +212,22 @@ function viteWczLayout() {
146
212
  if (id === virtualModuleId) return resolvedVirtualModuleId;
147
213
  return null;
148
214
  },
149
- load(id) {
215
+ async load(id) {
150
216
  if (id !== resolvedVirtualModuleId) return null;
151
- const resources = loadLocaleResources(localesPath, this.addWatchFile.bind(this));
152
- ensurePermissionsFile(permissionsPath, this.addWatchFile.bind(this));
153
- ensureScopesFile(scopesPath, this.addWatchFile.bind(this));
154
- const manifest = loadManifest(manifestPath, this.addWatchFile.bind(this));
155
- const normalizedPermissionsPath = permissionsPath.split(path.sep).join(path.posix.sep);
156
- const normalizedScopesPath = scopesPath.split(path.sep).join(path.posix.sep);
157
- const normalizedEnvPath = envPath.split(path.sep).join(path.posix.sep);
217
+ const addWatchFile = this.addWatchFile.bind(this);
218
+ const resources = loadLocaleResources(localesPath, addWatchFile);
219
+ writeLocaleTypes(localeTypesPath, Object.keys(resources));
220
+ const manifest = loadNamedJson(manifestPath, addWatchFile);
221
+ const { name: appName } = loadNamedJson(packagePath, addWatchFile);
158
222
  return `
159
223
  ${dayjsLocaleImports(resources)}
224
+ ${await muiLocaleModule(Object.keys(resources))}
160
225
  export const resources = ${JSON.stringify(resources)};
161
226
  export const manifest = ${JSON.stringify(manifest)};
162
- export { permissions } from "${normalizedPermissionsPath}";
163
- export { scopes } from "${normalizedScopesPath}";
164
- export { serverEnv } from "${normalizedEnvPath}";
227
+ export const appName = ${JSON.stringify(appName)};
228
+ export { permissions } from "${ensureFile(permissionsPath, permissionsFile, addWatchFile)}";
229
+ export { scopes } from "${ensureFile(scopesPath, scopesFile, addWatchFile)}";
230
+ export { env } from "${ensureFile(envPath, envFile, addWatchFile)}";
165
231
  `;
166
232
  }
167
233
  };
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":[],"sources":["../src/models/VaultConfig.ts","../src/lib/vite-plugin.ts"],"sourcesContent":["import z from \"zod\";\n\nexport const VaultConfigSchema = z.object({\n VAULT_ADDRESS: z.url(),\n VAULT_USERNAME: z.string().min(1),\n VAULT_PASSWORD: z.string().min(1),\n VAULT_SECRET_PATH: z.string().min(1),\n VAULT_MOUNT_POINT: z.string().default(\"release\"),\n});\n\nexport type VaultConfig = z.infer<typeof VaultConfigSchema>;\n","import fs from \"node:fs\";\nimport https from \"node:https\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport axios from \"axios\";\nimport { loadEnv } from \"vite\";\nimport { VaultConfigSchema } from \"../models/VaultConfig\";\nimport type { Resource } from \"i18next\";\nimport type { Plugin } from \"vite\";\n\nasync function fetchVaultSecrets(env: Record<string, string>): Promise<Record<string, string>> {\n const config = VaultConfigSchema.parse(env);\n const { VAULT_ADDRESS, VAULT_USERNAME, VAULT_PASSWORD, VAULT_SECRET_PATH, VAULT_MOUNT_POINT } =\n config;\n\n const client = axios.create({\n baseURL: VAULT_ADDRESS,\n httpsAgent: new https.Agent({ rejectUnauthorized: false }),\n });\n\n const { data: loginData } = await client.post(`/v1/auth/userpass/login/${VAULT_USERNAME}`, {\n password: VAULT_PASSWORD,\n });\n\n const { data: secretData } = await client.get(\n `/v1/${VAULT_MOUNT_POINT}/data/${VAULT_SECRET_PATH}`,\n {\n headers: { \"X-Vault-Token\": loginData.auth.client_token },\n },\n );\n\n const secrets = secretData?.data?.data;\n if (!secrets) throw new Error(\"No secrets found\");\n\n return Object.fromEntries(\n Object.entries(secrets).map(([key, value]) => [\n key,\n typeof value === \"string\" ? value : JSON.stringify(value),\n ]),\n );\n}\n\nasync function loadVaultSecrets(command: string): Promise<void> {\n if (command !== \"serve\") return;\n\n const env = loadEnv(\"development\", process.cwd(), \"\");\n if (!env.VAULT_ADDRESS) return;\n\n try {\n const secrets = await fetchVaultSecrets(env);\n Object.entries(secrets).forEach(([key, value]) => {\n process.env[key] = env[key]?.trim() ? env[key] : value;\n });\n } catch (e) {\n console.warn(\"[vite:wcz-layout] Vault failed:\", e instanceof Error ? e.message : e);\n }\n}\n\nfunction loadLocaleResources(localesPath: string, addWatchFile: (path: string) => void): Resource {\n if (!fs.existsSync(localesPath)) fs.mkdirSync(localesPath, { recursive: true });\n\n const enPath = path.join(localesPath, \"en.json\");\n if (!fs.existsSync(enPath)) fs.writeFileSync(enPath, JSON.stringify({}));\n\n const files = fs.readdirSync(localesPath);\n const resources: Resource = {};\n\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\n const lang = path.basename(file, \".json\");\n const filePath = path.join(localesPath, file);\n try {\n resources[lang] = { translation: JSON.parse(fs.readFileSync(filePath, \"utf-8\")) };\n } catch {\n resources[lang] = { translation: {} };\n }\n addWatchFile(filePath);\n }\n\n return resources;\n}\n\nconst require = createRequire(import.meta.url);\n\nfunction dayjsLocaleImports(resources: Resource): string {\n return Object.keys(resources)\n .map((lang) => lang.toLowerCase())\n .filter((lang) => {\n try {\n require.resolve(`dayjs/locale/${lang}.js`);\n return true;\n } catch {\n return false;\n }\n })\n .map((lang) => `import \"dayjs/locale/${lang}\";`)\n .join(\"\\n\");\n}\n\nfunction ensurePermissionsFile(\n permissionsPath: string,\n addWatchFile: (path: string) => void,\n): void {\n const dir = path.dirname(permissionsPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(permissionsPath)) {\n fs.writeFileSync(\n permissionsPath,\n 'import type { Permissions } from \"wcz-layout/models\";\\n\\n' +\n \"export const permissions = {\\n\" +\n ' admin: [\"wcz-developers\"],\\n' +\n \"} as const satisfies Permissions;\\n\",\n );\n }\n addWatchFile(permissionsPath);\n}\n\nfunction ensureScopesFile(scopesPath: string, addWatchFile: (path: string) => void): void {\n const dir = path.dirname(scopesPath);\n if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n if (!fs.existsSync(scopesPath)) {\n fs.writeFileSync(\n scopesPath,\n 'import type { Scopes } from \"wcz-layout/models\";\\n\\n' +\n \"export const scopes = {\\n\" +\n ' graph: \"User.Read\",\\n' +\n ' api: \"api://wistron.com/app-scope/access_as_user\",\\n' +\n \"} as const satisfies Scopes;\\n\",\n );\n }\n addWatchFile(scopesPath);\n}\n\nfunction loadManifest(\n manifestPath: string,\n addWatchFile: (path: string) => void,\n): { name: string } & Record<string, unknown> {\n addWatchFile(manifestPath);\n try {\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\n } catch {\n return { name: \"\" };\n }\n}\n\n// TanStack Start excludes wcz-layout from pre-bundling, and Vite doesn't pre-bundle bare imports\n// of excluded packages either, so CJS they pull in (url-parse, prop-types, ...) breaks in the\n// browser. Pre-bundle every bare import of the published chunks; empty when run from source.\nfunction wczLayoutImports(): string[] {\n const dist = path.dirname(fileURLToPath(import.meta.url));\n const specifiers = new Set<string>();\n for (const file of fs.readdirSync(dist)) {\n if (!file.endsWith(\".mjs\") || file === \"vite.mjs\") continue;\n for (const [, id] of fs\n .readFileSync(path.join(dist, file), \"utf-8\")\n .matchAll(/from \"([^\"]+)\"/g))\n specifiers.add(id);\n }\n return [...specifiers]\n .filter((id) => /^[@a-z]/.test(id) && !id.includes(\":\")) // skips relative, node:, virtual:\n .filter((id) => !/^@tanstack\\/react-(start|router)\\b/.test(id)) // Start keeps these excluded\n .map((id) => `wcz-layout > ${id}`);\n}\n\nexport function viteWczLayout(): Plugin {\n const virtualModuleId = \"virtual:wcz-layout\";\n const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n let localesPath: string;\n let permissionsPath: string;\n let scopesPath: string;\n let envPath: string;\n let manifestPath: string;\n\n return {\n name: \"vite:wcz-layout\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n localesPath = path.resolve(resolvedConfig.root, \"src/lib/locales\");\n permissionsPath = path.resolve(resolvedConfig.root, \"src/lib/auth/permissions.ts\");\n scopesPath = path.resolve(resolvedConfig.root, \"src/lib/auth/scopes.ts\");\n envPath = path.resolve(resolvedConfig.root, \"src/env.ts\");\n manifestPath = path.resolve(resolvedConfig.root, \"public/manifest.json\");\n },\n async config(_, { command }) {\n await loadVaultSecrets(command);\n return { optimizeDeps: { include: wczLayoutImports() } };\n },\n configureServer(server) {\n const refresh = (filePath: string) => {\n if (\n filePath.includes(localesPath) ||\n filePath === permissionsPath ||\n filePath === scopesPath ||\n filePath === envPath ||\n filePath === manifestPath\n ) {\n const module = server.moduleGraph.getModuleById(resolvedVirtualModuleId);\n if (module) server.moduleGraph.invalidateModule(module);\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n }\n };\n\n server.watcher.add([localesPath, permissionsPath, scopesPath, envPath, manifestPath]);\n server.watcher.on(\"add\", refresh);\n server.watcher.on(\"change\", refresh);\n server.watcher.on(\"unlink\", refresh);\n },\n resolveId(id) {\n if (id === virtualModuleId) return resolvedVirtualModuleId;\n return null;\n },\n load(id) {\n if (id !== resolvedVirtualModuleId) return null;\n\n const resources = loadLocaleResources(localesPath, this.addWatchFile.bind(this));\n ensurePermissionsFile(permissionsPath, this.addWatchFile.bind(this));\n ensureScopesFile(scopesPath, this.addWatchFile.bind(this));\n const manifest = loadManifest(manifestPath, this.addWatchFile.bind(this));\n\n const normalizedPermissionsPath = permissionsPath.split(path.sep).join(path.posix.sep);\n const normalizedScopesPath = scopesPath.split(path.sep).join(path.posix.sep);\n const normalizedEnvPath = envPath.split(path.sep).join(path.posix.sep);\n return `\n ${dayjsLocaleImports(resources)}\n export const resources = ${JSON.stringify(resources)};\n export const manifest = ${JSON.stringify(manifest)};\n export { permissions } from \"${normalizedPermissionsPath}\";\n export { scopes } from \"${normalizedScopesPath}\";\n export { serverEnv } from \"${normalizedEnvPath}\";\n `;\n },\n };\n}\n"],"mappings":";;;;;;;;;AAEA,MAAa,oBAAoB,EAAE,OAAO;CACxC,eAAe,EAAE,IAAI;CACrB,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAChC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAChC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACnC,mBAAmB,EAAE,OAAO,CAAC,CAAC,QAAQ,SAAS;AACjD,CAAC;;ACGD,eAAe,kBAAkB,KAA8D;CAE7F,MAAM,EAAE,eAAe,gBAAgB,gBAAgB,mBAAmB,sBAD3D,kBAAkB,MAAM,GAErC;CAEF,MAAM,SAAS,MAAM,OAAO;EAC1B,SAAS;EACT,YAAY,IAAI,MAAM,MAAM,EAAE,oBAAoB,MAAM,CAAC;CAC3D,CAAC;CAED,MAAM,EAAE,MAAM,cAAc,MAAM,OAAO,KAAK,2BAA2B,kBAAkB,EACzF,UAAU,eACZ,CAAC;CAED,MAAM,EAAE,MAAM,eAAe,MAAM,OAAO,IACxC,OAAO,kBAAkB,QAAQ,qBACjC,EACE,SAAS,EAAE,iBAAiB,UAAU,KAAK,aAAa,EAC1D,CACF;CAEA,MAAM,UAAU,YAAY,MAAM;CAClC,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,kBAAkB;CAEhD,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAC5C,KACA,OAAO,UAAU,WAAW,QAAQ,KAAK,UAA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;EACA,UAAU,IAAI;GACZ,IAAI,OAAO,iBAAiB,OAAO;GACnC,OAAO;EACT;EACA,KAAK,IAAI;GACP,IAAI,OAAO,yBAAyB,OAAO;GAE3C,MAAM,YAAY,oBAAoB,aAAa,KAAK,aAAa,KAAK,IAAI,CAAC;GAC/E,sBAAsB,iBAAiB,KAAK,aAAa,KAAK,IAAI,CAAC;GACnE,iBAAiB,YAAY,KAAK,aAAa,KAAK,IAAI,CAAC;GACzD,MAAM,WAAW,aAAa,cAAc,KAAK,aAAa,KAAK,IAAI,CAAC;GAExE,MAAM,4BAA4B,gBAAgB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG;GACrF,MAAM,uBAAuB,WAAW,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG;GAC3E,MAAM,oBAAoB,QAAQ,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG;GACrE,OAAO;cACC,mBAAmB,SAAS,EAAE;uCACL,KAAK,UAAU,SAAS,EAAE;sCAC3B,KAAK,UAAU,QAAQ,EAAE;2CACpB,0BAA0B;sCAC/B,qBAAqB;yCAClB,kBAAkB;;EAEvD;CACF;AACF"}
1
+ {"version":3,"file":"vite.mjs","names":[],"sources":["../src/models/VaultConfig.ts","../src/lib/vite-plugin.ts"],"sourcesContent":["import z from \"zod\";\n\nexport const VaultConfigSchema = z.object({\n VAULT_ADDRESS: z.url(),\n VAULT_USERNAME: z.string().min(1),\n VAULT_PASSWORD: z.string().min(1),\n VAULT_SECRET_PATH: z.string().min(1),\n VAULT_MOUNT_POINT: z.string().default(\"release\"),\n});\n\nexport type VaultConfig = z.infer<typeof VaultConfigSchema>;\n","import fs from \"node:fs\";\nimport https from \"node:https\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport axios from \"axios\";\nimport { loadEnv } from \"vite\";\nimport { VaultConfigSchema } from \"../models/VaultConfig\";\nimport type { Resource } from \"i18next\";\nimport type { Plugin } from \"vite\";\n\nasync function fetchVaultSecrets(env: Record<string, string>): Promise<Record<string, string>> {\n const config = VaultConfigSchema.parse(env);\n const { VAULT_ADDRESS, VAULT_USERNAME, VAULT_PASSWORD, VAULT_SECRET_PATH, VAULT_MOUNT_POINT } =\n config;\n\n const client = axios.create({\n baseURL: VAULT_ADDRESS,\n httpsAgent: new https.Agent({ rejectUnauthorized: false }),\n });\n\n const { data: loginData } = await client.post(`/v1/auth/userpass/login/${VAULT_USERNAME}`, {\n password: VAULT_PASSWORD,\n });\n\n const { data: secretData } = await client.get(\n `/v1/${VAULT_MOUNT_POINT}/data/${VAULT_SECRET_PATH}`,\n {\n headers: { \"X-Vault-Token\": loginData.auth.client_token },\n },\n );\n\n const secrets = secretData?.data?.data;\n if (!secrets) throw new Error(\"No secrets found\");\n\n return Object.fromEntries(\n Object.entries(secrets).map(([key, value]) => [\n key,\n typeof value === \"string\" ? value : JSON.stringify(value),\n ]),\n );\n}\n\nasync function loadVaultSecrets(command: string): Promise<void> {\n if (command !== \"serve\") return;\n\n const env = loadEnv(\"development\", process.cwd(), \"\");\n if (!env.VAULT_ADDRESS) return;\n\n try {\n const secrets = await fetchVaultSecrets(env);\n Object.entries(secrets).forEach(([key, value]) => {\n process.env[key] = env[key]?.trim() ? env[key] : value;\n });\n } catch (e) {\n console.warn(\"[vite:wcz-layout] Vault failed:\", e instanceof Error ? e.message : e);\n }\n}\n\nfunction loadLocaleResources(localesPath: string, addWatchFile: (path: string) => void): Resource {\n if (!fs.existsSync(localesPath)) fs.mkdirSync(localesPath, { recursive: true });\n\n const enPath = path.join(localesPath, \"en.json\");\n if (!fs.existsSync(enPath)) fs.writeFileSync(enPath, JSON.stringify({}));\n\n const files = fs.readdirSync(localesPath);\n const resources: Resource = {};\n\n for (const file of files.filter((f) => f.endsWith(\".json\"))) {\n const lang = path.basename(file, \".json\");\n const filePath = path.join(localesPath, file);\n try {\n resources[lang] = { translation: JSON.parse(fs.readFileSync(filePath, \"utf-8\")) };\n } catch {\n resources[lang] = { translation: {} };\n }\n addWatchFile(filePath);\n }\n\n return resources;\n}\n\nconst require = createRequire(import.meta.url);\n\nfunction dayjsLocaleImports(resources: Resource): string {\n return Object.keys(resources)\n .map((lang) => lang.toLowerCase())\n .filter((lang) => {\n try {\n require.resolve(`dayjs/locale/${lang}.js`);\n return true;\n } catch {\n return false;\n }\n })\n .map((lang) => `import \"dayjs/locale/${lang}\";`)\n .join(\"\\n\");\n}\n\n// MUI names its locales language + region (csCZ, enUS, zhTW): the exact one for zh-TW.json,\n// else the language's first. Only the app's languages are imported.\nasync function muiLocaleModule(languages: Array<string>): Promise<string> {\n const sources = Object.entries({\n \"@mui/material/locale\": await import(\"@mui/material/locale\"),\n \"@mui/x-date-pickers/locales\": await import(\"@mui/x-date-pickers/locales\"),\n });\n const imports: Array<string> = [];\n const locales: Record<string, Array<string>> = {};\n\n for (const [source, module] of sources) {\n const names = Object.keys(module);\n for (const language of languages) {\n const [base, region = \"\"] = language.split(\"-\");\n const name =\n names.find((n) => n === base + region.toUpperCase()) ??\n names.find((n) => new RegExp(`^${base}(?:[A-Z]|$)`).test(n));\n if (!name) continue;\n const alias = `mui${imports.length}`;\n imports.push(`import { ${name} as ${alias} } from \"${source}\";`);\n (locales[language] ??= []).push(alias);\n }\n }\n\n const entries = Object.entries(locales).map(\n ([language, aliases]) => `${JSON.stringify(language)}: [${aliases.join(\", \")}]`,\n );\n return `${imports.join(\"\\n\")}\\nexport const muiLocales = { ${entries.join(\", \")} };`;\n}\n\n// Types `t()` from en.json and fails type-checking, naming the key, when another locale lacks\n// one of en.json's keys (plural suffixes may differ per language).\nfunction writeLocaleTypes(typesPath: string, languages: Array<string>): void {\n const others = languages.filter((language) => language !== \"en\");\n const id = (language: string) => `locale_${language.replace(/\\W/g, \"_\")}`;\n const lines = [\n \"// Generated by wcz-layout from src/lib/locales/*.json. Do not edit.\",\n ...[\"en\", ...others].map((l) => `import type ${id(l)} from \"../lib/locales/${l}.json\";`),\n \"\",\n 'declare module \"i18next\" {',\n \" interface CustomTypeOptions {\",\n \" resources: { translation: typeof locale_en };\",\n \" }\",\n \"}\",\n ];\n if (others.length)\n lines.push(\n \"\",\n 'type Plural = \"zero\" | \"one\" | \"two\" | \"few\" | \"many\" | \"other\";',\n 'type Keys<T, Prefix extends string = \"\"> = {',\n \" [K in keyof T & string]: T[K] extends string\",\n \" ? `${Prefix}${K extends `${infer Key}_${Plural}` ? Key : K}`\",\n \" : Keys<T[K], `${Prefix}${K}.`>;\",\n \"}[keyof T & string];\",\n \"type Missing<Locale> = Exclude<Keys<typeof locale_en>, Keys<Locale>>;\",\n \"type Complete<MissingKeys extends never> = MissingKeys;\",\n \"\",\n \"export type Locales = {\",\n ...others.map(\n (l) => ` ${/^\\w+$/.test(l) ? l : JSON.stringify(l)}: Complete<Missing<typeof ${id(l)}>>;`,\n ),\n \"};\",\n );\n\n const content = `${lines.join(\"\\n\")}\\n`;\n if (fs.existsSync(typesPath) && fs.readFileSync(typesPath, \"utf-8\") === content) return;\n fs.mkdirSync(path.dirname(typesPath), { recursive: true });\n fs.writeFileSync(typesPath, content);\n}\n\nconst permissionsFile = `import type { Permissions } from \"wcz-layout/models\";\n\nexport const permissions = {\n admin: [\"wcz-developers\"],\n} as const satisfies Permissions;\n`;\n\nconst scopesFile = `import type { Scopes } from \"wcz-layout/models\";\n\nexport const scopes = {\n graph: \"User.Read\",\n api: \"api://wistron.com/app-scope/access_as_user\",\n} as const satisfies Scopes;\n`;\n\nconst envFile = `import type { Env } from \"wcz-layout/models\";\nimport { z } from \"zod\";\n\nexport const env = {\n server: {\n ENTRA_CLIENT_ID: z.string(),\n ENTRA_TENANT_ID: z.string(),\n ENTRA_CLIENT_SECRET: z.string(),\n SESSION_SECRET: z.string().min(32),\n },\n client: {},\n} satisfies Env;\n`;\n\n// A project file the virtual module re-exports: created with a starter when missing.\nfunction ensureFile(filePath: string, content: string, addWatchFile: (path: string) => void) {\n if (!fs.existsSync(filePath)) {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n fs.writeFileSync(filePath, content);\n }\n addWatchFile(filePath);\n return filePath.split(path.sep).join(path.posix.sep);\n}\n\n// public/manifest.webmanifest or package.json: both name the app.\nfunction loadNamedJson(\n filePath: string,\n addWatchFile: (path: string) => void,\n): { name: string } & Record<string, unknown> {\n addWatchFile(filePath);\n try {\n return JSON.parse(fs.readFileSync(filePath, \"utf-8\"));\n } catch {\n return { name: \"\" };\n }\n}\n\n// TanStack Start excludes wcz-layout from pre-bundling, and Vite doesn't pre-bundle bare imports\n// of excluded packages either, so CJS they pull in (url-parse, prop-types, ...) breaks in the\n// browser. Pre-bundle every bare import of the published chunks; empty when run from source.\nfunction wczLayoutImports(): string[] {\n const dist = path.dirname(fileURLToPath(import.meta.url));\n const specifiers = new Set<string>();\n for (const file of fs.readdirSync(dist)) {\n if (!file.endsWith(\".mjs\") || file === \"vite.mjs\") continue;\n for (const [, id] of fs\n .readFileSync(path.join(dist, file), \"utf-8\")\n .matchAll(/from \"([^\"]+)\"/g))\n specifiers.add(id);\n }\n return [...specifiers]\n .filter((id) => /^[@a-z]/.test(id) && !id.includes(\":\")) // skips relative, node:, virtual:\n .filter((id) => !/^@tanstack\\/react-(start|router)\\b/.test(id)) // Start keeps these excluded\n .map((id) => `wcz-layout > ${id}`);\n}\n\nexport function viteWczLayout(): Plugin {\n const virtualModuleId = \"virtual:wcz-layout\";\n const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n\n let localesPath: string;\n let permissionsPath: string;\n let scopesPath: string;\n let manifestPath: string;\n let packagePath: string;\n let localeTypesPath: string;\n let envPath: string;\n\n return {\n name: \"vite:wcz-layout\",\n enforce: \"pre\",\n configResolved(resolvedConfig) {\n localesPath = path.resolve(resolvedConfig.root, \"src/lib/locales\");\n permissionsPath = path.resolve(resolvedConfig.root, \"src/lib/auth/permissions.ts\");\n scopesPath = path.resolve(resolvedConfig.root, \"src/lib/auth/scopes.ts\");\n manifestPath = path.resolve(resolvedConfig.root, \"public/manifest.webmanifest\");\n packagePath = path.resolve(resolvedConfig.root, \"package.json\");\n localeTypesPath = path.resolve(resolvedConfig.root, \"src/types/i18next.gen.ts\");\n envPath = path.resolve(resolvedConfig.root, \"src/env.ts\");\n },\n async config(_, { command }) {\n await loadVaultSecrets(command);\n return { optimizeDeps: { include: wczLayoutImports() } };\n },\n configureServer(server) {\n const refresh = (filePath: string) => {\n if (\n filePath.includes(localesPath) ||\n filePath === permissionsPath ||\n filePath === scopesPath ||\n filePath === manifestPath ||\n filePath === envPath\n ) {\n // Every environment: the SSR module runner keeps its modules until told to reload,\n // so a new locale file would otherwise reach the browser but not the server.\n for (const environment of Object.values(server.environments)) {\n const module = environment.moduleGraph.getModuleById(resolvedVirtualModuleId);\n if (module) environment.moduleGraph.invalidateModule(module);\n environment.hot.send({ type: \"full-reload\", path: \"*\" });\n }\n }\n };\n\n server.watcher.add([localesPath, permissionsPath, scopesPath, manifestPath, envPath]);\n server.watcher.on(\"add\", refresh);\n server.watcher.on(\"change\", refresh);\n server.watcher.on(\"unlink\", refresh);\n },\n resolveId(id) {\n if (id === virtualModuleId) return resolvedVirtualModuleId;\n return null;\n },\n async load(id) {\n if (id !== resolvedVirtualModuleId) return null;\n\n const addWatchFile = this.addWatchFile.bind(this);\n const resources = loadLocaleResources(localesPath, addWatchFile);\n writeLocaleTypes(localeTypesPath, Object.keys(resources));\n const manifest = loadNamedJson(manifestPath, addWatchFile);\n // The file service namespace of the app's files.\n const { name: appName } = loadNamedJson(packagePath, addWatchFile);\n\n // These files may import only types from wcz-layout: wcz-layout imports this module.\n return `\n ${dayjsLocaleImports(resources)}\n ${await muiLocaleModule(Object.keys(resources))}\n export const resources = ${JSON.stringify(resources)};\n export const manifest = ${JSON.stringify(manifest)};\n export const appName = ${JSON.stringify(appName)};\n export { permissions } from \"${ensureFile(permissionsPath, permissionsFile, addWatchFile)}\";\n export { scopes } from \"${ensureFile(scopesPath, scopesFile, addWatchF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