funicular 0.2.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/funicular/compiler.rb +2 -3
- data/lib/funicular/vendor/picorbc/picorbc.wasm +0 -0
- data/lib/funicular/vendor/picoruby/debug/picoruby.js +30 -21
- data/lib/funicular/vendor/picoruby/debug/picoruby.wasm +0 -0
- data/lib/funicular/vendor/picoruby/dist/picoruby.js +1 -1
- data/lib/funicular/vendor/picoruby/dist/picoruby.wasm +0 -0
- data/lib/funicular/vendor/picoruby-test-node/picoruby.js +113 -90
- data/lib/funicular/vendor/picoruby-test-node/picoruby.wasm +0 -0
- data/lib/funicular/vendor/picoruby-test-node/picoruby.wasm.map +1 -1
- data/lib/funicular/version.rb +1 -1
- data/minitest/form_for_test.rb +106 -0
- data/mrblib/component.rb +74 -14
- data/mrblib/form_builder.rb +7 -1
- data/mrblib/patcher.rb +4 -0
- data/mrblib/vdom.rb +2 -0
- metadata +2 -1
|
Binary file
|
|
@@ -753,57 +753,6 @@ async function createWasm() {
|
|
|
753
753
|
|
|
754
754
|
|
|
755
755
|
|
|
756
|
-
var wasmTableMirror = [];
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
var getWasmTableEntry = (funcPtr) => {
|
|
760
|
-
var func = wasmTableMirror[funcPtr];
|
|
761
|
-
if (!func) {
|
|
762
|
-
/** @suppress {checkTypes} */
|
|
763
|
-
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
764
|
-
}
|
|
765
|
-
/** @suppress {checkTypes} */
|
|
766
|
-
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
|
|
767
|
-
return func;
|
|
768
|
-
};
|
|
769
|
-
var ___call_sighandler = (fp, sig) => getWasmTableEntry(fp)(sig);
|
|
770
|
-
|
|
771
|
-
var nodePath = require('node:path');
|
|
772
|
-
var PATH = {
|
|
773
|
-
isAbs: nodePath.isAbsolute,
|
|
774
|
-
normalize: nodePath.normalize,
|
|
775
|
-
dirname: nodePath.dirname,
|
|
776
|
-
basename: nodePath.basename,
|
|
777
|
-
join: nodePath.join,
|
|
778
|
-
join2: nodePath.join,
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
var initRandomFill = () => {
|
|
782
|
-
// This block is not needed on v19+ since crypto.getRandomValues is builtin
|
|
783
|
-
if (ENVIRONMENT_IS_NODE) {
|
|
784
|
-
var nodeCrypto = require('node:crypto');
|
|
785
|
-
return (view) => nodeCrypto.randomFillSync(view);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
return (view) => crypto.getRandomValues(view);
|
|
789
|
-
};
|
|
790
|
-
var randomFill = (view) => {
|
|
791
|
-
// Lazily init on the first invocation.
|
|
792
|
-
(randomFill = initRandomFill())(view);
|
|
793
|
-
};
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
/** @type{{resolve: function(...*)}} */
|
|
798
|
-
var PATH_FS = {
|
|
799
|
-
resolve:(...paths) => {
|
|
800
|
-
paths.unshift(FS.cwd());
|
|
801
|
-
return nodePath.posix.resolve(...paths);
|
|
802
|
-
},
|
|
803
|
-
relative:(from, to) => nodePath.posix.relative(from || FS.cwd(), to || FS.cwd()),
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
|
|
807
756
|
var UTF8Decoder = globalThis.TextDecoder && new TextDecoder();
|
|
808
757
|
|
|
809
758
|
var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
@@ -864,6 +813,78 @@ async function createWasm() {
|
|
|
864
813
|
return str;
|
|
865
814
|
};
|
|
866
815
|
|
|
816
|
+
/**
|
|
817
|
+
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
818
|
+
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
819
|
+
*
|
|
820
|
+
* @param {number} ptr
|
|
821
|
+
* @param {number=} maxBytesToRead - An optional length that specifies the
|
|
822
|
+
* maximum number of bytes to read. You can omit this parameter to scan the
|
|
823
|
+
* string until the first 0 byte. If maxBytesToRead is passed, and the string
|
|
824
|
+
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
|
|
825
|
+
* string will cut short at that byte index.
|
|
826
|
+
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
827
|
+
* @return {string}
|
|
828
|
+
*/
|
|
829
|
+
var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
|
|
830
|
+
assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
|
|
831
|
+
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : '';
|
|
832
|
+
};
|
|
833
|
+
var ___assert_fail = (condition, filename, line, func) =>
|
|
834
|
+
abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
|
835
|
+
|
|
836
|
+
var wasmTableMirror = [];
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
var getWasmTableEntry = (funcPtr) => {
|
|
840
|
+
var func = wasmTableMirror[funcPtr];
|
|
841
|
+
if (!func) {
|
|
842
|
+
/** @suppress {checkTypes} */
|
|
843
|
+
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
844
|
+
}
|
|
845
|
+
/** @suppress {checkTypes} */
|
|
846
|
+
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
|
|
847
|
+
return func;
|
|
848
|
+
};
|
|
849
|
+
var ___call_sighandler = (fp, sig) => getWasmTableEntry(fp)(sig);
|
|
850
|
+
|
|
851
|
+
var nodePath = require('node:path');
|
|
852
|
+
var PATH = {
|
|
853
|
+
isAbs: nodePath.isAbsolute,
|
|
854
|
+
normalize: nodePath.normalize,
|
|
855
|
+
dirname: nodePath.dirname,
|
|
856
|
+
basename: nodePath.basename,
|
|
857
|
+
join: nodePath.join,
|
|
858
|
+
join2: nodePath.join,
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
var initRandomFill = () => {
|
|
862
|
+
// This block is not needed on v19+ since crypto.getRandomValues is builtin
|
|
863
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
864
|
+
var nodeCrypto = require('node:crypto');
|
|
865
|
+
return (view) => nodeCrypto.randomFillSync(view);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
return (view) => crypto.getRandomValues(view);
|
|
869
|
+
};
|
|
870
|
+
var randomFill = (view) => {
|
|
871
|
+
// Lazily init on the first invocation.
|
|
872
|
+
(randomFill = initRandomFill())(view);
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
/** @type{{resolve: function(...*)}} */
|
|
878
|
+
var PATH_FS = {
|
|
879
|
+
resolve:(...paths) => {
|
|
880
|
+
paths.unshift(FS.cwd());
|
|
881
|
+
return nodePath.posix.resolve(...paths);
|
|
882
|
+
},
|
|
883
|
+
relative:(from, to) => nodePath.posix.relative(from || FS.cwd(), to || FS.cwd()),
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
867
888
|
var FS_stdin_getChar_buffer = [];
|
|
868
889
|
|
|
869
890
|
var lengthBytesUTF8 = (str) => {
|
|
@@ -2118,24 +2139,6 @@ async function createWasm() {
|
|
|
2118
2139
|
|
|
2119
2140
|
|
|
2120
2141
|
|
|
2121
|
-
/**
|
|
2122
|
-
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
2123
|
-
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
2124
|
-
*
|
|
2125
|
-
* @param {number} ptr
|
|
2126
|
-
* @param {number=} maxBytesToRead - An optional length that specifies the
|
|
2127
|
-
* maximum number of bytes to read. You can omit this parameter to scan the
|
|
2128
|
-
* string until the first 0 byte. If maxBytesToRead is passed, and the string
|
|
2129
|
-
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
|
|
2130
|
-
* string will cut short at that byte index.
|
|
2131
|
-
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
2132
|
-
* @return {string}
|
|
2133
|
-
*/
|
|
2134
|
-
var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => {
|
|
2135
|
-
assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
|
|
2136
|
-
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : '';
|
|
2137
|
-
};
|
|
2138
|
-
|
|
2139
2142
|
var strError = (errno) => UTF8ToString(_strerror(errno));
|
|
2140
2143
|
|
|
2141
2144
|
|
|
@@ -5936,20 +5939,22 @@ function checkIncomingModuleAPI() {
|
|
|
5936
5939
|
ignoredModuleProp('loadSplitModule');
|
|
5937
5940
|
}
|
|
5938
5941
|
var ASM_CONSTS = {
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5942
|
+
2633744: ($0) => { globalThis.picorubyRefs[$0] = null; },
|
|
5943
|
+
2633784: ($0) => { globalThis.picorubyRefs[$0] = true; },
|
|
5944
|
+
2633824: ($0) => { globalThis.picorubyRefs[$0] = false; },
|
|
5945
|
+
2633865: ($0, $1) => { globalThis.picorubyRefs[$0] = $1; },
|
|
5946
|
+
2633903: ($0, $1) => { globalThis.picorubyRefs[$0] = $1; },
|
|
5947
|
+
2633941: ($0, $1, $2) => { const str = UTF8ToString($1, $2); globalThis.picorubyRefs[$0] = str; },
|
|
5948
|
+
2634014: ($0, $1) => { const arr = globalThis.picorubyRefs[$0]; const elem = globalThis.picorubyRefs[$1]; arr.push(elem); delete globalThis.picorubyRefs[$1]; },
|
|
5949
|
+
2634153: ($0, $1, $2) => { const obj = globalThis.picorubyRefs[$0]; const key = UTF8ToString($1); const val = globalThis.picorubyRefs[$2]; obj[key] = val; delete globalThis.picorubyRefs[$2]; }
|
|
5947
5950
|
};
|
|
5948
5951
|
function ble_dataview_length(ref_id) { try { const dv = globalThis.picorubyRefs[ref_id]; if (dv && dv.byteLength !== undefined) { return dv.byteLength; } return 0; } catch(e) { console.error('ble_dataview_length failed:', e); return 0; } }
|
|
5949
5952
|
function ble_dataview_read(ref_id,out_buf,max_len) { try { const dv = globalThis.picorubyRefs[ref_id]; if (!dv) return 0; const len = Math.min(dv.byteLength, max_len); for (let i = 0; i < len; i++) { HEAPU8[out_buf + i] = dv.getUint8(i); } return len; } catch(e) { console.error('ble_dataview_read failed:', e); return 0; } }
|
|
5950
5953
|
function ble_create_uint8array(data,length) { try { const buffer = new Uint8Array(HEAPU8.buffer, data, length); const copy = new Uint8Array(buffer); const refId = globalThis.picorubyRefs.push(copy) - 1; return refId; } catch(e) { console.error('ble_create_uint8array failed:', e); return -1; } }
|
|
5951
5954
|
function ble_set_notify_handler(char_ref_id,callback_id) { try { const char_obj = globalThis.picorubyRefs[char_ref_id]; char_obj.addEventListener('characteristicvaluechanged', (event) => { const dataview = event.target.value; const len = dataview.byteLength; const ptr = _malloc(len); for (let i = 0; i < len; i++) { HEAPU8[ptr + i] = dataview.getUint8(i); } ccall( 'ble_notify_callback', 'void', ['number', 'number', 'number'], [callback_id, ptr, len] ); _free(ptr); }); } catch(e) { console.error('ble_set_notify_handler failed:', e); } }
|
|
5952
5955
|
function init_js_refs() { if (typeof globalThis.picorubyRefs === 'undefined') { globalThis.picorubyRefs = []; const rootObject = typeof window !== 'undefined' ? window : globalThis; globalThis.picorubyRefs.push(rootObject); } if (typeof window !== 'undefined' && typeof window._js_remove_event_listener_wrapper === 'undefined') { window._js_remove_event_listener_wrapper = function(callback_id) { if (!globalThis.picorubyEventHandlers) return false; const info = globalThis.picorubyEventHandlers[callback_id]; if (!info) return false; info.target.removeEventListener(info.type, info.handler); delete globalThis.picorubyEventHandlers[callback_id]; return true; }; } }
|
|
5956
|
+
function js_last_error_length() { const message = globalThis.picorubyLastError; return message ? lengthBytesUTF8(message) : 0; }
|
|
5957
|
+
function js_copy_last_error(buffer,buffer_size) { const message = globalThis.picorubyLastError; if (!message) { globalThis.picorubyLastError = null; return; } stringToUTF8(message, buffer, buffer_size); globalThis.picorubyLastError = null; }
|
|
5953
5958
|
function is_array_like(ref_id) { const obj = globalThis.picorubyRefs[ref_id]; const isNodeList = typeof NodeList !== 'undefined' && obj instanceof NodeList; const isHTMLCollection = typeof HTMLCollection !== 'undefined' && obj instanceof HTMLCollection; return isNodeList || isHTMLCollection || (typeof obj === 'object' && obj !== null && 'length' in obj && typeof obj.length === 'number'); }
|
|
5954
5959
|
function get_element(ref_id,index) { try { const nodeList = globalThis.picorubyRefs[ref_id]; const element = nodeList[index]; if (element === undefined) { return -1; } const newRefId = globalThis.picorubyRefs.push(element) - 1; return newRefId; } catch(e) { return -1; } }
|
|
5955
5960
|
function set_property(ref_id,key,value,value_len) { try { if (!globalThis.picorubyRefs || ref_id >= globalThis.picorubyRefs.length) { console.error('Invalid reference ID:', ref_id); return false; } const obj = globalThis.picorubyRefs[ref_id]; if (!obj) { console.error('Object not found for ref_id:', ref_id); return false; } const property = UTF8ToString(key); const val = UTF8ToString(value, value_len); obj[property] = val; return true; } catch(e) { console.error('Error in set_property:', e); return false; } }
|
|
@@ -5968,19 +5973,19 @@ function get_number_value(ref_id) { return globalThis.picorubyRefs[ref_id]; }
|
|
|
5968
5973
|
function get_string_value_length(ref_id) { const str = globalThis.picorubyRefs[ref_id]; return lengthBytesUTF8(str); }
|
|
5969
5974
|
function copy_string_value(ref_id,buffer,buffer_size) { const str = globalThis.picorubyRefs[ref_id]; stringToUTF8(str, buffer, buffer_size); }
|
|
5970
5975
|
function get_length(ref_id) { try { const obj = globalThis.picorubyRefs[ref_id]; return obj.length || 0; } catch(e) { return -1; } }
|
|
5971
|
-
function call_method(ref_id,method,arg,arg_len) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argString = UTF8ToString(arg, arg_len); let result; if (methodName === 'new') { result = new obj(argString); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argString); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5972
|
-
function call_method_no_arg(ref_id,method) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } let result = func.call(obj); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5973
|
-
function call_method_no_return(ref_id,method) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; if (typeof func === 'function') { func.call(obj); } } catch(e) {
|
|
5974
|
-
function call_method_int(ref_id,method,arg) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; let result; if (methodName === 'new') { result = new obj(arg); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, arg); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5975
|
-
function call_method_str(ref_id,method,arg1,arg1_len,arg2,arg2_len) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argString1 = UTF8ToString(arg1, arg1_len); const argString2 = UTF8ToString(arg2, arg2_len); let result; if (methodName === 'new') { result = new obj(argString1, argString2); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argString1, argString2); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5976
|
-
function call_method_with_ref(ref_id,method,arg_ref_id) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argObj = globalThis.picorubyRefs[arg_ref_id]; let result; if (methodName === 'new') { result = new obj(argObj); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argObj); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5977
|
-
function call_method_with_ref_ref(ref_id,method,arg_ref_1_id,arg_ref_2_id) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argObj1 = globalThis.picorubyRefs[arg_ref_1_id]; const argObj2 = globalThis.picorubyRefs[arg_ref_2_id]; let result; if (methodName === 'new') { result = new obj(argObj1, argObj2); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argObj1, argObj2); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5978
|
-
function call_method_with_ref_str_str(ref_id,method,arg1_ref_id,arg2_str,arg2_len,arg3_str,arg3_len) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argObj1 = globalThis.picorubyRefs[arg1_ref_id]; const argString2 = UTF8ToString(arg2_str, arg2_len); const argString3 = UTF8ToString(arg3_str, arg3_len); if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } let result = func.call(obj, argObj1, argString2, argString3); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5979
|
-
function call_method_with_args(ref_id,method,args_json,args_json_len) { try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } const argsStr = UTF8ToString(args_json, args_json_len); const argsData = JSON.parse(argsStr); if (!Array.isArray(argsData)) { console.error('args_json must be a JSON array'); return -1; } const args = argsData.map(arg => { switch (arg.type) { case 'string': return arg.value; case 'integer': return arg.value; case 'float': return arg.value; case 'boolean': return arg.value; case 'ref': return globalThis.picorubyRefs[arg.value]; case 'nil': return null; default: console.error('Unknown argument type:', arg.type); return null; } }); const result = func.call(obj, ...args); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5980
|
-
function call_constructor_with_args(ref_id,args_json,args_json_len) { try { const ctor = globalThis.picorubyRefs[ref_id]; if (typeof ctor !== 'function') { console.error('Object is not a constructor function'); return -1; } const argsStr = UTF8ToString(args_json, args_json_len); const argsData = JSON.parse(argsStr); if (!Array.isArray(argsData)) { console.error('args_json must be a JSON array'); return -1; } const args = argsData.map(arg => { switch (arg.type) { case 'string': return arg.value; case 'integer': return arg.value; case 'float': return arg.value; case 'boolean': return arg.value; case 'ref': return globalThis.picorubyRefs[arg.value]; case 'nil': return null; default: console.error('Unknown argument type:', arg.type); return null; } }); const result = new ctor(...args); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5981
|
-
function js_function_apply_args(func_ref_id,args_json,args_json_len) { try { const fn = globalThis.picorubyRefs[func_ref_id]; if (typeof fn !== 'function') { console.error('js_function_apply_args: not a function'); return -1; } const argsData = JSON.parse(UTF8ToString(args_json, args_json_len)); if (!Array.isArray(argsData)) { console.error('js_function_apply_args: args_json must be a JSON array'); return -1; } const args = argsData.map(arg => { switch (arg.type) { case 'string': case 'integer': case 'float': case 'boolean': return arg.value; case 'ref': return globalThis.picorubyRefs[arg.value]; case 'nil': return null; default: return null; } }); const result = fn(...args); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5982
|
-
function call_fetch_with_json_options(ref_id,url,options_json) { try { const obj = globalThis.picorubyRefs[ref_id]; const urlStr = UTF8ToString(url); const optionsStr = UTF8ToString(options_json); const options = JSON.parse(optionsStr); const result = obj.fetch(urlStr, options); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) {
|
|
5983
|
-
function setup_promise_handler(promise_id,callback_id,mrb_ptr,task_ptr) { const promise = globalThis.picorubyRefs[promise_id]; promise.then( (result) => { const resultId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); ccall( 'resume_promise_task', 'void', ['number', 'number', 'number', 'number'], [mrb_ptr, task_ptr, callback_id, resultId] ); } ); }
|
|
5976
|
+
function call_method(ref_id,method,arg,arg_len) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argString = UTF8ToString(arg, arg_len); let result; if (methodName === 'new') { result = new obj(argString); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argString); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5977
|
+
function call_method_no_arg(ref_id,method) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } let result = func.call(obj); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5978
|
+
function call_method_no_return(ref_id,method) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; if (typeof func === 'function') { func.call(obj); } } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); } }
|
|
5979
|
+
function call_method_int(ref_id,method,arg) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; let result; if (methodName === 'new') { result = new obj(arg); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, arg); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5980
|
+
function call_method_str(ref_id,method,arg1,arg1_len,arg2,arg2_len) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argString1 = UTF8ToString(arg1, arg1_len); const argString2 = UTF8ToString(arg2, arg2_len); let result; if (methodName === 'new') { result = new obj(argString1, argString2); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argString1, argString2); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5981
|
+
function call_method_with_ref(ref_id,method,arg_ref_id) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argObj = globalThis.picorubyRefs[arg_ref_id]; let result; if (methodName === 'new') { result = new obj(argObj); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argObj); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5982
|
+
function call_method_with_ref_ref(ref_id,method,arg_ref_1_id,arg_ref_2_id) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argObj1 = globalThis.picorubyRefs[arg_ref_1_id]; const argObj2 = globalThis.picorubyRefs[arg_ref_2_id]; let result; if (methodName === 'new') { result = new obj(argObj1, argObj2); } else { if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } result = func.call(obj, argObj1, argObj2); } const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5983
|
+
function call_method_with_ref_str_str(ref_id,method,arg1_ref_id,arg2_str,arg2_len,arg3_str,arg3_len) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; const argObj1 = globalThis.picorubyRefs[arg1_ref_id]; const argString2 = UTF8ToString(arg2_str, arg2_len); const argString3 = UTF8ToString(arg3_str, arg3_len); if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } let result = func.call(obj, argObj1, argString2, argString3); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5984
|
+
function call_method_with_args(ref_id,method,args_json,args_json_len) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const methodName = UTF8ToString(method); const func = obj[methodName]; if (typeof func !== 'function') { console.error('Method not found or not a function:', methodName); return -1; } const argsStr = UTF8ToString(args_json, args_json_len); const argsData = JSON.parse(argsStr); if (!Array.isArray(argsData)) { console.error('args_json must be a JSON array'); return -1; } const args = argsData.map(arg => { switch (arg.type) { case 'string': return arg.value; case 'integer': return arg.value; case 'float': return arg.value; case 'boolean': return arg.value; case 'ref': return globalThis.picorubyRefs[arg.value]; case 'nil': return null; default: console.error('Unknown argument type:', arg.type); return null; } }); const result = func.call(obj, ...args); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5985
|
+
function call_constructor_with_args(ref_id,args_json,args_json_len) { globalThis.picorubyLastError = null; try { const ctor = globalThis.picorubyRefs[ref_id]; if (typeof ctor !== 'function') { console.error('Object is not a constructor function'); return -1; } const argsStr = UTF8ToString(args_json, args_json_len); const argsData = JSON.parse(argsStr); if (!Array.isArray(argsData)) { console.error('args_json must be a JSON array'); return -1; } const args = argsData.map(arg => { switch (arg.type) { case 'string': return arg.value; case 'integer': return arg.value; case 'float': return arg.value; case 'boolean': return arg.value; case 'ref': return globalThis.picorubyRefs[arg.value]; case 'nil': return null; default: console.error('Unknown argument type:', arg.type); return null; } }); const result = new ctor(...args); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5986
|
+
function js_function_apply_args(func_ref_id,args_json,args_json_len) { globalThis.picorubyLastError = null; try { const fn = globalThis.picorubyRefs[func_ref_id]; if (typeof fn !== 'function') { console.error('js_function_apply_args: not a function'); return -1; } const argsData = JSON.parse(UTF8ToString(args_json, args_json_len)); if (!Array.isArray(argsData)) { console.error('js_function_apply_args: args_json must be a JSON array'); return -1; } const args = argsData.map(arg => { switch (arg.type) { case 'string': case 'integer': case 'float': case 'boolean': return arg.value; case 'ref': return globalThis.picorubyRefs[arg.value]; case 'nil': return null; default: return null; } }); const result = fn(...args); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5987
|
+
function call_fetch_with_json_options(ref_id,url,options_json) { globalThis.picorubyLastError = null; try { const obj = globalThis.picorubyRefs[ref_id]; const urlStr = UTF8ToString(url); const optionsStr = UTF8ToString(options_json); const options = JSON.parse(optionsStr); const result = obj.fetch(urlStr, options); const newRefId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); return newRefId; } catch(e) { globalThis.picorubyLastError = e && typeof e.message === 'string' ? e.message : String(e); return -1; } }
|
|
5988
|
+
function setup_promise_handler(promise_id,callback_id,mrb_ptr,task_ptr) { const promise = globalThis.picorubyRefs[promise_id]; promise.then( (result) => { const resultId = globalThis.picorubyRefs.length; globalThis.picorubyRefs.push(result); ccall( 'resume_promise_task', 'void', ['number', 'number', 'number', 'number'], [mrb_ptr, task_ptr, callback_id, resultId] ); } ).catch( (error) => { const message = error && typeof error.message === 'string' ? error.message : String(error); const size = lengthBytesUTF8(message) + 1; const errorPtr = _malloc(size); stringToUTF8(message, errorPtr, size); ccall( 'resume_promise_error_task', 'void', ['number', 'number', 'number', 'number'], [mrb_ptr, task_ptr, callback_id, errorPtr] ); } ); }
|
|
5984
5989
|
function js_add_event_listener(ref_id,callback_id,event_type) { const target = globalThis.picorubyRefs[ref_id]; const type = UTF8ToString(event_type); const handler = (event) => { if (!globalThis.picorubyEventHandlers || !globalThis.picorubyEventHandlers[callback_id]) { return; } if (type === 'submit' || (type === 'click' && target.tagName === 'A')) { event.preventDefault(); } const eventRefId = globalThis.picorubyRefs.push(event) - 1; ccall( 'call_ruby_callback', 'void', ['number', 'number'], [callback_id, eventRefId] ); }; target.addEventListener(type, handler); if (!globalThis.picorubyEventHandlers) { globalThis.picorubyEventHandlers = {}; } globalThis.picorubyEventHandlers[callback_id] = { target, type, handler }; }
|
|
5985
5990
|
function js_register_generic_callback(callback_id,callback_name) { const name = UTF8ToString(callback_name); if (!globalThis.picorubyGenericCallbacks) { globalThis.picorubyGenericCallbacks = {}; } globalThis.picorubyGenericCallbacks[name] = function(...args) { const argRefIds = args.map(arg => { const refId = globalThis.picorubyRefs.push(arg) - 1; return refId; }); const argRefIdsPtr = _malloc(argRefIds.length * 4); for (let i = 0; i < argRefIds.length; i++) { HEAP32[(argRefIdsPtr >> 2) + i] = argRefIds[i]; } const resultRefId = ccall( 'call_ruby_callback_sync_generic', 'number', ['number', 'number', 'number'], [callback_id, argRefIdsPtr, argRefIds.length] ); _free(argRefIdsPtr); if (resultRefId >= 0 && resultRefId < globalThis.picorubyRefs.length) { return globalThis.picorubyRefs[resultRefId]; } return undefined; }; }
|
|
5986
5991
|
function js_create_callback_function(callback_id) { try { const fn = function(...args) { const argRefIds = args.map(arg => globalThis.picorubyRefs.push(arg) - 1); const argRefIdsPtr = _malloc(argRefIds.length * 4); for (let i = 0; i < argRefIds.length; i++) { HEAP32[(argRefIdsPtr >> 2) + i] = argRefIds[i]; } const resultRefId = ccall( 'call_ruby_callback_sync_generic', 'number', ['number', 'number', 'number'], [callback_id, argRefIdsPtr, argRefIds.length] ); _free(argRefIdsPtr); if (resultRefId >= 0 && resultRefId < globalThis.picorubyRefs.length) { return globalThis.picorubyRefs[resultRefId]; } return undefined; }; return globalThis.picorubyRefs.push(fn) - 1; } catch (e) { console.error('js_create_callback_function failed:', e); return -1; } }
|
|
@@ -6043,6 +6048,9 @@ function ws_set_onmessage(ref_id,callback_id) { const ws = globalThis.picorubyRe
|
|
|
6043
6048
|
function ws_set_onerror(ref_id,callback_id) { const ws = globalThis.picorubyRefs[ref_id]; ws.onerror = (event) => { const eventRefId = globalThis.picorubyRefs.push(event) - 1; ccall( 'call_ruby_callback_oneshot', 'void', ['number', 'number'], [callback_id, eventRefId] ); }; }
|
|
6044
6049
|
function ws_set_onclose(ref_id,callback_id) { const ws = globalThis.picorubyRefs[ref_id]; ws.onclose = (event) => { const eventRefId = globalThis.picorubyRefs.push(event) - 1; ccall( 'call_ruby_callback_oneshot', 'void', ['number', 'number'], [callback_id, eventRefId] ); }; }
|
|
6045
6050
|
function emscripten_date_now() { return Date.now(); }
|
|
6051
|
+
function idb_request_to_promise(req_ref_id) { try { const req = globalThis.picorubyRefs[req_ref_id]; if (!req) { console.error('idb_request_to_promise: invalid ref_id', req_ref_id); return -1; } const promise = new Promise((resolve, reject) => { req.onsuccess = () => { resolve(req.result); }; req.onerror = () => { const msg = (req.error && req.error.message) || 'IDB request failed'; reject(new Error(msg)); }; }); return globalThis.picorubyRefs.push(promise) - 1; } catch (e) { console.error('idb_request_to_promise failed:', e); return -1; } }
|
|
6052
|
+
function idb_open_with_upgrade(name_ptr,version,callback_id) { try { const name = UTF8ToString(name_ptr); const idb = globalThis.indexedDB; if (!idb) { console.error('idb_open_with_upgrade: indexedDB unavailable'); return -1; } const req = (version > 0) ? idb.open(name, version) : idb.open(name); req.onupgradeneeded = (event) => { if (callback_id === 0) return; const db = req.result; const oldV = event.oldVersion; const newV = event.newVersion; const dbRef = globalThis.picorubyRefs.push(db) - 1; const oldRef = globalThis.picorubyRefs.push(oldV) - 1; const newRef = globalThis.picorubyRefs.push(newV) - 1; const argRefIds = [dbRef, oldRef, newRef]; const argRefIdsPtr = _malloc(argRefIds.length * 4); for (let i = 0; i < argRefIds.length; i++) { HEAP32[(argRefIdsPtr >> 2) + i] = argRefIds[i]; } try { ccall( 'call_ruby_callback_sync_generic', 'number', ['number', 'number', 'number'], [callback_id, argRefIdsPtr, argRefIds.length] ); } catch (e) { console.error('idb upgrade callback threw:', e); } finally { _free(argRefIdsPtr); } }; const promise = new Promise((resolve, reject) => { req.onsuccess = () => { resolve(req.result); }; req.onerror = () => { const msg = (req.error && req.error.message) || 'IDB open failed'; reject(new Error(msg)); }; req.onblocked = () => { reject(new Error('IDB open blocked: another connection holds an older version')); }; }); return globalThis.picorubyRefs.push(promise) - 1; } catch (e) { console.error('idb_open_with_upgrade failed:', e); return -1; } }
|
|
6053
|
+
function idb_transaction_to_promise(tx_ref_id) { try { const tx = globalThis.picorubyRefs[tx_ref_id]; if (!tx) { console.error('idb_transaction_to_promise: invalid ref_id', tx_ref_id); return -1; } const promise = new Promise((resolve, reject) => { tx.oncomplete = () => { resolve(true); }; tx.onerror = () => { const msg = (tx.error && tx.error.message) || 'IDB transaction error'; reject(new Error(msg)); }; tx.onabort = () => { const msg = (tx.error && tx.error.message) || 'IDB transaction aborted'; reject(new Error(msg)); }; }); return globalThis.picorubyRefs.push(promise) - 1; } catch (e) { console.error('idb_transaction_to_promise failed:', e); return -1; } }
|
|
6046
6054
|
|
|
6047
6055
|
// Imports from the Wasm binary.
|
|
6048
6056
|
var _ble_notify_callback = Module['_ble_notify_callback'] = makeInvalidEarlyAccess('_ble_notify_callback');
|
|
@@ -6060,6 +6068,7 @@ var _mrb_debug_get_callstack = Module['_mrb_debug_get_callstack'] = makeInvalidE
|
|
|
6060
6068
|
var _call_ruby_callback = Module['_call_ruby_callback'] = makeInvalidEarlyAccess('_call_ruby_callback');
|
|
6061
6069
|
var _call_ruby_callback_oneshot = Module['_call_ruby_callback_oneshot'] = makeInvalidEarlyAccess('_call_ruby_callback_oneshot');
|
|
6062
6070
|
var _resume_promise_task = Module['_resume_promise_task'] = makeInvalidEarlyAccess('_resume_promise_task');
|
|
6071
|
+
var _resume_promise_error_task = Module['_resume_promise_error_task'] = makeInvalidEarlyAccess('_resume_promise_error_task');
|
|
6063
6072
|
var _resume_binary_task = Module['_resume_binary_task'] = makeInvalidEarlyAccess('_resume_binary_task');
|
|
6064
6073
|
var _call_ruby_callback_sync_generic = Module['_call_ruby_callback_sync_generic'] = makeInvalidEarlyAccess('_call_ruby_callback_sync_generic');
|
|
6065
6074
|
var _mrb_tick_wasm = Module['_mrb_tick_wasm'] = makeInvalidEarlyAccess('_mrb_tick_wasm');
|
|
@@ -6105,6 +6114,7 @@ function assignWasmExports(wasmExports) {
|
|
|
6105
6114
|
assert(typeof wasmExports['call_ruby_callback'] != 'undefined', 'missing Wasm export: call_ruby_callback');
|
|
6106
6115
|
assert(typeof wasmExports['call_ruby_callback_oneshot'] != 'undefined', 'missing Wasm export: call_ruby_callback_oneshot');
|
|
6107
6116
|
assert(typeof wasmExports['resume_promise_task'] != 'undefined', 'missing Wasm export: resume_promise_task');
|
|
6117
|
+
assert(typeof wasmExports['resume_promise_error_task'] != 'undefined', 'missing Wasm export: resume_promise_error_task');
|
|
6108
6118
|
assert(typeof wasmExports['resume_binary_task'] != 'undefined', 'missing Wasm export: resume_binary_task');
|
|
6109
6119
|
assert(typeof wasmExports['call_ruby_callback_sync_generic'] != 'undefined', 'missing Wasm export: call_ruby_callback_sync_generic');
|
|
6110
6120
|
assert(typeof wasmExports['mrb_tick_wasm'] != 'undefined', 'missing Wasm export: mrb_tick_wasm');
|
|
@@ -6146,6 +6156,7 @@ function assignWasmExports(wasmExports) {
|
|
|
6146
6156
|
_call_ruby_callback = Module['_call_ruby_callback'] = createExportWrapper('call_ruby_callback', 2);
|
|
6147
6157
|
_call_ruby_callback_oneshot = Module['_call_ruby_callback_oneshot'] = createExportWrapper('call_ruby_callback_oneshot', 2);
|
|
6148
6158
|
_resume_promise_task = Module['_resume_promise_task'] = createExportWrapper('resume_promise_task', 4);
|
|
6159
|
+
_resume_promise_error_task = Module['_resume_promise_error_task'] = createExportWrapper('resume_promise_error_task', 4);
|
|
6149
6160
|
_resume_binary_task = Module['_resume_binary_task'] = createExportWrapper('resume_binary_task', 5);
|
|
6150
6161
|
_call_ruby_callback_sync_generic = Module['_call_ruby_callback_sync_generic'] = createExportWrapper('call_ruby_callback_sync_generic', 3);
|
|
6151
6162
|
_mrb_tick_wasm = Module['_mrb_tick_wasm'] = createExportWrapper('mrb_tick_wasm', 0);
|
|
@@ -6175,6 +6186,8 @@ function assignWasmExports(wasmExports) {
|
|
|
6175
6186
|
}
|
|
6176
6187
|
|
|
6177
6188
|
var wasmImports = {
|
|
6189
|
+
/** @export */
|
|
6190
|
+
__assert_fail: ___assert_fail,
|
|
6178
6191
|
/** @export */
|
|
6179
6192
|
__call_sighandler: ___call_sighandler,
|
|
6180
6193
|
/** @export */
|
|
@@ -6318,6 +6331,12 @@ var wasmImports = {
|
|
|
6318
6331
|
/** @export */
|
|
6319
6332
|
get_string_value_length,
|
|
6320
6333
|
/** @export */
|
|
6334
|
+
idb_open_with_upgrade,
|
|
6335
|
+
/** @export */
|
|
6336
|
+
idb_request_to_promise,
|
|
6337
|
+
/** @export */
|
|
6338
|
+
idb_transaction_to_promise,
|
|
6339
|
+
/** @export */
|
|
6321
6340
|
init_js_refs,
|
|
6322
6341
|
/** @export */
|
|
6323
6342
|
init_js_type_offsets,
|
|
@@ -6372,6 +6391,8 @@ var wasmImports = {
|
|
|
6372
6391
|
/** @export */
|
|
6373
6392
|
js_clear_timeout,
|
|
6374
6393
|
/** @export */
|
|
6394
|
+
js_copy_last_error,
|
|
6395
|
+
/** @export */
|
|
6375
6396
|
js_create_array,
|
|
6376
6397
|
/** @export */
|
|
6377
6398
|
js_create_callback_function,
|
|
@@ -6392,6 +6413,8 @@ var wasmImports = {
|
|
|
6392
6413
|
/** @export */
|
|
6393
6414
|
js_inspect_to_buffer,
|
|
6394
6415
|
/** @export */
|
|
6416
|
+
js_last_error_length,
|
|
6417
|
+
/** @export */
|
|
6395
6418
|
js_register_generic_callback,
|
|
6396
6419
|
/** @export */
|
|
6397
6420
|
js_remove_attribute,
|
|
Binary file
|