jmx-runtime 0.0.27 → 0.0.30

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/lib.ts CHANGED
@@ -1,29 +1,29 @@
1
- import { Props, IClassComponent, H, FComponentT, Children } from 'h'
2
- import { updateview } from './jmx'
3
-
4
- export type DeepReadonly<T> = { readonly [K in keyof T]: T[K] extends Record<string, unknown> ? DeepReadonly<T[K]> : T[K]; }
5
-
6
- export const When = ({ cond }: { cond: boolean }, cn: Children) => cond ? { cn } : void 0;
7
-
8
- export abstract class JMXComp<P extends Props = {}> implements IClassComponent {
9
-
10
- // assigned by jmx framework
11
- element!: HTMLElement
12
-
13
- // we provide this ctor for jsx which uses ctor arguments as properties of class components.
14
- // at runtime, we pass the props directly
15
- constructor(public props: P) { }
16
-
17
- // overrides
18
- mounted() { }
19
- update(uc?: IUpdateContext): boolean | void { }
20
- abstract view(): H
21
-
22
- // utility: updates the component's view
23
- updateview() { updateview(this.element) }
24
- get ismounted():boolean { return this.element as any }
25
- }
26
-
27
- export function cc(...namesOrObjects: (string | any)[]): string {
28
- return namesOrObjects.flatMap(n => (n.trim ? n : Object.keys(n).filter(k => n[k]))).join(' ') // n.trim distinguishes strings from objects
1
+ import { Props, IClassComponent, H, FComponentT, Children } from 'h'
2
+ import { updateview } from './jmx'
3
+
4
+ export type DeepReadonly<T> = { readonly [K in keyof T]: T[K] extends Record<string, unknown> ? DeepReadonly<T[K]> : T[K]; }
5
+
6
+ export const When = ({ cond }: { cond: boolean }, cn: Children) => cond ? { cn } : void 0;
7
+
8
+ export abstract class JMXComp<P extends Props = {}> implements IClassComponent {
9
+
10
+ // assigned by jmx framework
11
+ element!: HTMLElement
12
+
13
+ // we provide this ctor for jsx which uses ctor arguments as properties of class components.
14
+ // at runtime, we pass the props directly
15
+ constructor(public props: P) { }
16
+
17
+ // overrides
18
+ mounted() { }
19
+ update(uc?: IUpdateContext): boolean | void { }
20
+ abstract view(): H
21
+
22
+ // utility: updates the component's view
23
+ updateview() { updateview(this.element) }
24
+ get ismounted():boolean { return this.element as any }
25
+ }
26
+
27
+ export function cc(...namesOrObjects: (string | any)[]): string {
28
+ return namesOrObjects.flatMap(n => (n.trim ? n : Object.keys(n).filter(k => n[k]))).join(' ') // n.trim distinguishes strings from objects
29
29
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
- {
2
- "name": "jmx-runtime",
3
- "author": "snupo",
4
- "version": "0.0.27",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "type": "module",
9
- "main": "dist/index.js",
10
- "types": "./dist/index.d.ts",
11
- "scripts": {
12
- "build": "tsc"
13
- }
14
- }
1
+ {
2
+ "name": "jmx-runtime",
3
+ "author": "snupo",
4
+ "version": "0.0.30",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "main": "dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "rollup -c"
13
+ }
14
+ }
package/rollup.config.js CHANGED
@@ -1,31 +1,31 @@
1
- import typescript from "@rollup/plugin-typescript"
2
- import clean from "rollup-plugin-cleanup"
3
- import copy from 'rollup-plugin-copy'
4
- //import { createPathTransform } from 'rollup-sourcemap-path-transform'
5
-
6
- export default {
7
- input: 'index.ts',
8
- output: [
9
- {
10
- file: 'dist/index.js',
11
- format: 'es',
12
- sourcemap: true,
13
- }
14
- ],
15
- // sourcemapPathTransform: createPathTransform({
16
- // prefixes: {
17
- // '*src/components/': '/compi/comps/',
18
- // '/node_modules/': '/compi/deps/',
19
- // "../../../../../../../jmxa": "hase"
20
- // }
21
- // }),
22
- plugins: [
23
- typescript(),
24
- copy({
25
- targets: [
26
- { src: '*.ts', dest: 'dist' }, // Copy all .ts files to dist/src
27
- ],
28
- }),
29
- clean()
30
- ]
1
+ import typescript from "@rollup/plugin-typescript"
2
+ import clean from "rollup-plugin-cleanup"
3
+ import copy from 'rollup-plugin-copy'
4
+ //import { createPathTransform } from 'rollup-sourcemap-path-transform'
5
+
6
+ export default {
7
+ input: 'index.ts',
8
+ output: [
9
+ {
10
+ file: 'dist/index.js',
11
+ format: 'es',
12
+ sourcemap: true,
13
+ }
14
+ ],
15
+ // sourcemapPathTransform: createPathTransform({
16
+ // prefixes: {
17
+ // '*src/components/': '/compi/comps/',
18
+ // '/node_modules/': '/compi/deps/',
19
+ // "../../../../../../../jmxa": "hase"
20
+ // }
21
+ // }),
22
+ plugins: [
23
+ typescript(),
24
+ copy({
25
+ targets: [
26
+ { src: '*.ts', dest: 'dist' }, // Copy all .ts files to dist/src
27
+ ],
28
+ }),
29
+ clean()
30
+ ]
31
31
  }
package/tsconfig.json CHANGED
@@ -1,38 +1,38 @@
1
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
2
- {
3
- "compilerOptions": {
4
-
5
- "target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
6
- "module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
7
-
8
- "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
9
- "jsxFactory": "jsx",
10
- "jsxFragmentFactory": "jsxf",
11
-
12
- "declaration": true, /* Generates corresponding '.d.ts' file. */
13
- // "declarationDir": "dist/types",
14
- "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
-
16
- "sourceMap": true, /* Generates corresponding '.map' file. */
17
- "inlineSources": true,
18
-
19
- "outDir": "dist", /* Redirect output structure to the directory. */
20
- "rootDir": ".", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
21
-
22
- "removeComments": true, /* Do not emit comments to output. */
23
-
24
- "strict": true, /* Enable all strict type-checking options. */
25
- "strictNullChecks": true, /* Enable strict null checks. */
26
- "noImplicitAny": true,
27
-
28
- "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
29
- "baseUrl": ".", /* Base directory to resolve non-absolute module names. */
30
- //"typeRoots": ["types"], /* List of folders to include type definitions from. */
31
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
32
- "sourceRoot": ".", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
33
- "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
34
- "skipLibCheck": true, /* Skip type checking of declaration files. */
35
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
36
- },
37
- "include": ["./index.ts"]
1
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
2
+ {
3
+ "compilerOptions": {
4
+
5
+ "target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
6
+ "module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
7
+
8
+ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
9
+ "jsxFactory": "jsx",
10
+ "jsxFragmentFactory": "jsxf",
11
+
12
+ "declaration": true, /* Generates corresponding '.d.ts' file. */
13
+ // "declarationDir": "dist/types",
14
+ "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
+
16
+ "sourceMap": true, /* Generates corresponding '.map' file. */
17
+ "inlineSources": true,
18
+
19
+ "outDir": "dist", /* Redirect output structure to the directory. */
20
+ "rootDir": ".", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
21
+
22
+ "removeComments": true, /* Do not emit comments to output. */
23
+
24
+ "strict": true, /* Enable all strict type-checking options. */
25
+ "strictNullChecks": true, /* Enable strict null checks. */
26
+ "noImplicitAny": true,
27
+
28
+ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
29
+ "baseUrl": ".", /* Base directory to resolve non-absolute module names. */
30
+ //"typeRoots": ["types"], /* List of folders to include type definitions from. */
31
+ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
32
+ "sourceRoot": ".", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
33
+ "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
34
+ "skipLibCheck": true, /* Skip type checking of declaration files. */
35
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
36
+ },
37
+ "include": ["./index.ts"]
38
38
  }
package/dist/base.js DELETED
@@ -1,22 +0,0 @@
1
- export function rebind(o) {
2
- Object.entries(Object.getOwnPropertyDescriptors(Object.getPrototypeOf(o)))
3
- .filter(([name, p]) => name != 'constructor' && p.value instanceof Function)
4
- .forEach(([name]) => o[name] = o[name].bind(o));
5
- return o;
6
- }
7
- export function mount(o) { Object.assign(globalThis, o); }
8
- export const loggedmethodsex = (o, logger) => new Proxy(o, {
9
- get(target, name, receiver) {
10
- if (typeof target[name] === "function") {
11
- return function (...args) {
12
- logger(name, args, undefined);
13
- let r = target[name].apply(this, args);
14
- return r;
15
- };
16
- }
17
- return Reflect.get(target, name, receiver);
18
- },
19
- });
20
- export const loggedmethods = (o) => loggedmethodsex(o, (name, args, result) => console.log("%c" + name, "background:#585059;color:white;padding:2px;font-weight:bold", args));
21
- export const loggedmethodscolored = (bgcolor, o) => loggedmethodsex(o, (name, args, result) => console.log("%c" + name, `background:${bgcolor};color:white;padding:2px;font-weight:bold`, args));
22
- //# sourceMappingURL=base.js.map
package/dist/base.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"./","sources":["base.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAC,CAAsB;IACzC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,yBAAyB,CAAC,MAAM,CAAC,cAAc,CA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AAI,EAAE,6DAA6D,EAAE,IAAI,CAAC,CAAC,CAAA;AACnN,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAgC,OAAe,EAAE,CAAI,EAAM,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,EAAE,cAAc,OAAO,2CAA2C,EAAE,IAAI,CAAC,CAAC,CAAA","sourcesContent":["export function rebind(o: Record<string, any>) {\n Object.entries(Object.getOwnPropertyDescriptors(Object.getPrototypeOf(o)))\n .filter(([name, p]) => name != 'constructor' && p.value instanceof Function)\n .forEach(([name]) => o[name] = o[name].bind(o))\n return o\n}\n\nexport function mount(o: Record<string, any>) { Object.assign(globalThis, o) }\n\nexport const loggedmethodsex = <T extends Record<string, any>>(o: T, logger: (name: string, args: any[], result: any) => void) => new Proxy(o, {\n get(target, name: string, receiver) {\n if (typeof target[name] === \"function\") {\n return function (this: T, ...args: any[]) {\n\n logger(name, args, undefined)\n let r = target[name].apply(this, args)\n return r\n }\n }\n return Reflect.get(target, name, receiver)\n },\n})\n\nexport const loggedmethods = <T extends Record<string, any>>(o: T ): T => loggedmethodsex(o, (name, args, result) => console.log(\"%c\" + name, \"background:#585059;color:white;padding:2px;font-weight:bold\", args))\nexport const loggedmethodscolored = <T extends Record<string, any>>(bgcolor: string, o: T ): T => loggedmethodsex(o, (name, args, result) => console.log(\"%c\" + name, `background:${bgcolor};color:white;padding:2px;font-weight:bold`, args))\n"]}
package/dist/config.d.ts DELETED
@@ -1,9 +0,0 @@
1
- declare global {
2
- interface Window {
3
- jmx?: {
4
- getnamespace: (tag: string) => string;
5
- };
6
- }
7
- }
8
- export declare function createElement(tag: string): Element;
9
- //# sourceMappingURL=config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"./","sources":["config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,GAAG,CAAC,EAAE;YACF,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;SACxC,CAAA;KACJ;CACJ;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,WAGxC"}
package/dist/config.js DELETED
@@ -1,5 +0,0 @@
1
- export function createElement(tag) {
2
- let ns = window.jmx?.getnamespace?.(tag);
3
- return ns ? document.createElementNS(ns, tag) : document.createElement(tag);
4
- }
5
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"./","sources":["config.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,aAAa,CAAC,GAAW;IACrC,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAAA;IACxC,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAC/E,CAAC"}
package/dist/h.js DELETED
@@ -1,7 +0,0 @@
1
- export function jsx() {
2
- throw 'jmx plugin not configured';
3
- }
4
- export function jsxf() {
5
- throw 'jmx plugin not configured';
6
- }
7
- //# sourceMappingURL=h.js.map
package/dist/h.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"h.js","sourceRoot":"./","sources":["h.ts"],"names":[],"mappings":"AAkFA,MAAM,UAAU,GAAG;IACf,MAAM,2BAA2B,CAAA;AACrC,CAAC;AACD,MAAM,UAAU,IAAI;IAChB,MAAM,2BAA2B,CAAA;AACrC,CAAC","sourcesContent":["// jmx internal types - hopst\n// the following types describe the js expression we get from tsx after conversion be our jmx plugin\n// they can be useful for users as well, components might return them.\n\ntype Func<T> = () => T\nexport type Expr<T> = T | Func<T>\n\nexport type Props = Record<string, any>\n\nexport type FComponent = (props: Props | undefined, children?: ChildrenH) => HElement // show an example for usage of children\n\nexport type FComponentT<P> = (pcn: P, cn?: Children) => H | void\n\nexport interface IClassComponent {\n element: Node\n props?: Record<string, any>\n view(): H\n update(uc: IUpdateContext): boolean | void\n mounted?(): void\n}\n\ninterface CComponent {\n new (props: any): IClassComponent // while a real component expresses its interface via props pass to the ctor, internally we assign props after construction with new()\n}\n\nexport type ChildrenH = (H | undefined)[]\nexport type Children = Expr<ChildrenH>\n\ntype HText =\n | string // text node\n | number // text node\n | boolean // do not allow boolean, that\n\nexport type HFragment = {\n cn: Children\n}\n\nexport type HElement = {\n tag: string\n p?: Expr<Props>\n cn: Children\n i?: any\n}\n\ntype HCompFun = {\n tag: FComponent\n p?: Expr<Props>\n cn?: Children\n}\n\nexport type HCompClass = {\n tag: CComponent\n p?: Expr<Props>\n cn: Children\n i: IClassComponent\n}\n\nexport type HComp = HCompFun | HCompClass\n\nexport type H = // a hyperscript atom that describes a ...\n\n | HText\n | HElement // a tag, like p, div with attributes and children\n | HComp // a dynamic component computing any other HNode\n | HFragment\n\ndeclare global {\n interface Node {\n h?: HElement | HCompFun | HCompClass\n }\n export interface IUpdateContext {\n patchElementOnly?: boolean\n replace?: boolean\n }\n\n export interface Window {\n jmx?: {\n getnamespace: (tag: string) => string | undefined\n }\n }\n}\n\nexport function jsx(): HElement {\n throw 'jmx plugin not configured'\n} // dumy function for app code - jmx-plugin removes calls to this function, minifyer then removes it\nexport function jsxf(): HElement {\n throw 'jmx plugin not configured'\n} // dumy function for app code - jmx-plugin removes calls to this function, minifyer then removes it\n"]}
package/dist/jmx.js DELETED
@@ -1,135 +0,0 @@
1
- import { rebind } from './base';
2
- export function createElement(tag) {
3
- let ns = window.jmx?.getnamespace?.(tag);
4
- return ns ? document.createElementNS(ns, tag) : document.createElement(tag);
5
- }
6
- let evaluate = (expr) => (expr instanceof Function ? expr() : expr);
7
- let removeexcesschildren = (n, i) => {
8
- let c;
9
- while ((c = n.childNodes[i])) {
10
- c.remove();
11
- }
12
- };
13
- let iswebcomponent = (h) => h.tag.includes('-');
14
- let isclasscomponent = (h) => h.tag?.prototype?.view;
15
- let iselement = (h) => typeof h.tag == 'string';
16
- let isfragment = (h) => {
17
- return h.tag == undefined && h.cn != undefined;
18
- };
19
- let isobject = (o) => typeof o === 'object';
20
- let isproperty = (name, value) => ['value', 'checked', 'disabled', 'className', 'style', 'href', 'src', 'selected', 'readOnly', 'tabIndex'].includes(name) ||
21
- value instanceof Object ||
22
- value instanceof Function;
23
- let setprops = (e, newprops = {}) => {
24
- let oldprops = evaluate(e.h?.p) ?? {};
25
- for (let p in oldprops)
26
- !(p in newprops) && isproperty(p, oldprops[p]) ? (e[p] = null) : e.removeAttribute(p);
27
- for (let p in newprops)
28
- isproperty(p, newprops[p]) ? (e[p] = newprops[p]) : e.setAttribute(p, newprops[p]);
29
- };
30
- function sync(p, i, h) {
31
- h = evaluate(h);
32
- if (h === null || h === undefined)
33
- return i;
34
- let c = p.childNodes[i];
35
- function synctextnode(text) {
36
- if (c && c.nodeType == 3) {
37
- if (c.textContent != text)
38
- c.textContent = text;
39
- }
40
- else {
41
- let tn = document.createTextNode(text);
42
- c ? c.replaceWith(tn) : p.appendChild(tn);
43
- }
44
- }
45
- if (isobject(h)) {
46
- function syncchildren(p, h, i) {
47
- evaluate(h.cn)
48
- ?.flat()
49
- .forEach(hc => (i = sync(p, i, hc)));
50
- return i;
51
- }
52
- if (isfragment(h))
53
- return syncchildren(p, h, i);
54
- const props = evaluate(h.p);
55
- if (iselement(h)) {
56
- let n;
57
- if (c?.tagName?.toLowerCase() != h.tag.toLowerCase()) {
58
- n = createElement(h.tag);
59
- c ? c.replaceWith(n) : p.appendChild(n);
60
- setprops(n, props);
61
- props?.mounted?.(n);
62
- }
63
- else {
64
- n = c;
65
- setprops(n, props);
66
- if (props?.update?.(c, globaluc))
67
- return i + 1;
68
- }
69
- n.h = h;
70
- if (!globaluc.patchElementOnly && !iswebcomponent(h)) {
71
- const j = syncchildren(n, h, 0);
72
- removeexcesschildren(n, j);
73
- }
74
- return i + 1;
75
- }
76
- switch (typeof h.tag) {
77
- case 'function':
78
- let isupdate = c?.h?.tag == h.tag;
79
- let ci;
80
- if (isclasscomponent(h)) {
81
- h.i = ci = c?.h?.i ?? rebind(new h.tag(props));
82
- ci.props = props;
83
- if (isupdate && ci.update(globaluc))
84
- return i + 1;
85
- }
86
- let hr = ci?.view ? ci?.view() : h.tag(props, evaluate(h.cn));
87
- if (hr === undefined || hr == null)
88
- return i;
89
- let j = sync(p, i, hr);
90
- let cn = p.childNodes[i];
91
- cn.h = h;
92
- if (ci)
93
- ci.element = cn;
94
- if (!isupdate)
95
- ci?.mounted?.();
96
- return j;
97
- case 'object':
98
- return sync(p, i, h.tag);
99
- }
100
- }
101
- synctextnode(h);
102
- return i + 1;
103
- }
104
- let globaluc = {};
105
- export function patch(e, h) {
106
- if (!e)
107
- return;
108
- if (globaluc.replace)
109
- e.replaceChildren();
110
- const p = e.parentElement;
111
- const i = [].indexOf.call(p.childNodes, e);
112
- sync(p, i, h);
113
- }
114
- export function updateviewuc(uc, ...sels) {
115
- {
116
- globaluc = uc;
117
- updateviewinternal(...sels);
118
- }
119
- }
120
- export function updateview(...sels) {
121
- {
122
- globaluc = {};
123
- updateviewinternal(...sels);
124
- }
125
- }
126
- function updateviewinternal(...sels) {
127
- if (!sels.length)
128
- sels.push('body');
129
- sels.flatMap(s => (typeof s == 'string' ? [...document.querySelectorAll(s)] : s ? [s] : [])).forEach(e => {
130
- if (!e?.h)
131
- throw 'jmx: no h exists on the node';
132
- patch(e, e.h);
133
- });
134
- }
135
- //# sourceMappingURL=jmx.js.map
package/dist/jmx.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"jmx.js","sourceRoot":"./","sources":["jmx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,MAAM,UAAU,aAAa,CAAC,GAAW;IACrC,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,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E,GAAG,IAAe;IAC/D,CAAC;QACG,QAAQ,GAAG,EAAE,CAAA;QACb,kBAAkB,CAAC,GAAG,IAAI,CAAC,CAAA;IAC/B,CAAC;AACL,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,GAAG,IAAe;IACzC,CAAC;QACG,QAAQ,GAAG,EAAE,CAAA;QACb,kBAAkB,CAAC,GAAG,IAAI,CAAC,CAAA;IAC/B,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAG,IAAgB;IAC3C,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACrG,IAAI,CAAC,CAAC,EAAE,CAAC;YAAE,MAAM,8BAA8B,CAAA;QAC/C,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACN,CAAC","sourcesContent":["import { rebind } from './base'\nimport { Expr, FComponent, H, HComp, HCompClass, HElement, HFragment, IClassComponent, Props } from './h'\n\n// config\nexport function createElement(tag: string) {\n let ns = window.jmx?.getnamespace?.(tag)\n return ns ? document.createElementNS(ns, tag) : document.createElement(tag)\n}\n\nconst enum NodeType { // vaporizes (but for that must be in this file, otherwise not)\n TextNode = 3,\n}\n\nlet evaluate = <T>(expr: Expr<T>): T => (expr instanceof Function ? expr() : expr)\nlet removeexcesschildren = (n: Element, i: number) => {\n let c: ChildNode\n while ((c = n.childNodes[i])) {\n c.remove()\n }\n}\nlet iswebcomponent = (h: HElement) => (h.tag as string).includes('-')\nlet isclasscomponent = (h: HComp): h is HCompClass => (h.tag as any)?.prototype?.view\nlet iselement = (h: any): h is HElement => typeof h.tag == 'string'\nlet isfragment = (h: any): h is HFragment => {\n return h.tag == undefined && h.cn != undefined\n}\nlet isobject = (o: any): o is object => typeof o === 'object'\n\nlet isproperty = (name: string, value: any) =>\n ['value', 'checked', 'disabled', 'className', 'style', 'href', 'src', 'selected', 'readOnly', 'tabIndex'].includes(\n name\n ) ||\n value instanceof Object ||\n value instanceof Function\n\nlet setprops = (e: Element, newprops: Props = {}) => {\n let oldprops = evaluate(e.h?.p) ?? {}\n for (let p in oldprops)\n !(p in newprops) && isproperty(p, oldprops[p]) ? ((e as any)[p] = null) : e.removeAttribute(p)\n for (let p in newprops) isproperty(p, newprops[p]) ? ((e as any)[p] = newprops[p]) : e.setAttribute(p, newprops[p])\n}\n\n/** syncs at position i of p. returns the number of the element past the last added element.\n * if no element was added (eg when h=null) then it returns i\n * if a fragment with 5 nodes was added, it returns i + 5\n * when a single element or component is added, it is i+1 since they always create exactly 1 node\n */\nfunction sync(p: Element, i: number, h: Expr<H | undefined>): number {\n // console.log('%csync', \"background:orange\", p.tagName, i, h)\n\n h = evaluate(h)\n if (h === null || h === undefined) return i // skip this element. not that !!h would forbid to render the number 0 or the boolean value false\n\n let c = p.childNodes[i] // is often null, eg during fresh creation\n\n function synctextnode(text: string) {\n if (c && c.nodeType == NodeType.TextNode) {\n if (c.textContent != text) c.textContent = text // firefox updates even equal text, loosing an existing text selection\n } else {\n let tn = document.createTextNode(text)\n c ? c.replaceWith(tn) : p.appendChild(tn)\n }\n }\n\n if (isobject(h)) {\n // element nodes\n\n /** synchronizes children starting at the i-th element. returns the index of the last child synchronized */\n function syncchildren(p: Element, h: HElement | HComp | HFragment, i: number): number {\n evaluate(h.cn)\n ?.flat()\n .forEach(hc => (i = sync(p, i, hc)))\n return i\n }\n\n if (isfragment(h)) return syncchildren(p, h, i)\n\n const props = evaluate(h.p)\n\n if (iselement(h)) {\n let n: Element\n\n if ((<Element>c)?.tagName?.toLowerCase() != h.tag.toLowerCase()) {\n n = createElement(h.tag)\n c ? c.replaceWith(n) : p.appendChild(n)\n setprops(n, props)\n props?.mounted?.(n)\n } else {\n n = c as Element\n setprops(n, props)\n if (props?.update?.(c, globaluc)) return i + 1\n }\n\n // if only components shall be updateable (advantage: close variables inside component functions are always fresh materialized, avoids surprises), comment this out\n n.h = h\n\n if (!globaluc.patchElementOnly && !iswebcomponent(h as HElement)) {\n // tbd: make \"island\" attribute\n const j = syncchildren(n, h, 0)\n removeexcesschildren(n, j)\n }\n return i + 1\n }\n\n switch (typeof h.tag) {\n case 'function':\n let isupdate = c?.h?.tag == h.tag\n\n let ci: IClassComponent | undefined\n\n if (isclasscomponent(h)) {\n h.i = ci = (c?.h as HCompClass)?.i ?? rebind(new h.tag(props))\n ci.props = props\n\n // if component instance returns truthy for update(), then syncing is susbstituted by the component\n if (isupdate && ci.update(globaluc)) return i + 1\n }\n\n // materialize the component\n // we run compoents view() and fun code often, we do not compare properties to avoid their computation\n // this means that the inner hr (h resolved) is run often\n //\n // if ci has a view, return ci.view() even if it is falsy, this is perfectly valid\n let hr = ci?.view ? ci?.view() : (h.tag as FComponent)(props, evaluate(h.cn))\n\n // a component can return undefined or null if it has no elements to show\n if (hr === undefined || hr == null) return i\n\n let j = sync(p, i, hr)\n\n let cn = p.childNodes[i]!\n cn.h = h // attach h onto the materialized component node\n // ;(cn as HTMLElement).setAttribute?.('comp', '')\n\n if (ci) ci.element = cn\n if (!isupdate) ci?.mounted?.()\n\n return j\n\n case 'object':\n return sync(p, i, h.tag) // tbd: type of h is not correct, h.tag == never\n }\n }\n // text nodes\n synctextnode(h as string)\n return i + 1\n}\n\nlet globaluc: IUpdateContext = {}\n\nexport function patch(e: Node | null, h: Expr<H>) {\n if (!e) return\n if (globaluc.replace) (e as HTMLElement).replaceChildren()\n const p = e.parentElement as HTMLElement\n const i = [].indexOf.call<any, any, any>(p.childNodes, e)\n // always called deferred, because removing elements can trigger events and their handlers (like blur)\n sync(p, i, h)\n}\n\n// Overload signatures\ntype Selector = string | Node | undefined | null\ntype Selectors = Selector[]\n\nexport function updateviewuc(uc: IUpdateContext, ...sels: Selectors): void {\n {\n globaluc = uc\n updateviewinternal(...sels)\n }\n}\nexport function updateview(...sels: Selectors): void {\n {\n globaluc = {}\n updateviewinternal(...sels)\n }\n}\n\nfunction updateviewinternal(...sels: Selector[]): void {\n if (!sels.length) sels.push('body')\n sels.flatMap(s => (typeof s == 'string' ? [...document.querySelectorAll(s)] : s ? [s] : [])).forEach(e => {\n if (!e?.h) throw 'jmx: no h exists on the node'\n patch(e, e.h)\n })\n}\n"]}
package/dist/jsx.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=jsx.js.map
package/dist/jsx.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsx.js","sourceRoot":"./","sources":["jsx.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-interface */\n/* eslint-disable @typescript-eslint/ban-types */\n// This code is based on react definition in DefinitelyTyped published under the MIT license.\n// Repository: https://github.com/DefinitelyTyped/DefinitelyTyped\n// Path in the repository: types/react/v15/index.d.ts\n//\n// Copyrights of original definition are:\n// Asana <https://asana.com>\n// AssureSign <http://www.assuresign.com>\n// Microsoft <https://microsoft.com>\n// John Reilly <https://github.com/johnnyreilly/>\n// Benoit Benezech <https://github.com/bbenezech>\n// Patricio Zavolinsky <https://github.com/pzavolinsky>\n// Digiguru <https://github.com/digiguru>\n// Eric Anderson <https://github.com/ericanderson>\n// Albert Kurniawan <https://github.com/morcerf>\n// Tanguy Krotoff <https://github.com/tkrotoff>\n// Dovydas Navickas <https://github.com/DovydasNavickas>\n// Stéphane Goetz <https://github.com/onigoetz>\n\ndeclare global {\n namespace JSX {\n interface IntrinsicElements extends IntrinsicElementAttributes {\n // additional attributes for selected elements\n // label: HTMLAttributes & { bunny: number }\n }\n }\n}\n\ninterface EventHandler<E extends Event> {\n (event: E): void\n}\n\nexport interface AdditionalElementAttributes {\n mounted?: (n:Node) => void\n update?: (n:Node, uc:IUpdateContext) => void\n}\n\nexport interface HTMLAttributes extends AdditionalElementAttributes {\n class?: string\n style?: string\n accesskey?: string\n contenteditable?: boolean\n contextmenu?: string\n dir?: string\n disabled?: boolean\n draggable?: boolean\n hidden?: boolean\n id?: string\n lang?: string\n spellcheck?: boolean\n tabindex?: number\n title?: string\n role?: string\n\n // clipboard events\n onCopy?: ClipboardEvent\n onCut?: ClipboardEvent\n onPaste?: ClipboardEvent\n\n // composition events\n onCompositionend?: CompositionEvent\n onCompositionstart?: CompositionEvent\n onCompositionupdate?: CompositionEvent\n\n // drag drop events\n ondrag?: EventHandler<DragEvent>\n ondragend?: EventHandler<DragEvent>\n ondragenter?: EventHandler<DragEvent>\n ondragexit?: EventHandler<DragEvent>\n ondragleave?: EventHandler<DragEvent>\n ondragover?: EventHandler<DragEvent>\n ondragstart?: EventHandler<DragEvent>\n ondrop?: EventHandler<DragEvent>\n\n // focus events\n onfocus?: (ev: FocusEvent) => void\n onfocusout?: (ev: FocusEvent) => void\n onblur?: (ev: FocusEvent) => void\n\n // form events\n onchange?: EventHandler<Event>\n oninput?: EventHandler<Event>\n onreset?: EventHandler<Event>\n onsubmit?: EventHandler<Event>\n oninvalid?: EventHandler<Event>\n\n // image events\n onload?: EventHandler<Event>\n onerror?: EventHandler<Event>\n\n // keyboard events\n onkeydown?: EventHandler<KeyboardEvent>\n onkeypress?: EventHandler<KeyboardEvent>\n onkeyup?: EventHandler<KeyboardEvent>\n\n // mouse events\n onclick?: EventHandler<MouseEvent>\n oncontextmenu?: EventHandler<MouseEvent>\n ondblclick?: EventHandler<MouseEvent>\n onmousedown?: EventHandler<MouseEvent>\n onmouseenter?: EventHandler<MouseEvent>\n onmouseleave?: EventHandler<MouseEvent>\n onmousemove?: EventHandler<MouseEvent>\n onmouseout?: EventHandler<MouseEvent>\n onmouseover?: EventHandler<MouseEvent>\n onmouseup?: EventHandler<MouseEvent>\n\n // media events\n onAbort?: EventHandler<Event>\n onCanplay?: EventHandler<Event>\n onCanplaythrough?: EventHandler<Event>\n onDurationchange?: EventHandler<Event>\n onEmptied?: EventHandler<Event>\n onEncrypted?: EventHandler<Event>\n onEnded?: EventHandler<Event>\n onLoadeddata?: EventHandler<Event>\n onLoadedmetadata?: EventHandler<Event>\n onLoadstart?: EventHandler<Event>\n onPause?: EventHandler<Event>\n onPlay?: EventHandler<Event>\n onPlaying?: EventHandler<Event>\n onProgress?: EventHandler<Event>\n onRatechange?: EventHandler<Event>\n onSeeked?: EventHandler<Event>\n onSeeking?: EventHandler<Event>\n onStalled?: EventHandler<Event>\n onSuspend?: EventHandler<Event>\n onTimeupdate?: EventHandler<Event>\n onVolumechange?: EventHandler<Event>\n onWaiting?: EventHandler<Event>\n\n // selection events\n onSelect?: EventHandler<Event>\n\n // UI events\n onScroll?: UIEvent\n\n // touch events\n onTouchcancel?: TouchEvent\n onTouchend?: TouchEvent\n onTouchmove?: TouchEvent\n onTouchstart?: TouchEvent\n\n // wheel events\n onWheel?: WheelEvent\n\n // animation events\n onAnimationstart?: AnimationEvent\n onAnimationend?: AnimationEvent\n onAnimationiteration?: AnimationEvent\n\n // transition events\n onTransitionend?: TransitionEvent\n onTransitionstart?: TransitionEvent\n}\n\nexport interface AnchorHTMLAttributes extends HTMLAttributes {\n download?: any\n href?: string\n hreflang?: string\n media?: string\n rel?: string\n target?: string\n}\n\nexport interface AreaHTMLAttributes extends HTMLAttributes {\n alt?: string\n coord?: string\n download?: any\n href?: string\n hreflang?: string\n media?: string\n rel?: string\n shape?: string\n target?: string\n}\n\nexport interface AudioHTMLAttributes extends MediaHTMLAttributes { }\n\nexport interface BaseHTMLAttributes extends HTMLAttributes {\n href?: string\n target?: string\n}\n\nexport interface BlockquoteHTMLAttributes extends HTMLAttributes {\n cite?: string\n}\n\nexport interface ButtonHTMLAttributes extends HTMLAttributes {\n autofocus?: boolean\n disabled?: boolean\n form?: string\n formaction?: string\n formenctype?: string\n formmethod?: string\n formnovalidate?: boolean\n formtarget?: string\n name?: string\n type?: string\n value?: string | string[] | number\n}\n\nexport interface CanvasHTMLAttributes extends HTMLAttributes {\n height?: number | string\n width?: number | string\n}\n\nexport interface ColHTMLAttributes extends HTMLAttributes {\n span?: number\n}\n\nexport interface ColgroupHTMLAttributes extends ColHTMLAttributes { }\n\nexport interface DetailsHTMLAttributes extends HTMLAttributes {\n open?: boolean\n}\n\nexport interface DelHTMLAttributes extends HTMLAttributes {\n cite?: string\n datetime?: string\n}\n\nexport interface EmbedHTMLAttributes extends HTMLAttributes {\n height?: number | string\n src?: string\n type?: string\n width?: number | string\n}\n\nexport interface FieldsetHTMLAttributes extends HTMLAttributes {\n disabled?: boolean\n form?: string\n name?: string\n}\n\nexport interface FormHTMLAttributes extends HTMLAttributes {\n acceptcharset?: string\n action?: string\n autocomplete?: string\n enctype?: string\n method?: string\n name?: string\n novalidate?: boolean\n target?: string\n}\n\nexport interface HtmlHTMLAttributes extends HTMLAttributes {\n manifest?: string\n}\n\nexport interface IframeHTMLAttributes extends HTMLAttributes {\n allowfullscreen?: boolean\n allowtransparency?: boolean\n frameborder?: number | string\n height?: number | string\n marginheight?: number\n marginwidth?: number\n name?: string\n sandbox?: string\n scrolling?: string\n seamless?: boolean\n src?: string\n srcdoc?: string\n width?: number | string\n}\n\nexport interface ImgHTMLAttributes extends HTMLAttributes {\n alt?: string\n height?: number | string\n sizes?: string\n src?: string\n srcset?: string\n usemap?: string\n width?: number | string\n}\n\nexport interface InsHTMLAttributes extends HTMLAttributes {\n cite?: string\n datetime?: string\n}\n\nexport interface InputHTMLAttributes extends HTMLAttributes {\n accept?: string\n alt?: string\n autocomplete?: string\n autofocus?: boolean\n capture?: boolean // https://www.w3.org/tr/html-media-capture/#the-capture-attribute\n checked?: boolean\n crossorigin?: string\n disabled?: boolean\n form?: string\n formaction?: string\n formenctype?: string\n formmethod?: string\n formnovalidate?: boolean\n formtarget?: string\n height?: number | string\n list?: string\n max?: number | string\n maxlength?: number\n min?: number | string\n minlength?: number\n multiple?: boolean\n name?: string\n pattern?: string\n placeholder?: string\n readonly?: boolean\n required?: boolean\n size?: number\n src?: string\n step?: number | string\n type?: string\n value?: string | string[] | number\n width?: number | string\n}\n\nexport interface KeygenHTMLAttributes extends HTMLAttributes {\n autofocus?: boolean\n challenge?: string\n disabled?: boolean\n form?: string\n keytype?: string\n keyparams?: string\n name?: string\n}\n\nexport interface LabelHTMLAttributes extends HTMLAttributes {\n form?: string\n for?: string\n}\n\nexport interface LiHTMLAttributes extends HTMLAttributes {\n value?: string | string[] | number\n}\n\nexport interface LinkHTMLAttributes extends HTMLAttributes {\n href?: string\n hreflang?: string\n integrity?: string\n media?: string\n rel?: string\n sizes?: string\n type?: string\n}\n\nexport interface MapHTMLAttributes extends HTMLAttributes {\n name?: string\n}\n\nexport interface MenuHTMLAttributes extends HTMLAttributes {\n type?: string\n}\n\nexport interface MediaHTMLAttributes extends HTMLAttributes {\n autoplay?: boolean\n controls?: boolean\n crossorigin?: string\n loop?: boolean\n mediagroup?: string\n muted?: boolean\n preload?: string\n src?: string\n}\n\nexport interface MetaHTMLAttributes extends HTMLAttributes {\n charset?: string\n content?: string\n httpequiv?: string\n name?: string\n}\n\nexport interface MeterHTMLAttributes extends HTMLAttributes {\n form?: string\n high?: number\n low?: number\n max?: number | string\n min?: number | string\n optimum?: number\n value?: string | string[] | number\n}\n\nexport interface QuoteHTMLAttributes extends HTMLAttributes {\n cite?: string\n}\n\nexport interface ObjectHTMLAttributes extends HTMLAttributes {\n classid?: string\n data?: string\n form?: string\n height?: number | string\n name?: string\n type?: string\n usemap?: string\n width?: number | string\n wmode?: string\n}\n\nexport interface OlHTMLAttributes extends HTMLAttributes {\n reversed?: boolean\n start?: number\n}\n\nexport interface OptgroupHTMLAttributes extends HTMLAttributes {\n disabled?: boolean\n label?: string\n}\n\nexport interface OptionHTMLAttributes extends HTMLAttributes {\n disabled?: boolean\n label?: string\n selected?: boolean\n value?: string | string[] | number\n}\n\nexport interface OutputHTMLAttributes extends HTMLAttributes {\n form?: string\n htmlfor?: string\n name?: string\n}\n\nexport interface ParamHTMLAttributes extends HTMLAttributes {\n name?: string\n value?: string | string[] | number\n}\n\nexport interface ProgressHTMLAttributes extends HTMLAttributes {\n max?: number | string\n value?: string | string[] | number\n}\n\nexport interface ScriptHTMLAttributes extends HTMLAttributes {\n async?: boolean\n charset?: string\n crossorigin?: string\n defer?: boolean\n integrity?: string\n nonce?: string\n src?: string\n type?: string\n}\n\nexport interface SelectHTMLAttributes extends HTMLAttributes {\n autofocus?: boolean\n disabled?: boolean\n form?: string\n multiple?: boolean\n name?: string\n required?: boolean\n size?: number\n value?: string | string[] | number\n}\n\nexport interface SourceHTMLAttributes extends HTMLAttributes {\n media?: string\n sizes?: string\n src?: string\n srcset?: string\n type?: string\n}\n\nexport interface StyleHTMLAttributes extends HTMLAttributes {\n media?: string\n nonce?: string\n scoped?: boolean\n type?: string\n}\n\nexport interface TableHTMLAttributes extends HTMLAttributes {\n cellpadding?: number | string\n cellspacing?: number | string\n summary?: string\n}\n\nexport interface TextareaHTMLAttributes extends HTMLAttributes {\n autocomplete?: string\n autofocus?: boolean\n cols?: number\n dirname?: string\n disabled?: boolean\n form?: string\n maxlength?: number\n minlength?: number\n name?: string\n placeholder?: string\n readonly?: boolean\n required?: boolean\n rows?: number\n value?: string | string[] | number\n wrap?: string\n}\n\nexport interface TdHTMLAttributes extends HTMLAttributes {\n colspan?: number\n headers?: string\n rowspan?: number\n}\n\nexport interface ThHTMLAttributes extends HTMLAttributes {\n colspan?: number\n headers?: string\n rowspan?: number\n scope?: string\n}\n\nexport interface TimeHTMLAttributes extends HTMLAttributes {\n datetime?: string\n}\n\nexport interface TrackHTMLAttributes extends HTMLAttributes {\n default?: boolean\n kind?: string\n label?: string\n src?: string\n srclang?: string\n}\n\nexport interface VideoHTMLAttributes extends MediaHTMLAttributes {\n height?: number | string\n playsinline?: boolean\n poster?: string\n width?: number | string\n}\n\nexport interface AllHTMLAttributes extends HTMLAttributes {\n accept?: string\n acceptcharset?: string\n action?: boolean\n allowfullscreen?: boolean\n allowtransparency?: boolean\n alt?: string\n async?: boolean\n autocomplete?: string\n autofocus?: boolean\n autoplay?: boolean\n capture?: boolean // https://www.w3.org/tr/html-media-capture/#the-capture-attribute\n cellpadding?: number | string\n cellspacing?: number | string\n challenge?: string\n charset?: string\n checked?: boolean\n cite?: string\n classid?: string\n cols?: number\n colspan?: number\n content?: string\n controls?: boolean\n coord?: string\n crossorigin?: string\n data?: string\n datetime?: string\n default?: boolean\n defer?: boolean\n dirname?: string\n disabled?: boolean\n download?: any\n enctype?: string\n form?: string\n formaction?: string\n formenctype?: string\n formmethod?: string\n formnovalidate?: boolean\n formtarget?: string\n frameborder?: number | string\n headers?: string\n height?: number | string\n high?: number\n href?: string\n hreflang?: string\n htmlfor?: string\n httpequiv?: string\n integrity?: string\n keyparams?: string\n keytype?: string\n kind?: string\n label?: string\n list?: string\n loop?: boolean\n low?: number\n manifest?: string\n marginheight?: number\n marginwidth?: number\n max?: number | string\n maxlength?: number\n media?: string\n mediagroup?: string\n method?: string\n min?: number | string\n minlength?: number\n multiple?: boolean\n muted?: boolean\n name?: string\n nonce?: string\n novalidate?: boolean\n open?: boolean\n optimum?: number\n pattern?: string\n placeholder?: string\n playsinline?: boolean\n poster?: string\n preload?: string\n readonly?: boolean\n rel?: string\n required?: boolean\n reversed?: boolean\n rows?: number\n rowspan?: number\n sandbox?: string\n scope?: string\n scoped?: boolean\n scrolling?: string\n seamless?: boolean\n selected?: boolean\n shape?: string\n size?: number\n sizes?: string\n span?: number\n src?: string\n srcdoc?: string\n srclang?: string\n srcset?: string\n start?: number\n step?: number | string\n summary?: string\n target?: string\n type?: string\n usemap?: string\n value?: string | string[] | number\n width?: number | string\n wmode?: string\n wrap?: string\n}\n\nexport interface IntrinsicElementAttributes {\n a: AnchorHTMLAttributes\n abbr: HTMLAttributes\n address: HTMLAttributes\n area: AreaHTMLAttributes\n article: HTMLAttributes\n aside: HTMLAttributes\n audio: AudioHTMLAttributes\n b: HTMLAttributes\n base: BaseHTMLAttributes\n bdi: HTMLAttributes\n bdo: HTMLAttributes\n big: HTMLAttributes\n blockquote: BlockquoteHTMLAttributes\n body: HTMLAttributes\n br: HTMLAttributes\n button: ButtonHTMLAttributes\n canvas: CanvasHTMLAttributes\n caption: HTMLAttributes\n cite: HTMLAttributes\n code: HTMLAttributes\n col: ColHTMLAttributes\n colgroup: ColgroupHTMLAttributes\n data: HTMLAttributes\n datalist: HTMLAttributes\n dd: HTMLAttributes\n del: DelHTMLAttributes\n details: DetailsHTMLAttributes\n dfn: HTMLAttributes\n dialog: HTMLAttributes\n div: HTMLAttributes\n dl: HTMLAttributes\n dt: HTMLAttributes\n em: HTMLAttributes\n embed: EmbedHTMLAttributes\n fieldset: FieldsetHTMLAttributes\n figcaption: HTMLAttributes\n figure: HTMLAttributes\n footer: HTMLAttributes\n form: FormHTMLAttributes\n h1: HTMLAttributes\n h2: HTMLAttributes\n h3: HTMLAttributes\n h4: HTMLAttributes\n h5: HTMLAttributes\n h6: HTMLAttributes\n head: HTMLAttributes\n header: HTMLAttributes\n hgroup: HTMLAttributes\n hr: HTMLAttributes\n html: HtmlHTMLAttributes\n i: HTMLAttributes\n iframe: IframeHTMLAttributes\n img: ImgHTMLAttributes\n input: InputHTMLAttributes\n ins: InsHTMLAttributes\n kbd: HTMLAttributes\n keygen: KeygenHTMLAttributes\n label: LabelHTMLAttributes\n legend: HTMLAttributes\n li: LiHTMLAttributes\n link: LinkHTMLAttributes\n main: HTMLAttributes\n map: MapHTMLAttributes\n mark: HTMLAttributes\n menu: MenuHTMLAttributes\n menuitem: HTMLAttributes\n meta: MetaHTMLAttributes\n meter: MeterHTMLAttributes\n nav: HTMLAttributes\n noscript: HTMLAttributes\n object: ObjectHTMLAttributes\n ol: OlHTMLAttributes\n optgroup: OptgroupHTMLAttributes\n option: OptionHTMLAttributes\n output: OutputHTMLAttributes\n p: HTMLAttributes\n param: ParamHTMLAttributes\n picture: HTMLAttributes\n pre: HTMLAttributes\n progress: ProgressHTMLAttributes\n q: QuoteHTMLAttributes\n rp: HTMLAttributes\n rt: HTMLAttributes\n ruby: HTMLAttributes\n s: HTMLAttributes\n samp: HTMLAttributes\n script: ScriptHTMLAttributes\n section: HTMLAttributes\n select: SelectHTMLAttributes\n small: HTMLAttributes\n source: SourceHTMLAttributes\n span: HTMLAttributes\n strong: HTMLAttributes\n style: StyleHTMLAttributes\n sub: HTMLAttributes\n summary: HTMLAttributes\n sup: HTMLAttributes\n table: TableHTMLAttributes\n tbody: HTMLAttributes\n td: TdHTMLAttributes\n textarea: TextareaHTMLAttributes\n tfoot: HTMLAttributes\n th: ThHTMLAttributes\n thead: HTMLAttributes\n time: TimeHTMLAttributes\n title: HTMLAttributes\n tr: HTMLAttributes\n track: TrackHTMLAttributes\n u: HTMLAttributes\n ul: HTMLAttributes\n var: HTMLAttributes\n video: VideoHTMLAttributes\n wbr: HTMLAttributes\n}\n"]}
package/dist/lib.js DELETED
@@ -1,17 +0,0 @@
1
- import { updateview } from './jmx';
2
- export const When = ({ cond }, cn) => cond ? { cn } : void 0;
3
- export class JMXComp {
4
- props;
5
- element;
6
- constructor(props) {
7
- this.props = props;
8
- }
9
- mounted() { }
10
- update(uc) { }
11
- updateview() { updateview(this.element); }
12
- get ismounted() { return this.element; }
13
- }
14
- export function cc(...namesOrObjects) {
15
- return namesOrObjects.flatMap(n => (n.trim ? n : Object.keys(n).filter(k => n[k]))).join(' ');
16
- }
17
- //# sourceMappingURL=lib.js.map
package/dist/lib.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"./","sources":["lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAIlC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,IAAI,EAAqB,EAAE,EAAY,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAE1F,MAAM,OAAgB,OAAO;IAON;IAJnB,OAAO,CAAc;IAIrB,YAAmB,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;IAGhC,OAAO,KAAK,CAAC;IACb,MAAM,CAAC,EAAmB,IAAoB,CAAC;IAI/C,UAAU,KAAK,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA,CAAC,CAAC;IACzC,IAAI,SAAS,KAAa,OAAO,IAAI,CAAC,OAAc,CAAA,CAAC,CAAC;CACzD;AAED,MAAM,UAAU,EAAE,CAAC,GAAG,cAAgC;IAClD,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjG,CAAC","sourcesContent":["import { Props, IClassComponent, H, FComponentT, Children } from 'h'\nimport { updateview } from './jmx'\n\nexport type DeepReadonly<T> = { readonly [K in keyof T]: T[K] extends Record<string, unknown> ? DeepReadonly<T[K]> : T[K]; }\n\nexport const When = ({ cond }: { cond: boolean }, cn: Children) => cond ? { cn } : void 0;\n\nexport abstract class JMXComp<P extends Props = {}> implements IClassComponent {\n\n // assigned by jmx framework\n element!: HTMLElement\n\n // we provide this ctor for jsx which uses ctor arguments as properties of class components.\n // at runtime, we pass the props directly\n constructor(public props: P) { }\n\n // overrides\n mounted() { }\n update(uc?: IUpdateContext): boolean | void { }\n abstract view(): H\n\n // utility: updates the component's view\n updateview() { updateview(this.element) }\n get ismounted():boolean { return this.element as any }\n}\n\nexport function cc(...namesOrObjects: (string | any)[]): string {\n return namesOrObjects.flatMap(n => (n.trim ? n : Object.keys(n).filter(k => n[k]))).join(' ') // n.trim distinguishes strings from objects\n}"]}