justerm-wasm-decode 0.6.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 +131 -0
- package/colors.d.ts +27 -0
- package/colors.js +48 -0
- package/justerm_wasm_decode.d.ts +159 -0
- package/justerm_wasm_decode.js +9 -0
- package/justerm_wasm_decode_bg.js +575 -0
- package/justerm_wasm_decode_bg.wasm +0 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# justerm-wasm-decode
|
|
2
|
+
|
|
3
|
+
The **canonical web decoder** for [justerm](https://github.com/kihyun1998/justerm)'s binary wire
|
|
4
|
+
format — the engine's native `decode` compiled to WASM, so a web consumer shares *one* decoder with
|
|
5
|
+
the native backend instead of hand-writing (and re-syncing) a TypeScript mirror.
|
|
6
|
+
|
|
7
|
+
Typical data path: the native engine `encode`s a damage frame in your backend, the bytes cross your
|
|
8
|
+
IPC (e.g. a Tauri Channel), and in the webview this package decodes them into renderer-ready columns.
|
|
9
|
+
|
|
10
|
+
The decoder owns the **fixed formats and standards** (the wire records, the colour-ref encoding, the
|
|
11
|
+
flag bit positions, the xterm 16–255 colour formula). *Theme values* (your 16 ANSI colours + default
|
|
12
|
+
fg/bg) and *render policy* (inverse/dim/bold→bright, the font atlas, the cursor) stay yours. See
|
|
13
|
+
[ADR-0008](https://github.com/kihyun1998/justerm/blob/master/docs/adr/0008-wasm-decode-binding-separate-crate.md).
|
|
14
|
+
|
|
15
|
+
> Version-locked to the `justerm` crate: this package's version equals the engine version, so pinning
|
|
16
|
+
> one `justerm` version gives you a matching encoder (native) + decoder (this). `wireVersion()` lets
|
|
17
|
+
> you assert agreement at load.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install justerm-wasm-decode
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { decodeFrame, buildPalette, flags, wireVersion } from "justerm-wasm-decode";
|
|
29
|
+
import { resolveRgb, decodeColorRef, FG, BG } from "justerm-wasm-decode/colors.js";
|
|
30
|
+
|
|
31
|
+
// Bundler target (Vite/webpack): the above imports work directly.
|
|
32
|
+
// Web target (no bundler): `import init, { ... } from "justerm-wasm-decode"; await init();` first.
|
|
33
|
+
|
|
34
|
+
console.assert(wireVersion() === 2); // optional: assert the backend encoder agrees
|
|
35
|
+
|
|
36
|
+
// --- once at startup / on theme change ---
|
|
37
|
+
// buildPalette fills 0..15 from your scheme's ANSI colours and 16..255 from the
|
|
38
|
+
// fixed xterm cube/grayscale. Keep your default fg/bg alongside (they are the
|
|
39
|
+
// `Default` colour ref, resolved by role — not part of the 256).
|
|
40
|
+
const palette = {
|
|
41
|
+
colors: buildPalette(Uint32Array.from(scheme.ansi16)), // 16 × 0xRRGGBB
|
|
42
|
+
defaultFg: scheme.defaultFg, // 0xRRGGBB
|
|
43
|
+
defaultBg: scheme.defaultBg,
|
|
44
|
+
};
|
|
45
|
+
const F = flags(); // bit constants, read once
|
|
46
|
+
|
|
47
|
+
// --- per frame (e.g. an IPC message) ---
|
|
48
|
+
const frame = decodeFrame(wireBytes); // throws on a malformed buffer
|
|
49
|
+
// Structure-of-arrays columns (zero-copy views) + the span directory.
|
|
50
|
+
const { codepoints, fg, bg, extra, link, spans } = frame;
|
|
51
|
+
const flagBits = frame.flags; // note: the column; `flags()` above is the constants
|
|
52
|
+
|
|
53
|
+
for (let s = 0; s < spans.length; s += 5) {
|
|
54
|
+
const line = spans[s], left = spans[s + 1], offset = spans[s + 3], count = spans[s + 4];
|
|
55
|
+
for (let k = 0; k < count; k++) {
|
|
56
|
+
const i = offset + k;
|
|
57
|
+
const col = left + k;
|
|
58
|
+
|
|
59
|
+
const fgRgb = resolveRgb(fg[i], palette, FG); // 0xRRGGBB
|
|
60
|
+
const bgRgb = resolveRgb(bg[i], palette, BG);
|
|
61
|
+
const bold = (flagBits[i] & F.bold) !== 0;
|
|
62
|
+
if (flagBits[i] & F.wide_char_spacer) continue; // trailing half of a wide glyph
|
|
63
|
+
|
|
64
|
+
// your adapter: map codepoints[i] -> atlas glyph, apply bold/inverse/dim,
|
|
65
|
+
// resolve extra[i]/link[i] via sideTable/linkTable, place at (line, col).
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
frame.free(); // release the column views — or scope with `using frame = decodeFrame(...)`
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Lifetime of the columns
|
|
73
|
+
|
|
74
|
+
`codepoints` / `fg` / `bg` / `flags` / `extra` / `link` / `spans` are **zero-copy views** into WASM
|
|
75
|
+
linear memory — the bulk data reaches JS with no per-cell boundary crossing. A view is invalidated
|
|
76
|
+
when WASM memory grows, which the **next** `decodeFrame` call can trigger. Read or copy what you need
|
|
77
|
+
from one frame before decoding the next, and `free()` the frame (or scope it with `using`) when done.
|
|
78
|
+
The `palette` from `buildPalette` is an owned copy, so it is safe to keep across frames.
|
|
79
|
+
|
|
80
|
+
## What the columns hold
|
|
81
|
+
|
|
82
|
+
One entry per cell, in span order. `spans` is a flat directory: 5 `u32`s per span —
|
|
83
|
+
`line, left, right, cell_offset, cell_count` — where cell `k` of a span is column index
|
|
84
|
+
`cell_offset + k`.
|
|
85
|
+
|
|
86
|
+
| Column | Type | Meaning |
|
|
87
|
+
|--------|------|---------|
|
|
88
|
+
| `codepoints` | `Uint32Array` | base Unicode codepoint (not an atlas glyph id) |
|
|
89
|
+
| `fg` / `bg` | `Uint32Array` | colour references — pass to `resolveRgb` |
|
|
90
|
+
| `flags` | `Uint16Array` | attribute + layout bits — test with `flags()` constants |
|
|
91
|
+
| `extra` | `Uint16Array` | 1-based `sideTable` index for a grapheme cluster (`0` = none) |
|
|
92
|
+
| `link` | `Uint16Array` | 1-based `linkTable` index for an OSC 8 hyperlink (`0` = none) |
|
|
93
|
+
|
|
94
|
+
`frame.sideTable` (`string[]`) and `frame.linkTable` (`string[]`) carry the referenced clusters/URIs.
|
|
95
|
+
|
|
96
|
+
## Cursor
|
|
97
|
+
|
|
98
|
+
The frame also carries the engine's cursor as scalar getters (screen coordinates, 0-based):
|
|
99
|
+
|
|
100
|
+
| Getter | Type | Meaning |
|
|
101
|
+
|--------|------|---------|
|
|
102
|
+
| `cursorRow` / `cursorCol` | `number` | cursor cell position |
|
|
103
|
+
| `cursorVisible` | `boolean` | `false` when the engine hides the cursor (DECTCEM `?25l`) |
|
|
104
|
+
|
|
105
|
+
justerm **reports** the cursor; *drawing* it is your adapter's job. beamterm has no cursor primitive,
|
|
106
|
+
so draw the caret by inverting `fg`/`bg` on the cell at `(cursorRow, cursorCol)` (or an overlay quad).
|
|
107
|
+
A pure cursor move is included in the frame's damage spans (the old **and** new cells), so an
|
|
108
|
+
incremental cell-invert renderer clears the previous caret and inks the new one without ghosting.
|
|
109
|
+
|
|
110
|
+
## Colour helpers
|
|
111
|
+
|
|
112
|
+
- **`resolveRgb(ref, palette, role) → 0xRRGGBB`** — resolves a `fg[i]`/`bg[i]` ref: `Default` → the
|
|
113
|
+
role's default (`FG`/`BG`), `Indexed` → `palette.colors[i]`, `Rgb` → passthrough. Alloc-free; call
|
|
114
|
+
it per cell. It does **not** apply inverse/dim/hidden/bold→bright — that is your render policy.
|
|
115
|
+
- **`buildPalette(ansi16) → Uint32Array(256)`** — the 256-colour table (0..15 your ANSI, 16..255 the
|
|
116
|
+
fixed xterm standard). Build once per scheme.
|
|
117
|
+
- **`decodeColorRef(ref)`** — `{ kind: "default" } | { kind: "indexed", index } | { kind: "rgb", r,
|
|
118
|
+
g, b }`. For inspection; allocates, so prefer `resolveRgb` in the hot loop.
|
|
119
|
+
|
|
120
|
+
## Flag constants (`flags()`)
|
|
121
|
+
|
|
122
|
+
`bold`, `dim`, `italic`, `underline`, `blink`, `inverse`, `hidden`, `strikethrough`, `wide_char`,
|
|
123
|
+
`wide_char_spacer`, `wrapline` — each the bit to AND against a `flags[i]` value. How to act on them
|
|
124
|
+
(skip the spacer, bold→bright, dim) is your render policy. `wrapline` is engine reflow/copy metadata,
|
|
125
|
+
usually ignored by a renderer.
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
Dual-licensed under [MIT](https://github.com/kihyun1998/justerm/blob/master/LICENSE-MIT) or
|
|
130
|
+
[Apache-2.0](https://github.com/kihyun1998/justerm/blob/master/LICENSE-APACHE), at your option —
|
|
131
|
+
same as the `justerm` crate.
|
package/colors.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Types for the justerm-wasm-decode colour helpers (#36). See colors.js.
|
|
2
|
+
|
|
3
|
+
/** Role for `Default` resolution: foreground. */
|
|
4
|
+
export const FG: 0;
|
|
5
|
+
/** Role for `Default` resolution: background. */
|
|
6
|
+
export const BG: 1;
|
|
7
|
+
export type Role = typeof FG | typeof BG;
|
|
8
|
+
|
|
9
|
+
/** A resolved palette: 256 packed-RGB indices + the theme's default fg/bg. */
|
|
10
|
+
export interface Palette {
|
|
11
|
+
/** `0..15` the theme's ANSI colours, `16..255` the xterm cube/grayscale. */
|
|
12
|
+
colors: Uint32Array;
|
|
13
|
+
defaultFg: number;
|
|
14
|
+
defaultBg: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A decoded colour reference. */
|
|
18
|
+
export type ColorRef =
|
|
19
|
+
| { kind: "default" }
|
|
20
|
+
| { kind: "indexed"; index: number }
|
|
21
|
+
| { kind: "rgb"; r: number; g: number; b: number };
|
|
22
|
+
|
|
23
|
+
/** Resolve a colour ref to a packed `0xRRGGBB` number (alloc-free; per cell). */
|
|
24
|
+
export function resolveRgb(ref: number, palette: Palette, role: Role): number;
|
|
25
|
+
|
|
26
|
+
/** Unpack a colour ref into a tagged object (inspection; not the hot loop). */
|
|
27
|
+
export function decodeColorRef(ref: number): ColorRef;
|
package/colors.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Colour helpers for the justerm-wasm-decode decoder (#36, ADR-0008).
|
|
2
|
+
//
|
|
3
|
+
// The single hand-written JS mirror in the package: these decode justerm's
|
|
4
|
+
// tagged-u32 colour-ref encoding (high byte = tag — 0 Default, 1 Indexed, 2 Rgb;
|
|
5
|
+
// low 24 bits = payload). They live in JS, not WASM, because `resolveRgb` runs
|
|
6
|
+
// per cell and a WASM call per cell would defeat the zero-copy design (#34 AC3).
|
|
7
|
+
// Kept in lockstep with Rust `encode_color` by a parity test (wasm-pack --node).
|
|
8
|
+
|
|
9
|
+
/** Role for `Default` resolution: foreground. */
|
|
10
|
+
export const FG = 0;
|
|
11
|
+
/** Role for `Default` resolution: background. */
|
|
12
|
+
export const BG = 1;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a colour reference to a packed `0xRRGGBB` number. Alloc-free — call it
|
|
16
|
+
* per cell. `palette` is `{ colors: Uint32Array(256), defaultFg, defaultBg }`
|
|
17
|
+
* (build `colors` once per scheme with `buildPalette`); `role` is `FG` or `BG`,
|
|
18
|
+
* selecting which default a `Default` ref resolves to.
|
|
19
|
+
*
|
|
20
|
+
* Does NOT apply inverse/dim/hidden/bold→bright — those are render policy the
|
|
21
|
+
* caller applies afterward.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveRgb(ref, palette, role) {
|
|
24
|
+
switch (ref >>> 24) {
|
|
25
|
+
case 0:
|
|
26
|
+
return role === FG ? palette.defaultFg : palette.defaultBg;
|
|
27
|
+
case 1:
|
|
28
|
+
return palette.colors[ref & 0xff];
|
|
29
|
+
default:
|
|
30
|
+
return ref & 0xffffff;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Unpack a colour reference into a tagged object — `{ kind: 'default' }`,
|
|
36
|
+
* `{ kind: 'indexed', index }`, or `{ kind: 'rgb', r, g, b }`. For inspection,
|
|
37
|
+
* not the hot loop (it allocates an object); use `resolveRgb` there.
|
|
38
|
+
*/
|
|
39
|
+
export function decodeColorRef(ref) {
|
|
40
|
+
switch (ref >>> 24) {
|
|
41
|
+
case 0:
|
|
42
|
+
return { kind: "default" };
|
|
43
|
+
case 1:
|
|
44
|
+
return { kind: "indexed", index: ref & 0xff };
|
|
45
|
+
default:
|
|
46
|
+
return { kind: "rgb", r: (ref >>> 16) & 0xff, g: (ref >>> 8) & 0xff, b: ref & 0xff };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A decoded damage frame, presented for a web renderer.
|
|
6
|
+
*
|
|
7
|
+
* Scalars come via getters; cells are exposed as **structure-of-arrays** — one
|
|
8
|
+
* zero-copy typed-array column per field (`codepoints`/`fg`/`bg`/`flags`/
|
|
9
|
+
* `extra`/`link`) plus the `spans` directory — so a consumer reads `frame.fg[i]`
|
|
10
|
+
* with no byte-offset knowledge and no per-cell boundary crossing (#34/#35).
|
|
11
|
+
*/
|
|
12
|
+
export class DecodedFrame {
|
|
13
|
+
private constructor();
|
|
14
|
+
free(): void;
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
/**
|
|
17
|
+
* Per-cell background colour references (tagged `u32`s, as [`DecodedFrame::fg`]).
|
|
18
|
+
*/
|
|
19
|
+
readonly bg: Uint32Array;
|
|
20
|
+
/**
|
|
21
|
+
* Per-cell base codepoints (`cell.c` as `u32`), in span order — one of the
|
|
22
|
+
* structure-of-arrays cell columns (#35). Zero-copy view into WASM memory;
|
|
23
|
+
* the bulk data reaches JS with no per-cell boundary crossing (#34 AC3).
|
|
24
|
+
*
|
|
25
|
+
* # Lifetime (applies to every column + `spans`)
|
|
26
|
+
* The returned array views WASM memory directly; it is invalidated if that
|
|
27
|
+
* memory grows (e.g. the next `decodeFrame` call allocates). Read it before
|
|
28
|
+
* the next decode.
|
|
29
|
+
*/
|
|
30
|
+
readonly codepoints: Uint32Array;
|
|
31
|
+
readonly cols: number;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the caret blinks (att610 `?12`). The engine reports the mode; the
|
|
34
|
+
* renderer does the animation (#81).
|
|
35
|
+
*/
|
|
36
|
+
readonly cursorBlink: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Cursor column (screen coords, 0-based).
|
|
39
|
+
*/
|
|
40
|
+
readonly cursorCol: number;
|
|
41
|
+
/**
|
|
42
|
+
* Cursor row (screen coords, 0-based). The consumer draws the caret here by
|
|
43
|
+
* cell-invert / overlay — justerm only reports where it is (#38).
|
|
44
|
+
*/
|
|
45
|
+
readonly cursorRow: number;
|
|
46
|
+
/**
|
|
47
|
+
* Caret shape: `0` = Block, `1` = Underline, `2` = Bar (DECSCUSR #89). The
|
|
48
|
+
* consumer draws the shape; the engine only reports it (#81).
|
|
49
|
+
*/
|
|
50
|
+
readonly cursorShape: number;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the engine shows the cursor (DECTCEM `?25`). When `false` the
|
|
53
|
+
* consumer stops drawing the caret.
|
|
54
|
+
*/
|
|
55
|
+
readonly cursorVisible: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Per-cell frame-local grapheme side-table index (`0` = none; else
|
|
58
|
+
* `sideTable[extra - 1]`).
|
|
59
|
+
*/
|
|
60
|
+
readonly extra: Uint16Array;
|
|
61
|
+
/**
|
|
62
|
+
* Per-cell foreground colour references as tagged `u32`s (high byte = tag
|
|
63
|
+
* `Default|Indexed|Rgb`, low 24 = payload). Resolve with `resolveRgb`.
|
|
64
|
+
*/
|
|
65
|
+
readonly fg: Uint32Array;
|
|
66
|
+
/**
|
|
67
|
+
* Per-cell `CellFlags` bits. Test with the constants from `flags()`.
|
|
68
|
+
*/
|
|
69
|
+
readonly flags: Uint16Array;
|
|
70
|
+
readonly hasScroll: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* `0` = Full (every row present), `1` = Partial (only the listed spans).
|
|
73
|
+
*/
|
|
74
|
+
readonly kind: number;
|
|
75
|
+
/**
|
|
76
|
+
* Per-cell frame-local hyperlink index (`0` = none; else `linkTable[link - 1]`).
|
|
77
|
+
*/
|
|
78
|
+
readonly link: Uint16Array;
|
|
79
|
+
/**
|
|
80
|
+
* This frame's OSC 8 hyperlink URIs, indexed by a cell's `link` field
|
|
81
|
+
* (1-based; index 0 means none). Small and rare, so copied to a JS array.
|
|
82
|
+
*/
|
|
83
|
+
readonly linkTable: string[];
|
|
84
|
+
readonly rows: number;
|
|
85
|
+
readonly scrollBottom: number;
|
|
86
|
+
readonly scrollCount: number;
|
|
87
|
+
readonly scrollTop: number;
|
|
88
|
+
/**
|
|
89
|
+
* This frame's grapheme clusters, each joined into a string, indexed by a
|
|
90
|
+
* cell's `extra` field (1-based; index 0 means none). Small and rare, so
|
|
91
|
+
* copied to a JS array rather than viewed.
|
|
92
|
+
*/
|
|
93
|
+
readonly sideTable: string[];
|
|
94
|
+
/**
|
|
95
|
+
* Span directory: 5 `u32`s per span — `line, left, right, cell_offset,
|
|
96
|
+
* cell_count` — where `cell_offset` indexes the cell columns (cell k of a
|
|
97
|
+
* span is column index `cell_offset + k`). JS walks this directory, never per
|
|
98
|
+
* cell (#34 AC3). Same zero-copy view lifetime as the columns.
|
|
99
|
+
*/
|
|
100
|
+
readonly spans: Uint32Array;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The `CellFlags` bit positions, exported so a consumer tests `flags[i] & F.bold`
|
|
105
|
+
* without hard-coding bit values (#36). The values come straight from Rust
|
|
106
|
+
* `CellFlags`, so there is no JS mirror to drift. Read once and cache (e.g.
|
|
107
|
+
* destructure the result): the bits never change within a build.
|
|
108
|
+
*/
|
|
109
|
+
export class Flags {
|
|
110
|
+
private constructor();
|
|
111
|
+
free(): void;
|
|
112
|
+
[Symbol.dispose](): void;
|
|
113
|
+
blink: number;
|
|
114
|
+
bold: number;
|
|
115
|
+
dim: number;
|
|
116
|
+
hidden: number;
|
|
117
|
+
inverse: number;
|
|
118
|
+
italic: number;
|
|
119
|
+
strikethrough: number;
|
|
120
|
+
underline: number;
|
|
121
|
+
wide_char_spacer: number;
|
|
122
|
+
wide_char: number;
|
|
123
|
+
wrapline: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Resolve a 16-colour ANSI scheme into the full xterm 256-colour table (#36).
|
|
128
|
+
*
|
|
129
|
+
* Slots `0..16` are the supplied ANSI colours (the theme's values); `16..256`
|
|
130
|
+
* are the fixed xterm 6×6×6 cube + grayscale ramp, computed here so a consumer
|
|
131
|
+
* never re-implements that standard. Returns an **owned** copy (built per scheme;
|
|
132
|
+
* it outlives many `decodeFrame` calls). `ansi` is expected to have 16 entries
|
|
133
|
+
* (extras ignored, missing treated as `0`). The default fg/bg are *not* part of
|
|
134
|
+
* the 256 — the consumer keeps them and passes them to `resolveRgb`.
|
|
135
|
+
*/
|
|
136
|
+
export function buildPalette(ansi: Uint32Array): Uint32Array;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Decode a justerm wire buffer (ADR-0005) into a [`DecodedFrame`].
|
|
140
|
+
*
|
|
141
|
+
* On a malformed buffer this throws a JS `Error` carrying the `DecodeError`
|
|
142
|
+
* variant name — the validation a hand-written TS decoder would otherwise have
|
|
143
|
+
* to re-implement (and fuzz). Identical bytes yield a frame identical to the
|
|
144
|
+
* native `justerm_core::decode` (the build-parity test, #34 AC2).
|
|
145
|
+
*/
|
|
146
|
+
export function decodeFrame(bytes: Uint8Array): DecodedFrame;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The `CellFlags` bit constants (see [`Flags`]).
|
|
150
|
+
*/
|
|
151
|
+
export function flags(): Flags;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The wire-format version this decoder understands (the `VERSION` byte gating
|
|
155
|
+
* ADR-0005). A consumer can read it at load time to assert the WASM decoder and
|
|
156
|
+
* the backend encoder agree before any frame flows; `decodeFrame` also returns a
|
|
157
|
+
* `BadVersion` error on mismatch, so a stale artifact fails loudly.
|
|
158
|
+
*/
|
|
159
|
+
export function wireVersion(): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./justerm_wasm_decode.d.ts" */
|
|
2
|
+
import * as wasm from "./justerm_wasm_decode_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./justerm_wasm_decode_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
DecodedFrame, Flags, buildPalette, decodeFrame, flags, wireVersion
|
|
9
|
+
} from "./justerm_wasm_decode_bg.js";
|
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A decoded damage frame, presented for a web renderer.
|
|
3
|
+
*
|
|
4
|
+
* Scalars come via getters; cells are exposed as **structure-of-arrays** — one
|
|
5
|
+
* zero-copy typed-array column per field (`codepoints`/`fg`/`bg`/`flags`/
|
|
6
|
+
* `extra`/`link`) plus the `spans` directory — so a consumer reads `frame.fg[i]`
|
|
7
|
+
* with no byte-offset knowledge and no per-cell boundary crossing (#34/#35).
|
|
8
|
+
*/
|
|
9
|
+
export class DecodedFrame {
|
|
10
|
+
static __wrap(ptr) {
|
|
11
|
+
const obj = Object.create(DecodedFrame.prototype);
|
|
12
|
+
obj.__wbg_ptr = ptr;
|
|
13
|
+
DecodedFrameFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
__destroy_into_raw() {
|
|
17
|
+
const ptr = this.__wbg_ptr;
|
|
18
|
+
this.__wbg_ptr = 0;
|
|
19
|
+
DecodedFrameFinalization.unregister(this);
|
|
20
|
+
return ptr;
|
|
21
|
+
}
|
|
22
|
+
free() {
|
|
23
|
+
const ptr = this.__destroy_into_raw();
|
|
24
|
+
wasm.__wbg_decodedframe_free(ptr, 0);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Per-cell background colour references (tagged `u32`s, as [`DecodedFrame::fg`]).
|
|
28
|
+
* @returns {Uint32Array}
|
|
29
|
+
*/
|
|
30
|
+
get bg() {
|
|
31
|
+
const ret = wasm.decodedframe_bg(this.__wbg_ptr);
|
|
32
|
+
return ret;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Per-cell base codepoints (`cell.c` as `u32`), in span order — one of the
|
|
36
|
+
* structure-of-arrays cell columns (#35). Zero-copy view into WASM memory;
|
|
37
|
+
* the bulk data reaches JS with no per-cell boundary crossing (#34 AC3).
|
|
38
|
+
*
|
|
39
|
+
* # Lifetime (applies to every column + `spans`)
|
|
40
|
+
* The returned array views WASM memory directly; it is invalidated if that
|
|
41
|
+
* memory grows (e.g. the next `decodeFrame` call allocates). Read it before
|
|
42
|
+
* the next decode.
|
|
43
|
+
* @returns {Uint32Array}
|
|
44
|
+
*/
|
|
45
|
+
get codepoints() {
|
|
46
|
+
const ret = wasm.decodedframe_codepoints(this.__wbg_ptr);
|
|
47
|
+
return ret;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @returns {number}
|
|
51
|
+
*/
|
|
52
|
+
get cols() {
|
|
53
|
+
const ret = wasm.decodedframe_cols(this.__wbg_ptr);
|
|
54
|
+
return ret;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Whether the caret blinks (att610 `?12`). The engine reports the mode; the
|
|
58
|
+
* renderer does the animation (#81).
|
|
59
|
+
* @returns {boolean}
|
|
60
|
+
*/
|
|
61
|
+
get cursorBlink() {
|
|
62
|
+
const ret = wasm.decodedframe_cursorBlink(this.__wbg_ptr);
|
|
63
|
+
return ret !== 0;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Cursor column (screen coords, 0-based).
|
|
67
|
+
* @returns {number}
|
|
68
|
+
*/
|
|
69
|
+
get cursorCol() {
|
|
70
|
+
const ret = wasm.decodedframe_cursorCol(this.__wbg_ptr);
|
|
71
|
+
return ret;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Cursor row (screen coords, 0-based). The consumer draws the caret here by
|
|
75
|
+
* cell-invert / overlay — justerm only reports where it is (#38).
|
|
76
|
+
* @returns {number}
|
|
77
|
+
*/
|
|
78
|
+
get cursorRow() {
|
|
79
|
+
const ret = wasm.decodedframe_cursorRow(this.__wbg_ptr);
|
|
80
|
+
return ret;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Caret shape: `0` = Block, `1` = Underline, `2` = Bar (DECSCUSR #89). The
|
|
84
|
+
* consumer draws the shape; the engine only reports it (#81).
|
|
85
|
+
* @returns {number}
|
|
86
|
+
*/
|
|
87
|
+
get cursorShape() {
|
|
88
|
+
const ret = wasm.decodedframe_cursorShape(this.__wbg_ptr);
|
|
89
|
+
return ret;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Whether the engine shows the cursor (DECTCEM `?25`). When `false` the
|
|
93
|
+
* consumer stops drawing the caret.
|
|
94
|
+
* @returns {boolean}
|
|
95
|
+
*/
|
|
96
|
+
get cursorVisible() {
|
|
97
|
+
const ret = wasm.decodedframe_cursorVisible(this.__wbg_ptr);
|
|
98
|
+
return ret !== 0;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Per-cell frame-local grapheme side-table index (`0` = none; else
|
|
102
|
+
* `sideTable[extra - 1]`).
|
|
103
|
+
* @returns {Uint16Array}
|
|
104
|
+
*/
|
|
105
|
+
get extra() {
|
|
106
|
+
const ret = wasm.decodedframe_extra(this.__wbg_ptr);
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Per-cell foreground colour references as tagged `u32`s (high byte = tag
|
|
111
|
+
* `Default|Indexed|Rgb`, low 24 = payload). Resolve with `resolveRgb`.
|
|
112
|
+
* @returns {Uint32Array}
|
|
113
|
+
*/
|
|
114
|
+
get fg() {
|
|
115
|
+
const ret = wasm.decodedframe_fg(this.__wbg_ptr);
|
|
116
|
+
return ret;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Per-cell `CellFlags` bits. Test with the constants from `flags()`.
|
|
120
|
+
* @returns {Uint16Array}
|
|
121
|
+
*/
|
|
122
|
+
get flags() {
|
|
123
|
+
const ret = wasm.decodedframe_flags(this.__wbg_ptr);
|
|
124
|
+
return ret;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*/
|
|
129
|
+
get hasScroll() {
|
|
130
|
+
const ret = wasm.decodedframe_hasScroll(this.__wbg_ptr);
|
|
131
|
+
return ret !== 0;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* `0` = Full (every row present), `1` = Partial (only the listed spans).
|
|
135
|
+
* @returns {number}
|
|
136
|
+
*/
|
|
137
|
+
get kind() {
|
|
138
|
+
const ret = wasm.decodedframe_kind(this.__wbg_ptr);
|
|
139
|
+
return ret;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Per-cell frame-local hyperlink index (`0` = none; else `linkTable[link - 1]`).
|
|
143
|
+
* @returns {Uint16Array}
|
|
144
|
+
*/
|
|
145
|
+
get link() {
|
|
146
|
+
const ret = wasm.decodedframe_link(this.__wbg_ptr);
|
|
147
|
+
return ret;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* This frame's OSC 8 hyperlink URIs, indexed by a cell's `link` field
|
|
151
|
+
* (1-based; index 0 means none). Small and rare, so copied to a JS array.
|
|
152
|
+
* @returns {string[]}
|
|
153
|
+
*/
|
|
154
|
+
get linkTable() {
|
|
155
|
+
const ret = wasm.decodedframe_linkTable(this.__wbg_ptr);
|
|
156
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
157
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
158
|
+
return v1;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @returns {number}
|
|
162
|
+
*/
|
|
163
|
+
get rows() {
|
|
164
|
+
const ret = wasm.decodedframe_rows(this.__wbg_ptr);
|
|
165
|
+
return ret;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @returns {number}
|
|
169
|
+
*/
|
|
170
|
+
get scrollBottom() {
|
|
171
|
+
const ret = wasm.decodedframe_scrollBottom(this.__wbg_ptr);
|
|
172
|
+
return ret;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @returns {number}
|
|
176
|
+
*/
|
|
177
|
+
get scrollCount() {
|
|
178
|
+
const ret = wasm.decodedframe_scrollCount(this.__wbg_ptr);
|
|
179
|
+
return ret;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* @returns {number}
|
|
183
|
+
*/
|
|
184
|
+
get scrollTop() {
|
|
185
|
+
const ret = wasm.decodedframe_scrollTop(this.__wbg_ptr);
|
|
186
|
+
return ret;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* This frame's grapheme clusters, each joined into a string, indexed by a
|
|
190
|
+
* cell's `extra` field (1-based; index 0 means none). Small and rare, so
|
|
191
|
+
* copied to a JS array rather than viewed.
|
|
192
|
+
* @returns {string[]}
|
|
193
|
+
*/
|
|
194
|
+
get sideTable() {
|
|
195
|
+
const ret = wasm.decodedframe_sideTable(this.__wbg_ptr);
|
|
196
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
197
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
198
|
+
return v1;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Span directory: 5 `u32`s per span — `line, left, right, cell_offset,
|
|
202
|
+
* cell_count` — where `cell_offset` indexes the cell columns (cell k of a
|
|
203
|
+
* span is column index `cell_offset + k`). JS walks this directory, never per
|
|
204
|
+
* cell (#34 AC3). Same zero-copy view lifetime as the columns.
|
|
205
|
+
* @returns {Uint32Array}
|
|
206
|
+
*/
|
|
207
|
+
get spans() {
|
|
208
|
+
const ret = wasm.decodedframe_spans(this.__wbg_ptr);
|
|
209
|
+
return ret;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (Symbol.dispose) DecodedFrame.prototype[Symbol.dispose] = DecodedFrame.prototype.free;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The `CellFlags` bit positions, exported so a consumer tests `flags[i] & F.bold`
|
|
216
|
+
* without hard-coding bit values (#36). The values come straight from Rust
|
|
217
|
+
* `CellFlags`, so there is no JS mirror to drift. Read once and cache (e.g.
|
|
218
|
+
* destructure the result): the bits never change within a build.
|
|
219
|
+
*/
|
|
220
|
+
export class Flags {
|
|
221
|
+
static __wrap(ptr) {
|
|
222
|
+
const obj = Object.create(Flags.prototype);
|
|
223
|
+
obj.__wbg_ptr = ptr;
|
|
224
|
+
FlagsFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
225
|
+
return obj;
|
|
226
|
+
}
|
|
227
|
+
__destroy_into_raw() {
|
|
228
|
+
const ptr = this.__wbg_ptr;
|
|
229
|
+
this.__wbg_ptr = 0;
|
|
230
|
+
FlagsFinalization.unregister(this);
|
|
231
|
+
return ptr;
|
|
232
|
+
}
|
|
233
|
+
free() {
|
|
234
|
+
const ptr = this.__destroy_into_raw();
|
|
235
|
+
wasm.__wbg_flags_free(ptr, 0);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* @returns {number}
|
|
239
|
+
*/
|
|
240
|
+
get blink() {
|
|
241
|
+
const ret = wasm.__wbg_get_flags_blink(this.__wbg_ptr);
|
|
242
|
+
return ret;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @returns {number}
|
|
246
|
+
*/
|
|
247
|
+
get bold() {
|
|
248
|
+
const ret = wasm.__wbg_get_flags_bold(this.__wbg_ptr);
|
|
249
|
+
return ret;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* @returns {number}
|
|
253
|
+
*/
|
|
254
|
+
get dim() {
|
|
255
|
+
const ret = wasm.__wbg_get_flags_dim(this.__wbg_ptr);
|
|
256
|
+
return ret;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* @returns {number}
|
|
260
|
+
*/
|
|
261
|
+
get hidden() {
|
|
262
|
+
const ret = wasm.__wbg_get_flags_hidden(this.__wbg_ptr);
|
|
263
|
+
return ret;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* @returns {number}
|
|
267
|
+
*/
|
|
268
|
+
get inverse() {
|
|
269
|
+
const ret = wasm.__wbg_get_flags_inverse(this.__wbg_ptr);
|
|
270
|
+
return ret;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* @returns {number}
|
|
274
|
+
*/
|
|
275
|
+
get italic() {
|
|
276
|
+
const ret = wasm.__wbg_get_flags_italic(this.__wbg_ptr);
|
|
277
|
+
return ret;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* @returns {number}
|
|
281
|
+
*/
|
|
282
|
+
get strikethrough() {
|
|
283
|
+
const ret = wasm.__wbg_get_flags_strikethrough(this.__wbg_ptr);
|
|
284
|
+
return ret;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* @returns {number}
|
|
288
|
+
*/
|
|
289
|
+
get underline() {
|
|
290
|
+
const ret = wasm.__wbg_get_flags_underline(this.__wbg_ptr);
|
|
291
|
+
return ret;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* @returns {number}
|
|
295
|
+
*/
|
|
296
|
+
get wide_char_spacer() {
|
|
297
|
+
const ret = wasm.__wbg_get_flags_wide_char_spacer(this.__wbg_ptr);
|
|
298
|
+
return ret;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @returns {number}
|
|
302
|
+
*/
|
|
303
|
+
get wide_char() {
|
|
304
|
+
const ret = wasm.__wbg_get_flags_wide_char(this.__wbg_ptr);
|
|
305
|
+
return ret;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @returns {number}
|
|
309
|
+
*/
|
|
310
|
+
get wrapline() {
|
|
311
|
+
const ret = wasm.__wbg_get_flags_wrapline(this.__wbg_ptr);
|
|
312
|
+
return ret;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* @param {number} arg0
|
|
316
|
+
*/
|
|
317
|
+
set blink(arg0) {
|
|
318
|
+
wasm.__wbg_set_flags_blink(this.__wbg_ptr, arg0);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* @param {number} arg0
|
|
322
|
+
*/
|
|
323
|
+
set bold(arg0) {
|
|
324
|
+
wasm.__wbg_set_flags_bold(this.__wbg_ptr, arg0);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* @param {number} arg0
|
|
328
|
+
*/
|
|
329
|
+
set dim(arg0) {
|
|
330
|
+
wasm.__wbg_set_flags_dim(this.__wbg_ptr, arg0);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* @param {number} arg0
|
|
334
|
+
*/
|
|
335
|
+
set hidden(arg0) {
|
|
336
|
+
wasm.__wbg_set_flags_hidden(this.__wbg_ptr, arg0);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* @param {number} arg0
|
|
340
|
+
*/
|
|
341
|
+
set inverse(arg0) {
|
|
342
|
+
wasm.__wbg_set_flags_inverse(this.__wbg_ptr, arg0);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* @param {number} arg0
|
|
346
|
+
*/
|
|
347
|
+
set italic(arg0) {
|
|
348
|
+
wasm.__wbg_set_flags_italic(this.__wbg_ptr, arg0);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* @param {number} arg0
|
|
352
|
+
*/
|
|
353
|
+
set strikethrough(arg0) {
|
|
354
|
+
wasm.__wbg_set_flags_strikethrough(this.__wbg_ptr, arg0);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* @param {number} arg0
|
|
358
|
+
*/
|
|
359
|
+
set underline(arg0) {
|
|
360
|
+
wasm.__wbg_set_flags_underline(this.__wbg_ptr, arg0);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* @param {number} arg0
|
|
364
|
+
*/
|
|
365
|
+
set wide_char_spacer(arg0) {
|
|
366
|
+
wasm.__wbg_set_flags_wide_char_spacer(this.__wbg_ptr, arg0);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* @param {number} arg0
|
|
370
|
+
*/
|
|
371
|
+
set wide_char(arg0) {
|
|
372
|
+
wasm.__wbg_set_flags_wide_char(this.__wbg_ptr, arg0);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* @param {number} arg0
|
|
376
|
+
*/
|
|
377
|
+
set wrapline(arg0) {
|
|
378
|
+
wasm.__wbg_set_flags_wrapline(this.__wbg_ptr, arg0);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (Symbol.dispose) Flags.prototype[Symbol.dispose] = Flags.prototype.free;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Resolve a 16-colour ANSI scheme into the full xterm 256-colour table (#36).
|
|
385
|
+
*
|
|
386
|
+
* Slots `0..16` are the supplied ANSI colours (the theme's values); `16..256`
|
|
387
|
+
* are the fixed xterm 6×6×6 cube + grayscale ramp, computed here so a consumer
|
|
388
|
+
* never re-implements that standard. Returns an **owned** copy (built per scheme;
|
|
389
|
+
* it outlives many `decodeFrame` calls). `ansi` is expected to have 16 entries
|
|
390
|
+
* (extras ignored, missing treated as `0`). The default fg/bg are *not* part of
|
|
391
|
+
* the 256 — the consumer keeps them and passes them to `resolveRgb`.
|
|
392
|
+
* @param {Uint32Array} ansi
|
|
393
|
+
* @returns {Uint32Array}
|
|
394
|
+
*/
|
|
395
|
+
export function buildPalette(ansi) {
|
|
396
|
+
const ptr0 = passArray32ToWasm0(ansi, wasm.__wbindgen_malloc);
|
|
397
|
+
const len0 = WASM_VECTOR_LEN;
|
|
398
|
+
const ret = wasm.buildPalette(ptr0, len0);
|
|
399
|
+
var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
400
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
401
|
+
return v2;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Decode a justerm wire buffer (ADR-0005) into a [`DecodedFrame`].
|
|
406
|
+
*
|
|
407
|
+
* On a malformed buffer this throws a JS `Error` carrying the `DecodeError`
|
|
408
|
+
* variant name — the validation a hand-written TS decoder would otherwise have
|
|
409
|
+
* to re-implement (and fuzz). Identical bytes yield a frame identical to the
|
|
410
|
+
* native `justerm_core::decode` (the build-parity test, #34 AC2).
|
|
411
|
+
* @param {Uint8Array} bytes
|
|
412
|
+
* @returns {DecodedFrame}
|
|
413
|
+
*/
|
|
414
|
+
export function decodeFrame(bytes) {
|
|
415
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
416
|
+
const len0 = WASM_VECTOR_LEN;
|
|
417
|
+
const ret = wasm.decodeFrame(ptr0, len0);
|
|
418
|
+
if (ret[2]) {
|
|
419
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
420
|
+
}
|
|
421
|
+
return DecodedFrame.__wrap(ret[0]);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* The `CellFlags` bit constants (see [`Flags`]).
|
|
426
|
+
* @returns {Flags}
|
|
427
|
+
*/
|
|
428
|
+
export function flags() {
|
|
429
|
+
const ret = wasm.flags();
|
|
430
|
+
return Flags.__wrap(ret);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The wire-format version this decoder understands (the `VERSION` byte gating
|
|
435
|
+
* ADR-0005). A consumer can read it at load time to assert the WASM decoder and
|
|
436
|
+
* the backend encoder agree before any frame flows; `decodeFrame` also returns a
|
|
437
|
+
* `BadVersion` error on mismatch, so a stale artifact fails loudly.
|
|
438
|
+
* @returns {number}
|
|
439
|
+
*/
|
|
440
|
+
export function wireVersion() {
|
|
441
|
+
const ret = wasm.wireVersion();
|
|
442
|
+
return ret;
|
|
443
|
+
}
|
|
444
|
+
export function __wbg___wbindgen_throw_ea4887a5f8f9a9db(arg0, arg1) {
|
|
445
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
446
|
+
}
|
|
447
|
+
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
448
|
+
// Cast intrinsic for `Ref(Slice(U16)) -> NamedExternref("Uint16Array")`.
|
|
449
|
+
const ret = getArrayU16FromWasm0(arg0, arg1);
|
|
450
|
+
return ret;
|
|
451
|
+
}
|
|
452
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
453
|
+
// Cast intrinsic for `Ref(Slice(U32)) -> NamedExternref("Uint32Array")`.
|
|
454
|
+
const ret = getArrayU32FromWasm0(arg0, arg1);
|
|
455
|
+
return ret;
|
|
456
|
+
}
|
|
457
|
+
export function __wbindgen_cast_0000000000000003(arg0, arg1) {
|
|
458
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
459
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
460
|
+
return ret;
|
|
461
|
+
}
|
|
462
|
+
export function __wbindgen_init_externref_table() {
|
|
463
|
+
const table = wasm.__wbindgen_externrefs;
|
|
464
|
+
const offset = table.grow(4);
|
|
465
|
+
table.set(0, undefined);
|
|
466
|
+
table.set(offset + 0, undefined);
|
|
467
|
+
table.set(offset + 1, null);
|
|
468
|
+
table.set(offset + 2, true);
|
|
469
|
+
table.set(offset + 3, false);
|
|
470
|
+
}
|
|
471
|
+
const DecodedFrameFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
472
|
+
? { register: () => {}, unregister: () => {} }
|
|
473
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_decodedframe_free(ptr, 1));
|
|
474
|
+
const FlagsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
475
|
+
? { register: () => {}, unregister: () => {} }
|
|
476
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_flags_free(ptr, 1));
|
|
477
|
+
|
|
478
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
479
|
+
ptr = ptr >>> 0;
|
|
480
|
+
const mem = getDataViewMemory0();
|
|
481
|
+
const result = [];
|
|
482
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
483
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
484
|
+
}
|
|
485
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function getArrayU16FromWasm0(ptr, len) {
|
|
490
|
+
ptr = ptr >>> 0;
|
|
491
|
+
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
495
|
+
ptr = ptr >>> 0;
|
|
496
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
let cachedDataViewMemory0 = null;
|
|
500
|
+
function getDataViewMemory0() {
|
|
501
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
502
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
503
|
+
}
|
|
504
|
+
return cachedDataViewMemory0;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function getStringFromWasm0(ptr, len) {
|
|
508
|
+
return decodeText(ptr >>> 0, len);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
let cachedUint16ArrayMemory0 = null;
|
|
512
|
+
function getUint16ArrayMemory0() {
|
|
513
|
+
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
514
|
+
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
515
|
+
}
|
|
516
|
+
return cachedUint16ArrayMemory0;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
let cachedUint32ArrayMemory0 = null;
|
|
520
|
+
function getUint32ArrayMemory0() {
|
|
521
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
522
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
523
|
+
}
|
|
524
|
+
return cachedUint32ArrayMemory0;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
let cachedUint8ArrayMemory0 = null;
|
|
528
|
+
function getUint8ArrayMemory0() {
|
|
529
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
530
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
531
|
+
}
|
|
532
|
+
return cachedUint8ArrayMemory0;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
536
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
537
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
538
|
+
WASM_VECTOR_LEN = arg.length;
|
|
539
|
+
return ptr;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
543
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
544
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
545
|
+
WASM_VECTOR_LEN = arg.length;
|
|
546
|
+
return ptr;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function takeFromExternrefTable0(idx) {
|
|
550
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
551
|
+
wasm.__externref_table_dealloc(idx);
|
|
552
|
+
return value;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
556
|
+
cachedTextDecoder.decode();
|
|
557
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
558
|
+
let numBytesDecoded = 0;
|
|
559
|
+
function decodeText(ptr, len) {
|
|
560
|
+
numBytesDecoded += len;
|
|
561
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
562
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
563
|
+
cachedTextDecoder.decode();
|
|
564
|
+
numBytesDecoded = len;
|
|
565
|
+
}
|
|
566
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
let WASM_VECTOR_LEN = 0;
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
let wasm;
|
|
573
|
+
export function __wbg_set_wasm(val) {
|
|
574
|
+
wasm = val;
|
|
575
|
+
}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "justerm-wasm-decode",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "WASM decoder for justerm's wire format: structure-of-arrays cell columns + format-owned colour/flag helpers. See ADR-0008.",
|
|
5
|
+
"version": "0.6.0",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/kihyun1998/justerm"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"justerm_wasm_decode_bg.wasm",
|
|
13
|
+
"justerm_wasm_decode.js",
|
|
14
|
+
"justerm_wasm_decode_bg.js",
|
|
15
|
+
"justerm_wasm_decode.d.ts",
|
|
16
|
+
"colors.js",
|
|
17
|
+
"colors.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "justerm_wasm_decode.js",
|
|
20
|
+
"types": "justerm_wasm_decode.d.ts",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./justerm_wasm_decode.js",
|
|
23
|
+
"./snippets/*"
|
|
24
|
+
]
|
|
25
|
+
}
|