@dokebi/app 0.4.6 → 0.4.7
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/dist/index.js +14 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import { stat } from 'node:fs/promises';
|
|
2
3
|
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { types } from 'node:util';
|
|
@@ -330,6 +331,8 @@ class AppRuntime {
|
|
|
330
331
|
throw new AppError('NOT_REQUIRED', `Plugin ${name} is not declared by dokebi-app`);
|
|
331
332
|
return dependency;
|
|
332
333
|
}
|
|
334
|
+
/** The @dokebi/static mount names given to app public folders so far. */
|
|
335
|
+
#publicMounts = new Set();
|
|
333
336
|
/**
|
|
334
337
|
* R1 (user instruction 2026-10-28): an app's own browser files (CSS, images, fonts, scripts)
|
|
335
338
|
* live in `src/apps/<app>/public/`, next to its views, and answer `/assets/<path>` on the
|
|
@@ -359,8 +362,16 @@ class AppRuntime {
|
|
|
359
362
|
});
|
|
360
363
|
return;
|
|
361
364
|
}
|
|
362
|
-
// A mount name is a letter, then letters and digits (D-0147)
|
|
363
|
-
|
|
365
|
+
// A mount name is a letter, then letters and digits, at most 32 (D-0147): `app` and the app
|
|
366
|
+
// name without its hyphens. Two app names can give the same one (`shop-admin` and
|
|
367
|
+
// `shopadmin`, or names alike in their first 29 characters), and a second mount of a name
|
|
368
|
+
// stops the start (INVALID_MOUNT): the later app then gets a name with a hash of its own
|
|
369
|
+
// name (audit R9-g13-2). Every app that started before keeps the mount it always had.
|
|
370
|
+
const plain = `app${name.replace(/-/g, '')}`;
|
|
371
|
+
let mount = plain.slice(0, 32);
|
|
372
|
+
if (this.#publicMounts.has(mount))
|
|
373
|
+
mount = `${plain.slice(0, 24)}${createHash('sha256').update(name).digest('hex').slice(0, 8)}`;
|
|
374
|
+
this.#publicMounts.add(mount);
|
|
364
375
|
statics.mount(mount, { prefix: '/assets', root, app: name });
|
|
365
376
|
context.logger.log('debug', 'App public folder served', {
|
|
366
377
|
app: name,
|
|
@@ -1112,7 +1123,7 @@ function missingViews(name) {
|
|
|
1112
1123
|
}
|
|
1113
1124
|
export const createPlugin = definePlugin({
|
|
1114
1125
|
name: 'dokebi-app',
|
|
1115
|
-
version: '0.4.
|
|
1126
|
+
version: '0.4.7',
|
|
1116
1127
|
core: '^0.4.0',
|
|
1117
1128
|
options: declaration,
|
|
1118
1129
|
entry: parseEntry,
|