@pixagram/renderart 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -64
- package/dist/index.d.mts +68 -20
- package/dist/index.d.ts +68 -20
- package/dist/index.js +82 -857
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -856
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,792 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res) => function __init() {
|
|
4
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
-
};
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// pkg/renderart_wasm.js
|
|
12
|
-
var renderart_wasm_exports = {};
|
|
13
|
-
__export(renderart_wasm_exports, {
|
|
14
|
-
CrtConfig: () => CrtConfig,
|
|
15
|
-
HexConfig: () => HexConfig,
|
|
16
|
-
HexOrientation: () => HexOrientation,
|
|
17
|
-
UpscaleResult: () => UpscaleResult,
|
|
18
|
-
XbrzConfig: () => XbrzConfig,
|
|
19
|
-
crt_upscale: () => crt_upscale,
|
|
20
|
-
crt_upscale_config: () => crt_upscale_config,
|
|
21
|
-
default: () => renderart_wasm_default,
|
|
22
|
-
get_memory: () => get_memory,
|
|
23
|
-
hex_get_dimensions: () => hex_get_dimensions,
|
|
24
|
-
hex_upscale: () => hex_upscale,
|
|
25
|
-
hex_upscale_config: () => hex_upscale_config,
|
|
26
|
-
init: () => init,
|
|
27
|
-
initSync: () => initSync,
|
|
28
|
-
xbrz_upscale: () => xbrz_upscale,
|
|
29
|
-
xbrz_upscale_config: () => xbrz_upscale_config
|
|
30
|
-
});
|
|
31
|
-
function _assertClass(instance, klass) {
|
|
32
|
-
if (!(instance instanceof klass)) {
|
|
33
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function getArrayU32FromWasm0(ptr, len) {
|
|
37
|
-
ptr = ptr >>> 0;
|
|
38
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
39
|
-
}
|
|
40
|
-
function getDataViewMemory0() {
|
|
41
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
42
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
43
|
-
}
|
|
44
|
-
return cachedDataViewMemory0;
|
|
45
|
-
}
|
|
46
|
-
function getStringFromWasm0(ptr, len) {
|
|
47
|
-
ptr = ptr >>> 0;
|
|
48
|
-
return decodeText(ptr, len);
|
|
49
|
-
}
|
|
50
|
-
function getUint32ArrayMemory0() {
|
|
51
|
-
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
52
|
-
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
53
|
-
}
|
|
54
|
-
return cachedUint32ArrayMemory0;
|
|
55
|
-
}
|
|
56
|
-
function getUint8ArrayMemory0() {
|
|
57
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
58
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
59
|
-
}
|
|
60
|
-
return cachedUint8ArrayMemory0;
|
|
61
|
-
}
|
|
62
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
63
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
64
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
65
|
-
WASM_VECTOR_LEN = arg.length;
|
|
66
|
-
return ptr;
|
|
67
|
-
}
|
|
68
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
69
|
-
if (realloc === void 0) {
|
|
70
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
71
|
-
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
72
|
-
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
73
|
-
WASM_VECTOR_LEN = buf.length;
|
|
74
|
-
return ptr2;
|
|
75
|
-
}
|
|
76
|
-
let len = arg.length;
|
|
77
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
78
|
-
const mem = getUint8ArrayMemory0();
|
|
79
|
-
let offset = 0;
|
|
80
|
-
for (; offset < len; offset++) {
|
|
81
|
-
const code = arg.charCodeAt(offset);
|
|
82
|
-
if (code > 127) break;
|
|
83
|
-
mem[ptr + offset] = code;
|
|
84
|
-
}
|
|
85
|
-
if (offset !== len) {
|
|
86
|
-
if (offset !== 0) {
|
|
87
|
-
arg = arg.slice(offset);
|
|
88
|
-
}
|
|
89
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
90
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
91
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
92
|
-
offset += ret.written;
|
|
93
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
94
|
-
}
|
|
95
|
-
WASM_VECTOR_LEN = offset;
|
|
96
|
-
return ptr;
|
|
97
|
-
}
|
|
98
|
-
function takeFromExternrefTable0(idx) {
|
|
99
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
100
|
-
wasm.__externref_table_dealloc(idx);
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
function decodeText(ptr, len) {
|
|
104
|
-
numBytesDecoded += len;
|
|
105
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
106
|
-
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
107
|
-
cachedTextDecoder.decode();
|
|
108
|
-
numBytesDecoded = len;
|
|
109
|
-
}
|
|
110
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
111
|
-
}
|
|
112
|
-
function crt_upscale(input, src_w, src_h, scale) {
|
|
113
|
-
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
114
|
-
const len0 = WASM_VECTOR_LEN;
|
|
115
|
-
const ret = wasm.crt_upscale(ptr0, len0, src_w, src_h, scale);
|
|
116
|
-
if (ret[2]) {
|
|
117
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
118
|
-
}
|
|
119
|
-
return UpscaleResult.__wrap(ret[0]);
|
|
120
|
-
}
|
|
121
|
-
function crt_upscale_config(input, src_w, src_h, scale, config) {
|
|
122
|
-
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
123
|
-
const len0 = WASM_VECTOR_LEN;
|
|
124
|
-
_assertClass(config, CrtConfig);
|
|
125
|
-
const ret = wasm.crt_upscale_config(ptr0, len0, src_w, src_h, scale, config.__wbg_ptr);
|
|
126
|
-
if (ret[2]) {
|
|
127
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
128
|
-
}
|
|
129
|
-
return UpscaleResult.__wrap(ret[0]);
|
|
130
|
-
}
|
|
131
|
-
function get_memory() {
|
|
132
|
-
const ret = wasm.get_memory();
|
|
133
|
-
return ret;
|
|
134
|
-
}
|
|
135
|
-
function hex_get_dimensions(src_w, src_h, scale, orientation) {
|
|
136
|
-
const ret = wasm.hex_get_dimensions(src_w, src_h, scale, orientation);
|
|
137
|
-
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
138
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
139
|
-
return v1;
|
|
140
|
-
}
|
|
141
|
-
function hex_upscale(input, src_w, src_h, scale) {
|
|
142
|
-
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
143
|
-
const len0 = WASM_VECTOR_LEN;
|
|
144
|
-
const ret = wasm.hex_upscale(ptr0, len0, src_w, src_h, scale);
|
|
145
|
-
if (ret[2]) {
|
|
146
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
147
|
-
}
|
|
148
|
-
return UpscaleResult.__wrap(ret[0]);
|
|
149
|
-
}
|
|
150
|
-
function hex_upscale_config(input, src_w, src_h, scale, config) {
|
|
151
|
-
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
152
|
-
const len0 = WASM_VECTOR_LEN;
|
|
153
|
-
_assertClass(config, HexConfig);
|
|
154
|
-
const ret = wasm.hex_upscale_config(ptr0, len0, src_w, src_h, scale, config.__wbg_ptr);
|
|
155
|
-
if (ret[2]) {
|
|
156
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
157
|
-
}
|
|
158
|
-
return UpscaleResult.__wrap(ret[0]);
|
|
159
|
-
}
|
|
160
|
-
function init() {
|
|
161
|
-
wasm.init();
|
|
162
|
-
}
|
|
163
|
-
function xbrz_upscale(input, src_w, src_h, scale) {
|
|
164
|
-
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
165
|
-
const len0 = WASM_VECTOR_LEN;
|
|
166
|
-
const ret = wasm.xbrz_upscale(ptr0, len0, src_w, src_h, scale);
|
|
167
|
-
if (ret[2]) {
|
|
168
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
169
|
-
}
|
|
170
|
-
return UpscaleResult.__wrap(ret[0]);
|
|
171
|
-
}
|
|
172
|
-
function xbrz_upscale_config(input, src_w, src_h, scale, config) {
|
|
173
|
-
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
174
|
-
const len0 = WASM_VECTOR_LEN;
|
|
175
|
-
_assertClass(config, XbrzConfig);
|
|
176
|
-
const ret = wasm.xbrz_upscale_config(ptr0, len0, src_w, src_h, scale, config.__wbg_ptr);
|
|
177
|
-
if (ret[2]) {
|
|
178
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
179
|
-
}
|
|
180
|
-
return UpscaleResult.__wrap(ret[0]);
|
|
181
|
-
}
|
|
182
|
-
async function __wbg_load(module, imports) {
|
|
183
|
-
if (typeof Response === "function" && module instanceof Response) {
|
|
184
|
-
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
185
|
-
try {
|
|
186
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
187
|
-
} catch (e) {
|
|
188
|
-
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
189
|
-
if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
|
|
190
|
-
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);
|
|
191
|
-
} else {
|
|
192
|
-
throw e;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const bytes = await module.arrayBuffer();
|
|
197
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
198
|
-
} else {
|
|
199
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
200
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
201
|
-
return { instance, module };
|
|
202
|
-
} else {
|
|
203
|
-
return instance;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function __wbg_get_imports() {
|
|
208
|
-
const imports = {};
|
|
209
|
-
imports.wbg = {};
|
|
210
|
-
imports.wbg.__wbg___wbindgen_memory_a342e963fbcabd68 = function() {
|
|
211
|
-
const ret = wasm.memory;
|
|
212
|
-
return ret;
|
|
213
|
-
};
|
|
214
|
-
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
215
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
216
|
-
};
|
|
217
|
-
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
218
|
-
let deferred0_0;
|
|
219
|
-
let deferred0_1;
|
|
220
|
-
try {
|
|
221
|
-
deferred0_0 = arg0;
|
|
222
|
-
deferred0_1 = arg1;
|
|
223
|
-
console.error(getStringFromWasm0(arg0, arg1));
|
|
224
|
-
} finally {
|
|
225
|
-
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
229
|
-
const ret = new Error();
|
|
230
|
-
return ret;
|
|
231
|
-
};
|
|
232
|
-
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
233
|
-
const ret = arg1.stack;
|
|
234
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
235
|
-
const len1 = WASM_VECTOR_LEN;
|
|
236
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
237
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
238
|
-
};
|
|
239
|
-
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
240
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
241
|
-
return ret;
|
|
242
|
-
};
|
|
243
|
-
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
244
|
-
const table = wasm.__wbindgen_externrefs;
|
|
245
|
-
const offset = table.grow(4);
|
|
246
|
-
table.set(0, void 0);
|
|
247
|
-
table.set(offset + 0, void 0);
|
|
248
|
-
table.set(offset + 1, null);
|
|
249
|
-
table.set(offset + 2, true);
|
|
250
|
-
table.set(offset + 3, false);
|
|
251
|
-
};
|
|
252
|
-
return imports;
|
|
253
|
-
}
|
|
254
|
-
function __wbg_finalize_init(instance, module) {
|
|
255
|
-
wasm = instance.exports;
|
|
256
|
-
__wbg_init.__wbindgen_wasm_module = module;
|
|
257
|
-
cachedDataViewMemory0 = null;
|
|
258
|
-
cachedUint32ArrayMemory0 = null;
|
|
259
|
-
cachedUint8ArrayMemory0 = null;
|
|
260
|
-
wasm.__wbindgen_start();
|
|
261
|
-
return wasm;
|
|
262
|
-
}
|
|
263
|
-
function initSync(module) {
|
|
264
|
-
if (wasm !== void 0) return wasm;
|
|
265
|
-
if (typeof module !== "undefined") {
|
|
266
|
-
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
267
|
-
({ module } = module);
|
|
268
|
-
} else {
|
|
269
|
-
console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
const imports = __wbg_get_imports();
|
|
273
|
-
if (!(module instanceof WebAssembly.Module)) {
|
|
274
|
-
module = new WebAssembly.Module(module);
|
|
275
|
-
}
|
|
276
|
-
const instance = new WebAssembly.Instance(module, imports);
|
|
277
|
-
return __wbg_finalize_init(instance, module);
|
|
278
|
-
}
|
|
279
|
-
async function __wbg_init(module_or_path) {
|
|
280
|
-
if (wasm !== void 0) return wasm;
|
|
281
|
-
if (typeof module_or_path !== "undefined") {
|
|
282
|
-
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
283
|
-
({ module_or_path } = module_or_path);
|
|
284
|
-
} else {
|
|
285
|
-
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (typeof module_or_path === "undefined") {
|
|
289
|
-
module_or_path = new URL("renderart_wasm_bg.wasm", import.meta.url);
|
|
290
|
-
}
|
|
291
|
-
const imports = __wbg_get_imports();
|
|
292
|
-
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
293
|
-
module_or_path = fetch(module_or_path);
|
|
294
|
-
}
|
|
295
|
-
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
296
|
-
return __wbg_finalize_init(instance, module);
|
|
297
|
-
}
|
|
298
|
-
var wasm, cachedDataViewMemory0, cachedUint32ArrayMemory0, cachedUint8ArrayMemory0, cachedTextDecoder, MAX_SAFARI_DECODE_BYTES, numBytesDecoded, cachedTextEncoder, WASM_VECTOR_LEN, CrtConfigFinalization, HexConfigFinalization, UpscaleResultFinalization, XbrzConfigFinalization, CrtConfig, HexConfig, HexOrientation, UpscaleResult, XbrzConfig, EXPECTED_RESPONSE_TYPES, renderart_wasm_default;
|
|
299
|
-
var init_renderart_wasm = __esm({
|
|
300
|
-
"pkg/renderart_wasm.js"() {
|
|
301
|
-
cachedDataViewMemory0 = null;
|
|
302
|
-
cachedUint32ArrayMemory0 = null;
|
|
303
|
-
cachedUint8ArrayMemory0 = null;
|
|
304
|
-
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
305
|
-
cachedTextDecoder.decode();
|
|
306
|
-
MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
307
|
-
numBytesDecoded = 0;
|
|
308
|
-
cachedTextEncoder = new TextEncoder();
|
|
309
|
-
if (!("encodeInto" in cachedTextEncoder)) {
|
|
310
|
-
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
311
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
312
|
-
view.set(buf);
|
|
313
|
-
return {
|
|
314
|
-
read: arg.length,
|
|
315
|
-
written: buf.length
|
|
316
|
-
};
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
WASM_VECTOR_LEN = 0;
|
|
320
|
-
CrtConfigFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
321
|
-
}, unregister: () => {
|
|
322
|
-
} } : new FinalizationRegistry((ptr) => wasm.__wbg_crtconfig_free(ptr >>> 0, 1));
|
|
323
|
-
HexConfigFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
324
|
-
}, unregister: () => {
|
|
325
|
-
} } : new FinalizationRegistry((ptr) => wasm.__wbg_hexconfig_free(ptr >>> 0, 1));
|
|
326
|
-
UpscaleResultFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
327
|
-
}, unregister: () => {
|
|
328
|
-
} } : new FinalizationRegistry((ptr) => wasm.__wbg_upscaleresult_free(ptr >>> 0, 1));
|
|
329
|
-
XbrzConfigFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
|
|
330
|
-
}, unregister: () => {
|
|
331
|
-
} } : new FinalizationRegistry((ptr) => wasm.__wbg_xbrzconfig_free(ptr >>> 0, 1));
|
|
332
|
-
CrtConfig = class _CrtConfig {
|
|
333
|
-
static __wrap(ptr) {
|
|
334
|
-
ptr = ptr >>> 0;
|
|
335
|
-
const obj = Object.create(_CrtConfig.prototype);
|
|
336
|
-
obj.__wbg_ptr = ptr;
|
|
337
|
-
CrtConfigFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
338
|
-
return obj;
|
|
339
|
-
}
|
|
340
|
-
__destroy_into_raw() {
|
|
341
|
-
const ptr = this.__wbg_ptr;
|
|
342
|
-
this.__wbg_ptr = 0;
|
|
343
|
-
CrtConfigFinalization.unregister(this);
|
|
344
|
-
return ptr;
|
|
345
|
-
}
|
|
346
|
-
free() {
|
|
347
|
-
const ptr = this.__destroy_into_raw();
|
|
348
|
-
wasm.__wbg_crtconfig_free(ptr, 0);
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Horizontal warp intensity (0.0 - 0.1)
|
|
352
|
-
* @returns {number}
|
|
353
|
-
*/
|
|
354
|
-
get warp_x() {
|
|
355
|
-
const ret = wasm.__wbg_get_crtconfig_warp_x(this.__wbg_ptr);
|
|
356
|
-
return ret;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Horizontal warp intensity (0.0 - 0.1)
|
|
360
|
-
* @param {number} arg0
|
|
361
|
-
*/
|
|
362
|
-
set warp_x(arg0) {
|
|
363
|
-
wasm.__wbg_set_crtconfig_warp_x(this.__wbg_ptr, arg0);
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Vertical warp intensity (0.0 - 0.1)
|
|
367
|
-
* @returns {number}
|
|
368
|
-
*/
|
|
369
|
-
get warp_y() {
|
|
370
|
-
const ret = wasm.__wbg_get_crtconfig_warp_y(this.__wbg_ptr);
|
|
371
|
-
return ret;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Vertical warp intensity (0.0 - 0.1)
|
|
375
|
-
* @param {number} arg0
|
|
376
|
-
*/
|
|
377
|
-
set warp_y(arg0) {
|
|
378
|
-
wasm.__wbg_set_crtconfig_warp_y(this.__wbg_ptr, arg0);
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Scanline hardness (-10.0 to 0.0, more negative = sharper)
|
|
382
|
-
* @returns {number}
|
|
383
|
-
*/
|
|
384
|
-
get scan_hardness() {
|
|
385
|
-
const ret = wasm.__wbg_get_crtconfig_scan_hardness(this.__wbg_ptr);
|
|
386
|
-
return ret;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Scanline hardness (-10.0 to 0.0, more negative = sharper)
|
|
390
|
-
* @param {number} arg0
|
|
391
|
-
*/
|
|
392
|
-
set scan_hardness(arg0) {
|
|
393
|
-
wasm.__wbg_set_crtconfig_scan_hardness(this.__wbg_ptr, arg0);
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Scanline opacity (0.0 - 1.0)
|
|
397
|
-
* @returns {number}
|
|
398
|
-
*/
|
|
399
|
-
get scan_opacity() {
|
|
400
|
-
const ret = wasm.__wbg_get_crtconfig_scan_opacity(this.__wbg_ptr);
|
|
401
|
-
return ret;
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Scanline opacity (0.0 - 1.0)
|
|
405
|
-
* @param {number} arg0
|
|
406
|
-
*/
|
|
407
|
-
set scan_opacity(arg0) {
|
|
408
|
-
wasm.__wbg_set_crtconfig_scan_opacity(this.__wbg_ptr, arg0);
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Shadow mask opacity (0.0 - 1.0)
|
|
412
|
-
* @returns {number}
|
|
413
|
-
*/
|
|
414
|
-
get mask_opacity() {
|
|
415
|
-
const ret = wasm.__wbg_get_crtconfig_mask_opacity(this.__wbg_ptr);
|
|
416
|
-
return ret;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Shadow mask opacity (0.0 - 1.0)
|
|
420
|
-
* @param {number} arg0
|
|
421
|
-
*/
|
|
422
|
-
set mask_opacity(arg0) {
|
|
423
|
-
wasm.__wbg_set_crtconfig_mask_opacity(this.__wbg_ptr, arg0);
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Enable barrel distortion
|
|
427
|
-
* @returns {boolean}
|
|
428
|
-
*/
|
|
429
|
-
get enable_warp() {
|
|
430
|
-
const ret = wasm.__wbg_get_crtconfig_enable_warp(this.__wbg_ptr);
|
|
431
|
-
return ret !== 0;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Enable barrel distortion
|
|
435
|
-
* @param {boolean} arg0
|
|
436
|
-
*/
|
|
437
|
-
set enable_warp(arg0) {
|
|
438
|
-
wasm.__wbg_set_crtconfig_enable_warp(this.__wbg_ptr, arg0);
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Enable scanlines
|
|
442
|
-
* @returns {boolean}
|
|
443
|
-
*/
|
|
444
|
-
get enable_scanlines() {
|
|
445
|
-
const ret = wasm.__wbg_get_crtconfig_enable_scanlines(this.__wbg_ptr);
|
|
446
|
-
return ret !== 0;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Enable scanlines
|
|
450
|
-
* @param {boolean} arg0
|
|
451
|
-
*/
|
|
452
|
-
set enable_scanlines(arg0) {
|
|
453
|
-
wasm.__wbg_set_crtconfig_enable_scanlines(this.__wbg_ptr, arg0);
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Enable shadow mask
|
|
457
|
-
* @returns {boolean}
|
|
458
|
-
*/
|
|
459
|
-
get enable_mask() {
|
|
460
|
-
const ret = wasm.__wbg_get_crtconfig_enable_mask(this.__wbg_ptr);
|
|
461
|
-
return ret !== 0;
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Enable shadow mask
|
|
465
|
-
* @param {boolean} arg0
|
|
466
|
-
*/
|
|
467
|
-
set enable_mask(arg0) {
|
|
468
|
-
wasm.__wbg_set_crtconfig_enable_mask(this.__wbg_ptr, arg0);
|
|
469
|
-
}
|
|
470
|
-
constructor() {
|
|
471
|
-
const ret = wasm.crtconfig_new();
|
|
472
|
-
this.__wbg_ptr = ret >>> 0;
|
|
473
|
-
CrtConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
474
|
-
return this;
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Create preset: Authentic CRT look
|
|
478
|
-
* @returns {CrtConfig}
|
|
479
|
-
*/
|
|
480
|
-
static preset_authentic() {
|
|
481
|
-
const ret = wasm.crtconfig_preset_authentic();
|
|
482
|
-
return _CrtConfig.__wrap(ret);
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Create preset: Subtle modern look
|
|
486
|
-
* @returns {CrtConfig}
|
|
487
|
-
*/
|
|
488
|
-
static preset_subtle() {
|
|
489
|
-
const ret = wasm.crtconfig_preset_subtle();
|
|
490
|
-
return _CrtConfig.__wrap(ret);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Create preset: Flat screen (no curvature)
|
|
494
|
-
* @returns {CrtConfig}
|
|
495
|
-
*/
|
|
496
|
-
static preset_flat() {
|
|
497
|
-
const ret = wasm.crtconfig_preset_flat();
|
|
498
|
-
return _CrtConfig.__wrap(ret);
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
if (Symbol.dispose) CrtConfig.prototype[Symbol.dispose] = CrtConfig.prototype.free;
|
|
502
|
-
HexConfig = class _HexConfig {
|
|
503
|
-
static __wrap(ptr) {
|
|
504
|
-
ptr = ptr >>> 0;
|
|
505
|
-
const obj = Object.create(_HexConfig.prototype);
|
|
506
|
-
obj.__wbg_ptr = ptr;
|
|
507
|
-
HexConfigFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
508
|
-
return obj;
|
|
509
|
-
}
|
|
510
|
-
__destroy_into_raw() {
|
|
511
|
-
const ptr = this.__wbg_ptr;
|
|
512
|
-
this.__wbg_ptr = 0;
|
|
513
|
-
HexConfigFinalization.unregister(this);
|
|
514
|
-
return ptr;
|
|
515
|
-
}
|
|
516
|
-
free() {
|
|
517
|
-
const ptr = this.__destroy_into_raw();
|
|
518
|
-
wasm.__wbg_hexconfig_free(ptr, 0);
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Hexagon orientation
|
|
522
|
-
* @returns {HexOrientation}
|
|
523
|
-
*/
|
|
524
|
-
get orientation() {
|
|
525
|
-
const ret = wasm.__wbg_get_hexconfig_orientation(this.__wbg_ptr);
|
|
526
|
-
return ret;
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Hexagon orientation
|
|
530
|
-
* @param {HexOrientation} arg0
|
|
531
|
-
*/
|
|
532
|
-
set orientation(arg0) {
|
|
533
|
-
wasm.__wbg_set_hexconfig_orientation(this.__wbg_ptr, arg0);
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Draw hexagon borders
|
|
537
|
-
* @returns {boolean}
|
|
538
|
-
*/
|
|
539
|
-
get draw_borders() {
|
|
540
|
-
const ret = wasm.__wbg_get_hexconfig_draw_borders(this.__wbg_ptr);
|
|
541
|
-
return ret !== 0;
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Draw hexagon borders
|
|
545
|
-
* @param {boolean} arg0
|
|
546
|
-
*/
|
|
547
|
-
set draw_borders(arg0) {
|
|
548
|
-
wasm.__wbg_set_hexconfig_draw_borders(this.__wbg_ptr, arg0);
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* Border color (RGBA packed as u32: 0xRRGGBBAA)
|
|
552
|
-
* @returns {number}
|
|
553
|
-
*/
|
|
554
|
-
get border_color() {
|
|
555
|
-
const ret = wasm.__wbg_get_hexconfig_border_color(this.__wbg_ptr);
|
|
556
|
-
return ret >>> 0;
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Border color (RGBA packed as u32: 0xRRGGBBAA)
|
|
560
|
-
* @param {number} arg0
|
|
561
|
-
*/
|
|
562
|
-
set border_color(arg0) {
|
|
563
|
-
wasm.__wbg_set_hexconfig_border_color(this.__wbg_ptr, arg0);
|
|
564
|
-
}
|
|
565
|
-
/**
|
|
566
|
-
* Border thickness in pixels
|
|
567
|
-
* @returns {number}
|
|
568
|
-
*/
|
|
569
|
-
get border_thickness() {
|
|
570
|
-
const ret = wasm.__wbg_get_hexconfig_border_thickness(this.__wbg_ptr);
|
|
571
|
-
return ret >>> 0;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Border thickness in pixels
|
|
575
|
-
* @param {number} arg0
|
|
576
|
-
*/
|
|
577
|
-
set border_thickness(arg0) {
|
|
578
|
-
wasm.__wbg_set_hexconfig_border_thickness(this.__wbg_ptr, arg0);
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Background color (RGBA packed as u32)
|
|
582
|
-
* @returns {number}
|
|
583
|
-
*/
|
|
584
|
-
get background_color() {
|
|
585
|
-
const ret = wasm.__wbg_get_hexconfig_background_color(this.__wbg_ptr);
|
|
586
|
-
return ret >>> 0;
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* Background color (RGBA packed as u32)
|
|
590
|
-
* @param {number} arg0
|
|
591
|
-
*/
|
|
592
|
-
set background_color(arg0) {
|
|
593
|
-
wasm.__wbg_set_hexconfig_background_color(this.__wbg_ptr, arg0);
|
|
594
|
-
}
|
|
595
|
-
constructor() {
|
|
596
|
-
const ret = wasm.hexconfig_new();
|
|
597
|
-
this.__wbg_ptr = ret >>> 0;
|
|
598
|
-
HexConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
599
|
-
return this;
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Create preset with borders
|
|
603
|
-
* @returns {HexConfig}
|
|
604
|
-
*/
|
|
605
|
-
static preset_bordered() {
|
|
606
|
-
const ret = wasm.hexconfig_preset_bordered();
|
|
607
|
-
return _HexConfig.__wrap(ret);
|
|
608
|
-
}
|
|
609
|
-
/**
|
|
610
|
-
* Create preset for pointy-top hexagons
|
|
611
|
-
* @returns {HexConfig}
|
|
612
|
-
*/
|
|
613
|
-
static preset_pointy() {
|
|
614
|
-
const ret = wasm.hexconfig_preset_pointy();
|
|
615
|
-
return _HexConfig.__wrap(ret);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
if (Symbol.dispose) HexConfig.prototype[Symbol.dispose] = HexConfig.prototype.free;
|
|
619
|
-
HexOrientation = Object.freeze({
|
|
620
|
-
/**
|
|
621
|
-
* Flat edge at top, vertices on left/right
|
|
622
|
-
*/
|
|
623
|
-
FlatTop: 0,
|
|
624
|
-
"0": "FlatTop",
|
|
625
|
-
/**
|
|
626
|
-
* Vertex at top, flat edges on left/right
|
|
627
|
-
*/
|
|
628
|
-
PointyTop: 1,
|
|
629
|
-
"1": "PointyTop"
|
|
630
|
-
});
|
|
631
|
-
UpscaleResult = class _UpscaleResult {
|
|
632
|
-
static __wrap(ptr) {
|
|
633
|
-
ptr = ptr >>> 0;
|
|
634
|
-
const obj = Object.create(_UpscaleResult.prototype);
|
|
635
|
-
obj.__wbg_ptr = ptr;
|
|
636
|
-
UpscaleResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
637
|
-
return obj;
|
|
638
|
-
}
|
|
639
|
-
__destroy_into_raw() {
|
|
640
|
-
const ptr = this.__wbg_ptr;
|
|
641
|
-
this.__wbg_ptr = 0;
|
|
642
|
-
UpscaleResultFinalization.unregister(this);
|
|
643
|
-
return ptr;
|
|
644
|
-
}
|
|
645
|
-
free() {
|
|
646
|
-
const ptr = this.__destroy_into_raw();
|
|
647
|
-
wasm.__wbg_upscaleresult_free(ptr, 0);
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Pointer to the output buffer in WASM memory
|
|
651
|
-
* @returns {number}
|
|
652
|
-
*/
|
|
653
|
-
get ptr() {
|
|
654
|
-
const ret = wasm.upscaleresult_ptr(this.__wbg_ptr);
|
|
655
|
-
return ret >>> 0;
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Length of the output buffer in bytes
|
|
659
|
-
* @returns {number}
|
|
660
|
-
*/
|
|
661
|
-
get len() {
|
|
662
|
-
const ret = wasm.upscaleresult_len(this.__wbg_ptr);
|
|
663
|
-
return ret >>> 0;
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Output image width
|
|
667
|
-
* @returns {number}
|
|
668
|
-
*/
|
|
669
|
-
get width() {
|
|
670
|
-
const ret = wasm.upscaleresult_width(this.__wbg_ptr);
|
|
671
|
-
return ret >>> 0;
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Output image height
|
|
675
|
-
* @returns {number}
|
|
676
|
-
*/
|
|
677
|
-
get height() {
|
|
678
|
-
const ret = wasm.upscaleresult_height(this.__wbg_ptr);
|
|
679
|
-
return ret >>> 0;
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
if (Symbol.dispose) UpscaleResult.prototype[Symbol.dispose] = UpscaleResult.prototype.free;
|
|
683
|
-
XbrzConfig = class _XbrzConfig {
|
|
684
|
-
static __wrap(ptr) {
|
|
685
|
-
ptr = ptr >>> 0;
|
|
686
|
-
const obj = Object.create(_XbrzConfig.prototype);
|
|
687
|
-
obj.__wbg_ptr = ptr;
|
|
688
|
-
XbrzConfigFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
689
|
-
return obj;
|
|
690
|
-
}
|
|
691
|
-
__destroy_into_raw() {
|
|
692
|
-
const ptr = this.__wbg_ptr;
|
|
693
|
-
this.__wbg_ptr = 0;
|
|
694
|
-
XbrzConfigFinalization.unregister(this);
|
|
695
|
-
return ptr;
|
|
696
|
-
}
|
|
697
|
-
free() {
|
|
698
|
-
const ptr = this.__destroy_into_raw();
|
|
699
|
-
wasm.__wbg_xbrzconfig_free(ptr, 0);
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Luminance weight for edge detection (0.0 - 1.0)
|
|
703
|
-
* @returns {number}
|
|
704
|
-
*/
|
|
705
|
-
get luminance_weight() {
|
|
706
|
-
const ret = wasm.__wbg_get_crtconfig_warp_x(this.__wbg_ptr);
|
|
707
|
-
return ret;
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Luminance weight for edge detection (0.0 - 1.0)
|
|
711
|
-
* @param {number} arg0
|
|
712
|
-
*/
|
|
713
|
-
set luminance_weight(arg0) {
|
|
714
|
-
wasm.__wbg_set_crtconfig_warp_x(this.__wbg_ptr, arg0);
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Equal color tolerance (0 - 50)
|
|
718
|
-
* @returns {number}
|
|
719
|
-
*/
|
|
720
|
-
get equal_color_tolerance() {
|
|
721
|
-
const ret = wasm.__wbg_get_hexconfig_border_thickness(this.__wbg_ptr);
|
|
722
|
-
return ret >>> 0;
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Equal color tolerance (0 - 50)
|
|
726
|
-
* @param {number} arg0
|
|
727
|
-
*/
|
|
728
|
-
set equal_color_tolerance(arg0) {
|
|
729
|
-
wasm.__wbg_set_hexconfig_border_thickness(this.__wbg_ptr, arg0);
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Dominant direction threshold (3.5 - 6.0)
|
|
733
|
-
* @returns {number}
|
|
734
|
-
*/
|
|
735
|
-
get dominant_direction_threshold() {
|
|
736
|
-
const ret = wasm.__wbg_get_crtconfig_scan_hardness(this.__wbg_ptr);
|
|
737
|
-
return ret;
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Dominant direction threshold (3.5 - 6.0)
|
|
741
|
-
* @param {number} arg0
|
|
742
|
-
*/
|
|
743
|
-
set dominant_direction_threshold(arg0) {
|
|
744
|
-
wasm.__wbg_set_crtconfig_scan_hardness(this.__wbg_ptr, arg0);
|
|
745
|
-
}
|
|
746
|
-
/**
|
|
747
|
-
* Steep direction threshold (2.0 - 3.0)
|
|
748
|
-
* @returns {number}
|
|
749
|
-
*/
|
|
750
|
-
get steep_direction_threshold() {
|
|
751
|
-
const ret = wasm.__wbg_get_crtconfig_scan_opacity(this.__wbg_ptr);
|
|
752
|
-
return ret;
|
|
753
|
-
}
|
|
754
|
-
/**
|
|
755
|
-
* Steep direction threshold (2.0 - 3.0)
|
|
756
|
-
* @param {number} arg0
|
|
757
|
-
*/
|
|
758
|
-
set steep_direction_threshold(arg0) {
|
|
759
|
-
wasm.__wbg_set_crtconfig_scan_opacity(this.__wbg_ptr, arg0);
|
|
760
|
-
}
|
|
761
|
-
constructor() {
|
|
762
|
-
const ret = wasm.xbrzconfig_new();
|
|
763
|
-
this.__wbg_ptr = ret >>> 0;
|
|
764
|
-
XbrzConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
765
|
-
return this;
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* Preset for sharp edges
|
|
769
|
-
* @returns {XbrzConfig}
|
|
770
|
-
*/
|
|
771
|
-
static preset_sharp() {
|
|
772
|
-
const ret = wasm.xbrzconfig_preset_sharp();
|
|
773
|
-
return _XbrzConfig.__wrap(ret);
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Preset for smooth output
|
|
777
|
-
* @returns {XbrzConfig}
|
|
778
|
-
*/
|
|
779
|
-
static preset_smooth() {
|
|
780
|
-
const ret = wasm.xbrzconfig_preset_smooth();
|
|
781
|
-
return _XbrzConfig.__wrap(ret);
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
if (Symbol.dispose) XbrzConfig.prototype[Symbol.dispose] = XbrzConfig.prototype.free;
|
|
785
|
-
EXPECTED_RESPONSE_TYPES = /* @__PURE__ */ new Set(["basic", "cors", "default"]);
|
|
786
|
-
renderart_wasm_default = __wbg_init;
|
|
787
|
-
}
|
|
788
|
-
});
|
|
789
|
-
|
|
790
1
|
// src/crt-gpu.ts
|
|
791
2
|
var VERTEX_SHADER = `#version 300 es
|
|
792
3
|
layout(location = 0) in vec2 position;
|
|
@@ -1409,26 +620,33 @@ var HEX_PRESETS = {
|
|
|
1409
620
|
// src/wasm-loader.ts
|
|
1410
621
|
var wasmModule = null;
|
|
1411
622
|
var wasmMemory = null;
|
|
1412
|
-
var
|
|
1413
|
-
async function
|
|
1414
|
-
if (wasmModule) return
|
|
1415
|
-
if (
|
|
1416
|
-
|
|
623
|
+
var initPromise = null;
|
|
624
|
+
async function initWasm(wasmInit, wasm) {
|
|
625
|
+
if (wasmModule) return;
|
|
626
|
+
if (initPromise) return initPromise;
|
|
627
|
+
initPromise = (async () => {
|
|
1417
628
|
try {
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
wasmModule
|
|
1421
|
-
|
|
1422
|
-
|
|
629
|
+
await wasmInit();
|
|
630
|
+
wasmModule = wasm;
|
|
631
|
+
if (wasmModule.get_memory) {
|
|
632
|
+
wasmMemory = wasmModule.get_memory();
|
|
633
|
+
}
|
|
1423
634
|
} catch (e) {
|
|
1424
|
-
|
|
635
|
+
initPromise = null;
|
|
636
|
+
throw new Error(`Failed to initialize WASM module: ${e}`);
|
|
1425
637
|
}
|
|
1426
638
|
})();
|
|
1427
|
-
return
|
|
639
|
+
return initPromise;
|
|
1428
640
|
}
|
|
1429
641
|
function isWasmLoaded() {
|
|
1430
642
|
return wasmModule !== null;
|
|
1431
643
|
}
|
|
644
|
+
function getWasmModule() {
|
|
645
|
+
if (!wasmModule) {
|
|
646
|
+
throw new Error("WASM not initialized. Call initWasm() first.");
|
|
647
|
+
}
|
|
648
|
+
return wasmModule;
|
|
649
|
+
}
|
|
1432
650
|
function getOutputData(result) {
|
|
1433
651
|
if (!wasmMemory) throw new Error("WASM memory not available");
|
|
1434
652
|
const buffer = new Uint8Array(wasmMemory.buffer, result.ptr, result.len);
|
|
@@ -1457,19 +675,18 @@ var CrtCpuRenderer = class _CrtCpuRenderer {
|
|
|
1457
675
|
constructor() {
|
|
1458
676
|
this.ready = false;
|
|
1459
677
|
}
|
|
1460
|
-
/** Create
|
|
1461
|
-
static
|
|
678
|
+
/** Create renderer (WASM must be initialized first via initWasm) */
|
|
679
|
+
static create() {
|
|
680
|
+
if (!isWasmLoaded()) {
|
|
681
|
+
throw new Error("WASM not initialized. Call initWasm() first.");
|
|
682
|
+
}
|
|
1462
683
|
const renderer = new _CrtCpuRenderer();
|
|
1463
|
-
|
|
684
|
+
renderer.ready = true;
|
|
1464
685
|
return renderer;
|
|
1465
686
|
}
|
|
1466
|
-
async init() {
|
|
1467
|
-
await loadWasm();
|
|
1468
|
-
this.ready = true;
|
|
1469
|
-
}
|
|
1470
687
|
/** Check if renderer is ready */
|
|
1471
688
|
isReady() {
|
|
1472
|
-
return this.ready;
|
|
689
|
+
return this.ready && isWasmLoaded();
|
|
1473
690
|
}
|
|
1474
691
|
/** Render CRT effect */
|
|
1475
692
|
render(input, options = {}) {
|
|
@@ -1505,19 +722,18 @@ var HexCpuRenderer = class _HexCpuRenderer {
|
|
|
1505
722
|
constructor() {
|
|
1506
723
|
this.ready = false;
|
|
1507
724
|
}
|
|
1508
|
-
/** Create
|
|
1509
|
-
static
|
|
725
|
+
/** Create renderer (WASM must be initialized first via initWasm) */
|
|
726
|
+
static create() {
|
|
727
|
+
if (!isWasmLoaded()) {
|
|
728
|
+
throw new Error("WASM not initialized. Call initWasm() first.");
|
|
729
|
+
}
|
|
1510
730
|
const renderer = new _HexCpuRenderer();
|
|
1511
|
-
|
|
731
|
+
renderer.ready = true;
|
|
1512
732
|
return renderer;
|
|
1513
733
|
}
|
|
1514
|
-
async init() {
|
|
1515
|
-
await loadWasm();
|
|
1516
|
-
this.ready = true;
|
|
1517
|
-
}
|
|
1518
734
|
/** Check if renderer is ready */
|
|
1519
735
|
isReady() {
|
|
1520
|
-
return this.ready;
|
|
736
|
+
return this.ready && isWasmLoaded();
|
|
1521
737
|
}
|
|
1522
738
|
/** Render hexagonal effect */
|
|
1523
739
|
render(input, options = {}) {
|
|
@@ -1558,19 +774,18 @@ var XbrzCpuRenderer = class _XbrzCpuRenderer {
|
|
|
1558
774
|
constructor() {
|
|
1559
775
|
this.ready = false;
|
|
1560
776
|
}
|
|
1561
|
-
/** Create
|
|
1562
|
-
static
|
|
777
|
+
/** Create renderer (WASM must be initialized first via initWasm) */
|
|
778
|
+
static create() {
|
|
779
|
+
if (!isWasmLoaded()) {
|
|
780
|
+
throw new Error("WASM not initialized. Call initWasm() first.");
|
|
781
|
+
}
|
|
1563
782
|
const renderer = new _XbrzCpuRenderer();
|
|
1564
|
-
|
|
783
|
+
renderer.ready = true;
|
|
1565
784
|
return renderer;
|
|
1566
785
|
}
|
|
1567
|
-
async init() {
|
|
1568
|
-
await loadWasm();
|
|
1569
|
-
this.ready = true;
|
|
1570
|
-
}
|
|
1571
786
|
/** Check if renderer is ready */
|
|
1572
787
|
isReady() {
|
|
1573
|
-
return this.ready;
|
|
788
|
+
return this.ready && isWasmLoaded();
|
|
1574
789
|
}
|
|
1575
790
|
/** Render xBRZ scaling */
|
|
1576
791
|
render(input, options = {}) {
|
|
@@ -1650,14 +865,14 @@ var CrtEngine = class {
|
|
|
1650
865
|
return this.gpuRenderer;
|
|
1651
866
|
}
|
|
1652
867
|
/** Initialize CPU renderer */
|
|
1653
|
-
|
|
1654
|
-
if (!this.cpuRenderer && this.cpuAvailable) {
|
|
1655
|
-
this.cpuRenderer =
|
|
868
|
+
ensureCpu() {
|
|
869
|
+
if (!this.cpuRenderer && this.cpuAvailable && isWasmLoaded()) {
|
|
870
|
+
this.cpuRenderer = CrtCpuRenderer.create();
|
|
1656
871
|
}
|
|
1657
|
-
if (!this.cpuRenderer) throw new Error("CPU renderer not available");
|
|
872
|
+
if (!this.cpuRenderer) throw new Error("CPU renderer not available. Initialize WASM first.");
|
|
1658
873
|
return this.cpuRenderer;
|
|
1659
874
|
}
|
|
1660
|
-
|
|
875
|
+
render(input, optionsOrPreset, overrides) {
|
|
1661
876
|
let options = {};
|
|
1662
877
|
if (typeof optionsOrPreset === "string") {
|
|
1663
878
|
options = { ...CRT_PRESETS[optionsOrPreset], ...overrides };
|
|
@@ -1672,8 +887,7 @@ var CrtEngine = class {
|
|
|
1672
887
|
if (backend === "gpu") throw e;
|
|
1673
888
|
}
|
|
1674
889
|
}
|
|
1675
|
-
|
|
1676
|
-
return cpu.render(input, options);
|
|
890
|
+
return this.ensureCpu().render(input, options);
|
|
1677
891
|
}
|
|
1678
892
|
/** Render synchronously (GPU only) */
|
|
1679
893
|
renderSync(input, options) {
|
|
@@ -1701,14 +915,14 @@ var HexEngine = class {
|
|
|
1701
915
|
if (!this.gpuRenderer) throw new Error("GPU renderer not available");
|
|
1702
916
|
return this.gpuRenderer;
|
|
1703
917
|
}
|
|
1704
|
-
|
|
1705
|
-
if (!this.cpuRenderer && this.cpuAvailable) {
|
|
1706
|
-
this.cpuRenderer =
|
|
918
|
+
ensureCpu() {
|
|
919
|
+
if (!this.cpuRenderer && this.cpuAvailable && isWasmLoaded()) {
|
|
920
|
+
this.cpuRenderer = HexCpuRenderer.create();
|
|
1707
921
|
}
|
|
1708
|
-
if (!this.cpuRenderer) throw new Error("CPU renderer not available");
|
|
922
|
+
if (!this.cpuRenderer) throw new Error("CPU renderer not available. Initialize WASM first.");
|
|
1709
923
|
return this.cpuRenderer;
|
|
1710
924
|
}
|
|
1711
|
-
|
|
925
|
+
render(input, optionsOrPreset, overrides) {
|
|
1712
926
|
let options = {};
|
|
1713
927
|
if (typeof optionsOrPreset === "string") {
|
|
1714
928
|
options = { ...HEX_PRESETS[optionsOrPreset], ...overrides };
|
|
@@ -1723,8 +937,7 @@ var HexEngine = class {
|
|
|
1723
937
|
if (backend === "gpu") throw e;
|
|
1724
938
|
}
|
|
1725
939
|
}
|
|
1726
|
-
|
|
1727
|
-
return cpu.render(input, options);
|
|
940
|
+
return this.ensureCpu().render(input, options);
|
|
1728
941
|
}
|
|
1729
942
|
/** Render synchronously (GPU only) */
|
|
1730
943
|
renderSync(input, options) {
|
|
@@ -1748,22 +961,21 @@ var XbrzEngine = class {
|
|
|
1748
961
|
this.cpuRenderer = null;
|
|
1749
962
|
this.cpuAvailable = cpuAvailable;
|
|
1750
963
|
}
|
|
1751
|
-
|
|
1752
|
-
if (!this.cpuRenderer && this.cpuAvailable) {
|
|
1753
|
-
this.cpuRenderer =
|
|
964
|
+
ensureCpu() {
|
|
965
|
+
if (!this.cpuRenderer && this.cpuAvailable && isWasmLoaded()) {
|
|
966
|
+
this.cpuRenderer = XbrzCpuRenderer.create();
|
|
1754
967
|
}
|
|
1755
|
-
if (!this.cpuRenderer) throw new Error("CPU renderer not available");
|
|
968
|
+
if (!this.cpuRenderer) throw new Error("CPU renderer not available. Initialize WASM first.");
|
|
1756
969
|
return this.cpuRenderer;
|
|
1757
970
|
}
|
|
1758
|
-
|
|
971
|
+
render(input, optionsOrPreset, overrides) {
|
|
1759
972
|
let options = {};
|
|
1760
973
|
if (typeof optionsOrPreset === "string") {
|
|
1761
974
|
options = { ...XBRZ_PRESETS[optionsOrPreset], ...overrides };
|
|
1762
975
|
} else if (optionsOrPreset) {
|
|
1763
976
|
options = optionsOrPreset;
|
|
1764
977
|
}
|
|
1765
|
-
|
|
1766
|
-
return cpu.render(input, options);
|
|
978
|
+
return this.ensureCpu().render(input, options);
|
|
1767
979
|
}
|
|
1768
980
|
/** Get output dimensions */
|
|
1769
981
|
getDimensions(srcWidth, srcHeight, scale = 2) {
|
|
@@ -1788,20 +1000,30 @@ var RenderArt = class _RenderArt {
|
|
|
1788
1000
|
recommendedBackend: gpuAvailable ? "gpu" : cpuAvailable ? "cpu" : "auto"
|
|
1789
1001
|
};
|
|
1790
1002
|
}
|
|
1791
|
-
/**
|
|
1792
|
-
|
|
1003
|
+
/**
|
|
1004
|
+
* Create RenderArt instance
|
|
1005
|
+
* GPU renderers always available if WebGL2 supported.
|
|
1006
|
+
* CPU renderers require WASM to be initialized via initWasm() first.
|
|
1007
|
+
*/
|
|
1008
|
+
static create() {
|
|
1793
1009
|
const gpuAvailable = checkWebGL2();
|
|
1794
|
-
|
|
1795
|
-
try {
|
|
1796
|
-
await loadWasm();
|
|
1797
|
-
cpuAvailable = isWasmLoaded();
|
|
1798
|
-
} catch {
|
|
1799
|
-
}
|
|
1010
|
+
const cpuAvailable = isWasmLoaded();
|
|
1800
1011
|
if (!gpuAvailable && !cpuAvailable) {
|
|
1801
|
-
throw new Error("No rendering backend available. WebGL2
|
|
1012
|
+
throw new Error("No rendering backend available. WebGL2 not supported and WASM not initialized.");
|
|
1802
1013
|
}
|
|
1803
1014
|
return new _RenderArt(gpuAvailable, cpuAvailable);
|
|
1804
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Create GPU-only RenderArt instance (no WASM required)
|
|
1018
|
+
* CPU fallback will not be available.
|
|
1019
|
+
*/
|
|
1020
|
+
static createGpuOnly() {
|
|
1021
|
+
const gpuAvailable = checkWebGL2();
|
|
1022
|
+
if (!gpuAvailable) {
|
|
1023
|
+
throw new Error("WebGL2 not supported");
|
|
1024
|
+
}
|
|
1025
|
+
return new _RenderArt(true, false);
|
|
1026
|
+
}
|
|
1805
1027
|
/** Get renderer capabilities */
|
|
1806
1028
|
get capabilities() {
|
|
1807
1029
|
return { ...this._capabilities };
|
|
@@ -1814,6 +1036,6 @@ var RenderArt = class _RenderArt {
|
|
|
1814
1036
|
}
|
|
1815
1037
|
};
|
|
1816
1038
|
|
|
1817
|
-
export { CRT_PRESETS, CrtCpuRenderer, CrtGpuRenderer, HEX_PRESETS, HexCpuRenderer, HexGpuRenderer, RenderArt, XBRZ_PRESETS, XbrzCpuRenderer, hexGetDimensions,
|
|
1039
|
+
export { CRT_PRESETS, CrtCpuRenderer, CrtEngine, CrtGpuRenderer, HEX_PRESETS, HexCpuRenderer, HexEngine, HexGpuRenderer, RenderArt, XBRZ_PRESETS, XbrzCpuRenderer, XbrzEngine, getWasmModule, hexGetDimensions, initWasm, isWasmLoaded };
|
|
1818
1040
|
//# sourceMappingURL=index.mjs.map
|
|
1819
1041
|
//# sourceMappingURL=index.mjs.map
|