@celestia-island/hikari 0.55.370 → 0.55.371
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 +4 -3
- package/src/components/HkEmergencyAlert.layering.contract.test.ts +85 -24
- package/src/components/HkEmergencyAlert.scss +26 -7
- package/src/mermaid/index.ts +1 -0
- package/src/mermaid/wasmEngine.test.ts +36 -0
- package/src/mermaid/wasmEngine.ts +43 -0
- package/src/scene3d/holographicFleetSpec.ts +5 -1
- package/src/scene3d/wasmFleetSpec.ts +61 -0
- package/src/utils/qr/qrEncoder.test.ts +1 -0
- package/src/utils/qr/qrEncoder.ts +24 -16
- package/src/wasm/mermaid/hikari_wasm_mermaid.d.ts +21 -0
- package/src/wasm/mermaid/hikari_wasm_mermaid.js +6144 -0
- package/src/wasm/mermaid/interfaces/hikari-mermaid-types.d.ts +4 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-environment.d.ts +2 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-exit.d.ts +3 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-stderr.d.ts +3 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-stdin.d.ts +3 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-stdout.d.ts +3 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-terminal-input.d.ts +8 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-terminal-output.d.ts +8 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-terminal-stderr.d.ts +3 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-terminal-stdin.d.ts +3 -0
- package/src/wasm/mermaid/interfaces/wasi-cli-terminal-stdout.d.ts +3 -0
- package/src/wasm/mermaid/interfaces/wasi-clocks-monotonic-clock.d.ts +4 -0
- package/src/wasm/mermaid/interfaces/wasi-io-error.d.ts +8 -0
- package/src/wasm/mermaid/interfaces/wasi-io-poll.d.ts +10 -0
- package/src/wasm/mermaid/interfaces/wasi-io-streams.d.ts +38 -0
- package/src/wasm/mermaid/interfaces/wasi-random-insecure-seed.d.ts +2 -0
- package/src/wasm/qr/hikari_wasm_qr.d.ts +27 -0
- package/src/wasm/qr/hikari_wasm_qr.js +6173 -0
- package/src/wasm/qr/interfaces/hikari-qr-types.d.ts +24 -0
- package/src/wasm/qr/interfaces/wasi-cli-environment.d.ts +2 -0
- package/src/wasm/qr/interfaces/wasi-cli-exit.d.ts +3 -0
- package/src/wasm/qr/interfaces/wasi-cli-stderr.d.ts +3 -0
- package/src/wasm/qr/interfaces/wasi-cli-stdin.d.ts +3 -0
- package/src/wasm/qr/interfaces/wasi-cli-stdout.d.ts +3 -0
- package/src/wasm/qr/interfaces/wasi-cli-terminal-input.d.ts +8 -0
- package/src/wasm/qr/interfaces/wasi-cli-terminal-output.d.ts +8 -0
- package/src/wasm/qr/interfaces/wasi-cli-terminal-stderr.d.ts +3 -0
- package/src/wasm/qr/interfaces/wasi-cli-terminal-stdin.d.ts +3 -0
- package/src/wasm/qr/interfaces/wasi-cli-terminal-stdout.d.ts +3 -0
- package/src/wasm/qr/interfaces/wasi-clocks-monotonic-clock.d.ts +4 -0
- package/src/wasm/qr/interfaces/wasi-io-error.d.ts +8 -0
- package/src/wasm/qr/interfaces/wasi-io-poll.d.ts +10 -0
- package/src/wasm/qr/interfaces/wasi-io-streams.d.ts +38 -0
- package/src/wasm/scene3d/hikari_wasm_scene3d.d.ts +22 -0
- package/src/wasm/scene3d/hikari_wasm_scene3d.js +6403 -0
- package/src/wasm/scene3d/interfaces/hikari-scene3d-types.d.ts +33 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-environment.d.ts +2 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-exit.d.ts +3 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-stderr.d.ts +3 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-stdin.d.ts +3 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-stdout.d.ts +3 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-terminal-input.d.ts +8 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-terminal-output.d.ts +8 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-terminal-stderr.d.ts +3 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-terminal-stdin.d.ts +3 -0
- package/src/wasm/scene3d/interfaces/wasi-cli-terminal-stdout.d.ts +3 -0
- package/src/wasm/scene3d/interfaces/wasi-clocks-monotonic-clock.d.ts +4 -0
- package/src/wasm/scene3d/interfaces/wasi-io-error.d.ts +8 -0
- package/src/wasm/scene3d/interfaces/wasi-io-poll.d.ts +10 -0
- package/src/wasm/scene3d/interfaces/wasi-io-streams.d.ts +38 -0
- package/src/wasm/scene3d/interfaces/wasi-random-insecure-seed.d.ts +2 -0
- package/src/utils/qr/qrcode-generator.d.ts +0 -19
- package/src/utils/qr/qrcode-generator.js +0 -2289
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celestia-island/hikari",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.371",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@types/three": "^0.185",
|
|
74
|
+
"pinia": "^3",
|
|
74
75
|
"three": "^0.185",
|
|
75
|
-
"vue": "^3"
|
|
76
|
-
"pinia": "^3"
|
|
76
|
+
"vue": "^3"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@celestia-island/tairitsu-transport": "^0.2",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"marked": "^18"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
+
"@bytecodealliance/preview2-shim": "^0.31",
|
|
89
90
|
"@types/node": "^*",
|
|
90
91
|
"@types/three": "^0.185",
|
|
91
92
|
"@vitejs/plugin-vue": "^*",
|
|
@@ -25,34 +25,59 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
25
25
|
|
|
26
26
|
function sheet(): string {
|
|
27
27
|
const raw = readFileSync(join(here, "HkEmergencyAlert.scss"), "utf-8");
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
28
|
+
// Comments are stripped before ANY assertion (the registerAnimations
|
|
29
|
+
// parity convention): a commented-out declaration is not a
|
|
30
|
+
// declaration. Block comments first (a leftover `/* scrim */` fed
|
|
31
|
+
// the dark-ink pin — R4), then // comments ANYWHERE on a line —
|
|
32
|
+
// trailing `position: relative; // --hk-emergency-scrim: …` fed the
|
|
33
|
+
// pins with the real declaration gone (R7). The whitespace anchor
|
|
34
|
+
// keeps `https://` inside a value alive.
|
|
35
|
+
return raw
|
|
36
|
+
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
37
|
+
.replace(/(^|\s)\/\/.*$/gm, "$1");
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
/**
|
|
37
|
-
* webkit scrollbar rule). Assertions about the LAYER must
|
|
38
|
-
*
|
|
39
|
-
* `pointer-events: none` lines,
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
function
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
for (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
/** EVERY `.hk-emergency { … }` root rule, brace-balanced (each may
|
|
41
|
+
* nest the webkit scrollbar rule). Assertions about the LAYER must
|
|
42
|
+
* bind to these blocks — the band's pseudo-elements carry their own
|
|
43
|
+
* `pointer-events: none` lines (R3 M6), and a SECOND root block later
|
|
44
|
+
* in the sheet silently overrides the first (R7's white-scrim append),
|
|
45
|
+
* so the tests below also require the collection to hold exactly one.
|
|
46
|
+
* Comment-blindness is handled upstream in sheet(); braces inside
|
|
47
|
+
* comments are gone before the walk runs. */
|
|
48
|
+
function rootBlocks(css: string): string[] {
|
|
49
|
+
const marker = ".hk-emergency {";
|
|
50
|
+
const blocks: string[] = [];
|
|
51
|
+
let from = 0;
|
|
52
|
+
for (;;) {
|
|
53
|
+
const start = css.indexOf(marker, from);
|
|
54
|
+
if (start < 0) break;
|
|
55
|
+
let depth = 0;
|
|
56
|
+
let end = -1;
|
|
57
|
+
for (let i = start; i < css.length; i++) {
|
|
58
|
+
if (css[i] === "{") depth++;
|
|
59
|
+
else if (css[i] === "}") {
|
|
60
|
+
depth--;
|
|
61
|
+
if (depth === 0) {
|
|
62
|
+
end = i + 1;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
53
66
|
}
|
|
67
|
+
if (end < 0) throw new Error("unbalanced braces in a .hk-emergency root rule");
|
|
68
|
+
blocks.push(css.slice(start, end));
|
|
69
|
+
from = end;
|
|
70
|
+
}
|
|
71
|
+
return blocks;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The single root rule, or a thrown failure naming the drift. */
|
|
75
|
+
function rootBlock(css: string): string {
|
|
76
|
+
const blocks = rootBlocks(css);
|
|
77
|
+
if (blocks.length !== 1) {
|
|
78
|
+
throw new Error(`expected exactly one .hk-emergency root rule, found ${blocks.length}`);
|
|
54
79
|
}
|
|
55
|
-
|
|
80
|
+
return blocks[0];
|
|
56
81
|
}
|
|
57
82
|
|
|
58
83
|
describe("emergency alert layering contract", () => {
|
|
@@ -85,6 +110,42 @@ describe("emergency alert layering contract", () => {
|
|
|
85
110
|
expect(css.match(/pointer-events:\s*auto;/g)?.length).toBe(1);
|
|
86
111
|
});
|
|
87
112
|
|
|
113
|
+
it("the scrim stays dark ink — never a mode-inverting background token", () => {
|
|
114
|
+
// 0.55.370 pointed the scrim at --color-background: a WHITE veil in
|
|
115
|
+
// light themes, so the page never darkened and the takeover read
|
|
116
|
+
// as a pastel banner (2026-11-14 field report). Darkening is what
|
|
117
|
+
// a scrim does, in every mode — pin the ink and ban the inversion
|
|
118
|
+
// vector outright (R3 M1 replayed the bug with every test green).
|
|
119
|
+
const css = sheet();
|
|
120
|
+
// A second root block would silently override the first (R7).
|
|
121
|
+
expect(rootBlocks(css)).toHaveLength(1);
|
|
122
|
+
const root = rootBlock(css);
|
|
123
|
+
expect(root).not.toContain("var(--color-background");
|
|
124
|
+
// Dark-ink DIRECTION, not a literal: every RGB channel must be
|
|
125
|
+
// dark (<60) and the veil substantial (alpha >= 40%). A future
|
|
126
|
+
// retune (55%→52%, 9 11 16→12 14 20) passes; a light recolor
|
|
127
|
+
// (200 210 220) fails on semantics, not on mismatched text.
|
|
128
|
+
// EXACTLY ONE declaration per property, counted by NAME in any
|
|
129
|
+
// value form: a later duplicate wins the cascade silently, so a
|
|
130
|
+
// first-match-is-dark pin let `white` / var() forms slip past
|
|
131
|
+
// (R5's rgb probe; R6's white/var probes). Counting the name also
|
|
132
|
+
// guards the wash the same way (R6: an old tone-form wash could be
|
|
133
|
+
// appended under a correct color-mix line).
|
|
134
|
+
expect(root.match(/--hk-emergency-scrim\s*:/g)?.length, "exactly one --hk-emergency-scrim declaration").toBe(1);
|
|
135
|
+
// The one declaration must be a LITERAL dark rgb ink (darkening is
|
|
136
|
+
// mode-independent; symbolic or token forms may invert in light
|
|
137
|
+
// themes — the 0.55.370 bug).
|
|
138
|
+
const scrim = root.match(/--hk-emergency-scrim:\s*rgb\(\s*(\d+)\s+(\d+)\s+(\d+)\s*\/\s*(\d+)%\s*\);/);
|
|
139
|
+
expect(scrim, "the scrim must be a literal rgb(…) dark ink").not.toBeNull();
|
|
140
|
+
const [, r, g, b, a] = scrim!.map(Number) as unknown as number[];
|
|
141
|
+
expect(Math.max(r, g, b)).toBeLessThan(60);
|
|
142
|
+
expect(a).toBeGreaterThanOrEqual(40);
|
|
143
|
+
// Wash: exactly one, and it derives from the LINE (the theme's
|
|
144
|
+
// authoritative signal color) — R2's derivation-mismatch finding.
|
|
145
|
+
expect(root.match(/--hk-emergency-wash\s*:/g)?.length, "exactly one --hk-emergency-wash declaration").toBe(1);
|
|
146
|
+
expect(root).toMatch(/--hk-emergency-wash:\s*color-mix\(in srgb, var\(--hk-emergency-line\)/);
|
|
147
|
+
});
|
|
148
|
+
|
|
88
149
|
it("long content stays reachable: the layer scrolls and the band safe-centers", () => {
|
|
89
150
|
// A fixed full-height layer never grows the document, so clipped
|
|
90
151
|
// content would strand the actions forever (R2 finding 5). The
|
|
@@ -11,13 +11,25 @@
|
|
|
11
11
|
@use "../styles/polyfill" as *;
|
|
12
12
|
|
|
13
13
|
.hk-emergency {
|
|
14
|
-
// Severity
|
|
14
|
+
// Severity defaults; a theme re-points these per band state. The
|
|
15
|
+
// LINE is the theme's authoritative signal color: line-soft /
|
|
16
|
+
// edge-glow / wash all derive from it through color-mix, so a
|
|
17
|
+
// re-point (endfield's hazard yellow) carries soft edges, glow AND
|
|
18
|
+
// wash with it — no mismatched token pair. --hk-emergency-tone
|
|
19
|
+
// stays the ICON's ink (deliberately tied to the HkErrorLanding
|
|
20
|
+
// recipe's token colors).
|
|
15
21
|
--hk-emergency-tone: rgb(var(--color-error, 226 84 84));
|
|
16
22
|
--hk-emergency-line: var(--hk-emergency-tone);
|
|
17
|
-
--hk-emergency-line-soft:
|
|
18
|
-
--hk-emergency-
|
|
23
|
+
--hk-emergency-line-soft: color-mix(in srgb, var(--hk-emergency-line) 55%, transparent);
|
|
24
|
+
--hk-emergency-edge-glow: color-mix(in srgb, var(--hk-emergency-line) 22%, transparent);
|
|
25
|
+
--hk-emergency-wash: color-mix(in srgb, var(--hk-emergency-line) 14%, transparent);
|
|
19
26
|
--hk-emergency-band-bg: rgb(var(--color-surface, 24 26 32) / 96%);
|
|
20
|
-
|
|
27
|
+
// The scrim is DARK INK ON PURPOSE — theme-independent. Pointing it
|
|
28
|
+
// at --color-background (the 0.55.370 default) makes it a WHITE veil
|
|
29
|
+
// in light themes: the page never darkens, and the takeover reads as
|
|
30
|
+
// a pastel banner on plain paper (2026-11-14 field report). A scrim
|
|
31
|
+
// darkens what is behind it; that is mode-independent.
|
|
32
|
+
--hk-emergency-scrim: rgb(9 11 16 / 55%);
|
|
21
33
|
|
|
22
34
|
position: fixed;
|
|
23
35
|
// Chrome-band leg: in native hosts the window titlebar owns the top
|
|
@@ -53,8 +65,6 @@
|
|
|
53
65
|
.hk-emergency.is-warning {
|
|
54
66
|
--hk-emergency-tone: rgb(var(--color-warning, 222 168 62));
|
|
55
67
|
--hk-emergency-line: var(--hk-emergency-tone);
|
|
56
|
-
--hk-emergency-line-soft: rgb(var(--color-warning, 222 168 62) / 55%);
|
|
57
|
-
--hk-emergency-wash: rgb(var(--color-warning, 222 168 62) / 10%);
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
.hk-emergency-scrim {
|
|
@@ -81,13 +91,20 @@
|
|
|
81
91
|
var(--hk-emergency-band-bg);
|
|
82
92
|
border-top: 2px solid var(--hk-emergency-line);
|
|
83
93
|
border-bottom: 2px solid var(--hk-emergency-line);
|
|
94
|
+
// Elevation: the band is the one LIT surface over a darkened page —
|
|
95
|
+
// a deep soft shadow lifts it off the scrim so the takeover reads
|
|
96
|
+
// as layered, not pasted (0.55.370 field note: without this the
|
|
97
|
+
// light band floated flat on the light page).
|
|
98
|
+
box-shadow: 0 24px 72px rgb(3 5 9 / 42%);
|
|
84
99
|
text-align: center;
|
|
85
100
|
color: rgb(var(--color-text, 236 238 242));
|
|
86
101
|
font-family: var(--font-sans, system-ui, sans-serif);
|
|
87
102
|
|
|
88
103
|
// FUI double line: a second, fainter signal line hugging each edge
|
|
89
104
|
// just inside the solid one — reads as instrument chrome, not a
|
|
90
|
-
// decorative frame.
|
|
105
|
+
// decorative frame. The hairline carries a soft tone glow so the
|
|
106
|
+
// edges read as EMISSIVE signal lines (the restrained FUI note):
|
|
107
|
+
// light emitted by the alert, not decoration painted on.
|
|
91
108
|
&::before,
|
|
92
109
|
&::after {
|
|
93
110
|
content: "";
|
|
@@ -96,6 +113,7 @@
|
|
|
96
113
|
right: 0;
|
|
97
114
|
height: 1px;
|
|
98
115
|
background: var(--hk-emergency-line-soft);
|
|
116
|
+
box-shadow: 0 0 14px var(--hk-emergency-edge-glow);
|
|
99
117
|
pointer-events: none;
|
|
100
118
|
}
|
|
101
119
|
&::before {
|
|
@@ -277,3 +295,4 @@ html.reduce-motion {
|
|
|
277
295
|
animation: none;
|
|
278
296
|
}
|
|
279
297
|
}
|
|
298
|
+
|
package/src/mermaid/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { MermaidParserEngine } from "./engine";
|
|
|
18
18
|
import { MermaidParseError, parseMermaid } from "./parse";
|
|
19
19
|
|
|
20
20
|
export { MermaidParseError, parseMermaid };
|
|
21
|
+
export { wasmMermaidEngine } from "./wasmEngine";
|
|
21
22
|
export type {
|
|
22
23
|
MermaidDoc,
|
|
23
24
|
MermaidGraphDoc,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import type { MermaidGraphDoc } from "./types";
|
|
5
|
+
import { wasmMermaidEngine } from "./wasmEngine";
|
|
6
|
+
|
|
7
|
+
describe("wasmMermaidEngine", () => {
|
|
8
|
+
it("parses a graph through the wasm component", () => {
|
|
9
|
+
const doc = wasmMermaidEngine.parse("graph TD\n A --> B\n B --> C") as MermaidGraphDoc;
|
|
10
|
+
expect(doc).not.toBeNull();
|
|
11
|
+
expect(doc!.kind).toBe("graph");
|
|
12
|
+
expect(doc!.direction).toBe("TD");
|
|
13
|
+
expect(doc!.nodes.map((n) => n.id)).toEqual(["A", "B", "C"]);
|
|
14
|
+
expect(doc!.edges).toHaveLength(2);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("serializes shapes to the TS contract literals", () => {
|
|
18
|
+
const doc = wasmMermaidEngine.parse("flowchart LR\n S[Start] --> D{Check}") as MermaidGraphDoc;
|
|
19
|
+
expect(doc).not.toBeNull();
|
|
20
|
+
const shapes = doc!.nodes.map((n) => n.shape);
|
|
21
|
+
expect(shapes).toContain("rect");
|
|
22
|
+
expect(shapes).toContain("diamond");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("returns null on non-diagram input", () => {
|
|
26
|
+
expect(wasmMermaidEngine.parse("this is not a diagram")).toBeNull();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("falls through to the TS parser for sequence diagrams", () => {
|
|
30
|
+
const doc = wasmMermaidEngine.parse(
|
|
31
|
+
"sequenceDiagram\n Alice->>Bob: Hello\n Bob-->>Alice: Hi",
|
|
32
|
+
);
|
|
33
|
+
expect(doc).not.toBeNull();
|
|
34
|
+
expect(doc!.kind).toBe("sequence");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// wasmEngine.ts — the first-party mermaid parser engine backed by the
|
|
2
|
+
// hikari-wasm-mermaid component (Rust, pest-driven, the semantic reference
|
|
3
|
+
// hikari's TS port was a mirror of).
|
|
4
|
+
//
|
|
5
|
+
// The wasm component's parse() returns the JSON-serialized MermaidDiagram;
|
|
6
|
+
// this engine deserializes it back into the TS MermaidDoc shape. When the
|
|
7
|
+
// component supports only the graph subset (this first wave), the TS
|
|
8
|
+
// fallback parser handles the remaining diagram types — the dispatch is
|
|
9
|
+
// invisible to callers.
|
|
10
|
+
|
|
11
|
+
import type { MermaidDoc } from "./types";
|
|
12
|
+
import type { MermaidParserEngine } from "./engine";
|
|
13
|
+
import { parseMermaid } from "./parse";
|
|
14
|
+
import { parse } from "../wasm/mermaid/hikari_wasm_mermaid.js";
|
|
15
|
+
|
|
16
|
+
/** Check whether the wasm component handles this diagram type. */
|
|
17
|
+
function wasmHandles(source: string): boolean {
|
|
18
|
+
// First wave: graph/flowchart only.
|
|
19
|
+
return /^\s*(graph|flowchart)\b/i.test(source);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const wasmMermaidEngine: MermaidParserEngine = {
|
|
23
|
+
parse(source: string): MermaidDoc | null {
|
|
24
|
+
if (wasmHandles(source)) {
|
|
25
|
+
const result = parse(source);
|
|
26
|
+
if (result.json) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(result.json) as MermaidDoc;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
// Fall back to the TS parser for diagram types the wasm component
|
|
36
|
+
// does not cover yet (sequence/class/gantt/pie/quadrant).
|
|
37
|
+
try {
|
|
38
|
+
return parseMermaid(source);
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { hashIdToUnit, lerpPalette, type Vec3 } from "../utils/scene3d";
|
|
27
|
+
import { buildFleetSceneSpecWasm } from "./wasmFleetSpec";
|
|
27
28
|
|
|
28
29
|
/** Public, renderer-agnostic node input for HkStarSystem. Every HUD
|
|
29
30
|
* field is caller-owned data: the component never invents traffic, alerts
|
|
@@ -299,7 +300,10 @@ export function buildFleetSceneSpec(rows: FleetRowLike[]): FleetSceneSpec {
|
|
|
299
300
|
export function buildHolographicFleetSpec(
|
|
300
301
|
nodes: readonly StarSystemBodyInput[],
|
|
301
302
|
): FleetSceneSpec {
|
|
302
|
-
|
|
303
|
+
// Route through the wasm component (the Rust layout engine); the TS
|
|
304
|
+
// buildFleetSceneSpec stays as the reference implementation and test
|
|
305
|
+
// oracle — holographicFleetSpec.test.ts pins it against golden fixtures.
|
|
306
|
+
return buildFleetSceneSpecWasm(nodes.map((node) => ({
|
|
303
307
|
node_id: node.id,
|
|
304
308
|
tier: node.role === "star" ? 3 : 2,
|
|
305
309
|
station_count: Number.isFinite(node.endpointCount)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// wasmFleetSpec.ts — the wasm-backed fleet scene spec builder.
|
|
2
|
+
//
|
|
3
|
+
// Bridges hikari-wasm-scene3d (the Rust component that computes the
|
|
4
|
+
// deterministic solar-system layout) into the TS FleetSceneSpec shape the
|
|
5
|
+
// three.js renderer consumes. The TS buildFleetSceneSpec stays as the
|
|
6
|
+
// reference implementation and test oracle; this bridge routes production
|
|
7
|
+
// traffic through the wasm component.
|
|
8
|
+
|
|
9
|
+
import { buildFleetScene as wasmBuild } from "../wasm/scene3d/hikari_wasm_scene3d.js";
|
|
10
|
+
import type { FleetBodySpec, FleetRowLike, FleetSceneSpec } from "./holographicFleetSpec";
|
|
11
|
+
import type { Vec3 } from "../utils/scene3d";
|
|
12
|
+
|
|
13
|
+
/** WIT tuple → TS Vec3 (both are 3-element arrays at runtime). */
|
|
14
|
+
const toVec3 = (t: readonly [number, number, number]): Vec3 => [t[0], t[1], t[2]];
|
|
15
|
+
|
|
16
|
+
/** Adapt the wasm component's FleetBodySpec to the TS shape. */
|
|
17
|
+
function adaptBody(b: {
|
|
18
|
+
id: string; label: string; status: string; online: boolean; detail: string;
|
|
19
|
+
role: string; color: readonly [number, number, number]; radius: number;
|
|
20
|
+
orbitCenter: readonly [number, number, number]; orbitRadius: number;
|
|
21
|
+
orbitPeriodSec: number; orbitPhase: number; orbitTilt: number;
|
|
22
|
+
spinPeriodSec: number; satellites: number; satelliteTotal: number;
|
|
23
|
+
}): FleetBodySpec {
|
|
24
|
+
return {
|
|
25
|
+
id: b.id,
|
|
26
|
+
label: b.label,
|
|
27
|
+
status: b.status,
|
|
28
|
+
online: b.online,
|
|
29
|
+
detail: b.detail,
|
|
30
|
+
role: b.role === "star" ? "star" : "planet",
|
|
31
|
+
color: toVec3(b.color),
|
|
32
|
+
radius: b.radius,
|
|
33
|
+
orbitCenter: toVec3(b.orbitCenter),
|
|
34
|
+
orbitRadius: b.orbitRadius,
|
|
35
|
+
orbitPeriodSec: b.orbitPeriodSec,
|
|
36
|
+
orbitPhase: b.orbitPhase,
|
|
37
|
+
orbitTilt: b.orbitTilt,
|
|
38
|
+
spinPeriodSec: b.spinPeriodSec,
|
|
39
|
+
satellites: b.satellites,
|
|
40
|
+
satelliteTotal: b.satelliteTotal,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Build the fleet scene spec through the wasm component. */
|
|
45
|
+
export function buildFleetSceneSpecWasm(rows: readonly FleetRowLike[]): FleetSceneSpec {
|
|
46
|
+
const wasmRows = rows.map((r) => ({
|
|
47
|
+
nodeId: r.node_id,
|
|
48
|
+
tier: r.tier,
|
|
49
|
+
stationCount: r.station_count,
|
|
50
|
+
label: r.label,
|
|
51
|
+
status: r.status,
|
|
52
|
+
online: r.online,
|
|
53
|
+
detail: r.detail,
|
|
54
|
+
}));
|
|
55
|
+
const result = wasmBuild(wasmRows);
|
|
56
|
+
return {
|
|
57
|
+
stars: result.stars.map(adaptBody),
|
|
58
|
+
planets: result.planets.map(adaptBody),
|
|
59
|
+
hasRegistryCore: result.hasRegistryCore,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
// Thin TS wrapper over the
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// Thin TS wrapper over the in-tree Rust QR encoder (hikari-wasm-qr,
|
|
2
|
+
// compiled to a wasm component via tairitsu's wasm32-wasip2 target).
|
|
3
|
+
//
|
|
4
|
+
// The Rust `qrcode` crate (same author and algorithm as the vendored
|
|
5
|
+
// qrcode-generator.js it replaces) provides the encoding core; the wasm
|
|
6
|
+
// component exports a WIT-defined `encode(text, options) -> QrCode`
|
|
7
|
+
// contract, and this wrapper adapts it to the `qrMatrix` API HkQrCode
|
|
8
|
+
// has always consumed — the component swap is invisible to callers.
|
|
6
9
|
|
|
7
|
-
import
|
|
10
|
+
import { encode } from "../../wasm/qr/hikari_wasm_qr.js";
|
|
8
11
|
|
|
9
12
|
export type QrErrorCorrectionLevel = "L" | "M" | "Q" | "H";
|
|
10
13
|
|
|
@@ -18,20 +21,25 @@ export interface QrMatrixOptions {
|
|
|
18
21
|
/**
|
|
19
22
|
* Encode `text` as a QR module matrix. `true` = dark module.
|
|
20
23
|
*
|
|
21
|
-
* When `typeNumber` is 0 (default), the
|
|
22
|
-
*
|
|
24
|
+
* When `typeNumber` is 0 (default), the encoder auto-selects the smallest
|
|
25
|
+
* version that fits the payload and the chosen ECC level. Throws when the
|
|
26
|
+
* payload overflows the largest version (same contract as the vendored
|
|
27
|
+
* generator it replaced).
|
|
23
28
|
*/
|
|
24
29
|
export function qrMatrix(text: string, opts: QrMatrixOptions = {}): boolean[][] {
|
|
25
|
-
const level = opts.errorCorrectionLevel ?? "M"
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
const level = (opts.errorCorrectionLevel ?? "M").toLowerCase() as
|
|
31
|
+
| "l" | "m" | "q" | "h";
|
|
32
|
+
const result = encode(text, {
|
|
33
|
+
ecc: level,
|
|
34
|
+
version: opts.typeNumber ?? 0,
|
|
35
|
+
});
|
|
36
|
+
const size = result.size;
|
|
31
37
|
const matrix: boolean[][] = [];
|
|
32
|
-
for (let row = 0; row <
|
|
38
|
+
for (let row = 0; row < size; row++) {
|
|
33
39
|
const line: boolean[] = [];
|
|
34
|
-
for (let col = 0; col <
|
|
40
|
+
for (let col = 0; col < size; col++) {
|
|
41
|
+
line.push(result.modules[row * size + col]);
|
|
42
|
+
}
|
|
35
43
|
matrix.push(line);
|
|
36
44
|
}
|
|
37
45
|
return matrix;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// world root:component/root
|
|
2
|
+
export type ParseResult = import('./interfaces/hikari-mermaid-types.js').ParseResult;
|
|
3
|
+
export type * as HikariMermaidTypes from './interfaces/hikari-mermaid-types.js'; // import hikari:mermaid/types
|
|
4
|
+
export type * as WasiCliEnvironment0212 from './interfaces/wasi-cli-environment.js'; // import wasi:cli/environment@0.2.12
|
|
5
|
+
export type * as WasiCliExit0212 from './interfaces/wasi-cli-exit.js'; // import wasi:cli/exit@0.2.12
|
|
6
|
+
export type * as WasiCliStderr0212 from './interfaces/wasi-cli-stderr.js'; // import wasi:cli/stderr@0.2.12
|
|
7
|
+
export type * as WasiCliStdin0212 from './interfaces/wasi-cli-stdin.js'; // import wasi:cli/stdin@0.2.12
|
|
8
|
+
export type * as WasiCliStdout0212 from './interfaces/wasi-cli-stdout.js'; // import wasi:cli/stdout@0.2.12
|
|
9
|
+
export type * as WasiCliTerminalInput0212 from './interfaces/wasi-cli-terminal-input.js'; // import wasi:cli/terminal-input@0.2.12
|
|
10
|
+
export type * as WasiCliTerminalOutput0212 from './interfaces/wasi-cli-terminal-output.js'; // import wasi:cli/terminal-output@0.2.12
|
|
11
|
+
export type * as WasiCliTerminalStderr0212 from './interfaces/wasi-cli-terminal-stderr.js'; // import wasi:cli/terminal-stderr@0.2.12
|
|
12
|
+
export type * as WasiCliTerminalStdin0212 from './interfaces/wasi-cli-terminal-stdin.js'; // import wasi:cli/terminal-stdin@0.2.12
|
|
13
|
+
export type * as WasiCliTerminalStdout0212 from './interfaces/wasi-cli-terminal-stdout.js'; // import wasi:cli/terminal-stdout@0.2.12
|
|
14
|
+
export type * as WasiClocksMonotonicClock0212 from './interfaces/wasi-clocks-monotonic-clock.js'; // import wasi:clocks/monotonic-clock@0.2.12
|
|
15
|
+
export type * as WasiIoError0212 from './interfaces/wasi-io-error.js'; // import wasi:io/error@0.2.12
|
|
16
|
+
export type * as WasiIoPoll0212 from './interfaces/wasi-io-poll.js'; // import wasi:io/poll@0.2.12
|
|
17
|
+
export type * as WasiIoStreams0212 from './interfaces/wasi-io-streams.js'; // import wasi:io/streams@0.2.12
|
|
18
|
+
export type * as WasiRandomInsecureSeed0212 from './interfaces/wasi-random-insecure-seed.js'; // import wasi:random/insecure-seed@0.2.12
|
|
19
|
+
export function parse(source: string): ParseResult;
|
|
20
|
+
/** Permanently stop this instance and dispose guest-owned host resources. */
|
|
21
|
+
export const _util: { stop(): void; whenIdle(): Promise<void>; };
|