@primitiv-ui/harmoni-wasm 0.1.33 → 0.1.35
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 +29 -0
- package/harmoni_wasm.js +63 -0
- package/harmoni_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/harmoni_wasm.d.ts
CHANGED
|
@@ -216,6 +216,16 @@ export function generate_alpha_ramp(anchor: string): AlphaRamp;
|
|
|
216
216
|
*/
|
|
217
217
|
export function generate_alpha_ramp_with_steps(anchor: string, steps: number): AlphaRamp;
|
|
218
218
|
|
|
219
|
+
/**
|
|
220
|
+
* A neutral ramp in both modes from anchors that are **already** tinted, for a
|
|
221
|
+
* caller that did its own tinting (or wants none).
|
|
222
|
+
*
|
|
223
|
+
* [`generate_tinted_neutral_pair`] is the one to reach for. This is the seam
|
|
224
|
+
* underneath it, kept public because the anchors are a legitimate thing to hold
|
|
225
|
+
* directly — the Harmoni project stores its own `SoftNeutrals`.
|
|
226
|
+
*/
|
|
227
|
+
export function generate_neutral_pair(white: string, black: string, tint: TintMode, bow: number, steps: number): PaletteSet;
|
|
228
|
+
|
|
219
229
|
export function generate_neutral_ramp(white: string, black: string, tint: TintMode, bow: number): Palette;
|
|
220
230
|
|
|
221
231
|
/**
|
|
@@ -263,6 +273,23 @@ export function generate_palette_with_lightness(hex: string, lightness: Array<an
|
|
|
263
273
|
*/
|
|
264
274
|
export function generate_palette_with_steps(hex: string, steps: number, light_padding: number, dark_padding: number): Palette;
|
|
265
275
|
|
|
276
|
+
/**
|
|
277
|
+
* A neutral ramp in **both modes**, with its tint applied — the plugin's whole
|
|
278
|
+
* neutral generation in one call.
|
|
279
|
+
*
|
|
280
|
+
* This exists to take work away from TypeScript. The plugin's adapter was
|
|
281
|
+
* choosing between `tint_neutrals` and `tint_neutrals_duotone`, splitting the
|
|
282
|
+
* source hue by the spread, zeroing `bow` when untinted, and calling the
|
|
283
|
+
* generator twice with the anchors swapped. Every one of those is a colour
|
|
284
|
+
* decision, and colour decisions belong to the engine — the adapter's job is to
|
|
285
|
+
* marshal input in and results out, nothing else.
|
|
286
|
+
*
|
|
287
|
+
* `tint_source` of `None` is an untinted grey, which is what `tint === null` has
|
|
288
|
+
* always meant on the plugin side. `strength`, `spread` and `bow` are ignored in
|
|
289
|
+
* that case rather than shaping nothing.
|
|
290
|
+
*/
|
|
291
|
+
export function generate_tinted_neutral_pair(white: string, black: string, tint_source: string | null | undefined, strength: number, spread: number, bow: number, steps: number): PaletteSet;
|
|
292
|
+
|
|
266
293
|
export function get_contrast_rating(bg: string, fg: string): ContrastResult;
|
|
267
294
|
|
|
268
295
|
/**
|
|
@@ -365,6 +392,7 @@ export interface InitOutput {
|
|
|
365
392
|
readonly describe_oklch: (a: number, b: number, c: number) => any;
|
|
366
393
|
readonly generate_alpha_ramp: (a: number, b: number) => [number, number, number];
|
|
367
394
|
readonly generate_alpha_ramp_with_steps: (a: number, b: number, c: number) => [number, number, number];
|
|
395
|
+
readonly generate_neutral_pair: (a: number, b: number, c: number, d: number, e: any, f: number, g: number) => [number, number, number];
|
|
368
396
|
readonly generate_neutral_ramp: (a: number, b: number, c: number, d: number, e: any, f: number) => [number, number, number];
|
|
369
397
|
readonly generate_neutral_ramp_with_steps: (a: number, b: number, c: number, d: number, e: any, f: number, g: number) => [number, number, number];
|
|
370
398
|
readonly generate_palette: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
@@ -374,6 +402,7 @@ export interface InitOutput {
|
|
|
374
402
|
readonly generate_palette_with_light_padding: (a: number, b: number, c: number) => [number, number, number];
|
|
375
403
|
readonly generate_palette_with_lightness: (a: number, b: number, c: any, d: number, e: number) => [number, number, number];
|
|
376
404
|
readonly generate_palette_with_steps: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
405
|
+
readonly generate_tinted_neutral_pair: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number];
|
|
377
406
|
readonly get_contrast_rating: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
378
407
|
readonly grade: (a: number, b: any) => any;
|
|
379
408
|
readonly max_in_gamut_chroma: (a: number, b: number, c: any) => number;
|
package/harmoni_wasm.js
CHANGED
|
@@ -140,6 +140,32 @@ export function generate_alpha_ramp_with_steps(anchor, steps) {
|
|
|
140
140
|
return takeFromExternrefTable0(ret[0]);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* A neutral ramp in both modes from anchors that are **already** tinted, for a
|
|
145
|
+
* caller that did its own tinting (or wants none).
|
|
146
|
+
*
|
|
147
|
+
* [`generate_tinted_neutral_pair`] is the one to reach for. This is the seam
|
|
148
|
+
* underneath it, kept public because the anchors are a legitimate thing to hold
|
|
149
|
+
* directly — the Harmoni project stores its own `SoftNeutrals`.
|
|
150
|
+
* @param {string} white
|
|
151
|
+
* @param {string} black
|
|
152
|
+
* @param {TintMode} tint
|
|
153
|
+
* @param {number} bow
|
|
154
|
+
* @param {number} steps
|
|
155
|
+
* @returns {PaletteSet}
|
|
156
|
+
*/
|
|
157
|
+
export function generate_neutral_pair(white, black, tint, bow, steps) {
|
|
158
|
+
const ptr0 = passStringToWasm0(white, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
159
|
+
const len0 = WASM_VECTOR_LEN;
|
|
160
|
+
const ptr1 = passStringToWasm0(black, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
161
|
+
const len1 = WASM_VECTOR_LEN;
|
|
162
|
+
const ret = wasm.generate_neutral_pair(ptr0, len0, ptr1, len1, tint, bow, steps);
|
|
163
|
+
if (ret[2]) {
|
|
164
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
165
|
+
}
|
|
166
|
+
return takeFromExternrefTable0(ret[0]);
|
|
167
|
+
}
|
|
168
|
+
|
|
143
169
|
/**
|
|
144
170
|
* @param {string} white
|
|
145
171
|
* @param {string} black
|
|
@@ -318,6 +344,43 @@ export function generate_palette_with_steps(hex, steps, light_padding, dark_padd
|
|
|
318
344
|
return takeFromExternrefTable0(ret[0]);
|
|
319
345
|
}
|
|
320
346
|
|
|
347
|
+
/**
|
|
348
|
+
* A neutral ramp in **both modes**, with its tint applied — the plugin's whole
|
|
349
|
+
* neutral generation in one call.
|
|
350
|
+
*
|
|
351
|
+
* This exists to take work away from TypeScript. The plugin's adapter was
|
|
352
|
+
* choosing between `tint_neutrals` and `tint_neutrals_duotone`, splitting the
|
|
353
|
+
* source hue by the spread, zeroing `bow` when untinted, and calling the
|
|
354
|
+
* generator twice with the anchors swapped. Every one of those is a colour
|
|
355
|
+
* decision, and colour decisions belong to the engine — the adapter's job is to
|
|
356
|
+
* marshal input in and results out, nothing else.
|
|
357
|
+
*
|
|
358
|
+
* `tint_source` of `None` is an untinted grey, which is what `tint === null` has
|
|
359
|
+
* always meant on the plugin side. `strength`, `spread` and `bow` are ignored in
|
|
360
|
+
* that case rather than shaping nothing.
|
|
361
|
+
* @param {string} white
|
|
362
|
+
* @param {string} black
|
|
363
|
+
* @param {string | null | undefined} tint_source
|
|
364
|
+
* @param {number} strength
|
|
365
|
+
* @param {number} spread
|
|
366
|
+
* @param {number} bow
|
|
367
|
+
* @param {number} steps
|
|
368
|
+
* @returns {PaletteSet}
|
|
369
|
+
*/
|
|
370
|
+
export function generate_tinted_neutral_pair(white, black, tint_source, strength, spread, bow, steps) {
|
|
371
|
+
const ptr0 = passStringToWasm0(white, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
372
|
+
const len0 = WASM_VECTOR_LEN;
|
|
373
|
+
const ptr1 = passStringToWasm0(black, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
374
|
+
const len1 = WASM_VECTOR_LEN;
|
|
375
|
+
var ptr2 = isLikeNone(tint_source) ? 0 : passStringToWasm0(tint_source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
376
|
+
var len2 = WASM_VECTOR_LEN;
|
|
377
|
+
const ret = wasm.generate_tinted_neutral_pair(ptr0, len0, ptr1, len1, ptr2, len2, strength, spread, bow, steps);
|
|
378
|
+
if (ret[2]) {
|
|
379
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
380
|
+
}
|
|
381
|
+
return takeFromExternrefTable0(ret[0]);
|
|
382
|
+
}
|
|
383
|
+
|
|
321
384
|
/**
|
|
322
385
|
* @param {string} bg
|
|
323
386
|
* @param {string} fg
|
package/harmoni_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED