apprun 3.28.7 → 3.28.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-templates/webpack.config.js +2 -1
- package/dist/apprun-dev-tools.js +1 -2
- package/dist/apprun-dev-tools.js.map +1 -1
- package/dist/apprun-html.esm.js +10 -112
- package/dist/apprun-html.esm.js.map +1 -1
- package/dist/apprun-html.js +1 -1
- package/dist/apprun-html.js.LICENSE.txt +2 -24
- package/dist/apprun-html.js.map +1 -1
- package/dist/apprun-play.js +1 -1
- package/dist/apprun-play.js.map +1 -1
- package/dist/apprun.esm.js +1 -1
- package/dist/apprun.esm.js.map +1 -1
- package/dist/apprun.js +1 -1
- package/dist/apprun.js.map +1 -1
- package/esm/apprun-dev-tools.js +2 -1
- package/esm/apprun-dev-tools.js.map +1 -1
- package/esm/apprun.js +1 -1
- package/esm/apprun.js.map +1 -1
- package/esm/component.js +1 -1
- package/esm/component.js.map +1 -1
- package/esm/vdom-lit-html.js +40 -21
- package/esm/vdom-lit-html.js.map +1 -1
- package/esm/vdom-to-html.js +1 -2
- package/esm/vdom-to-html.js.map +1 -1
- package/package.json +18 -16
- package/src/apprun.ts +1 -1
- package/src/component.ts +1 -1
- package/src/vdom-lit-html.ts +42 -20
- package/src/vdom-to-html.tsx +2 -2
- package/webpack.config.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apprun",
|
|
3
|
-
"version": "3.28.
|
|
3
|
+
"version": "3.28.8",
|
|
4
4
|
"description": "JavaScript library that has Elm inspired architecture, event pub-sub and components",
|
|
5
5
|
"main": "dist/apprun.js",
|
|
6
6
|
"module": "dist/apprun.esm.js",
|
|
@@ -41,26 +41,27 @@
|
|
|
41
41
|
"commander": "^7.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@rollup/plugin-commonjs": "^
|
|
45
|
-
"@rollup/plugin-node-resolve": "^13.
|
|
46
|
-
"@types/jest": "^
|
|
47
|
-
"jest": "^27.
|
|
44
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
46
|
+
"@types/jest": "^27.4.0",
|
|
47
|
+
"jest": "^27.5.1",
|
|
48
48
|
"json-loader": "^0.5.7",
|
|
49
|
-
"lit-html": "1.
|
|
50
|
-
"marked": "^
|
|
51
|
-
"rollup": "^2.
|
|
52
|
-
"rollup-plugin-filesize": "^9.1.
|
|
49
|
+
"lit-html": "^2.1.3",
|
|
50
|
+
"marked": "^4.0.12",
|
|
51
|
+
"rollup": "^2.67.2",
|
|
52
|
+
"rollup-plugin-filesize": "^9.1.2",
|
|
53
53
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
54
54
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
55
55
|
"rollup-plugin-terser": "^7.0.2",
|
|
56
|
-
"ts-jest": "^27.
|
|
57
|
-
"ts-loader": "^9.2.
|
|
58
|
-
"typescript": "^4.
|
|
59
|
-
"webpack": "^5.
|
|
60
|
-
"webpack-cli": "^4.
|
|
61
|
-
"webpack-dev-server": "^
|
|
56
|
+
"ts-jest": "^27.1.3",
|
|
57
|
+
"ts-loader": "^9.2.6",
|
|
58
|
+
"typescript": "^4.5.5",
|
|
59
|
+
"webpack": "^5.68.0",
|
|
60
|
+
"webpack-cli": "^4.9.2",
|
|
61
|
+
"webpack-dev-server": "^4.7.4"
|
|
62
62
|
},
|
|
63
63
|
"jest": {
|
|
64
|
+
"testEnvironment": "jsdom",
|
|
64
65
|
"transformIgnorePatterns": [
|
|
65
66
|
"/node_modules/(?!lit-html).+\\.js"
|
|
66
67
|
],
|
|
@@ -81,6 +82,7 @@
|
|
|
81
82
|
"diagnostics": true,
|
|
82
83
|
"tsconfig": "tsconfig.jest.json"
|
|
83
84
|
}
|
|
84
|
-
}
|
|
85
|
+
},
|
|
86
|
+
"testRunner": "jest-jasmine2"
|
|
85
87
|
}
|
|
86
88
|
}
|
package/src/apprun.ts
CHANGED
|
@@ -27,7 +27,7 @@ app.webComponent = webComponent;
|
|
|
27
27
|
|
|
28
28
|
app.start = <T, E = any>(element?: Element, model?: T, view?: View<T>, update?: Update<T, E>,
|
|
29
29
|
options?: AppStartOptions<T>): Component<T, E> => {
|
|
30
|
-
const opts = {
|
|
30
|
+
const opts = { render: true, global_event: true, ...options };
|
|
31
31
|
const component = new Component<T, E>(model, view, update);
|
|
32
32
|
if (options && options.rendered) component.rendered = options.rendered;
|
|
33
33
|
component.mount(element, opts);
|
package/src/component.ts
CHANGED
|
@@ -127,7 +127,7 @@ export class Component<T = any, E = any> {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
start = (element = null, options?: MountOptions): Component<T, E> => {
|
|
130
|
-
return this.mount(element, {
|
|
130
|
+
return this.mount(element, { render: true, ...options });
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
public mount(element = null, options?: MountOptions): Component<T, E> {
|
package/src/vdom-lit-html.ts
CHANGED
|
@@ -1,38 +1,60 @@
|
|
|
1
1
|
import { createElement, updateElement, Fragment } from './vdom-my';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { render, svg, html, noChange, nothing } from 'lit-html';
|
|
5
|
+
import { directive, Directive, Part, PartInfo, PartType, EventPart } from 'lit-html/directive.js';
|
|
6
|
+
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
4
7
|
|
|
5
8
|
function _render(element, vdom, parent?) {
|
|
9
|
+
if (!vdom) return;
|
|
6
10
|
if (typeof vdom === 'string') {
|
|
7
11
|
render(html`${unsafeHTML(vdom)}`, element);
|
|
8
|
-
} else if (
|
|
12
|
+
} else if ('_$litType$' in vdom) {
|
|
13
|
+
if (!element['_$litPart$']) element.replaceChildren();
|
|
9
14
|
render(vdom, element);
|
|
10
15
|
} else {
|
|
11
16
|
updateElement(element, vdom, parent);
|
|
12
|
-
|
|
17
|
+
element['_$litPart$'] = undefined;
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
export class RunDirective extends Directive {
|
|
22
|
+
// State stored in class field
|
|
23
|
+
value: number | undefined;
|
|
24
|
+
constructor(partInfo: PartInfo) {
|
|
25
|
+
super(partInfo);
|
|
26
|
+
// When necessary, validate part in constructor using `part.type`
|
|
27
|
+
if (partInfo.type !== PartType.EVENT) {
|
|
28
|
+
throw new Error('${run} can only be used in event handlers');
|
|
29
|
+
}
|
|
19
30
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
// Optional: override update to perform any direct DOM manipulation
|
|
32
|
+
update(part: Part, params) {
|
|
33
|
+
/* Any imperative updates to DOM/parts would go here */
|
|
34
|
+
|
|
35
|
+
let { element, name } = part as EventPart;
|
|
36
|
+
const getComponent = () => {
|
|
37
|
+
let component = element['_component'];
|
|
38
|
+
while (!component && element) {
|
|
39
|
+
element = element.parentElement;
|
|
40
|
+
component = element && element['_component'];
|
|
41
|
+
}
|
|
42
|
+
console.assert(!!component, 'Component not found.');
|
|
43
|
+
return component;
|
|
44
|
+
}
|
|
45
|
+
const [event, ...args] = params;
|
|
46
|
+
if (typeof event === 'string') {
|
|
47
|
+
element[`on${name}`] = e => getComponent().run(event, ...args, e);
|
|
48
|
+
} else if (typeof event === 'function') {
|
|
49
|
+
element[`on${name}`] = e => getComponent().setState(event(getComponent().state, ...args, e));
|
|
26
50
|
}
|
|
27
|
-
|
|
28
|
-
return component;
|
|
51
|
+
return this.render();
|
|
29
52
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} else if (typeof event === 'function') {
|
|
33
|
-
element[`on${eventName}`] = e => getComponent().setState(event(getComponent().state, ...args, e));
|
|
53
|
+
render() {
|
|
54
|
+
return noChange;
|
|
34
55
|
}
|
|
35
|
-
}
|
|
56
|
+
}
|
|
36
57
|
|
|
58
|
+
const run = directive(RunDirective) as any;
|
|
37
59
|
export { createElement, Fragment, html, svg, _render as render, run };
|
|
38
60
|
|
package/src/vdom-to-html.tsx
CHANGED