@crossworks/share-ui 0.300.143 → 0.400.1
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/package.json +8 -7
- package/src/app-frame-html.test.ts +4 -7
- package/src/app-frame-html.ts +16 -13
- package/src/appearance-fresh-look.test.ts +4 -4
- package/src/appearance.ts +4 -4
- package/src/canvas-frame-html.test.ts +207 -0
- package/src/canvas-frame-html.ts +257 -0
- package/src/canvas-sandbox.tsx +264 -0
- package/src/drift/color.ts +112 -0
- package/src/drift/drift.test.ts +243 -0
- package/src/drift/engine.test.ts +200 -0
- package/src/drift/engine.ts +783 -0
- package/src/drift/index.ts +32 -0
- package/src/drift/options.ts +160 -0
- package/src/drift/shaders.ts +350 -0
- package/src/drift/spec.ts +77 -0
- package/src/drift/theme.ts +152 -0
- package/src/drift-mount.ts +77 -0
- package/src/help-topics.ts +1 -0
- package/src/nav-items.ts +2 -0
- package/src/note-presenter.test.ts +20 -0
- package/src/note-presenter.tsx +15 -4
- package/src/neat-background.test.ts +0 -58
- package/src/neat-background.ts +0 -249
- package/src/neat-mount.ts +0 -82
package/src/neat-mount.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
neatConfigFromSpec,
|
|
3
|
-
type NeatBackgroundSpec,
|
|
4
|
-
type NeatThemeTokens,
|
|
5
|
-
} from './neat-background';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The one true way to put a Neat spec onto a canvas — shared by every
|
|
9
|
-
* renderer (the /s reader's vanilla runtime here in mantle; jackdaw's React
|
|
10
|
-
* NeatBackdrop wraps it too), so the hard-won WebGL specifics live exactly
|
|
11
|
-
* once:
|
|
12
|
-
*
|
|
13
|
-
* - `@firecms/neat` is dynamically imported HERE, so every consumer's
|
|
14
|
-
* bundler splits the ~80KB WebGL chunk out and only fetches it on
|
|
15
|
-
* surfaces that actually paint a gradient.
|
|
16
|
-
* - Colours are read off the live document per call — shaders take
|
|
17
|
-
* literals, not `var()` — and an unresolvable theme mounts NOTHING
|
|
18
|
-
* rather than a wrong guess; the themed surface underneath is the
|
|
19
|
-
* designed fallback.
|
|
20
|
-
* - Neat's `seed` is NOT a randomness seed: it is the animation clock's
|
|
21
|
-
* starting value (u_time, fp32 on the GPU). A raw 32-bit seed exceeds
|
|
22
|
-
* fp32 precision and collapses the shader's small offsets into ONE FLAT
|
|
23
|
-
* COLOUR. It is modded into the library's own clock range here; the full
|
|
24
|
-
* seed still drives the parameter PRNG.
|
|
25
|
-
* - `prefers-reduced-motion` freezes the animation (speed 0); the wash
|
|
26
|
-
* still paints.
|
|
27
|
-
*
|
|
28
|
-
* TIMING is the caller's job: mount only after the document's theme
|
|
29
|
-
* class/attributes have settled (in practice, from a requestAnimationFrame
|
|
30
|
-
* callback), or the tokens read here belong to the OUTGOING theme. So is
|
|
31
|
-
* CANCELLATION: this resolves after an await, so a caller that has moved on
|
|
32
|
-
* must destroy the returned handle instead of keeping it.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
export type NeatMountHandle = { destroy: () => void };
|
|
36
|
-
|
|
37
|
-
/** The four tokens the shader derives every colour from, resolved to literal
|
|
38
|
-
* values off the live document. Null when the theme is unresolvable (a test
|
|
39
|
-
* DOM, a broken stylesheet) — paint nothing rather than a wrong guess. */
|
|
40
|
-
export function readNeatThemeTokens(): NeatThemeTokens | null {
|
|
41
|
-
const cs = getComputedStyle(document.documentElement);
|
|
42
|
-
const read = (name: string) => cs.getPropertyValue(name).trim();
|
|
43
|
-
const tokens = {
|
|
44
|
-
background: read('--background'),
|
|
45
|
-
primary: read('--primary'),
|
|
46
|
-
accent: read('--accent'),
|
|
47
|
-
secondary: read('--secondary'),
|
|
48
|
-
};
|
|
49
|
-
return tokens.background && tokens.primary ? tokens : null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Build the gradient onto `canvas`. Resolves to a handle to destroy, or null
|
|
54
|
-
* when nothing mounted (unresolvable theme, WebGL unavailable) — null is the
|
|
55
|
-
* designed fallback, never an error.
|
|
56
|
-
*/
|
|
57
|
-
export async function mountNeat(
|
|
58
|
-
canvas: HTMLCanvasElement,
|
|
59
|
-
spec: NeatBackgroundSpec,
|
|
60
|
-
mode: 'light' | 'dark',
|
|
61
|
-
opts: { resolution?: number; licenseKey?: string } = {},
|
|
62
|
-
): Promise<NeatMountHandle | null> {
|
|
63
|
-
const { NeatGradient } = await import('@firecms/neat');
|
|
64
|
-
const tokens = readNeatThemeTokens();
|
|
65
|
-
if (!tokens) return null;
|
|
66
|
-
|
|
67
|
-
const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
68
|
-
const config = neatConfigFromSpec(spec, tokens, mode);
|
|
69
|
-
try {
|
|
70
|
-
return new NeatGradient({
|
|
71
|
-
...config,
|
|
72
|
-
ref: canvas,
|
|
73
|
-
seed: spec.seed % 3600,
|
|
74
|
-
resolution: opts.resolution ?? 1,
|
|
75
|
-
speed: reduced ? 0 : config.speed,
|
|
76
|
-
...(opts.licenseKey ? { licenseKey: opts.licenseKey } : {}),
|
|
77
|
-
});
|
|
78
|
-
} catch {
|
|
79
|
-
// WebGL unavailable (headless browser, exhausted contexts).
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
}
|