apprun 3.28.7 → 3.28.10

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +4 -2
  2. package/README.md +8 -40
  3. package/WHATSNEW.md +6 -6
  4. package/apprun-cli.js +3 -221
  5. package/dist/apprun-dev-tools.js +1 -2
  6. package/dist/apprun-dev-tools.js.map +1 -1
  7. package/dist/apprun-html.esm.js +10 -112
  8. package/dist/apprun-html.esm.js.map +1 -1
  9. package/dist/apprun-html.js +1 -1
  10. package/dist/apprun-html.js.LICENSE.txt +2 -24
  11. package/dist/apprun-html.js.map +1 -1
  12. package/dist/apprun-play.js +1 -1
  13. package/dist/apprun-play.js.map +1 -1
  14. package/dist/apprun.esm.js +1 -1
  15. package/dist/apprun.esm.js.map +1 -1
  16. package/dist/apprun.js +1 -1
  17. package/dist/apprun.js.map +1 -1
  18. package/esm/apprun-dev-tools.js +2 -1
  19. package/esm/apprun-dev-tools.js.map +1 -1
  20. package/esm/apprun.js +1 -1
  21. package/esm/apprun.js.map +1 -1
  22. package/esm/component.js +3 -2
  23. package/esm/component.js.map +1 -1
  24. package/esm/directive.js +3 -3
  25. package/esm/directive.js.map +1 -1
  26. package/esm/vdom-lit-html.js +46 -21
  27. package/esm/vdom-lit-html.js.map +1 -1
  28. package/esm/vdom-my.js +9 -3
  29. package/esm/vdom-my.js.map +1 -1
  30. package/esm/vdom-to-html.js +1 -2
  31. package/esm/vdom-to-html.js.map +1 -1
  32. package/esm/vdom.js +1 -4
  33. package/esm/vdom.js.map +1 -1
  34. package/esm/web-component.js +18 -16
  35. package/esm/web-component.js.map +1 -1
  36. package/package.json +18 -19
  37. package/src/apprun.ts +1 -1
  38. package/src/component.ts +2 -2
  39. package/src/directive.ts +3 -3
  40. package/src/vdom-lit-html.ts +47 -20
  41. package/src/vdom-my.ts +8 -3
  42. package/src/vdom-to-html.tsx +2 -2
  43. package/src/vdom.ts +1 -4
  44. package/src/web-component.ts +16 -14
  45. package/webpack.config.js +2 -1
  46. package/cli-templates/Layout.ts_ +0 -35
  47. package/cli-templates/_build.js +0 -27
  48. package/cli-templates/_eslintrc.js +0 -40
  49. package/cli-templates/_gitignore +0 -6
  50. package/cli-templates/component.ts_ +0 -14
  51. package/cli-templates/index.html +0 -10
  52. package/cli-templates/jest.config.js +0 -19
  53. package/cli-templates/karma.conf.js +0 -24
  54. package/cli-templates/main.ts_ +0 -13
  55. package/cli-templates/readme.md +0 -7
  56. package/cli-templates/spa_index.html +0 -14
  57. package/cli-templates/spa_main.ts_ +0 -12
  58. package/cli-templates/spec.ts_ +0 -12
  59. package/cli-templates/stories.js_ +0 -47
  60. package/cli-templates/tsconfig.es5.json +0 -15
  61. package/cli-templates/tsconfig.es6.json +0 -15
  62. package/cli-templates/webpack.config.js +0 -23
  63. package/index-apprun-play.html +0 -46
package/CHANGELOG.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Change Log
2
2
 
3
3
  ## Releases
4
- * apprun@es5: 1.x, stable, es5
5
- * apprun@latest: 3.x, stable, es6/es2015, lit-html
4
+
5
+ ## 3.28.8 merged into master
6
+
7
+ * Use lit-html@2
6
8
 
7
9
  ## 3.28.3 merged into master
8
10
 
package/README.md CHANGED
@@ -22,12 +22,13 @@ You can also load AppRun directly from the unpkg.com CDN:
22
22
  ```javascript
23
23
  <script src="https://unpkg.com/apprun/dist/apprun-html.js"></script>
24
24
  ```
