jmx-runtime 0.0.26 → 0.0.27

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/base.ts CHANGED
@@ -1,25 +1,25 @@
1
- export function rebind(o: Record<string, any>) {
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
-
8
- export function mount(o: Record<string, any>) { Object.assign(globalThis, o) }
9
-
10
- export const loggedmethodsex = <T extends Record<string, any>>(o: T, logger: (name: string, args: any[], result: any) => void) => new Proxy(o, {
11
- get(target, name: string, receiver) {
12
- if (typeof target[name] === "function") {
13
- return function (this: T, ...args: any[]) {
14
-
15
- logger(name, args, undefined)
16
- let r = target[name].apply(this, args)
17
- return r
18
- }
19
- }
20
- return Reflect.get(target, name, receiver)
21
- },
22
- })
23
-
24
- export 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))
25
- export 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))
1
+ export function rebind(o: Record<string, any>) {
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
+
8
+ export function mount(o: Record<string, any>) { Object.assign(globalThis, o) }
9
+
10
+ export const loggedmethodsex = <T extends Record<string, any>>(o: T, logger: (name: string, args: any[], result: any) => void) => new Proxy(o, {
11
+ get(target, name: string, receiver) {
12
+ if (typeof target[name] === "function") {
13
+ return function (this: T, ...args: any[]) {
14
+
15
+ logger(name, args, undefined)
16
+ let r = target[name].apply(this, args)
17
+ return r
18
+ }
19
+ }
20
+ return Reflect.get(target, name, receiver)
21
+ },
22
+ })
23
+
24
+ export 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))
25
+ export 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))
package/dist/base.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export declare function rebind(o: Record<string, any>): Record<string, any>;
2
- export declare function mount(o: Record<string, any>): void;
3
- export declare const loggedmethodsex: <T extends Record<string, any>>(o: T, logger: (name: string, args: any[], result: any) => void) => T;
4
- export declare const loggedmethods: <T extends Record<string, any>>(o: T) => T;
5
- export declare const loggedmethodscolored: <T extends Record<string, any>>(bgcolor: string, o: T) => T;
1
+ export declare function rebind(o: Record<string, any>): Record<string, any>;
2
+ export declare function mount(o: Record<string, any>): void;
3
+ export declare const loggedmethodsex: <T extends Record<string, any>>(o: T, logger: (name: string, args: any[], result: any) => void) => T;
4
+ export declare const loggedmethods: <T extends Record<string, any>>(o: T) => T;
5
+ export declare const loggedmethodscolored: <T extends Record<string, any>>(bgcolor: string, o: T) => T;
6
6
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"./","sources":["base.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,uBAK5C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAkC;AAE9E,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,MAY3H,CAAA;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,KAAI,CAA8I,CAAA;AACnN,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,MAAM,KAAK,CAAC,KAAI,CAAiJ,CAAA"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"./","sources":["base.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,uBAK5C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAAkC;AAE9E,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,MAY3H,CAAA;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,KAAI,CAA8I,CAAA;AACnN,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,KAAI,CAAiJ,CAAA"}
package/dist/base.js CHANGED
@@ -1,22 +1,22 @@
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));
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
22
  //# sourceMappingURL=base.js.map
