@wasm-gaming/engine-specs 0.3.1 → 0.4.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.
@@ -1,3 +1,646 @@
1
1
  // ---- Introspectable property definitions ----
2
- export {};
2
+ /**
3
+ * The listener bookkeeping, shipped rather than described — the one piece of runtime
4
+ * code in this package.
5
+ *
6
+ * It is a **convenience, not a requirement**: the contract stays structural, so an
7
+ * engine that already owns an emitter satisfies {@link EngineSurface} without this.
8
+ * What it saves is the part everyone gets subtly wrong — iterating a copy, so a
9
+ * listener that unsubscribes mid-emit does not corrupt the loop; de-duplicating a
10
+ * listener registered twice; and keeping one throwing listener from silencing the
11
+ * rest.
12
+ *
13
+ * Hold it **privately** and hand the same instance to every carrier. That is what
14
+ * makes `sdk.on(…)` and `play.on(…)` one channel rather than two, lets a host
15
+ * subscribe before the engine exists, and keeps `emit` out of the public API — a host
16
+ * must not be able to forge an engine event.
17
+ */
18
+ export class EventEmitter {
19
+ #listeners = new Map();
20
+ /** @param listeners Registered immediately — what `EngineInit.on` carries. */
21
+ constructor(listeners) {
22
+ for (const type of Object.keys(listeners ?? {})) {
23
+ const listener = listeners?.[type];
24
+ if (listener)
25
+ this.on(type, listener);
26
+ }
27
+ }
28
+ /** Registering the same listener twice registers it once, as `EventTarget` does. */
29
+ on(type, listener) {
30
+ let set = this.#listeners.get(type);
31
+ if (!set)
32
+ this.#listeners.set(type, (set = new Set()));
33
+ set.add(listener);
34
+ return this;
35
+ }
36
+ /**
37
+ * The listener is required, as in `EventTarget`. A convenience `off(type)` dropping
38
+ * every listener for a type is a footgun on a page where two components subscribed
39
+ * independently: one unsubscribing would silence the other.
40
+ */
41
+ off(type, listener) {
42
+ const set = this.#listeners.get(type);
43
+ if (set?.delete(listener) && set.size === 0) {
44
+ this.#listeners.delete(type);
45
+ }
46
+ return this;
47
+ }
48
+ /**
49
+ * Takes the **detail**, and wraps it. The rest tuple is what lets an event with no
50
+ * detail be emitted as `emit('exit')` while still checking the ones that have one.
51
+ */
52
+ emit(type, ...[detail]) {
53
+ const set = this.#listeners.get(type);
54
+ if (!set)
55
+ return;
56
+ // Built once and frozen: every listener gets this same object, so a mutable one
57
+ // would let the first rewrite what the rest read.
58
+ const event = Object.freeze({ type, detail: detail });
59
+ // A copy: a listener may call `off()` — on itself or another — while this runs.
60
+ for (const listener of [...set]) {
61
+ try {
62
+ listener(event);
63
+ }
64
+ catch (thrown) {
65
+ // One bad listener must neither silence the rest nor vanish. Rethrowing on a
66
+ // fresh task puts it in front of `window.onerror` with its stack intact.
67
+ queueMicrotask(() => {
68
+ throw thrown;
69
+ });
70
+ }
71
+ }
72
+ }
73
+ }
74
+ /**
75
+ * Wrap a promise of a live engine in the chainable surface.
76
+ *
77
+ * Exported because it is the single most duplicated function in an engine, and an
78
+ * engine that does not extend {@link EnginePlayBase} still needs exactly this.
79
+ *
80
+ * `on` and `off` do **not** go through the chain: they reach the channel now, so a
81
+ * listener is live before the promise settles. Routing them through it would bind
82
+ * after the session opened and lose whatever was emitted while it was opening.
83
+ */
84
+ export function hydratePlay(inner, events) {
85
+ const chain = (step) => hydratePlay(inner.then(async (play) => {
86
+ await step(play);
87
+ return play;
88
+ }), events);
89
+ const hydrated = {
90
+ then: (onfulfilled, onrejected) => inner.then(onfulfilled, onrejected),
91
+ catch: (onrejected) => inner.catch(onrejected),
92
+ finally: (onfinally) => inner.finally(onfinally),
93
+ [Symbol.toStringTag]: 'PromisePlay',
94
+ config: ((patch) => patch === undefined
95
+ ? inner.then((play) => play.config())
96
+ : chain((play) => play.config(patch))),
97
+ options: ((patch) => patch === undefined
98
+ ? inner.then((play) => play.options())
99
+ : chain((play) => play.options(patch))),
100
+ assets: ((patch) => patch === undefined
101
+ ? inner.then((play) => play.assets())
102
+ : chain((play) => play.assets(patch))),
103
+ storage: ((patch) => patch === undefined
104
+ ? inner.then((play) => play.storage())
105
+ : chain((play) => play.storage(patch))),
106
+ mount: (target) => chain((play) => play.mount(target)),
107
+ on: (type, listener) => {
108
+ events.on(type, listener);
109
+ return hydrated;
110
+ },
111
+ off: (type, listener) => {
112
+ events.off(type, listener);
113
+ return hydrated;
114
+ },
115
+ restart: (options) => chain((play) => play.restart(options)),
116
+ destroy: () => inner.then((play) => play.destroy()),
117
+ };
118
+ return hydrated;
119
+ }
120
+ /**
121
+ * The live engine, with everything the contract prescribes already written: state,
122
+ * the cumulative merge, the descriptors, the chainable promise, and the channel.
123
+ *
124
+ * A subclass supplies what only it can know — {@link EnginePlayBase.open} and
125
+ * {@link EnginePlayBase.close}, optionally {@link EnginePlayBase.mounted} and
126
+ * {@link EnginePlayBase.patched} — and its properties as an {@link EngineSpec}.
127
+ *
128
+ * The spec arrives as a **constructor argument**, not an abstract field, and that is
129
+ * not a style choice: a subclass field initialiser runs *after* `super()`, so a
130
+ * `protected abstract spec` would still be `undefined` while this constructor seeded
131
+ * state from it. Passing it up makes the ordering trap impossible rather than merely
132
+ * avoided.
133
+ */
134
+ export class EnginePlayBase {
135
+ #spec;
136
+ #state;
137
+ #events;
138
+ #target;
139
+ /** The target {@link EnginePlayBase.mounted} has already been told about. */
140
+ #attached;
141
+ /**
142
+ * @param events The factory's channel. Omitted only when a play is built on its
143
+ * own; the factory always passes its own, which is what makes `sdk.on(…)` and
144
+ * `play.on(…)` one channel rather than two.
145
+ */
146
+ constructor(spec, init, events) {
147
+ this.#spec = spec;
148
+ this.#events = events ?? new EventEmitter(init?.on);
149
+ this.#state = {
150
+ config: seed(spec.config, init?.config),
151
+ options: seed(spec.options, init?.options),
152
+ assets: seed(spec.assets, init?.assets),
153
+ storage: seed(spec.storage, init?.storage),
154
+ };
155
+ // Recorded, not applied. `mounted()` is overridable, and a subclass's own fields
156
+ // are still uninitialised while this constructor runs — so the hook is deferred to
157
+ // the first `restart()`, by which point the subclass is whole.
158
+ this.#target = init?.mount;
159
+ }
160
+ /** The element is already recorded when this runs. */
161
+ mounted(target) {
162
+ void target;
163
+ }
164
+ /** A payload changed on a running engine — apply what is `live`, ignore the rest. */
165
+ patched(kind, patch) {
166
+ void kind;
167
+ void patch;
168
+ }
169
+ /**
170
+ * Emit one of this engine's own events.
171
+ *
172
+ * `protected`, so a typed host cannot forge an engine event — but be exact about
173
+ * what that buys: TypeScript erases `protected`, so this is a compile-time guard,
174
+ * not a capability boundary. Plain JavaScript can still reach it. Only the `#`
175
+ * fields below — the channel and the state — are unreachable at runtime.
176
+ */
177
+ emit(type, ...detail) {
178
+ this.#events.emit(type, ...detail);
179
+ }
180
+ /** Where the picture is, for a subclass that needs the element after `mounted()`. */
181
+ get target() {
182
+ return this.#target;
183
+ }
184
+ config(patch) {
185
+ // `arguments.length`, not `patch === undefined`: `config(undefined)` is a write of
186
+ // nothing, not a read.
187
+ if (arguments.length === 0)
188
+ return Promise.resolve(this.#describe('config'));
189
+ return this.#patch('config', patch);
190
+ }
191
+ options(patch) {
192
+ if (arguments.length === 0)
193
+ return Promise.resolve(this.#describe('options'));
194
+ return this.#patch('options', patch);
195
+ }
196
+ assets(patch) {
197
+ if (arguments.length === 0)
198
+ return Promise.resolve(this.#describe('assets'));
199
+ return this.#patch('assets', patch);
200
+ }
201
+ storage(patch) {
202
+ if (arguments.length === 0)
203
+ return Promise.resolve(this.#describe('storage'));
204
+ return this.#patch('storage', patch);
205
+ }
206
+ mount(target) {
207
+ this.#target = target;
208
+ return this.#run(() => this.#attach());
209
+ }
210
+ on(type, listener) {
211
+ this.#events.on(type, listener);
212
+ return hydratePlay(Promise.resolve(this), this.#events);
213
+ }
214
+ off(type, listener) {
215
+ this.#events.off(type, listener);
216
+ return hydratePlay(Promise.resolve(this), this.#events);
217
+ }
218
+ restart(options) {
219
+ return this.#run(async () => {
220
+ if (options)
221
+ Object.assign(this.#state.options, options);
222
+ // A target supplied to the constructor lands here, which is what makes
223
+ // `new Sdk({ mount: el }).start()` and `new Sdk().mount(el).start()` the same
224
+ // call — the rule the contract states for everything on the surface.
225
+ await this.#attach();
226
+ const opened = { ...this.#state.options };
227
+ await this.open(opened);
228
+ this.#emitCore('start', opened);
229
+ });
230
+ }
231
+ async destroy() {
232
+ await this.#guard(async () => {
233
+ await this.close();
234
+ this.#target = undefined;
235
+ this.#attached = undefined;
236
+ this.#emitCore('exit', undefined);
237
+ });
238
+ }
239
+ /** Tell the engine where it is, once per distinct target. Reparenting is legal. */
240
+ async #attach() {
241
+ if (!this.#target || this.#target === this.#attached)
242
+ return;
243
+ this.#attached = this.#target;
244
+ await this.mounted(this.#target);
245
+ }
246
+ // ---- Shared machinery ----
247
+ /** One getter's answer: the spec, with the current value written into each entry. */
248
+ #describe(kind) {
249
+ const spec = this.#spec[kind];
250
+ const state = this.#state[kind];
251
+ const out = {};
252
+ for (const key of Object.keys(spec)) {
253
+ out[key] = { ...spec[key], value: state[key] };
254
+ }
255
+ return out;
256
+ }
257
+ /** Cumulative, merged flat, one level — `undefined` is a value, not "leave alone". */
258
+ #patch(kind, patch) {
259
+ Object.assign(this.#state[kind], patch);
260
+ return this.#run(async () => {
261
+ await this.patched(kind, patch ?? {});
262
+ });
263
+ }
264
+ /** A step, as a link in the chain — and as an `error` event if it throws. */
265
+ #run(step) {
266
+ return hydratePlay(this.#guard(step), this.#events);
267
+ }
268
+ /**
269
+ * The rule that errors reach a host **both ways**: the promise rejects *and*
270
+ * `error` is emitted. Written once here rather than at every throw site.
271
+ */
272
+ async #guard(step) {
273
+ try {
274
+ await step();
275
+ return this;
276
+ }
277
+ catch (thrown) {
278
+ const error = thrown instanceof Error ? thrown : new Error(String(thrown));
279
+ this.#emitCore('error', error);
280
+ throw error;
281
+ }
282
+ }
283
+ /**
284
+ * The core events, emitted from here rather than by a subclass.
285
+ *
286
+ * The cast is the one thing TypeScript will not check here: `emit` takes a rest
287
+ * tuple that is conditional on the detail type, and that conditional stays
288
+ * unresolved while `P` is still a type parameter. It is sound — `EventsOf<P>`
289
+ * always contains `CoreEvents<P>` by construction — and confining it to this one
290
+ * method is why the three call sites above read plainly.
291
+ */
292
+ #emitCore(type, detail) {
293
+ // Cast the channel, not the method: pulling `emit` out into a variable would call
294
+ // it unbound, and it reads its listeners off `this`.
295
+ const events = this.#events;
296
+ events.emit(type, detail);
297
+ }
298
+ }
299
+ /** Starting state: every `default` the spec declares, then whatever `init` overrides. */
300
+ function seed(spec, patch) {
301
+ const state = {};
302
+ for (const [key, property] of Object.entries(spec)) {
303
+ if (property.default !== undefined)
304
+ state[key] = property.default;
305
+ }
306
+ return Object.assign(state, patch);
307
+ }
308
+ /**
309
+ * The factory, with everything the contract prescribes already written: the
310
+ * cumulative init, the synchronous chain, the channel that outlives every session,
311
+ * and one live engine per factory.
312
+ *
313
+ * A subclass supplies its static identity and {@link EngineSDKBase.createPlay}.
314
+ */
315
+ export class EngineSDKBase {
316
+ #init;
317
+ #play;
318
+ /**
319
+ * Created before any engine exists and handed to every carrier downstream. That is
320
+ * what lets a host subscribe to an error thrown while the first session opens.
321
+ */
322
+ events;
323
+ constructor(init) {
324
+ this.#init = { ...init };
325
+ this.events = new EventEmitter(init?.on);
326
+ }
327
+ config(patch) {
328
+ if (arguments.length === 0)
329
+ return this.#pending().config();
330
+ return this.#patch('config', patch);
331
+ }
332
+ options(patch) {
333
+ if (arguments.length === 0)
334
+ return this.#pending().options();
335
+ return this.#patch('options', patch);
336
+ }
337
+ assets(patch) {
338
+ if (arguments.length === 0)
339
+ return this.#pending().assets();
340
+ return this.#patch('assets', patch);
341
+ }
342
+ storage(patch) {
343
+ if (arguments.length === 0)
344
+ return this.#pending().storage();
345
+ return this.#patch('storage', patch);
346
+ }
347
+ /** Recorded now, applied when the engine exists — same call as `new Sdk({ mount })`. */
348
+ mount(target) {
349
+ this.#init.mount = target;
350
+ this.#play?.mount(target);
351
+ return this;
352
+ }
353
+ on(type, listener) {
354
+ this.events.on(type, listener);
355
+ return this;
356
+ }
357
+ off(type, listener) {
358
+ this.events.off(type, listener);
359
+ return this;
360
+ }
361
+ /**
362
+ * The only way in. On a live engine it reopens the session rather than building a
363
+ * second one: a factory governs at most one engine.
364
+ */
365
+ start(options) {
366
+ this.#play ??= this.createPlay(this.#init, this.events);
367
+ return this.#play.restart(options);
368
+ }
369
+ /** Answers a read before there is an engine: the settings the next one will use. */
370
+ #pending() {
371
+ return this.#play ?? this.createPlay(this.#init, this.events);
372
+ }
373
+ #patch(kind, patch) {
374
+ this.#init[kind] = { ...this.#init[kind], ...patch };
375
+ // A live engine gets it too, so the factory does not silently describe a state
376
+ // the engine is not in.
377
+ if (this.#play && patch)
378
+ this.#play[kind](patch);
379
+ return this;
380
+ }
381
+ }
382
+ /** Keyboard → action (`KeyboardEvent.key`). */
383
+ export const UI_KEYMAP = Object.freeze({
384
+ ArrowUp: 'up',
385
+ ArrowDown: 'down',
386
+ ArrowLeft: 'left',
387
+ ArrowRight: 'right',
388
+ Enter: 'accept',
389
+ ' ': 'accept',
390
+ Escape: 'back',
391
+ Backspace: 'back',
392
+ Tab: 'more',
393
+ v: 'more',
394
+ V: 'more',
395
+ ContextMenu: 'more',
396
+ q: 'prev',
397
+ Q: 'prev',
398
+ e: 'next',
399
+ E: 'next',
400
+ F1: 'menu',
401
+ });
402
+ /**
403
+ * Gamepad button index (W3C "standard" mapping) → action. A = 0, B = 1, X = 2, Y = 3,
404
+ * LB = 4, RB = 5, Select = 8, Start = 9, d-pad = 12–15. Select + Start together is
405
+ * `menu` as well (see {@link createInput}).
406
+ */
407
+ export const UI_PADMAP = Object.freeze({
408
+ 0: 'accept',
409
+ 1: 'back',
410
+ 2: 'more',
411
+ 3: 'more',
412
+ 4: 'prev',
413
+ 5: 'next',
414
+ 9: 'menu',
415
+ 12: 'up',
416
+ 13: 'down',
417
+ 14: 'left',
418
+ 15: 'right',
419
+ });
420
+ /** Hold-to-repeat for directions: first repeat after `delay` ms, then every `interval` ms. */
421
+ export const UI_REPEAT = Object.freeze({ delay: 380, interval: 110, axis: 0.6 });
422
+ const DIRECTIONS = new Set(['up', 'down', 'left', 'right']);
423
+ const isEditable = (target) => {
424
+ const element = target;
425
+ if (!element)
426
+ return false;
427
+ if (element.isContentEditable)
428
+ return true;
429
+ return element.tagName === 'INPUT' || element.tagName === 'TEXTAREA' || element.tagName === 'SELECT';
430
+ };
431
+ /**
432
+ * The scheme's runtime: keyboard and gamepads become {@link UiAction}s.
433
+ *
434
+ * Keyboard: `keydown` mapped through {@link UI_KEYMAP} (keys typed into form fields
435
+ * are left alone). Gamepads: polled each frame through {@link UI_PADMAP} and the left
436
+ * stick; directions repeat with {@link UI_REPEAT}; Select + Start together is `menu`
437
+ * (and then neither fires on its own). While {@link UiInput.suspend | suspended} (in
438
+ * game) the game gets every input except the menu combo: Select + Start and the
439
+ * `menuKeys` (Escape, F1) still arrive, as `menu`, so the pause menu can always open.
440
+ */
441
+ export function createInput(options = {}) {
442
+ const target = options.target ?? globalThis;
443
+ const capture = options.capture ?? true;
444
+ const swallow = options.swallow ?? true;
445
+ const keymap = options.keymap ?? UI_KEYMAP;
446
+ const menuKeys = new Set(options.menuKeys ?? ['Escape', 'F1']);
447
+ const padmap = options.padmap ?? UI_PADMAP;
448
+ const now = options.now ?? (() => globalThis.performance?.now() ?? Date.now());
449
+ const gamepads = options.gamepads ??
450
+ (() => (globalThis.navigator?.getGamepads?.() ?? []));
451
+ const schedule = options.schedule === undefined
452
+ ? (globalThis.requestAnimationFrame?.bind(globalThis) ?? null)
453
+ : options.schedule;
454
+ const listeners = new Set();
455
+ let suspended = false;
456
+ let destroyed = false;
457
+ let polling = false;
458
+ const held = new Map();
459
+ const fire = (action, detail) => {
460
+ for (const listener of listeners)
461
+ listener(action, detail);
462
+ };
463
+ const onKey = (event) => {
464
+ if (destroyed)
465
+ return;
466
+ const key = event;
467
+ if (suspended) {
468
+ if (!menuKeys.has(key.key) || key.repeat)
469
+ return;
470
+ key.preventDefault();
471
+ key.stopPropagation();
472
+ fire('menu', { source: 'keyboard', repeat: false });
473
+ return;
474
+ }
475
+ if (isEditable(key.target) && key.key !== 'Escape')
476
+ return;
477
+ const action = keymap[key.key];
478
+ if (!action)
479
+ return;
480
+ if (swallow) {
481
+ key.preventDefault();
482
+ key.stopPropagation();
483
+ }
484
+ fire(action, { source: 'keyboard', repeat: key.repeat === true });
485
+ };
486
+ const pressed = (pad) => {
487
+ const actions = new Set();
488
+ const select = pad.buttons[8]?.pressed === true;
489
+ const start = pad.buttons[9]?.pressed === true;
490
+ if (select && start)
491
+ actions.add('menu');
492
+ pad.buttons.forEach((button, index) => {
493
+ if (!button.pressed)
494
+ return;
495
+ if ((index === 8 || index === 9) && select && start)
496
+ return;
497
+ const action = padmap[index];
498
+ if (action)
499
+ actions.add(action);
500
+ });
501
+ const [x = 0, y = 0] = pad.axes;
502
+ if (x < -UI_REPEAT.axis)
503
+ actions.add('left');
504
+ if (x > UI_REPEAT.axis)
505
+ actions.add('right');
506
+ if (y < -UI_REPEAT.axis)
507
+ actions.add('up');
508
+ if (y > UI_REPEAT.axis)
509
+ actions.add('down');
510
+ return actions;
511
+ };
512
+ const poll = () => {
513
+ if (destroyed)
514
+ return;
515
+ const t = now();
516
+ const active = new Set();
517
+ for (const pad of gamepads())
518
+ if (pad)
519
+ for (const action of pressed(pad))
520
+ active.add(action);
521
+ for (const action of active) {
522
+ const state = held.get(action);
523
+ if (!state) {
524
+ held.set(action, { since: t, last: t });
525
+ // In game only the Select + Start combo gets through (plain Start is the game's).
526
+ const combo = action === 'menu' && gamepads().some((p) => p?.buttons[8]?.pressed && p.buttons[9]?.pressed);
527
+ if (!suspended || combo)
528
+ fire(action, { source: 'gamepad', repeat: false });
529
+ }
530
+ else if (DIRECTIONS.has(action) &&
531
+ t - state.since >= UI_REPEAT.delay &&
532
+ t - state.last >= UI_REPEAT.interval) {
533
+ state.last = t;
534
+ if (!suspended)
535
+ fire(action, { source: 'gamepad', repeat: true });
536
+ }
537
+ }
538
+ for (const action of [...held.keys()])
539
+ if (!active.has(action))
540
+ held.delete(action);
541
+ };
542
+ const loop = () => {
543
+ if (destroyed || !schedule)
544
+ return;
545
+ poll();
546
+ schedule(loop);
547
+ };
548
+ const startPolling = () => {
549
+ if (polling || !schedule)
550
+ return;
551
+ polling = true;
552
+ schedule(loop);
553
+ };
554
+ target.addEventListener('keydown', onKey, { capture });
555
+ target.addEventListener('gamepadconnected', startPolling);
556
+ if (gamepads().some(Boolean))
557
+ startPolling();
558
+ return {
559
+ on(listener) {
560
+ listeners.add(listener);
561
+ return () => listeners.delete(listener);
562
+ },
563
+ suspend() {
564
+ suspended = true;
565
+ },
566
+ resume() {
567
+ suspended = false;
568
+ },
569
+ get suspended() {
570
+ return suspended;
571
+ },
572
+ poll,
573
+ destroy() {
574
+ destroyed = true;
575
+ listeners.clear();
576
+ held.clear();
577
+ target.removeEventListener('keydown', onKey, { capture });
578
+ target.removeEventListener('gamepadconnected', startPolling);
579
+ },
580
+ };
581
+ }
582
+ /**
583
+ * Spatial navigation: the candidate a direction leads to from `from`, or null.
584
+ *
585
+ * Only candidates whose centre lies ahead in that direction count; among them the
586
+ * nearest wins, with sideways distance weighted double so "down" prefers the item
587
+ * straight below over a closer one off to the side.
588
+ */
589
+ export function nextFocus(from, candidates, direction) {
590
+ const centre = (el) => {
591
+ const r = el.getBoundingClientRect();
592
+ return { x: r.left + r.width / 2, y: r.top + r.height / 2 };
593
+ };
594
+ const origin = centre(from);
595
+ let best = null;
596
+ let bestScore = Infinity;
597
+ for (const candidate of candidates) {
598
+ if (candidate === from)
599
+ continue;
600
+ const c = centre(candidate);
601
+ const dx = c.x - origin.x;
602
+ const dy = c.y - origin.y;
603
+ const ahead = direction === 'up' ? -dy : direction === 'down' ? dy : direction === 'left' ? -dx : dx;
604
+ if (ahead <= 0.5)
605
+ continue;
606
+ const side = direction === 'up' || direction === 'down' ? Math.abs(dx) : Math.abs(dy);
607
+ const score = ahead + side * 2;
608
+ if (score < bestScore) {
609
+ bestScore = score;
610
+ best = candidate;
611
+ }
612
+ }
613
+ return best;
614
+ }
615
+ /**
616
+ * The look every menu shares, as CSS custom properties: the focus ring, radii, type
617
+ * faces, colours and spacing. Apps read them with `var(--wg-…)`; {@link uiTokensCss}
618
+ * writes them into a stylesheet.
619
+ */
620
+ export const UI_TOKENS = Object.freeze({
621
+ '--wg-bg': '#07080c',
622
+ '--wg-surface': 'rgb(18 20 28 / 0.78)',
623
+ '--wg-line': 'rgb(255 255 255 / 0.12)',
624
+ '--wg-text': '#f4f6fb',
625
+ '--wg-muted': '#8e97a9',
626
+ '--wg-ok': '#4ade80',
627
+ '--wg-danger': '#f87171',
628
+ '--wg-focus': '#ffffff',
629
+ '--wg-focus-ring': '0 0 0 3px #ffffff',
630
+ '--wg-radius': '22px',
631
+ '--wg-radius-small': '12px',
632
+ '--wg-gap': '16px',
633
+ '--wg-font-display': "'Unbounded Variable', 'Unbounded', system-ui, sans-serif",
634
+ '--wg-font-ui': "'Inter Variable', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif",
635
+ '--wg-ease': 'cubic-bezier(0.2, 0.8, 0.2, 1)',
636
+ '--wg-safe-top': 'env(safe-area-inset-top, 0px)',
637
+ '--wg-safe-bottom': 'env(safe-area-inset-bottom, 0px)',
638
+ });
639
+ /** `UI_TOKENS` as a CSS rule, e.g. for a `<style>` an app injects. */
640
+ export function uiTokensCss(selector = ':root') {
641
+ const body = Object.entries(UI_TOKENS)
642
+ .map(([name, value]) => ` ${name}: ${value};`)
643
+ .join('\n');
644
+ return `${selector} {\n${body}\n}\n`;
645
+ }
3
646
  //# sourceMappingURL=engine-specs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-specs.js","sourceRoot":"","sources":["../src/engine-specs.ts"],"names":[],"mappings":"AAAA,gDAAgD"}
1
+ {"version":3,"file":"engine-specs.js","sourceRoot":"","sources":["../src/engine-specs.ts"],"names":[],"mappings":"AAAA,gDAAgD;AA+GhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IACd,UAAU,GAAG,IAAI,GAAG,EAAwC,CAAC;IAEtE,8EAA8E;IAC9E,YAAY,SAA6B;QACvC,KAAK,MAAM,IAAI,IAAI,MAAM,C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