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