apprun 3.28.14 → 3.29.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 +8 -1
- package/LICENSE +1 -1
- package/README.md +85 -30
- package/WHATSNEW.md +16 -6
- package/apprun.d.ts +4 -4
- package/dist/apprun-dev-tools.js +1 -1
- package/dist/apprun-dev-tools.js.map +1 -1
- package/dist/apprun-html.esm.js +3 -3
- 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.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/esm/apprun-dev-tools.js +2 -2
- package/esm/apprun-dev-tools.js.map +1 -1
- package/esm/apprun.js +2 -2
- package/esm/apprun.js.map +1 -1
- package/esm/component.js +20 -21
- package/esm/component.js.map +1 -1
- package/esm/vdom-my.js +4 -2
- package/esm/vdom-my.js.map +1 -1
- package/index.html +0 -1
- package/package.json +1 -1
- package/src/apprun-dev-tools.tsx +2 -2
- package/src/apprun.ts +6 -5
- package/src/component.ts +21 -20
- package/src/vdom-my.ts +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Releases
|
|
4
4
|
|
|
5
|
+
## 3.29.0
|
|
6
|
+
|
|
7
|
+
* Resolve async state before running the event
|
|
8
|
+
|
|
9
|
+
## 3.28.15
|
|
10
|
+
|
|
11
|
+
* Support css selector in _mount_, _start_, and _app.render_
|
|
5
12
|
|
|
6
13
|
## 3.28.12
|
|
7
14
|
|
|
8
|
-
*
|
|
15
|
+
* Export safeHTML funciton
|
|
9
16
|
|
|
10
17
|
## 3.28.11
|
|
11
18
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,62 +2,117 @@
|
|
|
2
2
|
|
|
3
3
|
AppRun is a JavaScript library for building reliable, high-performance web applications using the Elm-inspired architecture, events, and components.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```js
|
|
6
|
+
// define the application state
|
|
7
|
+
const state = 0;
|
|
8
|
+
|
|
9
|
+
// view is a pure function to display the state
|
|
10
|
+
const view = state => `<div>
|
|
11
|
+
<h1>${state}</h1>
|
|
12
|
+
<button onclick="app.run('-1')">-1</button>
|
|
13
|
+
<button onclick="app.run('+1')">+1</button>
|
|
14
|
+
</div>`;
|
|
15
|
+
|
|
16
|
+
// update is a collection of event handlers
|
|
17
|
+
const update = {
|
|
18
|
+
'+1': state => state + 1,
|
|
19
|
+
'-1': state => state - 1
|
|
20
|
+
};
|
|
21
|
+
app.start(document.body, state, view, update);
|
|
22
|
+
```
|
|
23
|
+
<apprun-play style="height:200px"></apprun-play>
|
|
6
24
|
|
|
7
25
|
## AppRun Benefits
|
|
8
26
|
|
|
9
|
-
*
|
|
10
|
-
* No proprietary syntax to learn
|
|
11
|
-
* Compiler/transpiler is optional
|
|
27
|
+
* Clean architecure that needs less code
|
|
12
28
|
* State management and routing included
|
|
13
|
-
*
|
|
29
|
+
* No proprietary syntax to learn (no hooks)
|
|
30
|
+
* Use directly in the browser or with a compiler/bundler
|
|
31
|
+
* Advanced features: JSX, Web Components, Dev Tools, SSR, etc.
|
|
14
32
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
npm install apprun
|
|
18
|
-
```
|
|
33
|
+
|
|
34
|
+
## Getting Started
|
|
19
35
|
|
|
20
36
|
You can also load AppRun directly from the unpkg.com CDN:
|
|
21
37
|
|
|
22
|
-
```
|
|
38
|
+
```js
|
|
23
39
|
<script src="https://unpkg.com/apprun/dist/apprun-html.js"></script>
|
|
40
|
+
<script>
|
|
41
|
+
const view = state => `<div>${state}</div>`;
|
|
42
|
+
app.start(document.body, 'hello AppRun', view);
|
|
43
|
+
</script>
|
|
24
44
|
```
|
|
25
45
|
|
|
26
|
-
Or,
|
|
46
|
+
Or, use the ESM version:
|
|
47
|
+
```js
|
|
48
|
+
<script type="module">
|
|
49
|
+
import { app } from 'https://unpkg.com/apprun/dist/apprun-html.esm.js';
|
|
50
|
+
const view = state => `<div>${state}</div>`;
|
|
51
|
+
app.start(document.body, 'hello ESM', view);
|
|
52
|
+
</script>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Or, you can create an AppRun app by using the `npm create apprun-app` command.
|
|
27
56
|
|
|
28
57
|
```sh
|
|
29
|
-
npm
|
|
58
|
+
npm create apprun-app [my-app]
|
|
30
59
|
```
|
|
31
60
|
|
|
32
|
-
|
|
61
|
+
Or, you can install AppRun from npm.
|
|
62
|
+
```sh
|
|
63
|
+
npm install apprun
|
|
64
|
+
```
|
|
65
|
+
## Component and Web Component
|
|
66
|
+
|
|
67
|
+
An AppRun component is a mini-application with elm architecture, which means inside a component, there are _state_, _view_, and _update_. In addition, components provide a local scope.
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
class Counter extends Component {
|
|
71
|
+
state = 0;
|
|
72
|
+
view = state => {
|
|
73
|
+
const add = (state, num) => state + num;
|
|
74
|
+
return <>
|
|
75
|
+
<h1>{state}</h1>
|
|
76
|
+
<button $onclick={[add, -1]}>-1</button>
|
|
77
|
+
<button $onclick={[add, +1]}>+1</button>
|
|
78
|
+
</>;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
app.render(document.body, <Counter/>);
|
|
82
|
+
```
|
|
33
83
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
84
|
+
You can convert AppRun components into [web components/custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components). AppRun components become the custom elements that also can handle AppRun events.
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
class Counter extends Component {
|
|
88
|
+
state = 0;
|
|
89
|
+
view = state => {
|
|
90
|
+
const add = (state, num) => state + num;
|
|
91
|
+
return <>
|
|
92
|
+
<h1>{state}</h1>
|
|
93
|
+
<button $onclick={[add, -1]}>-1</button>
|
|
94
|
+
<button $onclick={[add, +1]}>+1</button>
|
|
95
|
+
</>;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
app.webComponent('my-app', Counter);
|
|
99
|
+
app.render(document.body, <my-app />);
|
|
100
|
+
```
|
|
37
101
|
|
|
102
|
+
> [All the Ways to Make a Web Component - May 2021 Update](https://webcomponents.dev/blog/all-the-ways-to-make-a-web-component/) compares the coding style, bundle size, and performance of 55 different ways to make a Web Component. It put AppRun on the top 1/3 of the list of bundle size and performance.
|
|
103
|
+
>
|
|
104
|
+
|
|
105
|
+
### Learn More
|
|
38
106
|
|
|
39
107
|
You can get started with [AppRun Docs](https://apprun.js.org/docs) and [the AppRun Playground](https://apprun.js.org/#play).
|
|
40
108
|
|
|
41
|
-
|
|
109
|
+
### AppRun Book from Apress
|
|
42
110
|
|
|
43
111
|
[](https://www.amazon.com/Practical-Application-Development-AppRun-High-Performance/dp/1484240685/)
|
|
44
112
|
|
|
45
113
|
* [Order from Amazon](https://www.amazon.com/Practical-Application-Development-AppRun-High-Performance/dp/1484240685/)
|
|
46
114
|
|
|
47
115
|
|
|
48
|
-
## AppRun Dev Tools
|
|
49
|
-
To use the AppRun dev-tools, include the dev-tools script.
|
|
50
|
-
|
|
51
|
-
```JavaScript
|
|
52
|
-
<script src="https://unpkg.com/apprun/dist/apprun-dev-tools.js"></script>
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
See the annoucement: [AppRun Dev Tools](https://dev.to/yysun/make-cli-run-in-the-console-42ho)
|
|
56
|
-
|
|
57
|
-
AppRun Dev Tools connects to the Redux DevTools Extension. To use the dev-tools, install the [Redux DevTools Extension](https://github.com/zalmoxisus/redux-devtools-extension). You can monitor the events and states.
|
|
58
|
-
|
|
59
|
-

|
|
60
|
-
|
|
61
116
|
## Contribute
|
|
62
117
|
|
|
63
118
|
You can launch the webpack dev-server and the demo app from the _demo_ folder with the following npm commands:
|
package/WHATSNEW.md
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
## What's New
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### Vite Support
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The command `npm create apprun-app` supports [Vite](https://vitejs.dev/) in addition to esbuild and webpack.
|
|
6
|
+
|
|
7
|
+
### Use React for Rendering View
|
|
8
|
+
|
|
9
|
+
You can use React for rendering view. See [apprun-use-react](https://github.com/yysun/apprun-use-react) for details.
|
|
10
|
+
|
|
11
|
+
> React 18 has breaking changes. Please use React 17 for now.
|
|
12
|
+
|
|
13
|
+
### Create-AppRun-App CLI
|
|
14
|
+
|
|
15
|
+
You can create an AppRun app by running command `npm create apprun-app`.
|
|
6
16
|
|
|
7
17
|
```sh
|
|
8
|
-
npm
|
|
18
|
+
npm create apprun-app [my-app]
|
|
9
19
|
```
|
|
10
20
|
|
|
11
|
-
> Note: AppRun CLI `npx apprun init` is deprecated. Please use `
|
|
21
|
+
> Note: AppRun CLI `npx apprun init` is deprecated. Please use `npm create apprun-app` instead.
|
|
12
22
|
|
|
13
23
|
|
|
14
24
|
## Recent Posts and Publications
|
|
@@ -22,7 +32,7 @@ This post compares the coding style, bundle size, and performance of 55 differen
|
|
|
22
32
|
|
|
23
33
|
This post introduces [apprun-dev-server](https://dev.to/yysun/a-dev-server-supports-esm-3cea), a dev server that provides fast and productive experiences to AppRun application development, so-called unbundled development.
|
|
24
34
|
|
|
25
|
-
|
|
35
|
+
### [Observerble HQ Notebooks](https://observablehq.com/@yysun)
|
|
26
36
|
|
|
27
37
|
* [Introducing AppRun](https://observablehq.com/@yysun/introducing-apprun)
|
|
28
38
|
|
package/apprun.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ declare module 'apprun' {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
export interface IApp {
|
|
40
|
-
start<T, E = any>(element?: Element, model?: T, view?: View<T>, update?: Update<T, E>,
|
|
40
|
+
start<T, E = any>(element?: Element | string, model?: T, view?: View<T>, update?: Update<T, E>,
|
|
41
41
|
options?: AppStartOptions<T>): Component<T, E>;
|
|
42
42
|
on(name: string, fn: (...args: any[]) => void, options?: any): void;
|
|
43
43
|
once(name: string, fn: (...args: any[]) => void, options?: any): void;
|
|
@@ -47,7 +47,7 @@ declare module 'apprun' {
|
|
|
47
47
|
query(name: string, ...args): Promise<any[]>;
|
|
48
48
|
h(tag: string | Function, ...children: any[]): VNode | VNode[];
|
|
49
49
|
createElement(tag: string | Function, ...children: any[]): VNode | VNode[];
|
|
50
|
-
render(element:
|
|
50
|
+
render(element: Element | string, node: VDOM): void;
|
|
51
51
|
Fragment(props: any[], ...children: any[]): any[];
|
|
52
52
|
route?: Route;
|
|
53
53
|
webComponent(name: string, componentClass, options?: CustomElementOptions): void;
|
|
@@ -59,8 +59,8 @@ declare module 'apprun' {
|
|
|
59
59
|
constructor(state?: T, view?: View<T>, update?: Update<T, E>);
|
|
60
60
|
readonly state: T;
|
|
61
61
|
setState(state: T, options?: { render?: boolean, history?: boolean }): void;
|
|
62
|
-
mount(element?: Element, options?: MountOptions): Component<T, E>;
|
|
63
|
-
start(element?: Element, options?: MountOptions): Component<T, E>;
|
|
62
|
+
mount(element?: Element | string, options?: MountOptions): Component<T, E>;
|
|
63
|
+
start(element?: Element | string, options?: MountOptions): Component<T, E>;
|
|
64
64
|
on(name: E, fn: (...args: any[]) => void, options?: any): void;
|
|
65
65
|
run(name: E, ...args: any[]): number;
|
|
66
66
|
rendered: (state: T) => void;
|
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={
|
|
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={752:(e,t,n)=>{n.d(t,{Z:()=>l});let o;const s="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g;s.app&&s._AppRunVersions?o=s.app:(o=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;return s.delay?this.delay(e,o,t,s):Object.keys(s).length>0?o.apply(this,[...t,s]):o.apply(this,t),!n.options.once})),n.length}once(e,t,n={}){this.on(e,t,Object.assign(Object.assign({},n),{once:!0}))}delay(e,t,n,o){o._t&&clearTimeout(o._t),o._t=setTimeout((()=>{clearTimeout(o._t),Object.keys(o).length>0?t.apply(this,[...n,o]):t.apply(this,n)}),o.delay)}query(e,...t){const n=this.getSubscribers(e,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+e);const o=n.map((e=>{const{fn:n,options:o}=e;return Object.keys(o).length>0?n.apply(this,[...t,o]):n.apply(this,t)}));return Promise.all(o)}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=>Object.assign(Object.assign({},t),{options:Object.assign(Object.assign({},t.options),{event:e})})))))),n}},s.app=o,s._AppRunVersions="AppRun-3");const l=o}},t={};function n(o){var s=t[o];if(void 0!==s)return s.exports;var l=t[o]={exports:{}};return e[o](l,l.exports,n),l.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),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o);var e=n(752);function t(e){return e.map((e=>l(e))).join("")}function s(e){for(var t in e)null==e[t]?delete e[t]:"object"==typeof e[t]&&s(e[t])}function l(e){if(!e)return"";if("_$litType$"in e)return e.toString();if(s(e),Array.isArray(e))return t(e);if("string"==typeof e)return e.startsWith("_html:")?e.substring(6):e;if(e.tag){const n=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):"",o=e.children?t(e.children):"";return`<${e.tag}${n}>${o}</${e.tag}>`}return"object"==typeof e?JSON.stringify(e):void 0}const r=l;let c;function i(e){c=window.open("",e),c.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 a(e){c.document.write(e+"\n")}function p(){c.document.write("</pre>\n </body>\n </html>"),c.document.close()}app.debug=!0;const u=e=>{a(`import ${e.constructor.name} from '../src/${e.constructor.name}'`),a(`describe('${e.constructor.name}', ()=>{`),e._actions.forEach((t=>{"."!==t.name&&(a(` it ('should handle event: ${t.name}', (done)=>{`),a(` const component = new ${e.constructor.name}().mount();`),a(` component.run('${t.name}');`),a(" setTimeout(() => {"),a(" //expect(?).toHaveBeenCalled();"),a(" //expect(component.state).toBe(?);"),a(" done();"),a(" })"))})),a("});")};let f=!1,d=[];app.on("debug",(e=>{f&&e.vdom&&(d.push(e),console.log(`* ${d.length} state(s) recorded.`))}));var m;function h(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()}e.Z.debug=!0,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 g=()=>{const t={components:{}};e.Z.run("get-components",t);const{components:n}=t;return n};let v=Number(null===(m=null===window||void 0===window?void 0:window.localStorage)||void 0===m?void 0:m.getItem("__apprun_debugging__"))||0;if(e.Z.on("debug",(e=>{1&v&&e.event&&console.log(e),2&v&&e.vdom&&console.log(e)})),window["_apprun-components"]=["components [print]",t=>{(t=>{const n=g(),o=[];if(n instanceof Map)for(let[e,t]of n){const n="string"==typeof e?document.getElementById(e)||document.querySelector(e):e;o.push({element:n,comps:t})}else Object.keys(n).forEach((e=>{const t="string"==typeof e?document.getElementById(e)||document.querySelector(e):e;o.push({element:t,comps:n[e]})}));if(t){const t=(t=>{const n=({events:t})=>e.Z.h("ul",null,t&&t.filter((e=>"."!==e.name)).map((t=>e.Z.h("li",null,t.name)))),o=({components:t})=>e.Z.h("ul",null,t.map((t=>e.Z.h("li",null,e.Z.h("div",null,t.constructor.name),e.Z.h(n,{events:t._actions})))));return e.Z.h("ul",null,t.map((({element:t,comps:n})=>e.Z.h("li",null,e.Z.h("div",null,(t=>e.Z.h("div",null,t.tagName.toLowerCase(),t.id?"#"+t.id:""," ",t.className&&t.className.split(" ").map((e=>"."+e)).join()))(t)),e.Z.h(o,{components:n})))))})(o);h(r(t))}else o.forEach((({element:e,comps:t})=>console.log(e,t)))})("print"===t)}],window["_apprun-events"]=["events [print]",t=>{(t=>{const n=e.Z._events,o={},s=g(),l=e=>e._actions.forEach((t=>{o[t.name]=o[t.name]||[],o[t.name].push(e)}));if(s instanceof Map)for(let[e,t]of s)t.forEach(l);else Object.keys(s).forEach((e=>s[e].forEach(l)));const c=[];if(Object.keys(o).forEach((e=>{c.push({event:e,components:o[e],global:!!n[e]})})),c.sort(((e,t)=>e.event>t.event?1:-1)).map((e=>e.event)),t){const t=(t=>{const n=({components:t})=>e.Z.h("ul",null,t.map((t=>e.Z.h("li",null,e.Z.h("div",null,t.constructor.name))))),o=({events:t,global:o})=>e.Z.h("ul",null,t&&t.filter((e=>e.global===o&&"."!==e.event)).map((({event:t,components:o})=>e.Z.h("li",null,e.Z.h("div",null,t),e.Z.h(n,{components:o})))));return e.Z.h("div",null,e.Z.h("div",null,"GLOBAL EVENTS"),e.Z.h(o,{events:t,global:!0}),e.Z.h("div",null,"LOCAL EVENTS"),e.Z.h(o,{events:t,global:!1}))})(c);h(r(t))}else console.log("=== GLOBAL EVENTS ==="),c.filter((e=>e.global&&"."!==e.event)).forEach((({event:e,components:t})=>console.log({event:e},t))),console.log("=== LOCAL EVENTS ==="),c.filter((e=>!e.global&&"."!==e.event)).forEach((({event:e,components:t})=>console.log({event:e},t)))})("print"===t)}],window["_apprun-log"]=["log [event|view] on|off",(e,t)=>{var n;"on"===e?v=3:"off"===e?v=0:"event"===e?"on"===t?v|=1:"off"===t&&(v&=-2):"view"===e&&("on"===t?v|=2:"off"===t&&(v&=-3)),console.log(`* log ${e} ${t||""}`),null===(n=null===window||void 0===window?void 0:window.localStorage)||void 0===n||n.setItem("__apprun_debugging__",`${v}`)}],window["_apprun-create-event-tests"]=["create-event-tests",()=>(()=>{const e={components:{}};app.run("get-components",e);const{components:t}=e;if(i(""),t instanceof Map)for(let[e,n]of t)n.forEach(u);else Object.keys(t).forEach((e=>{t[e].forEach(u)}));p()})()],window["_apprun-create-state-tests"]=["create-state-tests <start|stop>",e=>{var t;"start"===(t=e)?(d=[],f=!0,console.log("* State logging started.")):"stop"===t?(0!==d.length?(i(""),d.forEach(((e,t)=>{a(` it ('view snapshot: #${t+1}', ()=>{`),a(` const component = new ${e.component.constructor.name}()`),a(` const state = ${JSON.stringify(e.state,void 0,2)};`),a(" const vdom = component['view'](state);"),a(" expect(JSON.stringify(vdom)).toMatchSnapshot();"),a(" })")})),p()):console.log("* No state recorded."),f=!1,d=[],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 2.27: type "_apprun `help`" to list all available commands.'),window.__REDUX_DEVTOOLS_EXTENSION__){let t=!1;const n=window.__REDUX_DEVTOOLS_EXTENSION__.connect();if(n){const o=location.hash||"#";n.send(o,"");const s=[{component:null,state:""}];console.info("Connected to the Redux DevTools"),n.subscribe((n=>{if("START"===n.type)t=!0;else if("STOP"===n.type)t=!1;else if("DISPATCH"===n.type){const t=n.payload.index;if(0===t)e.Z.run(o);else{const{component:e,state:n}=s[t];null==e||e.setState(n)}}}));const l=(e,t,o)=>{null!=o&&(s.push({component:e,state:o}),n.send(t,o))};e.Z.on("debug",(e=>{if(t&&e.event){const t=e.newState,n={type:e.event,payload:e.p},o=e.component;t instanceof Promise?t.then((e=>l(o,n,e))):l(o,n,t)}}))}}})(),o})()));
|
|
2
2
|
//# sourceMappingURL=apprun-dev-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
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,IARnB,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,GCD1BA,EAAoBC,EAAI,WACvB,GAA0B,iBAAfC,WAAyB,OAAOA,WAC3C,IACC,OAAOH,MAAQ,IAAII,SAAS,cAAb,GACd,MAAOC,GACR,GAAsB,iBAAXC,OAAqB,OAAOA,QALjB,GCCxBL,EAAoBM,EAAKX,I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,MAAMyD,EAAQpB,EAAE0D,SAGV5D,EAAS,CAAEwD,KAFJtD,EAAErC,MAEQ4F,QADPvD,EAAEA,GAEZJ,EAAYI,EAAEJ,UAChBwB,aAAiBnE,QACnBmE,EAAMuC,MAAKnB,GAAKU,EAAKtD,EAAWE,EAAQ0C,KAExCU,EAAKtD,EAAWE,EAAQsB,Q","sources":["webpack://apprun/webpack/universalModuleDefinition","webpack://apprun/webpack/bootstrap","webpack://apprun/webpack/runtime/global","webpack://apprun/webpack/runtime/make namespace object","webpack://apprun/./src/app.ts","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 ","// The require scope\nvar __webpack_require__ = {};\n\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})();","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { EventOptions} from './types'\nexport class App {\n\n private _events: Object;\n\n public start;\n public h;\n public createElement;\n public render;\n public Fragment;\n public webComponent;\n public safeHTML;\n\n constructor() {\n this._events = {};\n }\n\n on(name: string, fn: (...args) => void, 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) => void): 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): 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 (options.delay) {\n this.delay(name, fn, args, options);\n } else {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }\n return !sub.options.once;\n });\n\n return subscribers.length;\n }\n\n once(name: string, fn, options: EventOptions = {}): void {\n this.on(name, fn, { ...options, once: true });\n }\n\n private delay(name, fn, args, options): void {\n if (options._t) clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }, options.delay);\n }\n\n query(name: string, ...args): 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 return Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n });\n return Promise.all(promises);\n }\n\n private getSubscribers(name: string, events) {\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-3';\nlet app: App;\nconst root = (typeof self === 'object' && self.self === self && self) ||\n (typeof global === 'object' && global.global === global && global)\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","\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 ('_$litType$' in vdom) {\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\napp['debug'] = true;\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 get_components = () => {\n const o = { components: {} };\n app.run('get-components', o);\n const { components } = o;\n return components;\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\n const Events = ({ events }) => <ul>\n {events && events.filter(event => event.name !== '.').map(event => <li>\n {event.name}\n </li>)}\n </ul>;\n\n const Components = ({ components }) => <ul>\n {components.map(component => <li>\n <div>{component.constructor.name}</div>\n <Events events={component['_actions']} />\n </li>)}\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\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 = get_components();\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 } else {\n Object.keys(cache).forEach(el =>\n cache[el].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 = get_components();\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) : key;\n data.push({ element, comps });\n }\n } else {\n Object.keys(components).forEach(el => {\n const element = typeof el === 'string' ? document.getElementById(el) : el;\n data.push({ element, comps: components[el] });\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]', (p) => {\n _components(p === 'print');\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 2.27: 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","__webpack_require__","g","globalThis","Function","e","window","r","Symbol","toStringTag","Object","defineProperty","value","self","global","constructor","_events","on","name","fn","options","push","off","subscribers","filter","sub","find","run","args","getSubscribers","console","assert","length","forEach","delay","keys","apply","once","_t","clearTimeout","setTimeout","query","promises","map","Promise","all","events","evt","endsWith","startsWith","replace","sort","a","b","event","toHTMLArray","nodes","node","toHTML","join","clean","obj","i","vdom","toString","Array","isArray","substring","tag","props","prop","toProps","children","JSON","stringify","win","openWin","open","document","write","location","href","text","closeWin","close","app","print_component_test","component","_actions","action","recording","p","log","newWin","html","cmd","get_components","o","components","debugging","Number","localStorage","getItem","print","data","Map","key","comps","element","getElementById","el","state","Events","Components","tagName","toLowerCase","id","className","split","c","viewElement","viewComponents","_components","global_events","cache","add_component","viewEvents","a1","a2","setItem","_createEventTests","s","idx","undefined","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,IARnB,CASGK,MAAM,I,yDCiFT,IAAIC,EACJ,MAAMP,EAAwB,iBAATQ,MAAqBA,KAAKA,OAASA,MAAQA,MAC3C,iBAAX,EAAAC,GAAuB,EAAAA,EAAOC,SAAW,EAAAD,GAAU,EAAAA,EACzDT,EAAU,KAAKA,EAAsB,gBACvCO,EAAMP,EAAU,KAEhBO,EAAM,IA/FD,MAYLI,cACEL,KAAKM,QAAU,GAGjBC,GAAGC,EAAcC,EAAuBC,EAAwB,IAC9DV,KAAKM,QAAQE,GAAQR,KAAKM,QAAQE,IAAS,GAC3CR,KAAKM,QAAQE,GAAMG,KAAK,CAAEF,GAAAA,EAAIC,QAAAA,IAGhCE,IAAIJ,EAAcC,GAChB,MAAMI,EAAcb,KAAKM,QAAQE,IAAS,GAE1CR,KAAKM,QAAQE,GAAQK,EAAYC,QAAQC,GAAQA,EAAIN,KAAOA,IAG9DO,KAAKR,GACH,OAAOR,KAAKM,QAAQE,GAGtBS,IAAIT,KAAiBU,GACnB,MAAML,EAAcb,KAAKmB,eAAeX,EAAMR,KAAKM,SAYnD,OAXAc,QAAQC,OAAOR,GAAeA,EAAYS,OAAS,EAAG,4BAA8Bd,GACpFK,EAAYU,SAASR,IACnB,MAAM,GAAEN,EAAE,QAAEC,GAAYK,EAMxB,OALIL,EAAQc,MACVxB,KAAKwB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rD,EAAEA,GAEZJ,EAAYI,EAAEJ,UAChBuB,aAAiBzF,QACnByF,EAAMsC,MAAKlB,GAAKS,EAAKpD,EAAWE,EAAQyC,KAExCS,EAAKpD,EAAWE,EAAQqB,U","sources":["webpack://apprun/webpack/universalModuleDefinition","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/webpack/runtime/make namespace object","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 ","import { EventOptions} from './types'\nexport class App {\n\n private _events: Object;\n\n public start;\n public h;\n public createElement;\n public render;\n public Fragment;\n public webComponent;\n public safeHTML;\n\n constructor() {\n this._events = {};\n }\n\n on(name: string, fn: (...args) => void, 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) => void): 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): 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 (options.delay) {\n this.delay(name, fn, args, options);\n } else {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }\n return !sub.options.once;\n });\n\n return subscribers.length;\n }\n\n once(name: string, fn, options: EventOptions = {}): void {\n this.on(name, fn, { ...options, once: true });\n }\n\n private delay(name, fn, args, options): void {\n if (options._t) clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }, options.delay);\n }\n\n query(name: string, ...args): 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 return Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n });\n return Promise.all(promises);\n }\n\n private getSubscribers(name: string, events) {\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-3';\nlet app: App;\nconst root = (typeof self === 'object' && self.self === self && self) ||\n (typeof global === 'object' && global.global === global && global)\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))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","\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 ('_$litType$' in vdom) {\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\napp['debug'] = true;\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 get_components = () => {\n const o = { components: {} };\n app.run('get-components', o);\n const { components } = o;\n return components;\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\n const Events = ({ events }) => <ul>\n {events && events.filter(event => event.name !== '.').map(event => <li>\n {event.name}\n </li>)}\n </ul>;\n\n const Components = ({ components }) => <ul>\n {components.map(component => <li>\n <div>{component.constructor.name}</div>\n <Events events={component['_actions']} />\n </li>)}\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\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 = get_components();\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 } else {\n Object.keys(cache).forEach(el =>\n cache[el].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 = get_components();\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 } else {\n Object.keys(components).forEach(el => {\n const element = typeof el === 'string' ? document.getElementById(el) || document.querySelector(el): el;\n data.push({ element, comps: components[el] });\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]', (p) => {\n _components(p === 'print');\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 2.27: 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","app","self","g","global","constructor","_events","on","name","fn","options","push","off","subscribers","filter","sub","find","run","args","getSubscribers","console","assert","length","forEach","delay","Object","keys","apply","once","_t","clearTimeout","setTimeout","query","promises","map","Promise","all","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","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","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","newWin","html","cmd","get_components","components","debugging","Number","localStorage","getItem","print","data","Map","comps","element","getElementById","querySelector","el","state","Events","Components","tagName","toLowerCase","id","className","split","c","viewElement","viewComponents","_components","global_events","cache","add_component","viewEvents","a1","a2","setItem","_createEventTests","s","idx","strings","command","info","devTools_running","devTools","connect","hash","send","buf","subscribe","message","type","payload","index","setState","newState","then"],"sourceRoot":""}
|
package/dist/apprun-html.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
class t{constructor(){this._events={}}on(t,i,s={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:i,options:s})}off(t,i){const s=this._events[t]||[];this._events[t]=s.filter((t=>t.fn!==i))}find(t){return this._events[t]}run(t,...i){const s=this.getSubscribers(t,this._events);return console.assert(s&&s.length>0,"No subscriber for event: "+t),s.forEach((s=>{const{fn:n,options:e}=s;return e.delay?this.delay(t,n,i,e):Object.keys(e).length>0?n.apply(this,[...i,e]):n.apply(this,i),!s.options.once})),s.length}once(t,i,s={}){this.on(t,i,Object.assign(Object.assign({},s),{once:!0}))}delay(t,i,s,n){n._t&&clearTimeout(n._t),n._t=setTimeout((()=>{clearTimeout(n._t),Object.keys(n).length>0?i.apply(this,[...s,n]):i.apply(this,s)}),n.delay)}query(t,...i){const s=this.getSubscribers(t,this._events);console.assert(s&&s.length>0,"No subscriber for event: "+t);const n=s.map((t=>{const{fn:s,options:n}=t;return Object.keys(n).length>0?s.apply(this,[...i,n]):s.apply(this,i)}));return Promise.all(n)}getSubscribers(t,i){const s=i[t]||[];return i[t]=s.filter((t=>!t.options.once)),Object.keys(i).filter((i=>i.endsWith("*")&&t.startsWith(i.replace("*","")))).sort(((t,i)=>i.length-t.length)).forEach((n=>s.push(...i[n].map((i=>Object.assign(Object.assign({},i),{options:Object.assign(Object.assign({},i.options),{event:t})})))))),s}}let i;const s="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;s.app&&s._AppRunVersions?i=s.app:(i=new t,s.app=i,s._AppRunVersions="AppRun-3");var n=i;const e=(t,i)=>(i?t.state[i]:t.state)||"",o=(t,i,s)=>{if(i){const n=t.state||{};n[i]=s,t.setState(n)}else t.setState(s)},r=(t,i)=>{if(Array.isArray(t))return t.map((t=>r(t,i)));{let{tag:s,props:h,children:c}=t;return s?(h&&Object.keys(h).forEach((t=>{t.startsWith("$")&&(((t,i,s,r)=>{if(t.startsWith("$on")){const s=i[t];if(t=t.substring(1),"boolean"==typeof s)i[t]=i=>r.run?r.run(t,i):n.run(t,i);else if("string"==typeof s)i[t]=t=>r.run?r.run(s,t):n.run(s,t);else if("function"==typeof s)i[t]=t=>r.setState(s(r.state,t));else if(Array.isArray(s)){const[e,...o]=s;"string"==typeof e?i[t]=t=>r.run?r.run(e,...o,t):n.run(e,...o,t):"function"==typeof e&&(i[t]=t=>r.setState(e(r.state,...o,t)))}}else if("$bind"===t){const n=i.type||"text",h="string"==typeof i[t]?i[t]:i.name;if("input"===s)switch(n){case"checkbox":i.checked=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.checked);break;case"radio":i.checked=e(r,h)===i.value,i.onclick=t=>o(r,h||t.target.name,t.target.value);break;case"number":case"range":i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,Number(t.target.value));break;default:i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value)}else"select"===s?(i.value=e(r,h),i.onchange=t=>{t.target.multiple||o(r,h||t.target.name,t.target.value)}):"option"===s?(i.selected=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.selected)):"textarea"===s&&(i.innerHTML=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value))}else n.run("$",{key:t,tag:s,props:i,component:r})})(t,h,s,i),delete h[t])})),c&&(c=r(c,i)),{tag:s,props:h,children:c}):t}};function h(t,...i){return c(i)}function c(t){const i=[],s=t=>{null!=t&&""!==t&&!1!==t&&i.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>s(t))):s(t)})),i}function l(t,i,...s){const n=c(s);if("string"==typeof t)return{tag:t,props:i,children:n};if(Array.isArray(t))return t;if(void 0===t&&s)return n;if(Object.getPrototypeOf(t).t)return{tag:t,props:i,children:n};if("function"==typeof t)return t(i,n);throw new Error(`Unknown tag in vdom ${t}`)}const u=new WeakMap,d=(t,i,s={})=>{null!=i&&!1!==i&&function(t,i,s={}){if(null==i||!1===i)return;i=g(i,s);const n="SVG"===(null==t?void 0:t.nodeName);if(!t)return;Array.isArray(i)?f(t,i,n):f(t,[i],n)}(t,i=r(i,s),s)};function a(t,i,s){3!==i._op&&(s=s||"svg"===i.tag,!function(t,i){const s=t.nodeName,n=`${i.tag||""}`;return s.toUpperCase()===n.toUpperCase()}(t,i)?t.parentNode.replaceChild(y(i,s),t):(!(2&i._op)&&f(t,i.children,s),!(1&i._op)&&b(t,i.props,s)))}function f(t,i,s){var n,e;const o=(null===(n=t.childNodes)||void 0===n?void 0:n.length)||0,r=(null==i?void 0:i.length)||0,h=Math.min(o,r);for(let n=0;n<h;n++){const e=i[n];if(3===e._op)continue;const o=t.childNodes[n];if("string"==typeof e)o.textContent!==e&&(3===o.nodeType?o.nodeValue=e:t.replaceChild(p(e),o));else if(e instanceof HTMLElement||e instanceof SVGElement)t.insertBefore(e,o);else{const i=e.props&&e.props.key;if(i)if(o.key===i)a(t.childNodes[n],e,s);else{const r=u[i];if(r){const i=r.nextSibling;t.insertBefore(r,o),i?t.insertBefore(o,i):t.appendChild(o),a(t.childNodes[n],e,s)}else t.replaceChild(y(e,s),o)}else a(t.childNodes[n],e,s)}}let c=(null===(e=t.childNodes)||void 0===e?void 0:e.length)||0;for(;c>h;)t.removeChild(t.lastChild),c--;if(r>h){const n=document.createDocumentFragment();for(let t=h;t<i.length;t++)n.appendChild(y(i[t],s));t.appendChild(n)}}const v=t=>{const i=document.createElement("section");return i.insertAdjacentHTML("afterbegin",t),Array.from(i.children)};function p(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const i=document.createElement("div");return i.insertAdjacentHTML("afterbegin",t.substring(6)),i}return document.createTextNode(null!=t?t:"")}function y(t,i){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return p(t);if(!t.tag||"function"==typeof t.tag)return p(JSON.stringify(t));const s=(i=i||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return b(s,t.props,i),t.children&&t.children.forEach((t=>s.appendChild(y(t,i)))),s}function b(t,i,s){const n=t._props||{};i=function(t,i){i.class=i.class||i.className,delete i.className;const s={};return t&&Object.keys(t).forEach((t=>s[t]=null)),i&&Object.keys(i).forEach((t=>s[t]=i[t])),s}(n,i||{}),t._props=i;for(const n in i){const e=i[n];if(n.startsWith("data-")){const i=n.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[i]!==e&&(e||""===e?t.dataset[i]=e:delete t.dataset[i])}else if("style"===n)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof e)t.style.cssText=e;else for(const i in e)t.style[i]!==e[i]&&(t.style[i]=e[i]);else if(n.startsWith("xlink")){const i=n.replace("xlink","").toLowerCase();null==e||!1===e?t.removeAttributeNS("http://www.w3.org/1999/xlink",i):t.setAttributeNS("http://www.w3.org/1999/xlink",i,e)}else n.startsWith("on")?e&&"function"!=typeof e?"string"==typeof e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]=e:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-/g.test(n)||s?t.getAttribute(n)!==e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]!==e&&(t[n]=e);"key"===n&&e&&(u[e]=t)}i&&"function"==typeof i.ref&&window.requestAnimationFrame((()=>i.ref(t)))}function g(t,i,s=0){var n;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>g(t,i,s++)));let e=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).t&&(e=function(t,i,s){const{tag:n,props:e,children:o}=t;let r=`_${s}`,h=e&&e.id;h?r=h:h=`_${s}${Date.now()}`;let c="section";e&&e.as&&(c=e.as,delete e.as),i.i||(i.i={});let l=i.i[r];if(!(l&&l instanceof n&&l.element)){const t=document.createElement(c);l=i.i[r]=new n(Object.assign(Object.assign({},e),{children:o})).start(t)}if(l.mounted){const t=l.mounted(e,o,l.state);void 0!==t&&l.setState(t)}return b(l.element,e,!1),l.element}(t,i,s)),e&&Array.isArray(e.children)){const t=null===(n=e.props)||void 0===n?void 0:n._component;if(t){let i=0;e.children=e.children.map((s=>g(s,t,i++)))}else e.children=e.children.map((t=>g(t,i,s++)))}return e}const w=(t,i={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(i.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const s=i||{};this._shadowRoot=s.shadow?this.attachShadow({mode:"open"}):this;const n=s.observedAttributes||[],e=n.reduce(((t,i)=>{const s=i.toLowerCase();return s!==i&&(t[s]=i),t}),{});this._attrMap=t=>e[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),n.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(i){this.attributeChangedCallback(t,o[t],i)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const i=this.children?Array.from(this.children):[];if(i.forEach((t=>t.parentElement.removeChild(t))),this._component=new t(Object.assign(Object.assign({},o),{children:i})).mount(this._shadowRoot,s),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,i,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==s.render&&this._component.run(".")}))}}disconnectedCallback(){var t,i,s,n;null===(i=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===i||i.call(t),null===(n=null===(s=this._component)||void 0===s?void 0:s.unmount)||void 0===n||n.call(s),this._component=null}attributeChangedCallback(t,s,n){if(this._component){const e=this._attrMap(t);this._component._props[e]=n,this._component.run("attributeChanged",e,s,n),n!==s&&!1!==i.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var m=(t,i,s)=>{"undefined"!=typeof customElements&&customElements.define(t,w(i,s))};const $={meta:new WeakMap,defineMetadata(t,i,s){this.meta.has(s)||this.meta.set(s,{}),this.meta.get(s)[t]=i},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,i){return i=Object.getPrototypeOf(i),this.meta.get(i)?this.meta.get(i)[t]:null}};function j(t,i={}){return(s,n,e)=>{const o=t?t.toString():n;return $.defineMetadata(`apprun-update:${o}`,{name:o,key:n,options:i},s),e}}function A(t,i={}){return function(s,n){const e=t?t.toString():n;$.defineMetadata(`apprun-update:${e}`,{name:e,key:n,options:i},s)}}function O(t,i){return function(s){return m(t,s,i),s}}const _=new Map;n.on("get-components",(t=>t.components=_));const x=t=>t;class k{constructor(i,s,n,e){this.state=i,this.view=s,this.update=n,this.options=e,this._app=new t,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,i)=>this.mount(t,Object.assign({render:!0},i))}renderState(t,i=null){if(!this.view)return;let s=i||this.view(t);if(n.debug&&n.run("debug",{component:this,_:s?".":"-",state:t,vdom:s,el:this.element}),"object"!=typeof document)return;const e="string"==typeof this.element?document.getElementById(this.element):this.element;if(e){const t="_c";this.unload?e._component===this&&e.getAttribute(t)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),e.setAttribute(t,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(e)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[t]}))):e.removeAttribute&&e.removeAttribute(t),e._component=this}!i&&s&&(s=r(s,this),n.render(e,s,this)),this.rendered&&this.rendered(this.state)}setState(t,i={render:!0,history:!1}){if(t instanceof Promise)Promise.all([t,this._state]).then((t=>{t[0]&&this.setState(t[0])})).catch((t=>{throw console.error(t),t})),this._state=t;else{if(this._state=t,null==t)return;this.state=t,!1!==i.render&&this.renderState(t),!1!==i.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof i.callback&&i.callback(this.state)}}mount(t=null,i){var s,e;return console.assert(!this.element,"Component already mounted."),this.options=i=Object.assign(Object.assign({},this.options),i),this.element=t,this.global_event=i.global_event,this.enable_history=!!i.history,this.enable_history&&(this.on(i.history.prev||"history-prev",this._history_prev),this.on(i.history.next||"history-next",this._history_next)),i.route&&(this.update=this.update||{},this.update[i.route]||(this.update[i.route]=x)),this.add_actions(),this.state=null!==(e=null!==(s=this.state)&&void 0!==s?s:this.model)&&void 0!==e?e:{},"function"==typeof this.state&&(this.state=this.state()),i.render?this.setState(this.state,{render:!0,history:!0}):this.setState(this.state,{render:!1,history:!0}),n.debug&&(_.get(t)?_.get(t).push(this):_.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,i,s={}){i&&"function"==typeof i&&(s.global&&this._global_events.push(t),this.on(t,((...e)=>{n.debug&&n.run("debug",{component:this,_:">",event:t,p:e,current_state:this.state,options:s});const o=i(this.state,...e);n.debug&&n.run("debug",{component:this,_:"<",event:t,p:e,newState:o,state:this.state,options:s}),this.setState(o,s)}),s))}add_actions(){const t=this.update||{};$.getMetadataKeys(this).forEach((i=>{if(i.startsWith("apprun-update:")){const s=$.getMetadata(i,this);t[s.name]=[this[s.key].bind(this),s.options]}}));const i={};Array.isArray(t)?t.forEach((t=>{const[s,n,e]=t;s.toString().split(",").forEach((t=>i[t.trim()]=[n,e]))})):Object.keys(t).forEach((s=>{const n=t[s];("function"==typeof n||Array.isArray(n))&&s.split(",").forEach((t=>i[t.trim()]=n))})),i["."]||(i["."]=x),Object.keys(i).forEach((t=>{const s=i[t];"function"==typeof s?this.add_action(t,s):Array.isArray(s)&&this.add_action(t,s[0],s[1])}))}run(t,...i){const s=t.toString();return this.is_global_event(s)?n.run(s,...i):this._app.run(s,...i)}on(t,i,s){const e=t.toString();return this._actions.push({name:e,fn:i}),this.is_global_event(e)?n.on(e,i,s):this._app.on(e,i,s)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:i,fn:s}=t;this.is_global_event(i)?n.off(i,s):this._app.off(i,s)}))}}k.t=!0;const T="//",M="///",E=t=>{if(t||(t="#"),t.startsWith("#")){const[i,...s]=t.split("/");n.run(i,...s)||n.run("///",i,...s),n.run("//",i,...s)}else if(t.startsWith("/")){const[i,s,...e]=t.split("/");n.run("/"+s,...e)||n.run("///","/"+s,...e),n.run("//","/"+s,...e)}else n.run(t)||n.run("///",t),n.run("//",t)};n.h=n.createElement=l,n.render=d,n.Fragment=h,n.webComponent=m,n.safeHTML=v,n.start=(t,i,s,n,e)=>{const o=Object.assign({render:!0,global_event:!0},e),r=new k(i,s,n);return e&&e.rendered&&(r.rendered=e.rendered),r.mount(t,o),r};const C=t=>{};
|
|
1
|
+
class t{constructor(){this._events={}}on(t,i,s={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:i,options:s})}off(t,i){const s=this._events[t]||[];this._events[t]=s.filter((t=>t.fn!==i))}find(t){return this._events[t]}run(t,...i){const s=this.getSubscribers(t,this._events);return console.assert(s&&s.length>0,"No subscriber for event: "+t),s.forEach((s=>{const{fn:n,options:e}=s;return e.delay?this.delay(t,n,i,e):Object.keys(e).length>0?n.apply(this,[...i,e]):n.apply(this,i),!s.options.once})),s.length}once(t,i,s={}){this.on(t,i,Object.assign(Object.assign({},s),{once:!0}))}delay(t,i,s,n){n._t&&clearTimeout(n._t),n._t=setTimeout((()=>{clearTimeout(n._t),Object.keys(n).length>0?i.apply(this,[...s,n]):i.apply(this,s)}),n.delay)}query(t,...i){const s=this.getSubscribers(t,this._events);console.assert(s&&s.length>0,"No subscriber for event: "+t);const n=s.map((t=>{const{fn:s,options:n}=t;return Object.keys(n).length>0?s.apply(this,[...i,n]):s.apply(this,i)}));return Promise.all(n)}getSubscribers(t,i){const s=i[t]||[];return i[t]=s.filter((t=>!t.options.once)),Object.keys(i).filter((i=>i.endsWith("*")&&t.startsWith(i.replace("*","")))).sort(((t,i)=>i.length-t.length)).forEach((n=>s.push(...i[n].map((i=>Object.assign(Object.assign({},i),{options:Object.assign(Object.assign({},i.options),{event:t})})))))),s}}let i;const s="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;s.app&&s._AppRunVersions?i=s.app:(i=new t,s.app=i,s._AppRunVersions="AppRun-3");var n=i;const e=(t,i)=>(i?t.state[i]:t.state)||"",o=(t,i,s)=>{if(i){const n=t.state||{};n[i]=s,t.setState(n)}else t.setState(s)},r=(t,i)=>{if(Array.isArray(t))return t.map((t=>r(t,i)));{let{tag:s,props:h,children:c}=t;return s?(h&&Object.keys(h).forEach((t=>{t.startsWith("$")&&(((t,i,s,r)=>{if(t.startsWith("$on")){const s=i[t];if(t=t.substring(1),"boolean"==typeof s)i[t]=i=>r.run?r.run(t,i):n.run(t,i);else if("string"==typeof s)i[t]=t=>r.run?r.run(s,t):n.run(s,t);else if("function"==typeof s)i[t]=t=>r.setState(s(r.state,t));else if(Array.isArray(s)){const[e,...o]=s;"string"==typeof e?i[t]=t=>r.run?r.run(e,...o,t):n.run(e,...o,t):"function"==typeof e&&(i[t]=t=>r.setState(e(r.state,...o,t)))}}else if("$bind"===t){const n=i.type||"text",h="string"==typeof i[t]?i[t]:i.name;if("input"===s)switch(n){case"checkbox":i.checked=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.checked);break;case"radio":i.checked=e(r,h)===i.value,i.onclick=t=>o(r,h||t.target.name,t.target.value);break;case"number":case"range":i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,Number(t.target.value));break;default:i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value)}else"select"===s?(i.value=e(r,h),i.onchange=t=>{t.target.multiple||o(r,h||t.target.name,t.target.value)}):"option"===s?(i.selected=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.selected)):"textarea"===s&&(i.innerHTML=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value))}else n.run("$",{key:t,tag:s,props:i,component:r})})(t,h,s,i),delete h[t])})),c&&(c=r(c,i)),{tag:s,props:h,children:c}):t}};function h(t,...i){return c(i)}function c(t){const i=[],s=t=>{null!=t&&""!==t&&!1!==t&&i.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>s(t))):s(t)})),i}function l(t,i,...s){const n=c(s);if("string"==typeof t)return{tag:t,props:i,children:n};if(Array.isArray(t))return t;if(void 0===t&&s)return n;if(Object.getPrototypeOf(t).t)return{tag:t,props:i,children:n};if("function"==typeof t)return t(i,n);throw new Error(`Unknown tag in vdom ${t}`)}const u=new WeakMap,d=(t,i,s={})=>{if(null==i||!1===i)return;!function(t,i,s={}){if(null==i||!1===i)return;if(i=g(i,s),!t)return;const n="SVG"===t.nodeName;Array.isArray(i)?f(t,i,n):f(t,[i],n)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,i=r(i,s),s)};function a(t,i,s){3!==i._op&&(s=s||"svg"===i.tag,!function(t,i){const s=t.nodeName,n=`${i.tag||""}`;return s.toUpperCase()===n.toUpperCase()}(t,i)?t.parentNode.replaceChild(y(i,s),t):(!(2&i._op)&&f(t,i.children,s),!(1&i._op)&&b(t,i.props,s)))}function f(t,i,s){var n,e;const o=(null===(n=t.childNodes)||void 0===n?void 0:n.length)||0,r=(null==i?void 0:i.length)||0,h=Math.min(o,r);for(let n=0;n<h;n++){const e=i[n];if(3===e._op)continue;const o=t.childNodes[n];if("string"==typeof e)o.textContent!==e&&(3===o.nodeType?o.nodeValue=e:t.replaceChild(p(e),o));else if(e instanceof HTMLElement||e instanceof SVGElement)t.insertBefore(e,o);else{const i=e.props&&e.props.key;if(i)if(o.key===i)a(t.childNodes[n],e,s);else{const r=u[i];if(r){const i=r.nextSibling;t.insertBefore(r,o),i?t.insertBefore(o,i):t.appendChild(o),a(t.childNodes[n],e,s)}else t.replaceChild(y(e,s),o)}else a(t.childNodes[n],e,s)}}let c=(null===(e=t.childNodes)||void 0===e?void 0:e.length)||0;for(;c>h;)t.removeChild(t.lastChild),c--;if(r>h){const n=document.createDocumentFragment();for(let t=h;t<i.length;t++)n.appendChild(y(i[t],s));t.appendChild(n)}}const v=t=>{const i=document.createElement("section");return i.insertAdjacentHTML("afterbegin",t),Array.from(i.children)};function p(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const i=document.createElement("div");return i.insertAdjacentHTML("afterbegin",t.substring(6)),i}return document.createTextNode(null!=t?t:"")}function y(t,i){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return p(t);if(!t.tag||"function"==typeof t.tag)return p(JSON.stringify(t));const s=(i=i||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return b(s,t.props,i),t.children&&t.children.forEach((t=>s.appendChild(y(t,i)))),s}function b(t,i,s){const n=t._props||{};i=function(t,i){i.class=i.class||i.className,delete i.className;const s={};return t&&Object.keys(t).forEach((t=>s[t]=null)),i&&Object.keys(i).forEach((t=>s[t]=i[t])),s}(n,i||{}),t._props=i;for(const n in i){const e=i[n];if(n.startsWith("data-")){const i=n.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[i]!==e&&(e||""===e?t.dataset[i]=e:delete t.dataset[i])}else if("style"===n)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof e)t.style.cssText=e;else for(const i in e)t.style[i]!==e[i]&&(t.style[i]=e[i]);else if(n.startsWith("xlink")){const i=n.replace("xlink","").toLowerCase();null==e||!1===e?t.removeAttributeNS("http://www.w3.org/1999/xlink",i):t.setAttributeNS("http://www.w3.org/1999/xlink",i,e)}else n.startsWith("on")?e&&"function"!=typeof e?"string"==typeof e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]=e:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-/g.test(n)||s?t.getAttribute(n)!==e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]!==e&&(t[n]=e);"key"===n&&e&&(u[e]=t)}i&&"function"==typeof i.ref&&window.requestAnimationFrame((()=>i.ref(t)))}function g(t,i,s=0){var n;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>g(t,i,s++)));let e=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).t&&(e=function(t,i,s){const{tag:n,props:e,children:o}=t;let r=`_${s}`,h=e&&e.id;h?r=h:h=`_${s}${Date.now()}`;let c="section";e&&e.as&&(c=e.as,delete e.as),i.i||(i.i={});let l=i.i[r];if(!(l&&l instanceof n&&l.element)){const t=document.createElement(c);l=i.i[r]=new n(Object.assign(Object.assign({},e),{children:o})).start(t)}if(l.mounted){const t=l.mounted(e,o,l.state);void 0!==t&&l.setState(t)}return b(l.element,e,!1),l.element}(t,i,s)),e&&Array.isArray(e.children)){const t=null===(n=e.props)||void 0===n?void 0:n._component;if(t){let i=0;e.children=e.children.map((s=>g(s,t,i++)))}else e.children=e.children.map((t=>g(t,i,s++)))}return e}const m=(t,i={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(i.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const s=i||{};this._shadowRoot=s.shadow?this.attachShadow({mode:"open"}):this;const n=s.observedAttributes||[],e=n.reduce(((t,i)=>{const s=i.toLowerCase();return s!==i&&(t[s]=i),t}),{});this._attrMap=t=>e[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),n.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(i){this.attributeChangedCallback(t,o[t],i)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const i=this.children?Array.from(this.children):[];if(i.forEach((t=>t.parentElement.removeChild(t))),this._component=new t(Object.assign(Object.assign({},o),{children:i})).mount(this._shadowRoot,s),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,i,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==s.render&&this._component.run(".")}))}}disconnectedCallback(){var t,i,s,n;null===(i=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===i||i.call(t),null===(n=null===(s=this._component)||void 0===s?void 0:s.unmount)||void 0===n||n.call(s),this._component=null}attributeChangedCallback(t,s,n){if(this._component){const e=this._attrMap(t);this._component._props[e]=n,this._component.run("attributeChanged",e,s,n),n!==s&&!1!==i.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var w=(t,i,s)=>{"undefined"!=typeof customElements&&customElements.define(t,m(i,s))};const $={meta:new WeakMap,defineMetadata(t,i,s){this.meta.has(s)||this.meta.set(s,{}),this.meta.get(s)[t]=i},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,i){return i=Object.getPrototypeOf(i),this.meta.get(i)?this.meta.get(i)[t]:null}};function j(t,i={}){return(s,n,e)=>{const o=t?t.toString():n;return $.defineMetadata(`apprun-update:${o}`,{name:o,key:n,options:i},s),e}}function A(t,i={}){return function(s,n){const e=t?t.toString():n;$.defineMetadata(`apprun-update:${e}`,{name:e,key:n,options:i},s)}}function O(t,i){return function(s){return w(t,s,i),s}}const _=new Map;n.find("get-components")||n.on("get-components",(t=>t.components=_));const x=t=>t;class k{constructor(i,s,n,e){this.state=i,this.view=s,this.update=n,this.options=e,this._app=new t,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,i)=>this.mount(t,Object.assign({render:!0},i))}renderState(t,i=null){if(!this.view)return;let s=i||this.view(t);if(n.debug&&n.run("debug",{component:this,_:s?".":"-",state:t,vdom:s,el:this.element}),"object"!=typeof document)return;const e="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(e){const t="_c";this.unload?e._component===this&&e.getAttribute(t)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),e.setAttribute(t,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(e)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[t]}))):e.removeAttribute&&e.removeAttribute(t),e._component=this}!i&&s&&(s=r(s,this),n.render(e,s,this)),this.rendered&&this.rendered(this.state)}setState(t,i={render:!0,history:!1}){if(t instanceof Promise)Promise.resolve(t).then((s=>{this.setState(s,i),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==i.render&&this.renderState(t),!1!==i.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof i.callback&&i.callback(this.state)}}mount(t=null,i){var s,e;return console.assert(!this.element,"Component already mounted."),this.options=i=Object.assign(Object.assign({},this.options),i),this.element=t,this.global_event=i.global_event,this.enable_history=!!i.history,this.enable_history&&(this.on(i.history.prev||"history-prev",this._history_prev),this.on(i.history.next||"history-next",this._history_next)),i.route&&(this.update=this.update||{},this.update[i.route]||(this.update[i.route]=x)),this.add_actions(),this.state=null!==(e=null!==(s=this.state)&&void 0!==s?s:this.model)&&void 0!==e?e:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!i.render,history:!0}),n.debug&&(_.get(t)?_.get(t).push(this):_.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,i,s={}){i&&"function"==typeof i&&(s.global&&this._global_events.push(t),this.on(t,((...e)=>{n.debug&&n.run("debug",{component:this,_:">",event:t,p:e,current_state:this.state,options:s});const o=i(this.state,...e);n.debug&&n.run("debug",{component:this,_:"<",event:t,p:e,newState:o,state:this.state,options:s}),this.setState(o,s)}),s))}add_actions(){const t=this.update||{};$.getMetadataKeys(this).forEach((i=>{if(i.startsWith("apprun-update:")){const s=$.getMetadata(i,this);t[s.name]=[this[s.key].bind(this),s.options]}}));const i={};Array.isArray(t)?t.forEach((t=>{const[s,n,e]=t;s.toString().split(",").forEach((t=>i[t.trim()]=[n,e]))})):Object.keys(t).forEach((s=>{const n=t[s];("function"==typeof n||Array.isArray(n))&&s.split(",").forEach((t=>i[t.trim()]=n))})),i["."]||(i["."]=x),Object.keys(i).forEach((t=>{const s=i[t];"function"==typeof s?this.add_action(t,s):Array.isArray(s)&&this.add_action(t,s[0],s[1])}))}run(t,...i){if(this.state instanceof Promise)return Promise.resolve(this.state).then((s=>{this.state=s,this.run(t,...i)}));{const s=t.toString();return this.is_global_event(s)?n.run(s,...i):this._app.run(s,...i)}}on(t,i,s){const e=t.toString();return this._actions.push({name:e,fn:i}),this.is_global_event(e)?n.on(e,i,s):this._app.on(e,i,s)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:i,fn:s}=t;this.is_global_event(i)?n.off(i,s):this._app.off(i,s)}))}}k.t=!0;const T="//",M="///",E=t=>{if(t||(t="#"),t.startsWith("#")){const[i,...s]=t.split("/");n.run(i,...s)||n.run("///",i,...s),n.run("//",i,...s)}else if(t.startsWith("/")){const[i,s,...e]=t.split("/");n.run("/"+s,...e)||n.run("///","/"+s,...e),n.run("//","/"+s,...e)}else n.run(t)||n.run("///",t),n.run("//",t)};n.h=n.createElement=l,n.render=d,n.Fragment=h,n.webComponent=w,n.safeHTML=v,n.start=(t,i,s,n,e)=>{const o=Object.assign({render:!0,global_event:!0},e),r=new k(i,s,n);return e&&e.rendered&&(r.rendered=e.rendered),r.mount(t,o),r};const C=t=>{};
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
6
|
*/
|
|
7
|
-
var S;n.on("$",C),n.on("debug",(t=>C)),n.on("//",C),n.on("#",C),n.route=E,n.on("route",(t=>n.route&&n.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{n.route===E&&(window.onpopstate=()=>E(location.hash),document.body.hasAttribute("apprun-no-init")||E(location.hash))})),"object"==typeof window&&(window.Component=k,window.React=n,window.on=A,window.customElement=O,window.safeHTML=v);const N=globalThis.trustedTypes,L=N?N.createPolicy("lit-html",{createHTML:t=>t}):void 0,U=`lit$${(Math.random()+"").slice(9)}$`,H="?"+U,
|
|
7
|
+
var S;n.on("$",C),n.on("debug",(t=>C)),n.on("//",C),n.on("#",C),n.route=E,n.on("route",(t=>n.route&&n.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{n.route===E&&(window.onpopstate=()=>E(location.hash),document.body.hasAttribute("apprun-no-init")||E(location.hash))})),"object"==typeof window&&(window.Component=k,window.React=n,window.on=A,window.customElement=O,window.safeHTML=v);const N=globalThis.trustedTypes,L=N?N.createPolicy("lit-html",{createHTML:t=>t}):void 0,U=`lit$${(Math.random()+"").slice(9)}$`,H="?"+U,P=`<${H}>`,D=document,I=(t="")=>D.createComment(t),V=t=>null===t||"object"!=typeof t&&"function"!=typeof t,G=Array.isArray,R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,W=/-->/g,q=/>/g,z=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,F=/'/g,Z=/"/g,J=/^(?:script|style|textarea|title)$/i,K=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),B=K(1),Q=K(2),X=Symbol.for("lit-noChange"),Y=Symbol.for("lit-nothing"),tt=new WeakMap,it=(t,i,s)=>{var n,e;const o=null!==(n=null==s?void 0:s.renderBefore)&&void 0!==n?n:i;let r=o._$litPart$;if(void 0===r){const t=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:null;o._$litPart$=r=new ht(i.insertBefore(I(),t),t,void 0,null!=s?s:{})}return r._$AI(t),r},st=D.createTreeWalker(D,129,null,!1),nt=(t,i)=>{const s=t.length-1,n=[];let e,o=2===i?"<svg>":"",r=R;for(let i=0;i<s;i++){const s=t[i];let h,c,l=-1,u=0;for(;u<s.length&&(r.lastIndex=u,c=r.exec(s),null!==c);)u=r.lastIndex,r===R?"!--"===c[1]?r=W:void 0!==c[1]?r=q:void 0!==c[2]?(J.test(c[2])&&(e=RegExp("</"+c[2],"g")),r=z):void 0!==c[3]&&(r=z):r===z?">"===c[0]?(r=null!=e?e:R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,h=c[1],r=void 0===c[3]?z:'"'===c[3]?Z:F):r===Z||r===F?r=z:r===W||r===q?r=R:(r=z,e=void 0);const d=r===z&&t[i+1].startsWith("/>")?" ":"";o+=r===R?s+P:l>=0?(n.push(h),s.slice(0,l)+"$lit$"+s.slice(l)+U+d):s+U+(-2===l?(n.push(void 0),i):d)}const h=o+(t[s]||"<?>")+(2===i?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==L?L.createHTML(h):h,n]};class et{constructor({strings:t,_$litType$:i},s){let n;this.parts=[];let e=0,o=0;const r=t.length-1,h=this.parts,[c,l]=nt(t,i);if(this.el=et.createElement(c,s),st.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(n=st.nextNode())&&h.length<r;){if(1===n.nodeType){if(n.hasAttributes()){const t=[];for(const i of n.getAttributeNames())if(i.endsWith("$lit$")||i.startsWith(U)){const s=l[o++];if(t.push(i),void 0!==s){const t=n.getAttribute(s.toLowerCase()+"$lit$").split(U),i=/([.?@])?(.*)/.exec(s);h.push({type:1,index:e,name:i[2],strings:t,ctor:"."===i[1]?lt:"?"===i[1]?dt:"@"===i[1]?at:ct})}else h.push({type:6,index:e})}for(const i of t)n.removeAttribute(i)}if(J.test(n.tagName)){const t=n.textContent.split(U),i=t.length-1;if(i>0){n.textContent=N?N.emptyScript:"";for(let s=0;s<i;s++)n.append(t[s],I()),st.nextNode(),h.push({type:2,index:++e});n.append(t[i],I())}}}else if(8===n.nodeType)if(n.data===H)h.push({type:2,index:e});else{let t=-1;for(;-1!==(t=n.data.indexOf(U,t+1));)h.push({type:7,index:e}),t+=U.length-1}e++}}static createElement(t,i){const s=D.createElement("template");return s.innerHTML=t,s}}function ot(t,i,s=t,n){var e,o,r,h;if(i===X)return i;let c=void 0!==n?null===(e=s._$Cl)||void 0===e?void 0:e[n]:s._$Cu;const l=V(i)?void 0:i._$litDirective$;return(null==c?void 0:c.constructor)!==l&&(null===(o=null==c?void 0:c._$AO)||void 0===o||o.call(c,!1),void 0===l?c=void 0:(c=new l(t),c._$AT(t,s,n)),void 0!==n?(null!==(r=(h=s)._$Cl)&&void 0!==r?r:h._$Cl=[])[n]=c:s._$Cu=c),void 0!==c&&(i=ot(t,c._$AS(t,i.values),c,n)),i}class rt{constructor(t,i){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var i;const{el:{content:s},parts:n}=this._$AD,e=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:D).importNode(s,!0);st.currentNode=e;let o=st.nextNode(),r=0,h=0,c=n[0];for(;void 0!==c;){if(r===c.index){let i;2===c.type?i=new ht(o,o.nextSibling,this,t):1===c.type?i=new c.ctor(o,c.name,c.strings,this,t):6===c.type&&(i=new ft(o,this,t)),this.v.push(i),c=n[++h]}r!==(null==c?void 0:c.index)&&(o=st.nextNode(),r++)}return e}m(t){let i=0;for(const s of this.v)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class ht{constructor(t,i,s,n){var e;this.type=2,this._$AH=Y,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=n,this._$Cg=null===(e=null==n?void 0:n.isConnected)||void 0===e||e}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=ot(this,t,i),V(t)?t===Y||null==t||""===t?(this._$AH!==Y&&this._$AR(),this._$AH=Y):t!==this._$AH&&t!==X&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var i;return G(t)||"function"==typeof(null===(i=t)||void 0===i?void 0:i[Symbol.iterator])})(t)?this.S(t):this.$(t)}A(t,i=this._$AB){return this._$AA.parentNode.insertBefore(t,i)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==Y&&V(this._$AH)?this._$AA.nextSibling.data=t:this.k(D.createTextNode(t)),this._$AH=t}T(t){var i;const{values:s,_$litType$:n}=t,e="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=et.createElement(n.h,this.options)),n);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===e)this._$AH.m(s);else{const t=new rt(e,this),i=t.p(this.options);t.m(s),this.k(i),this._$AH=t}}_$AC(t){let i=tt.get(t.strings);return void 0===i&&tt.set(t.strings,i=new et(t)),i}S(t){G(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,n=0;for(const e of t)n===i.length?i.push(s=new ht(this.A(I()),this.A(I()),this,this.options)):s=i[n],s._$AI(e),n++;n<i.length&&(this._$AR(s&&s._$AB.nextSibling,n),i.length=n)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cg=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class ct{constructor(t,i,s,n,e){this.type=1,this._$AH=Y,this._$AN=void 0,this.element=t,this.name=i,this._$AM=n,this.options=e,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=Y}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,n){const e=this.strings;let o=!1;if(void 0===e)t=ot(this,t,i,0),o=!V(t)||t!==this._$AH&&t!==X,o&&(this._$AH=t);else{const n=t;let r,h;for(t=e[0],r=0;r<e.length-1;r++)h=ot(this,n[s+r],i,r),h===X&&(h=this._$AH[r]),o||(o=!V(h)||h!==this._$AH[r]),h===Y?t=Y:t!==Y&&(t+=(null!=h?h:"")+e[r+1]),this._$AH[r]=h}o&&!n&&this.C(t)}C(t){t===Y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class lt extends ct{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===Y?void 0:t}}const ut=N?N.emptyScript:"";class dt extends ct{constructor(){super(...arguments),this.type=4}C(t){t&&t!==Y?this.element.setAttribute(this.name,ut):this.element.removeAttribute(this.name)}}class at extends ct{constructor(t,i,s,n,e){super(t,i,s,n,e),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=ot(this,t,i,0))&&void 0!==s?s:Y)===X)return;const n=this._$AH,e=t===Y&&n!==Y||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==Y&&(n===Y||e);e&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class ft{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){ot(this,t)}}const vt=window.litHtmlPolyfillSupport;null==vt||vt(et,ht),(null!==(S=globalThis.litHtmlVersions)&&void 0!==S?S:globalThis.litHtmlVersions=[]).push("2.2.1");
|
|
8
8
|
/**
|
|
9
9
|
* @license
|
|
10
10
|
* Copyright 2017 Google LLC
|
|
@@ -15,5 +15,5 @@ const pt=2,yt=5,bt=t=>(...i)=>({_$litDirective$:t,values:i});class gt{constructo
|
|
|
15
15
|
* @license
|
|
16
16
|
* Copyright 2017 Google LLC
|
|
17
17
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
-
*/class
|
|
18
|
+
*/class mt extends gt{constructor(t){if(super(t),this.it=Y,t.type!==pt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===Y||null==t)return this.ft=void 0,this.it=t;if(t===X)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this.ft;this.it=t;const i=[t];return i.raw=i,this.ft={_$litType$:this.constructor.resultType,strings:i,values:[]}}}mt.directiveName="unsafeHTML",mt.resultType=1;const wt=bt(mt);function $t(t,i,s){i&&("string"==typeof i?(t._$litPart$||t.replaceChildren(),it(B`${wt(i)}`,t)):"_$litType$"in i?(t._$litPart$||t.replaceChildren(),it(i,t)):(d(t,i,s),t._$litPart$=void 0))}const jt=bt(class extends gt{constructor(t){if(super(t),t.type!==yt)throw new Error("${run} can only be used in event handlers")}update(t,i){let{element:s,name:e}=t;const o=()=>{let t=s._component;for(;!t&&s;)s=s.parentElement,t=s&&s._component;return console.assert(!!t,"Component not found."),t},[r,...h]=i;return"string"==typeof r?s[`on${e}`]=t=>{const i=o();i?i.run(r,...h,t):n.run(r,...h,t)}:"function"==typeof r&&(s[`on${e}`]=t=>o().setState(r(o().state,...h,t))),this.render()}render(){return X}});n.createElement=l,n.render=$t,n.Fragment=h,"object"==typeof window&&(window.html=B,window.svg=Q,window.run=jt);export{k as Component,M as ROUTER_404_EVENT,T as ROUTER_EVENT,n as app,O as customElement,n as default,j as event,B as html,A as on,$t as render,jt as run,v as safeHTML,Q as svg,j as update};
|
|
19
19
|
//# sourceMappingURL=apprun-html.esm.js.map
|