@antelopejs/dms-frontend 0.3.12 → 0.4.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.
@@ -24,6 +24,13 @@ import {
24
24
  trackDmsServerScopes,
25
25
  } from "./frontend-module";
26
26
  import { frontendModules } from "./frontend-modules.generated";
27
+ import {
28
+ SSR_ICONS_ID,
29
+ serializeDmsIcons,
30
+ trackDmsIcons,
31
+ } from "./icon-hydration";
32
+
33
+ export { registerDmsIconCollections } from "./icon-hydration";
27
34
 
28
35
  export interface DmsSsrPage {
29
36
  component: string;
@@ -75,6 +82,14 @@ function asyncComponentsScript(names: Set<string>): string {
75
82
  return `<script id="${SSR_ASYNC_COMPONENTS_ID}" type="application/json">${value}</script>`;
76
83
  }
77
84
 
85
+ function iconsScript(names: Set<string>): string {
86
+ const value = JSON.stringify(serializeDmsIcons(names)).replaceAll(
87
+ "<",
88
+ "\\u003c",
89
+ );
90
+ return `<script id="${SSR_ICONS_ID}" type="application/json">${value}</script>`;
91
+ }
92
+
78
93
  await setupFrontendModules(frontendModules);
79
94
 
80
95
  export function isDmsFrontendPage(path: string): boolean {
@@ -117,6 +132,7 @@ async function renderDmsPageWithRuntime(
117
132
  const head = createHead();
118
133
  const ssrContext: DmsSsrContext = {};
119
134
  let asyncComponents = new Set<string>();
135
+ let icons = new Set<string>();
120
136
  const inertiaResult = await createInertiaApp({
121
137
  page,
122
138
  render: (app) => renderToString(app, ssrContext),
@@ -124,6 +140,7 @@ async function renderDmsPageWithRuntime(
124
140
  async setup({ App, props, plugin }) {
125
141
  const app = createSSRApp({ render: () => h(App, props) });
126
142
  asyncComponents = trackDmsAsyncComponents(app);
143
+ icons = trackDmsIcons(app);
127
144
  stopScopes = trackDmsServerScopes(app);
128
145
  const configured = await configureDmsApp({
129
146
  app,
@@ -173,7 +190,7 @@ async function renderDmsPageWithRuntime(
173
190
  const renderedHead = await renderSSRHead(head);
174
191
  return {
175
192
  error: page.props.error,
176
- body: `${inertiaResult.body}${asyncDataScript(runtime)}${asyncComponentsScript(asyncComponents)}`,
193
+ body: `${inertiaResult.body}${asyncDataScript(runtime)}${asyncComponentsScript(asyncComponents)}${iconsScript(icons)}`,
177
194
  head: {
178
195
  bodyAttrs: renderedHead.bodyAttrs,
179
196
  headTags: `${inertiaResult.head.join("")}${renderedHead.headTags}`,
@@ -2,7 +2,15 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { basename, resolve } from "node:path";
3
3
  import ui from "@nuxt/ui/vite";
4
4
  import vue from "@vitejs/plugin-vue";
5
- import { defineConfig, type LogLevel, normalizePath, type Plugin } from "vite";
5
+ import {
6
+ createLogger,
7
+ defineConfig,
8
+ type LogLevel,
9
+ normalizePath,
10
+ type Plugin,
11
+ } from "vite";
12
+ import { autoImportDirectories } from "./frontend-build-loader";
13
+ import { frontendBuilds } from "./frontend-builds.generated";
6
14
  import { orderHeadForFirstPaint } from "./head-order.mjs";
7
15
  import { iconScanGlobs } from "./icon-scan.mjs";
8
16
 
@@ -40,21 +48,19 @@ const stableModuleAliases = Object.fromEntries(
40
48
  }),
41
49
  );
42
50
  /**
43
- * Globs are POSIX, always.
44
- *
45
- * `resolve` returns a native path, so on Windows every pattern below would
46
- * carry backslashes — which a glob matcher reads as escape characters, not as
47
- * separators, and which therefore match nothing at all. `normalizePath` is
48
- * Vite's own answer to this and is the identity function on POSIX.
51
+ * `ajs dms build` runs Vite at "warn" and reports the steps itself; a verbose
52
+ * run, `dev` and a hand-run build keep Vite's own output.
53
+ */
54
+ const logLevel = (process.env.DMS_VITE_LOG_LEVEL ?? "info") as LogLevel;
55
+ const logger = createLogger(logLevel);
56
+ /**
57
+ * Only what each module declares in its `dms.frontend.build.ts`: a module
58
+ * without one has nothing auto-imported.
49
59
  */
50
- const importDirectories = frontendSourceRoots.flatMap((root) =>
51
- [
52
- "app/composables/**/*",
53
- "app/types/**/*",
54
- "app/utils/**/*",
55
- "app/build/composables/**/*",
56
- "app/build/types/**/*",
57
- ].map((glob) => ({ glob: normalizePath(resolve(root, glob)), types: true })),
60
+ const importDirectories = autoImportDirectories(
61
+ registry.modules,
62
+ frontendBuilds,
63
+ (message) => logger.warn(message),
58
64
  );
59
65
  const optimizedDependencies = [
60
66
  "vue",
@@ -90,8 +96,9 @@ const optimizedDependencies = [
90
96
  * startup, pays that cost a single time and in a place where it reads as
91
97
  * startup rather than as a crash.
92
98
  *
93
- * Normalized for the same reason as `importDirectories`: Vite hands these
94
- * patterns straight to its glob matcher without touching the separators.
99
+ * Globs are POSIX, always: `resolve` returns a native path, whose Windows
100
+ * backslashes a glob matcher reads as escape characters, not as separators.
101
+ * `normalizePath` is Vite's own answer to this, the identity on POSIX.
95
102
  */
96
103
  const optimizerEntries = [
97
104
  resolve(__dirname, "main.ts"),
@@ -117,12 +124,6 @@ const uiInertiaLinkImport = resolve(
117
124
  "node_modules/@nuxt/ui/dist/runtime/vue/overrides/inertia/Link.vue",
118
125
  );
119
126
 
120
- /**
121
- * `ajs dms build` runs Vite at "warn" and reports the steps itself; a verbose
122
- * run, `dev` and a hand-run build keep Vite's own output.
123
- */
124
- const logLevel = (process.env.DMS_VITE_LOG_LEVEL ?? "info") as LogLevel;
125
-
126
127
  export default defineConfig({
127
128
  logLevel,
128
129
  plugins: [
@@ -175,6 +176,7 @@ export default defineConfig({
175
176
  "useI18n",
176
177
  "useError",
177
178
  "useDmsLazyAsyncData",
179
+ "useDmsPageLoading",
178
180
  "useDmsApp",
179
181
  "useDmsRoute",
180
182
  "useDmsRouter",