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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa8a7ba40464c4e28ecc1b784612a9a62a8a88af985efd2508f142e03443fe9a
|
|
4
|
+
data.tar.gz: a81683de0aa13f2d91f21ccbddf6b8ed802f673567591adee4b12de6d0453d91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2809132d4fc00812c2443c2fb42e6744bbb25449beee2cb03c2b6cd2302792da21ba7d6a98ac462f7bcdc10b17af87988fa8fb38e635fa747d3bbba1e346c60
|
|
7
|
+
data.tar.gz: df0f03841a9f97ab6269f088be4b16a488430419cf7b5d196615488d098d149c6241bc08f495b477f3f539a72df13725412be09768fb90c3d96560677c9e2390
|
data/README.md
CHANGED
|
@@ -57,22 +57,22 @@ The others are common resources.
|
|
|
57
57
|
|
|
58
58
|
User documentation is hosted on **picoruby.org**:
|
|
59
59
|
|
|
60
|
-
- [Getting Started with Funicular](https://picoruby.org/funicular
|
|
61
|
-
- [Funicular on Rails](https://picoruby.org/funicular-on-rails) — installation, the asset pipeline, and a feature-by-feature tutorial plus reference (components, routing, forms, data fetching, stores,
|
|
60
|
+
- [Getting Started with Funicular](https://picoruby.org/funicular) — a standalone, no-Rails tutorial
|
|
61
|
+
- [Funicular on Rails](https://picoruby.org/funicular-on-rails-quick-chat) — quick tutorial, installation, the asset pipeline, and a feature-by-feature tutorial plus reference (components, routing, forms and validation, data fetching, stores, SSR, styling, debugging)
|
|
62
62
|
|
|
63
63
|
For contributors working on the gem itself, see [docs/architecture.md](docs/architecture.md).
|
|
64
64
|
|
|
65
65
|
## Development
|
|
66
66
|
|
|
67
67
|
This repository is a submodule of [picoruby/picoruby](https://github.com/picoruby/picoruby).
|
|
68
|
-
Do not check it out standalone. Instead, clone the parent repository and work from there:
|
|
68
|
+
Do not check it out as a standalone. Instead, clone the parent repository and work from there:
|
|
69
69
|
|
|
70
70
|
```console
|
|
71
71
|
git clone --recurse-submodules https://github.com/picoruby/picoruby.git
|
|
72
72
|
cd picoruby/mrbgems/picoruby-funicular
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
The CRubyGem side (`lib/`, `funicular.gemspec`, etc.) can be developed and tested independently inside that directory, but `rake copy_wasm` — which
|
|
75
|
+
The CRubyGem side (`lib/`, `funicular.gemspec`, etc.) can be developed and tested independently inside that directory, but `rake copy_wasm` — which vendors the PicoRuby.wasm and picorbc wasm artifacts into the gem — relies on sibling directories within the picoruby repository (`mrbgems/picoruby-wasm/npm/`).
|
|
76
76
|
Running it from a standalone checkout will fail.
|
|
77
77
|
|
|
78
78
|
## Testing
|
data/lib/funicular/compiler.rb
CHANGED
|
@@ -88,6 +88,8 @@ module Funicular
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
# Create a small temp file for ENV setting
|
|
91
|
+
output_dir = File.dirname(output_file)
|
|
92
|
+
FileUtils.mkdir_p(output_dir) unless Dir.exist?(output_dir)
|
|
91
93
|
env_file = "#{output_file}.env.rb"
|
|
92
94
|
File.open(env_file, "w") do |f|
|
|
93
95
|
f.puts "ENV['FUNICULAR_ENV'] = '#{Rails.env}'"
|
|
@@ -106,9 +108,6 @@ module Funicular
|
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
def compile_to_mrb
|
|
109
|
-
output_dir = File.dirname(output_file)
|
|
110
|
-
FileUtils.mkdir_p(output_dir) unless Dir.exist?(output_dir)
|
|
111
|
-
|
|
112
111
|
all_files = @source_files.dup
|
|
113
112
|
all_files << @env_file if @env_file
|
|
114
113
|
argv = [node_command, PICORBC_JS]
|
|
Binary file
|
|
@@ -5411,20 +5411,22 @@ function checkIncomingModuleAPI() {
|
|
|
5411
5411
|
ignoredModuleProp('loadSplitModule');
|
|
5412
5412
|
}
|
|
5413
5413
|
var ASM_CONSTS = {
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5414
|
+
2639196: ($0) => { globalThis.picorubyRefs[$0] = null; },
|
|
5415
|
+
2639236: ($0) => { globalThis.picorubyRefs[$0] = true; },
|
|
5416
|
+
2639276: ($0) => { globalThis.picorubyRefs[$0] = false; },
|
|
5417
|
+
2639317: ($0, $1) => { globalThis.picorubyRefs[$0] = $1; },
|
|
5418
|
+
2639355: ($0, $1) => { globalThis.picorubyRefs[$0] = $1; },
|
|
5419
|
+
2639393: ($0, $1, $2) => { const str = UTF8ToString($1, $2); globalThis.picorubyRefs[$0] = str; },
|
|
5420
|
+
2639466: ($0, $1) => { const arr = globalThis.picorubyRefs[$0]; const elem = globalThis.picorubyRefs[$1]; arr.push(elem); delete globalThis.picorubyRefs[$1]; },
|
|
5421
|
+
2639605: ($0, $1, $2) => { const obj = globalThis.picorubyRefs[$0]; const key = UTF8ToString($1); const val = globalThis.picorubyRefs[$2]; obj[key] = val; delete globalThis.picorubyRefs[$2]; }
|
|
5422
5422
|
};
|
|
5423
5423
|
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; } }
|
|
5424
5424
|
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; } }
|
|
5425
5425
|
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; } }
|
|
5426
5426
|
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); } }
|
|
5427
5427
|
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; }; } }
|
|
5428
|
+
function js_last_error_length() { const message = globalThis.picorubyLastError; return message ? lengthBytesUTF8(message) : 0; }
|
|
5429
|
+
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; }
|
|
5428
5430
|
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'); }
|
|
5429
5431
|
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; } }
|
|
5430
5432
|
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; } }
|
|
@@ -5443,19 +5445,19 @@ function get_number_value(ref_id) { return globalThis.picorubyRefs[ref_id]; }
|
|
|
5443
5445
|
function get_string_value_length(ref_id) { const str = globalThis.picorubyRefs[ref_id]; return lengthBytesUTF8(str); }
|
|
5444
5446
|
function copy_string_value(ref_id,buffer,buffer_size) { const str = globalThis.picorubyRefs[ref_id]; stringToUTF8(str, buffer, buffer_size); }
|
|
5445
5447
|
function get_length(ref_id) { try { const obj = globalThis.picorubyRefs[ref_id]; return obj.length || 0; } catch(e) { return -1; } }
|
|
5446
|
-
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) {
|
|
5447
|
-
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) {
|
|
5448
|
-
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) {
|
|
5449
|
-
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) {
|
|
5450
|
-
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) {
|
|
5451
|
-
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) {
|
|
5452
|
-
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) {
|
|
5453
|
-
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) {
|
|
5454
|
-
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) {
|
|
5455
|
-
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) {
|
|
5456
|
-
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) {
|
|
5457
|
-
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) {
|
|
5458
|
-
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] ); } ); }
|
|
5448
|
+
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; } }
|
|
5449
|
+
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; } }
|
|
5450
|
+
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); } }
|
|
5451
|
+
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; } }
|
|
5452
|
+
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; } }
|
|
5453
|
+
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; } }
|
|
5454
|
+
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; } }
|
|
5455
|
+
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; } }
|
|
5456
|
+
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; } }
|
|
5457
|
+
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; } }
|
|
5458
|
+
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; } }
|
|
5459
|
+
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; } }
|
|
5460
|
+
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] ); } ); }
|
|
5459
5461
|
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 }; }
|
|
5460
5462
|
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; }; }
|
|
5461
5463
|
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; } }
|
|
@@ -5538,6 +5540,7 @@ var _mrb_debug_get_callstack = Module['_mrb_debug_get_callstack'] = makeInvalidE
|
|
|
5538
5540
|
var _call_ruby_callback = Module['_call_ruby_callback'] = makeInvalidEarlyAccess('_call_ruby_callback');
|
|
5539
5541
|
var _call_ruby_callback_oneshot = Module['_call_ruby_callback_oneshot'] = makeInvalidEarlyAccess('_call_ruby_callback_oneshot');
|
|
5540
5542
|
var _resume_promise_task = Module['_resume_promise_task'] = makeInvalidEarlyAccess('_resume_promise_task');
|
|
5543
|
+
var _resume_promise_error_task = Module['_resume_promise_error_task'] = makeInvalidEarlyAccess('_resume_promise_error_task');
|
|
5541
5544
|
var _resume_binary_task = Module['_resume_binary_task'] = makeInvalidEarlyAccess('_resume_binary_task');
|
|
5542
5545
|
var _call_ruby_callback_sync_generic = Module['_call_ruby_callback_sync_generic'] = makeInvalidEarlyAccess('_call_ruby_callback_sync_generic');
|
|
5543
5546
|
var _mrb_tick_wasm = Module['_mrb_tick_wasm'] = makeInvalidEarlyAccess('_mrb_tick_wasm');
|
|
@@ -5583,6 +5586,7 @@ function assignWasmExports(wasmExports) {
|
|
|
5583
5586
|
assert(typeof wasmExports['call_ruby_callback'] != 'undefined', 'missing Wasm export: call_ruby_callback');
|
|
5584
5587
|
assert(typeof wasmExports['call_ruby_callback_oneshot'] != 'undefined', 'missing Wasm export: call_ruby_callback_oneshot');
|
|
5585
5588
|
assert(typeof wasmExports['resume_promise_task'] != 'undefined', 'missing Wasm export: resume_promise_task');
|
|
5589
|
+
assert(typeof wasmExports['resume_promise_error_task'] != 'undefined', 'missing Wasm export: resume_promise_error_task');
|
|
5586
5590
|
assert(typeof wasmExports['resume_binary_task'] != 'undefined', 'missing Wasm export: resume_binary_task');
|
|
5587
5591
|
assert(typeof wasmExports['call_ruby_callback_sync_generic'] != 'undefined', 'missing Wasm export: call_ruby_callback_sync_generic');
|
|
5588
5592
|
assert(typeof wasmExports['mrb_tick_wasm'] != 'undefined', 'missing Wasm export: mrb_tick_wasm');
|
|
@@ -5624,6 +5628,7 @@ function assignWasmExports(wasmExports) {
|
|
|
5624
5628
|
_call_ruby_callback = Module['_call_ruby_callback'] = createExportWrapper('call_ruby_callback', 2);
|
|
5625
5629
|
_call_ruby_callback_oneshot = Module['_call_ruby_callback_oneshot'] = createExportWrapper('call_ruby_callback_oneshot', 2);
|
|
5626
5630
|
_resume_promise_task = Module['_resume_promise_task'] = createExportWrapper('resume_promise_task', 4);
|
|
5631
|
+
_resume_promise_error_task = Module['_resume_promise_error_task'] = createExportWrapper('resume_promise_error_task', 4);
|
|
5627
5632
|
_resume_binary_task = Module['_resume_binary_task'] = createExportWrapper('resume_binary_task', 5);
|
|
5628
5633
|
_call_ruby_callback_sync_generic = Module['_call_ruby_callback_sync_generic'] = createExportWrapper('call_ruby_callback_sync_generic', 3);
|
|
5629
5634
|
_mrb_tick_wasm = Module['_mrb_tick_wasm'] = createExportWrapper('mrb_tick_wasm', 0);
|
|
@@ -5866,6 +5871,8 @@ var wasmImports = {
|
|
|
5866
5871
|
/** @export */
|
|
5867
5872
|
js_clear_timeout,
|
|
5868
5873
|
/** @export */
|
|
5874
|
+
js_copy_last_error,
|
|
5875
|
+
/** @export */
|
|
5869
5876
|
js_create_array,
|
|
5870
5877
|
/** @export */
|
|
5871
5878
|
js_create_callback_function,
|
|
@@ -5886,6 +5893,8 @@ var wasmImports = {
|
|
|
5886
5893
|
/** @export */
|
|
5887
5894
|
js_inspect_to_buffer,
|
|
5888
5895
|
/** @export */
|
|
5896
|
+
js_last_error_length,
|
|
5897
|
+
/** @export */
|
|
5889
5898
|
js_register_generic_callback,
|
|
5890
5899
|
/** @export */
|
|
5891
5900
|
js_remove_attribute,
|
|
Binary file
|