@antelopejs/dms-frontend 0.9.2 → 0.10.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 (123) hide show
  1. package/README.md +18 -24
  2. package/dist/commands/build-action.js +3 -2
  3. package/dist/commands/dev-action.js +2 -1
  4. package/dist/commands/prepare-action.js +1 -1
  5. package/dist/commands/start-action.js +3 -24
  6. package/dist/commands/workspace-task.js +2 -1
  7. package/dist/config.js +3 -0
  8. package/dist/derived-outputs.js +3 -3
  9. package/dist/discovery.js +17 -6
  10. package/dist/entry-weight.js +15 -0
  11. package/dist/fs-sync.js +7 -4
  12. package/dist/index.js +2 -1
  13. package/dist/internal/built-workspace.d.ts +4 -0
  14. package/dist/internal/built-workspace.js +43 -0
  15. package/dist/internal/ensure.d.ts +1 -0
  16. package/dist/internal/ensure.js +8 -0
  17. package/dist/internal/locale-catalogs.d.ts +8 -3
  18. package/dist/internal/locale-catalogs.js +16 -6
  19. package/dist/internal/manifest-decoder.d.ts +7 -0
  20. package/dist/internal/manifest-decoder.js +81 -0
  21. package/dist/internal/own-release.d.ts +5 -0
  22. package/dist/internal/own-release.js +20 -0
  23. package/dist/internal/plain-object.d.ts +1 -0
  24. package/dist/internal/plain-object.js +6 -0
  25. package/dist/internal/text-list.d.ts +1 -0
  26. package/dist/internal/text-list.js +10 -0
  27. package/dist/internal/vite-manifest.d.ts +6 -0
  28. package/dist/internal/vite-manifest.js +24 -0
  29. package/dist/layer-watch.js +25 -24
  30. package/dist/layers.d.ts +1 -1
  31. package/dist/layers.js +3 -1
  32. package/dist/locale-files.d.ts +2 -1
  33. package/dist/locale-files.js +4 -0
  34. package/dist/manifest.d.ts +1 -1
  35. package/dist/manifest.js +44 -31
  36. package/dist/materialize.js +6 -2
  37. package/dist/module-set.js +2 -1
  38. package/dist/node-options.d.ts +1 -0
  39. package/dist/node-options.js +8 -0
  40. package/dist/output.d.ts +15 -9
  41. package/dist/output.js +30 -18
  42. package/dist/private-values.d.ts +1 -1
  43. package/dist/private-values.js +5 -3
  44. package/dist/project-modules.js +13 -8
  45. package/dist/renderer-range.js +5 -3
  46. package/dist/server-process.js +1 -1
  47. package/dist/verify-source-build.js +10 -2
  48. package/dist/verify-source-client-bundle.d.ts +1 -0
  49. package/dist/verify-source-client-bundle.js +30 -0
  50. package/dist/verify-source-runner.js +44 -60
  51. package/dist/verify-source-sources.js +49 -11
  52. package/dist/workspace-setup.js +1 -1
  53. package/package.json +6 -4
  54. package/skills/dms-frontend/SKILL.md +1 -1
  55. package/templates/vue/app-runtime.ts +90 -16
  56. package/templates/vue/client-server-guard.mjs +16 -0
  57. package/templates/vue/compress-assets.mjs +9 -1
  58. package/templates/vue/entry-weight.mjs +22 -0
  59. package/templates/vue/frontend-module.ts +1 -0
  60. package/templates/vue/frontend-runtime/module-registration.ts +2 -2
  61. package/templates/vue/frontend-runtime/state.ts +2 -2
  62. package/templates/vue/frontend-runtime/types.ts +8 -2
  63. package/templates/vue/globals.d.ts +5 -0
  64. package/templates/vue/head-order.mjs +7 -0
  65. package/templates/vue/icon-bundle.ts +31 -0
  66. package/templates/vue/icon-scan.mjs +4 -0
  67. package/templates/vue/message-subset.ts +65 -0
  68. package/templates/vue/network-error.ts +4 -0
  69. package/templates/vue/server/auth/backend.mjs +41 -4
  70. package/templates/vue/server/auth/client-ip.mjs +52 -4
  71. package/templates/vue/server/auth/establish-endpoints.mjs +10 -6
  72. package/templates/vue/server/auth/session.mjs +81 -2
  73. package/templates/vue/server/auth-hooks.mjs +15 -5
  74. package/templates/vue/server/backend-proxies.mjs +65 -9
  75. package/templates/vue/server/backend-request.mjs +61 -0
  76. package/templates/vue/server/backend-response.mjs +23 -6
  77. package/templates/vue/server/built-files.mjs +7 -0
  78. package/templates/vue/server/cli-report.mjs +53 -11
  79. package/templates/vue/server/client-manifest.mjs +23 -1
  80. package/templates/vue/server/content.mjs +18 -1
  81. package/templates/vue/server/dev-private-files.mjs +17 -1
  82. package/templates/vue/server/dev-styles.mjs +38 -0
  83. package/templates/vue/server/email.mjs +9 -3
  84. package/templates/vue/server/favicon.mjs +3 -0
  85. package/templates/vue/server/generated-files.mjs +211 -0
  86. package/templates/vue/server/homepage.mjs +21 -9
  87. package/templates/vue/server/html-tag.mjs +4 -0
  88. package/templates/vue/server/icons.mjs +80 -7
  89. package/templates/vue/server/in-place-render.mjs +35 -0
  90. package/templates/vue/server/inertia.mjs +61 -2
  91. package/templates/vue/server/module-event.mjs +98 -17
  92. package/templates/vue/server/module-route-types.mjs +78 -0
  93. package/templates/vue/server/module-routes.mjs +138 -31
  94. package/templates/vue/server/module-server.mjs +98 -27
  95. package/templates/vue/server/module-testing.mjs +14 -5
  96. package/templates/vue/server/page-props.mjs +92 -2
  97. package/templates/vue/server/page-redirects.mjs +37 -0
  98. package/templates/vue/server/path-patterns.mjs +13 -1
  99. package/templates/vue/server/proxy-compression.mjs +22 -0
  100. package/templates/vue/server/proxy-headers.mjs +11 -1
  101. package/templates/vue/server/proxy-redirects.mjs +20 -5
  102. package/templates/vue/server/proxy-request.mjs +57 -0
  103. package/templates/vue/server/proxy-transfers.mjs +33 -5
  104. package/templates/vue/server/public-endpoints.mjs +138 -23
  105. package/templates/vue/server/public-options.mjs +20 -6
  106. package/templates/vue/server/request-failure.mjs +23 -0
  107. package/templates/vue/server/request-routing.mjs +26 -9
  108. package/templates/vue/server/request-target.mjs +9 -3
  109. package/templates/vue/server/route-rules.mjs +39 -15
  110. package/templates/vue/server/ssr-module.mjs +32 -0
  111. package/templates/vue/server/static-files.mjs +24 -1
  112. package/templates/vue/server/type-guards.mjs +71 -0
  113. package/templates/vue/server/vite-errors.mjs +32 -5
  114. package/templates/vue/server/web-body.mjs +3 -0
  115. package/templates/vue/server-module.ts +10 -1
  116. package/templates/vue/server.mjs +132 -148
  117. package/templates/vue/sfc-global-types.mjs +112 -13
  118. package/templates/vue/ssr-renderer.ts +12 -3
  119. package/templates/vue/ui-inertia-page.mjs +16 -1
  120. package/templates/vue/ui-kbd.mjs +2 -1
  121. package/templates/vue/ui-lazy-icons.mjs +44 -0
  122. package/templates/vue/ui-request-state.mjs +2 -1
  123. package/templates/vue/vite.config.ts +2 -0
