piral-inferno 0.13.8 → 0.14.0-beta.3156
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/convert.d.ts +8 -6
- package/convert.js +17 -8
- package/esm/converter.d.ts +13 -3
- package/esm/converter.js +9 -5
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +2 -6
- package/esm/create.js +7 -13
- package/esm/create.js.map +1 -1
- package/esm/extension.d.ts +2 -2
- package/esm/extension.js +35 -17
- package/esm/extension.js.map +1 -1
- package/esm/mount.d.ts +1 -1
- package/esm/mount.js +11 -18
- package/esm/mount.js.map +1 -1
- package/lib/converter.d.ts +13 -3
- package/lib/converter.js +13 -9
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +2 -6
- package/lib/create.js +8 -14
- package/lib/create.js.map +1 -1
- package/lib/extension.d.ts +2 -2
- package/lib/extension.js +40 -22
- package/lib/extension.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/mount.d.ts +1 -1
- package/lib/mount.js +15 -22
- package/lib/mount.js.map +1 -1
- package/package.json +4 -5
- package/src/converter.ts +15 -3
- package/src/create.ts +4 -13
- package/src/extension.ts +33 -2
- package/src/mount.ts +1 -1
- package/convert.ts +0 -16
package/convert.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HtmlComponent } from 'piral-core';
|
|
2
|
-
import {
|
|
3
|
-
declare const convert: <TProps extends import("piral-core").BaseComponentProps>(root: import("inferno").ComponentType<TProps>) => import("piral-core").ForeignComponent<TProps>;
|
|
2
|
+
import { createConverter } from './lib/converter';
|
|
4
3
|
export interface InfernoConverter {
|
|
5
|
-
(...params: Parameters<typeof
|
|
4
|
+
(...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
|
|
6
5
|
}
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export declare function createInfernoConverter(...params: Parameters<typeof createConverter>): {
|
|
7
|
+
from: InfernoConverter;
|
|
8
|
+
Extension: import("inferno").Component<import("piral-core").ExtensionSlotProps<string>, {}>;
|
|
9
|
+
};
|
|
10
|
+
declare const fromInferno: InfernoConverter, InfernoExtension: import("inferno").Component<import("piral-core").ExtensionSlotProps<string>, {}>;
|
|
11
|
+
export { fromInferno, InfernoExtension };
|
package/convert.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.
|
|
3
|
+
exports.InfernoExtension = exports.fromInferno = exports.createInfernoConverter = void 0;
|
|
4
4
|
var converter_1 = require("./lib/converter");
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function createInfernoConverter() {
|
|
6
|
+
var params = [];
|
|
7
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
|
+
params[_i] = arguments[_i];
|
|
9
|
+
}
|
|
10
|
+
var convert = converter_1.createConverter.apply(void 0, params);
|
|
11
|
+
var Extension = convert.Extension;
|
|
12
|
+
var from = function (root) { return ({
|
|
13
|
+
type: 'html',
|
|
14
|
+
component: convert(root)
|
|
15
|
+
}); };
|
|
16
|
+
return { from: from, Extension: Extension };
|
|
17
|
+
}
|
|
18
|
+
exports.createInfernoConverter = createInfernoConverter;
|
|
19
|
+
var _a = createInfernoConverter(), fromInferno = _a.from, InfernoExtension = _a.Extension;
|
|
11
20
|
exports.fromInferno = fromInferno;
|
|
12
|
-
exports.
|
|
21
|
+
exports.InfernoExtension = InfernoExtension;
|
package/esm/converter.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import { ComponentType } from 'inferno';
|
|
3
|
-
export
|
|
1
|
+
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
+
import type { ComponentType } from 'inferno';
|
|
3
|
+
export interface InfernoConverterOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Defines the name of the root element.
|
|
6
|
+
* @default slot
|
|
7
|
+
*/
|
|
8
|
+
rootName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createConverter(config?: InfernoConverterOptions): {
|
|
11
|
+
<TProps extends BaseComponentProps>(root: ComponentType<TProps>): ForeignComponent<TProps>;
|
|
12
|
+
Extension: import("inferno").Component<import("piral-core").ExtensionSlotProps<string>, {}>;
|
|
13
|
+
};
|
package/esm/converter.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { mountInferno, unmountInferno } from './mount';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { createExtension } from './extension';
|
|
3
|
+
export function createConverter(config = {}) {
|
|
4
|
+
const { rootName = 'slot' } = config;
|
|
5
|
+
const Extension = createExtension(rootName);
|
|
6
|
+
const convert = (root) => {
|
|
4
7
|
return {
|
|
5
|
-
mount
|
|
8
|
+
mount(el, props, ctx) {
|
|
6
9
|
mountInferno(el, root, props, ctx);
|
|
7
10
|
},
|
|
8
|
-
update
|
|
11
|
+
update(el, props, ctx) {
|
|
9
12
|
mountInferno(el, root, props, ctx);
|
|
10
13
|
},
|
|
11
|
-
unmount
|
|
14
|
+
unmount(el) {
|
|
12
15
|
unmountInferno(el);
|
|
13
16
|
},
|
|
14
17
|
};
|
|
15
18
|
};
|
|
19
|
+
convert.Extension = Extension;
|
|
16
20
|
return convert;
|
|
17
21
|
}
|
|
18
22
|
//# sourceMappingURL=converter.js.map
|
package/esm/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAEA,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,IAA2B,EAA4B,EAAE;QAC3G,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACrC,CAAC;YACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBACnB,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,EAAE;gBACR,cAAc,CAAC,EAAE,CAAC,CAAC;YACrB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/esm/create.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { PiralPlugin } from 'piral-core';
|
|
2
|
+
import { InfernoConverterOptions } from './converter';
|
|
2
3
|
import type { PiletInfernoApi } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Available configuration options for the Inferno plugin.
|
|
5
6
|
*/
|
|
6
|
-
export interface InfernoConfig {
|
|
7
|
-
/**
|
|
8
|
-
* Defines the name of the root element.
|
|
9
|
-
* @default slot
|
|
10
|
-
*/
|
|
11
|
-
rootName?: string;
|
|
7
|
+
export interface InfernoConfig extends InfernoConverterOptions {
|
|
12
8
|
}
|
|
13
9
|
/**
|
|
14
10
|
* Creates Pilet API extensions for integrating Inferno.
|
package/esm/create.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { createConverter } from './converter';
|
|
2
|
-
import { createExtension } from './extension';
|
|
3
2
|
/**
|
|
4
3
|
* Creates Pilet API extensions for integrating Inferno.
|
|
5
4
|
*/
|
|
6
|
-
export function createInfernoApi(config) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var convert = createConverter();
|
|
11
|
-
context.converters.inferno = function (_a) {
|
|
12
|
-
var root = _a.root;
|
|
13
|
-
return convert(root);
|
|
14
|
-
};
|
|
5
|
+
export function createInfernoApi(config = {}) {
|
|
6
|
+
return (context) => {
|
|
7
|
+
const convert = createConverter(config);
|
|
8
|
+
context.converters.inferno = ({ root }) => convert(root);
|
|
15
9
|
return {
|
|
16
|
-
fromInferno
|
|
10
|
+
fromInferno(root) {
|
|
17
11
|
return {
|
|
18
12
|
type: 'inferno',
|
|
19
|
-
root
|
|
13
|
+
root,
|
|
20
14
|
};
|
|
21
15
|
},
|
|
22
|
-
InfernoExtension:
|
|
16
|
+
InfernoExtension: convert.Extension,
|
|
23
17
|
};
|
|
24
18
|
};
|
|
25
19
|
}
|
package/esm/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA2B,MAAM,aAAa,CAAC;AAQvE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAwB,EAAE;IACzD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO;YACL,WAAW,CAAC,IAAI;gBACd,OAAO;oBACL,IAAI,EAAE,SAAS;oBACf,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,gBAAgB,EAAE,OAAO,CAAC,SAAS;SACpC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/esm/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionSlotProps } from 'piral-core';
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import { Component } from 'inferno';
|
|
3
|
-
export declare function createExtension(rootName
|
|
3
|
+
export declare function createExtension(rootName: string): Component<ExtensionSlotProps>;
|
package/esm/extension.js
CHANGED
|
@@ -1,34 +1,52 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import { compare } from 'piral-core';
|
|
3
1
|
import { Component } from 'inferno';
|
|
4
2
|
import { createElement } from 'inferno-create-element';
|
|
5
3
|
import { anyPropType } from './mount';
|
|
4
|
+
function compareObjects(a, b) {
|
|
5
|
+
for (const i in a) {
|
|
6
|
+
if (!(i in b)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
for (const i in b) {
|
|
11
|
+
if (!compare(a[i], b[i])) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
function compare(a, b) {
|
|
18
|
+
if (a !== b) {
|
|
19
|
+
const ta = typeof a;
|
|
20
|
+
const tb = typeof b;
|
|
21
|
+
if (ta === tb && ta === 'object' && a && b) {
|
|
22
|
+
return compareObjects(a, b);
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
6
28
|
export function createExtension(rootName) {
|
|
7
29
|
var _a;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
13
|
-
_this.onRefChange = function (element) {
|
|
30
|
+
const InfernoExtension = (_a = class extends Component {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.onRefChange = (element) => {
|
|
14
34
|
if (element) {
|
|
15
|
-
|
|
35
|
+
const { piral } = this.context;
|
|
16
36
|
element.innerHTML = '';
|
|
17
|
-
piral.renderHtmlExtension(element,
|
|
37
|
+
piral.renderHtmlExtension(element, this.props);
|
|
18
38
|
}
|
|
19
39
|
};
|
|
20
|
-
return _this;
|
|
21
40
|
}
|
|
22
|
-
|
|
41
|
+
shouldComponentUpdate(nextProps) {
|
|
23
42
|
return !compare(this.props, nextProps);
|
|
24
|
-
}
|
|
25
|
-
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
26
45
|
return createElement(rootName, {
|
|
27
46
|
ref: this.onRefChange,
|
|
28
47
|
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
}(Component)),
|
|
48
|
+
}
|
|
49
|
+
},
|
|
32
50
|
_a.contextTypes = {
|
|
33
51
|
piral: anyPropType,
|
|
34
52
|
},
|
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,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,SAAS,cAAc,CAAC,CAAM,EAAE,CAAM;IACpC,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE;QACjB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;YACb,OAAO,KAAK,CAAC;SACd;KACF;IAED,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE;QACjB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,OAAO,CAAI,CAAI,EAAE,CAAI;IAC5B,IAAI,CAAC,KAAK,CAAC,EAAE;QACX,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;QACpB,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;QAEpB,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,EAAE;YAC1C,OAAO,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC7B;QAED,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB;;IAC9C,MAAM,gBAAgB,SAAQ,KAAM,SAAQ,SAA6B;YAA3C;;gBAKpB,gBAAW,GAAG,CAAC,OAAoB,EAAE,EAAE;oBAC7C,IAAI,OAAO,EAAE;wBACX,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;wBAC/B,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;wBACvB,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;qBAChD;gBACH,CAAC,CAAC;YAWJ,CAAC;YATC,qBAAqB,CAAC,SAA6B;gBACjD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACzC,CAAC;YAED,MAAM;gBACJ,OAAO,aAAa,CAAC,QAAQ,EAAE;oBAC7B,GAAG,EAAE,IAAI,CAAC,WAAW;iBACtB,CAAC,CAAC;YACL,CAAC;SACF;QArBQ,eAAY,GAAG;YACpB,KAAK,EAAE,WAAW;SAClB;WAmBH,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
package/esm/mount.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType } from 'inferno';
|
|
2
|
-
import { BaseComponentProps } from 'piral-core';
|
|
2
|
+
import type { BaseComponentProps } from 'piral-core';
|
|
3
3
|
export declare const anyPropType: () => any;
|
|
4
4
|
export declare function mountInferno<T extends BaseComponentProps>(el: HTMLElement, root: ComponentType<T>, props: T, ctx?: any): void;
|
|
5
5
|
export declare function unmountInferno(el: HTMLElement): void;
|
package/esm/mount.js
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
import { __assign, __extends, __spreadArray } from "tslib";
|
|
2
1
|
import { render, Component } from 'inferno';
|
|
3
2
|
import { createElement } from 'inferno-create-element';
|
|
4
3
|
// tslint:disable-next-line:no-null-keyword
|
|
5
|
-
export
|
|
6
|
-
export function mountInferno(el, root, props, ctx) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__spreadArray(['piral'], Object.keys(ctx)).forEach(function (key) {
|
|
4
|
+
export const anyPropType = () => null;
|
|
5
|
+
export function mountInferno(el, root, props, ctx = {}) {
|
|
6
|
+
const contextTypes = {};
|
|
7
|
+
['piral', ...Object.keys(ctx)].forEach((key) => {
|
|
10
8
|
contextTypes[key] = anyPropType;
|
|
11
9
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
10
|
+
class Provider extends Component {
|
|
11
|
+
getChildContext() {
|
|
12
|
+
return Object.assign({ piral: props.piral }, ctx);
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
return __assign({ piral: props.piral }, ctx);
|
|
19
|
-
};
|
|
20
|
-
Provider.prototype.render = function () {
|
|
14
|
+
render() {
|
|
21
15
|
return this.props.children;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}(Component));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
Provider.childContextTypes = contextTypes;
|
|
26
19
|
render(createElement(Provider, {}, createElement(root, props)), el);
|
|
27
20
|
}
|
|
28
21
|
export function unmountInferno(el) {
|
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":"AAAA,OAAO,EAAE,MAAM,EAAiB,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;AAEtC,MAAM,UAAU,YAAY,CAC1B,EAAe,EACf,IAAsB,EACtB,KAAQ,EACR,MAAW,EAAE;IAEb,MAAM,YAAY,GAAG,EAAE,CAAC;IAExB,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7C,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,QAAS,SAAQ,SAAS;QAG9B,eAAe;YACb,uBACE,KAAK,EAAE,KAAK,CAAC,KAAK,IACf,GAAG,EACN;QACJ,CAAC;QAED,MAAM;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7B,CAAC;;IAXM,0BAAiB,GAAG,YAAY,CAAC;IAc1C,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,EAAE,aAAa,CAAC,IAAW,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAe;IAC5C,2CAA2C;IAC3C,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACnB,CAAC"}
|
package/lib/converter.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import { ComponentType } from 'inferno';
|
|
3
|
-
export
|
|
1
|
+
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
+
import type { ComponentType } from 'inferno';
|
|
3
|
+
export interface InfernoConverterOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Defines the name of the root element.
|
|
6
|
+
* @default slot
|
|
7
|
+
*/
|
|
8
|
+
rootName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createConverter(config?: InfernoConverterOptions): {
|
|
11
|
+
<TProps extends BaseComponentProps>(root: ComponentType<TProps>): ForeignComponent<TProps>;
|
|
12
|
+
Extension: import("inferno").Component<import("piral-core").ExtensionSlotProps<string>, {}>;
|
|
13
|
+
};
|
package/lib/converter.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createConverter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const mount_1 = require("./mount");
|
|
5
|
+
const extension_1 = require("./extension");
|
|
6
|
+
function createConverter(config = {}) {
|
|
7
|
+
const { rootName = 'slot' } = config;
|
|
8
|
+
const Extension = (0, extension_1.createExtension)(rootName);
|
|
9
|
+
const convert = (root) => {
|
|
7
10
|
return {
|
|
8
|
-
mount
|
|
9
|
-
mount_1.mountInferno(el, root, props, ctx);
|
|
11
|
+
mount(el, props, ctx) {
|
|
12
|
+
(0, mount_1.mountInferno)(el, root, props, ctx);
|
|
10
13
|
},
|
|
11
|
-
update
|
|
12
|
-
mount_1.mountInferno(el, root, props, ctx);
|
|
14
|
+
update(el, props, ctx) {
|
|
15
|
+
(0, mount_1.mountInferno)(el, root, props, ctx);
|
|
13
16
|
},
|
|
14
|
-
unmount
|
|
15
|
-
mount_1.unmountInferno(el);
|
|
17
|
+
unmount(el) {
|
|
18
|
+
(0, mount_1.unmountInferno)(el);
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
21
|
};
|
|
22
|
+
convert.Extension = Extension;
|
|
19
23
|
return convert;
|
|
20
24
|
}
|
|
21
25
|
exports.createConverter = createConverter;
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAEA,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,IAA2B,EAA4B,EAAE;QAC3G,OAAO;YACL,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBAClB,IAAA,oBAAY,EAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACrC,CAAC;YACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;gBACnB,IAAA,oBAAY,EAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,EAAE;gBACR,IAAA,sBAAc,EAAC,EAAE,CAAC,CAAC;YACrB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAlBD,0CAkBC"}
|
package/lib/create.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { PiralPlugin } from 'piral-core';
|
|
2
|
+
import { InfernoConverterOptions } from './converter';
|
|
2
3
|
import type { PiletInfernoApi } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Available configuration options for the Inferno plugin.
|
|
5
6
|
*/
|
|
6
|
-
export interface InfernoConfig {
|
|
7
|
-
/**
|
|
8
|
-
* Defines the name of the root element.
|
|
9
|
-
* @default slot
|
|
10
|
-
*/
|
|
11
|
-
rootName?: string;
|
|
7
|
+
export interface InfernoConfig extends InfernoConverterOptions {
|
|
12
8
|
}
|
|
13
9
|
/**
|
|
14
10
|
* Creates Pilet API extensions for integrating Inferno.
|
package/lib/create.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createInfernoApi = void 0;
|
|
4
|
-
|
|
5
|
-
var extension_1 = require("./extension");
|
|
4
|
+
const converter_1 = require("./converter");
|
|
6
5
|
/**
|
|
7
6
|
* Creates Pilet API extensions for integrating Inferno.
|
|
8
7
|
*/
|
|
9
|
-
function createInfernoApi(config) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var convert = converter_1.createConverter();
|
|
14
|
-
context.converters.inferno = function (_a) {
|
|
15
|
-
var root = _a.root;
|
|
16
|
-
return convert(root);
|
|
17
|
-
};
|
|
8
|
+
function createInfernoApi(config = {}) {
|
|
9
|
+
return (context) => {
|
|
10
|
+
const convert = (0, converter_1.createConverter)(config);
|
|
11
|
+
context.converters.inferno = ({ root }) => convert(root);
|
|
18
12
|
return {
|
|
19
|
-
fromInferno
|
|
13
|
+
fromInferno(root) {
|
|
20
14
|
return {
|
|
21
15
|
type: 'inferno',
|
|
22
|
-
root
|
|
16
|
+
root,
|
|
23
17
|
};
|
|
24
18
|
},
|
|
25
|
-
InfernoExtension:
|
|
19
|
+
InfernoExtension: convert.Extension,
|
|
26
20
|
};
|
|
27
21
|
};
|
|
28
22
|
}
|
package/lib/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,2CAAuE;AAQvE;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAAwB,EAAE;IACzD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO;YACL,WAAW,CAAC,IAAI;gBACd,OAAO;oBACL,IAAI,EAAE,SAAS;oBACf,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,gBAAgB,EAAE,OAAO,CAAC,SAAS;SACpC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAfD,4CAeC"}
|
package/lib/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExtensionSlotProps } from 'piral-core';
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import { Component } from 'inferno';
|
|
3
|
-
export declare function createExtension(rootName
|
|
3
|
+
export declare function createExtension(rootName: string): Component<ExtensionSlotProps>;
|
package/lib/extension.js
CHANGED
|
@@ -1,37 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createExtension = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const inferno_1 = require("inferno");
|
|
5
|
+
const inferno_create_element_1 = require("inferno-create-element");
|
|
6
|
+
const mount_1 = require("./mount");
|
|
7
|
+
function compareObjects(a, b) {
|
|
8
|
+
for (const i in a) {
|
|
9
|
+
if (!(i in b)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
for (const i in b) {
|
|
14
|
+
if (!compare(a[i], b[i])) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function compare(a, b) {
|
|
21
|
+
if (a !== b) {
|
|
22
|
+
const ta = typeof a;
|
|
23
|
+
const tb = typeof b;
|
|
24
|
+
if (ta === tb && ta === 'object' && a && b) {
|
|
25
|
+
return compareObjects(a, b);
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
9
31
|
function createExtension(rootName) {
|
|
10
32
|
var _a;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
16
|
-
_this.onRefChange = function (element) {
|
|
33
|
+
const InfernoExtension = (_a = class extends inferno_1.Component {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.onRefChange = (element) => {
|
|
17
37
|
if (element) {
|
|
18
|
-
|
|
38
|
+
const { piral } = this.context;
|
|
19
39
|
element.innerHTML = '';
|
|
20
|
-
piral.renderHtmlExtension(element,
|
|
40
|
+
piral.renderHtmlExtension(element, this.props);
|
|
21
41
|
}
|
|
22
42
|
};
|
|
23
|
-
return _this;
|
|
24
43
|
}
|
|
25
|
-
|
|
26
|
-
return !
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return inferno_create_element_1.createElement(rootName, {
|
|
44
|
+
shouldComponentUpdate(nextProps) {
|
|
45
|
+
return !compare(this.props, nextProps);
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return (0, inferno_create_element_1.createElement)(rootName, {
|
|
30
49
|
ref: this.onRefChange,
|
|
31
50
|
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}(inferno_1.Component)),
|
|
51
|
+
}
|
|
52
|
+
},
|
|
35
53
|
_a.contextTypes = {
|
|
36
54
|
piral: mount_1.anyPropType,
|
|
37
55
|
},
|
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,qCAAoC;AACpC,mEAAuD;AACvD,mCAAsC;AAEtC,SAAS,cAAc,CAAC,CAAM,EAAE,CAAM;IACpC,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE;QACjB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE;YACb,OAAO,KAAK,CAAC;SACd;KACF;IAED,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE;QACjB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,OAAO,CAAI,CAAI,EAAE,CAAI;IAC5B,IAAI,CAAC,KAAK,CAAC,EAAE;QACX,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;QACpB,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;QAEpB,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,EAAE;YAC1C,OAAO,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC7B;QAED,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,eAAe,CAAC,QAAgB;;IAC9C,MAAM,gBAAgB,SAAQ,KAAM,SAAQ,mBAA6B;YAA3C;;gBAKpB,gBAAW,GAAG,CAAC,OAAoB,EAAE,EAAE;oBAC7C,IAAI,OAAO,EAAE;wBACX,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;wBAC/B,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;wBACvB,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;qBAChD;gBACH,CAAC,CAAC;YAWJ,CAAC;YATC,qBAAqB,CAAC,SAA6B;gBACjD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACzC,CAAC;YAED,MAAM;gBACJ,OAAO,IAAA,sCAAa,EAAC,QAAQ,EAAE;oBAC7B,GAAG,EAAE,IAAI,CAAC,WAAW;iBACtB,CAAC,CAAC;YACL,CAAC;SACF;QArBQ,eAAY,GAAG;YACpB,KAAK,EAAE,mBAAW;SAClB;WAmBH,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA1BD,0CA0BC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./create"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./create"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./types"), exports);
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB;AACzB,uDAAwB"}
|
package/lib/mount.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType } from 'inferno';
|
|
2
|
-
import { BaseComponentProps } from 'piral-core';
|
|
2
|
+
import type { BaseComponentProps } from 'piral-core';
|
|
3
3
|
export declare const anyPropType: () => any;
|
|
4
4
|
export declare function mountInferno<T extends BaseComponentProps>(el: HTMLElement, root: ComponentType<T>, props: T, ctx?: any): void;
|
|
5
5
|
export declare function unmountInferno(el: HTMLElement): void;
|
package/lib/mount.js
CHANGED
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unmountInferno = exports.mountInferno = exports.anyPropType = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var inferno_create_element_1 = require("inferno-create-element");
|
|
4
|
+
const inferno_1 = require("inferno");
|
|
5
|
+
const inferno_create_element_1 = require("inferno-create-element");
|
|
7
6
|
// tslint:disable-next-line:no-null-keyword
|
|
8
|
-
|
|
7
|
+
const anyPropType = () => null;
|
|
9
8
|
exports.anyPropType = anyPropType;
|
|
10
|
-
function mountInferno(el, root, props, ctx) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
tslib_1.__spreadArray(['piral'], Object.keys(ctx)).forEach(function (key) {
|
|
9
|
+
function mountInferno(el, root, props, ctx = {}) {
|
|
10
|
+
const contextTypes = {};
|
|
11
|
+
['piral', ...Object.keys(ctx)].forEach((key) => {
|
|
14
12
|
contextTypes[key] = exports.anyPropType;
|
|
15
13
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
14
|
+
class Provider extends inferno_1.Component {
|
|
15
|
+
getChildContext() {
|
|
16
|
+
return Object.assign({ piral: props.piral }, ctx);
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
return tslib_1.__assign({ piral: props.piral }, ctx);
|
|
23
|
-
};
|
|
24
|
-
Provider.prototype.render = function () {
|
|
18
|
+
render() {
|
|
25
19
|
return this.props.children;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
inferno_1.render(inferno_create_element_1.createElement(Provider, {}, inferno_create_element_1.createElement(root, props)), el);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
Provider.childContextTypes = contextTypes;
|
|
23
|
+
(0, inferno_1.render)((0, inferno_create_element_1.createElement)(Provider, {}, (0, inferno_create_element_1.createElement)(root, props)), el);
|
|
31
24
|
}
|
|
32
25
|
exports.mountInferno = mountInferno;
|
|
33
26
|
function unmountInferno(el) {
|
|
34
27
|
// tslint:disable-next-line:no-null-keyword
|
|
35
|
-
inferno_1.render(null, el);
|
|
28
|
+
(0, inferno_1.render)(null, el);
|
|
36
29
|
}
|
|
37
30
|
exports.unmountInferno = unmountInferno;
|
|
38
31
|
//# 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":";;;AAAA,qCAA2D;AAC3D,mEAAuD;AAGvD,2CAA2C;AACpC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;AAAzB,QAAA,WAAW,eAAc;AAEtC,SAAgB,YAAY,CAC1B,EAAe,EACf,IAAsB,EACtB,KAAQ,EACR,MAAW,EAAE;IAEb,MAAM,YAAY,GAAG,EAAE,CAAC;IAExB,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7C,YAAY,CAAC,GAAG,CAAC,GAAG,mBAAW,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,QAAS,SAAQ,mBAAS;QAG9B,eAAe;YACb,uBACE,KAAK,EAAE,KAAK,CAAC,KAAK,IACf,GAAG,EACN;QACJ,CAAC;QAED,MAAM;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC7B,CAAC;;IAXM,0BAAiB,GAAG,YAAY,CAAC;IAc1C,IAAA,gBAAM,EAAC,IAAA,sCAAa,EAAC,QAAQ,EAAE,EAAE,EAAE,IAAA,sCAAa,EAAC,IAAW,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC;AA5BD,oCA4BC;AAED,SAAgB,cAAc,CAAC,EAAe;IAC5C,2CAA2C;IAC3C,IAAA,gBAAM,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACnB,CAAC;AAHD,wCAGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-inferno",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-beta.3156",
|
|
4
4
|
"description": "Plugin for integrating Inferno components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"lib",
|
|
26
26
|
"src",
|
|
27
27
|
"convert.d.ts",
|
|
28
|
-
"convert.ts",
|
|
29
28
|
"convert.js"
|
|
30
29
|
],
|
|
31
30
|
"repository": {
|
|
@@ -46,12 +45,12 @@
|
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"inferno": "^7.3.2",
|
|
48
47
|
"inferno-create-element": "^7.3.2",
|
|
49
|
-
"piral-core": "^0.
|
|
48
|
+
"piral-core": "^0.14.0-beta.3156"
|
|
50
49
|
},
|
|
51
50
|
"peerDependencies": {
|
|
52
51
|
"inferno": "^7.0.0",
|
|
53
52
|
"inferno-create-element": "^7.0.0",
|
|
54
|
-
"piral-core": "0.
|
|
53
|
+
"piral-core": "0.14.x"
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "e368a181defdfca4722d7bd478a9dcd47d90a51b"
|
|
57
56
|
}
|
package/src/converter.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import { ComponentType } from 'inferno';
|
|
1
|
+
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
+
import type { ComponentType } from 'inferno';
|
|
3
3
|
import { mountInferno, unmountInferno } from './mount';
|
|
4
|
+
import { createExtension } from './extension';
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
+
export interface InfernoConverterOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Defines the name of the root element.
|
|
9
|
+
* @default slot
|
|
10
|
+
*/
|
|
11
|
+
rootName?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createConverter(config: InfernoConverterOptions = {}) {
|
|
15
|
+
const { rootName = 'slot' } = config;
|
|
16
|
+
const Extension = createExtension(rootName);
|
|
6
17
|
const convert = <TProps extends BaseComponentProps>(root: ComponentType<TProps>): ForeignComponent<TProps> => {
|
|
7
18
|
return {
|
|
8
19
|
mount(el, props, ctx) {
|
|
@@ -16,5 +27,6 @@ export function createConverter() {
|
|
|
16
27
|
},
|
|
17
28
|
};
|
|
18
29
|
};
|
|
30
|
+
convert.Extension = Extension;
|
|
19
31
|
return convert;
|
|
20
32
|
}
|
package/src/create.ts
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import type { PiralPlugin } from 'piral-core';
|
|
2
|
-
import { createConverter } from './converter';
|
|
3
|
-
import { createExtension } from './extension';
|
|
2
|
+
import { createConverter, InfernoConverterOptions } from './converter';
|
|
4
3
|
import type { PiletInfernoApi } from './types';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Available configuration options for the Inferno plugin.
|
|
8
7
|
*/
|
|
9
|
-
export interface InfernoConfig {
|
|
10
|
-
/**
|
|
11
|
-
* Defines the name of the root element.
|
|
12
|
-
* @default slot
|
|
13
|
-
*/
|
|
14
|
-
rootName?: string;
|
|
15
|
-
}
|
|
8
|
+
export interface InfernoConfig extends InfernoConverterOptions {}
|
|
16
9
|
|
|
17
10
|
/**
|
|
18
11
|
* Creates Pilet API extensions for integrating Inferno.
|
|
19
12
|
*/
|
|
20
13
|
export function createInfernoApi(config: InfernoConfig = {}): PiralPlugin<PiletInfernoApi> {
|
|
21
|
-
const { rootName } = config;
|
|
22
|
-
|
|
23
14
|
return (context) => {
|
|
24
|
-
const convert = createConverter();
|
|
15
|
+
const convert = createConverter(config);
|
|
25
16
|
context.converters.inferno = ({ root }) => convert(root);
|
|
26
17
|
|
|
27
18
|
return {
|
|
@@ -31,7 +22,7 @@ export function createInfernoApi(config: InfernoConfig = {}): PiralPlugin<PiletI
|
|
|
31
22
|
root,
|
|
32
23
|
};
|
|
33
24
|
},
|
|
34
|
-
InfernoExtension:
|
|
25
|
+
InfernoExtension: convert.Extension,
|
|
35
26
|
};
|
|
36
27
|
};
|
|
37
28
|
}
|
package/src/extension.ts
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
|
-
import { ExtensionSlotProps
|
|
1
|
+
import type { ExtensionSlotProps } from 'piral-core';
|
|
2
2
|
import { Component } from 'inferno';
|
|
3
3
|
import { createElement } from 'inferno-create-element';
|
|
4
4
|
import { anyPropType } from './mount';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function compareObjects(a: any, b: any) {
|
|
7
|
+
for (const i in a) {
|
|
8
|
+
if (!(i in b)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
for (const i in b) {
|
|
14
|
+
if (!compare(a[i], b[i])) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function compare<T>(a: T, b: T) {
|
|
23
|
+
if (a !== b) {
|
|
24
|
+
const ta = typeof a;
|
|
25
|
+
const tb = typeof b;
|
|
26
|
+
|
|
27
|
+
if (ta === tb && ta === 'object' && a && b) {
|
|
28
|
+
return compareObjects(a, b);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createExtension(rootName: string): Component<ExtensionSlotProps> {
|
|
7
38
|
const InfernoExtension: any = class extends Component<ExtensionSlotProps> {
|
|
8
39
|
static contextTypes = {
|
|
9
40
|
piral: anyPropType,
|
package/src/mount.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render, ComponentType, Component } from 'inferno';
|
|
2
2
|
import { createElement } from 'inferno-create-element';
|
|
3
|
-
import { BaseComponentProps } from 'piral-core';
|
|
3
|
+
import type { BaseComponentProps } from 'piral-core';
|
|
4
4
|
|
|
5
5
|
// tslint:disable-next-line:no-null-keyword
|
|
6
6
|
export const anyPropType = () => null;
|
package/convert.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { HtmlComponent } from 'piral-core';
|
|
2
|
-
import { createConverter } from './lib/converter';
|
|
3
|
-
import { createExtension } from './lib/extension';
|
|
4
|
-
|
|
5
|
-
const convert = createConverter();
|
|
6
|
-
|
|
7
|
-
export interface InfernoConverter {
|
|
8
|
-
(...params: Parameters<typeof convert>): HtmlComponent<any>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const fromInferno: InfernoConverter = (root) => ({
|
|
12
|
-
type: 'html',
|
|
13
|
-
component: convert(root),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const createInfernoExtension = createExtension;
|