25
- Or use it as ES module from unpkg.com:
26
- ```javascript
27
- <script type="module">
28
- import { app, Component } from 'https://unpkg.com/apprun/esm/apprun-html?module';
29
- </script>
25
+
26
+ Or, you can create an AppRun app by using the `npm init apprun-app` command.
27
+
28
+ ```sh
29
+ npm init apprun-app [my-app]
30
30
  ```
31
+
31
32
  ## Architecture Concept
32
33
 
33
34
  * AppRun [architecure](docs/architecture) has _state_, _view_, and _update_.
@@ -39,41 +40,10 @@ You can get started with [AppRun Docs](https://apprun.js.org/docs) and [the AppR
39
40
 
40
41
  ## AppRun Book from Apress
41
42
 
42
- [![Order from Amazon](https://camo.githubusercontent.com/99fad1f024c274a3d752a1583cf125037583811c/68747470733a2f2f696d616765732e737072696e6765722e636f6d2f7367772f626f6f6b732f6d656469756d2f393738313438343234303638372e6a7067)](https://www.amazon.com/Practical-Application-Development-AppRun-High-Performance/dp/1484240685/)
43
+ [![Order from Amazon](https://images-na.ssl-images-amazon.com/images/I/51cr-t1pdSL._SX348_BO1,204,203,200_.jpg)](https://www.amazon.com/Practical-Application-Development-AppRun-High-Performance/dp/1484240685/)
43
44
 
44
45
  * [Order from Amazon](https://www.amazon.com/Practical-Application-Development-AppRun-High-Performance/dp/1484240685/)
45
46
 
46
- ## Create AppRun Apps
47
-
48
- Use the AppRun CLI to initialize an esbuild configured project:
49
-
50
- ```sh
51
- npx apprun --init --spa --esbuild
52
- ```
53
-
54
- Use the AppRun CLI to initialize a TypeScript and webpack configured project:
55
-
56
- ```sh
57
- npx apprun --init --spa
58
- ```
59
-
60
- To initialize a project that targets ES5, use the AppRun CLI with the --es5 flag:
61
-
62
- ```sh
63
- npx apprun --init --spa --es5
64
- ```
65
-
66
- ## AppRun Dev Server
67
-
68
- AppRun now has a dev server. It is base on the _live-server_ and supports ES Modules. _apprun-dev-server_ is install by AppRun CLI when using _esbuild_. Or you can use it directly.
69
-
70
-
71
- ```sh
72
- npx apprun-dev-server
73
- ```
74
-
75
- See the announcement: [A Dev Server Supports ESM](https://dev.to/yysun/a-dev-server-supports-esm-3cea)
76
-
77
47
 
78
48
  ## AppRun Dev Tools
79
49
  To use the AppRun dev-tools, include the dev-tools script.
@@ -125,13 +95,11 @@ AppRun is an MIT-licensed open source project. Please consider [supporting the p
125
95
  * Kevin Shi
126
96
  * Chancy Kennedy
127
97
 
128
-
129
-
130
98
  ## License
131
99
 
132
100
  MIT
133
101
 
134
- Copyright (c) 2015-2021 Yiyi Sun
102
+ Copyright (c) 2015-2022 Yiyi Sun
135
103
 
136
104
 
137
105
  [travis-image]: https://travis-ci.org/yysun/apprun.svg?branch=master
package/WHATSNEW.md CHANGED
@@ -1,15 +1,15 @@
1
1
  ### What's New
2
2
 
3
- ## Default npm Version Change
3
+ ## Create-AppRun-App CLI
4
4
 
5
- On May 19, 2020, the V3 branch merged into the master branch. AppRun replaced _morphdom_ with _lit-html_.
5
+ You can create an AppRun app by running command `npm init apprun-app`.
6
6
 
7
- When upgrading projects to the latest version (2.x), please modify the tsconfig from targeting es5 to es2015.
7
+ ```sh
8
+ npm init apprun-app [my-app]
9
+ ```
8
10
 
9
- Currently, the npm tags are as following:
11
+ > Note: AppRun CLI `npx apprun init` is deprecated. Please use `apprun create-app` instead.
10
12
 
11
- * apprun@es5: 1.x, stable, es5
12
- * apprun@latest: 3.x, stable, es2015, web components, lit-html
13
13
 
14
14
  ## Recent Posts and Publications
15
15
 
package/apprun-cli.js CHANGED
@@ -2,225 +2,7 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- const fs = require('fs');
6
- const path = require('path');
7
- const package_json = path.resolve('./package.json');
8
- const tsconfig_json = path.resolve('./tsconfig.json');
9
- const webpack_config_js = path.resolve('./webpack.config.js');
10
- const git_ignore_file = path.resolve('./.gitignore');
11
- const eslint_file = path.resolve('./.eslintrc.js');
12
- const index_html = path.resolve('./index.html');
13
- const main_tsx = path.resolve('./src/main.tsx');
14
- const spa_index = path.resolve('./index.html');
15
- const spa_main_tsx = path.resolve('./src/main.tsx');
16
- const spa_layout_tsx = path.resolve('./src/Layout.tsx');
17
- const readme_md = path.resolve('./README.md');
18
- const build_js = path.resolve('./_build.js');
19
- const execSync = require('child_process').execSync;
20
- const program = require('commander');
5
+ console.log(`apprun CLI is deprecated. Please use create-apprun-app instead.
21
6
 