@@ -7,7 +7,6 @@ import { createSSRApp, h, readonly } from "vue";
7
7
  import { appConfigs } from "./app-configs.generated";
8
8
  import {
9
9
  DMS_PAYLOAD_ID,
10
- type DmsServerFetch,
11
10
  SSR_ASYNC_COMPONENTS_ID,
12
11
  configureDmsApp,
13
12
  resolveDmsInertiaPage,
@@ -19,6 +18,7 @@ import {
19
18
  type DmsInertiaPage,
20
19
  type DmsPageProps,
21
20
  type DmsPayload,
21
+ type DmsServerFetch,
22
22
  createDmsFrontendRuntime,
23
23
  hasDmsPage,
24
24
  pageErrorData,
@@ -30,6 +30,7 @@ import {
30
30
  trackDmsServerScopes,
31
31
  withPublicOptions,
32
32
  } from "./frontend-module";
33
+ import { type DmsMessageSubset, SSR_MESSAGES_ID } from "./message-subset";
33
34
  import { parsePublicOptions } from "./public-options";
34
35
  import { frontendModules } from "./frontend-modules.generated";
35
36
  import {
@@ -129,6 +130,12 @@ function asyncComponentsScript(names: Set<string>): string {
129
130
  return `<script id="${SSR_ASYNC_COMPONENTS_ID}" type="application/json">${value}</script>`;
130
131
  }
131
132
 
133
+ function messagesScript(subset: DmsMessageSubset | undefined): string {
134
+ if (!subset) return "";
135
+ const value = JSON.stringify(subset).replaceAll("<", "\\u003c");
136
+ return `<script id="${SSR_MESSAGES_ID}" type="application/json">${value}</script>`;
137
+ }
138
+
132
139
  function iconsScript(names: Set<string>): string {
133
140
  const value = JSON.stringify(serializeDmsIcons(names)).replaceAll(
134
141
  "<",
@@ -159,7 +166,7 @@ export async function renderDmsPage(
159
166
  requestCookies?: string,
160
167
  ): Promise<DmsSsrResult> {
161
168
  const runtime = createDmsFrontendRuntime(
162
- serverFetch as typeof import("ofetch").ofetch,
169
+ serverFetch,
163
170
  {},
164
171
  true,
165
172
  requestCookies,
@@ -195,6 +202,7 @@ async function renderDmsPageWithRuntime(
195
202
  let iconSymbols = new Map<string, string>();
196
203
  let payload: DmsPayload = { data: {}, errors: {}, state: {} };
197
204
  let catalogLocale: (() => string | undefined) | undefined;
205
+ let messageSubset: (() => DmsMessageSubset | undefined) | undefined;
198
206
  const inertiaResult = await createInertiaApp({
199
207
  page,
200
208
  // Read as the HTML is complete: data a run settles afterwards was never
@@ -221,6 +229,7 @@ async function renderDmsPageWithRuntime(
221
229
  serverFetch,
222
230
  });
223
231
  catalogLocale = configured.catalogLocale;
232
+ messageSubset = configured.messageSubset;
224
233
  return app;
225
234
  },
226
235
  });
@@ -255,7 +264,7 @@ async function renderDmsPageWithRuntime(
255
264
  const renderedHead = await renderSSRHead(head);
256
265
  return {
257
266
  error: page.props.error,
258
- body: `${inertiaResult.body}${dmsIconSprite(iconSymbols)}${payloadScript(payload)}${asyncComponentsScript(asyncComponents)}${iconsScript(icons)}`,
267
+ body: `${inertiaResult.body}${dmsIconSprite(iconSymbols)}${payloadScript(payload)}${asyncComponentsScript(asyncComponents)}${iconsScript(icons)}${messagesScript(messageSubset?.())}`,
259
268
  head: {
260
269
  bodyAttrs: renderedHead.bodyAttrs,
261
270
  headTags: `${inertiaResult.head.join("")}${renderedHead.headTags}`,
@@ -6,6 +6,20 @@ const DMS_PAGE_IMPORT =
6
6
  const ANY_INERTIA_PAGE_IMPORT =
7
7
  /import\s*\{[^}]*\busePage\b[^}]*\}\s*from\s*["']@inertiajs\/vue3["']|import\s*\*\s*as\s+\w+\s+from\s*["']@inertiajs\/vue3["']/;
8
8
 
9
+ /**
10
+ * A Vite plugin that rewrites the source of Nuxt UI files.
11
+ *
12
+ * @typedef {{
13
+ * name: string,
14
+ * enforce: "pre",
15
+ * transform: (
16
+ * this: import("vite").Rollup.TransformPluginContext,
17
+ * code: string,
18
+ * id: string,
19
+ * ) => { code: string, map: null } | null,
20
+ * }} NuxtUiRewrite
21
+ */
22
+
9
23
  /**
10
24
  * The rewrite, as a Vite plugin.
11
25
  *
@@ -16,7 +30,8 @@ const ANY_INERTIA_PAGE_IMPORT =
16
30
  * a form this rewrite does not know, rather than letting the leak come back
17
31
  * unnoticed with a Nuxt UI release.
18
32
  *
19
- * @param isNuxtUiFile `(id) => boolean`, whether a module is Nuxt UI's
33
+ * @param {(id: string) => boolean} isNuxtUiFile whether a module is Nuxt UI's
34
+ * @returns {NuxtUiRewrite}
20
35
  */
21
36
  export function uiInertiaPage(isNuxtUiFile) {
22
37
  return {
@@ -21,7 +21,8 @@ const ROUTED_EXPORT =
21
21
  * changes the form rewritten here, rather than letting the mismatch come back
22
22
  * unnoticed.
23
23
  *
24
- * @param isNuxtUiFile `(id) => boolean`, whether a module is Nuxt UI's
24
+ * @param {(id: string) => boolean} isNuxtUiFile whether a module is Nuxt UI's
25
+ * @returns {import("./ui-inertia-page.mjs").NuxtUiRewrite}
25
26
  */
26
27
  export function uiKbd(isNuxtUiFile) {
27
28
  return {
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @typedef {object} IconsPluginContext
3
+ * @property {{ config: { consumer: string } }} environment
4
+ * @property {(message: string) => never} error
5
+ */
6
+
7
+ /** Nuxt UI's plugin that installs the client icon bundle. */
8
+ const ICONS_PLUGIN = /\/@nuxt\/ui\/dist\/runtime\/vue\/plugins\/icons\.js$/;
9
+
10
+ /**
11
+ * The client build of Nuxt UI's icons plugin, as a Vite plugin.
12
+ *
13
+ * The plugin imports the bundle of every icon the sources name, which put it
14
+ * in the entry of every page, the sign-in page's included, for icons it draws
15
+ * from the server render's own copy. The client gets an empty plugin, and
16
+ * `loadIconBundle` (`icon-bundle.ts`) loads the bundle when the page needs it. The server render keeps the plugin as it is. The
17
+ * build fails if Nuxt UI changes the form rewritten here, rather than
18
+ * letting the bundle return to the entry unnoticed.
19
+ *
20
+ * @param {(id: string) => boolean} isNuxtUiFile whether a module is Nuxt UI's
21
+ * @returns {{ name: string, enforce: "pre", transform: (this: IconsPluginContext, code: string, id: string) => { code: string, map: null } | null }}
22
+ */
23
+ export function uiLazyIcons(isNuxtUiFile) {
24
+ return {
25
+ name: "dms-ui-lazy-icons",
26
+ enforce: "pre",
27
+ transform(code, id) {
28
+ const path = id.replaceAll("\\", "/").split("?")[0];
29
+ if (
30
+ this.environment.config.consumer !== "client" ||
31
+ !isNuxtUiFile(id) ||
32
+ !ICONS_PLUGIN.test(path)
33
+ )
34
+ return null;
35
+ if (!code.includes("virtual:nuxt-ui-icons"))
36
+ this.error(
37
+ `${id} no longer installs the client icon bundle the way the DMS ` +
38
+ "defers it: the bundle would return to the entry. Update " +
39
+ "ui-lazy-icons.mjs for this Nuxt UI release.",
40
+ );
41
+ return { code: "export default { install() {} };", map: null };
42
+ },
43
+ };
44
+ }
@@ -21,7 +21,8 @@ const APPLICATION_STATE =
21
21
  * UI file defines `useState`, rather than letting the leak come back unnoticed
22
22
  * with a Nuxt UI release.
23
23
  *
24
- * @param isNuxtUiFile `(id) => boolean`, whether a module is Nuxt UI's
24
+ * @param {(id: string) => boolean} isNuxtUiFile whether a module is Nuxt UI's
25
+ * @returns {import("./ui-inertia-page.mjs").NuxtUiRewrite}
25
26
  */
26
27
  export function uiRequestState(isNuxtUiFile) {
27
28
  return {
@@ -14,6 +14,7 @@ import { recordEntryWeight } from "./entry-weight.mjs";
14
14
  import { rejectServerSourcesInClient } from "./client-server-guard.mjs";
15
15
  import { uiInertiaPage } from "./ui-inertia-page.mjs";
16
16
  import { uiKbd } from "./ui-kbd.mjs";
17
+ import { uiLazyIcons } from "./ui-lazy-icons.mjs";
17
18
  import { uiRequestState } from "./ui-request-state.mjs";
18
19
  import { autoImportDirectories, vitePlugins } from "./frontend-build-loader.ts";
19
20
  import { frontendBuilds } from "./frontend-builds.generated.ts";
@@ -184,6 +185,7 @@ export default defineConfig({
184
185
  },
185
186
  },
186
187
  uiKbd(isNuxtUiFile),
188
+ uiLazyIcons(isNuxtUiFile),
187
189
  uiInertiaPage(isNuxtUiFile),
188
190
  uiRequestState(isNuxtUiFile),
189
191
  vue({ script: { globalTypeFiles: [sfcGlobalTypesFile] } }),