@adea-ai/app-framework 0.46.12 → 0.47.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.
- package/README.md +1 -1
- package/dist/app/application.d.ts +2 -1
- package/dist/app/application.js +27 -16
- package/dist/app/create-application.js +6 -3
- package/dist/appearance/appearance-host.d.ts +2 -1
- package/dist/appearance/appearance-host.js +28 -21
- package/dist/appearance/editor.js +21 -3
- package/dist/framework-source.json +1 -1
- package/dist/shell/app-shell.d.ts +1 -1
- package/dist/shell/app-shell.js +97 -87
- package/dist/shell/app-utilities.d.ts +1 -1
- package/dist/shell/app-utilities.js +42 -23
- package/dist/shell/media-query.js +12 -10
- package/dist/shell/navigation-drawer.d.ts +1 -1
- package/dist/shell/navigation-drawer.js +6 -4
- package/dist/shell/poll.js +9 -11
- package/dist/shell/settings-sections.d.ts +1 -1
- package/dist/views/app-about.d.ts +1 -1
- package/dist/views/app-about.js +1 -1
- package/dist/views/app-appearance.d.ts +2 -1
- package/dist/views/app-appearance.js +4 -4
- package/dist/views/app-help.d.ts +1 -1
- package/dist/views/app-help.js +1 -1
- package/dist/views/app-settings.d.ts +2 -1
- package/dist/views/app-settings.js +15 -10
- package/dist/views/appearance-surface.d.ts +1 -1
- package/dist/views/appearance-surface.js +116 -91
- package/dist/views/update-surface.d.ts +1 -1
- package/dist/views/update-surface.js +1 -1
- package/package.json +14 -13
- package/src/app/application.tsx +28 -32
- package/src/appearance/appearance-host.tsx +30 -19
- package/src/appearance/editor.ts +25 -3
- package/src/shell/app-shell.tsx +46 -37
- package/src/shell/app-utilities.tsx +38 -40
- package/src/shell/media-query.ts +15 -10
- package/src/shell/navigation-drawer.tsx +1 -1
- package/src/shell/poll.ts +9 -10
- package/src/shell/settings-sections.ts +1 -1
- package/src/views/app-appearance.tsx +4 -3
- package/src/views/app-settings.tsx +2 -1
- package/src/views/appearance-surface.tsx +46 -35
- package/templates/application/AGENTS.md +29 -0
- package/templates/application/src/web/main.tsx +2 -2
- package/templates/application/tsconfig.json +1 -1
- package/templates/application/vite.config.ts +1 -1
|
@@ -8,9 +8,9 @@ import { createAppearanceEditor } from "../appearance/editor.js";
|
|
|
8
8
|
import { createThemeFileImporter } from "../appearance/theme-file-importer.js";
|
|
9
9
|
import { createThemeLibraryActionFence } from "../appearance/theme-library-action-fence.js";
|
|
10
10
|
import { DEFAULT_CUSTOM_ACCENT, allThemeRecords, appearanceThemeForPreview, normalizeCustomAccent } from "../appearance/theme-record-adapter.js";
|
|
11
|
-
import { createComponent, effect, insert, mergeProps, setAttribute, template } from "
|
|
12
|
-
import { For, Show,
|
|
13
|
-
import { MonitorCog } from "lucide
|
|
11
|
+
import { createComponent, effect, insert, memo, mergeProps, setAttribute, template } from "@solidjs/web";
|
|
12
|
+
import { For, Show, createEffect, createMemo, createSignal, onCleanup, onSettled, untrack } from "solid-js";
|
|
13
|
+
import { MonitorCog } from "@lucide/solid";
|
|
14
14
|
import { defaultPreferenceStorage } from "@adea-ai/ui/lib/preference-store";
|
|
15
15
|
import { isThemeAccentId } from "@adea-ai/ui/lib/themes";
|
|
16
16
|
import { accents, getAccent } from "@adea-ai/ui/lib/accent-presets";
|
|
@@ -21,12 +21,12 @@ import { AppearanceEditor, AppearancePopover } from "@adea-ai/ui/components/comp
|
|
|
21
21
|
import { Button } from "@adea-ai/ui/components/ui/button";
|
|
22
22
|
import { Input } from "@adea-ai/ui/components/ui/input";
|
|
23
23
|
// src/views/appearance-surface.tsx
|
|
24
|
-
var _tmpl$ =
|
|
25
|
-
var _tmpl$2 =
|
|
26
|
-
var _tmpl$3 =
|
|
27
|
-
var _tmpl$4 =
|
|
28
|
-
var _tmpl$5 =
|
|
29
|
-
var _tmpl$6 =
|
|
24
|
+
var _tmpl$ = /* @__PURE__ */ template(`<div class="flex flex-col gap-4"><!><!><!>`);
|
|
25
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<footer class="flex justify-end">`);
|
|
26
|
+
var _tmpl$3 = /* @__PURE__ */ template(`<section aria-label=Appearance class="grid gap-4"><header class="flex items-start gap-3"><div><p>Changes preview immediately. Save keeps them; leaving this section without saving restores your previous appearance.`);
|
|
27
|
+
var _tmpl$4 = /* @__PURE__ */ template(`<p class="text-sm text-muted-foreground"role=status>`);
|
|
28
|
+
var _tmpl$5 = /* @__PURE__ */ template(`<ul class="flex flex-col gap-2">`);
|
|
29
|
+
var _tmpl$6 = /* @__PURE__ */ template(`<li class="flex items-center gap-2"><span class=font-medium></span><span class="text-sm text-muted-foreground"> · imported <!>`);
|
|
30
30
|
var appearanceAccentOptions = Object.freeze(accents.map((accent) => ({ ...accent })));
|
|
31
31
|
function customAccentValue(accent) {
|
|
32
32
|
return accent === "theme" || getAccent(accent) || isThemeAccentId(accent) ? "" : accent;
|
|
@@ -42,15 +42,14 @@ function AppearanceHost(props) {
|
|
|
42
42
|
const appearance = useTheme();
|
|
43
43
|
const editor = createAppearanceEditor();
|
|
44
44
|
let catalogueRequested = false;
|
|
45
|
-
createEffect(() => {
|
|
46
|
-
if (!catalogueRequested &&
|
|
45
|
+
createEffect(() => !props.popover || props.popover.open, (visible) => {
|
|
46
|
+
if (!catalogueRequested && visible) {
|
|
47
47
|
catalogueRequested = true;
|
|
48
48
|
appearance.loadCatalogue?.();
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
const draftSurface = createMemo(() => editor.draft().surface);
|
|
52
|
-
createEffect(() => {
|
|
53
|
-
const surface = draftSurface();
|
|
52
|
+
createEffect(draftSurface, (surface) => {
|
|
54
53
|
mirrorWindowSurface(surface === "translucent" ? "theme" : surface);
|
|
55
54
|
});
|
|
56
55
|
const [customAccent, setCustomAccent] = createSignal("");
|
|
@@ -58,9 +57,9 @@ function AppearanceHost(props) {
|
|
|
58
57
|
const [accentStatus, setAccentStatus] = createSignal("");
|
|
59
58
|
const [libraryOpen, setLibraryOpen] = createSignal(false);
|
|
60
59
|
const [library, setLibrary] = createSignal(readCustomThemeLibrary(defaultPreferenceStorage()));
|
|
61
|
-
|
|
60
|
+
onSettled(() => {
|
|
62
61
|
setLibrary(readCustomThemeLibrary(defaultPreferenceStorage()));
|
|
63
|
-
|
|
62
|
+
return subscribeCustomThemes(() => setLibrary(customThemes()));
|
|
64
63
|
});
|
|
65
64
|
const themes = createMemo(() => {
|
|
66
65
|
library();
|
|
@@ -79,7 +78,7 @@ function AppearanceHost(props) {
|
|
|
79
78
|
const previewPair = createMemo(() => ({
|
|
80
79
|
lightThemeId: lightThemeId(),
|
|
81
80
|
darkThemeId: darkThemeId()
|
|
82
|
-
}),
|
|
81
|
+
}), { equals: (left, right) => left.lightThemeId === right.lightThemeId && left.darkThemeId === right.darkThemeId });
|
|
83
82
|
const lightPreview = createMemo(() => appearanceThemeForPreview(miniatures().light, draftAccent(), previewPair()));
|
|
84
83
|
const darkPreview = createMemo(() => appearanceThemeForPreview(miniatures().dark, draftAccent(), previewPair()));
|
|
85
84
|
const [importStatus, setImportStatus] = createSignal("");
|
|
@@ -140,8 +139,12 @@ function AppearanceHost(props) {
|
|
|
140
139
|
};
|
|
141
140
|
});
|
|
142
141
|
const sampleVariant = () => {
|
|
143
|
-
const
|
|
144
|
-
const
|
|
142
|
+
const draft = editor.draft();
|
|
143
|
+
const variants = draftVariants({
|
|
144
|
+
lightThemeId: draft.lightThemeId,
|
|
145
|
+
darkThemeId: draft.darkThemeId
|
|
146
|
+
});
|
|
147
|
+
const mode = draft.mode;
|
|
145
148
|
if (mode === "light") return variants.light;
|
|
146
149
|
if (mode === "dark") return variants.dark;
|
|
147
150
|
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches ? variants.dark : variants.light;
|
|
@@ -181,7 +184,7 @@ function AppearanceHost(props) {
|
|
|
181
184
|
setAccentStatus("");
|
|
182
185
|
setDraft({ accent: validation.value });
|
|
183
186
|
};
|
|
184
|
-
const onChange = (patch) =>
|
|
187
|
+
const onChange = (patch) => {
|
|
185
188
|
const { accent, surface, ...rest } = patch;
|
|
186
189
|
const otherChanges = {
|
|
187
190
|
...rest,
|
|
@@ -192,7 +195,7 @@ function AppearanceHost(props) {
|
|
|
192
195
|
return;
|
|
193
196
|
}
|
|
194
197
|
setDraft(otherChanges);
|
|
195
|
-
}
|
|
198
|
+
};
|
|
196
199
|
const save = () => {
|
|
197
200
|
if (accentStatus()) return;
|
|
198
201
|
if (!editor.dirty()) {
|
|
@@ -221,8 +224,10 @@ function AppearanceHost(props) {
|
|
|
221
224
|
setAccentStatus("");
|
|
222
225
|
closeLibrary();
|
|
223
226
|
};
|
|
224
|
-
|
|
225
|
-
|
|
227
|
+
onSettled(() => {
|
|
228
|
+
openDraft();
|
|
229
|
+
return revertDraft;
|
|
230
|
+
});
|
|
226
231
|
const editorProps = {
|
|
227
232
|
get draft() {
|
|
228
233
|
return publishedDraft();
|
|
@@ -276,17 +281,18 @@ function AppearanceHost(props) {
|
|
|
276
281
|
return props.popover;
|
|
277
282
|
},
|
|
278
283
|
get fallback() {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
284
|
+
var _el$6 = _tmpl$3();
|
|
285
|
+
var _el$7 = _el$6.firstChild;
|
|
286
|
+
var _el$8 = _el$7.firstChild;
|
|
287
|
+
var _el$9 = _el$8.firstChild;
|
|
288
|
+
insert(_el$7, createComponent(MonitorCog, { "aria-hidden": "true" }), _el$8);
|
|
289
|
+
insert(_el$8, createComponent(Heading, {
|
|
290
|
+
as: "h3",
|
|
291
|
+
size: "card",
|
|
292
|
+
children: "Appearance"
|
|
293
|
+
}), _el$9);
|
|
294
|
+
insert(_el$6, createComponent(AppearanceEditor, editorProps), null);
|
|
295
|
+
return _el$6;
|
|
290
296
|
},
|
|
291
297
|
children: (control) => createComponent(AppearancePopover, mergeProps(editorProps, {
|
|
292
298
|
triggerVariant: "toolbar",
|
|
@@ -325,18 +331,21 @@ function AppearanceHost(props) {
|
|
|
325
331
|
onClose: closeLibrary,
|
|
326
332
|
title: "Manage themes",
|
|
327
333
|
description: "Import a theme file. Imported themes appear in the Light and Dark theme menus and stay on this device.",
|
|
328
|
-
|
|
334
|
+
class: "max-h-full w-full max-w-104 overflow-y-auto",
|
|
329
335
|
get children() {
|
|
330
336
|
return [(() => {
|
|
331
|
-
var _el$ = _tmpl$
|
|
337
|
+
var _el$ = _tmpl$();
|
|
338
|
+
var _el$2 = _el$.firstChild;
|
|
339
|
+
var _el$3 = _el$2.nextSibling;
|
|
340
|
+
var _el$4 = _el$3.nextSibling;
|
|
332
341
|
insert(_el$, createComponent(Button, {
|
|
333
342
|
as: "label",
|
|
334
|
-
|
|
343
|
+
class: "w-full",
|
|
335
344
|
get children() {
|
|
336
345
|
return [createComponent(Input, {
|
|
337
346
|
type: "file",
|
|
338
347
|
accept: ".json,application/json",
|
|
339
|
-
|
|
348
|
+
class: "sr-only",
|
|
340
349
|
onChange: (event) => {
|
|
341
350
|
const file = event.currentTarget.files?.[0];
|
|
342
351
|
event.currentTarget.value = "";
|
|
@@ -344,68 +353,84 @@ function AppearanceHost(props) {
|
|
|
344
353
|
}
|
|
345
354
|
}), "Import a theme file (.json)"];
|
|
346
355
|
}
|
|
347
|
-
}),
|
|
348
|
-
insert(_el$,
|
|
349
|
-
|
|
350
|
-
return importStatus();
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
356
|
+
}), _el$2);
|
|
357
|
+
insert(_el$, (() => {
|
|
358
|
+
var _c$ = memo(() => {
|
|
359
|
+
return !!importStatus();
|
|
360
|
+
});
|
|
361
|
+
return () => {
|
|
362
|
+
return _c$() ? (() => {
|
|
363
|
+
var _el$10 = _tmpl$4();
|
|
364
|
+
insert(_el$10, importStatus);
|
|
365
|
+
effect(() => importPending() ? "true" : "false", (_v$) => {
|
|
366
|
+
setAttribute(_el$10, "aria-busy", _v$);
|
|
367
|
+
});
|
|
368
|
+
return _el$10;
|
|
369
|
+
})() : void 0;
|
|
370
|
+
};
|
|
371
|
+
})(), _el$3);
|
|
372
|
+
insert(_el$, (() => {
|
|
373
|
+
var _c$2 = memo(() => {
|
|
361
374
|
return library().length > 0;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
375
|
+
});
|
|
376
|
+
return () => {
|
|
377
|
+
return _c$2() ? (() => {
|
|
378
|
+
var _el$11 = _tmpl$5();
|
|
379
|
+
insert(_el$11, createComponent(For, {
|
|
380
|
+
get each() {
|
|
381
|
+
return library();
|
|
382
|
+
},
|
|
383
|
+
children: (theme) => (() => {
|
|
384
|
+
var _el$12 = _tmpl$6();
|
|
385
|
+
var _el$13 = _el$12.firstChild;
|
|
386
|
+
var _el$14 = _el$13.nextSibling;
|
|
387
|
+
var _el$15 = _el$14.firstChild;
|
|
388
|
+
var _el$16 = _el$15.nextSibling;
|
|
389
|
+
insert(_el$13, () => {
|
|
390
|
+
return theme.name;
|
|
391
|
+
});
|
|
392
|
+
insert(_el$14, () => {
|
|
393
|
+
return theme.appearance;
|
|
394
|
+
}, _el$15);
|
|
395
|
+
insert(_el$14, () => {
|
|
396
|
+
return new Date(theme.importedAt).toLocaleDateString();
|
|
397
|
+
}, _el$16);
|
|
398
|
+
insert(_el$12, createComponent(Button, {
|
|
399
|
+
type: "button",
|
|
400
|
+
size: "sm",
|
|
401
|
+
variant: "ghost",
|
|
402
|
+
onClick: async () => {
|
|
403
|
+
const action = themeActionFence.begin();
|
|
404
|
+
themeImporter.cancel();
|
|
405
|
+
setImportPending(false);
|
|
406
|
+
themeActionFence.report(action, "");
|
|
407
|
+
const storage = defaultPreferenceStorage();
|
|
408
|
+
if (!storage) {
|
|
409
|
+
themeActionFence.report(action, "The theme could not be removed. Check your storage and try again.");
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const result = await removeCustomThemeAtomically(theme.id, storage);
|
|
413
|
+
themeActionFence.report(action, result.ok ? result.recovered ? CUSTOM_THEME_LIBRARY_RECOVERED : "" : result.error);
|
|
414
|
+
},
|
|
415
|
+
children: "Remove"
|
|
416
|
+
}), null);
|
|
417
|
+
return _el$12;
|
|
418
|
+
})()
|
|
419
|
+
}));
|
|
420
|
+
return _el$11;
|
|
421
|
+
})() : void 0;
|
|
422
|
+
};
|
|
423
|
+
})(), _el$4);
|
|
399
424
|
return _el$;
|
|
400
425
|
})(), (() => {
|
|
401
|
-
var _el$
|
|
402
|
-
insert(_el$
|
|
426
|
+
var _el$5 = _tmpl$2();
|
|
427
|
+
insert(_el$5, createComponent(Button, {
|
|
403
428
|
type: "button",
|
|
404
429
|
variant: "outline",
|
|
405
430
|
onClick: () => closeLibrary(),
|
|
406
431
|
children: "Close"
|
|
407
432
|
}));
|
|
408
|
-
return _el$
|
|
433
|
+
return _el$5;
|
|
409
434
|
})()];
|
|
410
435
|
}
|
|
411
436
|
})];
|
|
@@ -29,4 +29,4 @@ export type ApplicationUpdateSurfaceProps = {
|
|
|
29
29
|
restoreFocusRef?: Accessor<HTMLElement | undefined>;
|
|
30
30
|
};
|
|
31
31
|
/** The shared Version & updates dialog, with an optional release-channel control. */
|
|
32
|
-
export declare function ApplicationUpdateSurface(props: ApplicationUpdateSurfaceProps): import("
|
|
32
|
+
export declare function ApplicationUpdateSurface(props: ApplicationUpdateSurfaceProps): import("@solidjs/web").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mirrorUpdateState, updateChannelStore } from "../updates/update-adapter.js";
|
|
2
|
-
import { createComponent } from "
|
|
2
|
+
import { createComponent } from "@solidjs/web";
|
|
3
3
|
import { createMemo } from "solid-js";
|
|
4
4
|
import { UpdateChannelControl, UpdateDialog } from "@adea-ai/ui/components/composites/update-dialog";
|
|
5
5
|
// src/views/update-surface.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/app-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -428,37 +428,38 @@
|
|
|
428
428
|
"tar": "^7.5.22"
|
|
429
429
|
},
|
|
430
430
|
"devDependencies": {
|
|
431
|
-
"@adea-ai/ui": "0.
|
|
431
|
+
"@adea-ai/ui": "0.160.0",
|
|
432
432
|
"@babel/core": "8.1.0",
|
|
433
433
|
"@babel/preset-typescript": "^8.0.7",
|
|
434
434
|
"@happy-dom/global-registrator": "^21.0.4",
|
|
435
|
+
"@lucide/solid": "1.77.0",
|
|
435
436
|
"@playwright/test": "1.65.0",
|
|
436
437
|
"@shadcn/lint": "^0.2.5",
|
|
438
|
+
"@solidjs/compiler": "2.0.2",
|
|
439
|
+
"@solidjs/vite-plugin": "3.0.1",
|
|
440
|
+
"@solidjs/web": "2.0.3",
|
|
437
441
|
"@tailwindcss/vite": "^4.3.5",
|
|
438
442
|
"@types/bun": "^1.4.4",
|
|
439
443
|
"@types/node": "^26.6.6",
|
|
440
|
-
"
|
|
444
|
+
"@ui-sdk/core": "0.1.0-beta.13",
|
|
445
|
+
"@ui-sdk/solid": "0.1.0-beta.13",
|
|
441
446
|
"code-foundry": "1.54.1",
|
|
442
447
|
"knip": "6.45.0",
|
|
443
|
-
"lucide-solid": "^1.71.0",
|
|
444
448
|
"oxfmt": "0.78.0",
|
|
445
449
|
"oxlint": "1.93.0",
|
|
446
|
-
"solid-js": "
|
|
450
|
+
"solid-js": "2.0.3",
|
|
447
451
|
"typescript": "^7.0.2",
|
|
448
452
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.5.1",
|
|
449
|
-
"vite-plugin-solid": "2.11.16",
|
|
450
453
|
"vite-plus": "1.5.1"
|
|
451
454
|
},
|
|
452
455
|
"peerDependencies": {
|
|
453
|
-
"@adea-ai/ui": "^0.
|
|
454
|
-
"lucide
|
|
455
|
-
"
|
|
456
|
+
"@adea-ai/ui": "^0.160.0",
|
|
457
|
+
"@lucide/solid": "^1.77.0",
|
|
458
|
+
"@solidjs/web": "^2.0.3",
|
|
459
|
+
"solid-js": "^2.0.3"
|
|
456
460
|
},
|
|
457
461
|
"overrides": {
|
|
458
462
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.5.1"
|
|
459
463
|
},
|
|
460
|
-
"packageManager": "bun@1.4.4"
|
|
461
|
-
"patchedDependencies": {
|
|
462
|
-
"@kobalte/core@0.13.14": "patches/@kobalte%2Fcore@0.13.14.patch"
|
|
463
|
-
}
|
|
464
|
+
"packageManager": "bun@1.4.4"
|
|
464
465
|
}
|
package/src/app/application.tsx
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
createMemo,
|
|
4
|
-
createSignal,
|
|
5
|
-
onCleanup,
|
|
6
|
-
type Component,
|
|
7
|
-
type JSX,
|
|
8
|
-
type ParentProps,
|
|
9
|
-
} from 'solid-js'
|
|
1
|
+
import { createEffect, createMemo, createSignal, type Component, type ParentProps } from 'solid-js'
|
|
2
|
+
import { Dynamic, type JSX } from '@solidjs/web'
|
|
10
3
|
import type { ContextualSidebarProps } from '@adea-ai/ui/components/layout/contextual-sidebar'
|
|
11
4
|
import type { ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy'
|
|
12
5
|
import { ApplicationShell } from '../shell/app-shell'
|
|
@@ -95,24 +88,28 @@ export type ApplicationProps = {
|
|
|
95
88
|
|
|
96
89
|
/** Mount shared UI chrome from an app's own views and identity. */
|
|
97
90
|
export function Application(props: ApplicationProps) {
|
|
98
|
-
|
|
91
|
+
// Unset until the app navigates, so the initial view is read where it is used rather
|
|
92
|
+
// than once at the top of the component.
|
|
93
|
+
const [localView, setLocalView] = createSignal<string>()
|
|
99
94
|
const [routerRevision, setRouterRevision] = createSignal(0)
|
|
100
|
-
createEffect(
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
createEffect(
|
|
96
|
+
() => props.router,
|
|
97
|
+
(router) => {
|
|
98
|
+
if (!router?.subscribe) return
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
let active = true
|
|
101
|
+
const unsubscribe = router.subscribe(() => {
|
|
102
|
+
if (active) setRouterRevision((revision) => revision + 1)
|
|
103
|
+
})
|
|
104
|
+
return () => {
|
|
105
|
+
active = false
|
|
106
|
+
unsubscribe()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
)
|
|
113
110
|
const view = createMemo(() => {
|
|
114
111
|
routerRevision()
|
|
115
|
-
const selected = props.router?.current() ?? localView()
|
|
112
|
+
const selected = props.router?.current() ?? localView() ?? props.definition.initialView
|
|
116
113
|
return (
|
|
117
114
|
props.definition.views.find((item) => item.id === selected) ??
|
|
118
115
|
props.definition.views.find((item) => item.id === props.definition.initialView)!
|
|
@@ -130,13 +127,12 @@ export function Application(props: ApplicationProps) {
|
|
|
130
127
|
setRouterRevision((revision) => revision + 1)
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
|
-
const
|
|
134
|
-
props.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
))
|
|
130
|
+
const DefaultTheme = (providerProps: ParentProps) => (
|
|
131
|
+
<ApplicationThemeProvider {...props.theme} storageKey={props.definition.storageKey}>
|
|
132
|
+
{providerProps.children}
|
|
133
|
+
</ApplicationThemeProvider>
|
|
134
|
+
)
|
|
135
|
+
const theme = createMemo(() => props.themeProvider ?? DefaultTheme)
|
|
140
136
|
// The shell reads these props many times, and a getter would rebuild them on every read.
|
|
141
137
|
// The memos live under the theme provider so view code sees its context.
|
|
142
138
|
const Shell = () => {
|
|
@@ -182,8 +178,8 @@ export function Application(props: ApplicationProps) {
|
|
|
182
178
|
)
|
|
183
179
|
}
|
|
184
180
|
return (
|
|
185
|
-
<
|
|
181
|
+
<Dynamic component={theme()}>
|
|
186
182
|
<Shell />
|
|
187
|
-
</
|
|
183
|
+
</Dynamic>
|
|
188
184
|
)
|
|
189
185
|
}
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
createSignal,
|
|
16
16
|
useContext,
|
|
17
17
|
type Context,
|
|
18
|
-
type JSX,
|
|
19
18
|
type ParentProps,
|
|
20
19
|
} from 'solid-js'
|
|
20
|
+
import type { JSX } from '@solidjs/web'
|
|
21
21
|
|
|
22
22
|
import {
|
|
23
23
|
ThemeProvider as UiThemeProvider,
|
|
@@ -140,21 +140,29 @@ export function createAppearanceContext(ui: UiThemeContextValue): AppearanceCont
|
|
|
140
140
|
|
|
141
141
|
// The shared provider ends a preview when the selection is committed. The editor's
|
|
142
142
|
// draft is still open, though, so it keeps showing until the editor ends it.
|
|
143
|
-
createEffect(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
...ui,
|
|
150
|
-
// `themes` is a live getter on the shared provider. Spreading the context
|
|
151
|
-
// would otherwise capture only the initial catalogue snapshot.
|
|
152
|
-
get themes() {
|
|
153
|
-
return ui.themes
|
|
143
|
+
createEffect(
|
|
144
|
+
() => {
|
|
145
|
+
ui.selection()
|
|
146
|
+
return ui.previewing()
|
|
154
147
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
(previewing) => {
|
|
149
|
+
if (draft !== undefined && !previewing) ui.preview(previewSelection(draft))
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
// Copy the shared context's properties as descriptors, not by spreading: a spread reads
|
|
154
|
+
// every getter (`themes` among them) once, here, outside any tracking scope, and keeps
|
|
155
|
+
// that first snapshot.
|
|
156
|
+
const update: AppearanceContextValue['update'] = (patch) =>
|
|
157
|
+
ui.setSelection(selectionFromPreferences(patch))
|
|
158
|
+
return Object.defineProperties(
|
|
159
|
+
{},
|
|
160
|
+
{
|
|
161
|
+
...Object.getOwnPropertyDescriptors(ui),
|
|
162
|
+
update: { value: update, enumerable: true },
|
|
163
|
+
preview: { value: preview, enumerable: true },
|
|
164
|
+
}
|
|
165
|
+
) as AppearanceContextValue
|
|
158
166
|
}
|
|
159
167
|
|
|
160
168
|
/*
|
|
@@ -163,18 +171,21 @@ export function createAppearanceContext(ui: UiThemeContextValue): AppearanceCont
|
|
|
163
171
|
* copy and a reader from the other two different context objects.
|
|
164
172
|
*/
|
|
165
173
|
const CONTEXT_KEY = Symbol.for('adea.app.theme')
|
|
166
|
-
type ContextHost = { [CONTEXT_KEY]?: Context<AppearanceContextValue |
|
|
174
|
+
type ContextHost = { [CONTEXT_KEY]?: Context<AppearanceContextValue | null> }
|
|
167
175
|
|
|
168
|
-
|
|
176
|
+
// `null` is the default so that reading outside a provider returns it instead of throwing
|
|
177
|
+
// Solid's ContextNotFoundError; `useTheme` throws its own, clearer error.
|
|
178
|
+
function appearanceContext(): Context<AppearanceContextValue | null> {
|
|
169
179
|
const host = globalThis as ContextHost
|
|
170
|
-
return (host[CONTEXT_KEY] ??= createContext<AppearanceContextValue>())
|
|
180
|
+
return (host[CONTEXT_KEY] ??= createContext<AppearanceContextValue | null>(null))
|
|
171
181
|
}
|
|
172
182
|
|
|
173
183
|
function AppearanceBridge(props: ParentProps) {
|
|
174
184
|
const ui = useOptionalUiTheme()
|
|
175
185
|
if (!ui) throw new Error('The appearance bridge must render inside the shared ThemeProvider.')
|
|
176
186
|
const Context = appearanceContext()
|
|
177
|
-
|
|
187
|
+
const value = createAppearanceContext(ui)
|
|
188
|
+
return <Context value={value}>{props.children}</Context>
|
|
178
189
|
}
|
|
179
190
|
|
|
180
191
|
type ThemeProviderProps = ParentProps<{
|
package/src/appearance/editor.ts
CHANGED
|
@@ -87,9 +87,31 @@ function sameOptionalFont(
|
|
|
87
87
|
export function createAppearanceEditor(
|
|
88
88
|
committed: AppearancePreferencesV2 = defaultAppearancePreferences
|
|
89
89
|
): AppearanceEditor {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
// Solid 2 shows a write to readers only after the next flush, but the editor is a
|
|
91
|
+
// synchronous state machine: a handler sets several fields and then reads the result
|
|
92
|
+
// (Save merges, a custom accent validates against the theme the same patch chose). The
|
|
93
|
+
// plain variables are the state; the signals only tell reactive readers it changed.
|
|
94
|
+
let draftValue = committed
|
|
95
|
+
let snapshotValue = committed
|
|
96
|
+
let resetValue = false
|
|
97
|
+
const [draftChanged, setDraftChanged] = createSignal(committed)
|
|
98
|
+
const [snapshotChanged, setSnapshotChanged] = createSignal(committed)
|
|
99
|
+
const [resetChanged, setResetChanged] = createSignal(false)
|
|
100
|
+
const draft = () => (draftChanged(), draftValue)
|
|
101
|
+
const snapshot = () => (snapshotChanged(), snapshotValue)
|
|
102
|
+
const resetAll = () => (resetChanged(), resetValue)
|
|
103
|
+
const setDraft = (value: AppearancePreferencesV2) => {
|
|
104
|
+
draftValue = value
|
|
105
|
+
setDraftChanged(() => value)
|
|
106
|
+
}
|
|
107
|
+
const setSnapshot = (value: AppearancePreferencesV2) => {
|
|
108
|
+
snapshotValue = value
|
|
109
|
+
setSnapshotChanged(() => value)
|
|
110
|
+
}
|
|
111
|
+
const setResetAll = (value: boolean) => {
|
|
112
|
+
resetValue = value
|
|
113
|
+
setResetChanged(value)
|
|
114
|
+
}
|
|
93
115
|
|
|
94
116
|
return {
|
|
95
117
|
draft,
|