@hadoku/ui-shell 0.1.203 → 0.1.204
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/motion/index.js +4 -14
- package/dist/settings/ui-scale.js +5 -14
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/index.js +23 -0
- package/package.json +7 -3
package/dist/motion/index.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* the frame the system changes (an attribute written from a `change` event lags it by a frame or more:
|
|
18
18
|
* af70's flyer swayed on under reduced motion). `data-shake` is always written: script reads it.
|
|
19
19
|
*/
|
|
20
|
+
import { remember, remembered } from "../storage/index.js";
|
|
20
21
|
export const MOTION_ATTR = { motion: 'data-motion', shake: 'data-shake', ambient: 'data-ambient' };
|
|
21
22
|
let chosen = {};
|
|
22
23
|
/** Whether the system asks for less motion: the default for every switch nobody has set. */
|
|
@@ -60,10 +61,7 @@ export function clearMotion(root) {
|
|
|
60
61
|
}
|
|
61
62
|
/** Per game (`<key>`, handed in): the choices last applied in this browser, so the first frame is drawn with them. */
|
|
62
63
|
export function rememberedMotion(key) {
|
|
63
|
-
|
|
64
|
-
const raw = globalThis.localStorage?.getItem(key) ?? null;
|
|
65
|
-
if (raw === null)
|
|
66
|
-
return null;
|
|
64
|
+
return remembered(key, (raw) => {
|
|
67
65
|
const parsed = JSON.parse(raw);
|
|
68
66
|
if (typeof parsed !== 'object' || parsed === null)
|
|
69
67
|
return null;
|
|
@@ -74,18 +72,10 @@ export function rememberedMotion(key) {
|
|
|
74
72
|
out[name] = v;
|
|
75
73
|
}
|
|
76
74
|
return out;
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
75
|
+
});
|
|
81
76
|
}
|
|
82
77
|
export function rememberMotion(key, choices) {
|
|
83
|
-
|
|
84
|
-
globalThis.localStorage?.setItem(key, JSON.stringify(choices));
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
// Not remembered: the next page follows the system until prefs answer.
|
|
88
|
-
}
|
|
78
|
+
remember(key, JSON.stringify(choices));
|
|
89
79
|
}
|
|
90
80
|
export { ambientPlayState, gateSelector, motionCss } from "./css.js";
|
|
91
81
|
export { animate, animationsOf, at, hold, homeEase, markTempo, moment, quicken, runningOf, STILL, TEMPO_PROPERTY, timerSet, together, weightEase, writeDurations } from "./animate.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { appId } from "../app-id/index.js";
|
|
2
|
+
import { remember, remembered } from "../storage/index.js";
|
|
2
3
|
/*
|
|
3
4
|
* The UI scale (the operator, 2026-10-21: "add a slider to allow scaling the size of the UI").
|
|
4
5
|
*
|
|
@@ -118,25 +119,15 @@ function rememberedKey() {
|
|
|
118
119
|
* known once prefs have answered (an identity read, then the prefs read), and a page drawn at 100%
|
|
119
120
|
* until then grew a tenth for a player at 110% as its content landed — the operator's "zoom in" on the
|
|
120
121
|
* front page (2026-11-01, `e2e/front-skeleton.spec.ts`). `null` when nothing is remembered.
|
|
121
|
-
* Wrapped as `../front/shape.ts` is: a private window or a blocked store still draws the page.
|
|
122
122
|
*/
|
|
123
123
|
export function rememberedUiScale() {
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
const value = raw === null ? Number.NaN : Number(raw);
|
|
124
|
+
return remembered(rememberedKey(), (raw) => {
|
|
125
|
+
const value = Number(raw);
|
|
127
126
|
return Number.isFinite(value) ? clampUiScale(value) : null;
|
|
128
|
-
}
|
|
129
|
-
catch {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
127
|
+
});
|
|
132
128
|
}
|
|
133
129
|
export function rememberUiScale(scale) {
|
|
134
|
-
|
|
135
|
-
globalThis.localStorage?.setItem(rememberedKey(), String(clampUiScale(scale)));
|
|
136
|
-
}
|
|
137
|
-
catch {
|
|
138
|
-
// Not remembered: the next page is drawn at 100% until prefs answer, as it was before.
|
|
139
|
-
}
|
|
130
|
+
remember(rememberedKey(), String(clampUiScale(scale)));
|
|
140
131
|
}
|
|
141
132
|
/** Write the scale on `root`; at 1 nothing is written, and the stylesheet's own default stands. */
|
|
142
133
|
export function applyUiScale(root, scale) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** What this browser remembers between pages: one `localStorage` value per key. */
|
|
2
|
+
/** The value under `key` as `parse` reads it; null when nothing is stored, or the store or `parse` throws. */
|
|
3
|
+
export declare function remembered<T>(key: string, parse: (raw: string) => T | null): T | null;
|
|
4
|
+
/** Stores `value` under `key`, or forgets the key on `null`. */
|
|
5
|
+
export declare function remember(key: string, value: string | null): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** What this browser remembers between pages: one `localStorage` value per key. */
|
|
2
|
+
/** The value under `key` as `parse` reads it; null when nothing is stored, or the store or `parse` throws. */
|
|
3
|
+
export function remembered(key, parse) {
|
|
4
|
+
try {
|
|
5
|
+
const raw = globalThis.localStorage?.getItem(key) ?? null;
|
|
6
|
+
return raw === null ? null : parse(raw);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Stores `value` under `key`, or forgets the key on `null`. */
|
|
13
|
+
export function remember(key, value) {
|
|
14
|
+
try {
|
|
15
|
+
if (value === null)
|
|
16
|
+
globalThis.localStorage?.removeItem(key);
|
|
17
|
+
else
|
|
18
|
+
globalThis.localStorage?.setItem(key, value);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// A private window or blocked storage must still draw the page: unremembered is the whole fallback.
|
|
22
|
+
}
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/ui-shell",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.204",
|
|
4
|
+
"gitHead": "6212ef2571050bce6d2e17cfccd0bb5d14ef966e",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "The parts of a game's UI any game keeps: chrome, trim, room shell, embed mount, theme and settings frame, UI scale, usage counting, the sound mixer, motion and generic components. One appId parameterizes its storage keys, events and chat prefix. MIT; imports only react, react-dom, platform-wire and @wolffm/*.",
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./dist/session/index.d.ts",
|
|
47
47
|
"import": "./dist/session/index.js"
|
|
48
48
|
},
|
|
49
|
+
"./storage": {
|
|
50
|
+
"types": "./dist/storage/index.d.ts",
|
|
51
|
+
"import": "./dist/storage/index.js"
|
|
52
|
+
},
|
|
49
53
|
"./sound": {
|
|
50
54
|
"types": "./dist/sound/index.d.ts",
|
|
51
55
|
"import": "./dist/sound/index.js"
|
|
@@ -68,7 +72,7 @@
|
|
|
68
72
|
"react-dom": "^19.2.8"
|
|
69
73
|
},
|
|
70
74
|
"dependencies": {
|
|
71
|
-
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.
|
|
75
|
+
"@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.204",
|
|
72
76
|
"@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.2.3",
|
|
73
77
|
"@wolffm/themes": "npm:@hadoku/themes@^5.14.21",
|
|
74
78
|
"zod": "4.5.4"
|