apprun 3.37.3 → 3.38.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/CHANGELOG.md +6 -0
- package/WHATSNEW.md +6 -0
- package/ai/apprun.prompt.md +545 -109
- package/apprun.d.ts +17 -5
- package/dist/apprun-code.js +1 -1
- package/dist/apprun-code.js.map +1 -1
- package/dist/apprun-dev-tools.js +1 -1
- package/dist/apprun-dev-tools.js.map +1 -1
- package/dist/apprun-html.esm.js +7 -7
- package/dist/apprun-html.esm.js.map +1 -1
- package/dist/apprun-html.js +1 -1
- package/dist/apprun-html.js.map +1 -1
- package/dist/apprun-play-html.esm.js +7 -7
- package/dist/apprun-play-html.esm.js.map +1 -1
- package/dist/apprun-play.js +1 -1
- package/dist/apprun-play.js.map +1 -1
- package/dist/apprun.esm.js +1 -1
- package/dist/apprun.esm.js.map +1 -1
- package/dist/apprun.js +1 -1
- package/dist/apprun.js.map +1 -1
- package/dist/createState.js.map +1 -1
- package/esm/apprun-play.js.map +1 -1
- package/esm/apprun.js.map +1 -1
- package/esm/directive.js +129 -8
- package/esm/directive.js.map +1 -1
- package/esm/version.js +1 -1
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.js.map +1 -1
- package/package.json +1 -1
- package/src/apprun-play.tsx +1 -1
- package/src/apprun.ts +2 -2
- package/src/component.ts +1 -1
- package/src/createState.ts +1 -1
- package/src/directive.ts +132 -7
- package/src/global.d.ts +2 -2
- package/src/types.ts +3 -3
- package/src/version.ts +1 -1
package/dist/apprun-dev-tools.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apprun=t():e.apprun=t()}(this,(()=>(()=>{"use strict";var e={672:(e,t,n)=>{n.d(t,{C:()=>o});const o="AppRun-3.
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apprun=t():e.apprun=t()}(this,(()=>(()=>{"use strict";var e={672:(e,t,n)=>{n.d(t,{C:()=>o});const o="AppRun-3.38.0"},859:(e,t,n)=>{n.d(t,{A:()=>c});var o=n(672);const s=o.C;let r;const l="undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};l.app&&l._AppRunVersions?r=l.app:(r=new class{constructor(){this._events={}}on(e,t,n={}){this._events[e]=this._events[e]||[],this._events[e].push({fn:t,options:n})}off(e,t){const n=this._events[e]||[];this._events[e]=n.filter((e=>e.fn!==t))}find(e){return this._events[e]}run(e,...t){const n=this.getSubscribers(e,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+e),n.forEach((n=>{const{fn:o,options:s}=n;if(!o||"function"!=typeof o)return console.error(`AppRun event handler for '${e}' is not a function:`,o),!1;if(s.delay)this.delay(e,o,t,s);else try{Object.keys(s).length>0?o.apply(this,[...t,s]):o.apply(this,t)}catch(t){console.error(`Error in event handler for '${e}':`,t)}return!n.options.once})),n.length}once(e,t,n={}){this.on(e,t,{...n,once:!0})}delay(e,t,n,o){o._t&&clearTimeout(o._t),o._t=setTimeout((()=>{clearTimeout(o._t);try{Object.keys(o).length>0?t.apply(this,[...n,o]):t.apply(this,n)}catch(t){console.error(`Error in delayed event handler for '${e}':`,t)}}),o.delay)}runAsync(e,...t){const n=this.getSubscribers(e,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+e);const o=n.map((n=>{const{fn:o,options:s}=n;if(!o||"function"!=typeof o)return console.error(`AppRun async event handler for '${e}' is not a function:`,o),Promise.resolve(null);try{return Object.keys(s).length>0?o.apply(this,[...t,s]):o.apply(this,t)}catch(t){return console.error(`Error in async event handler for '${e}':`,t),Promise.reject(t)}}));return Promise.all(o)}query(e,...t){return console.warn("app.query() is deprecated. Use app.runAsync() instead."),this.runAsync(e,...t)}getSubscribers(e,t){const n=t[e]||[];return t[e]=n.filter((e=>!e.options.once)),Object.keys(t).filter((t=>t.endsWith("*")&&e.startsWith(t.replace("*","")))).sort(((e,t)=>t.length-e.length)).forEach((o=>n.push(...t[o].map((t=>({...t,options:{...t.options,event:e}})))))),n}},l.app=r,l._AppRunVersions=s);const c=r}},t={};function n(o){var s=t[o];if(void 0!==s)return s.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o=n(859);function s(e){return e.map((e=>l(e))).join("")}function r(e){for(var t in e)null==e[t]?delete e[t]:"object"==typeof e[t]&&r(e[t])}function l(e){if(!e)return"";if(e._$litType$)return e.toString();if(r(e),Array.isArray(e))return s(e);if("string"==typeof e)return e.startsWith("_html:")?e.substring(6):e;if(e.tag){const t=e.props?function(e){return Object.keys(e).map((t=>{return` ${"className"===t?"class":t}="${n=e[t],"object"==typeof n?Object.keys(n).map((e=>`${e}:${n[e]}`)).join(";"):n.toString()}"`;var n})).join("")}(e.props):"",n=e.children?s(e.children):"";return`<${e.tag}${t}>${n}</${e.tag}>`}return"object"==typeof e?JSON.stringify(e):void 0}const c=l;let i;function a(e){i=window.open("",e),i.document.write(`<html>\n <title>AppRun Analyzer | ${document.location.href}</title>\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI" }\n </style>\n <body><pre>`)}function p(e){i.document.write(e+"\n")}function u(){i.document.write("</pre>\n </body>\n </html>"),i.document.close()}app.debug=!0;const f=e=>{p(`import ${e.constructor.name} from '../src/${e.constructor.name}'`),p(`describe('${e.constructor.name}', ()=>{`),e._actions.forEach((t=>{"."!==t.name&&(p(` it ('should handle event: ${t.name}', (done)=>{`),p(` const component = new ${e.constructor.name}().mount();`),p(` component.run('${t.name}');`),p(" setTimeout(() => {"),p(" //expect(?).toHaveBeenCalled();"),p(" //expect(component.state).toBe(?);"),p(" done();"),p(" })"))})),p("});")};let d=!1,h=[];app.on("debug",(e=>{d&&e.vdom&&(h.push(e),console.log(`* ${h.length} state(s) recorded.`))}));function m(e){const t={get(e,t,n){const o=Reflect.get(e,t,n);return"object"==typeof o&&null!==o?Array.isArray(o)?o.map((e=>m(e))):m(o):`{${t}}`}};return Array.isArray(e)?e.map((e=>m(e))):new Proxy(e,t)}function g(e){let t;if("object"==typeof e.state){const n=m(e.state);t=e.view(n)}else t=e.view(e.state);return t}const y=new Map;function v(e){const t=window.open("","_apprun_debug","toolbar=0");t.document.write(`<html>\n <title>AppRun Analyzer | ${document.location.href}</title>\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI" }\n li { margin-left: 80px; }\n </style>\n <body>\n <div id="main">${e}</div>\n <\/script>\n </body>\n </html>`),t.document.close()}o.A.debug=!0,o.A.on("debug-create-component",(e=>{const t=e.element;t?y.get(t)?y.get(t).push(e):y.set(t,[e]):console.warn("Component created without an element:",e)})),window["_apprun-help"]=["",()=>{Object.keys(window).forEach((e=>{e.startsWith("_apprun-")&&("_apprun-help"===e?console.log("AppRun Commands:"):console.log(`* ${e.substring(8)}: ${window[e][0]}`))}))}];const b=e=>{const t=y,n=[];if(t instanceof Map)for(let[e,o]of t){const t="string"==typeof e?document.getElementById(e)||document.querySelector(e):e;n.push({element:t,comps:o})}if(e){const e=(e=>{const t=({components:e})=>o.A.h("ul",null,e.map((e=>{const t=g(e),n=e._actions.map((e=>e.name)),s={state:e.state,view:t,actions:n,update:e.update};return o.A.h("li",null,o.A.h("div",null,e.constructor.name),o.A.h("div",null,o.A.h("pre",null,(r=JSON.stringify(s,null,2))?r.toString().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"):r)),o.A.h("br",null));var r})));return o.A.h("ul",null,e.map((({element:e,comps:n})=>o.A.h("li",null,o.A.h("div",null,(e=>o.A.h("div",null,e.tagName.toLowerCase(),e.id?"#"+e.id:""," ",e.className&&e.className.split(" ").map((e=>"."+e)).join()))(e)),o.A.h(t,{components:n})))))})(n);v(c(e))}else n.forEach((({element:e,comps:t})=>console.log(e,t)))};let w=Number(window?.localStorage?.getItem("__apprun_debugging__"))||0;if(o.A.on("debug",(e=>{1&w&&e.event&&console.log(e),2&w&&e.vdom&&console.log(e)})),window["_apprun-components"]=["components [print|clear]",e=>{"print"===e?b(!0):"clear"===e?(y.clear(),console.log("Component cache cleared")):b(!1)}],window["_apprun-events"]=["events [print]",e=>{(e=>{const t=o.A._events,n={},s=y,r=e=>e._actions.forEach((t=>{n[t.name]=n[t.name]||[],n[t.name].push(e)}));if(s instanceof Map)for(let[e,t]of s)t.forEach(r);const l=[];if(Object.keys(n).forEach((e=>{l.push({event:e,components:n[e],global:!!t[e]})})),l.sort(((e,t)=>e.event>t.event?1:-1)).map((e=>e.event)),e){const e=(e=>{const t=({components:e})=>o.A.h("ul",null,e.map((e=>o.A.h("li",null,o.A.h("div",null,e.constructor.name))))),n=({events:e,global:n})=>o.A.h("ul",null,e&&e.filter((e=>e.global===n&&"."!==e.event)).map((({event:e,components:n})=>o.A.h("li",null,o.A.h("div",null,e),o.A.h(t,{components:n})))));return o.A.h("div",null,o.A.h("div",null,"GLOBAL EVENTS"),o.A.h(n,{events:e,global:!0}),o.A.h("div",null,"LOCAL EVENTS"),o.A.h(n,{events:e,global:!1}))})(l);v(c(e))}else console.log("=== GLOBAL EVENTS ==="),l.filter((e=>e.global&&"."!==e.event)).forEach((({event:e,components:t})=>console.log({event:e},t))),console.log("=== LOCAL EVENTS ==="),l.filter((e=>!e.global&&"."!==e.event)).forEach((({event:e,components:t})=>console.log({event:e},t)))})("print"===e)}],window["_apprun-log"]=["log [event|view] on|off",(e,t)=>{"on"===e?w=3:"off"===e?w=0:"event"===e?"on"===t?w|=1:"off"===t&&(w&=-2):"view"===e&&("on"===t?w|=2:"off"===t&&(w&=-3)),console.log(`* log ${e} ${t||""}`),window?.localStorage?.setItem("__apprun_debugging__",`${w}`)}],window["_apprun-create-event-tests"]=["create-event-tests",()=>(()=>{const e={components:{}};app.run("get-components",e);const{components:t}=e;if(a(""),t instanceof Map)for(let[e,n]of t)n.forEach(f);else Object.keys(t).forEach((e=>{t[e].forEach(f)}));u()})()],window["_apprun-create-state-tests"]=["create-state-tests <start|stop>",e=>{var t;"start"===(t=e)?(h=[],d=!0,console.log("* State logging started.")):"stop"===t?(0!==h.length?(a(""),h.forEach(((e,t)=>{p(` it ('view snapshot: #${t+1}', ()=>{`),p(` const component = new ${e.component.constructor.name}()`),p(` const state = ${JSON.stringify(e.state,void 0,2)};`),p(" const vdom = component['view'](state);"),p(" expect(JSON.stringify(vdom)).toMatchSnapshot();"),p(" })")})),u()):console.log("* No state recorded."),d=!1,h=[],console.log("* State logging stopped.")):console.log("create-state-tests <start|stop>")}],window._apprun=e=>{const[t,...n]=e[0].split(" ").filter((e=>!!e)),o=window[`_apprun-${t}`];o?o[1](...n):window["_apprun-help"][1]()},console.info('AppRun DevTools 3.36: type "_apprun `help`" to list all available commands.'),window.__REDUX_DEVTOOLS_EXTENSION__){let e=!1;const t=window.__REDUX_DEVTOOLS_EXTENSION__.connect();if(t){const n=location.hash||"#";t.send(n,"");const s=[{component:null,state:""}];console.info("Connected to the Redux DevTools"),t.subscribe((t=>{if("START"===t.type)e=!0;else if("STOP"===t.type)e=!1;else if("DISPATCH"===t.type){const e=t.payload.index;if(0===e)o.A.run(n);else{const{component:t,state:n}=s[e];t?.setState(n)}}}));const r=(e,n,o)=>{null!=o&&(s.push({component:e,state:o}),t.send(n,o))};o.A.on("debug",(t=>{if(e&&t.event){const e=t.newState,n={type:t.event,payload:t.p},o=t.component;e instanceof Promise?e.then((e=>r(o,n,e))):r(o,n,e)}}))}}return{}})()));
|
|
2
2
|
//# sourceMappingURL=apprun-dev-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dist/apprun-dev-tools.js","mappings":"CA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AAM,KAAKjI,QAAOkI,KAAOA,IAClDsB,EAAUtK,OAAO,WAAW8H,KAC9BwC,EAASA,EAAQ,MAAM7D,GACtBzG,OAAO,gBAAgB,IAAI,EAGlCoB,QAAQmJ,KAAK,+EAEIvK,OAAqC,6BACxC,CACZ,IAAIwK,GAAmB,EACvB,MAAMC,EAAWzK,OAAqC,6BAAE0K,UACxD,GAAID,EAAU,CACZ,MAAME,EAAO5E,SAAS4E,MAAQ,IAC9BF,EAASG,KAAKD,EAAM,IACpB,MAAME,EAAM,CAAC,CAAExE,UAAW,KAAMiB,MAAO,KACvClG,QAAQmJ,KAAK,mCACbE,EAASK,WAAWC,IAClB,GAAqB,UAAjBA,EAAQC,KAAkBR,GAAmB,OAC5C,GAAqB,SAAjBO,EAAQC,KAAiBR,GAAmB,OAChD,GAAqB,aAAjBO,EAAQC,KAAqB,CAEpC,MAAMZ,EAAMW,EAAQE,QAAQC,MAC5B,GAAY,IAARd,EAAa,IAAInJ,IAAI0J,OACpB,CACH,MAAM,UAAEtE,EAAS,MAAEiB,GAAUuD,EAAIT,GACjC/D,GAAW8E,SAAS7D,EACtB,CACF,KAGF,MAAMsD,EAAO,CAACvE,EAAWE,EAAQe,KAClB,MAATA,IACJuD,EAAIlK,KAAK,CAAE0F,YAAWiB,UACtBmD,EAASG,KAAKrE,EAAQe,GAAM,EAG9B,IAAI/G,GAAG,SAASkG,IACd,GAAI+D,GAAoB/D,EAAEvD,MAAO,CAC/B,MAAMoE,EAAQb,EAAE2E,SAGV7E,EAAS,CAAEyE,KAFJvE,EAAEvD,MAEQ+H,QADPxE,EAAEA,GAEZJ,EAAYI,EAAEJ,UAChBiB,aAAiBlF,QACnBkF,EAAM+D,MAAKlB,GAAKS,EAAKvE,EAAWE,EAAQ4D,KAExCS,EAAKvE,EAAWE,EAAQe,EAE5B,IAEJ,CACF,C","sources":["webpack://apprun/webpack/universalModuleDefinition","webpack://apprun/./src/version.ts","webpack://apprun/./src/app.ts","webpack://apprun/webpack/bootstrap","webpack://apprun/webpack/runtime/define property getters","webpack://apprun/webpack/runtime/global","webpack://apprun/webpack/runtime/hasOwnProperty shorthand","webpack://apprun/./src/vdom-to-html.tsx","webpack://apprun/./src/apprun-dev-tools-tests.tsx","webpack://apprun/./src/apprun-dev-tools.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"apprun\"] = factory();\n\telse\n\t\troot[\"apprun\"] = factory();\n})(this, () => {\nreturn ","/**\n * Version Management Utility\n * \n * Single source of truth for AppRun version information.\n * This file ensures version consistency across all modules.\n * \n * The version is derived from package.json and should be updated\n * only when the package version changes.\n */\n\n// Import version from package.json to maintain single source of truth\n// This version string is used across the framework\nexport const APPRUN_VERSION = '3.37.2';\n\n// Version string with prefix for global tracking\nexport const APPRUN_VERSION_GLOBAL = `AppRun-${APPRUN_VERSION}`;\n","/**\n * Core AppRun application class and singleton instance\n *\n * This file provides:\n * 1. App class - The core event system implementation with pub/sub capabilities\n * - on(): Subscribe to events with options (once, delay, global)\n * - off(): Unsubscribe from events with proper cleanup\n * - run(): Publish events synchronously with error handling\n * - runAsync(): Publish events asynchronously with Promise support, returns handler values\n * - query(): Deprecated alias for runAsync() - use runAsync() instead\n *\n * 2. Default app singleton - Global event bus instance\n * - Created once and reused across the application\n * - Stored in global scope (window/global) with version tracking\n * - Prevents duplicate instances across different versions\n *\n * Features:\n * - Event wildcards support (events ending with '*')\n * - Delayed event execution with timeout management\n * - Once-only event subscriptions\n * - Async event handling with Promise.all\n * - Global event bus shared across components\n * - Memory leak prevention with proper cleanup\n *\n * Type Safety Improvements (v3.35.1):\n * - Added validation for event handler functions\n * - Enhanced error handling in event execution\n * - Improved null checks in delayed event handling\n * - Better error reporting for invalid handlers\n *\n * Usage:\n * ```ts\n * // Subscribe to events\n * app.on('event-name', (state, ...args) => {\n * // Handle event\n * });\n *\n * // Publish events (fire-and-forget)\n * app.run('event-name', ...args);\n * \n * // Get return values from event handlers\n * app.runAsync('event-name', data).then(results => {\n * // Handle results array\n * });\n * ```\n */\n\nimport { EventOptions } from './types'\nimport { APPRUN_VERSION_GLOBAL } from './version'\n\nexport class App {\n\n _events: { [key: string]: Array<{ fn: (...args: any[]) => any, options: EventOptions }> };\n\n constructor() {\n this._events = {} as { [key: string]: Array<{ fn: (...args: any[]) => any, options: EventOptions }> };\n }\n\n on(name: string, fn: (...args: any[]) => any, options: EventOptions = {}): void {\n this._events[name] = this._events[name] || [];\n this._events[name].push({ fn, options });\n }\n\n off(name: string, fn: (...args: any[]) => any): void {\n const subscribers = this._events[name] || [];\n\n this._events[name] = subscribers.filter((sub) => sub.fn !== fn);\n }\n\n find(name: string): any {\n return this._events[name];\n }\n\n run(name: string, ...args: any[]): number {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n subscribers.forEach((sub) => {\n const { fn, options } = sub;\n if (!fn || typeof fn !== 'function') {\n console.error(`AppRun event handler for '${name}' is not a function:`, fn);\n return false;\n }\n if (options.delay) {\n this.delay(name, fn, args, options);\n } else {\n try {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n } catch (error) {\n console.error(`Error in event handler for '${name}':`, error);\n }\n }\n return !sub.options.once;\n });\n\n return subscribers.length;\n }\n\n once(name: string, fn: (...args: any[]) => any, options: EventOptions = {}): void {\n this.on(name, fn, { ...options, once: true });\n }\n\n private delay(name: string, fn: (...args: any[]) => any, args: any[], options: EventOptions): void {\n if (options._t) clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n try {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n } catch (error) {\n console.error(`Error in delayed event handler for '${name}':`, error);\n }\n }, options.delay);\n }\n\n runAsync(name: string, ...args: any[]): Promise<any[]> {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n const promises = subscribers.map(sub => {\n const { fn, options } = sub;\n if (!fn || typeof fn !== 'function') {\n console.error(`AppRun async event handler for '${name}' is not a function:`, fn);\n return Promise.resolve(null);\n }\n try {\n return Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n } catch (error) {\n console.error(`Error in async event handler for '${name}':`, error);\n return Promise.reject(error);\n }\n });\n return Promise.all(promises);\n }\n\n /**\n * @deprecated Use runAsync() instead. app.query() will be removed in a future version.\n */\n query(name: string, ...args: any[]): Promise<any[]> {\n console.warn('app.query() is deprecated. Use app.runAsync() instead.');\n return this.runAsync(name, ...args);\n }\n\n private getSubscribers(name: string, events: { [key: string]: Array<{ fn: (...args: any[]) => any, options: EventOptions }> }): Array<{ fn: (...args: any[]) => any, options: EventOptions }> {\n const subscribers = events[name] || [];\n\n // Update the list of subscribers by pulling out those which will run once.\n // We must do this update prior to running any of the events in case they\n // cause additional events to be turned off or on.\n events[name] = subscribers.filter((sub) => {\n return !sub.options.once;\n });\n Object.keys(events).filter(evt => evt.endsWith('*') && name.startsWith(evt.replace('*', '')))\n .sort((a, b) => b.length - a.length)\n .forEach(evt => subscribers.push(...events[evt].map(sub => ({\n ...sub,\n options: { ...sub.options, event: name }\n }))));\n return subscribers;\n }\n}\n\nconst AppRunVersions = APPRUN_VERSION_GLOBAL;\nlet _app: App;\nconst root = (typeof window !== 'undefined' ? window :\n typeof global !== 'undefined' ? global :\n typeof self !== 'undefined' ? self : {}) as any;\n\nif (root.app && root._AppRunVersions) {\n _app = root.app;\n} else {\n _app = new App();\n root.app = _app;\n root._AppRunVersions = AppRunVersions;\n}\nexport default _app;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","\nimport { VDOM } from './types';\nimport { TemplateResult } from 'lit-html';\n\nfunction getProp(prop) {\n if (typeof prop === 'object') {\n return Object.keys(prop).map(name => `${name}:${prop[name]}`).join(';');\n }\n else return prop.toString();\n}\n\nfunction toProps(props) {\n return Object.keys(props)\n .map(name => ` ${name === 'className' ? 'class' : name}=\"${getProp(props[name])}\"`)\n .join('');\n}\n\nfunction toHTMLArray(nodes) {\n return nodes.map(node => toHTML(node)).join('');\n}\n\nfunction clean(obj) {\n for (var i in obj) {\n if (obj[i] == null) {\n delete obj[i];\n } else if (typeof obj[i] === 'object') {\n clean(obj[i]);\n }\n }\n}\n\nfunction toHTML (vdom) {\n if (!vdom) return '';\n if (vdom['_$litType$']) {\n return vdom.toString();\n }\n clean(vdom);\n if (Array.isArray(vdom)) return toHTMLArray(vdom);\n if (typeof vdom === 'string') {\n return vdom.startsWith('_html:') ? vdom.substring(6) : vdom;\n } else if (vdom.tag) {\n const props = vdom.props ? toProps(vdom.props) : '';\n const children = vdom.children ? toHTMLArray(vdom.children) : '';\n return `<${vdom.tag}${props}>${children}</${vdom.tag}>`;\n }\n if (typeof vdom === 'object') return JSON.stringify(vdom);\n}\n\nexport default toHTML;","declare var app;\nlet win;\napp['debug'] = true;\n\nfunction openWin(name) {\n win = window.open('', name);\n win.document.write(`<html>\n <title>AppRun Analyzer | ${document.location.href}</title>\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\" }\n </style>\n <body><pre>`);\n}\n\nfunction write(text) {\n win.document.write(text + '\\n');\n}\n\nfunction closeWin() {\n win.document.write(`</pre>\n </body>\n </html>`);\n win.document.close();\n}\n\nconst print_component_test = component => {\n write(`import ${component.constructor.name} from '../src/${component.constructor.name}'`);\n write(`describe('${component.constructor.name}', ()=>{`);\n component._actions.forEach(action => {\n if (action.name !== '.') {\n write(` it ('should handle event: ${action.name}', (done)=>{`);\n write(` const component = new ${component.constructor.name}().mount();`);\n write(` component.run('${action.name}');`);\n write(` setTimeout(() => {`);\n write(` \\/\\/expect(?).toHaveBeenCalled();`);\n write(` \\/\\/expect(component.state).toBe(?);`);\n write(` done();`);\n write(` })`);\n }\n });\n write(`});`);\n};\nexport const _createEventTests = () => {\n const o = { components: {} };\n app.run('get-components', o);\n const { components } = o;\n openWin('');\n if (components instanceof Map) {\n for (let [key, comps] of components) {\n comps.forEach(print_component_test);\n }\n } else {\n Object.keys(components).forEach(el => {\n components[el].forEach(print_component_test);\n });\n }\n closeWin();\n}\n\nlet recording = false;\nlet events = [];\n\napp.on('debug', p => {\n if (recording && p.vdom) {\n events.push(p);\n console.log(`* ${events.length} state(s) recorded.`);\n }\n});\n\nexport const _createStateTests = (s) => {\n\n const printTests = () => {\n if (events.length === 0) {\n console.log('* No state recorded.');\n return;\n }\n openWin('');\n events.forEach((event, idx) => {\n write(` it ('view snapshot: #${idx + 1}', ()=>{`);\n write(` const component = new ${event.component.constructor.name}()`);\n write(` const state = ${JSON.stringify(event.state, undefined, 2)};`);\n write(` const vdom = component['view'](state);`);\n write(` expect(JSON.stringify(vdom)).toMatchSnapshot();`);\n write(` })`);\n });\n closeWin();\n }\n\n if (s === 'start') {\n events = [];\n recording = true;\n console.log('* State logging started.');\n } else if (s === 'stop') {\n printTests();\n recording = false;\n events = [];\n console.log('* State logging stopped.');\n } else {\n console.log('create-state-tests <start|stop>');\n }\n}\n","import app from './app';\nimport toHTML from './vdom-to-html';\nimport { _createEventTests, _createStateTests } from './apprun-dev-tools-tests';\n\nfunction createProxy(obj) {\n const handler = {\n get(target, property, receiver) {\n\n // Get the property value\n const value = Reflect.get(target, property, receiver);\n\n // If the value is an object (including arrays), proxy it\n if (typeof value === 'object' && value !== null) {\n if (Array.isArray(value)) {\n // Proxy each element of the array if it's an object\n return value.map(item => createProxy(item));\n } else {\n // Recursively proxy the object\n return createProxy(value);\n }\n }\n\n return `{${property}}`\n },\n\n };\n\n return Array.isArray(obj) ?\n obj.map(item => createProxy(item)) : new Proxy(obj, handler);\n}\n\nfunction htmlEncode(input) {\n return !input ? input : input.toString()\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\nfunction getVDOM(component) {\n let view;\n if (typeof component.state === 'object') {\n const proxy = createProxy(component.state);\n view = component.view(proxy);\n } else {\n view = component.view(component.state);\n }\n return view;\n}\n\nconst componentCache = new Map();\napp['debug'] = true;\napp.on('debug-create-component', component => {\n const element = component.element;\n if (!element) {\n console.warn('Component created without an element:', component);\n return;\n }\n if (componentCache.get(element)) { componentCache.get(element).push(component) }\n else { componentCache.set(element, [component]) }\n});\n\nwindow['_apprun-help'] = ['', () => {\n Object.keys(window).forEach(cmd => {\n if (cmd.startsWith('_apprun-')) {\n cmd === '_apprun-help' ?\n console.log('AppRun Commands:') :\n console.log(`* ${cmd.substring(8)}: ${window[cmd][0]}`);\n }\n });\n}];\n\nfunction newWin(html) {\n const win = window.open('', '_apprun_debug', 'toolbar=0');\n win.document.write(`<html>\n <title>AppRun Analyzer | ${document.location.href}</title>\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\" }\n li { margin-left: 80px; }\n </style>\n <body>\n <div id=\"main\">${html}</div>\n </script>\n </body>\n </html>`);\n win.document.close();\n}\n\nconst viewElement = element => <div>\n {element.tagName.toLowerCase()}{element.id ? '#' + element.id : ''}\n {' '}\n {element.className && element.className.split(' ').map(c => '.' + c).join()}\n</div>;\n\nconst viewComponents = state => {\n const Components = ({ components }) => <ul>\n {components.map(component => {\n\n const vdom = getVDOM(component);\n const events = component['_actions'].map(a => a.name);\n\n const component_def = {\n state: component.state,\n view: vdom,\n actions: events,\n update: component.update\n };\n\n return <li>\n <div>{component.constructor.name}</div>\n <div><pre>{htmlEncode(JSON.stringify(component_def, null, 2))}</pre></div>\n <br />\n </li>;\n\n })}\n </ul>;\n\n return <ul>\n {state.map(({ element, comps }) => <li>\n <div>{viewElement(element)}</div>\n <Components components={comps} />\n </li>)}\n </ul>\n}\n\nconst viewEvents = state => {\n const Components = ({ components }) => <ul>\n {components.map(component => <li>\n <div>{component.constructor.name}</div>\n </li>)}\n </ul>;\n\n const Events = ({ events, global }) => <ul>\n {events && events\n .filter(event =>\n event.global === global && event.event !== '.')\n .map(({ event, components }) => <li>\n <div>{event}</div>\n <Components components={components} />\n </li>)}\n </ul>;\n\n return <div>\n <div>GLOBAL EVENTS</div>\n <Events events={state} global={true} />\n <div>LOCAL EVENTS</div>\n <Events events={state} global={false} />\n </div>\n}\n\nconst _events = (print?) => {\n const global_events = app['_events']\n const events = {};\n const cache = componentCache;\n\n const add_component = component => component['_actions'].forEach(event => {\n events[event.name] = events[event.name] || [];\n events[event.name].push(component);\n });\n\n if (cache instanceof Map) {\n for (let [key, comps] of cache) {\n comps.forEach(add_component);\n }\n }\n const data = [];\n Object.keys(events).forEach(event => {\n data.push({ event, components: events[event], global: global_events[event] ? true : false });\n });\n\n data.sort(((a, b) => a.event > b.event ? 1 : -1)).map(e => e.event);\n\n if (print) {\n const vdom = viewEvents(data);\n newWin(toHTML(vdom));\n } else {\n console.log('=== GLOBAL EVENTS ===')\n data.filter(event => event.global && event.event !== '.')\n .forEach(({ event, components }) => console.log({ event }, components));\n console.log('=== LOCAL EVENTS ===')\n data.filter(event => !event.global && event.event !== '.')\n .forEach(({ event, components }) => console.log({ event }, components));\n }\n}\n\nconst _components = (print?) => {\n const components = componentCache;\n const data = [];\n\n if (components instanceof Map) {\n for (let [key, comps] of components) {\n const element = typeof key === 'string' ? document.getElementById(key) || document.querySelector(key) : key;\n data.push({ element, comps });\n }\n }\n if (print) {\n const vdom = viewComponents(data);\n newWin(toHTML(vdom));\n } else {\n data.forEach(({ element, comps }) => console.log(element, comps));\n }\n}\n\nlet debugging = Number(window?.localStorage?.getItem('__apprun_debugging__')) || 0;\napp.on('debug', p => {\n if (debugging & 1 && p.event) console.log(p);\n if (debugging & 2 && p.vdom) console.log(p);\n});\n\nwindow['_apprun-components'] = ['components [print|clear]', (p) => {\n if (p === 'print') {\n _components(true);\n } else if (p === 'clear') {\n componentCache.clear();\n console.log('Component cache cleared');\n } else {\n _components(false);\n }\n}]\n\nwindow['_apprun-events'] = ['events [print]', (p) => {\n _events(p === 'print');\n}]\n\nwindow['_apprun-log'] = ['log [event|view] on|off', (a1?, a2?) => {\n if (a1 === 'on') {\n debugging = 3;\n } else if (a1 === 'off') {\n debugging = 0;\n } else if (a1 === 'event') {\n if (a2 === 'on') {\n debugging |= 1;\n } else if (a2 === 'off') {\n debugging &= ~1;\n }\n } else if (a1 === 'view') {\n if (a2 === 'on') {\n debugging |= 2;\n } else if (a2 === 'off') {\n debugging &= ~2;\n }\n }\n console.log(`* log ${a1} ${a2 || ''}`);\n window?.localStorage?.setItem('__apprun_debugging__', `${debugging}`)\n}];\n\nwindow['_apprun-create-event-tests'] = ['create-event-tests',\n () => _createEventTests()\n]\n\nwindow['_apprun-create-state-tests'] = ['create-state-tests <start|stop>',\n (p?) => _createStateTests(p)\n]\n\nwindow['_apprun'] = (strings) => {\n const [cmd, ...p] = strings[0].split(' ').filter(c => !!c);\n const command = window[`_apprun-${cmd}`];\n if (command) command[1](...p);\n else window['_apprun-help'][1]();\n}\n\nconsole.info('AppRun DevTools 3.36: type \"_apprun `help`\" to list all available commands.');\n\nconst reduxExt = window['__REDUX_DEVTOOLS_EXTENSION__'];\nif (reduxExt) {\n let devTools_running = false;\n const devTools = window['__REDUX_DEVTOOLS_EXTENSION__'].connect();\n if (devTools) {\n const hash = location.hash || '#';\n devTools.send(hash, '');\n const buf = [{ component: null, state: '' }];\n console.info('Connected to the Redux DevTools');\n devTools.subscribe((message) => {\n if (message.type === 'START') devTools_running = true;\n else if (message.type === 'STOP') devTools_running = false;\n else if (message.type === 'DISPATCH') {\n // console.log('From Redux DevTools: ', message);\n const idx = message.payload.index;\n if (idx === 0) { app.run(hash) }\n else {\n const { component, state } = buf[idx];\n component?.setState(state);\n }\n }\n });\n\n const send = (component, action, state) => {\n if (state == null) return;\n buf.push({ component, state });\n devTools.send(action, state);\n }\n\n app.on('debug', p => {\n if (devTools_running && p.event) {\n const state = p.newState;\n const type = p.event;\n const payload = p.p;\n const action = { type, payload };\n const component = p.component;\n if (state instanceof Promise) {\n state.then(s => send(component, action, s));\n } else {\n send(component, action, state);\n }\n }\n });\n }\n}\n"],"names":["root","factory","exports","module","define","amd","this","APPRUN_VERSION_GLOBAL","AppRunVersions","_app","window","g","self","app","_AppRunVersions","constructor","_events","on","name","fn","options","push","off","subscribers","filter","sub","find","run","args","getSubscribers","console","assert","length","forEach","error","delay","Object","keys","apply","once","_t","clearTimeout","setTimeout","runAsync","promises","map","Promise","resolve","reject","all","query","warn","events","evt","endsWith","startsWith","replace","sort","a","b","event","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","defineProperty","enumerable","get","globalThis","Function","e","obj","prop","prototype","hasOwnProperty","call","toHTMLArray","nodes","node","toHTML","join","clean","i","vdom","toString","Array","isArray","substring","tag","props","toProps","children","JSON","stringify","win","openWin","open","document","write","location","href","text","closeWin","close","print_component_test","component","_actions","action","recording","p","log","createProxy","handler","target","property","receiver","value","Reflect","item","Proxy","getVDOM","view","state","proxy","componentCache","Map","newWin","html","element","set","cmd","_components","print","components","data","comps","getElementById","querySelector","Components","component_def","actions","update","input","tagName","toLowerCase","id","className","split","c","viewElement","viewComponents","debugging","Number","localStorage","getItem","clear","global_events","cache","add_component","global","Events","viewEvents","a1","a2","setItem","el","_createEventTests","s","idx","strings","command","info","devTools_running","devTools","connect","hash","send","buf","subscribe","message","type","payload","index","setState","newState","then"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"dist/apprun-dev-tools.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,yDCGF,MAGMC,EAAwB,e,8CCgJrC,MAAMC,EAAiB,IACvB,IAAIC,EACJ,MAAMT,EAA0B,oBAAXU,OAAyBA,YAC1B,IAAX,EAAAC,EAAyB,EAAAA,EACd,oBAATC,KAAuBA,KAAO,CAAC,EAEtCZ,EAAKa,KAAOb,EAAKc,gBACnBL,EAAOT,EAAKa,KAEZJ,EAAO,IAtHF,MAIL,WAAAM,GACET,KAAKU,QAAU,CAAC,CAClB,CAEA,EAAAC,CAAGC,EAAcC,EAA6BC,EAAwB,CAAC,GACrEd,KAAKU,QAAQE,GAAQZ,KAAKU,QAAQE,IAAS,GAC3CZ,KAAKU,QAAQE,GAAMG,KAAK,CAAEF,KAAIC,WAChC,CAEA,GAAAE,CAAIJ,EAAcC,GAChB,MAAMI,EAAcjB,KAAKU,QAAQE,IAAS,GAE1CZ,KAAKU,QAAQE,GAAQK,EAAYC,QAAQC,GAAQA,EAAIN,KAAOA,GAC9D,CAEA,IAAAO,CAAKR,GACH,OAAOZ,KAAKU,QAAQE,EACtB,CAEA,GAAAS,CAAIT,KAAiBU,GAC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AoB/D,EAAEvD,MAAO,CAC/B,MAAMoE,EAAQb,EAAE2E,SAGV7E,EAAS,CAAEyE,KAFJvE,EAAEvD,MAEQ+H,QADPxE,EAAEA,GAEZJ,EAAYI,EAAEJ,UAChBiB,aAAiBlF,QACnBkF,EAAM+D,MAAKlB,GAAKS,EAAKvE,EAAWE,EAAQ4D,KAExCS,EAAKvE,EAAWE,EAAQe,EAE5B,IAEJ,CACF,C","sources":["webpack://apprun/webpack/universalModuleDefinition","webpack://apprun/./src/version.ts","webpack://apprun/./src/app.ts","webpack://apprun/webpack/bootstrap","webpack://apprun/webpack/runtime/define property getters","webpack://apprun/webpack/runtime/global","webpack://apprun/webpack/runtime/hasOwnProperty shorthand","webpack://apprun/./src/vdom-to-html.tsx","webpack://apprun/./src/apprun-dev-tools-tests.tsx","webpack://apprun/./src/apprun-dev-tools.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"apprun\"] = factory();\n\telse\n\t\troot[\"apprun\"] = factory();\n})(this, () => {\nreturn ","/**\n * Version Management Utility\n * \n * Single source of truth for AppRun version information.\n * This file ensures version consistency across all modules.\n * \n * The version is derived from package.json and should be updated\n * only when the package version changes.\n */\n\n// Import version from package.json to maintain single source of truth\n// This version string is used across the framework\nexport const APPRUN_VERSION = '3.38.0';\n\n// Version string with prefix for global tracking\nexport const APPRUN_VERSION_GLOBAL = `AppRun-${APPRUN_VERSION}`;\n","/**\n * Core AppRun application class and singleton instance\n *\n * This file provides:\n * 1. App class - The core event system implementation with pub/sub capabilities\n * - on(): Subscribe to events with options (once, delay, global)\n * - off(): Unsubscribe from events with proper cleanup\n * - run(): Publish events synchronously with error handling\n * - runAsync(): Publish events asynchronously with Promise support, returns handler values\n * - query(): Deprecated alias for runAsync() - use runAsync() instead\n *\n * 2. Default app singleton - Global event bus instance\n * - Created once and reused across the application\n * - Stored in global scope (window/global) with version tracking\n * - Prevents duplicate instances across different versions\n *\n * Features:\n * - Event wildcards support (events ending with '*')\n * - Delayed event execution with timeout management\n * - Once-only event subscriptions\n * - Async event handling with Promise.all\n * - Global event bus shared across components\n * - Memory leak prevention with proper cleanup\n *\n * Type Safety Improvements (v3.35.1):\n * - Added validation for event handler functions\n * - Enhanced error handling in event execution\n * - Improved null checks in delayed event handling\n * - Better error reporting for invalid handlers\n *\n * Usage:\n * ```ts\n * // Subscribe to events\n * app.on('event-name', (state, ...args) => {\n * // Handle event\n * });\n *\n * // Publish events (fire-and-forget)\n * app.run('event-name', ...args);\n * \n * // Get return values from event handlers\n * app.runAsync('event-name', data).then(results => {\n * // Handle results array\n * });\n * ```\n */\n\nimport { EventOptions } from './types'\nimport { APPRUN_VERSION_GLOBAL } from './version'\n\nexport class App {\n\n _events: { [key: string]: Array<{ fn: (...args: any[]) => any, options: EventOptions }> };\n\n constructor() {\n this._events = {} as { [key: string]: Array<{ fn: (...args: any[]) => any, options: EventOptions }> };\n }\n\n on(name: string, fn: (...args: any[]) => any, options: EventOptions = {}): void {\n this._events[name] = this._events[name] || [];\n this._events[name].push({ fn, options });\n }\n\n off(name: string, fn: (...args: any[]) => any): void {\n const subscribers = this._events[name] || [];\n\n this._events[name] = subscribers.filter((sub) => sub.fn !== fn);\n }\n\n find(name: string): any {\n return this._events[name];\n }\n\n run(name: string, ...args: any[]): number {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n subscribers.forEach((sub) => {\n const { fn, options } = sub;\n if (!fn || typeof fn !== 'function') {\n console.error(`AppRun event handler for '${name}' is not a function:`, fn);\n return false;\n }\n if (options.delay) {\n this.delay(name, fn, args, options);\n } else {\n try {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n } catch (error) {\n console.error(`Error in event handler for '${name}':`, error);\n }\n }\n return !sub.options.once;\n });\n\n return subscribers.length;\n }\n\n once(name: string, fn: (...args: any[]) => any, options: EventOptions = {}): void {\n this.on(name, fn, { ...options, once: true });\n }\n\n private delay(name: string, fn: (...args: any[]) => any, args: any[], options: EventOptions): void {\n if (options._t) clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n try {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n } catch (error) {\n console.error(`Error in delayed event handler for '${name}':`, error);\n }\n }, options.delay);\n }\n\n runAsync(name: string, ...args: any[]): Promise<any[]> {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n const promises = subscribers.map(sub => {\n const { fn, options } = sub;\n if (!fn || typeof fn !== 'function') {\n console.error(`AppRun async event handler for '${name}' is not a function:`, fn);\n return Promise.resolve(null);\n }\n try {\n return Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n } catch (error) {\n console.error(`Error in async event handler for '${name}':`, error);\n return Promise.reject(error);\n }\n });\n return Promise.all(promises);\n }\n\n /**\n * @deprecated Use runAsync() instead. app.query() will be removed in a future version.\n */\n query(name: string, ...args: any[]): Promise<any[]> {\n console.warn('app.query() is deprecated. Use app.runAsync() instead.');\n return this.runAsync(name, ...args);\n }\n\n private getSubscribers(name: string, events: { [key: string]: Array<{ fn: (...args: any[]) => any, options: EventOptions }> }): Array<{ fn: (...args: any[]) => any, options: EventOptions }> {\n const subscribers = events[name] || [];\n\n // Update the list of subscribers by pulling out those which will run once.\n // We must do this update prior to running any of the events in case they\n // cause additional events to be turned off or on.\n events[name] = subscribers.filter((sub) => {\n return !sub.options.once;\n });\n Object.keys(events).filter(evt => evt.endsWith('*') && name.startsWith(evt.replace('*', '')))\n .sort((a, b) => b.length - a.length)\n .forEach(evt => subscribers.push(...events[evt].map(sub => ({\n ...sub,\n options: { ...sub.options, event: name }\n }))));\n return subscribers;\n }\n}\n\nconst AppRunVersions = APPRUN_VERSION_GLOBAL;\nlet _app: App;\nconst root = (typeof window !== 'undefined' ? window :\n typeof global !== 'undefined' ? global :\n typeof self !== 'undefined' ? self : {}) as any;\n\nif (root.app && root._AppRunVersions) {\n _app = root.app;\n} else {\n _app = new App();\n root.app = _app;\n root._AppRunVersions = AppRunVersions;\n}\nexport default _app;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","\nimport { VDOM } from './types';\nimport { TemplateResult } from 'lit-html';\n\nfunction getProp(prop) {\n if (typeof prop === 'object') {\n return Object.keys(prop).map(name => `${name}:${prop[name]}`).join(';');\n }\n else return prop.toString();\n}\n\nfunction toProps(props) {\n return Object.keys(props)\n .map(name => ` ${name === 'className' ? 'class' : name}=\"${getProp(props[name])}\"`)\n .join('');\n}\n\nfunction toHTMLArray(nodes) {\n return nodes.map(node => toHTML(node)).join('');\n}\n\nfunction clean(obj) {\n for (var i in obj) {\n if (obj[i] == null) {\n delete obj[i];\n } else if (typeof obj[i] === 'object') {\n clean(obj[i]);\n }\n }\n}\n\nfunction toHTML (vdom) {\n if (!vdom) return '';\n if (vdom['_$litType$']) {\n return vdom.toString();\n }\n clean(vdom);\n if (Array.isArray(vdom)) return toHTMLArray(vdom);\n if (typeof vdom === 'string') {\n return vdom.startsWith('_html:') ? vdom.substring(6) : vdom;\n } else if (vdom.tag) {\n const props = vdom.props ? toProps(vdom.props) : '';\n const children = vdom.children ? toHTMLArray(vdom.children) : '';\n return `<${vdom.tag}${props}>${children}</${vdom.tag}>`;\n }\n if (typeof vdom === 'object') return JSON.stringify(vdom);\n}\n\nexport default toHTML;","declare var app;\nlet win;\napp['debug'] = true;\n\nfunction openWin(name) {\n win = window.open('', name);\n win.document.write(`<html>\n <title>AppRun Analyzer | ${document.location.href}</title>\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\" }\n </style>\n <body><pre>`);\n}\n\nfunction write(text) {\n win.document.write(text + '\\n');\n}\n\nfunction closeWin() {\n win.document.write(`</pre>\n </body>\n </html>`);\n win.document.close();\n}\n\nconst print_component_test = component => {\n write(`import ${component.constructor.name} from '../src/${component.constructor.name}'`);\n write(`describe('${component.constructor.name}', ()=>{`);\n component._actions.forEach(action => {\n if (action.name !== '.') {\n write(` it ('should handle event: ${action.name}', (done)=>{`);\n write(` const component = new ${component.constructor.name}().mount();`);\n write(` component.run('${action.name}');`);\n write(` setTimeout(() => {`);\n write(` \\/\\/expect(?).toHaveBeenCalled();`);\n write(` \\/\\/expect(component.state).toBe(?);`);\n write(` done();`);\n write(` })`);\n }\n });\n write(`});`);\n};\nexport const _createEventTests = () => {\n const o = { components: {} };\n app.run('get-components', o);\n const { components } = o;\n openWin('');\n if (components instanceof Map) {\n for (let [key, comps] of components) {\n comps.forEach(print_component_test);\n }\n } else {\n Object.keys(components).forEach(el => {\n components[el].forEach(print_component_test);\n });\n }\n closeWin();\n}\n\nlet recording = false;\nlet events = [];\n\napp.on('debug', p => {\n if (recording && p.vdom) {\n events.push(p);\n console.log(`* ${events.length} state(s) recorded.`);\n }\n});\n\nexport const _createStateTests = (s) => {\n\n const printTests = () => {\n if (events.length === 0) {\n console.log('* No state recorded.');\n return;\n }\n openWin('');\n events.forEach((event, idx) => {\n write(` it ('view snapshot: #${idx + 1}', ()=>{`);\n write(` const component = new ${event.component.constructor.name}()`);\n write(` const state = ${JSON.stringify(event.state, undefined, 2)};`);\n write(` const vdom = component['view'](state);`);\n write(` expect(JSON.stringify(vdom)).toMatchSnapshot();`);\n write(` })`);\n });\n closeWin();\n }\n\n if (s === 'start') {\n events = [];\n recording = true;\n console.log('* State logging started.');\n } else if (s === 'stop') {\n printTests();\n recording = false;\n events = [];\n console.log('* State logging stopped.');\n } else {\n console.log('create-state-tests <start|stop>');\n }\n}\n","import app from './app';\nimport toHTML from './vdom-to-html';\nimport { _createEventTests, _createStateTests } from './apprun-dev-tools-tests';\n\nfunction createProxy(obj) {\n const handler = {\n get(target, property, receiver) {\n\n // Get the property value\n const value = Reflect.get(target, property, receiver);\n\n // If the value is an object (including arrays), proxy it\n if (typeof value === 'object' && value !== null) {\n if (Array.isArray(value)) {\n // Proxy each element of the array if it's an object\n return value.map(item => createProxy(item));\n } else {\n // Recursively proxy the object\n return createProxy(value);\n }\n }\n\n return `{${property}}`\n },\n\n };\n\n return Array.isArray(obj) ?\n obj.map(item => createProxy(item)) : new Proxy(obj, handler);\n}\n\nfunction htmlEncode(input) {\n return !input ? input : input.toString()\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\nfunction getVDOM(component) {\n let view;\n if (typeof component.state === 'object') {\n const proxy = createProxy(component.state);\n view = component.view(proxy);\n } else {\n view = component.view(component.state);\n }\n return view;\n}\n\nconst componentCache = new Map();\napp['debug'] = true;\napp.on('debug-create-component', component => {\n const element = component.element;\n if (!element) {\n console.warn('Component created without an element:', component);\n return;\n }\n if (componentCache.get(element)) { componentCache.get(element).push(component) }\n else { componentCache.set(element, [component]) }\n});\n\nwindow['_apprun-help'] = ['', () => {\n Object.keys(window).forEach(cmd => {\n if (cmd.startsWith('_apprun-')) {\n cmd === '_apprun-help' ?\n console.log('AppRun Commands:') :\n console.log(`* ${cmd.substring(8)}: ${window[cmd][0]}`);\n }\n });\n}];\n\nfunction newWin(html) {\n const win = window.open('', '_apprun_debug', 'toolbar=0');\n win.document.write(`<html>\n <title>AppRun Analyzer | ${document.location.href}</title>\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\" }\n li { margin-left: 80px; }\n </style>\n <body>\n <div id=\"main\">${html}</div>\n </script>\n </body>\n </html>`);\n win.document.close();\n}\n\nconst viewElement = element => <div>\n {element.tagName.toLowerCase()}{element.id ? '#' + element.id : ''}\n {' '}\n {element.className && element.className.split(' ').map(c => '.' + c).join()}\n</div>;\n\nconst viewComponents = state => {\n const Components = ({ components }) => <ul>\n {components.map(component => {\n\n const vdom = getVDOM(component);\n const events = component['_actions'].map(a => a.name);\n\n const component_def = {\n state: component.state,\n view: vdom,\n actions: events,\n update: component.update\n };\n\n return <li>\n <div>{component.constructor.name}</div>\n <div><pre>{htmlEncode(JSON.stringify(component_def, null, 2))}</pre></div>\n <br />\n </li>;\n\n })}\n </ul>;\n\n return <ul>\n {state.map(({ element, comps }) => <li>\n <div>{viewElement(element)}</div>\n <Components components={comps} />\n </li>)}\n </ul>\n}\n\nconst viewEvents = state => {\n const Components = ({ components }) => <ul>\n {components.map(component => <li>\n <div>{component.constructor.name}</div>\n </li>)}\n </ul>;\n\n const Events = ({ events, global }) => <ul>\n {events && events\n .filter(event =>\n event.global === global && event.event !== '.')\n .map(({ event, components }) => <li>\n <div>{event}</div>\n <Components components={components} />\n </li>)}\n </ul>;\n\n return <div>\n <div>GLOBAL EVENTS</div>\n <Events events={state} global={true} />\n <div>LOCAL EVENTS</div>\n <Events events={state} global={false} />\n </div>\n}\n\nconst _events = (print?) => {\n const global_events = app['_events']\n const events = {};\n const cache = componentCache;\n\n const add_component = component => component['_actions'].forEach(event => {\n events[event.name] = events[event.name] || [];\n events[event.name].push(component);\n });\n\n if (cache instanceof Map) {\n for (let [key, comps] of cache) {\n comps.forEach(add_component);\n }\n }\n const data = [];\n Object.keys(events).forEach(event => {\n data.push({ event, components: events[event], global: global_events[event] ? true : false });\n });\n\n data.sort(((a, b) => a.event > b.event ? 1 : -1)).map(e => e.event);\n\n if (print) {\n const vdom = viewEvents(data);\n newWin(toHTML(vdom));\n } else {\n console.log('=== GLOBAL EVENTS ===')\n data.filter(event => event.global && event.event !== '.')\n .forEach(({ event, components }) => console.log({ event }, components));\n console.log('=== LOCAL EVENTS ===')\n data.filter(event => !event.global && event.event !== '.')\n .forEach(({ event, components }) => console.log({ event }, components));\n }\n}\n\nconst _components = (print?) => {\n const components = componentCache;\n const data = [];\n\n if (components instanceof Map) {\n for (let [key, comps] of components) {\n const element = typeof key === 'string' ? document.getElementById(key) || document.querySelector(key) : key;\n data.push({ element, comps });\n }\n }\n if (print) {\n const vdom = viewComponents(data);\n newWin(toHTML(vdom));\n } else {\n data.forEach(({ element, comps }) => console.log(element, comps));\n }\n}\n\nlet debugging = Number(window?.localStorage?.getItem('__apprun_debugging__')) || 0;\napp.on('debug', p => {\n if (debugging & 1 && p.event) console.log(p);\n if (debugging & 2 && p.vdom) console.log(p);\n});\n\nwindow['_apprun-components'] = ['components [print|clear]', (p) => {\n if (p === 'print') {\n _components(true);\n } else if (p === 'clear') {\n componentCache.clear();\n console.log('Component cache cleared');\n } else {\n _components(false);\n }\n}]\n\nwindow['_apprun-events'] = ['events [print]', (p) => {\n _events(p === 'print');\n}]\n\nwindow['_apprun-log'] = ['log [event|view] on|off', (a1?, a2?) => {\n if (a1 === 'on') {\n debugging = 3;\n } else if (a1 === 'off') {\n debugging = 0;\n } else if (a1 === 'event') {\n if (a2 === 'on') {\n debugging |= 1;\n } else if (a2 === 'off') {\n debugging &= ~1;\n }\n } else if (a1 === 'view') {\n if (a2 === 'on') {\n debugging |= 2;\n } else if (a2 === 'off') {\n debugging &= ~2;\n }\n }\n console.log(`* log ${a1} ${a2 || ''}`);\n window?.localStorage?.setItem('__apprun_debugging__', `${debugging}`)\n}];\n\nwindow['_apprun-create-event-tests'] = ['create-event-tests',\n () => _createEventTests()\n]\n\nwindow['_apprun-create-state-tests'] = ['create-state-tests <start|stop>',\n (p?) => _createStateTests(p)\n]\n\nwindow['_apprun'] = (strings) => {\n const [cmd, ...p] = strings[0].split(' ').filter(c => !!c);\n const command = window[`_apprun-${cmd}`];\n if (command) command[1](...p);\n else window['_apprun-help'][1]();\n}\n\nconsole.info('AppRun DevTools 3.36: type \"_apprun `help`\" to list all available commands.');\n\nconst reduxExt = window['__REDUX_DEVTOOLS_EXTENSION__'];\nif (reduxExt) {\n let devTools_running = false;\n const devTools = window['__REDUX_DEVTOOLS_EXTENSION__'].connect();\n if (devTools) {\n const hash = location.hash || '#';\n devTools.send(hash, '');\n const buf = [{ component: null, state: '' }];\n console.info('Connected to the Redux DevTools');\n devTools.subscribe((message) => {\n if (message.type === 'START') devTools_running = true;\n else if (message.type === 'STOP') devTools_running = false;\n else if (message.type === 'DISPATCH') {\n // console.log('From Redux DevTools: ', message);\n const idx = message.payload.index;\n if (idx === 0) { app.run(hash) }\n else {\n const { component, state } = buf[idx];\n component?.setState(state);\n }\n }\n });\n\n const send = (component, action, state) => {\n if (state == null) return;\n buf.push({ component, state });\n devTools.send(action, state);\n }\n\n app.on('debug', p => {\n if (devTools_running && p.event) {\n const state = p.newState;\n const type = p.event;\n const payload = p.p;\n const action = { type, payload };\n const component = p.component;\n if (state instanceof Promise) {\n state.then(s => send(component, action, s));\n } else {\n send(component, action, state);\n }\n }\n });\n }\n}\n"],"names":["root","factory","exports","module","define","amd","this","APPRUN_VERSION_GLOBAL","AppRunVersions","_app","window","g","self","app","_AppRunVersions","constructor","_events","on","name","fn","options","push","off","subscribers","filter","sub","find","run","args","getSubscribers","console","assert","length","forEach","error","delay","Object","keys","apply","once","_t","clearTimeout","setTimeout","runAsync","promises","map","Promise","resolve","reject","all","query","warn","events","evt","endsWith","startsWith","replace","sort","a","b","event","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","defineProperty","enumerable","get","globalThis","Function","e","obj","prop","prototype","hasOwnProperty","call","toHTMLArray","nodes","node","toHTML","join","clean","i","vdom","toString","Array","isArray","substring","tag","props","toProps","children","JSON","stringify","win","openWin","open","document","write","location","href","text","closeWin","close","print_component_test","component","_actions","action","recording","p","log","createProxy","handler","target","property","receiver","value","Reflect","item","Proxy","getVDOM","view","state","proxy","componentCache","Map","newWin","html","element","set","cmd","_components","print","components","data","comps","getElementById","querySelector","Components","component_def","actions","update","input","tagName","toLowerCase","id","className","split","c","viewElement","viewComponents","debugging","Number","localStorage","getItem","clear","global_events","cache","add_component","global","Events","viewEvents","a1","a2","setItem","el","_createEventTests","s","idx","strings","command","info","devTools_running","devTools","connect","hash","send","buf","subscribe","message","type","payload","index","setState","newState","then"],"sourceRoot":""}
|