@hypertekt/cli 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +51 -2
- package/dist/chunk-1549rett.js +10150 -0
- package/dist/chunk-347438qj.js +115 -0
- package/dist/chunk-52gs253t.js +7 -0
- package/dist/chunk-6esapa8d.js +8 -0
- package/dist/chunk-7gxa9f23.js +8 -0
- package/dist/chunk-ad9j8gft.js +5 -0
- package/dist/chunk-d7way8c6.js +6 -0
- package/dist/chunk-eqgwmgyq.js +78 -0
- package/dist/chunk-gd8ejat6.js +8 -0
- package/dist/chunk-gqyc469c.js +5 -0
- package/dist/chunk-h0nv22gg.js +17 -0
- package/dist/chunk-h1fgyz2p.js +8 -0
- package/dist/chunk-hdth8n2f.js +8 -0
- package/dist/chunk-k99p61nq.js +6 -0
- package/dist/chunk-ky1akbb8.js +8 -0
- package/dist/chunk-m36p5w60.js +8 -0
- package/dist/chunk-mfsh6vqg.js +8 -0
- package/dist/chunk-nraadct1.js +715 -0
- package/dist/chunk-pkfk9xp4.js +8 -0
- package/dist/chunk-pz1y9y2j.js +48 -0
- package/dist/chunk-se5h32xz.js +8 -0
- package/dist/chunk-v23yh6gk.js +7 -0
- package/dist/index_bg-904m1xk3.wasm +0 -0
- package/dist/inter-400-v60xk7vr.bin +0 -0
- package/dist/inter-700-yddxh4e0.bin +0 -0
- package/dist/main.js +37061 -0
- package/package.json +46 -4
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CARD
|
|
3
|
+
} from "./chunk-347438qj.js";
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/.bun/@resvg+resvg-wasm@2.6.2/node_modules/@resvg/resvg-wasm/index.mjs
|
|
6
|
+
var wasm;
|
|
7
|
+
var heap = new Array(128).fill(undefined);
|
|
8
|
+
heap.push(undefined, null, true, false);
|
|
9
|
+
var heap_next = heap.length;
|
|
10
|
+
function addHeapObject(obj) {
|
|
11
|
+
if (heap_next === heap.length)
|
|
12
|
+
heap.push(heap.length + 1);
|
|
13
|
+
const idx = heap_next;
|
|
14
|
+
heap_next = heap[idx];
|
|
15
|
+
heap[idx] = obj;
|
|
16
|
+
return idx;
|
|
17
|
+
}
|
|
18
|
+
function getObject(idx) {
|
|
19
|
+
return heap[idx];
|
|
20
|
+
}
|
|
21
|
+
function dropObject(idx) {
|
|
22
|
+
if (idx < 132)
|
|
23
|
+
return;
|
|
24
|
+
heap[idx] = heap_next;
|
|
25
|
+
heap_next = idx;
|
|
26
|
+
}
|
|
27
|
+
function takeObject(idx) {
|
|
28
|
+
const ret = getObject(idx);
|
|
29
|
+
dropObject(idx);
|
|
30
|
+
return ret;
|
|
31
|
+
}
|
|
32
|
+
var WASM_VECTOR_LEN = 0;
|
|
33
|
+
var cachedUint8Memory0 = null;
|
|
34
|
+
function getUint8Memory0() {
|
|
35
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
36
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
37
|
+
}
|
|
38
|
+
return cachedUint8Memory0;
|
|
39
|
+
}
|
|
40
|
+
var cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
|
|
41
|
+
throw Error("TextEncoder not available");
|
|
42
|
+
} };
|
|
43
|
+
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
44
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
45
|
+
} : function(arg, view) {
|
|
46
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
47
|
+
view.set(buf);
|
|
48
|
+
return {
|
|
49
|
+
read: arg.length,
|
|
50
|
+
written: buf.length
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
54
|
+
if (realloc === undefined) {
|
|
55
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
56
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
57
|
+
getUint8Memory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
58
|
+
WASM_VECTOR_LEN = buf.length;
|
|
59
|
+
return ptr2;
|
|
60
|
+
}
|
|
61
|
+
let len = arg.length;
|
|
62
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
63
|
+
const mem = getUint8Memory0();
|
|
64
|
+
let offset = 0;
|
|
65
|
+
for (;offset < len; offset++) {
|
|
66
|
+
const code = arg.charCodeAt(offset);
|
|
67
|
+
if (code > 127)
|
|
68
|
+
break;
|
|
69
|
+
mem[ptr + offset] = code;
|
|
70
|
+
}
|
|
71
|
+
if (offset !== len) {
|
|
72
|
+
if (offset !== 0) {
|
|
73
|
+
arg = arg.slice(offset);
|
|
74
|
+
}
|
|
75
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
76
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
77
|
+
const ret = encodeString(arg, view);
|
|
78
|
+
offset += ret.written;
|
|
79
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
80
|
+
}
|
|
81
|
+
WASM_VECTOR_LEN = offset;
|
|
82
|
+
return ptr;
|
|
83
|
+
}
|
|
84
|
+
function isLikeNone(x) {
|
|
85
|
+
return x === undefined || x === null;
|
|
86
|
+
}
|
|
87
|
+
var cachedInt32Memory0 = null;
|
|
88
|
+
function getInt32Memory0() {
|
|
89
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
90
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
91
|
+
}
|
|
92
|
+
return cachedInt32Memory0;
|
|
93
|
+
}
|
|
94
|
+
var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
|
|
95
|
+
throw Error("TextDecoder not available");
|
|
96
|
+
} };
|
|
97
|
+
if (typeof TextDecoder !== "undefined") {
|
|
98
|
+
cachedTextDecoder.decode();
|
|
99
|
+
}
|
|
100
|
+
function getStringFromWasm0(ptr, len) {
|
|
101
|
+
ptr = ptr >>> 0;
|
|
102
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
103
|
+
}
|
|
104
|
+
function _assertClass(instance, klass) {
|
|
105
|
+
if (!(instance instanceof klass)) {
|
|
106
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
107
|
+
}
|
|
108
|
+
return instance.ptr;
|
|
109
|
+
}
|
|
110
|
+
function handleError(f, args) {
|
|
111
|
+
try {
|
|
112
|
+
return f.apply(this, args);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var BBoxFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm.__wbg_bbox_free(ptr >>> 0));
|
|
118
|
+
var BBox = class _BBox {
|
|
119
|
+
static __wrap(ptr) {
|
|
120
|
+
ptr = ptr >>> 0;
|
|
121
|
+
const obj = Object.create(_BBox.prototype);
|
|
122
|
+
obj.__wbg_ptr = ptr;
|
|
123
|
+
BBoxFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
124
|
+
return obj;
|
|
125
|
+
}
|
|
126
|
+
__destroy_into_raw() {
|
|
127
|
+
const ptr = this.__wbg_ptr;
|
|
128
|
+
this.__wbg_ptr = 0;
|
|
129
|
+
BBoxFinalization.unregister(this);
|
|
130
|
+
return ptr;
|
|
131
|
+
}
|
|
132
|
+
free() {
|
|
133
|
+
const ptr = this.__destroy_into_raw();
|
|
134
|
+
wasm.__wbg_bbox_free(ptr);
|
|
135
|
+
}
|
|
136
|
+
get x() {
|
|
137
|
+
const ret = wasm.__wbg_get_bbox_x(this.__wbg_ptr);
|
|
138
|
+
return ret;
|
|
139
|
+
}
|
|
140
|
+
set x(arg0) {
|
|
141
|
+
wasm.__wbg_set_bbox_x(this.__wbg_ptr, arg0);
|
|
142
|
+
}
|
|
143
|
+
get y() {
|
|
144
|
+
const ret = wasm.__wbg_get_bbox_y(this.__wbg_ptr);
|
|
145
|
+
return ret;
|
|
146
|
+
}
|
|
147
|
+
set y(arg0) {
|
|
148
|
+
wasm.__wbg_set_bbox_y(this.__wbg_ptr, arg0);
|
|
149
|
+
}
|
|
150
|
+
get width() {
|
|
151
|
+
const ret = wasm.__wbg_get_bbox_width(this.__wbg_ptr);
|
|
152
|
+
return ret;
|
|
153
|
+
}
|
|
154
|
+
set width(arg0) {
|
|
155
|
+
wasm.__wbg_set_bbox_width(this.__wbg_ptr, arg0);
|
|
156
|
+
}
|
|
157
|
+
get height() {
|
|
158
|
+
const ret = wasm.__wbg_get_bbox_height(this.__wbg_ptr);
|
|
159
|
+
return ret;
|
|
160
|
+
}
|
|
161
|
+
set height(arg0) {
|
|
162
|
+
wasm.__wbg_set_bbox_height(this.__wbg_ptr, arg0);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var RenderedImageFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm.__wbg_renderedimage_free(ptr >>> 0));
|
|
166
|
+
var RenderedImage = class _RenderedImage {
|
|
167
|
+
static __wrap(ptr) {
|
|
168
|
+
ptr = ptr >>> 0;
|
|
169
|
+
const obj = Object.create(_RenderedImage.prototype);
|
|
170
|
+
obj.__wbg_ptr = ptr;
|
|
171
|
+
RenderedImageFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
172
|
+
return obj;
|
|
173
|
+
}
|
|
174
|
+
__destroy_into_raw() {
|
|
175
|
+
const ptr = this.__wbg_ptr;
|
|
176
|
+
this.__wbg_ptr = 0;
|
|
177
|
+
RenderedImageFinalization.unregister(this);
|
|
178
|
+
return ptr;
|
|
179
|
+
}
|
|
180
|
+
free() {
|
|
181
|
+
const ptr = this.__destroy_into_raw();
|
|
182
|
+
wasm.__wbg_renderedimage_free(ptr);
|
|
183
|
+
}
|
|
184
|
+
get width() {
|
|
185
|
+
const ret = wasm.renderedimage_width(this.__wbg_ptr);
|
|
186
|
+
return ret >>> 0;
|
|
187
|
+
}
|
|
188
|
+
get height() {
|
|
189
|
+
const ret = wasm.renderedimage_height(this.__wbg_ptr);
|
|
190
|
+
return ret >>> 0;
|
|
191
|
+
}
|
|
192
|
+
asPng() {
|
|
193
|
+
try {
|
|
194
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
195
|
+
wasm.renderedimage_asPng(retptr, this.__wbg_ptr);
|
|
196
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
197
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
198
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
199
|
+
if (r2) {
|
|
200
|
+
throw takeObject(r1);
|
|
201
|
+
}
|
|
202
|
+
return takeObject(r0);
|
|
203
|
+
} finally {
|
|
204
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
get pixels() {
|
|
208
|
+
const ret = wasm.renderedimage_pixels(this.__wbg_ptr);
|
|
209
|
+
return takeObject(ret);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var ResvgFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm.__wbg_resvg_free(ptr >>> 0));
|
|
213
|
+
var Resvg = class {
|
|
214
|
+
__destroy_into_raw() {
|
|
215
|
+
const ptr = this.__wbg_ptr;
|
|
216
|
+
this.__wbg_ptr = 0;
|
|
217
|
+
ResvgFinalization.unregister(this);
|
|
218
|
+
return ptr;
|
|
219
|
+
}
|
|
220
|
+
free() {
|
|
221
|
+
const ptr = this.__destroy_into_raw();
|
|
222
|
+
wasm.__wbg_resvg_free(ptr);
|
|
223
|
+
}
|
|
224
|
+
constructor(svg, options, custom_font_buffers) {
|
|
225
|
+
try {
|
|
226
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
227
|
+
var ptr0 = isLikeNone(options) ? 0 : passStringToWasm0(options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
228
|
+
var len0 = WASM_VECTOR_LEN;
|
|
229
|
+
wasm.resvg_new(retptr, addHeapObject(svg), ptr0, len0, isLikeNone(custom_font_buffers) ? 0 : addHeapObject(custom_font_buffers));
|
|
230
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
231
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
232
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
233
|
+
if (r2) {
|
|
234
|
+
throw takeObject(r1);
|
|
235
|
+
}
|
|
236
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
237
|
+
return this;
|
|
238
|
+
} finally {
|
|
239
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
get width() {
|
|
243
|
+
const ret = wasm.resvg_width(this.__wbg_ptr);
|
|
244
|
+
return ret;
|
|
245
|
+
}
|
|
246
|
+
get height() {
|
|
247
|
+
const ret = wasm.resvg_height(this.__wbg_ptr);
|
|
248
|
+
return ret;
|
|
249
|
+
}
|
|
250
|
+
render() {
|
|
251
|
+
try {
|
|
252
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
253
|
+
wasm.resvg_render(retptr, this.__wbg_ptr);
|
|
254
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
255
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
256
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
257
|
+
if (r2) {
|
|
258
|
+
throw takeObject(r1);
|
|
259
|
+
}
|
|
260
|
+
return RenderedImage.__wrap(r0);
|
|
261
|
+
} finally {
|
|
262
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
toString() {
|
|
266
|
+
let deferred1_0;
|
|
267
|
+
let deferred1_1;
|
|
268
|
+
try {
|
|
269
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
270
|
+
wasm.resvg_toString(retptr, this.__wbg_ptr);
|
|
271
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
272
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
273
|
+
deferred1_0 = r0;
|
|
274
|
+
deferred1_1 = r1;
|
|
275
|
+
return getStringFromWasm0(r0, r1);
|
|
276
|
+
} finally {
|
|
277
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
278
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
innerBBox() {
|
|
282
|
+
const ret = wasm.resvg_innerBBox(this.__wbg_ptr);
|
|
283
|
+
return ret === 0 ? undefined : BBox.__wrap(ret);
|
|
284
|
+
}
|
|
285
|
+
getBBox() {
|
|
286
|
+
const ret = wasm.resvg_getBBox(this.__wbg_ptr);
|
|
287
|
+
return ret === 0 ? undefined : BBox.__wrap(ret);
|
|
288
|
+
}
|
|
289
|
+
cropByBBox(bbox) {
|
|
290
|
+
_assertClass(bbox, BBox);
|
|
291
|
+
wasm.resvg_cropByBBox(this.__wbg_ptr, bbox.__wbg_ptr);
|
|
292
|
+
}
|
|
293
|
+
imagesToResolve() {
|
|
294
|
+
try {
|
|
295
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
296
|
+
wasm.resvg_imagesToResolve(retptr, this.__wbg_ptr);
|
|
297
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
298
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
299
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
300
|
+
if (r2) {
|
|
301
|
+
throw takeObject(r1);
|
|
302
|
+
}
|
|
303
|
+
return takeObject(r0);
|
|
304
|
+
} finally {
|
|
305
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
resolveImage(href, buffer) {
|
|
309
|
+
try {
|
|
310
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
311
|
+
const ptr0 = passStringToWasm0(href, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
312
|
+
const len0 = WASM_VECTOR_LEN;
|
|
313
|
+
wasm.resvg_resolveImage(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(buffer));
|
|
314
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
315
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
316
|
+
if (r1) {
|
|
317
|
+
throw takeObject(r0);
|
|
318
|
+
}
|
|
319
|
+
} finally {
|
|
320
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
async function __wbg_load(module, imports) {
|
|
325
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
326
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
327
|
+
try {
|
|
328
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
329
|
+
} catch (e) {
|
|
330
|
+
if (module.headers.get("Content-Type") != "application/wasm") {
|
|
331
|
+
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);
|
|
332
|
+
} else {
|
|
333
|
+
throw e;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const bytes = await module.arrayBuffer();
|
|
338
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
339
|
+
} else {
|
|
340
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
341
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
342
|
+
return { instance, module };
|
|
343
|
+
} else {
|
|
344
|
+
return instance;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function __wbg_get_imports() {
|
|
349
|
+
const imports = {};
|
|
350
|
+
imports.wbg = {};
|
|
351
|
+
imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) {
|
|
352
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
353
|
+
return addHeapObject(ret);
|
|
354
|
+
};
|
|
355
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
356
|
+
const ret = wasm.memory;
|
|
357
|
+
return addHeapObject(ret);
|
|
358
|
+
};
|
|
359
|
+
imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
|
|
360
|
+
const ret = getObject(arg0).buffer;
|
|
361
|
+
return addHeapObject(ret);
|
|
362
|
+
};
|
|
363
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
|
|
364
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
365
|
+
return addHeapObject(ret);
|
|
366
|
+
};
|
|
367
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
368
|
+
takeObject(arg0);
|
|
369
|
+
};
|
|
370
|
+
imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
|
|
371
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
372
|
+
return addHeapObject(ret);
|
|
373
|
+
};
|
|
374
|
+
imports.wbg.__wbg_values_839f3396d5aac002 = function(arg0) {
|
|
375
|
+
const ret = getObject(arg0).values();
|
|
376
|
+
return addHeapObject(ret);
|
|
377
|
+
};
|
|
378
|
+
imports.wbg.__wbg_next_196c84450b364254 = function() {
|
|
379
|
+
return handleError(function(arg0) {
|
|
380
|
+
const ret = getObject(arg0).next();
|
|
381
|
+
return addHeapObject(ret);
|
|
382
|
+
}, arguments);
|
|
383
|
+
};
|
|
384
|
+
imports.wbg.__wbg_done_298b57d23c0fc80c = function(arg0) {
|
|
385
|
+
const ret = getObject(arg0).done;
|
|
386
|
+
return ret;
|
|
387
|
+
};
|
|
388
|
+
imports.wbg.__wbg_value_d93c65011f51a456 = function(arg0) {
|
|
389
|
+
const ret = getObject(arg0).value;
|
|
390
|
+
return addHeapObject(ret);
|
|
391
|
+
};
|
|
392
|
+
imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) {
|
|
393
|
+
let result;
|
|
394
|
+
try {
|
|
395
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
396
|
+
} catch (_) {
|
|
397
|
+
result = false;
|
|
398
|
+
}
|
|
399
|
+
const ret = result;
|
|
400
|
+
return ret;
|
|
401
|
+
};
|
|
402
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
403
|
+
const obj = getObject(arg1);
|
|
404
|
+
const ret = typeof obj === "string" ? obj : undefined;
|
|
405
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
406
|
+
var len1 = WASM_VECTOR_LEN;
|
|
407
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
408
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
409
|
+
};
|
|
410
|
+
imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() {
|
|
411
|
+
const ret = new Array;
|
|
412
|
+
return addHeapObject(ret);
|
|
413
|
+
};
|
|
414
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
415
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
416
|
+
return addHeapObject(ret);
|
|
417
|
+
};
|
|
418
|
+
imports.wbg.__wbg_push_a5b05aedc7234f9f = function(arg0, arg1) {
|
|
419
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
420
|
+
return ret;
|
|
421
|
+
};
|
|
422
|
+
imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
|
|
423
|
+
const ret = getObject(arg0).length;
|
|
424
|
+
return ret;
|
|
425
|
+
};
|
|
426
|
+
imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
|
|
427
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
428
|
+
};
|
|
429
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
430
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
431
|
+
};
|
|
432
|
+
return imports;
|
|
433
|
+
}
|
|
434
|
+
function __wbg_init_memory(imports, maybe_memory) {}
|
|
435
|
+
function __wbg_finalize_init(instance, module) {
|
|
436
|
+
wasm = instance.exports;
|
|
437
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
438
|
+
cachedInt32Memory0 = null;
|
|
439
|
+
cachedUint8Memory0 = null;
|
|
440
|
+
return wasm;
|
|
441
|
+
}
|
|
442
|
+
async function __wbg_init(input) {
|
|
443
|
+
if (wasm !== undefined)
|
|
444
|
+
return wasm;
|
|
445
|
+
if (typeof input === "undefined") {
|
|
446
|
+
input = new URL("index_bg.wasm", undefined);
|
|
447
|
+
}
|
|
448
|
+
const imports = __wbg_get_imports();
|
|
449
|
+
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
|
450
|
+
input = fetch(input);
|
|
451
|
+
}
|
|
452
|
+
__wbg_init_memory(imports);
|
|
453
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
|
454
|
+
return __wbg_finalize_init(instance, module);
|
|
455
|
+
}
|
|
456
|
+
var dist_default = __wbg_init;
|
|
457
|
+
var initialized = false;
|
|
458
|
+
var initWasm = async (module_or_path) => {
|
|
459
|
+
if (initialized) {
|
|
460
|
+
throw new Error("Already initialized. The `initWasm()` function can be used only once.");
|
|
461
|
+
}
|
|
462
|
+
await dist_default(await module_or_path);
|
|
463
|
+
initialized = true;
|
|
464
|
+
};
|
|
465
|
+
var Resvg2 = class extends Resvg {
|
|
466
|
+
constructor(svg, options) {
|
|
467
|
+
if (!initialized)
|
|
468
|
+
throw new Error("Wasm has not been initialized. Call `initWasm()` function.");
|
|
469
|
+
const font = options?.font;
|
|
470
|
+
if (!!font && isCustomFontsOptions(font)) {
|
|
471
|
+
const serializableOptions = {
|
|
472
|
+
...options,
|
|
473
|
+
font: {
|
|
474
|
+
...font,
|
|
475
|
+
fontBuffers: undefined
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
super(svg, JSON.stringify(serializableOptions), font.fontBuffers);
|
|
479
|
+
} else {
|
|
480
|
+
super(svg, JSON.stringify(options));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
function isCustomFontsOptions(value) {
|
|
485
|
+
return Object.prototype.hasOwnProperty.call(value, "fontBuffers");
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// ../engine/src/draw/font.ts
|
|
489
|
+
function fontWidths(font) {
|
|
490
|
+
const view = new DataView(font.buffer, font.byteOffset, font.byteLength);
|
|
491
|
+
const tables = new Map;
|
|
492
|
+
const count = view.getUint16(4);
|
|
493
|
+
for (let index = 0;index < count; index++) {
|
|
494
|
+
const at = 12 + index * 16;
|
|
495
|
+
const tag = String.fromCharCode(font[at], font[at + 1], font[at + 2], font[at + 3]);
|
|
496
|
+
tables.set(tag, view.getUint32(at + 8));
|
|
497
|
+
}
|
|
498
|
+
const table = (tag) => {
|
|
499
|
+
const at = tables.get(tag);
|
|
500
|
+
if (at === undefined)
|
|
501
|
+
throw new Error(`The font has no ${tag} table.`);
|
|
502
|
+
return at;
|
|
503
|
+
};
|
|
504
|
+
const unitsPerEm = view.getUint16(table("head") + 18);
|
|
505
|
+
const metrics = view.getUint16(table("hhea") + 34);
|
|
506
|
+
const hmtx = table("hmtx");
|
|
507
|
+
const advance = (glyph) => view.getUint16(hmtx + Math.min(glyph, metrics - 1) * 4);
|
|
508
|
+
const glyphOf = cmap(view, table("cmap"));
|
|
509
|
+
const missing = advance(0);
|
|
510
|
+
const widths = new Map;
|
|
511
|
+
const width = (code) => {
|
|
512
|
+
let found = widths.get(code);
|
|
513
|
+
if (found === undefined) {
|
|
514
|
+
const glyph = glyphOf(code);
|
|
515
|
+
found = glyph === 0 ? missing : advance(glyph);
|
|
516
|
+
widths.set(code, found);
|
|
517
|
+
}
|
|
518
|
+
return found;
|
|
519
|
+
};
|
|
520
|
+
return {
|
|
521
|
+
measure(text, size) {
|
|
522
|
+
let units = 0;
|
|
523
|
+
for (const character of text)
|
|
524
|
+
units += width(character.codePointAt(0));
|
|
525
|
+
return units / unitsPerEm * size;
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
function cmap(view, at) {
|
|
530
|
+
const count = view.getUint16(at + 2);
|
|
531
|
+
let format4 = null;
|
|
532
|
+
let format12 = null;
|
|
533
|
+
for (let index = 0;index < count; index++) {
|
|
534
|
+
const record = at + 4 + index * 8;
|
|
535
|
+
const platform = view.getUint16(record);
|
|
536
|
+
const encoding = view.getUint16(record + 2);
|
|
537
|
+
const subtable = at + view.getUint32(record + 4);
|
|
538
|
+
const format = view.getUint16(subtable);
|
|
539
|
+
const unicode = platform === 0 || platform === 3 && (encoding === 1 || encoding === 10);
|
|
540
|
+
if (!unicode)
|
|
541
|
+
continue;
|
|
542
|
+
if (format === 12)
|
|
543
|
+
format12 = subtable;
|
|
544
|
+
else if (format === 4)
|
|
545
|
+
format4 = subtable;
|
|
546
|
+
}
|
|
547
|
+
if (format12 !== null) {
|
|
548
|
+
const groups = view.getUint32(format12 + 12);
|
|
549
|
+
return (code) => {
|
|
550
|
+
for (let index = 0;index < groups; index++) {
|
|
551
|
+
const group = format12 + 16 + index * 12;
|
|
552
|
+
const start = view.getUint32(group);
|
|
553
|
+
const end = view.getUint32(group + 4);
|
|
554
|
+
if (code >= start && code <= end)
|
|
555
|
+
return view.getUint32(group + 8) + (code - start);
|
|
556
|
+
}
|
|
557
|
+
return 0;
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (format4 === null)
|
|
561
|
+
throw new Error("The font has no Unicode cmap.");
|
|
562
|
+
const segments = view.getUint16(format4 + 6) / 2;
|
|
563
|
+
const ends = format4 + 14;
|
|
564
|
+
const starts = ends + segments * 2 + 2;
|
|
565
|
+
const deltas = starts + segments * 2;
|
|
566
|
+
const offsets = deltas + segments * 2;
|
|
567
|
+
return (code) => {
|
|
568
|
+
if (code > 65535)
|
|
569
|
+
return 0;
|
|
570
|
+
for (let index = 0;index < segments; index++) {
|
|
571
|
+
if (code > view.getUint16(ends + index * 2))
|
|
572
|
+
continue;
|
|
573
|
+
const start = view.getUint16(starts + index * 2);
|
|
574
|
+
if (code < start)
|
|
575
|
+
return 0;
|
|
576
|
+
const delta = view.getInt16(deltas + index * 2);
|
|
577
|
+
const offset = view.getUint16(offsets + index * 2);
|
|
578
|
+
if (offset === 0)
|
|
579
|
+
return code + delta & 65535;
|
|
580
|
+
const glyph = view.getUint16(offsets + index * 2 + offset + (code - start) * 2);
|
|
581
|
+
return glyph === 0 ? 0 : glyph + delta & 65535;
|
|
582
|
+
}
|
|
583
|
+
return 0;
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// ../engine/src/draw/index.ts
|
|
588
|
+
var started = null;
|
|
589
|
+
async function createDrawer(parts) {
|
|
590
|
+
started ??= initWasm(parts.wasm);
|
|
591
|
+
await started;
|
|
592
|
+
const regular = fontWidths(parts.regular);
|
|
593
|
+
const bold = fontWidths(parts.bold);
|
|
594
|
+
const fonts = [parts.regular, parts.bold];
|
|
595
|
+
const svg = async (request) => request.kind === "card" ? cardSvg(request, await embed(request.logo), bold, regular) : iconSvg(request, await embed(request.image));
|
|
596
|
+
return {
|
|
597
|
+
svg,
|
|
598
|
+
async draw(request) {
|
|
599
|
+
const resvg = new Resvg2(await svg(request), {
|
|
600
|
+
font: { fontBuffers: fonts, loadSystemFonts: false, defaultFontFamily: "Inter" }
|
|
601
|
+
});
|
|
602
|
+
try {
|
|
603
|
+
const rendered = resvg.render();
|
|
604
|
+
try {
|
|
605
|
+
return rendered.asPng();
|
|
606
|
+
} finally {
|
|
607
|
+
rendered.free();
|
|
608
|
+
}
|
|
609
|
+
} finally {
|
|
610
|
+
resvg.free();
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
var PAD = 80;
|
|
616
|
+
var INK = "#111111";
|
|
617
|
+
var MUTED = "#555555";
|
|
618
|
+
var TITLE_SIZES = [76, 66, 58];
|
|
619
|
+
var TITLE_LINES = 3;
|
|
620
|
+
var FOOT_SIZE = 30;
|
|
621
|
+
var BAR = 24;
|
|
622
|
+
function cardSvg(request, logo, bold, regular) {
|
|
623
|
+
const width = CARD.width;
|
|
624
|
+
const height = CARD.height;
|
|
625
|
+
const inner = width - PAD * 2;
|
|
626
|
+
const top = logo ? 76 + 88 : PAD;
|
|
627
|
+
const foot = height - (request.color ? BAR : 0) - 64;
|
|
628
|
+
let size = TITLE_SIZES[TITLE_SIZES.length - 1];
|
|
629
|
+
let lines = [];
|
|
630
|
+
for (const each of TITLE_SIZES) {
|
|
631
|
+
lines = wrap(request.title, (text) => bold.measure(text, each), inner);
|
|
632
|
+
size = each;
|
|
633
|
+
if (lines.length <= TITLE_LINES)
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
if (lines.length > TITLE_LINES) {
|
|
637
|
+
lines = lines.slice(0, TITLE_LINES);
|
|
638
|
+
lines[TITLE_LINES - 1] = shorten(`${lines[TITLE_LINES - 1]}…`, (text) => bold.measure(text, size), inner);
|
|
639
|
+
}
|
|
640
|
+
const leading = Math.round(size * 1.16);
|
|
641
|
+
const block = leading * (lines.length - 1) + size;
|
|
642
|
+
const middle = top + (foot - FOOT_SIZE - 40 - top) / 2;
|
|
643
|
+
const first = Math.round(middle - block / 2 + size * 0.8);
|
|
644
|
+
const footText = shorten(request.domain && request.domain !== request.name ? `${request.name} · ${request.domain}` : request.name, (text) => regular.measure(text, FOOT_SIZE), inner);
|
|
645
|
+
return [
|
|
646
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">`,
|
|
647
|
+
`<rect width="${width}" height="${height}" fill="#ffffff"/>`,
|
|
648
|
+
logo ? `<image href="${logo}" x="${PAD}" y="76" width="400" height="88" preserveAspectRatio="xMinYMid meet"/>` : "",
|
|
649
|
+
...lines.map((line, index) => `<text x="${PAD}" y="${first + index * leading}" font-family="Inter" font-weight="700" font-size="${size}" fill="${INK}">${escapeXml(line)}</text>`),
|
|
650
|
+
`<text x="${PAD}" y="${foot}" font-family="Inter" font-weight="400" font-size="${FOOT_SIZE}" fill="${MUTED}">${escapeXml(footText)}</text>`,
|
|
651
|
+
request.color ? `<rect y="${height - BAR}" width="${width}" height="${BAR}" fill="${request.color}"/>` : "",
|
|
652
|
+
"</svg>"
|
|
653
|
+
].join("");
|
|
654
|
+
}
|
|
655
|
+
function iconSvg(request, image) {
|
|
656
|
+
const size = request.size;
|
|
657
|
+
const pad = Math.round(size * request.padding);
|
|
658
|
+
const inner = size - pad * 2;
|
|
659
|
+
return [
|
|
660
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">`,
|
|
661
|
+
request.background ? `<rect width="${size}" height="${size}" fill="${request.background}"/>` : "",
|
|
662
|
+
image ? `<image href="${image}" x="${pad}" y="${pad}" width="${inner}" height="${inner}" preserveAspectRatio="xMidYMid meet"/>` : "",
|
|
663
|
+
"</svg>"
|
|
664
|
+
].join("");
|
|
665
|
+
}
|
|
666
|
+
function wrap(text, measure, max) {
|
|
667
|
+
const lines = [];
|
|
668
|
+
let line = "";
|
|
669
|
+
for (const word of text.trim().split(/\s+/)) {
|
|
670
|
+
if (word === "")
|
|
671
|
+
continue;
|
|
672
|
+
const tried = line === "" ? word : `${line} ${word}`;
|
|
673
|
+
if (measure(tried) <= max) {
|
|
674
|
+
line = tried;
|
|
675
|
+
continue;
|
|
676
|
+
}
|
|
677
|
+
if (line !== "")
|
|
678
|
+
lines.push(line);
|
|
679
|
+
line = word;
|
|
680
|
+
while (measure(line) > max && line.length > 1) {
|
|
681
|
+
let cut = line.length - 1;
|
|
682
|
+
while (cut > 1 && measure(line.slice(0, cut)) > max)
|
|
683
|
+
cut--;
|
|
684
|
+
lines.push(line.slice(0, cut));
|
|
685
|
+
line = line.slice(cut);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (line !== "")
|
|
689
|
+
lines.push(line);
|
|
690
|
+
return lines;
|
|
691
|
+
}
|
|
692
|
+
function shorten(text, measure, max) {
|
|
693
|
+
if (measure(text) <= max)
|
|
694
|
+
return text;
|
|
695
|
+
let cut = text.replace(/…$/, "");
|
|
696
|
+
while (cut.length > 1 && measure(`${cut.trimEnd()}…`) > max)
|
|
697
|
+
cut = cut.slice(0, -1);
|
|
698
|
+
return `${cut.trimEnd()}…`;
|
|
699
|
+
}
|
|
700
|
+
var MIME = { svg: "image/svg+xml", png: "image/png", jpeg: "image/jpeg", gif: "image/gif" };
|
|
701
|
+
async function embed(image) {
|
|
702
|
+
if (!image)
|
|
703
|
+
return null;
|
|
704
|
+
const bytes = await image.read();
|
|
705
|
+
let binary = "";
|
|
706
|
+
for (let at = 0;at < bytes.length; at += 32768)
|
|
707
|
+
binary += String.fromCharCode(...bytes.subarray(at, at + 32768));
|
|
708
|
+
return `data:${MIME[image.type]};base64,${btoa(binary)}`;
|
|
709
|
+
}
|
|
710
|
+
function escapeXml(text) {
|
|
711
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
712
|
+
}
|
|
713
|
+
export {
|
|
714
|
+
createDrawer
|
|
715
|
+
};
|