@fontmin-rs/wasm 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-PRESENT ntnyq <https://github.com/ntnyq>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,458 @@
1
+ //#region src/generated/fontmin_wasm_core.js
2
+ /**
3
+ * @param {any} sources
4
+ * @param {any} options_value
5
+ * @returns {any}
6
+ */
7
+ function generate_css(sources, options_value) {
8
+ const ret = wasm.generate_css(sources, options_value);
9
+ if (ret[2]) throw takeFromExternrefTable0(ret[1]);
10
+ return takeFromExternrefTable0(ret[0]);
11
+ }
12
+ /**
13
+ * @returns {string}
14
+ */
15
+ function runtime_name() {
16
+ let deferred1_0;
17
+ let deferred1_1;
18
+ try {
19
+ const ret = wasm.runtime_name();
20
+ deferred1_0 = ret[0];
21
+ deferred1_1 = ret[1];
22
+ return getStringFromWasm0(ret[0], ret[1]);
23
+ } finally {
24
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
25
+ }
26
+ }
27
+ /**
28
+ * @param {string} operation
29
+ * @param {Uint8Array} input
30
+ * @param {any} options
31
+ * @returns {any}
32
+ */
33
+ function transform(operation, input, options) {
34
+ const ptr0 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
35
+ const len0 = WASM_VECTOR_LEN;
36
+ const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
37
+ const len1 = WASM_VECTOR_LEN;
38
+ const ret = wasm.transform(ptr0, len0, ptr1, len1, options);
39
+ if (ret[2]) throw takeFromExternrefTable0(ret[1]);
40
+ return takeFromExternrefTable0(ret[0]);
41
+ }
42
+ /**
43
+ * @param {any} inputs
44
+ * @param {any} options
45
+ * @returns {any}
46
+ */
47
+ function transform_icons(inputs, options) {
48
+ const ret = wasm.transform_icons(inputs, options);
49
+ if (ret[2]) throw takeFromExternrefTable0(ret[1]);
50
+ return takeFromExternrefTable0(ret[0]);
51
+ }
52
+ /**
53
+ * @param {string} operation
54
+ * @param {string} input
55
+ * @param {any} options
56
+ * @returns {any}
57
+ */
58
+ function transform_text(operation, input, options) {
59
+ const ptr0 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len0 = WASM_VECTOR_LEN;
61
+ const ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
62
+ const len1 = WASM_VECTOR_LEN;
63
+ const ret = wasm.transform_text(ptr0, len0, ptr1, len1, options);
64
+ if (ret[2]) throw takeFromExternrefTable0(ret[1]);
65
+ return takeFromExternrefTable0(ret[0]);
66
+ }
67
+ function __wbg_get_imports() {
68
+ return {
69
+ __proto__: null,
70
+ "./fontmin_wasm_core_bg.js": {
71
+ __proto__: null,
72
+ __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
73
+ return Error(getStringFromWasm0(arg0, arg1));
74
+ },
75
+ __wbg_Number_9a4e0ecb0fa16705: function(arg0) {
76
+ return Number(arg0);
77
+ },
78
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
79
+ const ptr1 = passStringToWasm0(String(arg1), wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
80
+ const len1 = WASM_VECTOR_LEN;
81
+ getDataViewMemory0().setInt32(arg0 + 4, len1, true);
82
+ getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
83
+ },
84
+ __wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f: function(arg0, arg1) {
85
+ const v = arg1;
86
+ const ret = typeof v === "bigint" ? v : void 0;
87
+ getDataViewMemory0().setBigInt64(arg0 + 8, isLikeNone(ret) ? BigInt(0) : ret, true);
88
+ getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), true);
89
+ },
90
+ __wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
91
+ const v = arg0;
92
+ const ret = typeof v === "boolean" ? v : void 0;
93
+ return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
94
+ },
95
+ __wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
96
+ const ptr1 = passStringToWasm0(debugString(arg1), wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
97
+ const len1 = WASM_VECTOR_LEN;
98
+ getDataViewMemory0().setInt32(arg0 + 4, len1, true);
99
+ getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
100
+ },
101
+ __wbg___wbindgen_in_aca499c5de7ff5e5: function(arg0, arg1) {
102
+ return arg0 in arg1;
103
+ },
104
+ __wbg___wbindgen_is_bigint_2f76dc55065b4273: function(arg0) {
105
+ return typeof arg0 === "bigint";
106
+ },
107
+ __wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
108
+ return typeof arg0 === "function";
109
+ },
110
+ __wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
111
+ const val = arg0;
112
+ return typeof val === "object" && val !== null;
113
+ },
114
+ __wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) {
115
+ return typeof arg0 === "string";
116
+ },
117
+ __wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
118
+ return arg0 === void 0;
119
+ },
120
+ __wbg___wbindgen_jsval_eq_e659fcf7b0e32763: function(arg0, arg1) {
121
+ return arg0 === arg1;
122
+ },
123
+ __wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
124
+ return arg0 == arg1;
125
+ },
126
+ __wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
127
+ const obj = arg1;
128
+ const ret = typeof obj === "number" ? obj : void 0;
129
+ getDataViewMemory0().setFloat64(arg0 + 8, isLikeNone(ret) ? 0 : ret, true);
130
+ getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), true);
131
+ },
132
+ __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
133
+ const obj = arg1;
134
+ const ret = typeof obj === "string" ? obj : void 0;
135
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136
+ var len1 = WASM_VECTOR_LEN;
137
+ getDataViewMemory0().setInt32(arg0 + 4, len1, true);
138
+ getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
139
+ },
140
+ __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
141
+ throw new Error(getStringFromWasm0(arg0, arg1));
142
+ },
143
+ __wbg_call_8a2dd23819f8a60a: function() {
144
+ return handleError(function(arg0, arg1) {
145
+ return arg0.call(arg1);
146
+ }, arguments);
147
+ },
148
+ __wbg_done_89b2b13e91a60321: function(arg0) {
149
+ return arg0.done;
150
+ },
151
+ __wbg_entries_015dc610cd81ede0: function(arg0) {
152
+ return Object.entries(arg0);
153
+ },
154
+ __wbg_get_507a50627bffa49b: function(arg0, arg1) {
155
+ return arg0[arg1 >>> 0];
156
+ },
157
+ __wbg_get_c7eb1f358a7654df: function() {
158
+ return handleError(function(arg0, arg1) {
159
+ return Reflect.get(arg0, arg1);
160
+ }, arguments);
161
+ },
162
+ __wbg_get_unchecked_6e0ad6d2a41b06f6: function(arg0, arg1) {
163
+ return arg0[arg1 >>> 0];
164
+ },
165
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
166
+ return arg0[arg1];
167
+ },
168
+ __wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
169
+ let result;
170
+ try {
171
+ result = arg0 instanceof ArrayBuffer;
172
+ } catch (_) {
173
+ result = false;
174
+ }
175
+ return result;
176
+ },
177
+ __wbg_instanceof_Map_e5b5e3db98422fcc: function(arg0) {
178
+ let result;
179
+ try {
180
+ result = arg0 instanceof Map;
181
+ } catch (_) {
182
+ result = false;
183
+ }
184
+ return result;
185
+ },
186
+ __wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
187
+ let result;
188
+ try {
189
+ result = arg0 instanceof Uint8Array;
190
+ } catch (_) {
191
+ result = false;
192
+ }
193
+ return result;
194
+ },
195
+ __wbg_isArray_0677c962b281d01a: function(arg0) {
196
+ return Array.isArray(arg0);
197
+ },
198
+ __wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
199
+ return Number.isSafeInteger(arg0);
200
+ },
201
+ __wbg_iterator_6f722e4a93058b71: function() {
202
+ return Symbol.iterator;
203
+ },
204
+ __wbg_length_1f0964f4a5e2c6d8: function(arg0) {
205
+ return arg0.length;
206
+ },
207
+ __wbg_length_370319915dc99107: function(arg0) {
208
+ return arg0.length;
209
+ },
210
+ __wbg_new_32b398fb48b6d94a: function() {
211
+ return new Array();
212
+ },
213
+ __wbg_new_7796ffc7ed656783: function() {
214
+ return /* @__PURE__ */ new Map();
215
+ },
216
+ __wbg_new_cd45aabdf6073e84: function(arg0) {
217
+ return new Uint8Array(arg0);
218
+ },
219
+ __wbg_new_da52cf8fe3429cb2: function() {
220
+ return /* @__PURE__ */ new Object();
221
+ },
222
+ __wbg_next_6dbf2c0ac8cde20f: function(arg0) {
223
+ return arg0.next;
224
+ },
225
+ __wbg_next_71f2aa1cb3d1e37e: function() {
226
+ return handleError(function(arg0) {
227
+ return arg0.next();
228
+ }, arguments);
229
+ },
230
+ __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
231
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
232
+ },
233
+ __wbg_set_575dd786d51585f8: function(arg0, arg1, arg2) {
234
+ return arg0.set(arg1, arg2);
235
+ },
236
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
237
+ arg0[arg1] = arg2;
238
+ },
239
+ __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
240
+ arg0[arg1 >>> 0] = arg2;
241
+ },
242
+ __wbg_value_a5d5488a9589444a: function(arg0) {
243
+ return arg0.value;
244
+ },
245
+ __wbindgen_cast_0000000000000001: function(arg0) {
246
+ return arg0;
247
+ },
248
+ __wbindgen_cast_0000000000000002: function(arg0) {
249
+ return arg0;
250
+ },
251
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
252
+ return getStringFromWasm0(arg0, arg1);
253
+ },
254
+ __wbindgen_cast_0000000000000004: function(arg0) {
255
+ return BigInt.asUintN(64, arg0);
256
+ },
257
+ __wbindgen_init_externref_table: function() {
258
+ const table = wasm.__wbindgen_externrefs;
259
+ const offset = table.grow(4);
260
+ table.set(0, void 0);
261
+ table.set(offset + 0, void 0);
262
+ table.set(offset + 1, null);
263
+ table.set(offset + 2, true);
264
+ table.set(offset + 3, false);
265
+ }
266
+ }
267
+ };
268
+ }
269
+ function addToExternrefTable0(obj) {
270
+ const idx = wasm.__externref_table_alloc();
271
+ wasm.__wbindgen_externrefs.set(idx, obj);
272
+ return idx;
273
+ }
274
+ function debugString(val) {
275
+ const type = typeof val;
276
+ if (type == "number" || type == "boolean" || val == null) return `${val}`;
277
+ if (type == "string") return `"${val}"`;
278
+ if (type == "symbol") {
279
+ const description = val.description;
280
+ if (description == null) return "Symbol";
281
+ else return `Symbol(${description})`;
282
+ }
283
+ if (type == "function") {
284
+ const name = val.name;
285
+ if (typeof name == "string" && name.length > 0) return `Function(${name})`;
286
+ else return "Function";
287
+ }
288
+ if (Array.isArray(val)) {
289
+ const length = val.length;
290
+ let debug = "[";
291
+ if (length > 0) debug += debugString(val[0]);
292
+ for (let i = 1; i < length; i++) debug += ", " + debugString(val[i]);
293
+ debug += "]";
294
+ return debug;
295
+ }
296
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
297
+ let className;
298
+ if (builtInMatches && builtInMatches.length > 1) className = builtInMatches[1];
299
+ else return toString.call(val);
300
+ if (className == "Object") try {
301
+ return "Object(" + JSON.stringify(val) + ")";
302
+ } catch (_) {
303
+ return "Object";
304
+ }
305
+ if (val instanceof Error) return `${val.name}: ${val.message}\n${val.stack}`;
306
+ return className;
307
+ }
308
+ function getArrayU8FromWasm0(ptr, len) {
309
+ ptr = ptr >>> 0;
310
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
311
+ }
312
+ let cachedDataViewMemory0 = null;
313
+ function getDataViewMemory0() {
314
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
315
+ return cachedDataViewMemory0;
316
+ }
317
+ function getStringFromWasm0(ptr, len) {
318
+ return decodeText(ptr >>> 0, len);
319
+ }
320
+ let cachedUint8ArrayMemory0 = null;
321
+ function getUint8ArrayMemory0() {
322
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
323
+ return cachedUint8ArrayMemory0;
324
+ }
325
+ function handleError(f, args) {
326
+ try {
327
+ return f.apply(this, args);
328
+ } catch (e) {
329
+ const idx = addToExternrefTable0(e);
330
+ wasm.__wbindgen_exn_store(idx);
331
+ }
332
+ }
333
+ function isLikeNone(x) {
334
+ return x === void 0 || x === null;
335
+ }
336
+ function passArray8ToWasm0(arg, malloc) {
337
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
338
+ getUint8ArrayMemory0().set(arg, ptr / 1);
339
+ WASM_VECTOR_LEN = arg.length;
340
+ return ptr;
341
+ }
342
+ function passStringToWasm0(arg, malloc, realloc) {
343
+ if (realloc === void 0) {
344
+ const buf = cachedTextEncoder.encode(arg);
345
+ const ptr = malloc(buf.length, 1) >>> 0;
346
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
347
+ WASM_VECTOR_LEN = buf.length;
348
+ return ptr;
349
+ }
350
+ let len = arg.length;
351
+ let ptr = malloc(len, 1) >>> 0;
352
+ const mem = getUint8ArrayMemory0();
353
+ let offset = 0;
354
+ for (; offset < len; offset++) {
355
+ const code = arg.charCodeAt(offset);
356
+ if (code > 127) break;
357
+ mem[ptr + offset] = code;
358
+ }
359
+ if (offset !== len) {
360
+ if (offset !== 0) arg = arg.slice(offset);
361
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
362
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
363
+ const ret = cachedTextEncoder.encodeInto(arg, view);
364
+ offset += ret.written;
365
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
366
+ }
367
+ WASM_VECTOR_LEN = offset;
368
+ return ptr;
369
+ }
370
+ function takeFromExternrefTable0(idx) {
371
+ const value = wasm.__wbindgen_externrefs.get(idx);
372
+ wasm.__externref_table_dealloc(idx);
373
+ return value;
374
+ }
375
+ let cachedTextDecoder = new TextDecoder("utf-8", {
376
+ ignoreBOM: true,
377
+ fatal: true
378
+ });
379
+ cachedTextDecoder.decode();
380
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
381
+ let numBytesDecoded = 0;
382
+ function decodeText(ptr, len) {
383
+ numBytesDecoded += len;
384
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
385
+ cachedTextDecoder = new TextDecoder("utf-8", {
386
+ ignoreBOM: true,
387
+ fatal: true
388
+ });
389
+ cachedTextDecoder.decode();
390
+ numBytesDecoded = len;
391
+ }
392
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
393
+ }
394
+ const cachedTextEncoder = new TextEncoder();
395
+ if (!("encodeInto" in cachedTextEncoder)) cachedTextEncoder.encodeInto = function(arg, view) {
396
+ const buf = cachedTextEncoder.encode(arg);
397
+ view.set(buf);
398
+ return {
399
+ read: arg.length,
400
+ written: buf.length
401
+ };
402
+ };
403
+ let WASM_VECTOR_LEN = 0;
404
+ let wasm;
405
+ function __wbg_finalize_init(instance, module) {
406
+ wasm = instance.exports;
407
+ cachedDataViewMemory0 = null;
408
+ cachedUint8ArrayMemory0 = null;
409
+ wasm.__wbindgen_start();
410
+ return wasm;
411
+ }
412
+ async function __wbg_load(module, imports) {
413
+ if (typeof Response === "function" && module instanceof Response) {
414
+ if (typeof WebAssembly.instantiateStreaming === "function") try {
415
+ return await WebAssembly.instantiateStreaming(module, imports);
416
+ } catch (e) {
417
+ if (module.ok && expectedResponseType(module.type) && module.headers.get("Content-Type") !== "application/wasm") 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);
418
+ else throw e;
419
+ }
420
+ const bytes = await module.arrayBuffer();
421
+ return await WebAssembly.instantiate(bytes, imports);
422
+ } else {
423
+ const instance = await WebAssembly.instantiate(module, imports);
424
+ if (instance instanceof WebAssembly.Instance) return {
425
+ instance,
426
+ module
427
+ };
428
+ else return instance;
429
+ }
430
+ function expectedResponseType(type) {
431
+ switch (type) {
432
+ case "basic":
433
+ case "cors":
434
+ case "default": return true;
435
+ }
436
+ return false;
437
+ }
438
+ }
439
+ function initSync(module) {
440
+ if (wasm !== void 0) return wasm;
441
+ if (module !== void 0) if (Object.getPrototypeOf(module) === Object.prototype) ({module} = module);
442
+ else console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
443
+ const imports = __wbg_get_imports();
444
+ if (!(module instanceof WebAssembly.Module)) module = new WebAssembly.Module(module);
445
+ return __wbg_finalize_init(new WebAssembly.Instance(module, imports), module);
446
+ }
447
+ async function __wbg_init(module_or_path) {
448
+ if (wasm !== void 0) return wasm;
449
+ if (module_or_path !== void 0) if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
450
+ else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
451
+ if (module_or_path === void 0) module_or_path = new URL("fontmin_wasm_core_bg.wasm", import.meta.url);
452
+ const imports = __wbg_get_imports();
453
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) module_or_path = fetch(module_or_path);
454
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
455
+ return __wbg_finalize_init(instance, module);
456
+ }
457
+ //#endregion
458
+ export { __wbg_init as default, generate_css, initSync, runtime_name, transform, transform_icons, transform_text };
Binary file
@@ -0,0 +1,196 @@
1
+ //#region src/generated/fontmin_wasm_core.d.ts
2
+ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
3
+ //#endregion
4
+ //#region src/runtime.d.ts
5
+ declare function isWasmInitialized(): boolean;
6
+ declare function initWasm(input?: InitInput): Promise<void>;
7
+ //#endregion
8
+ //#region types.d.ts
9
+ type FontFormat = 'ttf' | 'otf' | 'woff' | 'woff2' | 'eot' | 'svg' | 'css' | 'unknown';
10
+ type OutputFormat = 'ttf' | 'woff' | 'woff2' | 'eot' | 'svg' | 'css';
11
+ type LayoutSubsetMode = 'drop' | 'conservative' | 'preserve';
12
+ interface FontMetadata {
13
+ ascender: number;
14
+ descender: number;
15
+ familyName?: string;
16
+ fullName?: string;
17
+ glyphCount: number;
18
+ postScriptName?: string;
19
+ subfamilyName?: string;
20
+ tables: string[];
21
+ unitsPerEm: number;
22
+ }
23
+ interface FontInfo {
24
+ format: FontFormat;
25
+ metadata: FontMetadata;
26
+ size: number;
27
+ }
28
+ interface SubsetOptions {
29
+ basicText?: boolean;
30
+ keepNotdef?: boolean;
31
+ layout?: LayoutSubsetMode;
32
+ preserveHinting?: boolean;
33
+ text?: string;
34
+ trim?: boolean;
35
+ unicodeRanges?: string[];
36
+ unicodes?: number[];
37
+ }
38
+ interface WoffOptions {
39
+ compressionLevel?: number;
40
+ deflate?: boolean;
41
+ metadata?: string;
42
+ privateData?: Uint8Array;
43
+ }
44
+ interface Ttf2Woff2Options {
45
+ quality?: number;
46
+ }
47
+ interface Ttf2EotOptions {
48
+ version?: number;
49
+ }
50
+ interface Ttf2SvgOptions {
51
+ fontFamily?: string;
52
+ }
53
+ interface Otf2TtfOptions {
54
+ preserveHinting?: boolean;
55
+ variationCoordinates?: Record<string, number>;
56
+ }
57
+ interface Svg2TtfOptions {
58
+ hinting?: boolean;
59
+ normalize?: boolean;
60
+ }
61
+ interface SvgIcon {
62
+ contents: string;
63
+ name: string;
64
+ unicode?: number;
65
+ }
66
+ interface Svgs2TtfOptions {
67
+ ascent?: number;
68
+ descent?: number;
69
+ fontName?: string;
70
+ normalize?: boolean;
71
+ startUnicode?: number;
72
+ }
73
+ interface CssGlyph {
74
+ name?: string;
75
+ unicode: number;
76
+ }
77
+ interface CssFontSource {
78
+ contents?: Uint8Array;
79
+ fileName: string;
80
+ format: Exclude<OutputFormat, 'css'>;
81
+ glyphs?: CssGlyph[];
82
+ unicodeRanges?: string[];
83
+ }
84
+ interface CssOptions {
85
+ asFileName?: boolean;
86
+ base64?: boolean;
87
+ fontDisplay?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
88
+ fontFamily?: string;
89
+ fontPath?: string;
90
+ glyph?: boolean;
91
+ iconPrefix?: string;
92
+ local?: boolean;
93
+ target?: 'css' | 'scss' | 'less';
94
+ unicodeRanges?: string[];
95
+ }
96
+ //#endregion
97
+ //#region src/native.d.ts
98
+ declare function subsetTtf(input: Uint8Array, options?: SubsetOptions): Promise<Uint8Array>;
99
+ declare function ttfToWoff(input: Uint8Array, options?: WoffOptions): Promise<Uint8Array>;
100
+ declare function woffToTtf(input: Uint8Array): Promise<Uint8Array>;
101
+ declare function ttfToWoff2(input: Uint8Array, options?: Ttf2Woff2Options): Promise<Uint8Array>;
102
+ declare function woff2ToTtf(input: Uint8Array): Promise<Uint8Array>;
103
+ declare function validateWoff2(input: Uint8Array): Promise<void>;
104
+ declare function ttfToEot(input: Uint8Array, options?: Ttf2EotOptions): Promise<Uint8Array>;
105
+ declare function eotToTtf(input: Uint8Array): Promise<Uint8Array>;
106
+ declare function ttfToSvg(input: Uint8Array, options?: Ttf2SvgOptions): Promise<string>;
107
+ declare function svgFontToTtf(input: string, options?: Svg2TtfOptions): Promise<Uint8Array>;
108
+ declare function svgsToTtf(inputs: SvgIcon[], options?: Svgs2TtfOptions): Promise<Uint8Array>;
109
+ declare function otfToTtf(input: Uint8Array, options?: Otf2TtfOptions): Promise<Uint8Array>;
110
+ declare function inspect(input: Uint8Array): Promise<FontInfo>;
111
+ declare function generateFontFaceCss(sources: CssFontSource[], options?: CssOptions): Promise<string>;
112
+ //#endregion
113
+ //#region src/plugins.d.ts
114
+ type MaybePromise<T> = T | Promise<T>;
115
+ interface DeliverySlice {
116
+ name: string;
117
+ unicodeRanges: string[];
118
+ }
119
+ interface DeliverySlicesOptions {
120
+ slices: DeliverySlice[];
121
+ }
122
+ interface GlyphOptions extends SubsetOptions {
123
+ clone?: boolean;
124
+ }
125
+ interface Ttf2WoffPluginOptions extends WoffOptions {
126
+ clone?: boolean;
127
+ }
128
+ interface Ttf2Woff2PluginOptions extends Ttf2Woff2Options {
129
+ clone?: boolean;
130
+ }
131
+ interface Ttf2EotPluginOptions extends Ttf2EotOptions {
132
+ clone?: boolean;
133
+ }
134
+ interface Ttf2SvgPluginOptions extends Ttf2SvgOptions {
135
+ clone?: boolean;
136
+ }
137
+ interface Otf2TtfPluginOptions extends Otf2TtfOptions {
138
+ clone?: boolean;
139
+ }
140
+ interface Svg2TtfPluginOptions extends Svg2TtfOptions {
141
+ clone?: boolean;
142
+ }
143
+ interface Svgs2TtfPluginOptions extends Svgs2TtfOptions {
144
+ clone?: boolean;
145
+ }
146
+ interface ModernWebOptions extends GlyphOptions, Otf2TtfPluginOptions, Ttf2WoffPluginOptions, Ttf2Woff2PluginOptions {
147
+ fontDisplay?: CssOptions['fontDisplay'];
148
+ fontFamily?: string;
149
+ fontPath?: string;
150
+ local?: boolean;
151
+ }
152
+ interface FontminCompatPresetOptions extends GlyphOptions, Otf2TtfPluginOptions, Ttf2EotPluginOptions, Ttf2SvgPluginOptions, Ttf2WoffPluginOptions, Ttf2Woff2PluginOptions {
153
+ fontDisplay?: CssOptions['fontDisplay'];
154
+ fontPath?: string;
155
+ local?: boolean;
156
+ }
157
+ interface BrowserPluginContext {
158
+ diagnostics: {
159
+ level: 'warn';
160
+ message: string;
161
+ }[];
162
+ emitFile(asset: BrowserAsset): void;
163
+ warn(message: string | Error): void;
164
+ }
165
+ interface BrowserPlugin<Options extends object = object> {
166
+ name: string;
167
+ options?: Options;
168
+ transform?(asset: BrowserAsset, context: BrowserPluginContext): MaybePromise<BrowserAsset | BrowserAsset[] | null | undefined>;
169
+ }
170
+ declare function glyph(options?: GlyphOptions): BrowserPlugin<GlyphOptions>;
171
+ declare function deliverySlices(slices: DeliverySlice[]): BrowserPlugin<DeliverySlicesOptions>;
172
+ declare function ttf2woff(options?: Ttf2WoffPluginOptions): BrowserPlugin<Ttf2WoffPluginOptions>;
173
+ declare function ttf2woff2(options?: Ttf2Woff2PluginOptions): BrowserPlugin<Ttf2Woff2PluginOptions>;
174
+ declare function ttf2eot(options?: Ttf2EotPluginOptions): BrowserPlugin<Ttf2EotPluginOptions>;
175
+ declare function ttf2svg(options?: Ttf2SvgPluginOptions): BrowserPlugin<Ttf2SvgPluginOptions>;
176
+ declare function otf2ttf(options?: Otf2TtfPluginOptions): BrowserPlugin<Otf2TtfPluginOptions>;
177
+ declare function svg2ttf(options?: Svg2TtfPluginOptions): BrowserPlugin<Svg2TtfPluginOptions>;
178
+ declare function svgs2ttf(options?: Svgs2TtfPluginOptions): BrowserPlugin<Svgs2TtfPluginOptions>;
179
+ declare function css(options?: CssOptions): BrowserPlugin<CssOptions>;
180
+ declare function modernWeb(options?: ModernWebOptions): BrowserPlugin[];
181
+ declare function fontminCompatPreset(options?: FontminCompatPresetOptions): BrowserPlugin[];
182
+ //#endregion
183
+ //#region src/optimize.d.ts
184
+ interface BrowserAsset {
185
+ contents: Uint8Array;
186
+ fileName: string;
187
+ format?: string;
188
+ unicodeRanges?: string[];
189
+ }
190
+ interface BrowserOptimizeConfig {
191
+ assets: BrowserAsset[];
192
+ plugins?: BrowserPlugin[];
193
+ }
194
+ declare function optimizeBrowser(config: BrowserOptimizeConfig): Promise<BrowserAsset[]>;
195
+ //#endregion
196
+ export { type BrowserAsset, type BrowserOptimizeConfig, type BrowserPlugin, type BrowserPluginContext, type CssFontSource, type CssGlyph, type CssOptions, type DeliverySlice, type DeliverySlicesOptions, type FontFormat, type FontInfo, type FontMetadata, type FontminCompatPresetOptions, type GlyphOptions, type LayoutSubsetMode, type MaybePromise, type ModernWebOptions, type Otf2TtfOptions, type Otf2TtfPluginOptions, type OutputFormat, type SubsetOptions, type Svg2TtfOptions, type Svg2TtfPluginOptions, type SvgIcon, type Svgs2TtfOptions, type Svgs2TtfPluginOptions, type Ttf2EotOptions, type Ttf2EotPluginOptions, type Ttf2SvgOptions, type Ttf2SvgPluginOptions, type Ttf2Woff2Options, type Ttf2Woff2PluginOptions, type Ttf2WoffPluginOptions, type WoffOptions, css, deliverySlices, eotToTtf, fontminCompatPreset, generateFontFaceCss, glyph, initWasm, inspect, isWasmInitialized, modernWeb, optimizeBrowser, otf2ttf, otfToTtf, subsetTtf, svg2ttf, svgFontToTtf, svgs2ttf, svgsToTtf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2, ttfToEot, ttfToSvg, ttfToWoff, ttfToWoff2, validateWoff2, woff2ToTtf, woffToTtf };
package/dist/index.mjs ADDED
@@ -0,0 +1,333 @@
1
+ //#region src/runtime.ts
2
+ let initialization;
3
+ let initialized = false;
4
+ function isWasmInitialized() {
5
+ return initialized;
6
+ }
7
+ function assertWasmInitialized() {
8
+ if (!initialized) throw new Error("fontmin-rs WASM runtime is not initialized; call initWasm() first");
9
+ }
10
+ async function getWasmModule() {
11
+ assertWasmInitialized();
12
+ return initialization;
13
+ }
14
+ async function initWasm(input) {
15
+ initialization ??= import("./fontmin_wasm_core-Cn_EVAE9.mjs").then(async (module) => {
16
+ await module.default(input === void 0 ? void 0 : { module_or_path: input });
17
+ if (module.runtime_name() !== "fontmin-rs") throw new Error("fontmin-rs WASM runtime did not initialize correctly");
18
+ initialized = true;
19
+ return module;
20
+ });
21
+ await initialization;
22
+ }
23
+ //#endregion
24
+ //#region src/native.ts
25
+ function bytes(value) {
26
+ return new Uint8Array(value);
27
+ }
28
+ async function binary(operation, input, options = {}) {
29
+ return bytes((await getWasmModule()).transform(operation, input, options));
30
+ }
31
+ async function subsetTtf(input, options = {}) {
32
+ return binary("subsetTtf", input, options);
33
+ }
34
+ async function ttfToWoff(input, options = {}) {
35
+ return binary("ttfToWoff", input, options);
36
+ }
37
+ async function woffToTtf(input) {
38
+ return binary("woffToTtf", input);
39
+ }
40
+ async function ttfToWoff2(input, options = {}) {
41
+ return binary("ttfToWoff2", input, options);
42
+ }
43
+ async function woff2ToTtf(input) {
44
+ return binary("woff2ToTtf", input);
45
+ }
46
+ async function validateWoff2(input) {
47
+ (await getWasmModule()).transform("validateWoff2", input, {});
48
+ }
49
+ async function ttfToEot(input, options = {}) {
50
+ return binary("ttfToEot", input, options);
51
+ }
52
+ async function eotToTtf(input) {
53
+ return binary("eotToTtf", input);
54
+ }
55
+ async function ttfToSvg(input, options = {}) {
56
+ return (await getWasmModule()).transform("ttfToSvg", input, options);
57
+ }
58
+ async function svgFontToTtf(input, options = {}) {
59
+ return bytes((await getWasmModule()).transform_text("svgFontToTtf", input, options));
60
+ }
61
+ async function svgsToTtf(inputs, options = {}) {
62
+ return bytes((await getWasmModule()).transform_icons(inputs, options));
63
+ }
64
+ async function otfToTtf(input, options = {}) {
65
+ return binary("otfToTtf", input, options);
66
+ }
67
+ async function inspect(input) {
68
+ return (await getWasmModule()).transform("inspect", input, {});
69
+ }
70
+ async function generateFontFaceCss(sources, options = {}) {
71
+ return (await getWasmModule()).generate_css(sources, options);
72
+ }
73
+ //#endregion
74
+ //#region src/plugins.ts
75
+ function plugin(name, options) {
76
+ return {
77
+ name,
78
+ options
79
+ };
80
+ }
81
+ function glyph(options = {}) {
82
+ return plugin("glyph", {
83
+ basicText: false,
84
+ keepNotdef: true,
85
+ layout: "conservative",
86
+ preserveHinting: false,
87
+ trim: true,
88
+ unicodes: [],
89
+ ...options
90
+ });
91
+ }
92
+ function deliverySlices(slices) {
93
+ return plugin("unicodeSlices", { slices: slices.map((slice) => ({
94
+ name: slice.name,
95
+ unicodeRanges: [...slice.unicodeRanges]
96
+ })) });
97
+ }
98
+ function normalizeDeliverySlices(options) {
99
+ const values = options.slices;
100
+ if (!Array.isArray(values) || values.length === 0) throw new Error("unicode delivery slices must not be empty");
101
+ const names = /* @__PURE__ */ new Set();
102
+ return values.map((value, index) => {
103
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`unicode delivery slice ${index + 1} must be an object`);
104
+ const { name, unicodeRanges } = value;
105
+ if (typeof name !== "string" || name.length === 0 || !/^[A-Za-z0-9_-]+$/u.test(name)) throw new Error(`unicode delivery slice ${index + 1} must have a name containing only letters, digits, hyphens, or underscores`);
106
+ if (names.has(name)) throw new Error(`unicode delivery slice name is duplicated: ${name}`);
107
+ if (!Array.isArray(unicodeRanges) || unicodeRanges.length === 0 || unicodeRanges.some((range) => typeof range !== "string" || range.length === 0)) throw new Error(`unicode delivery slice ${name} must include at least one Unicode range`);
108
+ names.add(name);
109
+ return {
110
+ name,
111
+ unicodeRanges: [...unicodeRanges]
112
+ };
113
+ });
114
+ }
115
+ function ttf2woff(options = {}) {
116
+ return plugin("ttf2woff", options);
117
+ }
118
+ function ttf2woff2(options = {}) {
119
+ return plugin("ttf2woff2", options);
120
+ }
121
+ function ttf2eot(options = {}) {
122
+ return plugin("ttf2eot", options);
123
+ }
124
+ function ttf2svg(options = {}) {
125
+ return plugin("ttf2svg", options);
126
+ }
127
+ function otf2ttf(options = {}) {
128
+ return plugin("otf2ttf", options);
129
+ }
130
+ function svg2ttf(options = {}) {
131
+ return plugin("svg2ttf", options);
132
+ }
133
+ function svgs2ttf(options = {}) {
134
+ return plugin("svgs2ttf", options);
135
+ }
136
+ function css(options = {}) {
137
+ return plugin("css", {
138
+ asFileName: false,
139
+ base64: false,
140
+ fontDisplay: "swap",
141
+ fontFamily: "fontmin",
142
+ fontPath: "./",
143
+ glyph: false,
144
+ iconPrefix: "icon",
145
+ local: true,
146
+ target: "css",
147
+ ...options
148
+ });
149
+ }
150
+ function modernWeb(options = {}) {
151
+ const { fontFamily, fontPath, local, fontDisplay, ...subset } = options;
152
+ const cssOptions = {};
153
+ if (fontFamily !== void 0) cssOptions.fontFamily = fontFamily;
154
+ if (fontPath !== void 0) cssOptions.fontPath = fontPath;
155
+ if (local !== void 0) cssOptions.local = local;
156
+ if (fontDisplay !== void 0) cssOptions.fontDisplay = fontDisplay;
157
+ const otfOptions = { clone: false };
158
+ if (typeof options.preserveHinting === "boolean") otfOptions.preserveHinting = options.preserveHinting;
159
+ if (options.variationCoordinates !== void 0) otfOptions.variationCoordinates = options.variationCoordinates;
160
+ return [
161
+ otf2ttf(otfOptions),
162
+ glyph(subset),
163
+ ttf2woff(options),
164
+ ttf2woff2(options),
165
+ css(cssOptions)
166
+ ];
167
+ }
168
+ function fontminCompatPreset(options = {}) {
169
+ const { fontFamily, fontPath, local, fontDisplay, ...subset } = options;
170
+ const cssOptions = {};
171
+ if (fontFamily !== void 0) cssOptions.fontFamily = fontFamily;
172
+ if (fontPath !== void 0) cssOptions.fontPath = fontPath;
173
+ if (local !== void 0) cssOptions.local = local;
174
+ if (fontDisplay !== void 0) cssOptions.fontDisplay = fontDisplay;
175
+ return [
176
+ otf2ttf(options),
177
+ glyph(subset),
178
+ ttf2eot(options),
179
+ ttf2svg(options),
180
+ ttf2woff(options),
181
+ ttf2woff2(options),
182
+ css(cssOptions)
183
+ ];
184
+ }
185
+ //#endregion
186
+ //#region src/optimize.ts
187
+ async function optimizeBrowser(config) {
188
+ let assets = config.assets.map(formatAsset);
189
+ for (const plugin of config.plugins ?? []) {
190
+ if (plugin.name === "glyph") {
191
+ assets = await Promise.all(assets.map(async (asset) => asset.format === "ttf" ? {
192
+ ...asset,
193
+ contents: await subsetTtf(asset.contents, optionsOf(plugin))
194
+ } : asset));
195
+ continue;
196
+ }
197
+ if (plugin.name === "unicodeSlices") {
198
+ const slices = normalizeDeliverySlices(optionsOf(plugin));
199
+ const slicedAssets = [];
200
+ for (const asset of assets) {
201
+ if (asset.format !== "ttf") {
202
+ slicedAssets.push(asset);
203
+ continue;
204
+ }
205
+ for (const slice of slices) slicedAssets.push({
206
+ ...asset,
207
+ contents: await subsetTtf(asset.contents, { unicodeRanges: slice.unicodeRanges }),
208
+ fileName: appendFileNameSuffix(asset.fileName, slice.name),
209
+ unicodeRanges: slice.unicodeRanges
210
+ });
211
+ }
212
+ assets = slicedAssets;
213
+ continue;
214
+ }
215
+ if (plugin.name === "css") {
216
+ const css = await generateFontFaceCss(assets.filter((asset) => [
217
+ "eot",
218
+ "svg",
219
+ "ttf",
220
+ "woff",
221
+ "woff2"
222
+ ].includes(asset.format ?? "")).map((asset) => {
223
+ const source = {
224
+ contents: asset.contents,
225
+ fileName: asset.fileName,
226
+ format: asset.format
227
+ };
228
+ return asset.unicodeRanges === void 0 ? source : {
229
+ ...source,
230
+ unicodeRanges: asset.unicodeRanges
231
+ };
232
+ }), optionsOf(plugin));
233
+ const firstFont = assets.find((asset) => asset.format === "ttf");
234
+ if (firstFont !== void 0) assets.push({
235
+ contents: new TextEncoder().encode(css),
236
+ fileName: replaceExtension(firstFont.fileName, "css"),
237
+ format: "css"
238
+ });
239
+ continue;
240
+ }
241
+ if (plugin.name === "svgs2ttf") {
242
+ const icons = assets.filter((asset) => asset.format === "svg").map((asset) => ({
243
+ contents: new TextDecoder().decode(asset.contents),
244
+ name: asset.fileName.replace(/\.[^.]+$/u, "")
245
+ }));
246
+ if (icons.length > 0) {
247
+ const options = optionsOf(plugin);
248
+ const fontName = options.fontName ?? "iconfont";
249
+ assets.push({
250
+ contents: await svgsToTtf(icons, options),
251
+ fileName: `${toKebabCase(fontName)}.ttf`,
252
+ format: "ttf"
253
+ });
254
+ }
255
+ continue;
256
+ }
257
+ if (plugin.transform !== void 0) {
258
+ const emitted = [];
259
+ const context = {
260
+ diagnostics: [],
261
+ emitFile(asset) {
262
+ emitted.push(formatAsset(asset));
263
+ },
264
+ warn(message) {
265
+ context.diagnostics.push({
266
+ level: "warn",
267
+ message: message instanceof Error ? message.message : message
268
+ });
269
+ }
270
+ };
271
+ const transformed = [];
272
+ for (const asset of assets) {
273
+ const result = await plugin.transform(asset, context);
274
+ if (result === null) continue;
275
+ if (result === void 0) transformed.push(asset);
276
+ else transformed.push(...(Array.isArray(result) ? result : [result]).map(formatAsset));
277
+ }
278
+ assets = transformed.concat(emitted);
279
+ continue;
280
+ }
281
+ if (plugin.name === "otf2ttf" && optionsOf(plugin).clone === false) {
282
+ assets = await Promise.all(assets.map(async (asset) => await convert(asset, plugin) ?? asset));
283
+ continue;
284
+ }
285
+ const additions = [];
286
+ for (const asset of assets) {
287
+ const converted = await convert(asset, plugin);
288
+ if (converted !== void 0) additions.push(converted);
289
+ }
290
+ assets = assets.concat(additions);
291
+ }
292
+ return assets;
293
+ }
294
+ async function convert(asset, plugin) {
295
+ if (plugin.name === "ttf2woff" && asset.format === "ttf") return converted(asset, "woff", await ttfToWoff(asset.contents, optionsOf(plugin)));
296
+ if (plugin.name === "ttf2woff2" && asset.format === "ttf") return converted(asset, "woff2", await ttfToWoff2(asset.contents, optionsOf(plugin)));
297
+ if (plugin.name === "ttf2eot" && asset.format === "ttf") return converted(asset, "eot", await ttfToEot(asset.contents, optionsOf(plugin)));
298
+ if (plugin.name === "ttf2svg" && asset.format === "ttf") return converted(asset, "svg", new TextEncoder().encode(await ttfToSvg(asset.contents, optionsOf(plugin))));
299
+ if (plugin.name === "otf2ttf" && asset.format === "otf") return converted(asset, "ttf", await otfToTtf(asset.contents, optionsOf(plugin)));
300
+ if (plugin.name === "svg2ttf" && asset.format === "svg") return converted(asset, "ttf", await svgFontToTtf(new TextDecoder().decode(asset.contents), optionsOf(plugin)));
301
+ }
302
+ function optionsOf(plugin) {
303
+ return plugin.options ?? {};
304
+ }
305
+ function converted(asset, format, contents) {
306
+ return {
307
+ ...asset,
308
+ contents,
309
+ fileName: replaceExtension(asset.fileName, format),
310
+ format
311
+ };
312
+ }
313
+ function formatAsset(asset) {
314
+ return {
315
+ ...asset,
316
+ format: formatOf(asset.fileName)
317
+ };
318
+ }
319
+ function formatOf(fileName) {
320
+ return fileName.split(".").pop()?.toLowerCase() ?? "unknown";
321
+ }
322
+ function replaceExtension(fileName, extension) {
323
+ return `${fileName.replace(/\.[^.]+$/u, "")}.${extension}`;
324
+ }
325
+ function appendFileNameSuffix(fileName, suffix) {
326
+ const extension = fileName.match(/(\.[^.]+)$/u)?.[1] ?? "";
327
+ return `${extension === "" ? fileName : fileName.slice(0, -extension.length)}-${suffix}${extension}`;
328
+ }
329
+ function toKebabCase(value) {
330
+ return value.trim().replaceAll(/([a-z])([A-Z])/gu, "$1-$2").replaceAll(/\s+/gu, "-").toLowerCase();
331
+ }
332
+ //#endregion
333
+ export { css, deliverySlices, eotToTtf, fontminCompatPreset, generateFontFaceCss, glyph, initWasm, inspect, isWasmInitialized, modernWeb, optimizeBrowser, otf2ttf, otfToTtf, subsetTtf, svg2ttf, svgFontToTtf, svgs2ttf, svgsToTtf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2, ttfToEot, ttfToSvg, ttfToWoff, ttfToWoff2, validateWoff2, woff2ToTtf, woffToTtf };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@fontmin-rs/wasm",
3
+ "version": "0.1.0-beta.1",
4
+ "description": "Browser WASM runtime for fontmin-rs.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/fontmin-rs/fontmin-rs.git"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "main": "./dist/index.mjs",
16
+ "types": "./dist/index.d.mts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.mts",
20
+ "default": "./dist/index.mjs"
21
+ }
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "devDependencies": {
27
+ "@ntnyq/tsconfig": "^3.1.0",
28
+ "playwright": "^1.61.1",
29
+ "tsdown": "^0.22.8",
30
+ "typescript": "^7.0.2",
31
+ "vitest": "^4.1.10"
32
+ },
33
+ "scripts": {
34
+ "build": "pnpm run build:wasm && pnpm run build:js",
35
+ "build:js": "tsdown && node scripts/copy-wasm.mjs",
36
+ "build:wasm": "wasm-pack build ../fontmin-core --target web --out-dir ../fontmin/src/generated --out-name fontmin_wasm_core",
37
+ "test": "vitest --run",
38
+ "test:browser": "pnpm run build && node tests/browser-runtime.mjs",
39
+ "typecheck": "tsgo --noEmit"
40
+ }
41
+ }