@buffcore/admin-shell 0.8.41 → 0.8.42
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/admin.js +2 -1
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Button.js +7 -2
- package/dist/components/DeviceFrame.d.ts +6 -1
- package/dist/components/DeviceFrame.js +2 -2
- package/dist/components/look.d.ts +5 -0
- package/dist/components/look.js +5 -0
- package/dist/console-settings.js +4 -1
- package/dist/design-fonts.d.ts +5 -0
- package/dist/design-fonts.js +20 -0
- package/dist/prototype/PageLook.js +3 -2
- package/dist/prototype/create.d.ts +3 -1
- package/dist/prototype/create.js +0 -1
- package/dist/prototype/page.d.ts +19 -2
- package/dist/prototype/page.js +20 -2
- package/dist/prototype/shown.js +1 -1
- package/dist/prototype/viewer.d.ts +2 -0
- package/dist/prototype/viewer.js +6 -2
- package/dist/workbench/app/ServedPrototype.js +19 -1
- package/dist/workbench/app/StudioApp.js +29 -20
- package/dist/workbench/app/actions.d.ts +3 -1
- package/dist/workbench/app/actions.js +8 -2
- package/dist/workbench/app/ask-card.d.ts +10 -0
- package/dist/workbench/app/ask-card.js +34 -0
- package/dist/workbench/app/chat-session.d.ts +32 -0
- package/dist/workbench/app/chat.d.ts +37 -0
- package/dist/workbench/app/frame.js +4 -2
- package/dist/workbench/app/host-part-loader.d.ts +5 -2
- package/dist/workbench/app/host-part-module.d.ts +17 -0
- package/dist/workbench/app/host-part-module.js +55 -0
- package/dist/workbench/app/host-parts.d.ts +2 -11
- package/dist/workbench/app/host-parts.js +53 -67
- package/dist/workbench/app/level-choice.d.ts +3 -0
- package/dist/workbench/app/mount.d.ts +4 -1
- package/dist/workbench/app/mount.js +2 -2
- package/dist/workbench/app/panel-cards.d.ts +3 -3
- package/dist/workbench/app/panel-cards.js +3 -2
- package/dist/workbench/app/places.d.ts +17 -2
- package/dist/workbench/app/places.js +14 -2
- package/dist/workbench/app/scene-address.d.ts +10 -0
- package/dist/workbench/app/scene-address.js +14 -0
- package/dist/workbench/app/studio-post.js +1 -0
- package/dist/workbench/app/test/loop-fixture.d.ts +22 -0
- package/dist/workbench/app/usePrototypeUi.js +14 -0
- package/dist/workbench/app/work.d.ts +7 -7
- package/dist/workbench/host-theme.d.ts +3 -0
- package/dist/workbench/host-theme.js +14 -0
- package/dist/workbench/index.d.ts +1 -0
- package/dist/workbench/index.js +1 -0
- package/dist/workbench/studio/frame/HostRailEntries.d.ts +3 -0
- package/dist/workbench/studio/frame/HostRailEntries.js +15 -0
- package/dist/workbench/studio/frame/HostSide.d.ts +6 -0
- package/dist/workbench/studio/frame/HostSide.js +31 -0
- package/dist/workbench/studio/frame/LevelChip.js +2 -1
- package/dist/workbench/studio/frame/LevelChoices.js +24 -8
- package/dist/workbench/studio/frame/NeverAskSetting.d.ts +7 -0
- package/dist/workbench/studio/frame/NeverAskSetting.js +24 -0
- package/dist/workbench/studio/frame/PanelList.js +5 -2
- package/dist/workbench/studio/frame/PanelNotice.js +2 -1
- package/dist/workbench/studio/frame/PanelScenes.d.ts +5 -0
- package/dist/workbench/studio/frame/PanelScenes.js +38 -0
- package/dist/workbench/studio/frame/PermissionAskCard.d.ts +18 -0
- package/dist/workbench/studio/frame/PermissionAskCard.js +60 -0
- package/dist/workbench/studio/frame/PermissionAskFold.d.ts +12 -0
- package/dist/workbench/studio/frame/PermissionAskFold.js +54 -0
- package/dist/workbench/studio/frame/Place.d.ts +6 -2
- package/dist/workbench/studio/frame/Place.js +13 -5
- package/dist/workbench/studio/frame/SettingsSheet.js +6 -1
- package/dist/workbench/studio/frame/StudioRail.js +2 -1
- package/dist/workbench/studio/frame/panelControls.d.ts +17 -0
- package/dist/workbench/studio/i18n/frame.en.d.ts +26 -0
- package/dist/workbench/studio/i18n/frame.en.js +26 -0
- package/dist/workbench/studio/i18n/frame.es.json +27 -1
- package/dist/workbench/studio/i18n/levels.en.d.ts +5 -0
- package/dist/workbench/studio/i18n/levels.en.js +5 -0
- package/dist/workbench/studio/i18n/levels.es.json +6 -1
- package/dist/workbench/studio/i18n/loop.en.d.ts +4 -0
- package/dist/workbench/studio/i18n/loop.en.js +4 -0
- package/dist/workbench/studio/i18n/loop.es.json +4 -0
- package/dist/workbench/studio/i18n/save.en.d.ts +1 -3
- package/dist/workbench/studio/i18n/save.en.js +13 -15
- package/dist/workbench/studio/i18n/save.es.json +14 -16
- package/dist/workbench/studio/i18n/structure.en.d.ts +6 -0
- package/dist/workbench/studio/i18n/structure.en.js +6 -0
- package/dist/workbench/studio/i18n/structure.es.d.ts +6 -0
- package/dist/workbench/studio/i18n/structure.es.js +6 -0
- package/dist/workbench/studio/loop/PrototypePage.js +4 -3
- package/dist/workbench/studio/loop/PrototypeScenes.js +1 -2
- package/dist/workbench/studio/loop/PrototypeSimplePage.js +7 -6
- package/dist/workbench/studio/loop/PrototypeSnapshot.js +5 -1
- package/dist/workbench/studio/loop/ReviewedSave.d.ts +1 -1
- package/dist/workbench/studio/loop/ReviewedSave.js +2 -10
- package/dist/workbench/studio/loop/ServedBrand.js +3 -3
- package/dist/workbench/studio/loop/StructurePage.d.ts +2 -0
- package/dist/workbench/studio/loop/StructurePage.js +1 -1
- package/dist/workbench/studio/loop/StructurePreview.js +4 -4
- package/dist/workbench/studio/loop/StructurePrompts.js +9 -4
- package/dist/workbench/studio/loop/step-state.d.ts +1 -1
- package/dist/workbench/studio/loop/step-state.js +9 -8
- package/dist/workbench/studio/loop/structure-answers.d.ts +8 -0
- package/dist/workbench/studio/loop/structure-answers.js +34 -0
- package/dist/workbench/studio/loop/usePlanningDraft.js +2 -1
- package/dist/workbench/studio/loop/usePlanningSave.d.ts +16 -2
- package/dist/workbench/studio/loop/usePlanningSave.js +40 -2
- package/dist/workbench/studio/loop/usePrototypeRecord.js +5 -4
- package/dist/workbench/studio/loop/useReviewedSave.d.ts +9 -4
- package/dist/workbench/studio/loop/useReviewedSave.js +89 -30
- package/dist/workbench/studio/run/LiveServers.js +1 -1
- package/dist/workbench/studio/run/ReleasePage.js +1 -1
- package/dist/workbench/studio/run/ReleasesPage.js +2 -2
- package/dist/workbench/studio/run/ServedRelease.js +1 -1
- package/dist/workbench/studio/work/work-test-data.d.ts +3 -0
- package/package.json +6 -6
- package/vite.d.ts +6 -1
- package/vite.js +78 -5
package/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `@buffcore/admin-shell/vite`: what the admin console needs from its Vite app. Plain JavaScript, so
|
|
2
2
|
// Node loads it in a product's vite.config.ts from node_modules.
|
|
3
|
-
import { readFileSync } from 'node:fs';
|
|
4
|
-
import { dirname, join } from 'node:path';
|
|
3
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
7
|
// import.meta.url, which Vite keeps when it bundles a config that imports this file.
|
|
@@ -9,6 +9,37 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
9
9
|
|
|
10
10
|
export const SERVICE_WORKER = '/firebase-messaging-sw.js';
|
|
11
11
|
export const MANIFEST = '/manifest.webmanifest';
|
|
12
|
+
/** The element of the console's page that lists the design system's font files. */
|
|
13
|
+
export const FONT_LIST = 'buffcore-fonts';
|
|
14
|
+
|
|
15
|
+
const FONT_TYPES = { woff2: 'font/woff2', woff: 'font/woff', ttf: 'font/ttf', otf: 'font/otf' };
|
|
16
|
+
const fontType = (/** @type {string} */ file) =>
|
|
17
|
+
FONT_TYPES[/** @type {keyof typeof FONT_TYPES} */ (file.split('.').pop()?.toLowerCase() ?? '')];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The design system's font files (`design/fonts/` beside the product's `buffcore.config.ts`, the
|
|
21
|
+
* nearest one up from the console's folder, inside its repository), read each time: none when
|
|
22
|
+
* the folder is missing.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} from The console's folder.
|
|
25
|
+
* @returns {string[]}
|
|
26
|
+
*/
|
|
27
|
+
export function designFontFiles(from) {
|
|
28
|
+
let dir = resolve(from);
|
|
29
|
+
while (!existsSync(join(dir, 'buffcore.config.ts'))) {
|
|
30
|
+
if (dirname(dir) === dir || existsSync(join(dir, '.git'))) return [];
|
|
31
|
+
dir = dirname(dir);
|
|
32
|
+
}
|
|
33
|
+
const fonts = join(dir, 'design', 'fonts');
|
|
34
|
+
try {
|
|
35
|
+
return readdirSync(fonts, { withFileTypes: true })
|
|
36
|
+
.filter((entry) => entry.isFile() && fontType(entry.name))
|
|
37
|
+
.map((entry) => join(fonts, entry.name))
|
|
38
|
+
.sort();
|
|
39
|
+
} catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
12
43
|
|
|
13
44
|
/**
|
|
14
45
|
* Serves BuffCore's files at the console's root, in development and in the build, so a product
|
|
@@ -18,6 +49,10 @@ export const MANIFEST = '/manifest.webmanifest';
|
|
|
18
49
|
* @param {{ name: string }} options The name under the icon on the home screen.
|
|
19
50
|
*/
|
|
20
51
|
export function adminConsole({ name }) {
|
|
52
|
+
// Where the console's files are served from, once Vite has read its config.
|
|
53
|
+
let root = process.cwd();
|
|
54
|
+
let base = '/';
|
|
55
|
+
const fontPath = (/** @type {string} */ file) => `_fonts/${encodeURIComponent(basename(file))}`;
|
|
21
56
|
const files = {
|
|
22
57
|
[SERVICE_WORKER]: {
|
|
23
58
|
type: 'text/javascript',
|
|
@@ -39,22 +74,60 @@ export function adminConsole({ name }) {
|
|
|
39
74
|
const address = URL.parse(process.env.APE_ADMIN_URL ?? '');
|
|
40
75
|
return { server: { host: address?.hostname === '[::1]' ? '::1' : '127.0.0.1' } };
|
|
41
76
|
},
|
|
77
|
+
/** @param {{ root: string, base: string }} config */
|
|
78
|
+
configResolved(config) {
|
|
79
|
+
root = config.root;
|
|
80
|
+
base = config.base;
|
|
81
|
+
},
|
|
42
82
|
/** @param {{ middlewares: { use: (handler: (req: { url?: string }, res: import('node:http').ServerResponse, next: () => void) => void) => void } }} server */
|
|
43
83
|
configureServer(server) {
|
|
44
84
|
server.middlewares.use((req, res, next) => {
|
|
45
|
-
const
|
|
85
|
+
const path = new URL(req.url ?? '/', 'http://console').pathname;
|
|
86
|
+
// The design system's fonts, by name: only the files listed, never a path.
|
|
87
|
+
const font = path.startsWith(`${base}_fonts/`)
|
|
88
|
+
? designFontFiles(root).find((file) => `${base}${fontPath(file)}` === path)
|
|
89
|
+
: undefined;
|
|
90
|
+
if (font) {
|
|
91
|
+
res.setHeader('Content-Type', fontType(font) ?? 'application/octet-stream');
|
|
92
|
+
res.end(readFileSync(font));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const file = files[path];
|
|
46
96
|
if (!file) return next();
|
|
47
97
|
res.setHeader('Content-Type', file.type);
|
|
48
98
|
res.end(file.source);
|
|
49
99
|
});
|
|
50
100
|
},
|
|
51
|
-
/** @this {{ emitFile: (file: { type: 'asset'; fileName: string; source: string }) => void }} */
|
|
101
|
+
/** @this {{ emitFile: (file: { type: 'asset'; fileName: string; source: string | Uint8Array }) => void }} */
|
|
52
102
|
generateBundle() {
|
|
53
103
|
for (const [path, file] of Object.entries(files))
|
|
54
104
|
this.emitFile({ type: 'asset', fileName: path.slice(1), source: file.source });
|
|
105
|
+
for (const font of designFontFiles(root))
|
|
106
|
+
this.emitFile({
|
|
107
|
+
type: 'asset',
|
|
108
|
+
fileName: decodeURIComponent(fontPath(font)),
|
|
109
|
+
source: readFileSync(font),
|
|
110
|
+
});
|
|
55
111
|
},
|
|
112
|
+
/**
|
|
113
|
+
* The manifest's link, and the design system's font files for the console to match to its
|
|
114
|
+
* theme's families (`designFontCss`): a list the page reads, never runs.
|
|
115
|
+
*/
|
|
56
116
|
transformIndexHtml() {
|
|
57
|
-
|
|
117
|
+
const fonts = designFontFiles(root).map((font) => `${base}${fontPath(font)}`);
|
|
118
|
+
return [
|
|
119
|
+
{ tag: 'link', attrs: { rel: 'manifest', href: MANIFEST }, injectTo: 'head' },
|
|
120
|
+
...(fonts.length
|
|
121
|
+
? [
|
|
122
|
+
{
|
|
123
|
+
tag: 'script',
|
|
124
|
+
attrs: { type: 'application/json', id: FONT_LIST },
|
|
125
|
+
children: JSON.stringify(fonts).replaceAll('<', '\\u003c'),
|
|
126
|
+
injectTo: 'head',
|
|
127
|
+
},
|
|
128
|
+
]
|
|
129
|
+
: []),
|
|
130
|
+
];
|
|
58
131
|
},
|
|
59
132
|
};
|
|
60
133
|
}
|