22
- const dir_src = './src';
23
- const dir_tests = './tests';
24
- const dir_stories = './src/stories'
25
-
26
- let show_start = false;
27
- let show_test = false;
28
- let es5 = false;
29
- let esbuild = false;
30
-
31
- function read(name) {
32
- return fs.readFileSync(path.resolve(__dirname + '/cli-templates', name), 'utf8');
33
- }
34
-
35
- function write(file_name, text, title = ' * Creating', overwrite = false) {
36
- const file = path.resolve(file_name);
37
- if (!fs.existsSync(file) || overwrite) {
38
- process.stdout.write(`${title}: ${file} ... `);
39
- fs.writeFileSync(
40
- file,
41
- text
42
- );
43
- process.stdout.write('Done\n');
44
- } else {
45
- process.stdout.write(` * No change made. File exists: ${file}\n`);
46
- }
47
- }
48
-
49
- function init() {
50
- RegExp.prototype.toJSON = RegExp.prototype.toString;
51
-
52
- if (!fs.existsSync(package_json)) {
53
- console.log(' * Initializing package.json');
54
- execSync('npm init -y');
55
- }
56
-
57
- if (!fs.existsSync(dir_src)) fs.mkdirSync(dir_src);
58
-
59
- const packages_es5 = 'npm install -D apprun@es5 typescript webpack webpack-cli webpack-dev-server ts-loader source-map-loader';
60
- const packages_es6 = 'npm install -D apprun typescript webpack webpack-cli webpack-dev-server ts-loader source-map-loader';
61
- console.log(' * Installing packages. This might take a few minutes.');
62
- if (!esbuild) {
63
- es5
64
- ? execSync(packages_es5)
65
- : execSync(packages_es6);
66
- } else {
67
- es5
68
- ? execSync('npm install -D apprun@es5 apprun-dev-server esbuild')
69
- : execSync('npm install -D apprun apprun-dev-server esbuild');
70
- }
71
- es5
72
- ? write(tsconfig_json, read('tsconfig.es5.json'), ' * Configuring typescript - es5', true)
73
- : write(tsconfig_json, read('tsconfig.es6.json'), ' * Configuring typescript - es2015', true);
74
-
75
- write(index_html, read('index.html'));
76
- write(main_tsx, read('main.ts_'));
77
- write(readme_md, read('readme.md'));
78
-
79
- console.log(' * Adding npm scripts');
80
- const package_info = require(package_json);
81
- if (!package_info.scripts) package_info["scripts"] = {}
82
- if (!esbuild) {
83
- if (!package_info.scripts['start']) {
84
- package_info["scripts"]["start"] = 'webpack serve --mode development';
85
- }
86
- if (!package_info.scripts['build']) {
87
- package_info["scripts"]["build"] = 'webpack --mode production';
88
- }
89
- write(webpack_config_js, read('webpack.config.js'))
90
- } else {
91
- write(build_js, read('_build.js'));
92
- if (!package_info.scripts['start']) {
93
- package_info["scripts"]["start"] = 'node _build start';
94
- }
95
- if (!package_info.scripts['build']) {
96
- package_info["scripts"]["build"] = 'node _build';
97
- }
98
- }
99
- if (!package_info.scripts['tsc:watch']) {
100
- package_info['scripts']['tsc:watch'] = 'tsc -w';
101
- }
102
- save_package_json(package_info);
103
- git_init();
104
- // jest_init();
105
- show_start = true;
106
- }
107
-
108
- function save_package_json(package_info) {
109
- fs.writeFileSync(
110
- package_json,
111
- JSON.stringify(package_info, null, 2)
112
- );
113
- }
114
-
115
- function git_init() {
116
- if (!fs.existsSync('.git')) {
117
- console.log(' * Initializing git');
118
- execSync('git init');
119
- } else {
120
- console.log(' * Skip git init. .git exsits');
121
- }
122
- write(git_ignore_file, read('_gitignore'));
123
- }
124
-
125
- function component(name) {
126
- if (!fs.existsSync(dir_src)) fs.mkdirSync(dir_src);
127
- const fn = path.resolve(dir_src + '/' + name + '.tsx');
128
- const component_template = read('component.ts_');
129
- write(fn, component_template.replace(/\#name/g, name),
130
- `Creating component ${name}`);
131
- show_start = true;
132
- }
133
-
134
- function jest_init() {
135
- console.log(' * Installing jest');
136
- execSync('npm i @types/jest jest ts-jest --save-dev');
137
- const jest_config = {
138
- "preset": "ts-jest",
139
- }
140
-
141
- const package_info = require(package_json) || {};
142
- package_info["jest"] = jest_config
143
-
144
- package_info["scripts"]["test"] = 'jest --watch';
145
- save_package_json(package_info);
146
- show_test = true;
147
- }
148
-
149
- function lint_init() {
150
- console.log(' * Installing ESLint');
151
- execSync('npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin');
152
-
153
- const package_info = require(package_json) || {};
154
- package_info["scripts"]["lint"] = 'eslint src';
155
- package_info["scripts"]["lint:fix"] = 'eslint src --fix';
156
- save_package_json(package_info);
157
-
158
- write(eslint_file, read('_eslintrc.js'));
159
- }
160
-
161
- function component_spec(name) {
162
- if (!fs.existsSync(dir_tests)) fs.mkdirSync(dir_tests);
163
- const fn = path.resolve(dir_tests + '/' + name + '.spec.ts');
164
- const test_template = read('spec.ts_');
165
- write(fn, test_template.replace(/\#name/g, name),
166
- `Creating component spec ${name}`);
167
- show_test = true;
168
- }
169
-
170
- function component_story(name) {
171
- if (!fs.existsSync(dir_stories)) fs.mkdirSync(dir_stories);
172
- const fn = path.resolve(dir_stories + '/' + name + '.stories.tsx');
173
- const story_template = read('stories.js_');
174
- write(fn, story_template.replace(/\#name/g, name),
175
- `Creating component stories ${name}`);
176
- }
177
-
178
- function spa() {
179
- if (!fs.existsSync(dir_src)) fs.mkdirSync(dir_src);
180
- write(spa_index, read('spa_index.html'), 'Creating', true);
181
- write(spa_main_tsx, read('spa_main.ts_'), 'Creating', true);
182
- write(spa_layout_tsx, read('Layout.ts_'), 'Creating', true);
183
- component('Home');
184
- component('About');
185
- component('Contact');
186
- show_start = true;
187
- }
188
-
189
- program
190
- .name('apprun')
191
- .version('2.27')
192
- .option('-i, --init', 'Initialize AppRun Project')
193
- .option('-c, --component <file>', 'Generate AppRun component')
194
- .option('-g, --git', 'Initialize git repository')
195
- .option('-j, --jest', 'Install jest')
196
- .option('-l, --lint', 'Install ESLint')
197
- .option('-t, --test <file>', 'Generate component spec')
198
- .option('-o, --story <file>', 'Generate component stories')
199
- .option('-s, --spa', 'Generate SPA app')
200
- .option('-5, --es5', 'Use apprun@es5')
201
- .option('-e, --esbuild', 'Use esbuild')
202
- .parse(process.argv);
203
-
204
- program._name = 'apprun';
205
- const options = program.opts();
206
-
207
- if (!options.init && !options.component && !options.git && !options.jest &&
208
- !options.test && !options.spa && !options.lint && !options.story) {
209
- program.outputHelp();
210
- process.exit()
211
- }
212
-
213
- if (options.es5) es5 = true;
214
- if (options.esbuild) esbuild = true;
215
- if (options.init) init();
216
- if (options.component) component(program.component);
217
- if (options.git) git_init();
218
- if (options.jest) jest_init();
219
- if (options.lint) lint_init();
220
- if (options.test) component_spec(program.test);
221
- if (options.story) component_story(program.story);
222
- if (options.spa) spa();
223
-
224
- console.log('\r');
225
- if (show_start) console.log('All done. You can run `npm start` and then navigate to http://localhost:8080 in a browser.');
226
- //if (show_test) console.log('All done. You can run `npm test`.');
7
+ npm init apprun-app [my-app]
8
+ `);
@@ -1,3 +1,2 @@
1
- /*! For license information please see apprun-dev-tools.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apprun=e():t.apprun=e()}(this,(function(){return(()=>{"use strict";var t={};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e);let n;const s="object"==typeof self&&self.self===self&&self||"object"==typeof t.g&&t.g.global===t.g&&t.g;s.app&&s._AppRunVersions?n=s.app:(n=new class{constructor(){this._events={}}on(t,e,n={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:n})}off(t,e){const n=this._events[t]||[];this._events[t]=n.filter((t=>t.fn!==e))}find(t){return this._events[t]}run(t,...e){const n=this.getSubscribers(t,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+t),n.forEach((n=>{const{fn:s,options:o}=n;return o.delay?this.delay(t,s,e,o):Object.keys(o).length>0?s.apply(this,[...e,o]):s.apply(this,e),!n.options.once})),n.length}once(t,e,n={}){this.on(t,e,Object.assign(Object.assign({},n),{once:!0}))}delay(t,e,n,s){s._t&&clearTimeout(s._t),s._t=setTimeout((()=>{clearTimeout(s._t),Object.keys(s).length>0?e.apply(this,[...n,s]):e.apply(this,n)}),s.delay)}query(t,...e){const n=this.getSubscribers(t,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+t);const s=n.map((t=>{const{fn:n,options:s}=t;return Object.keys(s).length>0?n.apply(this,[...e,s]):n.apply(this,e)}));return Promise.all(s)}getSubscribers(t,e){const n=e[t]||[];return e[t]=n.filter((t=>!t.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&t.startsWith(e.replace("*","")))).sort(((t,e)=>e.length-t.length)).forEach((s=>n.push(...e[s].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:t})})))))),n}},s.app=n,s._AppRunVersions="AppRun-3");const o=n,i=new WeakMap,l=t=>"function"==typeof t&&i.has(t),r="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,a={},c={},p=`{{lit-${String(Math.random()).slice(2)}}}`,u=`\x3c!--${p}--\x3e`,h=(new RegExp(`${p}|${u}`),"$lit$"),d=t=>-1!==t.index,m=()=>document.createComment(""),f=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class _{constructor(t,e,n){this.__parts=[],this.template=t,this.processor=e,this.options=n}update(t){let e=0;for(const n of this.__parts)void 0!==n&&n.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=r?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],n=this.template.parts,s=document.createTreeWalker(t,133,null,!1);let o,i=0,l=0,a=s.nextNode();for(;i<n.length;)if(o=n[i],d(o)){for(;l<o.index;)l++,"TEMPLATE"===a.nodeName&&(e.push(a),s.currentNode=a.content),null===(a=s.nextNode())&&(s.currentNode=e.pop(),a=s.nextNode());if("node"===o.type){const t=this.processor.handleTextExpression(this.options);t.insertAfterNode(a.previousSibling),this.__parts.push(t)}else this.__parts.push(...this.processor.handleAttributeExpressions(a,o.name,o.strings,this.options));i++}else this.__parts.push(void 0),i++;return r&&(document.adoptNode(t),customElements.upgrade(t)),t}}const g=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),v=` ${p} `;class y{constructor(t,e,n,s){this.strings=t,this.values=e,this.type=n,this.processor=s}getHTML(){const t=this.strings.length-1;let e="",n=!1;for(let s=0;s<t;s++){const t=this.strings[s],o=t.lastIndexOf("\x3c!--");n=(o>-1||n)&&-1===t.indexOf("--\x3e",o+1);const i=f.exec(t);e+=null===i?t+(n?v:u):t.substr(0,i.index)+i[1]+i[2]+h+i[3]+p}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==g&&(e=g.createHTML(e)),t.innerHTML=e,t}}const b=t=>null===t||!("object"==typeof t||"function"==typeof t),w=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class x{constructor(t,e,n){this.dirty=!0,this.element=t,this.name=e,this.strings=n,this.parts=[];for(let t=0;t<n.length-1;t++)this.parts[t]=this._createPart()}_createPart(){return new N(this)}_getValue(){const t=this.strings,e=t.length-1,n=this.parts;if(1===e&&""===t[0]&&""===t[1]){const t=n[0].value;if("symbol"==typeof t)return String(t);if("string"==typeof t||!w(t))return t}let s="";for(let o=0;o<e;o++){s+=t[o];const e=n[o];if(void 0!==e){const t=e.value;if(b(t)||!w(t))s+="string"==typeof t?t:String(t);else for(const e of t)s+="string"==typeof e?e:String(e)}}return s+=t[e],s}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class N{constructor(t){this.value=void 0,this.committer=t}setValue(t){t===a||b(t)&&t===this.value||(this.value=t,l(t)||(this.committer.dirty=!0))}commit(){for(;l(this.value);){const t=this.value;this.value=a,t(this)}this.value!==a&&this.committer.commit()}}class E{constructor(t){this.value=void 0,this.__pendingValue=void 0,this.options=t}appendInto(t){this.startNode=t.appendChild(m()),this.endNode=t.appendChild(m())}insertAfterNode(t){this.startNode=t,this.endNode=t.nextSibling}appendIntoPart(t){t.__insert(this.startNode=m()),t.__insert(this.endNode=m())}insertAfterPart(t){t.__insert(this.startNode=m()),this.endNode=t.endNode,t.endNode=this.startNode}setValue(t){this.__pendingValue=t}commit(){if(null===this.startNode.parentNode)return;for(;l(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=a,t(this)}const t=this.__pendingValue;t!==a&&(b(t)?t!==this.value&&this.__commitText(t):t instanceof y?this.__commitTemplateResult(t):t instanceof Node?this.__commitNode(t):w(t)?this.__commitIterable(t):t===c?(this.value=c,this.clear()):this.__commitText(t))}__insert(t){this.endNode.parentNode.insertBefore(t,this.endNode)}__commitNode(t){this.value!==t&&(this.clear(),this.__insert(t),this.value=t)}__commitText(t){const e=this.startNode.nextSibling,n="string"==typeof(t=null==t?"":t)?t:String(t);e===this.endNode.previousSibling&&3===e.nodeType?e.data=n:this.__commitNode(document.createTextNode(n)),this.value=t}__commitTemplateResult(t){const e=this.options.templateFactory(t);if(this.value instanceof _&&this.value.template===e)this.value.update(t.values);else{const n=new _(e,t.processor,this.options),s=n._clone();n.update(t.values),this.__commitNode(s),this.value=n}}__commitIterable(t){Array.isArray(this.value)||(this.value=[],this.clear());const e=this.value;let n,s=0;for(const o of t)n=e[s],void 0===n&&(n=new E(this.options),e.push(n),0===s?n.appendIntoPart(this):n.insertAfterPart(e[s-1])),n.setValue(o),n.commit(),s++;s<e.length&&(e.length=s,this.clear(n&&n.endNode))}clear(t=this.startNode){((t,e,n=null)=>{for(;e!==n;){const n=e.nextSibling;t.removeChild(e),e=n}})(this.startNode.parentNode,t.nextSibling,this.endNode)}}class S{constructor(t,e,n){if(this.value=void 0,this.__pendingValue=void 0,2!==n.length||""!==n[0]||""!==n[1])throw new Error("Boolean attributes can only contain a single expression");this.element=t,this.name=e,this.strings=n}setValue(t){this.__pendingValue=t}commit(){for(;l(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=a,t(this)}if(this.__pendingValue===a)return;const t=!!this.__pendingValue;this.value!==t&&(t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=t),this.__pendingValue=a}}class V extends x{constructor(t,e,n){super(t,e,n),this.single=2===n.length&&""===n[0]&&""===n[1]}_createPart(){return new T(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class T extends N{}let O=!1;(()=>{try{const t={get capture(){return O=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class ${constructor(t,e,n){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=n,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;l(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=a,t(this)}if(this.__pendingValue===a)return;const t=this.__pendingValue,e=this.value,n=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),s=null!=t&&(null==e||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=j(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=a}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const j=t=>t&&(O?{capture:t.capture,passive:t.passive,once:t.once}:t.capture);function A(t){return t.map((t=>M(t))).join("")}function L(t){for(var e in t)null==t[e]?delete t[e]:"object"==typeof t[e]&&L(t[e])}function M(t){if(!t)return"";if(t instanceof y)return t.toString();if(L(t),Array.isArray(t))return A(t);if("string"==typeof t)return t.startsWith("_html:")?t.substring(6):t;if(t.tag){const e=t.props?function(t){return Object.keys(t).map((e=>{return` ${"className"===e?"class":e}="${n=t[e],"object"==typeof n?Object.keys(n).map((t=>`${t}:${n[t]}`)).join(";"):n.toString()}"`;var n})).join("")}(t.props):"",n=t.children?A(t.children):"";return`<${t.tag}${e}>${n}</${t.tag}>`}return"object"==typeof t?JSON.stringify(t):void 0}new class{handleAttributeExpressions(t,e,n,s){const o=e[0];return"."===o?new V(t,e.slice(1),n).parts:"@"===o?[new $(t,e.slice(1),s.eventContext)]:"?"===o?[new S(t,e.slice(1),n)]:new x(t,e,n).parts}handleTextExpression(t){return new E(t)}},new Map,new WeakMap,"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const k=M;let C;function I(t){C=window.open("",t),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 P(t){C.document.write(t+"\n")}function R(){C.document.write("</pre>\n </body>\n </html>"),C.document.close()}app.debug=!0;const H=t=>{P(`import ${t.constructor.name} from '../src/${t.constructor.name}'`),P(`describe('${t.constructor.name}', ()=>{`),t._actions.forEach((e=>{"."!==e.name&&(P(` it ('should handle event: ${e.name}', (done)=>{`),P(` const component = new ${t.constructor.name}().mount();`),P(` component.run('${e.name}');`),P(" setTimeout(() => {"),P(" //expect(?).toHaveBeenCalled();"),P(" //expect(component.state).toBe(?);"),P(" done();"),P(" })"))})),P("});")};let B=!1,F=[];app.on("debug",(t=>{B&&t.vdom&&(F.push(t),console.log(`* ${F.length} state(s) recorded.`))}));var W;function D(t){const e=window.open("","_apprun_debug","toolbar=0");e.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">${t}</div>\n <\/script>\n </body>\n </html>`),e.document.close()}o.debug=!0,window["_apprun-help"]=["",()=>{Object.keys(window).forEach((t=>{t.startsWith("_apprun-")&&("_apprun-help"===t?console.log("AppRun Commands:"):console.log(`* ${t.substring(8)}: ${window[t][0]}`))}))}];const U=()=>{const t={components:{}};o.run("get-components",t);const{components:e}=t;return e};let X=Number(null===(W=null===window||void 0===window?void 0:window.localStorage)||void 0===W?void 0:W.getItem("__apprun_debugging__"))||0;if(o.on("debug",(t=>{1&X&&t.event&&console.log(t),2&X&&t.vdom&&console.log(t)})),window["_apprun-components"]=["components [print]",t=>{(t=>{const e=U(),n=[];if(e instanceof Map)for(let[t,s]of e){const e="string"==typeof t?document.getElementById(t):t;n.push({element:e,comps:s})}else Object.keys(e).forEach((t=>{const s="string"==typeof t?document.getElementById(t):t;n.push({element:s,comps:e[t]})}));if(t){const t=(t=>{const e=({events:t})=>o.h("ul",null,t&&t.filter((t=>"."!==t.name)).map((t=>o.h("li",null,t.name)))),n=({components:t})=>o.h("ul",null,t.map((t=>o.h("li",null,o.h("div",null,t.constructor.name),o.h(e,{events:t._actions})))));return o.h("ul",null,t.map((({element:t,comps:e})=>o.h("li",null,o.h("div",null,(t=>o.h("div",null,t.tagName.toLowerCase(),t.id?"#"+t.id:""," ",t.className&&t.className.split(" ").map((t=>"."+t)).join()))(t)),o.h(n,{components:e})))))})(n);D(k(t))}else n.forEach((({element:t,comps:e})=>console.log(t,e)))})("print"===t)}],window["_apprun-events"]=["events [print]",t=>{(t=>{const e=o._events,n={},s=U(),i=t=>t._actions.forEach((e=>{n[e.name]=n[e.name]||[],n[e.name].push(t)}));if(s instanceof Map)for(let[t,e]of s)e.forEach(i);else Object.keys(s).forEach((t=>s[t].forEach(i)));const l=[];if(Object.keys(n).forEach((t=>{l.push({event:t,components:n[t],global:!!e[t]})})),l.sort(((t,e)=>t.event>e.event?1:-1)).map((t=>t.event)),t){const t=(t=>{const e=({components:t})=>o.h("ul",null,t.map((t=>o.h("li",null,o.h("div",null,t.constructor.name))))),n=({events:t,global:n})=>o.h("ul",null,t&&t.filter((t=>t.global===n&&"."!==t.event)).map((({event:t,components:n})=>o.h("li",null,o.h("div",null,t),o.h(e,{components:n})))));return o.h("div",null,o.h("div",null,"GLOBAL EVENTS"),o.h(n,{events:t,global:!0}),o.h("div",null,"LOCAL EVENTS"),o.h(n,{events:t,global:!1}))})(l);D(k(t))}else console.log("=== GLOBAL EVENTS ==="),l.filter((t=>t.global&&"."!==t.event)).forEach((({event:t,components:e})=>console.log({event:t},e))),console.log("=== LOCAL EVENTS ==="),l.filter((t=>!t.global&&"."!==t.event)).forEach((({event:t,components:e})=>console.log({event:t},e)))})("print"===t)}],window["_apprun-log"]=["log [event|view] on|off",(t,e)=>{var n;"on"===t?X=3:"off"===t?X=0:"event"===t?"on"===e?X|=1:"off"===e&&(X&=-2):"view"===t&&("on"===e?X|=2:"off"===e&&(X&=-3)),console.log(`* log ${t} ${e||""}`),null===(n=null===window||void 0===window?void 0:window.localStorage)||void 0===n||n.setItem("__apprun_debugging__",`${X}`)}],window["_apprun-create-event-tests"]=["create-event-tests",()=>(()=>{const t={components:{}};app.run("get-components",t);const{components:e}=t;if(I(""),e instanceof Map)for(let[t,n]of e)n.forEach(H);else Object.keys(e).forEach((t=>{e[t].forEach(H)}));R()})()],window["_apprun-create-state-tests"]=["create-state-tests <start|stop>",t=>{var e;"start"===(e=t)?(F=[],B=!0,console.log("* State logging started.")):"stop"===e?(0!==F.length?(I(""),F.forEach(((t,e)=>{P(` it ('view snapshot: #${e+1}', ()=>{`),P(` const component = new ${t.component.constructor.name}()`),P(` const state = ${JSON.stringify(t.state,void 0,2)};`),P(" const vdom = component['view'](state);"),P(" expect(JSON.stringify(vdom)).toMatchSnapshot();"),P(" })")})),R()):console.log("* No state recorded."),B=!1,F=[],console.log("* State logging stopped.")):console.log("create-state-tests <start|stop>")}],window._apprun=t=>{const[e,...n]=t[0].split(" ").filter((t=>!!t)),s=window[`_apprun-${e}`];s?s[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 e=window.__REDUX_DEVTOOLS_EXTENSION__.connect();if(e){const n=location.hash||"#";e.send(n,"");const s=[{component:null,state:""}];console.info("Connected to the Redux DevTools"),e.subscribe((e=>{if("START"===e.type)t=!0;else if("STOP"===e.type)t=!1;else if("DISPATCH"===e.type){const t=e.payload.index;if(0===t)o.run(n);else{const{component:e,state:n}=s[t];null==e||e.setState(n)}}}));const i=(t,n,o)=>{null!=o&&(s.push({component:t,state:o}),e.send(n,o))};o.on("debug",(e=>{if(t&&e.event){const t=e.newState,n={type:e.event,payload:e.p},s=e.component;t instanceof Promise?t.then((t=>i(s,n,t))):i(s,n,t)}}))}}return 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,(function(){return(()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t);let n;const o="object"==typeof self&&self.self===self&&self||"object"==typeof e.g&&e.g.global===e.g&&e.g;o.app&&o._AppRunVersions?n=o.app:(n=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}},o.app=n,o._AppRunVersions="AppRun-3");const s=n;function l(e){return e.map((e=>i(e))).join("")}function c(e){for(var t in e)null==e[t]?delete e[t]:"object"==typeof e[t]&&c(e[t])}function i(e){if(!e)return"";if("_$litType$"in e)return e.toString();if(c(e),Array.isArray(e))return l(e);if("string"==typeof e)return e.startsWith("_html:")?e.substring(6):e;if(e.tag){const t=e.props?function(e){return Object.keys(e).map((t=>{return` ${"className"===t?"class":t}="${n=e[t],"object"==typeof n?Object.keys(n).map((e=>`${e}:${n[e]}`)).join(";"):n.toString()}"`;var n})).join("")}(e.props):"",n=e.children?l(e.children):"";return`<${e.tag}${t}>${n}</${e.tag}>`}return"object"==typeof e?JSON.stringify(e):void 0}const r=i;let a;function p(e){a=window.open("",e),a.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 u(e){a.document.write(e+"\n")}function f(){a.document.write("</pre>\n </body>\n </html>"),a.document.close()}app.debug=!0;const d=e=>{u(`import ${e.constructor.name} from '../src/${e.constructor.name}'`),u(`describe('${e.constructor.name}', ()=>{`),e._actions.forEach((t=>{"."!==t.name&&(u(` it ('should handle event: ${t.name}', (done)=>{`),u(` const component = new ${e.constructor.name}().mount();`),u(` component.run('${t.name}');`),u(" setTimeout(() => {"),u(" //expect(?).toHaveBeenCalled();"),u(" //expect(component.state).toBe(?);"),u(" done();"),u(" })"))})),u("});")};let m=!1,h=[];app.on("debug",(e=>{m&&e.vdom&&(h.push(e),console.log(`* ${h.length} state(s) recorded.`))}));var g;function v(e){const t=window.open("","_apprun_debug","toolbar=0");t.document.write(`<html>\n <title>AppRun Analyzer | ${document.location.href}</title>\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI" }\n li { margin-left: 80px; }\n </style>\n <body>\n <div id="main">${e}</div>\n <\/script>\n </body>\n </html>`),t.document.close()}s.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 y=()=>{const e={components:{}};s.run("get-components",e);const{components:t}=e;return t};let b=Number(null===(g=null===window||void 0===window?void 0:window.localStorage)||void 0===g?void 0:g.getItem("__apprun_debugging__"))||0;if(s.on("debug",(e=>{1&b&&e.event&&console.log(e),2&b&&e.vdom&&console.log(e)})),window["_apprun-components"]=["components [print]",e=>{(e=>{const t=y(),n=[];if(t instanceof Map)for(let[e,o]of t){const t="string"==typeof e?document.getElementById(e):e;n.push({element:t,comps:o})}else Object.keys(t).forEach((e=>{const o="string"==typeof e?document.getElementById(e):e;n.push({element:o,comps:t[e]})}));if(e){const e=(e=>{const t=({events:e})=>s.h("ul",null,e&&e.filter((e=>"."!==e.name)).map((e=>s.h("li",null,e.name)))),n=({components:e})=>s.h("ul",null,e.map((e=>s.h("li",null,s.h("div",null,e.constructor.name),s.h(t,{events:e._actions})))));return s.h("ul",null,e.map((({element:e,comps:t})=>s.h("li",null,s.h("div",null,(e=>s.h("div",null,e.tagName.toLowerCase(),e.id?"#"+e.id:""," ",e.className&&e.className.split(" ").map((e=>"."+e)).join()))(e)),s.h(n,{components:t})))))})(n);v(r(e))}else n.forEach((({element:e,comps:t})=>console.log(e,t)))})("print"===e)}],window["_apprun-events"]=["events [print]",e=>{(e=>{const t=s._events,n={},o=y(),l=e=>e._actions.forEach((t=>{n[t.name]=n[t.name]||[],n[t.name].push(e)}));if(o instanceof Map)for(let[e,t]of o)t.forEach(l);else Object.keys(o).forEach((e=>o[e].forEach(l)));const c=[];if(Object.keys(n).forEach((e=>{c.push({event:e,components:n[e],global:!!t[e]})})),c.sort(((e,t)=>e.event>t.event?1:-1)).map((e=>e.event)),e){const e=(e=>{const t=({components:e})=>s.h("ul",null,e.map((e=>s.h("li",null,s.h("div",null,e.constructor.name))))),n=({events:e,global:n})=>s.h("ul",null,e&&e.filter((e=>e.global===n&&"."!==e.event)).map((({event:e,components:n})=>s.h("li",null,s.h("div",null,e),s.h(t,{components:n})))));return s.h("div",null,s.h("div",null,"GLOBAL EVENTS"),s.h(n,{events:e,global:!0}),s.h("div",null,"LOCAL EVENTS"),s.h(n,{events:e,global:!1}))})(c);v(r(e))}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"===e)}],window["_apprun-log"]=["log [event|view] on|off",(e,t)=>{var n;"on"===e?b=3:"off"===e?b=0:"event"===e?"on"===t?b|=1:"off"===t&&(b&=-2):"view"===e&&("on"===t?b|=2:"off"===t&&(b&=-3)),console.log(`* log ${e} ${t||""}`),null===(n=null===window||void 0===window?void 0:window.localStorage)||void 0===n||n.setItem("__apprun_debugging__",`${b}`)}],window["_apprun-create-event-tests"]=["create-event-tests",()=>(()=>{const e={components:{}};app.run("get-components",e);const{components:t}=e;if(p(""),t instanceof Map)for(let[e,n]of t)n.forEach(d);else Object.keys(t).forEach((e=>{t[e].forEach(d)}));f()})()],window["_apprun-create-state-tests"]=["create-state-tests <start|stop>",e=>{var t;"start"===(t=e)?(h=[],m=!0,console.log("* State logging started.")):"stop"===t?(0!==h.length?(p(""),h.forEach(((e,t)=>{u(` it ('view snapshot: #${t+1}', ()=>{`),u(` const component = new ${e.component.constructor.name}()`),u(` const state = ${JSON.stringify(e.state,void 0,2)};`),u(" const vdom = component['view'](state);"),u(" expect(JSON.stringify(vdom)).toMatchSnapshot();"),u(" })")})),f()):console.log("* No state recorded."),m=!1,h=[],console.log("* State logging stopped.")):console.log("create-state-tests <start|stop>")}],window._apprun=e=>{const[t,...n]=e[0].split(" ").filter((e=>!!e)),o=window[`_apprun-${t}`];o?o[1](...n):window["_apprun-help"][1]()},console.info('AppRun DevTools 2.27: type "_apprun `help`" to list all available commands.'),window.__REDUX_DEVTOOLS_EXTENSION__){let e=!1;const t=window.__REDUX_DEVTOOLS_EXTENSION__.connect();if(t){const n=location.hash||"#";t.send(n,"");const o=[{component:null,state:""}];console.info("Connected to the Redux DevTools"),t.subscribe((t=>{if("START"===t.type)e=!0;else if("STOP"===t.type)e=!1;else if("DISPATCH"===t.type){const e=t.payload.index;if(0===e)s.run(n);else{const{component:t,state:n}=o[e];null==t||t.setState(n)}}}));const l=(e,n,s)=>{null!=s&&(o.push({component:e,state:s}),t.send(n,s))};s.on("debug",(t=>{if(e&&t.event){const e=t.newState,n={type:t.event,payload:t.p},o=t.component;e instanceof Promise?e.then((e=>l(o,n,e))):l(o,n,e)}}))}}return t})()}));
3
2
  //# sourceMappingURL=apprun-dev-tools.js.map