apprun 4.0.0 → 6.0.0-rc.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.
Files changed (135) hide show
  1. package/CHANGELOG.md +235 -12
  2. package/LICENSE +1 -1
  3. package/README.md +225 -110
  4. package/apprun.d.ts +240 -34
  5. package/cli/app.js +29 -0
  6. package/cli/colors.js +69 -0
  7. package/cli/index.html +13 -0
  8. package/cli/index.js +96 -0
  9. package/dist/apprun-code.js +2 -0
  10. package/dist/apprun-code.js.map +1 -0
  11. package/dist/apprun-dev-tools.js +1 -1
  12. package/dist/apprun-dev-tools.js.map +1 -1
  13. package/dist/apprun-html.esm.js +34 -0
  14. package/dist/apprun-html.esm.js.map +1 -0
  15. package/dist/apprun-html.js +2 -1
  16. package/dist/apprun-html.js.LICENSE.txt +11 -0
  17. package/dist/apprun-html.js.map +1 -1
  18. package/dist/apprun-play.js +2 -0
  19. package/dist/apprun-play.js.map +1 -0
  20. package/dist/apprun.esm.js +2 -0
  21. package/dist/apprun.esm.js.map +1 -0
  22. package/dist/apprun.js +1 -1
  23. package/dist/apprun.js.map +1 -1
  24. package/dist/createState.js +2 -0
  25. package/dist/createState.js.map +1 -0
  26. package/esm/add-components.js +90 -0
  27. package/esm/add-components.js.map +1 -0
  28. package/esm/app.js +209 -0
  29. package/esm/app.js.map +1 -0
  30. package/esm/apprun-code.js +170 -0
  31. package/esm/apprun-code.js.map +1 -0
  32. package/esm/apprun-dev-tools-tests.js +95 -0
  33. package/esm/apprun-dev-tools-tests.js.map +1 -0
  34. package/esm/apprun-dev-tools.js +281 -0
  35. package/esm/apprun-dev-tools.js.map +1 -0
  36. package/esm/apprun-html.js +24 -0
  37. package/esm/apprun-html.js.map +1 -0
  38. package/esm/apprun-play.js +248 -0
  39. package/esm/apprun-play.js.map +1 -0
  40. package/esm/apprun.js +220 -0
  41. package/esm/apprun.js.map +1 -0
  42. package/esm/component.js +413 -0
  43. package/esm/component.js.map +1 -0
  44. package/esm/createState.js +9 -0
  45. package/esm/createState.js.map +1 -0
  46. package/esm/decorator.js +88 -0
  47. package/esm/decorator.js.map +1 -0
  48. package/esm/directive.js +306 -0
  49. package/esm/directive.js.map +1 -0
  50. package/esm/router.js +345 -0
  51. package/esm/router.js.map +1 -0
  52. package/esm/type-utils.js +90 -0
  53. package/esm/type-utils.js.map +1 -0
  54. package/esm/types.js +58 -0
  55. package/esm/types.js.map +1 -0
  56. package/esm/vdom-lit-html.js +65 -0
  57. package/esm/vdom-lit-html.js.map +1 -0
  58. package/esm/vdom-my-prop-attr.js +227 -0
  59. package/esm/vdom-my-prop-attr.js.map +1 -0
  60. package/esm/vdom-my.js +293 -0
  61. package/esm/vdom-my.js.map +1 -0
  62. package/esm/vdom-to-html.js +54 -0
  63. package/esm/vdom-to-html.js.map +1 -0
  64. package/esm/vdom.js +28 -0
  65. package/esm/vdom.js.map +1 -0
  66. package/esm/version.js +15 -0
  67. package/esm/version.js.map +1 -0
  68. package/esm/web-component.js +155 -0
  69. package/esm/web-component.js.map +1 -0
  70. package/jsx-runtime.js +2 -0
  71. package/jsx-runtime.js.map +1 -0
  72. package/package.json +90 -41
  73. package/.travis.yml +0 -10
  74. package/.vscode/launch.json +0 -19
  75. package/BACKERS.md +0 -3
  76. package/apprun-cli.js +0 -177
  77. package/cli-templates/_gitignore +0 -6
  78. package/cli-templates/component.ts_ +0 -16
  79. package/cli-templates/index.html +0 -11
  80. package/cli-templates/karma.conf.js +0 -24
  81. package/cli-templates/main.ts_ +0 -13
  82. package/cli-templates/readme.md +0 -7
  83. package/cli-templates/spa_index.html +0 -14
  84. package/cli-templates/spa_main.ts_ +0 -47
  85. package/cli-templates/spec.ts_ +0 -11
  86. package/cli-templates/tsconfig.json +0 -12
  87. package/cli-templates/webpack.config.js +0 -23
  88. package/demo-html/app.js +0 -2
  89. package/demo-html/app.js.map +0 -1
  90. package/demo-html/counter-c.html +0 -29
  91. package/demo-html/counter-wc-event.html +0 -29
  92. package/demo-html/counter-wc.html +0 -29
  93. package/demo-html/counter.html +0 -26
  94. package/demo-html/index.html +0 -14
  95. package/demo-html/main.tsx +0 -31
  96. package/docs/README.md +0 -326
  97. package/docs/index.html +0 -23
  98. package/index.html +0 -85
  99. package/logo.png +0 -0
  100. package/src/app.ts +0 -69
  101. package/src/apprun-dev-tools.tsx +0 -67
  102. package/src/apprun-html.ts +0 -13
  103. package/src/apprun.ts +0 -53
  104. package/src/component.ts +0 -189
  105. package/src/createComponent.tsx +0 -38
  106. package/src/decorator.ts +0 -36
  107. package/src/router.ts +0 -19
  108. package/src/types.ts +0 -9
  109. package/src/vdom-html.ts +0 -17
  110. package/src/vdom-my.ts +0 -191
  111. package/src/vdom-to-html.tsx +0 -45
  112. package/src/vdom.ts +0 -7
  113. package/src/web-component.ts +0 -29
  114. package/tests/app-rx.spec_ +0 -41
  115. package/tests/app.spec.ts +0 -122
  116. package/tests/application.spec.tsx +0 -23
  117. package/tests/component.spec.tsx +0 -296
  118. package/tests/custom-element.spec.tsx +0 -19
  119. package/tests/data-attr.spec.tsx +0 -42
  120. package/tests/decorator.spec.tsx +0 -104
  121. package/tests/fragment.spec.tsx +0 -79
  122. package/tests/hyperscript.spec.ts +0 -43
  123. package/tests/node-test.js +0 -7
  124. package/tests/router.spec.ts +0 -69
  125. package/tests/stateful-component.spec.tsx +0 -248
  126. package/tests/typed.spec.tsx +0 -63
  127. package/tests/vdom-html.spec.ts +0 -35
  128. package/tests/vdom-jsx.spec.tsx +0 -131
  129. package/tests/vdom-my.spec.tsx +0 -195
  130. package/tests/view-engine.spec.js +0 -59
  131. package/tsconfig.json +0 -11
  132. package/tslint.json +0 -124
  133. package/typescriptreact.json +0 -87
  134. package/viewEngine.js +0 -54
  135. package/webpack.config.js +0 -30
