@makano/rew 1.2.59 → 1.2.62

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.
@@ -304,6 +304,14 @@ class Page extends Node {
304
304
  el.style.setProperty(i, value[i]);
305
305
  }
306
306
  return;
307
+ } else if(key.startsWith('on')){
308
+ if(!el.listeners) el.listeners = [];
309
+ if(el.listeners.includes(value)) return;
310
+ el.listeners.push(value);
311
+ el.addEventListener(key.replace('on', '').toLowerCase(), (event) => {
312
+ new Function('event', value).call(event.target, event);
313
+ });
314
+ return;
307
315
  }
308
316
  el.setAttribute(key, defVal);
309
317
  }
@@ -443,9 +451,9 @@ module.exports = (context, importOptions) => {
443
451
  state(value) {
444
452
  return new State(value);
445
453
  }
446
- useState(states, callback){
447
- const statesMapped = states.map(i => `getState('${i.id}')`);
448
- return `((${callback})(...[${statesMapped}]))`;
454
+ invokeState(states, callback){
455
+ const statesMapped = states.map(i => i instanceof State ? `getState('${i.id}')` : (typeof i == "function" ? i.toString() : JSON.stringify(i)));
456
+ return `((${callback})(event, ...[${statesMapped}]))`;
449
457
  }
450
458
  async bundle(filepath, options = {}) {
451
459
  const virtualModuleId = `virtual:${filepath}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.59",
3
+ "version": "1.2.62",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {
package/runtime.d.ts CHANGED
@@ -492,7 +492,7 @@ declare class ModuleWeb {
492
492
 
493
493
  state(value): ModuleWebState | any;
494
494
  // @ts-ignore
495
- useState(states: State[], callback: CallableFunction): any;
495
+ invokeState(states: State[], callback: CallableFunction): any;
496
496
 
497
497
  bundle(filePath: string, options?: Record<string, any>): string;
498
498
  }