piral-million 0.15.0-beta.4579 → 0.15.0-beta.4607
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/README.md +3 -3
- package/convert.d.ts +2 -2
- package/esm/converter.d.ts +2 -3
- package/esm/converter.js +7 -7
- package/esm/converter.js.map +1 -1
- package/esm/extension.d.ts +1 -2
- package/esm/extension.js +6 -40
- package/esm/extension.js.map +1 -1
- package/esm/mount.d.ts +10 -5
- package/esm/mount.js +9 -11
- package/esm/mount.js.map +1 -1
- package/lib/converter.d.ts +2 -3
- package/lib/converter.js +6 -6
- package/lib/converter.js.map +1 -1
- package/lib/extension.d.ts +1 -2
- package/lib/extension.js +6 -40
- package/lib/extension.js.map +1 -1
- package/lib/mount.d.ts +10 -5
- package/lib/mount.js +10 -13
- package/lib/mount.js.map +1 -1
- package/package.json +3 -3
- package/src/converter.ts +8 -9
- package/src/extension.ts +9 -50
- package/src/mount.ts +11 -18
package/README.md
CHANGED
|
@@ -62,7 +62,6 @@ export function setup(piral: PiletApi) {
|
|
|
62
62
|
Using Million with Piral is as simple as installing `piral-million` and `million`.
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
|
-
import 'million';
|
|
66
65
|
import { createMillionApi } from 'piral-million';
|
|
67
66
|
```
|
|
68
67
|
|
|
@@ -76,13 +75,14 @@ const instance = createInstance({
|
|
|
76
75
|
});
|
|
77
76
|
```
|
|
78
77
|
|
|
79
|
-
The `million` package should be shared with the pilets via the *package.json*:
|
|
78
|
+
The `million` package and its `million/react` module should be shared with the pilets via the *package.json*:
|
|
80
79
|
|
|
81
80
|
```json
|
|
82
81
|
{
|
|
83
82
|
"pilets": {
|
|
84
83
|
"externals": [
|
|
85
|
-
"million"
|
|
84
|
+
"million",
|
|
85
|
+
"million/react"
|
|
86
86
|
]
|
|
87
87
|
}
|
|
88
88
|
}
|
package/convert.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface MillionConverter {
|
|
|
12
12
|
}
|
|
13
13
|
export declare function createMillionConverter(...params: Parameters<typeof createConverter>): {
|
|
14
14
|
from: MillionConverter;
|
|
15
|
-
Extension: (props: any) =>
|
|
15
|
+
Extension: (props: any) => any;
|
|
16
16
|
};
|
|
17
|
-
declare const fromMillion: MillionConverter, MillionExtension: (props: any) =>
|
|
17
|
+
declare const fromMillion: MillionConverter, MillionExtension: (props: any) => any;
|
|
18
18
|
export { fromMillion, MillionExtension };
|
package/esm/converter.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import type { VNode } from 'million';
|
|
3
2
|
export interface MillionConverterOptions {
|
|
4
3
|
/**
|
|
5
4
|
* Defines the name of the root element.
|
|
@@ -8,6 +7,6 @@ export interface MillionConverterOptions {
|
|
|
8
7
|
rootName?: string;
|
|
9
8
|
}
|
|
10
9
|
export declare function createConverter(config?: MillionConverterOptions): {
|
|
11
|
-
<TProps extends BaseComponentProps>(root:
|
|
12
|
-
Extension: (props: import("piral-core").ExtensionSlotProps<string>) =>
|
|
10
|
+
<TProps extends BaseComponentProps>(root: any): ForeignComponent<TProps>;
|
|
11
|
+
Extension: (props: import("piral-core").ExtensionSlotProps<string>) => any;
|
|
13
12
|
};
|
package/esm/converter.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { mountMillion,
|
|
1
|
+
import { mountMillion, unmountMillion } from './mount';
|
|
2
2
|
import { createExtension } from './extension';
|
|
3
3
|
export function createConverter(config = {}) {
|
|
4
4
|
const { rootName = 'slot' } = config;
|
|
5
5
|
const Extension = createExtension(rootName);
|
|
6
6
|
const convert = (root) => ({
|
|
7
|
-
mount(el, props, ctx
|
|
8
|
-
|
|
7
|
+
mount(el, props, ctx) {
|
|
8
|
+
mountMillion(el, root, props, ctx);
|
|
9
9
|
},
|
|
10
|
-
update(el, props, ctx
|
|
11
|
-
|
|
10
|
+
update(el, props, ctx) {
|
|
11
|
+
mountMillion(el, root, props, ctx);
|
|
12
12
|
},
|
|
13
|
-
unmount(el
|
|
14
|
-
unmountMillion(el
|
|
13
|
+
unmount(el) {
|
|
14
|
+
unmountMillion(el);
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
convert.Extension = Extension;
|
package/esm/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,MAAM,UAAU,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,IAAS,EAA4B,EAAE,CAAC,CAAC;QAC3F,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YAClB,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YACnB,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,CAAC,EAAE;YACR,cAAc,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/esm/extension.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { VNode } from 'million';
|
|
2
1
|
import type { ExtensionSlotProps } from 'piral-core';
|
|
3
|
-
export declare function createExtension(rootName: string): (props: ExtensionSlotProps) =>
|
|
2
|
+
export declare function createExtension(rootName: string): (props: ExtensionSlotProps<string>) => any;
|
package/esm/extension.js
CHANGED
|
@@ -1,45 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
for (const i in a) {
|
|
4
|
-
if (!(i in b)) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
for (const i in b) {
|
|
9
|
-
if (!compare(a[i], b[i])) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
function compare(a, b) {
|
|
16
|
-
if (a !== b) {
|
|
17
|
-
const ta = typeof a;
|
|
18
|
-
const tb = typeof b;
|
|
19
|
-
if (ta === tb && ta === 'object' && a && b) {
|
|
20
|
-
return compareObjects(a, b);
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
1
|
+
import { createElement, useContext } from 'million/react';
|
|
2
|
+
import { piralContext } from './mount';
|
|
26
3
|
export function createExtension(rootName) {
|
|
27
4
|
return (props) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
node.childNodes.forEach((n) => node.removeChild(n));
|
|
33
|
-
piral.renderHtmlExtension(node, this.props);
|
|
34
|
-
return true;
|
|
35
|
-
},
|
|
36
|
-
update(node, newNode, oldNode) {
|
|
37
|
-
if (!compare(newNode.props, oldNode.props)) {
|
|
38
|
-
//TODO render extension
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
},
|
|
42
|
-
});
|
|
5
|
+
const { piral } = useContext(piralContext);
|
|
6
|
+
const m = createElement;
|
|
7
|
+
//TODO
|
|
8
|
+
return m(rootName);
|
|
43
9
|
};
|
|
44
10
|
}
|
|
45
11
|
//# sourceMappingURL=extension.js.map
|
package/esm/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,CAAC,KAAyB,EAAE,EAAE;QACnC,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,aAAoB,CAAC;QAC/B,MAAM;QACN,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC"}
|
package/esm/mount.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { BaseComponentProps, ComponentContext } from 'piral-core';
|
|
2
|
+
export declare const piralContext: {
|
|
3
|
+
value: any;
|
|
4
|
+
Provider: ({ value }: {
|
|
5
|
+
value: any;
|
|
6
|
+
}) => any;
|
|
7
|
+
Consumer: () => any;
|
|
8
|
+
};
|
|
9
|
+
export declare function mountMillion<T extends BaseComponentProps>(el: HTMLElement, root: any, props: T, ctx: ComponentContext): any;
|
|
10
|
+
export declare function unmountMillion(el: HTMLElement): void;
|
package/esm/mount.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { render,
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { render, createElement, createContext } from 'million/react';
|
|
2
|
+
export const piralContext = createContext({});
|
|
3
|
+
export function mountMillion(el, root, props, ctx) {
|
|
4
|
+
const value = Object.assign(Object.assign({}, ctx), { piral: props.piral });
|
|
5
|
+
const m = createElement;
|
|
6
|
+
const node = m(piralContext.Provider, { value }, m(root, props));
|
|
7
|
+
render(node, el);
|
|
5
8
|
return node;
|
|
6
9
|
}
|
|
7
|
-
export function
|
|
8
|
-
|
|
9
|
-
render(el, newNode, oldNode);
|
|
10
|
-
return newNode;
|
|
11
|
-
}
|
|
12
|
-
export function unmountMillion(el, oldNode) {
|
|
13
|
-
render(el, '', oldNode);
|
|
10
|
+
export function unmountMillion(el) {
|
|
11
|
+
render('', el);
|
|
14
12
|
}
|
|
15
13
|
//# sourceMappingURL=mount.js.map
|
package/esm/mount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;AAE9C,MAAM,UAAU,YAAY,CAA+B,EAAe,EAAE,IAAS,EAAE,KAAQ,EAAE,GAAqB;IACpH,MAAM,KAAK,mCAAQ,GAAG,KAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAE,CAAC;IAC7C,MAAM,CAAC,GAAG,aAAoB,CAAC;IAC/B,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACjE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAe;IAC5C,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACjB,CAAC"}
|
package/lib/converter.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import type { VNode } from 'million';
|
|
3
2
|
export interface MillionConverterOptions {
|
|
4
3
|
/**
|
|
5
4
|
* Defines the name of the root element.
|
|
@@ -8,6 +7,6 @@ export interface MillionConverterOptions {
|
|
|
8
7
|
rootName?: string;
|
|
9
8
|
}
|
|
10
9
|
export declare function createConverter(config?: MillionConverterOptions): {
|
|
11
|
-
<TProps extends BaseComponentProps>(root:
|
|
12
|
-
Extension: (props: import("piral-core").ExtensionSlotProps<string>) =>
|
|
10
|
+
<TProps extends BaseComponentProps>(root: any): ForeignComponent<TProps>;
|
|
11
|
+
Extension: (props: import("piral-core").ExtensionSlotProps<string>) => any;
|
|
13
12
|
};
|
package/lib/converter.js
CHANGED
|
@@ -7,14 +7,14 @@ function createConverter(config = {}) {
|
|
|
7
7
|
const { rootName = 'slot' } = config;
|
|
8
8
|
const Extension = (0, extension_1.createExtension)(rootName);
|
|
9
9
|
const convert = (root) => ({
|
|
10
|
-
mount(el, props, ctx
|
|
11
|
-
|
|
10
|
+
mount(el, props, ctx) {
|
|
11
|
+
(0, mount_1.mountMillion)(el, root, props, ctx);
|
|
12
12
|
},
|
|
13
|
-
update(el, props, ctx
|
|
14
|
-
|
|
13
|
+
update(el, props, ctx) {
|
|
14
|
+
(0, mount_1.mountMillion)(el, root, props, ctx);
|
|
15
15
|
},
|
|
16
|
-
unmount(el
|
|
17
|
-
(0, mount_1.unmountMillion)(el
|
|
16
|
+
unmount(el) {
|
|
17
|
+
(0, mount_1.unmountMillion)(el);
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
convert.Extension = Extension;
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,mCAAuD;AACvD,2CAA8C;AAU9C,SAAgB,eAAe,CAAC,SAAkC,EAAE;IAClE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,IAAS,EAA4B,EAAE,CAAC,CAAC;QAC3F,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YAClB,IAAA,oBAAY,EAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YACnB,IAAA,oBAAY,EAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,CAAC,EAAE;YACR,IAAA,sBAAc,EAAC,EAAE,CAAC,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAhBD,0CAgBC"}
|
package/lib/extension.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { VNode } from 'million';
|
|
2
1
|
import type { ExtensionSlotProps } from 'piral-core';
|
|
3
|
-
export declare function createExtension(rootName: string): (props: ExtensionSlotProps) =>
|
|
2
|
+
export declare function createExtension(rootName: string): (props: ExtensionSlotProps<string>) => any;
|
package/lib/extension.js
CHANGED
|
@@ -1,48 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createExtension = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
for (const i in a) {
|
|
7
|
-
if (!(i in b)) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
for (const i in b) {
|
|
12
|
-
if (!compare(a[i], b[i])) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
function compare(a, b) {
|
|
19
|
-
if (a !== b) {
|
|
20
|
-
const ta = typeof a;
|
|
21
|
-
const tb = typeof b;
|
|
22
|
-
if (ta === tb && ta === 'object' && a && b) {
|
|
23
|
-
return compareObjects(a, b);
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
4
|
+
const react_1 = require("million/react");
|
|
5
|
+
const mount_1 = require("./mount");
|
|
29
6
|
function createExtension(rootName) {
|
|
30
7
|
return (props) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
node.childNodes.forEach((n) => node.removeChild(n));
|
|
36
|
-
piral.renderHtmlExtension(node, this.props);
|
|
37
|
-
return true;
|
|
38
|
-
},
|
|
39
|
-
update(node, newNode, oldNode) {
|
|
40
|
-
if (!compare(newNode.props, oldNode.props)) {
|
|
41
|
-
//TODO render extension
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
},
|
|
45
|
-
});
|
|
8
|
+
const { piral } = (0, react_1.useContext)(mount_1.piralContext);
|
|
9
|
+
const m = react_1.createElement;
|
|
10
|
+
//TODO
|
|
11
|
+
return m(rootName);
|
|
46
12
|
};
|
|
47
13
|
}
|
|
48
14
|
exports.createExtension = createExtension;
|
package/lib/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AACA,yCAA0D;AAC1D,mCAAuC;AAEvC,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,CAAC,KAAyB,EAAE,EAAE;QACnC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,kBAAU,EAAC,oBAAY,CAAC,CAAC;QAC3C,MAAM,CAAC,GAAG,qBAAoB,CAAC;QAC/B,MAAM;QACN,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC;AAPD,0CAOC"}
|
package/lib/mount.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { BaseComponentProps, ComponentContext } from 'piral-core';
|
|
2
|
+
export declare const piralContext: {
|
|
3
|
+
value: any;
|
|
4
|
+
Provider: ({ value }: {
|
|
5
|
+
value: any;
|
|
6
|
+
}) => any;
|
|
7
|
+
Consumer: () => any;
|
|
8
|
+
};
|
|
9
|
+
export declare function mountMillion<T extends BaseComponentProps>(el: HTMLElement, root: any, props: T, ctx: ComponentContext): any;
|
|
10
|
+
export declare function unmountMillion(el: HTMLElement): void;
|
package/lib/mount.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unmountMillion = exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
(
|
|
3
|
+
exports.unmountMillion = exports.mountMillion = exports.piralContext = void 0;
|
|
4
|
+
const react_1 = require("million/react");
|
|
5
|
+
exports.piralContext = (0, react_1.createContext)({});
|
|
6
|
+
function mountMillion(el, root, props, ctx) {
|
|
7
|
+
const value = Object.assign(Object.assign({}, ctx), { piral: props.piral });
|
|
8
|
+
const m = react_1.createElement;
|
|
9
|
+
const node = m(exports.piralContext.Provider, { value }, m(root, props));
|
|
10
|
+
(0, react_1.render)(node, el);
|
|
8
11
|
return node;
|
|
9
12
|
}
|
|
10
13
|
exports.mountMillion = mountMillion;
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
(0, million_1.render)(el, newNode, oldNode);
|
|
14
|
-
return newNode;
|
|
15
|
-
}
|
|
16
|
-
exports.updateMillion = updateMillion;
|
|
17
|
-
function unmountMillion(el, oldNode) {
|
|
18
|
-
(0, million_1.render)(el, '', oldNode);
|
|
14
|
+
function unmountMillion(el) {
|
|
15
|
+
(0, react_1.render)('', el);
|
|
19
16
|
}
|
|
20
17
|
exports.unmountMillion = unmountMillion;
|
|
21
18
|
//# sourceMappingURL=mount.js.map
|
package/lib/mount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;;AACA,yCAAqE;AAExD,QAAA,YAAY,GAAG,IAAA,qBAAa,EAAC,EAAE,CAAC,CAAC;AAE9C,SAAgB,YAAY,CAA+B,EAAe,EAAE,IAAS,EAAE,KAAQ,EAAE,GAAqB;IACpH,MAAM,KAAK,mCAAQ,GAAG,KAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAE,CAAC;IAC7C,MAAM,CAAC,GAAG,qBAAoB,CAAC;IAC/B,MAAM,IAAI,GAAG,CAAC,CAAC,oBAAY,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACjE,IAAA,cAAM,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC;AACd,CAAC;AAND,oCAMC;AAED,SAAgB,cAAc,CAAC,EAAe;IAC5C,IAAA,cAAM,EAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACjB,CAAC;AAFD,wCAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-million",
|
|
3
|
-
"version": "0.15.0-beta.
|
|
3
|
+
"version": "0.15.0-beta.4607",
|
|
4
4
|
"description": "Plugin for integrating Million components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"million": "^1.12.0",
|
|
68
|
-
"piral-core": "0.15.0-beta.
|
|
68
|
+
"piral-core": "0.15.0-beta.4607"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"million": "^1.0.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "2b1f8f84149c0ddb5020a5df0bb1b94dad56f386"
|
|
74
74
|
}
|
package/src/converter.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import
|
|
3
|
-
import { mountMillion, updateMillion, unmountMillion } from './mount';
|
|
2
|
+
import { mountMillion, unmountMillion } from './mount';
|
|
4
3
|
import { createExtension } from './extension';
|
|
5
4
|
|
|
6
5
|
export interface MillionConverterOptions {
|
|
@@ -14,15 +13,15 @@ export interface MillionConverterOptions {
|
|
|
14
13
|
export function createConverter(config: MillionConverterOptions = {}) {
|
|
15
14
|
const { rootName = 'slot' } = config;
|
|
16
15
|
const Extension = createExtension(rootName);
|
|
17
|
-
const convert = <TProps extends BaseComponentProps>(root:
|
|
18
|
-
mount(el, props, ctx
|
|
19
|
-
|
|
16
|
+
const convert = <TProps extends BaseComponentProps>(root: any): ForeignComponent<TProps> => ({
|
|
17
|
+
mount(el, props, ctx) {
|
|
18
|
+
mountMillion(el, root, props, ctx);
|
|
20
19
|
},
|
|
21
|
-
update(el, props, ctx
|
|
22
|
-
|
|
20
|
+
update(el, props, ctx) {
|
|
21
|
+
mountMillion(el, root, props, ctx);
|
|
23
22
|
},
|
|
24
|
-
unmount(el
|
|
25
|
-
unmountMillion(el
|
|
23
|
+
unmount(el) {
|
|
24
|
+
unmountMillion(el);
|
|
26
25
|
},
|
|
27
26
|
});
|
|
28
27
|
convert.Extension = Extension;
|
package/src/extension.ts
CHANGED
|
@@ -1,53 +1,12 @@
|
|
|
1
|
-
import { m, VNode, _ } from 'million';
|
|
2
1
|
import type { ExtensionSlotProps } from 'piral-core';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!compare(a[i], b[i])) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function compare<T>(a: T, b: T) {
|
|
21
|
-
if (a !== b) {
|
|
22
|
-
const ta = typeof a;
|
|
23
|
-
const tb = typeof b;
|
|
24
|
-
|
|
25
|
-
if (ta === tb && ta === 'object' && a && b) {
|
|
26
|
-
return compareObjects(a, b);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createExtension(rootName: string): (props: ExtensionSlotProps) => VNode {
|
|
36
|
-
return (props) => {
|
|
37
|
-
return m(rootName, props, _, _, _, {
|
|
38
|
-
create(node) {
|
|
39
|
-
const { piral } = props as any;
|
|
40
|
-
node.textContent = '';
|
|
41
|
-
node.childNodes.forEach((n) => node.removeChild(n));
|
|
42
|
-
piral.renderHtmlExtension(node, this.props);
|
|
43
|
-
return true;
|
|
44
|
-
},
|
|
45
|
-
update(node, newNode, oldNode) {
|
|
46
|
-
if (!compare((newNode as any).props, (oldNode as any).props)) {
|
|
47
|
-
//TODO render extension
|
|
48
|
-
}
|
|
49
|
-
return true;
|
|
50
|
-
},
|
|
51
|
-
});
|
|
2
|
+
import { createElement, useContext } from 'million/react';
|
|
3
|
+
import { piralContext } from './mount';
|
|
4
|
+
|
|
5
|
+
export function createExtension(rootName: string) {
|
|
6
|
+
return (props: ExtensionSlotProps) => {
|
|
7
|
+
const { piral } = useContext(piralContext);
|
|
8
|
+
const m = createElement as any;
|
|
9
|
+
//TODO
|
|
10
|
+
return m(rootName);
|
|
52
11
|
};
|
|
53
12
|
}
|
package/src/mount.ts
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { BaseComponentProps, ComponentContext } from 'piral-core';
|
|
2
|
+
import { render, createElement, createContext } from 'million/react';
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
const node = m(root as any, props);
|
|
6
|
-
render(el, node);
|
|
7
|
-
return node;
|
|
8
|
-
}
|
|
4
|
+
export const piralContext = createContext({});
|
|
9
5
|
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const newNode = m(root as any, props);
|
|
17
|
-
render(el, newNode, oldNode);
|
|
18
|
-
return newNode;
|
|
6
|
+
export function mountMillion<T extends BaseComponentProps>(el: HTMLElement, root: any, props: T, ctx: ComponentContext) {
|
|
7
|
+
const value = { ...ctx, piral: props.piral };
|
|
8
|
+
const m = createElement as any;
|
|
9
|
+
const node = m(piralContext.Provider, { value }, m(root, props));
|
|
10
|
+
render(node, el);
|
|
11
|
+
return node;
|
|
19
12
|
}
|
|
20
13
|
|
|
21
|
-
export function unmountMillion(el: HTMLElement
|
|
22
|
-
render(
|
|
14
|
+
export function unmountMillion(el: HTMLElement) {
|
|
15
|
+
render('', el);
|
|
23
16
|
}
|