package/apprun-cli.js DELETED
@@ -1,177 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- 'use strict';
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 index_html = path.resolve('./index.html');
12
- const main_tsx = path.resolve('./main.tsx');
13
- const spa_index = path.resolve('./index.html');
14
- const spa_main_tsx = path.resolve('./main.tsx');
15
- const readme_md = path.resolve('./README.md');
16
- const execSync = require('child_process').execSync;
17
- const program = require('commander');
18
-
19
- let show_start = false;
20
- let show_test = false;
21
-
22
- function read(name) {
23
- return fs.readFileSync(path.resolve(__dirname + '/cli-templates', name), 'utf8');
24
- }
25
-
26
- function write(file_name, text, title = 'Creating', overwrite = false) {
27
- const file = path.resolve(file_name);
28
- if (!fs.existsSync(file) || overwrite) {
29
- process.stdout.write(`${title}: ${file} ... `);
30
- fs.writeFileSync(
31
- file,
32
- text
33
- );
34
- process.stdout.write('Done\n');
35
- } else {
36
- process.stdout.write(`No change made. File exists: ${file}\n`);
37
- }
38
- }
39
-
40
- function init() {
41
- RegExp.prototype.toJSON = RegExp.prototype.toString;
42
-
43
- if (!fs.existsSync(package_json)) {
44
- console.log('Initializing package.json');
45
- execSync('npm init -y');
46
- }
47
-
48
- console.log('Installing packages. This might take a couple minutes.');
49
- execSync('npm install webpack webpack-cli webpack-dev-server ts-loader typescript source-map-loader --save-dev');
50
- execSync('npm install apprun --save');
51
-
52
- write(tsconfig_json, read('tsconfig.json'));
53
- write(webpack_config_js, read('webpack.config.js'))
54
- write(index_html, read('index.html'));
55
- write(main_tsx, read('main.ts_'));
56
- write(readme_md, read('readme.md'));
57
-
58
- console.log('Adding npm scripts');
59
- const package_info = require(package_json);
60
- if (!package_info.scripts) package_info["scripts"] = {}
61
- if (!package_info.scripts['start']) {
62
- package_info["scripts"]["start"] = 'webpack-dev-server --mode development';
63
- }
64
- if (!package_info.scripts['build']) {
65
- package_info["scripts"]["build"] = 'webpack -p --mode production';
66
- }
67
- fs.writeFileSync(
68
- package_json,
69
- JSON.stringify(package_info, null, 2)
70
- );
71
- git_init();
72
- jest_init();
73
- show_start = true;
74
- }
75
-
76
- function git_init() {
77
- if (!fs.existsSync('.git')) {
78
- console.log('Initializing git');
79
- execSync('git init');
80
- } else {
81
- console.log('Skip git init. .git exsits');
82
- }
83
- write(git_ignore_file, read('_gitignore'));
84
- }
85
-
86
- function component(name) {
87
- const fn = path.resolve(name + '.tsx');
88
- const component_template = read('component.ts_');
89
- write(name + '.tsx', component_template.replace(/\#name/g, name),
90
- `Creating component ${name}`);
91
- show_start = true;
92
- }
93
-
94
- function karma_init() {
95
- console.log('Installing karma');
96
- execSync('npm i @types/jasmine jasmine-core karma karma-chrome-launcher karma-jasmine karma-webpack --save-dev');
97
- write('karma.conf.js', read('karma.conf.js'));
98
- show_test = true;
99
- }
100
-
101
- function jest_init() {
102
- console.log('Installing jest');
103
- execSync('npm i @types/jest jest ts-jest --save-dev');
104
-
105
- const jest_config = {
106
- "transform": {
107
- "^.+\\.tsx?$": "ts-jest"
108
- },
109
- "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
110
- "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
111
- "globals": {
112
- "ts-jest": {
113
- "enableTsDiagnostics": true
114
- }
115
- }
116
- }
117
- delete require.cache[require.resolve(package_json)];
118
- const package_info = require(package_json) || {};
119
- package_info["jest"] = jest_config
120
-
121
- package_info["scripts"]["test"] = 'jest --watch';
122
- fs.writeFileSync(
123
- package_json,
124
- JSON.stringify(package_info, null, 2)
125
- );
126
-
127
- show_test = true;
128
- }
129
-
130
- function component_spec(name) {
131
- const fn = path.resolve(name + '.spec.ts');
132
- const test_template = read('spec.ts_');
133
- write(fn, test_template.replace(/\#name/g, name),
134
- `Creating component spec ${name}`);
135
- show_test = true;
136
- }
137
-
138
- function spa() {
139
- write(spa_index, read('spa_index.html'), 'Creating', true);
140
- write(spa_main_tsx, read('spa_main.ts_'), 'Creating', true);
141
- component('Home');
142
- component('About');
143
- component('Contact');
144
- show_start = true;
145
- }
146
-
147
- program
148
- .name('apprun')
149
- .version('1.12.6')
150
- .option('-i, --init', 'Initialize AppRun Project')
151
- .option('-c, --component <file>', 'Generate AppRun component')
152
- .option('-g, --git', 'Initialize git repository')
153
- .option('-j, --jest', 'Install jest')
154
- .option('-k, --karma', 'Install karma')
155
- .option('-t, --test <file>', 'Generate component spec')
156
- .option('-s, --spa', 'Generate SPA app')
157
- .parse(process.argv);
158
-
159
- program._name = 'apprun';
160
-
161
- if (!program.init && !program.component && !program.git && !program.jest &&
162
- !program.karma && !program.test && !program.spa) {
163
- program.outputHelp();
164
- process.exit()
165
- }
166
-
167
- if (program.init) init();
168
- if (program.component) component(program.component);
169
- if (program.git) git_init();
170
- if (program.jest) jest_init();
171
- if (program.karma) karma_init();
172
- if (program.test) component_spec(program.test);
173
- if (program.spa) spa();
174
-
175
- console.log('\r');
176
- if (show_start) console.log('All done. You can run `npm start` and then navigate to http://localhost:8080 in a browser.');
177
- //if (show_test) console.log('All done. You can run `npm test`.');
@@ -1,6 +0,0 @@
1
- .DS_Store
2
- Thumbs.db
3
- *.log
4
- node_modules
5
- coverage
6
- .cache
@@ -1,16 +0,0 @@
1
- import app, {Component} from 'apprun';
2
-
3
- export default class #nameComponent extends Component {
4
- state = '#name';
5
-
6
- view = (state) => {
7
- return <div>
8
- <h1>{state}</h1>
9
- </div>
10
- }
11
-
12
- update = {
13
- '##name': state => state,
14
- }
15
- }
16
-
@@ -1,11 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>apprun</title>
6
- </head>
7
- <body>
8
- <div id="my-app"></div>
9
- <script src="app.js"></script>
10
- </body>
11
- </html>
@@ -1,24 +0,0 @@
1
- var webpackConfig = require('./webpack.config');
2
- module.exports = function (config) {
3
- config.set({
4
- basePath: '',
5
- frameworks: ["jasmine"],
6
- files: [
7
- { pattern: "tests/*.spec.*" }
8
- ],
9
- exclude: [
10
- ],
11
- preprocessors: {
12
- 'tests/*.spec.*': ['webpack'],
13
- },
14
- webpack: webpackConfig,
15
- reporters: ["progress"],
16
- colors: true,
17
- // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
18
- logLevel: config.LOG_INFO,
19
- browsers: ['Chrome'],
20
- mime: {
21
- 'text/x-typescript': ['ts', 'tsx']
22
- }
23
- })
24
- }
@@ -1,13 +0,0 @@
1
- import app from 'apprun';
2
-
3
- const model = 'Hello world - AppRun !';
4
-
5
- const view = (state) => <div>
6
- <h1>{state}</h1>
7
- </div>;
8
-
9
- const update = {
10
-
11
- }
12
-
13
- app.start('my-app', model, view, update);
@@ -1,7 +0,0 @@
1
- ##
2
-
3
- * Use _npm start_ to start the dev server
4
- * Use _npm test_ to run unit tests
5
- * Use _npm run build_ to build for production
6
-
7
- This is an application built with [AppRun](https://github.com/yysun/apprun).
@@ -1,14 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
- <title>AppRun</title>
7
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
8
- integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
9
- </head>
10
- <body>
11
- <div id="main"></div>
12
- <script src="app.js"></script>
13
- </body>
14
- </html>
@@ -1,47 +0,0 @@
1
- import app from 'apprun';
2
-
3
- app.on('#', _ => app.run('#Home'))
4
-
5
- app.on('//', route => {
6
- const menus = document.querySelectorAll('.navbar-nav li');
7
- for (let i = 0; i < menus.length; ++i) menus[i].classList.remove('active');
8
- const item = document.querySelector(`[href='${route}']`);
9
- item && item.parentElement.classList.add('active');
10
- })
11
-
12
- const view = state => <div className="container">
13
- <nav className="navbar navbar-expand-lg navbar-light bg-light">
14
- <a className="navbar-brand" href="#">Project Name</a>
15
- <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
16
- aria-expanded="false" aria-label="Toggle navigation">
17
- <span className="navbar-toggler-icon"></span>
18
- </button>
19
- <div className="collapse navbar-collapse" id="navbarSupportedContent">
20
- <ul className="navbar-nav mr-auto">
21
- <li className="nav-item active">
22
- <a className="nav-link" href="#Home">Home
23
- <span className="sr-only">(current)</span>
24
- </a>
25
- </li>
26
- <li className="nav-item">
27
- <a className="nav-link" href="#About">About</a>
28
- </li>
29
- <li className="nav-item">
30
- <a className="nav-link" href="#Contact">Contact</a>
31
- </li>
32
- </ul>
33
- </div>
34
- </nav>
35
- <div className="container" id="my-app"></div>
36
- </div>
37
-
38
- app.start('main', {}, view, {})
39
-
40
- import Home from './Home';
41
- import About from './About';
42
- import Contact from './Contact';
43
-
44
- const element = 'my-app';
45
- new Home().mount(element);
46
- new About().mount(element);
47
- new Contact().mount(element);
@@ -1,11 +0,0 @@
1
- import app from 'apprun'
2
- import #name from './#name';
3
-
4
- describe('component', () => {
5
- it('should render state upon route event', () => {
6
- const element = document.createElement('div');
7
- const component = new #name().mount(element);
8
- app.run('##name');
9
- expect(element.textContent).toBe('#name');
10
- })
11
- })
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2015",
4
- "module": "es2015",
5
- "moduleResolution": "node",
6
- "jsx": "react",
7
- "reactNamespace": "app",
8
- "lib": ["dom", "es2015", "es5"],
9
- "experimentalDecorators": true,
10
- "sourceMap": true
11
- }
12
- }
@@ -1,23 +0,0 @@
1
- const path = require('path');
2
- module.exports = {
3
- entry: {
4
- 'app': './main.tsx',
5
- },
6
- output: {
7
- filename: '[name].js',
8
- path: path.resolve(__dirname)
9
- },
10
- resolve: {
11
- extensions: ['.ts', '.tsx', '.js']
12
- },
13
- module: {
14
- rules: [
15
- { test: /.tsx?$/, loader: 'ts-loader' },
16
- { test: /\.js$/, use: ["source-map-loader"], enforce: "pre" }
17
- ]
18
- },
19
- devServer: {
20
- open: true
21
- },
22
- devtool: 'source-map'
23
- }
package/demo-html/app.js DELETED
@@ -1,2 +0,0 @@
1
- !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 function(t){var e={};function n(s){if(e[s])return e[s].exports;var o=e[s]={i:s,l:!1,exports:{}};return t[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(s,o,function(e){return t[e]}.bind(null,o));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0});class n{constructor(){this._events={}}on(t,e,n={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:n})}off(t,e){let n=this._events[t];n&&((n=n.filter(t=>t.fn!==e)).length?this._events[t]=n:delete this._events[t])}run(t,...e){let n=this._events[t];console.assert(!!n,"No subscriber for event: "+t),n&&((n=n.filter(n=>{const{fn:s,options:o}=n;return o.delay?this.delay(t,s,e,o):s.apply(this,e),!n.options.once})).length?this._events[t]=n:delete this._events[t])}once(t,e,n={}){this.on(t,e,Object.assign({},n,{once:!0}))}delay(t,e,n,s){s._t&&clearTimeout(s._t),s._t=setTimeout(()=>{clearTimeout(s._t),e.apply(this,n)},s.delay)}}let s;e.App=n;const o=t||window;o.app&&o.app.start?s=o.app:(s=new n,o.app=s),e.default=s}).call(this,n(3))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=n(0),o=n(9),i=n(7);e.Component=i.Component;const r=n(2);e.on=r.on,e.update=r.update,e.event=r.update;const a=n(6),c=n(5);s.default.createElement=o.createElement,s.default.render=o.render,s.default.Fragment=o.Fragment,s.default.webComponent=c.default,s.default.start=((t,e,n,s,o)=>{const r=Object.assign(o||{},{render:!0,global_event:!0}),a=new i.Component(e,n,s);return o&&o.rendered&&(a.rendered=o.rendered),a.mount(t,r),a}),s.default.route||(s.default.route=a.default,s.default.on("//",t=>{}),s.default.on("#",t=>{}),s.default.on("route",t=>a.default(t)),"object"==typeof document&&document.addEventListener("DOMContentLoaded",()=>{window.onpopstate=(()=>a.default(location.hash)),a.default(location.hash)})),e.default=s.default,s.default.on("debug",t=>0)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Reflect={meta:new WeakMap,defineMetadata(t,e,n){this.meta.has(n)||this.meta.set(n,{}),this.meta.get(n)[t]=e},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,e){return e=Object.getPrototypeOf(e),this.meta.get(e)?this.meta.get(e)[t]:null}},e.update=function(t,n={}){return(s,o,i)=>(t=t||o,e.Reflect.defineMetadata(`apprun-update:${t}`,{name:t,key:o,options:n},s),i)},e.on=function(t,n={}){return function(s,o){t=t||o,e.Reflect.defineMetadata(`apprun-update:${t}`,{name:t,key:o,options:n},s)}}},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=n(8),o="_props";function i(t){const e=[],n=t=>{null!==t&&void 0!==t&&""!==t&&!1!==t&&e.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach(t=>{Array.isArray(t)?t.forEach(t=>n(t)):n(t)}),e}e.createElement=function(t,e,...n){const s=i(n);return"string"==typeof t?{tag:t,props:e,children:s}:void 0===t&&n?s:Object.getPrototypeOf(t).__isAppRunComponent?{tag:t,props:e,children:s}:t(e,s)};const r={};function a(t,e,n={}){if(null!=e&&(e=s.default(e,n),t))if(Array.isArray(e))l(t,e);else{const n=e;t.firstChild?c(t.firstChild,n):t.appendChild(u(n))}}function c(t,e){console.assert(!!t),function(t,e){return t.nodeName===`${e.tag||""}`.toUpperCase()}(t,e)?(l(t,e.children),h(t,e.props)):t.parentNode.replaceChild(u(e),t)}function l(t,e){const n=Math.min(t.childNodes.length,e.length);for(let s=0;s<n;s++){const n=e[s],o=t.childNodes[s];if("string"==typeof n)o.textContent!==n&&(3===o.nodeType?o.textContent=n:t.replaceChild(d(n),o));else{const e=n.props&&n.props.key;if(e)if(o.key===e)c(t.childNodes[s],n);else{const i=e&&r[e];i?(t.replaceChild(i,o),t.appendChild(o),c(t.childNodes[s],n)):(t.appendChild(u(n),o),c(t.childNodes[s],n))}else c(t.childNodes[s],n)}}let s=t.childNodes.length;for(;s>n;)t.removeChild(t.lastChild),s--;if(e.length>n){const s=document.createDocumentFragment();for(let t=n;t<e.length;t++)s.appendChild(u(e[t]));t.appendChild(s)}}function d(t){if(0===t.indexOf("_html:")){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",t.substring(6)),e}return document.createTextNode(t)}function u(t){if(console.assert(null!==t&&void 0!==t),"string"==typeof t)return d(t);if(!t.tag||"function"==typeof t.tag)return d(JSON.stringify(t));const e="svg"===t.tag?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return h(e,t.props),t.children&&t.children.forEach(t=>e.appendChild(u(t))),e}function h(t,e){console.assert(!!t),e=function(t,e){const n={};return t&&Object.keys(t).forEach(t=>n[t]=""),e&&Object.keys(e).forEach(t=>n[t]=e[t]),n}(t[o]||{},e),t[o]=e;for(let n in e){const s=e[n];if("style"===n){t.style.cssText&&(t.style.cssText="");for(let e in s)t.style[e]!==s[e]&&(t.style[e]=s[e])}else if(n.startsWith("data-")){const e=n.substring(5);t.dataset[e]!==s&&(t.dataset[e]=s)}else n.startsWith("role")||n.startsWith("aria-")?t.getAttribute(n)!==s&&t.setAttribute(n,s):(t[n]!==s&&(t[n]=s),"key"===n&&s&&(r[s]=t))}}e.updateElement=a,e.render=a,e.Fragment=function(t,...e){return i(e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.customElement=((t,e={})=>(class extends HTMLElement{constructor(){super();const n=Object.assign({render:!0,shadow:!1},e);this._shadowRoot=n.shadow?this.attachShadow({mode:"open"}):this;const s={};Array.from(this.attributes).forEach(t=>s[t.name]=t.value),this.children&&(s.children=Array.from(this.children),s.children.forEach(t=>t.parentElement.removeChild(t))),this._component=new t(s).mount(this._shadowRoot,n),this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component)}get state(){return this._component.state}})),e.default=((t,n,s)=>{customElements&&customElements.define(t,e.customElement(n,s))})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=n(0),o="//";e.default=function(t){if(t||(t="#"),t.startsWith("#")){const[e,...n]=t.split("/");s.default.run(e,...n),s.default.run(o,e,...n)}else if(t.startsWith("/")){const[e,n,...i]=t.split("/");s.default.run("/"+n,...i),s.default.run(o,"/"+n,...i)}else s.default.run(t),s.default.run(o,t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=n(0),o=n(2),i={};s.default.on("get-components",t=>t.components=i);class r{constructor(t,e,n,o){this.state=t,this.view=e,this.update=n,this.options=o,this._app=new s.App,this._actions=[],this._history=[],this._history_idx=-1,this.start=((t=null,e={render:!0})=>this.mount(t,Object.assign({},e,{render:!0})))}renderState(t){if(!this.view)return;const e=this.view(t);if(s.default.run("debug",{component:this,state:t,vdom:e||"[vdom is null - no render]"}),"object"!=typeof document)return;const n="string"==typeof this.element?document.getElementById(this.element):this.element;n&&(n._component=this),s.default.render(n,e,this),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){if(t instanceof Promise)t.then(t=>{this.setState(t,e)}).catch(t=>{throw console.error(t),t}),this.state=t;else{if(null==t)return;this.state=t,!1!==e.render&&this.renderState(t),!1!==e.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof e.callback&&e.callback(this.state)}}mount(t=null,e){if(console.assert(!this.element,"Component already mounted."),this.options=e=Object.assign(this.options||{},e),this.element=t,this.global_event=e.global_event,this.enable_history=!!e.history,this.enable_history){const t=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},n=()=>{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.on(e.history.prev||"history-prev",t),this.on(e.history.next||"history-next",n)}return this.add_actions(),void 0===this.state&&(this.state=this.model||{}),e.render?this.setState(this.state,{render:!0,history:!0}):this.setState(this.state,{render:!1,history:!0}),i[t]=i[t]||[],i[t].push(this),this}is_global_event(t){return t&&(t.startsWith("#")||t.startsWith("/"))}add_action(t,e,n={}){e&&"function"==typeof e&&this.on(t,(...o)=>{const i=e(this.state,...o);s.default.run("debug",{component:this,event:t,e:o,state:this.state,newState:i,options:n}),this.setState(i,n)},n)}add_actions(){const t=this.update||{};o.Reflect.getMetadataKeys(this).forEach(e=>{if(e.startsWith("apprun-update:")){const n=o.Reflect.getMetadata(e,this);t[n.name]=[this[n.key].bind(this),n.options]}});const e={};Object.keys(t).forEach(n=>{const s=t[n];("function"==typeof s||Array.isArray(s))&&n.split(",").forEach(t=>e[t.trim()]=s)}),Object.keys(e).forEach(t=>{const n=e[t];"function"==typeof n?this.add_action(t,n):Array.isArray(n)&&this.add_action(t,n[0],n[1])})}run(t,...e){return this.global_event||this.is_global_event(t)?s.default.run(t,...e):this._app.run(t,...e)}on(t,e,n){return this._actions.push({name:t,fn:e}),this.global_event||this.is_global_event(t)?s.default.on(t,e,n):this._app.on(t,e,n)}unmount(){this._actions.forEach(t=>{const{name:e,fn:n}=t;this.global_event||this.is_global_event(e)?s.default.off(e,n):this._app.off(e,n)})}}r.__isAppRunComponent=!0,e.Component=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=n(0);e.default=function t(e,n,o=0){if("string"==typeof e)return e;if(Array.isArray(e))return e.map(e=>t(e,n,o++));let i=e;return e&&e.tag&&Object.getPrototypeOf(e.tag).__isAppRunComponent&&(i=function(t,e,n){const{tag:o,props:i,children:r}=t;let a=i&&i.id,c=`_${o.name}_${n}`;a?c=`_${o.name}_${a}`:a=`_${o.name}_${n}`,e.__componentCache||(e.__componentCache={});let l=e.__componentCache[c];l||(l=e.__componentCache[c]=new o(Object.assign({},i,{children:r})).mount(a)),l.mounted&&l.mounted(i,r);const d=l.state;let u="";return d instanceof Promise||!l.view||(u=l.view(d),l.rendered&&l.rendered(d)),s.default.createElement("div",{id:a},u)}(e,n,o++)),i&&i.children&&(i.children=i.children.map(e=>t(e,n,o++))),i}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=n(4);e.createElement=s.createElement,e.Fragment=s.Fragment,e.render=function(t,e,n){s.updateElement(t,e,n)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const s=n(1);s.default.webComponent("my-app",class extends s.Component{constructor({num:t,children:e}){super(),this.view=(t=>s.default.createElement("div",null,s.default.createElement("h1",null,t))),this.update={"-1":t=>t-1,"+1":t=>t+1},this.rendered=(t=>{this.children.forEach(t=>{this.element.firstElementChild.appendChild(t)}),this.element.setAttribute("num",t)}),this.children=e,this.state=parseInt(t)}})}])});
2
- //# sourceMappingURL=app.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["webpack://apprun/webpack/universalModuleDefinition","webpack://apprun/webpack/bootstrap","webpack://apprun/./src/app.ts","webpack://apprun/./src/apprun.ts","webpack://apprun/./src/decorator.ts","webpack://apprun/(webpack)/buildin/global.js","webpack://apprun/./src/vdom-my.ts","webpack://apprun/./src/web-component.ts","webpack://apprun/./src/router.ts","webpack://apprun/./src/component.ts","webpack://apprun/./src/createComponent.tsx","webpack://apprun/./src/vdom.ts","webpack://apprun/./demo-html/main.tsx"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","App","[object Object]","_events","fn","options","push","subscribers","filter","sub","length","args","console","assert","delay","apply","once","on","assign","_t","clearTimeout","setTimeout","app","global","window","default","app_1","vdom_1","component_1","Component","decorator_1","update","event","router_1","web_component_1","createElement","render","Fragment","webComponent","start","element","model","view","opts","global_event","component","rendered","mount","_","url","document","addEventListener","onpopstate","location","hash","Reflect","meta","WeakMap","metadataKey","metadataValue","target","has","set","getPrototypeOf","keys","descriptor","defineMetadata","g","Function","eval","e","createComponent_1","ATTR_PROPS","collect","children","ch","undefined","forEach","Array","isArray","tag","props","__isAppRunComponent","keyCache","nodes","parent","updateChildren","node","firstChild","appendChild","el","nodeName","toUpperCase","same","updateProps","parentNode","replaceChild","len","Math","min","childNodes","child","textContent","nodeType","createText","old","removeChild","lastChild","createDocumentFragment","indexOf","div","insertAdjacentHTML","substring","createTextNode","JSON","stringify","createElementNS","a","b","mergeProps","style","cssText","startsWith","dname","dataset","getAttribute","setAttribute","updateElement","customElement","componentClass","HTMLElement","super","shadow","_shadowRoot","attachShadow","from","attributes","item","parentElement","_component","run","state","customElements","ROUTER_EVENT","rest","split","componentCache","components","_app","_actions","_history","_history_idx","html","vdom","getElementById","history","Promise","then","setState","catch","err","error","renderState","enable_history","callback","prev","next","add_actions","action","newState","actions","getMetadataKeys","getMetadata","all","trim","add_action","is_global_event","off","createComponent","idx","map","id","__componentCache","mounted","vdom_my_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M+D,GAAOP,cAAY3B,MAAMsI,IAEnFxI,EAAU0I,SAAW1I,EAAU0I,QAAQtG,EAAOP,GAC9C,MAAMmE,EAAQhG,EAAUgG,MACxB,IAAIY,EAAO,GAKX,OAJMZ,aAAiBe,UAAY/G,EAAUH,OAC3C+G,EAAO5G,EAAUH,KAAKmG,GACtBhG,EAAUC,UAAYD,EAAUC,SAAS+F,IAEpCnH,EAAAD,QAAAU,cAAA,OAAKkJ,GAAIA,GAAK5B,GAO+DrH,CAAOmD,EAAMF,EAAQ8F,MACrG1B,GAAQA,EAAK/E,WAAU+E,EAAK/E,SAAW+E,EAAK/E,SAAS0G,IAAI/E,GAAS6E,EAAgB7E,EAAOhB,EAAQ8F,OAC9F1B,kFClCT,MAAA+B,EAAAzN,EAAA,GAISN,EAAA0E,cAJAqJ,EAAArJ,cAIe1E,EAAA4E,SAJemJ,EAAAnJ,SACvC5E,EAAA2E,OAAA,SAAuBI,EAASgH,EAAMnE,GACpCmG,EAAAzD,cAAcvF,EAASgH,EAAMnE,mFCD/B,MAAAoG,EAAA1N,EAAA,GA6BA0N,EAAAhK,QAAIa,aAAa,uBA3BGmJ,EAAA5J,UAoBlB3B,aAAYwL,IAAEA,EAAGhH,SAAEA,IACjByD,QAlBFtK,KAAA6E,KAAO,CAACmG,GACC4C,EAAAhK,QAAAU,cAAA,WAAKsJ,EAAAhK,QAAAU,cAAA,UAAK0G,KAGnBhL,KAAAkE,QACE4J,KAAO9C,GAAUA,EAAQ,EACzB+C,KAAO/C,GAAUA,EAAQ,GAI3BhL,KAAAiF,SAAW+F,KACThL,KAAK6G,SAASG,QAAQa,IACpB7H,KAAK2E,QAAQqJ,kBAAkBpG,YAAYC,KAE7C7H,KAAK2E,QAAQsF,aAAa,MAAOe,KAKjChL,KAAK6G,SAAWA,EAChB7G,KAAKgL,MAAQiD,SAASJ","file":"demo-html/app.js","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, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 10);\n","export class App {\n\n private _events: Object;\n\n public start;\n public createElement;\n public render;\n public Fragment;\n public webComponent;\n\n constructor() {\n this._events = {};\n }\n\n on(name: string, fn: (...args) => void, options: any = {}) {\n this._events[name] = this._events[name] || [];\n this._events[name].push({ fn: fn, options: options });\n }\n\n off(name: string, fn: (...args) => void) {\n let subscribers = this._events[name];\n if (subscribers) {\n subscribers = subscribers.filter((sub) => sub.fn !== fn);\n if (subscribers.length) this._events[name] = subscribers;\n else delete this._events[name]\n }\n }\n\n run(name: string, ...args) {\n let subscribers = this._events[name];\n console.assert(!!subscribers, 'No subscriber for event: ' + name);\n if (subscribers) {\n subscribers = subscribers.filter((sub) => {\n const { fn, options } = sub;\n if (options.delay) {\n this.delay(name, fn, args, options);\n } else {\n fn.apply(this, args);\n }\n return !sub.options.once;\n });\n if (subscribers.length) this._events[name] = subscribers;\n else delete this._events[name]\n }\n }\n\n once(name: string, fn, options: any = {}) {\n this.on(name, fn, { ...options, once: true });\n }\n\n private delay(name, fn, args, options) {\n if (options._t) clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n fn.apply(this, args);\n }, options.delay);\n }\n}\n\nlet app: App;\ndeclare var global;\nconst root = global || window;\nif (root['app'] && root['app']['start']) {\n app = root['app'];\n} else {\n app = new App();\n root['app'] = app;\n}\nexport default app;\n","import app from './app';\nimport { createElement, render, Fragment } from './vdom';\nimport { Component } from './component';\nimport { VNode, View, Action, Update } from './types';\nimport { on, update } from './decorator';\nimport route from './router';\nimport webComponent from './web-component';\n\nexport interface IApp {\n start<T>(element?: Element | string, model?: T, view?: View<T>, update?: Update<T>,\n options?: { history?, rendered?: (state: T) => void}): Component<T>;\n on(name: string, fn: (...args: any[]) => void, options?: any): void;\n off(name: string, fn: (...args: any[]) => void): void;\n run(name: string, ...args: any[]): void;\n createElement(tag: string | Function, props, ...children): VNode | VNode[];\n render(element: HTMLElement, node: VNode): void;\n Fragment(props, ...children): any[];\n webComponent(name: string, componentClass, options?): void;\n}\n\napp.createElement = createElement;\napp.render = render;\napp.Fragment = Fragment;\napp.webComponent = webComponent;\n\napp.start = <T>(element?: HTMLElement | string, model?: T, view?: View<T>, update?: Update<T>,\n options?: { history?, rendered?: (state: T) => void }) : Component<T> => {\n const opts = Object.assign(options || {}, { render: true, global_event: true });\n const component = new Component<T>(model, view, update);\n if (options && options.rendered) component.rendered = options.rendered;\n component.mount(element, opts);\n return component;\n};\n\nif (!app['route']) {\n app['route'] = route;\n app.on('//', _ => { });\n app.on('#', _ => { });\n app.on('route', url => route(url));\n if (typeof document === 'object') {\n document.addEventListener(\"DOMContentLoaded\", () => {\n window.onpopstate = () => route(location.hash);\n route(location.hash);\n });\n }\n}\n\nexport type StatelessComponent<T={}> = (args: T) => string | VNode | void;\nexport { Component, View, Action, Update, on, update };\nexport { update as event };\nexport default app as IApp;\n\napp.on('debug', _ => 0);","export const Reflect = {\n\n meta: new WeakMap(),\n\n defineMetadata(metadataKey, metadataValue, target) {\n if (!this.meta.has(target)) this.meta.set(target, {});\n this.meta.get(target)[metadataKey] = metadataValue;\n },\n\n getMetadataKeys(target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? Object.keys(this.meta.get(target)) : [];\n },\n\n getMetadata(metadataKey, target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? this.meta.get(target)[metadataKey] : null;\n }\n}\n\nexport function update(name?: string, options: any = {}) {\n return (target: any, key: string, descriptor: any) => {\n name = name || key;\n Reflect.defineMetadata(`apprun-update:${name}`,\n { name, key, options }, target);\n return descriptor;\n }\n}\n\nexport function on(name?: string, options: any = {}) {\n return function (target: any, key: string) {\n name = name || key;\n Reflect.defineMetadata(`apprun-update:${name}`,\n { name, key, options }, target)\n }\n}\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import createComponent from './createComponent';\nimport { VNode } from './types';\nexport type Element = any; //HTMLElement | SVGSVGElement | SVGElement;\n\nconst ATTR_PROPS = '_props';\n\nfunction collect(children) {\n const ch = [];\n const push = (c) => {\n if (c !== null && c !== undefined && c !== '' && c !== false) {\n ch.push((typeof c === 'function' || typeof c === 'object') ? c : `${c}`);\n }\n }\n children && children.forEach(c => {\n if (Array.isArray(c)) {\n c.forEach(i => push(i));\n } else {\n push(c);\n }\n });\n return ch;\n}\n\nexport function createElement (tag: string | Function, props: {}, ...children) {\n const ch = collect(children);\n if (typeof tag === 'string') return { tag, props, children: ch };\n else if (tag === undefined && children) return ch; // JSX fragments\n else if (Object.getPrototypeOf(tag).__isAppRunComponent) {\n return { tag, props, children:ch } // createComponent(tag, { ...props, children });\n }\n else\n return tag(props, ch);\n};\n\nconst keyCache = {};\n\nexport const updateElement = render;\n\nexport function render(element: Element, nodes: VNode | VNode[], parent = {}) {\n // console.log('render', element, node);\n if (nodes == null) return;\n\n nodes = createComponent(nodes, parent);\n\n if (!element) return;\n if (Array.isArray(nodes)) {\n updateChildren(element, nodes);\n } else {\n const node = nodes;\n if (!element.firstChild) {\n element.appendChild(create(node));\n } else {\n update(element.firstChild, node);\n }\n }\n}\n\nfunction same(el: Element, node: VNode) {\n // if (!el || !node) return false;\n const key1 = el.nodeName;\n const key2 = `${node.tag || ''}`;\n return key1 === key2.toUpperCase();\n}\n\nfunction update(element: Element, node: VNode) {\n console.assert(!!element);\n //console.log('update', element, node);\n if (!same(element, node)) {\n element.parentNode.replaceChild(create(node), element);\n return;\n }\n updateChildren(element, node.children);\n updateProps(element, node.props);\n}\n\nfunction updateChildren(element, children) {\n const len = Math.min(element.childNodes.length, children.length);\n for (let i = 0; i < len; i++) {\n const child = children[i];\n const el = element.childNodes[i];\n if (typeof child === 'string') {\n if (el.textContent !== child) {\n if (el.nodeType === 3) {\n el.textContent = child\n } else {\n element.replaceChild(createText(child), el);\n }\n }\n } else {\n const key = child.props && child.props['key'];\n if (key) {\n if (el.key === key) {\n update(element.childNodes[i], child);\n } else {\n const old = key && keyCache[key];\n if (old) {\n element.replaceChild(old, el);\n element.appendChild(el);\n update(element.childNodes[i], child);\n } else {\n element.appendChild(create(child), el);\n update(element.childNodes[i], child);\n }\n }\n } else {\n update(element.childNodes[i], child);\n }\n }\n }\n\n let n = element.childNodes.length;\n while (n > len) {\n element.removeChild(element.lastChild);\n n--;\n }\n\n if (children.length > len) {\n const d = document.createDocumentFragment();\n for (let i = len; i < children.length; i++) {\n d.appendChild(create(children[i]));\n }\n element.appendChild(d);\n }\n}\n\nfunction createText(node) {\n if (node.indexOf('_html:') === 0) { // ?\n const div = document.createElement('div');\n div.insertAdjacentHTML('afterbegin', node.substring(6))\n return div;\n } else {\n return document.createTextNode(node);\n }\n}\n\nfunction create(node: VNode | string): Element {\n console.assert(node !== null && node !== undefined);\n // console.log('create', node, typeof node);\n\n if (typeof node === \"string\") return createText(node);\n if (!node.tag || (typeof node.tag == 'function')) return createText(JSON.stringify(node));\n\n const element = (node.tag === \"svg\")\n ? document.createElementNS(\"http://www.w3.org/2000/svg\", node.tag)\n : document.createElement(node.tag);\n\n updateProps(element, node.props);\n\n if (node.children) node.children.forEach(child => element.appendChild(create(child)));\n\n return element\n}\n\nfunction mergeProps(a: {}, b: {}): {} {\n const props = {};\n if (a) Object.keys(a).forEach(p => props[p] = '');\n if (b) Object.keys(b).forEach(p => props[p] = b[p]);\n return props;\n}\n\nfunction updateProps(element: Element, props: {}) {\n console.assert(!!element);\n // console.log('updateProps', element, props);\n\n const cached = element[ATTR_PROPS] || {};\n props = mergeProps(cached, props);\n element[ATTR_PROPS] = props;\n for (let name in props) {\n const value = props[name];\n // if (cached[name] === value) continue;\n // console.log('updateProps', name, value);\n if (name === 'style') {\n if (element.style.cssText) element.style.cssText = '';\n for (let s in value) {\n if (element.style[s] !== value[s]) element.style[s] = value[s];\n }\n } else if (name.startsWith('data-')) {\n const dname = name.substring(5);\n if (element.dataset[dname] !== value) element.dataset[dname] = value;\n } else if (name.startsWith(\"role\") || name.startsWith(\"aria-\")) {\n if (element.getAttribute(name) !== value) element.setAttribute(name, value)\n } else {\n if (element[name] !== value) element[name] = value;\n if (name === 'key' && value) keyCache[value] = element;\n }\n }\n}\n\nexport function Fragment(props, ...children): any[] {\n return collect(children);\n}","import { Component } from './component';\ndeclare var customElements;\n\nexport const customElement = (componentClass, options={}) => class extends HTMLElement {\n private _shadowRoot;\n private _component;\n public on;\n public run;\n constructor() {\n super();\n const opts = { render: true, shadow: false, ...options };\n this._shadowRoot = opts.shadow ?\n this.attachShadow({ mode: 'open' }) : this;\n const props = {}\n Array.from(this.attributes).forEach(item => props[item.name] = item.value);\n if (this.children) {\n props['children'] = Array.from(this.children);\n props['children'].forEach(el => el.parentElement.removeChild(el));\n }\n this._component = new componentClass(props).mount(this._shadowRoot, opts);\n this.on = this._component.on.bind(this._component);\n this.run = this._component.run.bind(this._component);\n }\n get state() { return this._component.state; }\n}\n\nexport default (name: string, componentClass, options?) => {\n customElements && customElements.define(name, customElement(componentClass, options))\n}","import app from './app';\n\nconst ROUTER_EVENT = '//';\n\nexport default function route(url: string) {\n if (!url) url = '#';\n if (url.startsWith('#')) {\n const [name, ...rest] = url.split('/');\n app.run(name, ...rest);\n app.run(ROUTER_EVENT, name, ...rest);\n } else if (url.startsWith('/')) {\n const [_, name, ...rest] = url.split('/');\n app.run('/' + name, ...rest);\n app.run(ROUTER_EVENT, '/' + name, ...rest);\n } else {\n app.run(url);\n app.run(ROUTER_EVENT, url);\n }\n}\n","\r\nimport app, { App } from './app';\r\nimport { Reflect } from './decorator'\r\nimport { VNode, View, Update } from './types';\r\n\r\nconst componentCache = {};\r\napp.on('get-components', o => o.components = componentCache);\r\n\r\nexport class Component<T=any> {\r\n static __isAppRunComponent = true;\r\n private _app = new App();\r\n private _actions = [];\r\n element;\r\n private _history = [];\r\n private _history_idx = -1;\r\n private enable_history;\r\n private global_event;\r\n public rendered;\r\n public mounted;\r\n\r\n private renderState(state: T) {\r\n if (!this.view) return;\r\n const html = this.view(state);\r\n\r\n app.run('debug', {\r\n component: this,\r\n state,\r\n vdom: html || '[vdom is null - no render]',\r\n });\r\n\r\n if (typeof document !== 'object') return;\r\n\r\n const el = (typeof this.element === 'string') ?\r\n document.getElementById(this.element) : this.element;\r\n if (el) el['_component'] = this;\r\n app.render(el, html, this);\r\n if (this.rendered) (this.rendered(this.state));\r\n }\r\n\r\n public setState(state: T, options: { render: boolean, history: boolean, callback?}\r\n = { render: true, history: false}) {\r\n if (state instanceof Promise) {\r\n // Promise will not be saved or rendered\r\n // state will be saved and rendered when promise is resolved\r\n state.then(s => {\r\n this.setState(s, options)\r\n }).catch(err => {\r\n console.error(err);\r\n throw err;\r\n });\r\n this.state = state;\r\n } else {\r\n if (state == null) return;\r\n this.state = state;\r\n if (options.render !== false) this.renderState(state);\r\n if (options.history !== false && this.enable_history) {\r\n this._history = [...this._history, state];\r\n this._history_idx = this._history.length - 1;\r\n }\r\n if (typeof options.callback === 'function') options.callback(this.state);\r\n }\r\n }\r\n\r\n constructor(\r\n protected state?: T,\r\n protected view?: View<T>,\r\n protected update?: Update<T>,\r\n protected options?) {\r\n }\r\n\r\n start = (element = null,\r\n options: { render?: boolean, history?, global_event?: boolean } = { render: true }): Component<T> => {\r\n return this.mount(element, { ...options, render: true });\r\n }\r\n\r\n public mount(element = null, options?: { render?: boolean, history?, global_event?: boolean}) {\r\n\r\n console.assert(!this.element, 'Component already mounted.')\r\n this.options = options = Object.assign(this.options || {}, options);\r\n this.element = element;\r\n this.global_event = options.global_event;\r\n this.enable_history = !!options.history;\r\n\r\n if (this.enable_history) {\r\n const prev = () => {\r\n this._history_idx --;\r\n if (this._history_idx >=0) {\r\n this.setState(this._history[this._history_idx], { render: true, history: false });\r\n }\r\n else {\r\n this._history_idx = 0;\r\n }\r\n };\r\n\r\n const next = () => {\r\n this._history_idx ++;\r\n if (this._history_idx < this._history.length) {\r\n this.setState(this._history[this._history_idx], { render: true, history: false });\r\n }\r\n else {\r\n this._history_idx = this._history.length - 1;\r\n }\r\n };\r\n this.on(options.history.prev || 'history-prev', prev)\r\n this.on(options.history.next || 'history-next', next)\r\n }\r\n this.add_actions();\r\n if (this.state === undefined) this.state = this['model'] || {};\r\n if (options.render) {\r\n this.setState(this.state, { render: true, history: true });\r\n } else {\r\n this.setState(this.state, { render: false, history: true });\r\n }\r\n\r\n componentCache[element] = componentCache[element] || [];\r\n componentCache[element].push(this);\r\n return this;\r\n }\r\n\r\n is_global_event(name: string): boolean {\r\n return name && (name.startsWith('#') || name.startsWith('/'));\r\n }\r\n\r\n add_action(name: string, action, options: any = {}) {\r\n if (!action || typeof action !== 'function') return;\r\n this.on(name, (...p) => {\r\n const newState = action(this.state, ...p);\r\n\r\n app.run('debug', {\r\n component: this,\r\n 'event': name,\r\n e: p,\r\n state: this.state,\r\n newState,\r\n options\r\n })\r\n\r\n this.setState(newState, options)\r\n }, options);\r\n }\r\n\r\n add_actions() {\r\n const actions = this.update || {};\r\n Reflect.getMetadataKeys(this).forEach(key => {\r\n if (key.startsWith('apprun-update:')) {\r\n const meta = Reflect.getMetadata(key, this)\r\n actions[meta.name] = [this[meta.key].bind(this), meta.options];\r\n }\r\n })\r\n const all = {};\r\n Object.keys(actions).forEach(name => {\r\n const action = actions[name];\r\n if (typeof action === 'function' || Array.isArray(action)) {\r\n name.split(',').forEach(n => all[n.trim()] = action)\r\n }\r\n })\r\n\r\n Object.keys(all).forEach(name => {\r\n const action = all[name];\r\n if (typeof action === 'function') {\r\n this.add_action(name, action);\r\n } else if (Array.isArray(action)) {\r\n this.add_action(name, action[0], action[1]);\r\n }\r\n });\r\n }\r\n\r\n public run(name: string, ...args) {\r\n return this.global_event || this.is_global_event(name) ?\r\n app.run(name, ...args) :\r\n this._app.run(name, ...args);\r\n }\r\n\r\n public on(name: string, fn: (...args) => void, options?: any) {\r\n this._actions.push({ name, fn });\r\n return this.global_event || this.is_global_event(name) ?\r\n app.on(name, fn, options) :\r\n this._app.on(name, fn, options);\r\n }\r\n\r\n public unmount() {\r\n this._actions.forEach(action => {\r\n const { name, fn } = action;\r\n this.global_event || this.is_global_event(name) ?\r\n app.off(name, fn) :\r\n this._app.off(name, fn);\r\n });\r\n }\r\n}\r\n","import app from './app';\n\nfunction render(node, parent, idx) {\n const { tag, props, children } = node;\n\n let id = props && props['id'];\n let key = `_${tag.name}_${idx}`\n if (!id) {\n id = `_${tag.name}_${idx}`;\n } else {\n key = `_${tag.name}_${id}`;\n }\n\n if (!parent.__componentCache) parent.__componentCache = {};\n let component = parent.__componentCache[key];\n if (!component) {\n component = parent.__componentCache[key] = new tag({ ...props, children }).mount(id);\n }\n component.mounted && component.mounted(props, children);\n const state = component.state;\n let vdom = '';\n if (!(state instanceof Promise) && component.view) {\n vdom = component.view(state);\n component.rendered && component.rendered(state);\n }\n return <div id={id}>{vdom}</div>;\n}\n\nfunction createComponent(node, parent, idx = 0) {\n if (typeof node === 'string') return node;\n if (Array.isArray(node)) return node.map(child => createComponent(child, parent, idx++));\n let vdom = node;\n if (node && node.tag && Object.getPrototypeOf(node.tag).__isAppRunComponent) vdom = render(node, parent, idx++);\n if (vdom && vdom.children) vdom.children = vdom.children.map(child => createComponent(child, parent, idx++));\n return vdom;\n }\n\nexport default createComponent;\n","import { createElement, updateElement, Fragment } from './vdom-my';\nexport function render(element, html, parent?) {\n updateElement(element, html, parent);\n}\nexport { createElement, Fragment };\n\n\n","\nimport app, { Component } from '../src/apprun';\ndeclare var customElements;\nclass MyApp extends Component {\n // state = 0/\n\n view = (state) => {\n return <div><h1>{state}</h1></div>\n }\n\n update = {\n '-1': (state) => state - 1,\n '+1': (state) => state + 1\n }\n\n children;\n rendered = state => {\n this.children.forEach(el => {\n this.element.firstElementChild.appendChild(el)\n });\n this.element.setAttribute('num', state);\n }\n\n constructor({ num, children } ) {\n super();\n this.children = children;\n this.state = parseInt(num);\n }\n}\n\napp.webComponent('my-app', MyApp);"],"sourceRoot":""}
@@ -1,29 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Counter as web component</title>
6
- </head>
7
- <body>
8
- <div id="my-app"></div>
9
- <script src="../dist/apprun-html.js"></script>
10
- <script>
11
- class Counter extends Component {
12
- constructor() {
13
- super();
14
- this.state = 0;
15
- this.view = state => `<div>
16
- <h1>${state}</h1>
17
- <button onclick='app.run("-1")'>-1</button>
18
- <button onclick='app.run("+1")'>+1</button>
19
- </div>`;
20
- this.update = {
21
- '+1': state => state + 1,
22
- '-1': state => state - 1
23
- };
24
- }
25
- }
26
- new Counter().start('my-app', {global_event: true});
27
- </script>
28
- </body>
29
- </html>
@@ -1,29 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Counter as web component</title>
6
- </head>
7
- <body>
8
- <my-app id='counter'></my-app>
9
- <script src="../dist/apprun-html.js"></script>
10
- <script>
11
- class Counter extends Component {
12
- constructor() {
13
- super();
14
- this.state = 0;
15
- this.view = state => `<div>
16
- <h1>${state}</h1>
17
- <button onclick='counter.run("-1")'>-1</button>
18
- <button onclick='counter.run("+1")'>+1</button>
19
- </div>`;
20
- this.update = {
21
- '+1': state => state + 1,
22
- '-1': state => state - 1
23
- };
24
- }
25
- }
26
- app.webComponent('my-app', Counter);
27
- </script>
28
- </body>
29
- </html>
@@ -1,29 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Counter as web component</title>
6
- </head>
7
- <body>
8
- <my-app />
9
- <script src="../dist/apprun-html.js"></script>
10
- <script>
11
- class Counter extends Component {
12
- constructor() {
13
- super();
14
- this.state = 0;
15
- this.view = state => `<div>
16
- <h1>${state}</h1>
17
- <button onclick='app.run("-1")'>-1</button>
18
- <button onclick='app.run("+1")'>+1</button>
19
- </div>`;
20
- this.update = {
21
- '+1': state => state + 1,
22
- '-1': state => state - 1
23
- };
24
- }
25
- }
26
- app.webComponent('my-app', Counter, {global_event: true, shadow: true});
27
- </script>
28
- </body>
29
- </html>
@@ -1,26 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Counter</title>
6
- </head>
7
- <body>
8
- <script src="../dist/apprun-html.js"></script>
9
- <div id="my-app"></div>
10
- <script>
11
- const state = 0;
12
- const view = state => {
13
- return `<div>
14
- <h1>${state}</h1>
15
- <button onclick='app.run("-1")'>-1</button>
16
- <button onclick='app.run("+1")'>+1</button>
17
- </div>`;
18
- };
19
- const update = {
20
- '+1': state => state + 1,
21
- '-1': state => state - 1
22
- };
23
- app.start('my-app', state, view, update);
24
- </script>
25
- </body>
26
- </html>
@@ -1,14 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>apprun - web component</title>
6
- </head>
7
- <body>
8
- <my-app id="counter" num="2">
9
- <button onclick="counter.run('-1')">-1</button>
10
- <button onclick="counter.run('+1')">+1</button>
11
- </my-app>
12
- <script src="app.js"></script>
13
- </body>
14
- </html>