package/dist/base.js.map CHANGED
@@ -1 +1 @@
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,CAAC,CAAC,CAAC,CAAC,CAAC;SACrE,MAAM,CAAC,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AA;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>) {\r\n Object.entries(Object.getOwnPropertyDescriptors(Object.getPrototypeOf(o)))\r\n .filter(([name, p]) => name != 'constructor' && p.value instanceof Function)\r\n .forEach(([name]) => o[name] = o[name].bind(o))\r\n return o\r\n}\r\n\r\nexport function mount(o: Record<string, any>) { Object.assign(globalThis, o) }\r\n\r\nexport const loggedmethodsex = <T extends Record<string, any>>(o: T, logger: (name: string, args: any[], result: any) => void) => new Proxy(o, {\r\n get(target, name: string, receiver) {\r\n if (typeof target[name] === \"function\") {\r\n return function (this: T, ...args: any[]) {\r\n\r\n logger(name, args, undefined)\r\n let r = target[name].apply(this, args)\r\n return r\r\n }\r\n }\r\n return Reflect.get(target, name, receiver)\r\n },\r\n})\r\n\r\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))\r\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))\r\n"]}
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,CAAC,CAAC,CAAC,CAAC,CAAC;SACrE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAA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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 CHANGED
@@ -1,9 +1,9 @@
1
- declare global {
2
- interface Window {
3
- jmx?: {
4
- getnamespace: (tag: string) => string;
5
- };
6
- }
7
- }
8
- export declare function createElement(tag: string): Element;
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
9
  //# sourceMappingURL=config.d.ts.map
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
- export function createElement(tag) {
2
- let ns = window.jmx?.getnamespace?.(tag);
3
- return ns ? document.createElementNS(ns, tag) : document.createElement(tag);
4
- }
1
+ export function createElement(tag) {
2
+ let ns = window.jmx?.getnamespace?.(tag);
3
+ return ns ? document.createElementNS(ns, tag) : document.createElement(tag);
4
+ }
5
5
  //# sourceMappingURL=config.js.map
package/dist/h.d.ts CHANGED
@@ -1,58 +1,58 @@
1
- type Func<T> = () => T;
2
- export type Expr<T> = T | Func<T>;
3
- export type Props = Record<string, any>;
4
- export type FComponent = (props: Props | undefined, children?: ChildrenH) => HElement;
5
- export type FComponentT<P> = (pcn: P, cn?: Children) => H | void;
6
- export interface IClassComponent {
7
- element: Node;
8
- props?: Record<string, any>;
9
- view(): H;
10
- update(uc: IUpdateContext): boolean | void;
11
- mounted?(): void;
12
- }
13
- interface CComponent {
14
- new (props: any): IClassComponent;
15
- }
16
- export type ChildrenH = (H | undefined)[];
17
- export type Children = Expr<ChildrenH>;
18
- type HText = string | number | boolean;
19
- export type HFragment = {
20
- cn: Children;
21
- };
22
- export type HElement = {
23
- tag: string;
24
- p?: Expr<Props>;
25
- cn: Children;
26
- i?: any;
27
- };
28
- type HCompFun = {
29
- tag: FComponent;
30
- p?: Expr<Props>;
31
- cn?: Children;
32
- };
33
- export type HCompClass = {
34
- tag: CComponent;
35
- p?: Expr<Props>;
36
- cn: Children;
37
- i: IClassComponent;
38
- };
39
- export type HComp = HCompFun | HCompClass;
40
- export type H = HText | HElement | HComp | HFragment;
41
- declare global {
42
- interface Node {
43
- h?: HElement | HCompFun | HCompClass;
44
- }
45
- export interface IUpdateContext {
46
- patchElementOnly?: boolean;
47
- replace?: boolean;
48
- }
49
- export interface Window {
50
- jmx?: {
51
- getnamespace: (tag: string) => string | undefined;
52
- };
53
- }
54
- }
55
- export declare function jsx(): HElement;
56
- export declare function jsxf(): HElement;
57
- export {};
1
+ type Func<T> = () => T;
2
+ export type Expr<T> = T | Func<T>;
3
+ export type Props = Record<string, any>;
4
+ export type FComponent = (props: Props | undefined, children?: ChildrenH) => HElement;
5
+ export type FComponentT<P> = (pcn: P, cn?: Children) => H | void;
6
+ export interface IClassComponent {
7
+ element: Node;
8
+ props?: Record<string, any>;
9
+ view(): H;
10
+ update(uc: IUpdateContext): boolean | void;
11
+ mounted?(): void;
12
+ }
13
+ interface CComponent {
14
+ new (props: any): IClassComponent;
15
+ }
16
+ export type ChildrenH = (H | undefined)[];
17
+ export type Children = Expr<ChildrenH>;
18
+ type HText = string | number | boolean;
19
+ export type HFragment = {
20
+ cn: Children;
21
+ };
22
+ export type HElement = {
23
+ tag: string;
24
+ p?: Expr<Props>;
25
+ cn: Children;
26
+ i?: any;
27
+ };
28
+ type HCompFun = {
29
+ tag: FComponent;
30
+ p?: Expr<Props>;
31
+ cn?: Children;
32
+ };
33
+ export type HCompClass = {
34
+ tag: CComponent;
35
+ p?: Expr<Props>;
36
+ cn: Children;
37
+ i: IClassComponent;
38
+ };
39
+ export type HComp = HCompFun | HCompClass;
40
+ export type H = HText | HElement | HComp | HFragment;
41
+ declare global {
42
+ interface Node {
43
+ h?: HElement | HCompFun | HCompClass;
44
+ }
45
+ export interface IUpdateContext {
46
+ patchElementOnly?: boolean;
47
+ replace?: boolean;
48
+ }
49
+ export interface Window {
50
+ jmx?: {
51
+ getnamespace: (tag: string) => string | undefined;
52
+ };
53
+ }
54
+ }
55
+ export declare function jsx(): HElement;
56
+ export declare function jsxf(): HElement;
57
+ export {};
58
58
  //# sourceMappingURL=h.d.ts.map
package/dist/h.js CHANGED
@@ -1,7 +1,7 @@
1
- export function jsx() {
2
- throw 'jmx plugin not configured';
3
- }
4
- export function jsxf() {
5
- throw 'jmx plugin not configured';
6
- }
1
+ export function jsx() {
2
+ throw 'jmx plugin not configured';
3
+ }
4
+ export function jsxf() {
5
+ throw 'jmx plugin not configured';
6
+ }
7
7
  //# sourceMappingURL=h.js.map
package/dist/h.js.map CHANGED
@@ -1 +1 @@
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\r\n// the following types describe the js expression we get from tsx after conversion be our jmx plugin\r\n// they can be useful for users as well, components might return them.\r\n\r\ntype Func<T> = () => T\r\nexport type Expr<T> = T | Func<T>\r\n\r\nexport type Props = Record<string, any>\r\n\r\nexport type FComponent = (props: Props | undefined, children?: ChildrenH) => HElement // show an example for usage of children\r\n\r\nexport type FComponentT<P> = (pcn: P, cn?: Children) => H | void\r\n\r\nexport interface IClassComponent {\r\n element: Node\r\n props?: Record<string, any>\r\n view(): H\r\n update(uc: IUpdateContext): boolean | void\r\n mounted?(): void\r\n}\r\n\r\ninterface CComponent {\r\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()\r\n}\r\n\r\nexport type ChildrenH = (H | undefined)[]\r\nexport type Children = Expr<ChildrenH>\r\n\r\ntype HText =\r\n | string // text node\r\n | number // text node\r\n | boolean // do not allow boolean, that\r\n\r\nexport type HFragment = {\r\n cn: Children\r\n}\r\n\r\nexport type HElement = {\r\n tag: string\r\n p?: Expr<Props>\r\n cn: Children\r\n i?: any\r\n}\r\n\r\ntype HCompFun = {\r\n tag: FComponent\r\n p?: Expr<Props>\r\n cn?: Children\r\n}\r\n\r\nexport type HCompClass = {\r\n tag: CComponent\r\n p?: Expr<Props>\r\n cn: Children\r\n i: IClassComponent\r\n}\r\n\r\nexport type HComp = HCompFun | HCompClass\r\n\r\nexport type H = // a hyperscript atom that describes a ...\r\n\r\n | HText\r\n | HElement // a tag, like p, div with attributes and children\r\n | HComp // a dynamic component computing any other HNode\r\n | HFragment\r\n\r\ndeclare global {\r\n interface Node {\r\n h?: HElement | HCompFun | HCompClass\r\n }\r\n export interface IUpdateContext {\r\n patchElementOnly?: boolean\r\n replace?: boolean\r\n }\r\n\r\n export interface Window {\r\n jmx?: {\r\n getnamespace: (tag: string) => string | undefined\r\n }\r\n }\r\n}\r\n\r\nexport function jsx(): HElement {\r\n throw 'jmx plugin not configured'\r\n} // dumy function for app code - jmx-plugin removes calls to this function, minifyer then removes it\r\nexport function jsxf(): HElement {\r\n throw 'jmx plugin not configured'\r\n} // dumy function for app code - jmx-plugin removes calls to this function, minifyer then removes it\r\n"]}
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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './jmx';
2
- export * from './lib';
3
- export * from './base';
4
- export * from './h';
5
- export * from './jsx';
1
+ export * from './jmx';
2
+ export * from './lib';
3
+ export * from './base';
4
+ export * from './h';
5
+ export * from './jsx';
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export * from './jmx';
2
- export * from './lib';
3
- export * from './base';
4
- export * from './h';
5
- export * from './jsx';
1
+ export * from './jmx';
2
+ export * from './lib';
3
+ export * from './base';
4
+ export * from './h';
5
+ export * from './jsx';
6
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,KAAK,CAAC;AACpB,cAAc,OAAO,CAAC","sourcesContent":["export * from './jmx';\r\nexport * from './lib';\r\nexport * from './base';\r\nexport * from './h';\r\nexport * from './jsx';\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,KAAK,CAAC;AACpB,cAAc,OAAO,CAAC","sourcesContent":["export * from './jmx';\nexport * from './lib';\nexport * from './base';\nexport * from './h';\nexport * from './jsx';\n"]}
package/dist/jmx.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Expr, H } from './h';
2
- export declare function createElement(tag: string): Element;
3
- export declare function patch(e: Node | null, h: Expr<H>): void;
4
- type Selector = string | Node | undefined | null;
5
- type Selectors = Selector[];
6
- export declare function updateviewuc(uc: IUpdateContext, ...sels: Selectors): void;
7
- export declare function updateview(...sels: Selectors): void;
8
- export {};
1
+ import { Expr, H } from './h';
2
+ export declare function createElement(tag: string): Element;
3
+ export declare function patch(e: Node | null, h: Expr<H>): void;
4
+ type Selector = string | Node | undefined | null;
5
+ type Selectors = Selector[];
6
+ export declare function updateviewuc(uc: IUpdateContext, ...sels: Selectors): void;
7
+ export declare function updateview(...sels: Selectors): void;
8
+ export {};
9
9
  //# sourceMappingURL=jmx.d.ts.map
package/dist/jmx.js CHANGED
@@ -1,135 +1,135 @@
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
- }
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
135
  //# sourceMappingURL=jmx.js.map