@dokebi/template-inertia 0.4.10 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI.md +1 -1
- package/dist/index.js +1 -1
- package/dist/module-pages.js +17 -3
- package/package.json +2 -2
package/AI.md
CHANGED
|
@@ -242,7 +242,7 @@ A module keeps its Vue pages in its own views folder (@dokebi/module AI.md §4a)
|
|
|
242
242
|
- The module text is one static import per page file and `export default modulePages({ <module>: { '<template>/<path>': page } })`. Left out: pages of sets the app did not choose (`Pages/<set>/**`), and a page the app overrides in `views/default/Pages/<module>/` (the app's file wins for every template). At most 2000 page files per app (warn `INERTIA_MODULE_PAGES_LIMIT`).
|
|
243
243
|
- `modulePages(table)` of `@dokebi/template-inertia/pages` (no imports, browser and SSR bundles) gives `{ modules, page(template, name) }`: the module's page of `template`, else of `default`, else undefined. The entries look up the app's own page first: `` pick(`Pages/${name}`) ?? modulePages.page(template, name) ``.
|
|
244
244
|
- Types: `/// <reference types="@dokebi/template-inertia/module-pages" />` in `src/infra/inertia/page.d.ts` (the generated file has it) declares the virtual module for vue-tsc and `dokebi check`, whose browser program now reads the project's `.d.ts` files too.
|
|
245
|
-
- The dev server serves each module's views folder like an app's (§5.2), and reloads the browser when a `.vue` file is added to or removed from a module folder or the app's views, or the app file changes. The dev server reads an app's module pages in a worker thread of its own (0.4.10, D-0230), so the app file and everything it imports — the module list the CLI writes (`registeredModules`, D-0227), the modules' definitions — are read as they are now; a module added with `npx dokebi module add` while `dokebi dev` runs is served (its pages in the table, its folder allowed) once the list or the app file changes, without a restart. A change of the module list file
|
|
245
|
+
- The dev server serves each module's views folder like an app's (§5.2), and reloads the browser when a `.vue` file is added to or removed from a module folder or the app's views, or the app file changes. The dev server reads an app's module pages in a worker thread of its own (0.4.10, D-0230), so the app file and everything it imports — the module list the CLI writes (`registeredModules`, D-0227), the modules' definitions — are read as they are now; a module added with `npx dokebi module add` while `dokebi dev` runs is served (its pages in the table, its folder allowed) once the list or the app file changes, without a restart. A change of the module list file reads the app again too, and so does a change of **any** module's definition (`module.ts`, `.mts` or `.js`) under the app's `src/` — a module that gains `views:` while `dokebi dev` runs has its pages in the table at once, and one that drops them loses them (0.4.11; before, only modules that already had views were watched, and `Unknown page` stayed until a restart).
|
|
246
246
|
- `vite.ssr.config.ts` needs `dokebiInertia()` too (the SSR build resolves the same import; server rendering still leaves the seal imports to Node). `npx dokebi doctor` names an entry without the import while a module under `src/` has Vue pages (`TEMPLATE_FIX_MISSING`, `module-pages`) and a Vite config without `dokebiInertia()` while an entry imports it (`module-pages-plugin`).
|
|
247
247
|
- An app package without the sources (before @dokebi/app 0.4.9): no module pages, warn `INERTIA_MODULE_PAGES_UNSUPPORTED`. Failures are coded errors of the build: `MODULE_PAGES_APP_MISSING` (imported outside an app's views folder), `MODULE_PAGES_FAILED` (the app file cannot be imported, exports no definition, or a module folder cannot be read; the cause is kept).
|
|
248
248
|
- Debug logs: `Inertia module pages gathered` (app, page count per module, skipped sets, ms), `Inertia module pages changed; the browser reloads` (event, path), `Inertia dev file policy allows a module views folder`.
|
package/dist/index.js
CHANGED
package/dist/module-pages.js
CHANGED
|
@@ -86,6 +86,8 @@ async function readHere(app) {
|
|
|
86
86
|
return { kind: 'unsupported' };
|
|
87
87
|
return { kind: 'sources', sources: list() };
|
|
88
88
|
}
|
|
89
|
+
/** A module's definition file (D-0227: `module.ts` at the module's root). */
|
|
90
|
+
const DEFINITION = /^module\.(?:ts|mts|js)$/;
|
|
89
91
|
/** How long the dev server waits for a worker to read an app's module page sources. */
|
|
90
92
|
const WORKER_TIMEOUT_MS = 30_000;
|
|
91
93
|
const WORKER = new URL('./module-pages-worker.js', import.meta.url);
|
|
@@ -238,7 +240,11 @@ export class ModulePagesSource {
|
|
|
238
240
|
const page = event !== 'change' &&
|
|
239
241
|
path.endsWith('.vue') &&
|
|
240
242
|
watched.folders.some((folder) => within(path, folder));
|
|
241
|
-
|
|
243
|
+
// Any module definition under the app's sources (src/): a module the app mounts that
|
|
244
|
+
// gains, changes or drops `views` changes the table, and a module without views is not
|
|
245
|
+
// in the sources to watch by name (shop: gameplus/member/Favorites unknown until a restart).
|
|
246
|
+
const definition = DEFINITION.test(basename(path)) && within(path, watched.sources);
|
|
247
|
+
if (!page && !definition && path !== watched.app && !watched.files.includes(path))
|
|
242
248
|
continue;
|
|
243
249
|
this.#invalidate(id, event, path);
|
|
244
250
|
}
|
|
@@ -257,12 +263,20 @@ export class ModulePagesSource {
|
|
|
257
263
|
...['ts', 'js'].map((ext) => join(dirname(app), '..', '..', `dokebi.modules.generated.${ext}`)),
|
|
258
264
|
...sources.flatMap((source) => ['module.ts', 'module.mts', 'module.js'].map((name) => join(dirname(source.folder), name))),
|
|
259
265
|
];
|
|
260
|
-
|
|
266
|
+
const root = join(dirname(app), '..', '..');
|
|
267
|
+
this.#watched.set(id, { app, folders, files, sources: root });
|
|
261
268
|
if (!this.#serve)
|
|
262
269
|
return;
|
|
263
270
|
for (const source of sources)
|
|
264
271
|
this.#allow(source.folder);
|
|
265
|
-
|
|
272
|
+
// The source tree too, so a definition file is seen wherever its module lives (Vite watches
|
|
273
|
+
// its root; this covers a host whose root is elsewhere).
|
|
274
|
+
this.#server?.watcher?.add([
|
|
275
|
+
app,
|
|
276
|
+
root,
|
|
277
|
+
...folders,
|
|
278
|
+
...files.filter((file) => existsSync(file)),
|
|
279
|
+
]);
|
|
266
280
|
}
|
|
267
281
|
#invalidate(id, event, path) {
|
|
268
282
|
const server = this.#server;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dokebi/template-inertia",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"description": "Inertia v3 server adapter for Dokebi: page JSON, Vite manifest assets and optional server-side rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dokebi",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"@dokebi/i18n": "0.2.5",
|
|
147
147
|
"@dokebi/session": "0.4.8",
|
|
148
148
|
"@dokebi/web": "0.4.12",
|
|
149
|
-
"@dokebi/websocket": "0.4.
|
|
149
|
+
"@dokebi/websocket": "0.4.8",
|
|
150
150
|
"@dokebi/websocket-hub": "0.4.3",
|
|
151
151
|
"@inertiajs/vue3": "3.9.1",
|
|
152
152
|
"vue": "3.5.44"
|