@snupo/jmc 1.0.62 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/design-guide.md +193 -0
- package/dist/base.d.ts +3 -2
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +11 -13
- package/dist/base.js.map +1 -1
- package/dist/events.js +1 -0
- package/dist/events.js.map +1 -1
- package/dist/h.d.ts +14 -7
- package/dist/h.d.ts.map +1 -1
- package/dist/h.js +7 -4
- package/dist/h.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/jmc.d.ts +1 -12
- package/dist/jmc.d.ts.map +1 -1
- package/dist/jmc.js +80 -119
- package/dist/jmc.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +5 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +6 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +14 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +10 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx.d.ts +39 -46
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js.map +1 -1
- package/dist/lib.d.ts +5 -3
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +4 -5
- package/dist/lib.js.map +1 -1
- package/dist/props.d.ts +11 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +43 -0
- package/dist/props.js.map +1 -0
- package/dist/update.d.ts +10 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +48 -0
- package/dist/update.js.map +1 -0
- package/package.json +31 -4
- package/readme.md +313 -34
- package/src/base.ts +11 -15
- package/src/events.ts +1 -1
- package/src/h.ts +29 -18
- package/src/index.ts +2 -1
- package/src/jmc.ts +90 -138
- package/src/jsx-dev-runtime.ts +8 -0
- package/src/jsx-runtime.ts +17 -0
- package/src/jsx.ts +18 -30
- package/src/lib.ts +10 -8
- package/src/props.ts +43 -0
- package/src/update.ts +54 -0
- package/dist/updateview.d.ts +0 -17
- package/dist/updateview.d.ts.map +0 -1
- package/dist/updateview.js +0 -43
- package/dist/updateview.js.map +0 -1
- package/src/updateview.ts +0 -48
package/dist/jmc.js
CHANGED
|
@@ -1,130 +1,102 @@
|
|
|
1
1
|
import { rebind } from './base.js';
|
|
2
|
-
import {
|
|
3
|
-
let iswebcomponent = (h) => h.tag.includes('-');
|
|
4
|
-
let attributeNames = new Set([
|
|
5
|
-
'selected',
|
|
6
|
-
'viewBox',
|
|
7
|
-
'list'
|
|
8
|
-
// other HTML attributes where your framework wants attribute semantics
|
|
9
|
-
]);
|
|
10
|
-
export let jmcconfig = {
|
|
11
|
-
attributeNames
|
|
12
|
-
};
|
|
13
|
-
const isproperty = (e, name, value) => !attributeNames.has(name) &&
|
|
14
|
-
(value instanceof Object ||
|
|
15
|
-
value instanceof Function || (e.namespaceURI !== 'http://www.w3.org/2000/svg' &&
|
|
16
|
-
name in e &&
|
|
17
|
-
name !== 'style'));
|
|
18
|
-
let setprops = (e, old, now) => {
|
|
19
|
-
old ??= {};
|
|
20
|
-
now ??= {};
|
|
21
|
-
// removals
|
|
22
|
-
for (let p in old) {
|
|
23
|
-
if (!(p in now)) {
|
|
24
|
-
if (p.startsWith('on'))
|
|
25
|
-
setevent(e, p.slice(2), null);
|
|
26
|
-
else if (isproperty(e, p, old[p]))
|
|
27
|
-
e[p] = typeof old[p] === 'boolean' ? false : '';
|
|
28
|
-
else
|
|
29
|
-
e.removeAttribute(p);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// updates
|
|
33
|
-
for (let p in now) {
|
|
34
|
-
let v = now[p];
|
|
35
|
-
v = v?.thunk ? v() : v;
|
|
36
|
-
if (p.startsWith('on'))
|
|
37
|
-
setevent(e, p.slice(2), v);
|
|
38
|
-
else if (v != old[p]) {
|
|
39
|
-
if (isproperty(e, p, v))
|
|
40
|
-
e[p] = v;
|
|
41
|
-
else if ((v === false || v == null) && !p.startsWith('aria-'))
|
|
42
|
-
e.removeAttribute(p);
|
|
43
|
-
else
|
|
44
|
-
e.setAttribute(p, v);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
2
|
+
import { jmcconfig, setprops } from './props.js';
|
|
48
3
|
let removeexcesschildren = (n, i) => {
|
|
49
4
|
let c;
|
|
50
5
|
while ((c = n.childNodes[i])) {
|
|
51
6
|
try {
|
|
52
7
|
c.remove();
|
|
53
8
|
}
|
|
54
|
-
catch
|
|
9
|
+
catch { } // due to blur-event-handlers, this can fail
|
|
55
10
|
}
|
|
56
11
|
};
|
|
57
|
-
/** synchronizes children starting at the i-th
|
|
12
|
+
/** synchronizes children starting at the i-th node. returns the index after the last child synchronized */
|
|
58
13
|
let syncchildren = (p, cn, i, depth, uc) => {
|
|
59
|
-
cn.flat(999)
|
|
60
|
-
.filter((hc) => hc !== null && hc !== undefined) // skip. keep 0 and false renderable, per comment below)
|
|
61
|
-
.forEach((hc) => (i = sync(p, i, hc, undefined, depth, uc)));
|
|
14
|
+
cn.flat(999).forEach((hc) => (i = sync(p, i, hc, undefined, depth, uc)));
|
|
62
15
|
return i;
|
|
63
16
|
};
|
|
17
|
+
/** class components must render exactly one root node, they are attached to it and update through it */
|
|
18
|
+
let assertnonfragment = (h, hv, i, j) => {
|
|
19
|
+
if (j - i != 1 || hv?.kind == 4)
|
|
20
|
+
throw new Error(`${h.tag.name}.view() must render exactly one root element`);
|
|
21
|
+
};
|
|
64
22
|
function sync(parent, i, h, hfun, depth, uc) {
|
|
65
|
-
// console.log('%csync', "background:orange", parent.tagName, i, h, hfun, depth)
|
|
66
|
-
if (h === null || h === undefined)
|
|
67
|
-
return i; // skip. keep 0 and false renderable, per comment below
|
|
68
23
|
let c = parent.childNodes[i];
|
|
24
|
+
// null, undefined and booleans render nothing, like in React, so {cond && <b />} works. 0 is still rendered.
|
|
25
|
+
// nothing still takes its slot, as a placeholder: so the siblings after it keep their position, and with it their state
|
|
26
|
+
if (h == null || typeof h == 'boolean') {
|
|
27
|
+
if (hfun?.kind != 3)
|
|
28
|
+
h = ''; // an empty text node, invisible
|
|
29
|
+
else {
|
|
30
|
+
// a class component rendering nothing is attached to a comment, so it keeps its state and can show itself again
|
|
31
|
+
if (c?.nodeType != 8 /* NodeType.Comment */) {
|
|
32
|
+
let n = new Comment();
|
|
33
|
+
c ? c.replaceWith(n) : parent.append(n);
|
|
34
|
+
c = n;
|
|
35
|
+
}
|
|
36
|
+
c.h = hfun;
|
|
37
|
+
return i + 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
69
40
|
switch (h.kind) {
|
|
70
41
|
case 1: {
|
|
42
|
+
// element
|
|
71
43
|
let n;
|
|
72
|
-
let { tag, cn, p } = h;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
n.h = hfun ?? h; // sets the new property values
|
|
77
|
-
if (--depth &&
|
|
78
|
-
!n.hasAttribute('const') &&
|
|
79
|
-
!iswebcomponent(h)) {
|
|
80
|
-
const j = syncchildren(n, cn, 0, depth, uc);
|
|
81
|
-
removeexcesschildren(n, j);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
if (c?.tagName?.toLowerCase() != tag.toLowerCase()) {
|
|
85
|
-
let ns = p?.xmlns ??
|
|
44
|
+
let { tag, cn = [], p } = h;
|
|
45
|
+
let fresh = c?.tagName?.toLowerCase() != tag.toLowerCase();
|
|
46
|
+
if (fresh) {
|
|
47
|
+
let ns = p.xmlns ??
|
|
86
48
|
(parent.tagName == 'foreignObject'
|
|
87
49
|
? 'http://www.w3.org/1999/xhtml'
|
|
88
50
|
: parent.namespaceURI);
|
|
89
51
|
n = document.createElementNS(ns, tag);
|
|
90
52
|
c ? c.replaceWith(n) : parent.appendChild(n);
|
|
91
|
-
process();
|
|
92
|
-
p?.mounted?.(n);
|
|
93
53
|
}
|
|
94
|
-
else
|
|
54
|
+
else
|
|
95
55
|
n = c;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
56
|
+
n.h = hfun ?? h; // attach before update(), which may handle the update itself
|
|
57
|
+
if (jmcconfig.debug && hfun)
|
|
58
|
+
n.setAttribute('comp', hfun.tag.name);
|
|
59
|
+
if (!fresh && p.update?.(n, uc))
|
|
60
|
+
return i + 1;
|
|
61
|
+
// a const element is an island: jmc renders it once, then foreign code owns it. update() still runs
|
|
62
|
+
if (fresh || !p.const) {
|
|
63
|
+
n.ep = setprops(n, n.ep, p);
|
|
64
|
+
if (--depth && !tag.includes('-')) { // web components render their own children
|
|
65
|
+
const j = syncchildren(n, cn, 0, depth, uc);
|
|
66
|
+
removeexcesschildren(n, j);
|
|
67
|
+
}
|
|
99
68
|
}
|
|
69
|
+
if (fresh)
|
|
70
|
+
p.mounted?.(n);
|
|
100
71
|
return i + 1;
|
|
101
72
|
}
|
|
102
|
-
case 4: {
|
|
103
|
-
return syncchildren(parent, h.cn ?? [], i, --depth, uc);
|
|
104
|
-
}
|
|
105
73
|
case 2: {
|
|
74
|
+
// function component
|
|
75
|
+
// TBD REMOVE the second argument once we know it is unused: the children are in h.p.children
|
|
106
76
|
let hr = h.tag(h.p, h.cn);
|
|
107
77
|
return sync(parent, i, hr, hfun ?? h, depth, uc);
|
|
108
78
|
}
|
|
109
79
|
case 3: {
|
|
110
|
-
if
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
: sync(parent, i, ci.view(), c.h, depth, uc); // hfun because outermost function shall be attached
|
|
80
|
+
// class component. reuses the instance attached to c, if c renders the same class
|
|
81
|
+
let old = c?.h?.tag == h.tag ? c.h : undefined;
|
|
82
|
+
let ci = old ? old.i : (h.i = rebind(new h.tag(h.p)));
|
|
83
|
+
if (old) {
|
|
84
|
+
ci.props = old.p = h.p; // set attached p too, for a repeatable update through c.h
|
|
85
|
+
if (ci.update?.(uc))
|
|
86
|
+
return i + 1; // update() substitutes view/sync when returning truthy
|
|
118
87
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
ci.element = n;
|
|
88
|
+
let hv = ci.view();
|
|
89
|
+
let j = sync(parent, i, hv, old ?? h, depth, uc); // the attached H, so updates find the instance
|
|
90
|
+
assertnonfragment(h, hv, i, j);
|
|
91
|
+
ci.element = parent.childNodes[i];
|
|
92
|
+
if (!old)
|
|
125
93
|
ci.mounted?.();
|
|
126
|
-
|
|
127
|
-
|
|
94
|
+
return j;
|
|
95
|
+
}
|
|
96
|
+
case 4: {
|
|
97
|
+
// fragment. hfun is deliberately not passed on: a component returning a fragment is not attached
|
|
98
|
+
// to any node, so it cannot update itself, only its parent can update it
|
|
99
|
+
return syncchildren(parent, h.cn ?? [], i, --depth, uc);
|
|
128
100
|
}
|
|
129
101
|
default:
|
|
130
102
|
// textnode
|
|
@@ -143,41 +115,30 @@ export function patch(e, h, depth = 999, uc = {}) {
|
|
|
143
115
|
if (!e)
|
|
144
116
|
return;
|
|
145
117
|
if (depth == 0) {
|
|
146
|
-
;
|
|
147
118
|
e.replaceChildren();
|
|
148
119
|
depth = 999;
|
|
149
120
|
}
|
|
150
121
|
let p = e.parentElement;
|
|
151
|
-
let i = [].indexOf
|
|
122
|
+
let i = [...p.childNodes].indexOf(e);
|
|
152
123
|
sync(p, i, h, undefined, depth, uc);
|
|
153
124
|
return p.childNodes[i];
|
|
154
125
|
}
|
|
155
126
|
export function updateview(...cmds) {
|
|
156
|
-
if (!cmds.
|
|
157
|
-
cmds.push('body');
|
|
127
|
+
if (!cmds.some(c => typeof c == 'string' || c instanceof Node))
|
|
128
|
+
cmds.push('body'); // no target given: body
|
|
158
129
|
let uc = {};
|
|
159
130
|
let depth = 999;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
else if (typeof c === 'number') {
|
|
173
|
-
depth = c;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
uc = c;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
f(cmds);
|
|
181
|
-
// if (!patchcount) console.warn("updateview did not update anything. cmds=", ...cmds)
|
|
131
|
+
// isConnected: a selector's matches are collected upfront, patching one can replace a later one
|
|
132
|
+
let up = (n) => { if (n.h && n.isConnected)
|
|
133
|
+
patch(n, n.h, depth, uc); };
|
|
134
|
+
for (const c of cmds)
|
|
135
|
+
if (typeof c == 'string')
|
|
136
|
+
document.querySelectorAll(c).forEach(up);
|
|
137
|
+
else if (c instanceof Node)
|
|
138
|
+
up(c);
|
|
139
|
+
else if (typeof c == 'number')
|
|
140
|
+
depth = c;
|
|
141
|
+
else
|
|
142
|
+
uc = c;
|
|
182
143
|
}
|
|
183
144
|
//# sourceMappingURL=jmc.js.map
|
package/dist/jmc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jmc.js","sourceRoot":"","sources":["../src/jmc.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAanC,IAAI,cAAc,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAEzD,IAAI,cAAc,GAAG,IAAI,GAAG,CAAC;IACzB,UAAU;IACV,SAAS;IACT,MAAM;IACN,uEAAuE;CAC1E,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,SAAS,GAAG;IACnB,cAAc;CACjB,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,CAAU,EAAE,IAAY,EAAE,KAAU,EAAE,EAAE,CACx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AC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;oBACxB,UAAU,EAAE,CAAA;gBAChB,CAAC;YACL,CAAC;iBAAM,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;gBAC/B,KAAK,GAAG,CAAC,CAAA;YACb,CAAC;iBAAM,CAAC;gBACJ,EAAE,GAAG,CAAC,CAAA;YACV,CAAC;QACL,CAAC;IACL,CAAC;IAED,CAAC,CAAC,IAAI,CAAC,CAAA;IAEP,sFAAsF;AAC1F,CAAC","sourcesContent":["import type {\r\n H,\r\n HElement,\r\n J,\r\n Selector,\r\n Children,\r\n HClassComponent,\r\n HU,\r\n} from './h'\r\nimport { rebind } from './base.js'\r\nimport { setevent } from './events'\r\n\r\nconst enum NodeType {\r\n // vaporizes (but for that must be in this file, otherwise not)\r\n TextNode = 3,\r\n}\r\n\r\ndeclare global {\r\n interface Node {\r\n h?: H & { p?: J }\r\n }\r\n}\r\n\r\nlet iswebcomponent = (h: HElement) => h.tag.includes('-')\r\n\r\nlet attributeNames = new Set([\r\n 'selected',\r\n 'viewBox', \r\n 'list'\r\n // other HTML attributes where your framework wants attribute semantics\r\n])\r\n\r\nexport let jmcconfig = {\r\n attributeNames\r\n}\r\n\r\nconst isproperty = (e: Element, name: string, value: any) =>\r\n !attributeNames.has(name) &&\r\n (value instanceof Object ||\r\n value instanceof Function || (\r\n e.namespaceURI !== 'http://www.w3.org/2000/svg' &&\r\n name in e &&\r\n name !== 'style'))\r\n\r\nlet setprops = (e: Element & J, old: J | undefined, now: J | undefined) => {\r\n old ??= {}\r\n now ??= {}\r\n\r\n // removals\r\n for (let p in old) {\r\n if (!(p in now)) {\r\n if (p.startsWith('on')) setevent(e, p.slice(2), null)\r\n else if (isproperty(e, p, old[p])) e[p] = typeof old[p] === 'boolean' ? false : ''\r\n else e.removeAttribute(p)\r\n }\r\n }\r\n\r\n // updates\r\n for (let p in now) {\r\n let v = now[p]\r\n v = v?.thunk ? v() : v\r\n\r\n if (p.startsWith('on')) setevent(e, p.slice(2), v)\r\n else if (v != old[p]) {\r\n if (isproperty(e, p, v)) e[p] = v\r\n else if ((v === false || v == null) && !p.startsWith('aria-')) e.removeAttribute(p)\r\n else e.setAttribute(p, v)\r\n }\r\n }\r\n}\r\n\r\nlet removeexcesschildren = (n: Element, i: number) => {\r\n let c: ChildNode\r\n while ((c = n.childNodes[i])) {\r\n try {\r\n c.remove()\r\n } catch (_) { } // due to blur-event-handlers, this can fail\r\n }\r\n}\r\n\r\n/** synchronizes children starting at the i-th element. returns the index of the last child synchronized */\r\nlet syncchildren = (\r\n p: Element,\r\n cn: Children,\r\n i: number,\r\n depth: number,\r\n uc: J,\r\n): number => {\r\n cn.flat(999)\r\n .filter((hc) => hc !== null && hc !== undefined) // skip. keep 0 and false renderable, per comment below)\r\n .forEach((hc) => (i = sync(p, i, hc, undefined, depth, uc)))\r\n return i\r\n}\r\n\r\nfunction sync(\r\n parent: Element,\r\n i: number,\r\n h: HU,\r\n hfun: H | undefined,\r\n depth: number,\r\n uc: J,\r\n): number {\r\n // console.log('%csync', \"background:orange\", parent.tagName, i, h, hfun, depth)\r\n\r\n if (h === null || h === undefined) return i // skip. keep 0 and false renderable, per comment below\r\n\r\n let c = parent.childNodes[i]\r\n\r\n switch (h.kind) {\r\n case 1: {\r\n let n: Element\r\n let { tag, cn, p } = h\r\n cn ??= []\r\n\r\n let process = () => {\r\n setprops(n, n.h?.p, p)\r\n n.h = hfun ?? h // sets the new property values\r\n if (\r\n --depth &&\r\n !n.hasAttribute('const') &&\r\n !iswebcomponent(h as HElement)\r\n ) {\r\n const j = syncchildren(n, cn, 0, depth, uc)\r\n removeexcesschildren(n, j)\r\n }\r\n }\r\n\r\n if ((<Element>c)?.tagName?.toLowerCase() != tag.toLowerCase()) {\r\n let ns =\r\n p?.xmlns ??\r\n (parent.tagName == 'foreignObject'\r\n ? 'http://www.w3.org/1999/xhtml'\r\n : parent.namespaceURI)\r\n n = document.createElementNS(ns, tag)\r\n c ? c.replaceWith(n) : parent.appendChild(n)\r\n process()\r\n p?.mounted?.(n)\r\n } else {\r\n n = c as Element\r\n if (p?.update?.(c, uc)) return i + 1\r\n process()\r\n }\r\n\r\n return i + 1\r\n }\r\n\r\n case 4: {\r\n return syncchildren(parent, h.cn ?? [], i, --depth, uc)\r\n }\r\n\r\n case 2: {\r\n let hr = h.tag(h.p, h.cn)\r\n return sync(parent, i, hr, hfun ?? h, depth, uc)\r\n }\r\n\r\n case 3: {\r\n if ((c?.h as any)?.tag == h.tag) {\r\n let ci = (c.h as HClassComponent).i!\r\n ci.props = c.h!.p = h.p\r\n c.h!.p = h.p // for repatable update, set attached h.p. alternatively, we could use ci.props in case where h.p is undefined\r\n // update() substitutes view/sync when returning truthy\r\n return ci.update?.(uc)\r\n ? i + 1\r\n : sync(parent, i, ci.view(), c.h, depth, uc) // hfun because outermost function shall be attached\r\n } else {\r\n let ci = (h.i = rebind(new h.tag(h.p)))\r\n let hv = ci.view()\r\n let j = sync(parent, i, hv, h, depth, uc)\r\n let n = parent.childNodes[i]!\r\n ci.element = n\r\n ci.mounted?.()\r\n return j\r\n }\r\n }\r\n\r\n default:\r\n // textnode\r\n let s = h.toString()\r\n if (c?.nodeType == NodeType.TextNode) {\r\n if (c.textContent != s) c.textContent = s // firefox updates equal text, loosing existing text selection\r\n } else {\r\n c ? c.replaceWith(s) : parent.append(s)\r\n }\r\n return i + 1\r\n }\r\n}\r\n\r\nexport function patch(\r\n e: Node | null,\r\n h: H,\r\n depth = 999,\r\n uc = {} as J,\r\n): HTMLElement | undefined {\r\n if (!e) return\r\n if (depth == 0) {\r\n ; (e as HTMLElement).replaceChildren()\r\n depth = 999\r\n }\r\n let p = e.parentElement as HTMLElement\r\n let i = [].indexOf.call<any, any, any>(p.childNodes, e)\r\n sync(p, i, h, undefined, depth, uc)\r\n return p.childNodes[i] as HTMLElement\r\n}\r\n\r\nexport type Command = Selector | J | number\r\n\r\nexport function updateview(...cmds: Command[]): void {\r\n if (!cmds.length) cmds.push('body')\r\n let uc = {}\r\n let depth = 999\r\n let patchcount = 0\r\n\r\n function f(cmds: Command[]) {\r\n for (const c of cmds) {\r\n if (typeof c === 'string') {\r\n f([...document.querySelectorAll(c)])\r\n } else if (c instanceof Node) {\r\n if (c.h) {\r\n patch(c, c.h, depth, uc)\r\n patchcount++\r\n }\r\n } else if (typeof c === 'number') {\r\n depth = c\r\n } else {\r\n uc = c\r\n }\r\n }\r\n }\r\n\r\n f(cmds)\r\n\r\n // if (!patchcount) console.warn(\"updateview did not update anything. cmds=\", ...cmds)\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"jmc.js","sourceRoot":"","sources":["../src/jmc.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAgBhD,IAAI,oBAAoB,GAAG,CAAC,CAAU,EAAE,CAAS,EAAE,EAAE;IACjD,IAAI,CAAY,CAAA;IAChB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,IAAI,CAAC;YACD,CAAC,CAAC,MAAM,EAAE,CAAA;QACd,CAAC;QAAC,MAAM,CAAC,CAAC,CAAC,CAAC,4CAA4C;IAC5D,CAAC;AACL,CAAC,CAAA;AAED,2GAA2G;AAC3G,IAAI,YAAY,GAAG,CACf,CAAU,EACV,EAAY,EACZ,CAAS,EACT,KAAa,EACb,EAAK,EACC,EAAE;IACR,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IACxE,OAAO,CAAC,CAAA;AACZ,CAAC,CAAA;AAED,wGAAwG;AACxG,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rebind } from './base.js'\r\nimport { jmcconfig, setprops } from './props.js'\r\n\r\nconst enum NodeType {\r\n // vaporizes (but for that must be in this file, otherwise not)\r\n TextNode = 3,\r\n Comment = 8,\r\n}\r\n\r\n/** a node as jmc sees it. kept module-local, so consumers' Node type stays untouched */\r\ntype JNode<N extends Node = ChildNode> = N & {\r\n /** the H this node updates from: the element's own H, or the outermost component rendering it */\r\n h?: HElement | HComp\r\n /** props last applied to this element. kept apart from h, which may be the owning component's H */\r\n ep?: J\r\n}\r\n\r\nlet removeexcesschildren = (n: Element, i: number) => {\r\n let c: ChildNode\r\n while ((c = n.childNodes[i])) {\r\n try {\r\n c.remove()\r\n } catch { } // due to blur-event-handlers, this can fail\r\n }\r\n}\r\n\r\n/** synchronizes children starting at the i-th node. returns the index after the last child synchronized */\r\nlet syncchildren = (\r\n p: Element,\r\n cn: Children,\r\n i: number,\r\n depth: number,\r\n uc: J,\r\n): number => {\r\n cn.flat(999).forEach((hc) => (i = sync(p, i, hc, undefined, depth, uc)))\r\n return i\r\n}\r\n\r\n/** class components must render exactly one root node, they are attached to it and update through it */\r\nlet assertnonfragment = (h: HClassComponent, hv: HU, i: number, j: number) => {\r\n if (j - i != 1 || hv?.kind == 4) throw new Error(`${h.tag.name}.view() must render exactly one root element`)\r\n}\r\n\r\nfunction sync(\r\n parent: Element,\r\n i: number,\r\n h: HU,\r\n hfun: HComp | undefined,\r\n depth: number,\r\n uc: J,\r\n): number {\r\n let c: JNode | undefined = parent.childNodes[i]\r\n\r\n // null, undefined and booleans render nothing, like in React, so {cond && <b />} works. 0 is still rendered.\r\n // nothing still takes its slot, as a placeholder: so the siblings after it keep their position, and with it their state\r\n if (h == null || typeof h == 'boolean') {\r\n if (hfun?.kind != 3) h = '' // an empty text node, invisible\r\n else {\r\n // a class component rendering nothing is attached to a comment, so it keeps its state and can show itself again\r\n if (c?.nodeType != NodeType.Comment) {\r\n let n = new Comment()\r\n c ? c.replaceWith(n) : parent.append(n)\r\n c = n\r\n }\r\n c.h = hfun\r\n return i + 1\r\n }\r\n }\r\n\r\n switch (h.kind) {\r\n case 1: {\r\n // element\r\n let n: Element & JNode\r\n let { tag, cn = [], p } = h\r\n\r\n let fresh = (<Element>c)?.tagName?.toLowerCase() != tag.toLowerCase()\r\n if (fresh) {\r\n let ns =\r\n p.xmlns ??\r\n (parent.tagName == 'foreignObject'\r\n ? 'http://www.w3.org/1999/xhtml'\r\n : parent.namespaceURI)\r\n n = document.createElementNS(ns, tag)\r\n c ? c.replaceWith(n) : parent.appendChild(n)\r\n } else n = c as Element & JNode\r\n\r\n n.h = hfun ?? h // attach before update(), which may handle the update itself\r\n if (jmcconfig.debug && hfun) n.setAttribute('comp', hfun.tag.name)\r\n if (!fresh && p.update?.(n, uc)) return i + 1\r\n\r\n // a const element is an island: jmc renders it once, then foreign code owns it. update() still runs\r\n if (fresh || !p.const) {\r\n n.ep = setprops(n, n.ep, p)\r\n if (--depth && !tag.includes('-')) { // web components render their own children\r\n const j = syncchildren(n, cn, 0, depth, uc)\r\n removeexcesschildren(n, j)\r\n }\r\n }\r\n if (fresh) p.mounted?.(n)\r\n\r\n return i + 1\r\n }\r\n\r\n case 2: {\r\n // function component\r\n // TBD REMOVE the second argument once we know it is unused: the children are in h.p.children\r\n let hr = h.tag(h.p, h.cn)\r\n return sync(parent, i, hr, hfun ?? h, depth, uc)\r\n }\r\n\r\n case 3: {\r\n // class component. reuses the instance attached to c, if c renders the same class\r\n let old = c?.h?.tag == h.tag ? c.h as HClassComponent : undefined\r\n let ci = old ? old.i! : (h.i = rebind(new h.tag(h.p)))\r\n if (old) {\r\n ci.props = old.p = h.p // set attached p too, for a repeatable update through c.h\r\n if (ci.update?.(uc)) return i + 1 // update() substitutes view/sync when returning truthy\r\n }\r\n let hv = ci.view()\r\n let j = sync(parent, i, hv, old ?? h, depth, uc) // the attached H, so updates find the instance\r\n assertnonfragment(h, hv, i, j)\r\n ci.element = parent.childNodes[i]\r\n if (!old) ci.mounted?.()\r\n return j\r\n }\r\n\r\n case 4: {\r\n // fragment. hfun is deliberately not passed on: a component returning a fragment is not attached\r\n // to any node, so it cannot update itself, only its parent can update it\r\n return syncchildren(parent, h.cn ?? [], i, --depth, uc)\r\n }\r\n\r\n default:\r\n // textnode\r\n let s = h.toString()\r\n if (c?.nodeType == NodeType.TextNode) {\r\n if (c.textContent != s) c.textContent = s // firefox updates equal text, loosing existing text selection\r\n } else {\r\n c ? c.replaceWith(s) : parent.append(s)\r\n }\r\n return i + 1\r\n }\r\n}\r\n\r\nexport function patch(\r\n e: Node | null,\r\n h: H,\r\n depth = 999,\r\n uc: J = {},\r\n): HTMLElement | undefined {\r\n if (!e) return\r\n if (depth == 0) {\r\n (e as Element).replaceChildren()\r\n depth = 999\r\n }\r\n let p = e.parentElement!\r\n let i = [...p.childNodes].indexOf(e as ChildNode)\r\n sync(p, i, h, undefined, depth, uc)\r\n return p.childNodes[i] as HTMLElement\r\n}\r\n\r\nexport function updateview(...cmds: Command[]): void {\r\n if (!cmds.some(c => typeof c == 'string' || c instanceof Node)) cmds.push('body') // no target given: body\r\n let uc: J = {}\r\n let depth = 999\r\n\r\n // isConnected: a selector's matches are collected upfront, patching one can replace a later one\r\n let up = (n: JNode<Node>) => { if (n.h && n.isConnected) patch(n, n.h, depth, uc) }\r\n\r\n for (const c of cmds)\r\n if (typeof c == 'string') document.querySelectorAll(c).forEach(up)\r\n else if (c instanceof Node) up(c)\r\n else if (typeof c == 'number') depth = c\r\n else uc = c\r\n}\r\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Fragment } from './jsx-runtime.js';
|
|
2
|
+
export type { JSX } from './jsx-runtime.js';
|
|
3
|
+
/** like jsx and jsxs. the extra arguments for debugging (key, source, self) are not used */
|
|
4
|
+
export declare let jsxDEV: (tag: any, props: any, _key: any, isstaticchildren: boolean) => import("./h.js").HElement | import("./h.js").HFragment | import("./h.js").HComp;
|
|
5
|
+
//# sourceMappingURL=jsx-dev-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,YAAY,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,4FAA4F;AAC5F,eAAO,IAAI,MAAM,GAAI,KAAK,GAAG,EAAE,OAAO,GAAG,EAAE,MAAM,GAAG,EAAE,kBAAkB,OAAO,oFAAgD,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// entry point of the automatic JSX runtime in development ("jsx": "react-jsxdev", or Vite in dev mode)
|
|
2
|
+
import { jsx, jsxs } from './jsx-runtime.js';
|
|
3
|
+
export { Fragment } from './jsx-runtime.js';
|
|
4
|
+
/** like jsx and jsxs. the extra arguments for debugging (key, source, self) are not used */
|
|
5
|
+
export let jsxDEV = (tag, props, _key, isstaticchildren) => (isstaticchildren ? jsxs : jsx)(tag, props);
|
|
6
|
+
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.js","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG3C,4FAA4F;AAC5F,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,GAAQ,EAAE,KAAU,EAAE,IAAS,EAAE,gBAAyB,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA","sourcesContent":["// entry point of the automatic JSX runtime in development (\"jsx\": \"react-jsxdev\", or Vite in dev mode)\r\nimport { jsx, jsxs } from './jsx-runtime.js'\r\n\r\nexport { Fragment } from './jsx-runtime.js'\r\nexport type { JSX } from './jsx-runtime.js'\r\n\r\n/** like jsx and jsxs. the extra arguments for debugging (key, source, self) are not used */\r\nexport let jsxDEV = (tag: any, props: any, _key: any, isstaticchildren: boolean) => (isstaticchildren ? jsxs : jsx)(tag, props)\r\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as classic, jsxf } from './h.js';
|
|
2
|
+
export { jsxf as Fragment };
|
|
3
|
+
/** an element with one child or none */
|
|
4
|
+
export declare let jsx: (tag: any, { children, ...p }: any) => import("./h.js").HElement | import("./h.js").HFragment | import("./h.js").HComp;
|
|
5
|
+
/** an element with several children, always an array */
|
|
6
|
+
export declare let jsxs: (tag: any, { children, ...p }: any) => import("./h.js").HElement | import("./h.js").HFragment | import("./h.js").HComp;
|
|
7
|
+
export declare namespace JSX {
|
|
8
|
+
type IntrinsicElements = {
|
|
9
|
+
[K in keyof classic.JSX.IntrinsicElements]: classic.JSX.IntrinsicElements[K] & {
|
|
10
|
+
children?: any;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,CAAA;AAE3B,wCAAwC;AACxC,eAAO,IAAI,GAAG,GAAI,KAAK,GAAG,EAAE,oBAAoB,GAAG,oFAAmE,CAAA;AAEtH,wDAAwD;AACxD,eAAO,IAAI,IAAI,GAAI,KAAK,GAAG,EAAE,oBAAoB,GAAG,oFAAiC,CAAA;AAErF,yBAAiB,GAAG,CAAC;IAEjB,KAAY,iBAAiB,GAAG;SAAG,CAAC,IAAI,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG;YAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;SAAE;KAAE,CAAA;CACxI"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// entry point of the automatic JSX runtime, used with "jsx": "react-jsx" and "jsxImportSource": "@snupo/jmc".
|
|
2
|
+
// the compiler then imports jsx, jsxs and Fragment from here by itself, so .tsx files need no jsx import.
|
|
3
|
+
// it passes the children inside the props: jsx(tag, { ...props, children }). this adapts that to jmc's jsx(tag, props, ...children)
|
|
4
|
+
import { jsx as classic, jsxf } from './h.js';
|
|
5
|
+
export { jsxf as Fragment };
|
|
6
|
+
/** an element with one child or none */
|
|
7
|
+
export let jsx = (tag, { children, ...p }) => classic(tag, p, ...(children === undefined ? [] : [children]));
|
|
8
|
+
/** an element with several children, always an array */
|
|
9
|
+
export let jsxs = (tag, { children, ...p }) => classic(tag, p, ...children);
|
|
10
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,0GAA0G;AAC1G,oIAAoI;AACpI,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,CAAA;AAE3B,wCAAwC;AACxC,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,GAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAEtH,wDAAwD;AACxD,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,GAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAA","sourcesContent":["// entry point of the automatic JSX runtime, used with \"jsx\": \"react-jsx\" and \"jsxImportSource\": \"@snupo/jmc\".\r\n// the compiler then imports jsx, jsxs and Fragment from here by itself, so .tsx files need no jsx import.\r\n// it passes the children inside the props: jsx(tag, { ...props, children }). this adapts that to jmc's jsx(tag, props, ...children)\r\nimport { jsx as classic, jsxf } from './h.js'\r\n\r\nexport { jsxf as Fragment }\r\n\r\n/** an element with one child or none */\r\nexport let jsx = (tag: any, { children, ...p }: any) => classic(tag, p, ...(children === undefined ? [] : [children]))\r\n\r\n/** an element with several children, always an array */\r\nexport let jsxs = (tag: any, { children, ...p }: any) => classic(tag, p, ...children)\r\n\r\nexport namespace JSX {\r\n // the same elements as in classic mode. the automatic runtime type-checks children as a prop, so every element accepts them\r\n export type IntrinsicElements = { [K in keyof classic.JSX.IntrinsicElements]: classic.JSX.IntrinsicElements[K] & { children?: any } }\r\n}\r\n"]}
|
package/dist/jsx.d.ts
CHANGED
|
@@ -494,53 +494,46 @@ interface SVGAttributes<T> extends AriaAttributes, HTMLAttributes {
|
|
|
494
494
|
zoomAndPan?: string | undefined;
|
|
495
495
|
}
|
|
496
496
|
type SVGProps<T extends SVGElement> = SVGAttributes<T>;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
class?: string | undefined;
|
|
536
|
-
};
|
|
537
|
-
foreignObject: SVGProps<SVGForeignObjectElement> & {
|
|
538
|
-
class?: string | undefined;
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
}
|
|
497
|
+
/** the elements jmc knows. JSX reads them through jsx.JSX.IntrinsicElements, see h.ts */
|
|
498
|
+
export interface JmcIntrinsicElements extends IntrinsicElementAttributes {
|
|
499
|
+
label: LabelHTMLAttributes & {
|
|
500
|
+
for?: string;
|
|
501
|
+
};
|
|
502
|
+
svg: SVGProps<SVGSVGElement> & {
|
|
503
|
+
class?: string | undefined;
|
|
504
|
+
xmlns: "http://www.w3.org/2000/svg";
|
|
505
|
+
};
|
|
506
|
+
path: SVGProps<SVGPathElement> & {
|
|
507
|
+
class?: string | undefined;
|
|
508
|
+
};
|
|
509
|
+
textPath: SVGProps<SVGTextPathElement> & {
|
|
510
|
+
class?: string | undefined;
|
|
511
|
+
style?: string | undefined;
|
|
512
|
+
};
|
|
513
|
+
tspan: SVGProps<SVGTSpanElement> & {
|
|
514
|
+
class?: string | undefined;
|
|
515
|
+
};
|
|
516
|
+
circle: SVGProps<SVGCircleElement> & {
|
|
517
|
+
class?: string | undefined;
|
|
518
|
+
};
|
|
519
|
+
rect: SVGProps<SVGRectElement> & {
|
|
520
|
+
class?: string | undefined;
|
|
521
|
+
};
|
|
522
|
+
line: SVGProps<SVGLineElement> & {
|
|
523
|
+
class?: string | undefined;
|
|
524
|
+
};
|
|
525
|
+
text: SVGProps<SVGTextElement> & {
|
|
526
|
+
class?: string | undefined;
|
|
527
|
+
style?: string | undefined;
|
|
528
|
+
};
|
|
529
|
+
g: SVGProps<SVGGElement> & {
|
|
530
|
+
class?: string | undefined;
|
|
531
|
+
};
|
|
532
|
+
foreignObject: SVGProps<SVGForeignObjectElement> & {
|
|
533
|
+
class?: string | undefined;
|
|
534
|
+
};
|
|
542
535
|
}
|
|
543
|
-
type WithThunk<T> = T extends undefined ? undefined : T | (() => T);
|
|
536
|
+
type WithThunk<T> = T extends undefined ? undefined : T | (() => T | undefined);
|
|
544
537
|
export type HTMLAttributes = {
|
|
545
538
|
[K in keyof HTMLAttributesBase]?: WithThunk<NonNullable<HTMLAttributesBase[K]>>;
|
|
546
539
|
};
|