@primitiv-ui/harmoni-wasm 0.1.30
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/harmoni_wasm.d.ts +393 -0
- package/harmoni_wasm.js +846 -0
- package/harmoni_wasm_bg.wasm +0 -0
- package/package.json +21 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export interface AlphaRamp {
|
|
4
|
+
swatches: AlphaSwatch[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface AlphaSwatch {
|
|
8
|
+
l: number;
|
|
9
|
+
c: number;
|
|
10
|
+
h: number;
|
|
11
|
+
alpha: number;
|
|
12
|
+
step: number;
|
|
13
|
+
oklch: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ChromaHeadroom {
|
|
17
|
+
label: string;
|
|
18
|
+
requested: number;
|
|
19
|
+
granted: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ChromaHeadroomReport {
|
|
23
|
+
steps: ChromaHeadroom[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ContrastResult {
|
|
27
|
+
ratio: number;
|
|
28
|
+
display_ratio: string;
|
|
29
|
+
rating: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface CurvePreset {
|
|
33
|
+
easing: Easing;
|
|
34
|
+
direction: Direction;
|
|
35
|
+
accent: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ForegroundCoverage {
|
|
39
|
+
aaa: number;
|
|
40
|
+
aa: number;
|
|
41
|
+
fail: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface OklchTriple {
|
|
45
|
+
l: number;
|
|
46
|
+
c: number;
|
|
47
|
+
h: number;
|
|
48
|
+
hex: string;
|
|
49
|
+
rgb: Rgb;
|
|
50
|
+
oklch: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface Palette {
|
|
54
|
+
swatches: Swatch[];
|
|
55
|
+
lightness_curve: number[];
|
|
56
|
+
max_recommended_light_padding: number;
|
|
57
|
+
max_recommended_dark_padding: number;
|
|
58
|
+
note: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PaletteSet {
|
|
62
|
+
light: Palette;
|
|
63
|
+
dark: Palette;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface Ramp {
|
|
67
|
+
steps: SwatchStep[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface RampQuality {
|
|
71
|
+
steps: StepQuality[];
|
|
72
|
+
hue_span_intended: number | null;
|
|
73
|
+
hue_span_rendered: number | null;
|
|
74
|
+
min_delta_l: number | null;
|
|
75
|
+
mean_chroma_utilisation: number | null;
|
|
76
|
+
mean_chroma_demand: number | null;
|
|
77
|
+
foreground_coverage: ForegroundCoverage;
|
|
78
|
+
gamut: Gamut;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ReadableStep {
|
|
82
|
+
label: SwatchLabel;
|
|
83
|
+
color: SwatchStep;
|
|
84
|
+
contrast_ratio: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface Rgb {
|
|
88
|
+
r: number;
|
|
89
|
+
g: number;
|
|
90
|
+
b: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface SoftNeutrals {
|
|
94
|
+
white: OklchTriple;
|
|
95
|
+
black: OklchTriple;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface StepQuality {
|
|
99
|
+
label: string;
|
|
100
|
+
chroma_demand: number | null;
|
|
101
|
+
chroma_utilisation: number | null;
|
|
102
|
+
rendered_l: number;
|
|
103
|
+
rendered_c: number;
|
|
104
|
+
rendered_h: number;
|
|
105
|
+
delta_l: number | null;
|
|
106
|
+
hue_error: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface Swatch {
|
|
110
|
+
l: number;
|
|
111
|
+
c: number;
|
|
112
|
+
h: number;
|
|
113
|
+
label: SwatchLabel;
|
|
114
|
+
hex: string;
|
|
115
|
+
rgb: Rgb;
|
|
116
|
+
oklch: string;
|
|
117
|
+
best_foreground: SwatchStep;
|
|
118
|
+
foreground_source: ForegroundSource;
|
|
119
|
+
contrast_result: ContrastResult;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface SwatchStep {
|
|
123
|
+
l: number;
|
|
124
|
+
c: number;
|
|
125
|
+
h: number;
|
|
126
|
+
label: SwatchLabel;
|
|
127
|
+
hex: string;
|
|
128
|
+
rgb: Rgb;
|
|
129
|
+
oklch: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type ContrastUse = "BodyText" | "LargeText" | "NonText";
|
|
133
|
+
|
|
134
|
+
export type Direction = "EaseIn" | "EaseOut" | "EaseInOut";
|
|
135
|
+
|
|
136
|
+
export type Easing = "Linear" | "Quadratic" | "Cubic" | "Quartic" | "Quintic" | "Sine" | "Exponential" | "Circular" | "Arc";
|
|
137
|
+
|
|
138
|
+
export type ForegroundSource = "Step900" | "Step50" | "SoftWhite" | "SoftBlack" | "PureWhite" | "PureBlack";
|
|
139
|
+
|
|
140
|
+
export type Gamut = "Srgb" | "DisplayP3";
|
|
141
|
+
|
|
142
|
+
export type Grade = "Aaa" | "Aa" | "LargeTextOnly" | "Fail";
|
|
143
|
+
|
|
144
|
+
export type SwatchLabel = { Number: number } | { Name: string };
|
|
145
|
+
|
|
146
|
+
export type TintMode = "Inherit" | "Achromatic";
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Parses any CSS colour string (`#rrggbb`, `oklch(L C H)`, `rgb(...)`, a
|
|
151
|
+
* named colour, ...) into the OkLCH triple the picker's hex⇄oklch text field
|
|
152
|
+
* round-trips through — `{ l, c, h }` plus the `hex`/`rgb`/`oklch` renderings
|
|
153
|
+
* (RFC 0010 §4). Parsing crosses into the one Rust engine; no JS colour
|
|
154
|
+
* library is involved (Principle 1). Errors on an unparseable string.
|
|
155
|
+
* Generates the ramp this OkLCH colour would seed and measures what it can
|
|
156
|
+
* actually do in `gamut` — chroma the steps get versus what they ask for, hue
|
|
157
|
+
* held versus rendered, step spacing, and foreground coverage.
|
|
158
|
+
*
|
|
159
|
+
* This is the picker's feedback source (RFC 0027 §6): the data is already on
|
|
160
|
+
* screen as a gamut boundary, it was simply never interpreted. Call it once per
|
|
161
|
+
* gamut to state the trade-off — the same hue that mutes badly in sRGB may be
|
|
162
|
+
* comfortable in Display-P3.
|
|
163
|
+
*/
|
|
164
|
+
export function assess_brand_ramp(l: number, c: number, h: number, gamut: Gamut): RampQuality;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Per-step chroma headroom for the ramp this colour would seed: what each
|
|
168
|
+
* step's scale asks for, against what the gamut grants. The gap is what tells a
|
|
169
|
+
* designer their hue will mute — and where (RFC 0027 §6).
|
|
170
|
+
*/
|
|
171
|
+
export function chroma_headroom(l: number, c: number, h: number, gamut: Gamut): ChromaHeadroomReport;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sample a curve preset at `count` positions, normalised to `0..=1` ascending.
|
|
175
|
+
*
|
|
176
|
+
* This is the shape itself, not a ramp: what a preview glyph draws, and what a
|
|
177
|
+
* chart plots before the ramp's own endpoints are applied to it.
|
|
178
|
+
*/
|
|
179
|
+
export function curve_samples(preset: CurvePreset, count: number): Float32Array;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The accent at which `Arc` is a shape of its own.
|
|
183
|
+
*
|
|
184
|
+
* Both ends of the accent range duplicate `Sine` — 0 is its ease-out, 1 its
|
|
185
|
+
* ease-in — so the default is a real engine decision rather than a midpoint
|
|
186
|
+
* picked for tidiness. A control that hardcodes it drifts the moment the
|
|
187
|
+
* engine changes its mind, the same argument as `supported_step_range`.
|
|
188
|
+
*/
|
|
189
|
+
export function default_arc_accent(): number;
|
|
190
|
+
|
|
191
|
+
export function derive_soft_neutrals(brand: string, softness: number): SoftNeutrals;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Renders an OkLCH `{ l, c, h }` triple back into the engine's canonical
|
|
195
|
+
* `hex`/`rgb`/`oklch` strings, so the picker formats its current value through
|
|
196
|
+
* the same source of truth it parses with (RFC 0010 §4).
|
|
197
|
+
*/
|
|
198
|
+
export function describe_oklch(l: number, c: number, h: number): OklchTriple;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Builds an alpha ramp from a single anchor colour (Path A): the anchor held
|
|
202
|
+
* constant across ten steps while opacity climbs the shared curve. Neutral
|
|
203
|
+
* ramps pass their veil colour (soft-black in light, soft-white in dark);
|
|
204
|
+
* brand ramps pass the brand's identity swatch.
|
|
205
|
+
*/
|
|
206
|
+
export function generate_alpha_ramp(anchor: string): AlphaRamp;
|
|
207
|
+
|
|
208
|
+
export function generate_neutral_ramp(white: string, black: string, tint: TintMode, bow: number): Palette;
|
|
209
|
+
|
|
210
|
+
export function generate_palette(hex: string, light_padding: number, dark_padding: number): Palette;
|
|
211
|
+
|
|
212
|
+
export function generate_palette_pair(hex: string, light_lightness: Array<any>, dark_lightness: Array<any>, light_padding: number, dark_padding: number): PaletteSet;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* A light/dark pair shaped by a curve preset instead of the built-in curves.
|
|
216
|
+
*
|
|
217
|
+
* Additive rather than a parameter on `generate_palette_pair_with_steps`,
|
|
218
|
+
* because a preset is genuinely opt-in: the hand-authored curves are not
|
|
219
|
+
* straight lines and no preset reproduces them, so "no preset" has to stay a
|
|
220
|
+
* distinct call rather than becoming `Linear` by default.
|
|
221
|
+
*/
|
|
222
|
+
export function generate_palette_pair_with_curve(hex: string, steps: number, light_padding: number, dark_padding: number, curve: CurvePreset): PaletteSet;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* A light/dark pair of `steps` steps each, from the built-in curves.
|
|
226
|
+
*/
|
|
227
|
+
export function generate_palette_pair_with_steps(hex: string, steps: number, light_padding: number, dark_padding: number): PaletteSet;
|
|
228
|
+
|
|
229
|
+
export function generate_palette_with_light_padding(hex: string, light_padding: number): Palette;
|
|
230
|
+
|
|
231
|
+
export function generate_palette_with_lightness(hex: string, lightness: Array<any>, light_padding: number, dark_padding: number): Palette;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Generate a light palette of `steps` steps, reading the built-in curves at
|
|
235
|
+
* that resolution. `steps` outside the supported range is an error rather
|
|
236
|
+
* than being clamped, so a caller finds out it asked for the impossible.
|
|
237
|
+
*/
|
|
238
|
+
export function generate_palette_with_steps(hex: string, steps: number, light_padding: number, dark_padding: number): Palette;
|
|
239
|
+
|
|
240
|
+
export function get_contrast_rating(bg: string, fg: string): ContrastResult;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* What `ratio` achieves when the colour is used as `use`.
|
|
244
|
+
*
|
|
245
|
+
* `get_contrast_rating` answers a different question — it reports a ratio and
|
|
246
|
+
* a single stringly-typed rating, which cannot say that one ratio is AA as
|
|
247
|
+
* body copy, AAA at heading size, and past the non-text bar all at once. A
|
|
248
|
+
* grade is what a designer decides on; compose this with the ratio from
|
|
249
|
+
* `get_contrast_rating` when the evidence behind the verdict is wanted too.
|
|
250
|
+
*/
|
|
251
|
+
export function grade(ratio: number, use: ContrastUse): Grade;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The maximum in-gamut chroma for an OkLCH lightness and hue, against the given
|
|
255
|
+
* `gamut` (sRGB or Display-P3) — the boundary curve the OKLCH picker overlays on
|
|
256
|
+
* its charts and clamps the cursor to (RFC 0010 §3, §7).
|
|
257
|
+
*/
|
|
258
|
+
export function max_in_gamut_chroma(lightness: number, hue: number, gamut: Gamut): number;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Paints the OkLCH chroma×hue plane for a fixed lightness as a flat RGBA buffer
|
|
262
|
+
* (`width * height * 4` bytes, row-major) — the picker's Lightness chart. Hue
|
|
263
|
+
* runs left→right, chroma top→bottom; out-of-gamut pixels are transparent
|
|
264
|
+
* (RFC 0010 §3, §7).
|
|
265
|
+
*/
|
|
266
|
+
export function paint_ch_plane(lightness: number, width: number, height: number, c_max: number, gamut: Gamut): Uint8Array;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Paints the chroma sweep at a fixed lightness and hue against `gamut` as a flat
|
|
270
|
+
* RGBA buffer (`width * 4` bytes) for the picker's C slider track (RFC 0010 §7).
|
|
271
|
+
*/
|
|
272
|
+
export function paint_chroma_strip(lightness: number, hue: number, width: number, c_max: number, gamut: Gamut): Uint8Array;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Paints the hue spectrum at a fixed lightness and chroma against `gamut` as a
|
|
276
|
+
* flat RGBA buffer (`width * 4` bytes) for the picker's hue slider track
|
|
277
|
+
* (RFC 0010 §3, §7).
|
|
278
|
+
*/
|
|
279
|
+
export function paint_hue_strip(lightness: number, chroma: number, width: number, gamut: Gamut): Uint8Array;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Paints the OkLCH lightness×chroma plane for a fixed hue as a flat RGBA
|
|
283
|
+
* buffer (`width * height * 4` bytes, row-major) the canvas blits straight
|
|
284
|
+
* into `ImageData`. Pixels carry `gamut` coordinates; out-of-gamut pixels are
|
|
285
|
+
* transparent (RFC 0010 §3, §7).
|
|
286
|
+
*/
|
|
287
|
+
export function paint_lc_plane(hue: number, width: number, height: number, c_max: number, gamut: Gamut): Uint8Array;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Paints the OkLCH lightness×hue plane for a fixed chroma as a flat RGBA buffer
|
|
291
|
+
* (`width * height * 4` bytes, row-major) — the picker's Chroma chart. Hue runs
|
|
292
|
+
* left→right, lightness top→bottom; out-of-gamut pixels are transparent
|
|
293
|
+
* (RFC 0010 §3, §7).
|
|
294
|
+
*/
|
|
295
|
+
export function paint_lh_plane(chroma: number, width: number, height: number, gamut: Gamut): Uint8Array;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Paints the lightness sweep at a fixed chroma and hue against `gamut` as a flat
|
|
299
|
+
* RGBA buffer (`width * 4` bytes) for the picker's L slider track (RFC 0010 §7).
|
|
300
|
+
*/
|
|
301
|
+
export function paint_lightness_strip(chroma: number, hue: number, width: number, gamut: Gamut, l_min: number, l_max: number): Uint8Array;
|
|
302
|
+
|
|
303
|
+
export function parse_color(input: string): OklchTriple;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* The step of `ramp` to use for a role that must clear `threshold` against
|
|
307
|
+
* `surface` — a link colour, a muted-text colour, a border.
|
|
308
|
+
*
|
|
309
|
+
* Returns the **quietest** step that clears, not the first: a role wants the
|
|
310
|
+
* least contrast that still passes, because a border pushed to body-text
|
|
311
|
+
* weight passes its floor and looks like a mistake. `None` where nothing in
|
|
312
|
+
* the ramp reaches the threshold, rather than the least bad option.
|
|
313
|
+
*
|
|
314
|
+
* This is the question `get_best_foreground` cannot answer — that one draws
|
|
315
|
+
* from the ramp's ends and the white/black anchors, so it has nothing to say
|
|
316
|
+
* about which *mid-ramp* step is readable on some *other* surface.
|
|
317
|
+
*/
|
|
318
|
+
export function readable_step(ramp: Ramp, surface: SwatchStep, threshold: number): ReadableStep | undefined;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* The ramp lengths the engine supports, as `[min, default, max]` — what a
|
|
322
|
+
* step-count control should bound itself to rather than hardcoding.
|
|
323
|
+
*/
|
|
324
|
+
export function supported_step_range(): Uint32Array;
|
|
325
|
+
|
|
326
|
+
export function tint_neutrals(white: string, black: string, source: string, strength: number): SoftNeutrals;
|
|
327
|
+
|
|
328
|
+
export function tint_neutrals_duotone(white: string, black: string, highlight: string, shadow: string, strength: number): SoftNeutrals;
|
|
329
|
+
|
|
330
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
331
|
+
|
|
332
|
+
export interface InitOutput {
|
|
333
|
+
readonly memory: WebAssembly.Memory;
|
|
334
|
+
readonly assess_brand_ramp: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
335
|
+
readonly chroma_headroom: (a: number, b: number, c: number, d: any) => any;
|
|
336
|
+
readonly curve_samples: (a: any, b: number) => [number, number];
|
|
337
|
+
readonly default_arc_accent: () => number;
|
|
338
|
+
readonly derive_soft_neutrals: (a: number, b: number, c: number) => [number, number, number];
|
|
339
|
+
readonly describe_oklch: (a: number, b: number, c: number) => any;
|
|
340
|
+
readonly generate_alpha_ramp: (a: number, b: number) => [number, number, number];
|
|
341
|
+
readonly generate_neutral_ramp: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number];
|
|
342
|
+
readonly generate_palette: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
343
|
+
readonly generate_palette_pair: (a: number, b: number, c: any, d: any, e: number, f: number) => [number, number, number];
|
|
344
|
+
readonly generate_palette_pair_with_curve: (a: number, b: number, c: number, d: number, e: number, f: any) => [number, number, number];
|
|
345
|
+
readonly generate_palette_pair_with_steps: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
346
|
+
readonly generate_palette_with_light_padding: (a: number, b: number, c: number) => [number, number, number];
|
|
347
|
+
readonly generate_palette_with_lightness: (a: number, b: number, c: any, d: number, e: number) => [number, number, number];
|
|
348
|
+
readonly generate_palette_with_steps: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
349
|
+
readonly get_contrast_rating: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
350
|
+
readonly grade: (a: number, b: any) => any;
|
|
351
|
+
readonly max_in_gamut_chroma: (a: number, b: number, c: any) => number;
|
|
352
|
+
readonly paint_ch_plane: (a: number, b: number, c: number, d: number, e: any) => [number, number];
|
|
353
|
+
readonly paint_chroma_strip: (a: number, b: number, c: number, d: number, e: any) => [number, number];
|
|
354
|
+
readonly paint_hue_strip: (a: number, b: number, c: number, d: any) => [number, number];
|
|
355
|
+
readonly paint_lc_plane: (a: number, b: number, c: number, d: number, e: any) => [number, number];
|
|
356
|
+
readonly paint_lh_plane: (a: number, b: number, c: number, d: any) => [number, number];
|
|
357
|
+
readonly paint_lightness_strip: (a: number, b: number, c: number, d: any, e: number, f: number) => [number, number];
|
|
358
|
+
readonly parse_color: (a: number, b: number) => [number, number, number];
|
|
359
|
+
readonly readable_step: (a: any, b: any, c: number) => any;
|
|
360
|
+
readonly supported_step_range: () => [number, number];
|
|
361
|
+
readonly tint_neutrals: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
362
|
+
readonly tint_neutrals_duotone: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
|
|
363
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
364
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
365
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
366
|
+
readonly __externref_table_alloc: () => number;
|
|
367
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
368
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
369
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
370
|
+
readonly __wbindgen_start: () => void;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
377
|
+
* a precompiled `WebAssembly.Module`.
|
|
378
|
+
*
|
|
379
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
380
|
+
*
|
|
381
|
+
* @returns {InitOutput}
|
|
382
|
+
*/
|
|
383
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
387
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
388
|
+
*
|
|
389
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
390
|
+
*
|
|
391
|
+
* @returns {Promise<InitOutput>}
|
|
392
|
+
*/
|
|
393
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/harmoni_wasm.js
ADDED
|
@@ -0,0 +1,846 @@
|
|
|
1
|
+
/* @ts-self-types="./harmoni_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses any CSS colour string (`#rrggbb`, `oklch(L C H)`, `rgb(...)`, a
|
|
5
|
+
* named colour, ...) into the OkLCH triple the picker's hex⇄oklch text field
|
|
6
|
+
* round-trips through — `{ l, c, h }` plus the `hex`/`rgb`/`oklch` renderings
|
|
7
|
+
* (RFC 0010 §4). Parsing crosses into the one Rust engine; no JS colour
|
|
8
|
+
* library is involved (Principle 1). Errors on an unparseable string.
|
|
9
|
+
* Generates the ramp this OkLCH colour would seed and measures what it can
|
|
10
|
+
* actually do in `gamut` — chroma the steps get versus what they ask for, hue
|
|
11
|
+
* held versus rendered, step spacing, and foreground coverage.
|
|
12
|
+
*
|
|
13
|
+
* This is the picker's feedback source (RFC 0027 §6): the data is already on
|
|
14
|
+
* screen as a gamut boundary, it was simply never interpreted. Call it once per
|
|
15
|
+
* gamut to state the trade-off — the same hue that mutes badly in sRGB may be
|
|
16
|
+
* comfortable in Display-P3.
|
|
17
|
+
* @param {number} l
|
|
18
|
+
* @param {number} c
|
|
19
|
+
* @param {number} h
|
|
20
|
+
* @param {Gamut} gamut
|
|
21
|
+
* @returns {RampQuality}
|
|
22
|
+
*/
|
|
23
|
+
export function assess_brand_ramp(l, c, h, gamut) {
|
|
24
|
+
const ret = wasm.assess_brand_ramp(l, c, h, gamut);
|
|
25
|
+
if (ret[2]) {
|
|
26
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
27
|
+
}
|
|
28
|
+
return takeFromExternrefTable0(ret[0]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Per-step chroma headroom for the ramp this colour would seed: what each
|
|
33
|
+
* step's scale asks for, against what the gamut grants. The gap is what tells a
|
|
34
|
+
* designer their hue will mute — and where (RFC 0027 §6).
|
|
35
|
+
* @param {number} l
|
|
36
|
+
* @param {number} c
|
|
37
|
+
* @param {number} h
|
|
38
|
+
* @param {Gamut} gamut
|
|
39
|
+
* @returns {ChromaHeadroomReport}
|
|
40
|
+
*/
|
|
41
|
+
export function chroma_headroom(l, c, h, gamut) {
|
|
42
|
+
const ret = wasm.chroma_headroom(l, c, h, gamut);
|
|
43
|
+
return ret;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sample a curve preset at `count` positions, normalised to `0..=1` ascending.
|
|
48
|
+
*
|
|
49
|
+
* This is the shape itself, not a ramp: what a preview glyph draws, and what a
|
|
50
|
+
* chart plots before the ramp's own endpoints are applied to it.
|
|
51
|
+
* @param {CurvePreset} preset
|
|
52
|
+
* @param {number} count
|
|
53
|
+
* @returns {Float32Array}
|
|
54
|
+
*/
|
|
55
|
+
export function curve_samples(preset, count) {
|
|
56
|
+
const ret = wasm.curve_samples(preset, count);
|
|
57
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
58
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
59
|
+
return v1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The accent at which `Arc` is a shape of its own.
|
|
64
|
+
*
|
|
65
|
+
* Both ends of the accent range duplicate `Sine` — 0 is its ease-out, 1 its
|
|
66
|
+
* ease-in — so the default is a real engine decision rather than a midpoint
|
|
67
|
+
* picked for tidiness. A control that hardcodes it drifts the moment the
|
|
68
|
+
* engine changes its mind, the same argument as `supported_step_range`.
|
|
69
|
+
* @returns {number}
|
|
70
|
+
*/
|
|
71
|
+
export function default_arc_accent() {
|
|
72
|
+
const ret = wasm.default_arc_accent();
|
|
73
|
+
return ret;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} brand
|
|
78
|
+
* @param {number} softness
|
|
79
|
+
* @returns {SoftNeutrals}
|
|
80
|
+
*/
|
|
81
|
+
export function derive_soft_neutrals(brand, softness) {
|
|
82
|
+
const ptr0 = passStringToWasm0(brand, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
83
|
+
const len0 = WASM_VECTOR_LEN;
|
|
84
|
+
const ret = wasm.derive_soft_neutrals(ptr0, len0, softness);
|
|
85
|
+
if (ret[2]) {
|
|
86
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
87
|
+
}
|
|
88
|
+
return takeFromExternrefTable0(ret[0]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Renders an OkLCH `{ l, c, h }` triple back into the engine's canonical
|
|
93
|
+
* `hex`/`rgb`/`oklch` strings, so the picker formats its current value through
|
|
94
|
+
* the same source of truth it parses with (RFC 0010 §4).
|
|
95
|
+
* @param {number} l
|
|
96
|
+
* @param {number} c
|
|
97
|
+
* @param {number} h
|
|
98
|
+
* @returns {OklchTriple}
|
|
99
|
+
*/
|
|
100
|
+
export function describe_oklch(l, c, h) {
|
|
101
|
+
const ret = wasm.describe_oklch(l, c, h);
|
|
102
|
+
return ret;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Builds an alpha ramp from a single anchor colour (Path A): the anchor held
|
|
107
|
+
* constant across ten steps while opacity climbs the shared curve. Neutral
|
|
108
|
+
* ramps pass their veil colour (soft-black in light, soft-white in dark);
|
|
109
|
+
* brand ramps pass the brand's identity swatch.
|
|
110
|
+
* @param {string} anchor
|
|
111
|
+
* @returns {AlphaRamp}
|
|
112
|
+
*/
|
|
113
|
+
export function generate_alpha_ramp(anchor) {
|
|
114
|
+
const ptr0 = passStringToWasm0(anchor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
115
|
+
const len0 = WASM_VECTOR_LEN;
|
|
116
|
+
const ret = wasm.generate_alpha_ramp(ptr0, len0);
|
|
117
|
+
if (ret[2]) {
|
|
118
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
119
|
+
}
|
|
120
|
+
return takeFromExternrefTable0(ret[0]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} white
|
|
125
|
+
* @param {string} black
|
|
126
|
+
* @param {TintMode} tint
|
|
127
|
+
* @param {number} bow
|
|
128
|
+
* @returns {Palette}
|
|
129
|
+
*/
|
|
130
|
+
export function generate_neutral_ramp(white, black, tint, bow) {
|
|
131
|
+
const ptr0 = passStringToWasm0(white, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
133
|
+
const ptr1 = passStringToWasm0(black, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
134
|
+
const len1 = WASM_VECTOR_LEN;
|
|
135
|
+
const ret = wasm.generate_neutral_ramp(ptr0, len0, ptr1, len1, tint, bow);
|
|
136
|
+
if (ret[2]) {
|
|
137
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
138
|
+
}
|
|
139
|
+
return takeFromExternrefTable0(ret[0]);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} hex
|
|
144
|
+
* @param {number} light_padding
|
|
145
|
+
* @param {number} dark_padding
|
|
146
|
+
* @returns {Palette}
|
|
147
|
+
*/
|
|
148
|
+
export function generate_palette(hex, light_padding, dark_padding) {
|
|
149
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
151
|
+
const ret = wasm.generate_palette(ptr0, len0, light_padding, dark_padding);
|
|
152
|
+
if (ret[2]) {
|
|
153
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
154
|
+
}
|
|
155
|
+
return takeFromExternrefTable0(ret[0]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @param {string} hex
|
|
160
|
+
* @param {Array<any>} light_lightness
|
|
161
|
+
* @param {Array<any>} dark_lightness
|
|
162
|
+
* @param {number} light_padding
|
|
163
|
+
* @param {number} dark_padding
|
|
164
|
+
* @returns {PaletteSet}
|
|
165
|
+
*/
|
|
166
|
+
export function generate_palette_pair(hex, light_lightness, dark_lightness, light_padding, dark_padding) {
|
|
167
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
168
|
+
const len0 = WASM_VECTOR_LEN;
|
|
169
|
+
const ret = wasm.generate_palette_pair(ptr0, len0, light_lightness, dark_lightness, light_padding, dark_padding);
|
|
170
|
+
if (ret[2]) {
|
|
171
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
172
|
+
}
|
|
173
|
+
return takeFromExternrefTable0(ret[0]);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A light/dark pair shaped by a curve preset instead of the built-in curves.
|
|
178
|
+
*
|
|
179
|
+
* Additive rather than a parameter on `generate_palette_pair_with_steps`,
|
|
180
|
+
* because a preset is genuinely opt-in: the hand-authored curves are not
|
|
181
|
+
* straight lines and no preset reproduces them, so "no preset" has to stay a
|
|
182
|
+
* distinct call rather than becoming `Linear` by default.
|
|
183
|
+
* @param {string} hex
|
|
184
|
+
* @param {number} steps
|
|
185
|
+
* @param {number} light_padding
|
|
186
|
+
* @param {number} dark_padding
|
|
187
|
+
* @param {CurvePreset} curve
|
|
188
|
+
* @returns {PaletteSet}
|
|
189
|
+
*/
|
|
190
|
+
export function generate_palette_pair_with_curve(hex, steps, light_padding, dark_padding, curve) {
|
|
191
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
+
const len0 = WASM_VECTOR_LEN;
|
|
193
|
+
const ret = wasm.generate_palette_pair_with_curve(ptr0, len0, steps, light_padding, dark_padding, curve);
|
|
194
|
+
if (ret[2]) {
|
|
195
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
196
|
+
}
|
|
197
|
+
return takeFromExternrefTable0(ret[0]);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* A light/dark pair of `steps` steps each, from the built-in curves.
|
|
202
|
+
* @param {string} hex
|
|
203
|
+
* @param {number} steps
|
|
204
|
+
* @param {number} light_padding
|
|
205
|
+
* @param {number} dark_padding
|
|
206
|
+
* @returns {PaletteSet}
|
|
207
|
+
*/
|
|
208
|
+
export function generate_palette_pair_with_steps(hex, steps, light_padding, dark_padding) {
|
|
209
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
210
|
+
const len0 = WASM_VECTOR_LEN;
|
|
211
|
+
const ret = wasm.generate_palette_pair_with_steps(ptr0, len0, steps, light_padding, dark_padding);
|
|
212
|
+
if (ret[2]) {
|
|
213
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
214
|
+
}
|
|
215
|
+
return takeFromExternrefTable0(ret[0]);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @param {string} hex
|
|
220
|
+
* @param {number} light_padding
|
|
221
|
+
* @returns {Palette}
|
|
222
|
+
*/
|
|
223
|
+
export function generate_palette_with_light_padding(hex, light_padding) {
|
|
224
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
225
|
+
const len0 = WASM_VECTOR_LEN;
|
|
226
|
+
const ret = wasm.generate_palette_with_light_padding(ptr0, len0, light_padding);
|
|
227
|
+
if (ret[2]) {
|
|
228
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
229
|
+
}
|
|
230
|
+
return takeFromExternrefTable0(ret[0]);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @param {string} hex
|
|
235
|
+
* @param {Array<any>} lightness
|
|
236
|
+
* @param {number} light_padding
|
|
237
|
+
* @param {number} dark_padding
|
|
238
|
+
* @returns {Palette}
|
|
239
|
+
*/
|
|
240
|
+
export function generate_palette_with_lightness(hex, lightness, light_padding, dark_padding) {
|
|
241
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
242
|
+
const len0 = WASM_VECTOR_LEN;
|
|
243
|
+
const ret = wasm.generate_palette_with_lightness(ptr0, len0, lightness, light_padding, dark_padding);
|
|
244
|
+
if (ret[2]) {
|
|
245
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
246
|
+
}
|
|
247
|
+
return takeFromExternrefTable0(ret[0]);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Generate a light palette of `steps` steps, reading the built-in curves at
|
|
252
|
+
* that resolution. `steps` outside the supported range is an error rather
|
|
253
|
+
* than being clamped, so a caller finds out it asked for the impossible.
|
|
254
|
+
* @param {string} hex
|
|
255
|
+
* @param {number} steps
|
|
256
|
+
* @param {number} light_padding
|
|
257
|
+
* @param {number} dark_padding
|
|
258
|
+
* @returns {Palette}
|
|
259
|
+
*/
|
|
260
|
+
export function generate_palette_with_steps(hex, steps, light_padding, dark_padding) {
|
|
261
|
+
const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
262
|
+
const len0 = WASM_VECTOR_LEN;
|
|
263
|
+
const ret = wasm.generate_palette_with_steps(ptr0, len0, steps, light_padding, dark_padding);
|
|
264
|
+
if (ret[2]) {
|
|
265
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
266
|
+
}
|
|
267
|
+
return takeFromExternrefTable0(ret[0]);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* @param {string} bg
|
|
272
|
+
* @param {string} fg
|
|
273
|
+
* @returns {ContrastResult}
|
|
274
|
+
*/
|
|
275
|
+
export function get_contrast_rating(bg, fg) {
|
|
276
|
+
const ptr0 = passStringToWasm0(bg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
278
|
+
const ptr1 = passStringToWasm0(fg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
279
|
+
const len1 = WASM_VECTOR_LEN;
|
|
280
|
+
const ret = wasm.get_contrast_rating(ptr0, len0, ptr1, len1);
|
|
281
|
+
if (ret[2]) {
|
|
282
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
283
|
+
}
|
|
284
|
+
return takeFromExternrefTable0(ret[0]);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* What `ratio` achieves when the colour is used as `use`.
|
|
289
|
+
*
|
|
290
|
+
* `get_contrast_rating` answers a different question — it reports a ratio and
|
|
291
|
+
* a single stringly-typed rating, which cannot say that one ratio is AA as
|
|
292
|
+
* body copy, AAA at heading size, and past the non-text bar all at once. A
|
|
293
|
+
* grade is what a designer decides on; compose this with the ratio from
|
|
294
|
+
* `get_contrast_rating` when the evidence behind the verdict is wanted too.
|
|
295
|
+
* @param {number} ratio
|
|
296
|
+
* @param {ContrastUse} use
|
|
297
|
+
* @returns {Grade}
|
|
298
|
+
*/
|
|
299
|
+
export function grade(ratio, use) {
|
|
300
|
+
const ret = wasm.grade(ratio, use);
|
|
301
|
+
return ret;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The maximum in-gamut chroma for an OkLCH lightness and hue, against the given
|
|
306
|
+
* `gamut` (sRGB or Display-P3) — the boundary curve the OKLCH picker overlays on
|
|
307
|
+
* its charts and clamps the cursor to (RFC 0010 §3, §7).
|
|
308
|
+
* @param {number} lightness
|
|
309
|
+
* @param {number} hue
|
|
310
|
+
* @param {Gamut} gamut
|
|
311
|
+
* @returns {number}
|
|
312
|
+
*/
|
|
313
|
+
export function max_in_gamut_chroma(lightness, hue, gamut) {
|
|
314
|
+
const ret = wasm.max_in_gamut_chroma(lightness, hue, gamut);
|
|
315
|
+
return ret;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Paints the OkLCH chroma×hue plane for a fixed lightness as a flat RGBA buffer
|
|
320
|
+
* (`width * height * 4` bytes, row-major) — the picker's Lightness chart. Hue
|
|
321
|
+
* runs left→right, chroma top→bottom; out-of-gamut pixels are transparent
|
|
322
|
+
* (RFC 0010 §3, §7).
|
|
323
|
+
* @param {number} lightness
|
|
324
|
+
* @param {number} width
|
|
325
|
+
* @param {number} height
|
|
326
|
+
* @param {number} c_max
|
|
327
|
+
* @param {Gamut} gamut
|
|
328
|
+
* @returns {Uint8Array}
|
|
329
|
+
*/
|
|
330
|
+
export function paint_ch_plane(lightness, width, height, c_max, gamut) {
|
|
331
|
+
const ret = wasm.paint_ch_plane(lightness, width, height, c_max, gamut);
|
|
332
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
333
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
334
|
+
return v1;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Paints the chroma sweep at a fixed lightness and hue against `gamut` as a flat
|
|
339
|
+
* RGBA buffer (`width * 4` bytes) for the picker's C slider track (RFC 0010 §7).
|
|
340
|
+
* @param {number} lightness
|
|
341
|
+
* @param {number} hue
|
|
342
|
+
* @param {number} width
|
|
343
|
+
* @param {number} c_max
|
|
344
|
+
* @param {Gamut} gamut
|
|
345
|
+
* @returns {Uint8Array}
|
|
346
|
+
*/
|
|
347
|
+
export function paint_chroma_strip(lightness, hue, width, c_max, gamut) {
|
|
348
|
+
const ret = wasm.paint_chroma_strip(lightness, hue, width, c_max, gamut);
|
|
349
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
350
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
351
|
+
return v1;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Paints the hue spectrum at a fixed lightness and chroma against `gamut` as a
|
|
356
|
+
* flat RGBA buffer (`width * 4` bytes) for the picker's hue slider track
|
|
357
|
+
* (RFC 0010 §3, §7).
|
|
358
|
+
* @param {number} lightness
|
|
359
|
+
* @param {number} chroma
|
|
360
|
+
* @param {number} width
|
|
361
|
+
* @param {Gamut} gamut
|
|
362
|
+
* @returns {Uint8Array}
|
|
363
|
+
*/
|
|
364
|
+
export function paint_hue_strip(lightness, chroma, width, gamut) {
|
|
365
|
+
const ret = wasm.paint_hue_strip(lightness, chroma, width, gamut);
|
|
366
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
367
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
368
|
+
return v1;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Paints the OkLCH lightness×chroma plane for a fixed hue as a flat RGBA
|
|
373
|
+
* buffer (`width * height * 4` bytes, row-major) the canvas blits straight
|
|
374
|
+
* into `ImageData`. Pixels carry `gamut` coordinates; out-of-gamut pixels are
|
|
375
|
+
* transparent (RFC 0010 §3, §7).
|
|
376
|
+
* @param {number} hue
|
|
377
|
+
* @param {number} width
|
|
378
|
+
* @param {number} height
|
|
379
|
+
* @param {number} c_max
|
|
380
|
+
* @param {Gamut} gamut
|
|
381
|
+
* @returns {Uint8Array}
|
|
382
|
+
*/
|
|
383
|
+
export function paint_lc_plane(hue, width, height, c_max, gamut) {
|
|
384
|
+
const ret = wasm.paint_lc_plane(hue, width, height, c_max, gamut);
|
|
385
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
386
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
387
|
+
return v1;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Paints the OkLCH lightness×hue plane for a fixed chroma as a flat RGBA buffer
|
|
392
|
+
* (`width * height * 4` bytes, row-major) — the picker's Chroma chart. Hue runs
|
|
393
|
+
* left→right, lightness top→bottom; out-of-gamut pixels are transparent
|
|
394
|
+
* (RFC 0010 §3, §7).
|
|
395
|
+
* @param {number} chroma
|
|
396
|
+
* @param {number} width
|
|
397
|
+
* @param {number} height
|
|
398
|
+
* @param {Gamut} gamut
|
|
399
|
+
* @returns {Uint8Array}
|
|
400
|
+
*/
|
|
401
|
+
export function paint_lh_plane(chroma, width, height, gamut) {
|
|
402
|
+
const ret = wasm.paint_lh_plane(chroma, width, height, gamut);
|
|
403
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
404
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
405
|
+
return v1;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Paints the lightness sweep at a fixed chroma and hue against `gamut` as a flat
|
|
410
|
+
* RGBA buffer (`width * 4` bytes) for the picker's L slider track (RFC 0010 §7).
|
|
411
|
+
* @param {number} chroma
|
|
412
|
+
* @param {number} hue
|
|
413
|
+
* @param {number} width
|
|
414
|
+
* @param {Gamut} gamut
|
|
415
|
+
* @param {number} l_min
|
|
416
|
+
* @param {number} l_max
|
|
417
|
+
* @returns {Uint8Array}
|
|
418
|
+
*/
|
|
419
|
+
export function paint_lightness_strip(chroma, hue, width, gamut, l_min, l_max) {
|
|
420
|
+
const ret = wasm.paint_lightness_strip(chroma, hue, width, gamut, l_min, l_max);
|
|
421
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
422
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
423
|
+
return v1;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* @param {string} input
|
|
428
|
+
* @returns {OklchTriple}
|
|
429
|
+
*/
|
|
430
|
+
export function parse_color(input) {
|
|
431
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
432
|
+
const len0 = WASM_VECTOR_LEN;
|
|
433
|
+
const ret = wasm.parse_color(ptr0, len0);
|
|
434
|
+
if (ret[2]) {
|
|
435
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
436
|
+
}
|
|
437
|
+
return takeFromExternrefTable0(ret[0]);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* The step of `ramp` to use for a role that must clear `threshold` against
|
|
442
|
+
* `surface` — a link colour, a muted-text colour, a border.
|
|
443
|
+
*
|
|
444
|
+
* Returns the **quietest** step that clears, not the first: a role wants the
|
|
445
|
+
* least contrast that still passes, because a border pushed to body-text
|
|
446
|
+
* weight passes its floor and looks like a mistake. `None` where nothing in
|
|
447
|
+
* the ramp reaches the threshold, rather than the least bad option.
|
|
448
|
+
*
|
|
449
|
+
* This is the question `get_best_foreground` cannot answer — that one draws
|
|
450
|
+
* from the ramp's ends and the white/black anchors, so it has nothing to say
|
|
451
|
+
* about which *mid-ramp* step is readable on some *other* surface.
|
|
452
|
+
* @param {Ramp} ramp
|
|
453
|
+
* @param {SwatchStep} surface
|
|
454
|
+
* @param {number} threshold
|
|
455
|
+
* @returns {ReadableStep | undefined}
|
|
456
|
+
*/
|
|
457
|
+
export function readable_step(ramp, surface, threshold) {
|
|
458
|
+
const ret = wasm.readable_step(ramp, surface, threshold);
|
|
459
|
+
return ret;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* The ramp lengths the engine supports, as `[min, default, max]` — what a
|
|
464
|
+
* step-count control should bound itself to rather than hardcoding.
|
|
465
|
+
* @returns {Uint32Array}
|
|
466
|
+
*/
|
|
467
|
+
export function supported_step_range() {
|
|
468
|
+
const ret = wasm.supported_step_range();
|
|
469
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
470
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
471
|
+
return v1;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @param {string} white
|
|
476
|
+
* @param {string} black
|
|
477
|
+
* @param {string} source
|
|
478
|
+
* @param {number} strength
|
|
479
|
+
* @returns {SoftNeutrals}
|
|
480
|
+
*/
|
|
481
|
+
export function tint_neutrals(white, black, source, strength) {
|
|
482
|
+
const ptr0 = passStringToWasm0(white, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
483
|
+
const len0 = WASM_VECTOR_LEN;
|
|
484
|
+
const ptr1 = passStringToWasm0(black, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
485
|
+
const len1 = WASM_VECTOR_LEN;
|
|
486
|
+
const ptr2 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
487
|
+
const len2 = WASM_VECTOR_LEN;
|
|
488
|
+
const ret = wasm.tint_neutrals(ptr0, len0, ptr1, len1, ptr2, len2, strength);
|
|
489
|
+
if (ret[2]) {
|
|
490
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
491
|
+
}
|
|
492
|
+
return takeFromExternrefTable0(ret[0]);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* @param {string} white
|
|
497
|
+
* @param {string} black
|
|
498
|
+
* @param {string} highlight
|
|
499
|
+
* @param {string} shadow
|
|
500
|
+
* @param {number} strength
|
|
501
|
+
* @returns {SoftNeutrals}
|
|
502
|
+
*/
|
|
503
|
+
export function tint_neutrals_duotone(white, black, highlight, shadow, strength) {
|
|
504
|
+
const ptr0 = passStringToWasm0(white, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
505
|
+
const len0 = WASM_VECTOR_LEN;
|
|
506
|
+
const ptr1 = passStringToWasm0(black, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
507
|
+
const len1 = WASM_VECTOR_LEN;
|
|
508
|
+
const ptr2 = passStringToWasm0(highlight, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
509
|
+
const len2 = WASM_VECTOR_LEN;
|
|
510
|
+
const ptr3 = passStringToWasm0(shadow, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
511
|
+
const len3 = WASM_VECTOR_LEN;
|
|
512
|
+
const ret = wasm.tint_neutrals_duotone(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, strength);
|
|
513
|
+
if (ret[2]) {
|
|
514
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
515
|
+
}
|
|
516
|
+
return takeFromExternrefTable0(ret[0]);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function __wbg_get_imports() {
|
|
520
|
+
const import0 = {
|
|
521
|
+
__proto__: null,
|
|
522
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
523
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
524
|
+
return ret;
|
|
525
|
+
},
|
|
526
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
527
|
+
const ret = String(arg1);
|
|
528
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
529
|
+
const len1 = WASM_VECTOR_LEN;
|
|
530
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
531
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
532
|
+
},
|
|
533
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
534
|
+
const ret = arg0 === undefined;
|
|
535
|
+
return ret;
|
|
536
|
+
},
|
|
537
|
+
__wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
|
|
538
|
+
const obj = arg1;
|
|
539
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
540
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
541
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
542
|
+
},
|
|
543
|
+
__wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
|
|
544
|
+
const obj = arg1;
|
|
545
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
546
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
547
|
+
var len1 = WASM_VECTOR_LEN;
|
|
548
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
549
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
550
|
+
},
|
|
551
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
552
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
553
|
+
},
|
|
554
|
+
__wbg_get_a8ee5c45dabc1b3b: function(arg0, arg1) {
|
|
555
|
+
const ret = arg0[arg1 >>> 0];
|
|
556
|
+
return ret;
|
|
557
|
+
},
|
|
558
|
+
__wbg_length_b3416cf66a5452c8: function(arg0) {
|
|
559
|
+
const ret = arg0.length;
|
|
560
|
+
return ret;
|
|
561
|
+
},
|
|
562
|
+
__wbg_new_a70fbab9066b301f: function() {
|
|
563
|
+
const ret = new Array();
|
|
564
|
+
return ret;
|
|
565
|
+
},
|
|
566
|
+
__wbg_new_ab79df5bd7c26067: function() {
|
|
567
|
+
const ret = new Object();
|
|
568
|
+
return ret;
|
|
569
|
+
},
|
|
570
|
+
__wbg_parse_e9eddd2a82c706eb: function() { return handleError(function (arg0, arg1) {
|
|
571
|
+
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
572
|
+
return ret;
|
|
573
|
+
}, arguments); },
|
|
574
|
+
__wbg_set_282384002438957f: function(arg0, arg1, arg2) {
|
|
575
|
+
arg0[arg1 >>> 0] = arg2;
|
|
576
|
+
},
|
|
577
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
578
|
+
arg0[arg1] = arg2;
|
|
579
|
+
},
|
|
580
|
+
__wbg_stringify_5ae93966a84901ac: function() { return handleError(function (arg0) {
|
|
581
|
+
const ret = JSON.stringify(arg0);
|
|
582
|
+
return ret;
|
|
583
|
+
}, arguments); },
|
|
584
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
585
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
586
|
+
const ret = arg0;
|
|
587
|
+
return ret;
|
|
588
|
+
},
|
|
589
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
590
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
591
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
592
|
+
return ret;
|
|
593
|
+
},
|
|
594
|
+
__wbindgen_init_externref_table: function() {
|
|
595
|
+
const table = wasm.__wbindgen_externrefs;
|
|
596
|
+
const offset = table.grow(4);
|
|
597
|
+
table.set(0, undefined);
|
|
598
|
+
table.set(offset + 0, undefined);
|
|
599
|
+
table.set(offset + 1, null);
|
|
600
|
+
table.set(offset + 2, true);
|
|
601
|
+
table.set(offset + 3, false);
|
|
602
|
+
},
|
|
603
|
+
};
|
|
604
|
+
return {
|
|
605
|
+
__proto__: null,
|
|
606
|
+
"./harmoni_wasm_bg.js": import0,
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
function addToExternrefTable0(obj) {
|
|
611
|
+
const idx = wasm.__externref_table_alloc();
|
|
612
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
613
|
+
return idx;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
617
|
+
ptr = ptr >>> 0;
|
|
618
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
622
|
+
ptr = ptr >>> 0;
|
|
623
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
627
|
+
ptr = ptr >>> 0;
|
|
628
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
let cachedDataViewMemory0 = null;
|
|
632
|
+
function getDataViewMemory0() {
|
|
633
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
634
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
635
|
+
}
|
|
636
|
+
return cachedDataViewMemory0;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
640
|
+
function getFloat32ArrayMemory0() {
|
|
641
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
642
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
643
|
+
}
|
|
644
|
+
return cachedFloat32ArrayMemory0;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function getStringFromWasm0(ptr, len) {
|
|
648
|
+
ptr = ptr >>> 0;
|
|
649
|
+
return decodeText(ptr, len);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
let cachedUint32ArrayMemory0 = null;
|
|
653
|
+
function getUint32ArrayMemory0() {
|
|
654
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
655
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
656
|
+
}
|
|
657
|
+
return cachedUint32ArrayMemory0;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
let cachedUint8ArrayMemory0 = null;
|
|
661
|
+
function getUint8ArrayMemory0() {
|
|
662
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
663
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
664
|
+
}
|
|
665
|
+
return cachedUint8ArrayMemory0;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function handleError(f, args) {
|
|
669
|
+
try {
|
|
670
|
+
return f.apply(this, args);
|
|
671
|
+
} catch (e) {
|
|
672
|
+
const idx = addToExternrefTable0(e);
|
|
673
|
+
wasm.__wbindgen_exn_store(idx);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function isLikeNone(x) {
|
|
678
|
+
return x === undefined || x === null;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
682
|
+
if (realloc === undefined) {
|
|
683
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
684
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
685
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
686
|
+
WASM_VECTOR_LEN = buf.length;
|
|
687
|
+
return ptr;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
let len = arg.length;
|
|
691
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
692
|
+
|
|
693
|
+
const mem = getUint8ArrayMemory0();
|
|
694
|
+
|
|
695
|
+
let offset = 0;
|
|
696
|
+
|
|
697
|
+
for (; offset < len; offset++) {
|
|
698
|
+
const code = arg.charCodeAt(offset);
|
|
699
|
+
if (code > 0x7F) break;
|
|
700
|
+
mem[ptr + offset] = code;
|
|
701
|
+
}
|
|
702
|
+
if (offset !== len) {
|
|
703
|
+
if (offset !== 0) {
|
|
704
|
+
arg = arg.slice(offset);
|
|
705
|
+
}
|
|
706
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
707
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
708
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
709
|
+
|
|
710
|
+
offset += ret.written;
|
|
711
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
WASM_VECTOR_LEN = offset;
|
|
715
|
+
return ptr;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function takeFromExternrefTable0(idx) {
|
|
719
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
720
|
+
wasm.__externref_table_dealloc(idx);
|
|
721
|
+
return value;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
725
|
+
cachedTextDecoder.decode();
|
|
726
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
727
|
+
let numBytesDecoded = 0;
|
|
728
|
+
function decodeText(ptr, len) {
|
|
729
|
+
numBytesDecoded += len;
|
|
730
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
731
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
732
|
+
cachedTextDecoder.decode();
|
|
733
|
+
numBytesDecoded = len;
|
|
734
|
+
}
|
|
735
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
const cachedTextEncoder = new TextEncoder();
|
|
739
|
+
|
|
740
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
741
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
742
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
743
|
+
view.set(buf);
|
|
744
|
+
return {
|
|
745
|
+
read: arg.length,
|
|
746
|
+
written: buf.length
|
|
747
|
+
};
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
let WASM_VECTOR_LEN = 0;
|
|
752
|
+
|
|
753
|
+
let wasmModule, wasm;
|
|
754
|
+
function __wbg_finalize_init(instance, module) {
|
|
755
|
+
wasm = instance.exports;
|
|
756
|
+
wasmModule = module;
|
|
757
|
+
cachedDataViewMemory0 = null;
|
|
758
|
+
cachedFloat32ArrayMemory0 = null;
|
|
759
|
+
cachedUint32ArrayMemory0 = null;
|
|
760
|
+
cachedUint8ArrayMemory0 = null;
|
|
761
|
+
wasm.__wbindgen_start();
|
|
762
|
+
return wasm;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
async function __wbg_load(module, imports) {
|
|
766
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
767
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
768
|
+
try {
|
|
769
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
770
|
+
} catch (e) {
|
|
771
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
772
|
+
|
|
773
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
774
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
775
|
+
|
|
776
|
+
} else { throw e; }
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const bytes = await module.arrayBuffer();
|
|
781
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
782
|
+
} else {
|
|
783
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
784
|
+
|
|
785
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
786
|
+
return { instance, module };
|
|
787
|
+
} else {
|
|
788
|
+
return instance;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
function expectedResponseType(type) {
|
|
793
|
+
switch (type) {
|
|
794
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
795
|
+
}
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function initSync(module) {
|
|
801
|
+
if (wasm !== undefined) return wasm;
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
if (module !== undefined) {
|
|
805
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
806
|
+
({module} = module)
|
|
807
|
+
} else {
|
|
808
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
const imports = __wbg_get_imports();
|
|
813
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
814
|
+
module = new WebAssembly.Module(module);
|
|
815
|
+
}
|
|
816
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
817
|
+
return __wbg_finalize_init(instance, module);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
async function __wbg_init(module_or_path) {
|
|
821
|
+
if (wasm !== undefined) return wasm;
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
if (module_or_path !== undefined) {
|
|
825
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
826
|
+
({module_or_path} = module_or_path)
|
|
827
|
+
} else {
|
|
828
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
if (module_or_path === undefined) {
|
|
833
|
+
module_or_path = new URL('harmoni_wasm_bg.wasm', import.meta.url);
|
|
834
|
+
}
|
|
835
|
+
const imports = __wbg_get_imports();
|
|
836
|
+
|
|
837
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
838
|
+
module_or_path = fetch(module_or_path);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
842
|
+
|
|
843
|
+
return __wbg_finalize_init(instance, module);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@primitiv-ui/harmoni-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "Public wasm-pack build of harmoni-core, the Primitiv palette engine.",
|
|
5
|
+
"version": "0.1.30",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/primitiv-ui/primitiv.git"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"harmoni_wasm_bg.wasm",
|
|
13
|
+
"harmoni_wasm.js",
|
|
14
|
+
"harmoni_wasm.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"main": "harmoni_wasm.js",
|
|
17
|
+
"types": "harmoni_wasm.d.ts",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./snippets/*"
|
|
20
|
+
]
|
|
21
|
+
}
|