piral-preact 1.6.0-beta.7240 → 1.6.0-beta.7243
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 +1 -1
- package/convert.js +1 -1
- package/lib/converter.js +7 -11
- package/lib/converter.js.map +1 -1
- package/lib/create.js +3 -7
- package/lib/create.js.map +1 -1
- package/lib/extension.js +6 -10
- package/lib/extension.js.map +1 -1
- package/lib/index.js +2 -5
- package/lib/index.js.map +1 -1
- package/lib/mount.js +8 -14
- package/lib/mount.js.map +1 -1
- package/lib/types.js +1 -2
- package/package.json +9 -25
- package/esm/converter.d.ts +0 -13
- package/esm/converter.js +0 -20
- package/esm/converter.js.map +0 -1
- package/esm/create.d.ts +0 -12
- package/esm/create.js +0 -20
- package/esm/create.js.map +0 -1
- package/esm/extension.d.ts +0 -3
- package/esm/extension.js +0 -53
- package/esm/extension.js.map +0 -1
- package/esm/index.d.ts +0 -2
- package/esm/index.js +0 -3
- package/esm/index.js.map +0 -1
- package/esm/mount.d.ts +0 -5
- package/esm/mount.js +0 -26
- package/esm/mount.js.map +0 -1
- package/esm/types.d.ts +0 -34
- package/esm/types.js +0 -2
- package/esm/types.js.map +0 -1
package/convert.d.ts
CHANGED
package/convert.js
CHANGED
package/lib/converter.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const mount_1 = require("./mount");
|
|
5
|
-
const extension_1 = require("./extension");
|
|
6
|
-
function createConverter(config = {}) {
|
|
1
|
+
import { mountPreact, unmountPreact } from './mount';
|
|
2
|
+
import { createExtension } from './extension';
|
|
3
|
+
export function createConverter(config = {}) {
|
|
7
4
|
const { rootName = 'piral-slot' } = config;
|
|
8
|
-
const Extension =
|
|
5
|
+
const Extension = createExtension(rootName);
|
|
9
6
|
const convert = (root) => ({
|
|
10
7
|
mount(el, props, ctx) {
|
|
11
|
-
|
|
8
|
+
mountPreact(el, root, props, ctx);
|
|
12
9
|
},
|
|
13
10
|
update(el, props, ctx) {
|
|
14
|
-
|
|
11
|
+
mountPreact(el, root, props, ctx);
|
|
15
12
|
},
|
|
16
13
|
unmount(el) {
|
|
17
|
-
|
|
14
|
+
unmountPreact(el);
|
|
18
15
|
},
|
|
19
16
|
});
|
|
20
17
|
convert.Extension = Extension;
|
|
21
18
|
return convert;
|
|
22
19
|
}
|
|
23
|
-
exports.createConverter = createConverter;
|
|
24
20
|
//# sourceMappingURL=converter.js.map
|
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":"AAEA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,MAAM,UAAU,eAAe,CAAC,SAAiC,EAAE;IACjE,MAAM,EAAE,QAAQ,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;IAC3C,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,IAA2B,EAA4B,EAAE,CAAC,CAAC;QAC7G,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YAClB,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YACnB,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,CAAC,EAAE;YACR,aAAa,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib/create.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPreactApi = void 0;
|
|
4
|
-
const converter_1 = require("./converter");
|
|
1
|
+
import { createConverter } from './converter';
|
|
5
2
|
/**
|
|
6
3
|
* Creates new Pilet API extensions for integrating Preact.
|
|
7
4
|
*/
|
|
8
|
-
function createPreactApi(config = {}) {
|
|
5
|
+
export function createPreactApi(config = {}) {
|
|
9
6
|
return (context) => {
|
|
10
|
-
const convert =
|
|
7
|
+
const convert = createConverter(config);
|
|
11
8
|
context.converters.preact = ({ root }) => convert(root);
|
|
12
9
|
return {
|
|
13
10
|
fromPreact(root) {
|
|
@@ -20,5 +17,4 @@ function createPreactApi(config = {}) {
|
|
|
20
17
|
};
|
|
21
18
|
};
|
|
22
19
|
}
|
|
23
|
-
exports.createPreactApi = createPreactApi;
|
|
24
20
|
//# sourceMappingURL=create.js.map
|
package/lib/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAC;AAQtE;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB,EAAE;IACvD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAExD,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,eAAe,EAAE,OAAO,CAAC,SAAS;SACnC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/extension.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createExtension = void 0;
|
|
4
|
-
const preact_1 = require("preact");
|
|
5
|
-
const mount_1 = require("./mount");
|
|
1
|
+
import { Component, createElement } from 'preact';
|
|
2
|
+
import { anyPropType } from './mount';
|
|
6
3
|
function compareObjects(a, b) {
|
|
7
4
|
for (const i in a) {
|
|
8
5
|
if (!(i in b)) {
|
|
@@ -27,8 +24,8 @@ function compare(a, b) {
|
|
|
27
24
|
}
|
|
28
25
|
return true;
|
|
29
26
|
}
|
|
30
|
-
function createExtension(rootName) {
|
|
31
|
-
class PreactExtension extends
|
|
27
|
+
export function createExtension(rootName) {
|
|
28
|
+
class PreactExtension extends Component {
|
|
32
29
|
constructor() {
|
|
33
30
|
super(...arguments);
|
|
34
31
|
this.onRefChange = (element) => setTimeout(() => {
|
|
@@ -43,15 +40,14 @@ function createExtension(rootName) {
|
|
|
43
40
|
return !compare(this.props, nextProps);
|
|
44
41
|
}
|
|
45
42
|
render() {
|
|
46
|
-
return
|
|
43
|
+
return createElement(rootName, {
|
|
47
44
|
ref: this.onRefChange,
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
PreactExtension.contextTypes = {
|
|
52
|
-
piral:
|
|
49
|
+
piral: anyPropType,
|
|
53
50
|
};
|
|
54
51
|
return PreactExtension;
|
|
55
52
|
}
|
|
56
|
-
exports.createExtension = createExtension;
|
|
57
53
|
//# sourceMappingURL=extension.js.map
|
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":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C,EAAE,CAAC,CAAC,CAAC;QAWV,CAAC;QATC,qBAAqB,CAAC,SAA6B;YACjD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC;QAED,MAAM;YACJ,OAAO,aAAa,CAAC,QAAQ,EAAE;gBAC7B,GAAG,EAAE,IAAI,CAAC,WAAW;aACtB,CAAC,CAAC;QACL,CAAC;;IArBM,4BAAY,GAAG;QACpB,KAAK,EAAE,WAAW;KACnB,AAFkB,CAEjB;IAsBJ,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./create"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
1
|
+
export * from './create';
|
|
2
|
+
export * from './types';
|
|
6
3
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/lib/mount.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unmountPreact = exports.mountPreact = exports.anyPropType = void 0;
|
|
4
|
-
const preact_1 = require("preact");
|
|
1
|
+
import { render, createElement, Component } from 'preact';
|
|
5
2
|
// tslint:disable-next-line:no-null-keyword
|
|
6
|
-
const anyPropType = () => null;
|
|
7
|
-
|
|
8
|
-
function mountPreact(el, root, props, ctx = {}) {
|
|
3
|
+
export const anyPropType = () => null;
|
|
4
|
+
export function mountPreact(el, root, props, ctx = {}) {
|
|
9
5
|
const contextTypes = {};
|
|
10
6
|
['piral', ...Object.keys(ctx)].forEach((key) => {
|
|
11
|
-
contextTypes[key] =
|
|
7
|
+
contextTypes[key] = anyPropType;
|
|
12
8
|
});
|
|
13
|
-
class Provider extends
|
|
9
|
+
class Provider extends Component {
|
|
14
10
|
getChildContext() {
|
|
15
11
|
return {
|
|
16
12
|
piral: props.piral,
|
|
@@ -22,11 +18,9 @@ function mountPreact(el, root, props, ctx = {}) {
|
|
|
22
18
|
}
|
|
23
19
|
}
|
|
24
20
|
Provider.childContextTypes = contextTypes;
|
|
25
|
-
|
|
21
|
+
render(createElement(Provider, {}, createElement(root, props)), el);
|
|
26
22
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
(0, preact_1.render)('', el);
|
|
23
|
+
export function unmountPreact(el) {
|
|
24
|
+
render('', el);
|
|
30
25
|
}
|
|
31
|
-
exports.unmountPreact = unmountPreact;
|
|
32
26
|
//# 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,OAAO,EAAE,MAAM,EAAiB,aAAa,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGzE,2CAA2C;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,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,OAAO;gBACL,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,GAAG,GAAG;aACP,CAAC;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,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAe;IAC3C,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACjB,CAAC"}
|
package/lib/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-preact",
|
|
3
|
-
"version": "1.6.0-beta.
|
|
3
|
+
"version": "1.6.0-beta.7243",
|
|
4
4
|
"description": "Plugin for integrating Preact components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -16,32 +16,17 @@
|
|
|
16
16
|
"author": "smapiot",
|
|
17
17
|
"homepage": "https://piral.io",
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"module": "
|
|
19
|
+
"module": "lib/index.js",
|
|
20
20
|
"main": "lib/index.js",
|
|
21
21
|
"typings": "lib/index.d.ts",
|
|
22
22
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
"./convert": {
|
|
28
|
-
"import": "./convert.js"
|
|
29
|
-
},
|
|
30
|
-
"./esm/*": {
|
|
31
|
-
"import": "./esm/*"
|
|
32
|
-
},
|
|
33
|
-
"./lib/*": {
|
|
34
|
-
"require": "./lib/*"
|
|
35
|
-
},
|
|
36
|
-
"./_/*": {
|
|
37
|
-
"import": "./esm/*.js",
|
|
38
|
-
"require": "./lib/*.js"
|
|
39
|
-
},
|
|
23
|
+
".": "./lib/index.js",
|
|
24
|
+
"./convert": "./convert.js",
|
|
25
|
+
"./lib/*": "./lib/*",
|
|
40
26
|
"./package.json": "./package.json"
|
|
41
27
|
},
|
|
42
28
|
"sideEffects": false,
|
|
43
29
|
"files": [
|
|
44
|
-
"esm",
|
|
45
30
|
"lib",
|
|
46
31
|
"src",
|
|
47
32
|
"convert.d.ts",
|
|
@@ -56,16 +41,15 @@
|
|
|
56
41
|
},
|
|
57
42
|
"scripts": {
|
|
58
43
|
"cleanup": "rimraf esm lib convert.d.ts convert.js",
|
|
59
|
-
"build": "yarn build:
|
|
44
|
+
"build": "yarn build:esnext && yarn build:convert",
|
|
60
45
|
"build:convert": "tsc convert.ts --skipLibCheck --declaration --module esnext",
|
|
61
|
-
"build:
|
|
62
|
-
"build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
|
|
46
|
+
"build:esnext": "tsc --project tsconfig.json --outDir lib --module esnext",
|
|
63
47
|
"typedoc": "typedoc --json ../../../docs/types/piral-preact.json src --exclude \"src/**/*.test.*\"",
|
|
64
48
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
65
49
|
},
|
|
66
50
|
"devDependencies": {
|
|
67
|
-
"piral-core": "1.6.0-beta.
|
|
51
|
+
"piral-core": "1.6.0-beta.7243",
|
|
68
52
|
"preact": "^10.5.13"
|
|
69
53
|
},
|
|
70
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "bbb6e4f78c61b6ef753099a5b378ad2708565ce3"
|
|
71
55
|
}
|
package/esm/converter.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ComponentType } from 'preact';
|
|
2
|
-
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
3
|
-
export interface PreactConverterOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Defines the name of the root element.
|
|
6
|
-
* @default piral-slot
|
|
7
|
-
*/
|
|
8
|
-
rootName?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function createConverter(config?: PreactConverterOptions): {
|
|
11
|
-
<TProps extends BaseComponentProps>(root: ComponentType<TProps>): ForeignComponent<TProps>;
|
|
12
|
-
Extension: ComponentType<import("piral-core").ExtensionSlotProps>;
|
|
13
|
-
};
|
package/esm/converter.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { mountPreact, unmountPreact } from './mount';
|
|
2
|
-
import { createExtension } from './extension';
|
|
3
|
-
export function createConverter(config = {}) {
|
|
4
|
-
const { rootName = 'piral-slot' } = config;
|
|
5
|
-
const Extension = createExtension(rootName);
|
|
6
|
-
const convert = (root) => ({
|
|
7
|
-
mount(el, props, ctx) {
|
|
8
|
-
mountPreact(el, root, props, ctx);
|
|
9
|
-
},
|
|
10
|
-
update(el, props, ctx) {
|
|
11
|
-
mountPreact(el, root, props, ctx);
|
|
12
|
-
},
|
|
13
|
-
unmount(el) {
|
|
14
|
-
unmountPreact(el);
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
convert.Extension = Extension;
|
|
18
|
-
return convert;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=converter.js.map
|
package/esm/converter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,MAAM,UAAU,eAAe,CAAC,SAAiC,EAAE;IACjE,MAAM,EAAE,QAAQ,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;IAC3C,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,IAA2B,EAA4B,EAAE,CAAC,CAAC;QAC7G,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YAClB,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG;YACnB,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,CAAC,EAAE;YACR,aAAa,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/esm/create.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { PiralPlugin } from 'piral-core';
|
|
2
|
-
import { PreactConverterOptions } from './converter';
|
|
3
|
-
import type { PiletPreactApi } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Available configuration options for the Preact plugin.
|
|
6
|
-
*/
|
|
7
|
-
export interface PreactConfig extends PreactConverterOptions {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Creates new Pilet API extensions for integrating Preact.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createPreactApi(config?: PreactConfig): PiralPlugin<PiletPreactApi>;
|
package/esm/create.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createConverter } from './converter';
|
|
2
|
-
/**
|
|
3
|
-
* Creates new Pilet API extensions for integrating Preact.
|
|
4
|
-
*/
|
|
5
|
-
export function createPreactApi(config = {}) {
|
|
6
|
-
return (context) => {
|
|
7
|
-
const convert = createConverter(config);
|
|
8
|
-
context.converters.preact = ({ root }) => convert(root);
|
|
9
|
-
return {
|
|
10
|
-
fromPreact(root) {
|
|
11
|
-
return {
|
|
12
|
-
type: 'preact',
|
|
13
|
-
root,
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
PreactExtension: convert.Extension,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=create.js.map
|
package/esm/create.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAC;AAQtE;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB,EAAE;IACvD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAExD,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,IAAI;iBACL,CAAC;YACJ,CAAC;YACD,eAAe,EAAE,OAAO,CAAC,SAAS;SACnC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/esm/extension.d.ts
DELETED
package/esm/extension.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Component, createElement } from 'preact';
|
|
2
|
-
import { anyPropType } from './mount';
|
|
3
|
-
function compareObjects(a, b) {
|
|
4
|
-
for (const i in a) {
|
|
5
|
-
if (!(i in b)) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
for (const i in b) {
|
|
10
|
-
if (!compare(a[i], b[i])) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
function compare(a, b) {
|
|
17
|
-
if (a !== b) {
|
|
18
|
-
const ta = typeof a;
|
|
19
|
-
const tb = typeof b;
|
|
20
|
-
if (ta === tb && ta === 'object' && a && b) {
|
|
21
|
-
return compareObjects(a, b);
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
export function createExtension(rootName) {
|
|
28
|
-
class PreactExtension extends Component {
|
|
29
|
-
constructor() {
|
|
30
|
-
super(...arguments);
|
|
31
|
-
this.onRefChange = (element) => setTimeout(() => {
|
|
32
|
-
if (element) {
|
|
33
|
-
const { piral } = this.context;
|
|
34
|
-
element.innerHTML = '';
|
|
35
|
-
piral.renderHtmlExtension(element, this.props);
|
|
36
|
-
}
|
|
37
|
-
}, 0);
|
|
38
|
-
}
|
|
39
|
-
shouldComponentUpdate(nextProps) {
|
|
40
|
-
return !compare(this.props, nextProps);
|
|
41
|
-
}
|
|
42
|
-
render() {
|
|
43
|
-
return createElement(rootName, {
|
|
44
|
-
ref: this.onRefChange,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
PreactExtension.contextTypes = {
|
|
49
|
-
piral: anyPropType,
|
|
50
|
-
};
|
|
51
|
-
return PreactExtension;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=extension.js.map
|
package/esm/extension.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAiB,MAAM,QAAQ,CAAC;AACjE,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;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 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/esm/mount.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from 'preact';
|
|
2
|
-
import type { BaseComponentProps } from 'piral-core';
|
|
3
|
-
export declare const anyPropType: () => any;
|
|
4
|
-
export declare function mountPreact<T extends BaseComponentProps>(el: HTMLElement, root: ComponentType<T>, props: T, ctx?: any): void;
|
|
5
|
-
export declare function unmountPreact(el: HTMLElement): void;
|
package/esm/mount.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { render, createElement, Component } from 'preact';
|
|
2
|
-
// tslint:disable-next-line:no-null-keyword
|
|
3
|
-
export const anyPropType = () => null;
|
|
4
|
-
export function mountPreact(el, root, props, ctx = {}) {
|
|
5
|
-
const contextTypes = {};
|
|
6
|
-
['piral', ...Object.keys(ctx)].forEach((key) => {
|
|
7
|
-
contextTypes[key] = anyPropType;
|
|
8
|
-
});
|
|
9
|
-
class Provider extends Component {
|
|
10
|
-
getChildContext() {
|
|
11
|
-
return {
|
|
12
|
-
piral: props.piral,
|
|
13
|
-
...ctx,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
render() {
|
|
17
|
-
return this.props.children;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
Provider.childContextTypes = contextTypes;
|
|
21
|
-
render(createElement(Provider, {}, createElement(root, props)), el);
|
|
22
|
-
}
|
|
23
|
-
export function unmountPreact(el) {
|
|
24
|
-
render('', el);
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=mount.js.map
|
package/esm/mount.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,aAAa,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGzE,2CAA2C;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,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,OAAO;gBACL,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,GAAG,GAAG;aACP,CAAC;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,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAe;IAC3C,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACjB,CAAC"}
|
package/esm/types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
|
|
2
|
-
import type { ComponentType } from 'preact';
|
|
3
|
-
declare module 'piral-core/lib/types/custom' {
|
|
4
|
-
interface PiletCustomApi extends PiletPreactApi {
|
|
5
|
-
}
|
|
6
|
-
interface PiralCustomComponentConverters<TProps> {
|
|
7
|
-
preact(component: PreactComponent<TProps>): ForeignComponent<TProps>;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export interface PreactComponent<TProps> {
|
|
11
|
-
/**
|
|
12
|
-
* The component root.
|
|
13
|
-
*/
|
|
14
|
-
root: ComponentType<TProps>;
|
|
15
|
-
/**
|
|
16
|
-
* The type of the Preact component.
|
|
17
|
-
*/
|
|
18
|
-
type: 'preact';
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Defines the provided set of Preact Pilet API extensions.
|
|
22
|
-
*/
|
|
23
|
-
export interface PiletPreactApi {
|
|
24
|
-
/**
|
|
25
|
-
* Wraps an Preact component for use in Piral.
|
|
26
|
-
* @param component The component root.
|
|
27
|
-
* @returns The Piral Preact component.
|
|
28
|
-
*/
|
|
29
|
-
fromPreact<TProps>(component: ComponentType<TProps>): PreactComponent<TProps>;
|
|
30
|
-
/**
|
|
31
|
-
* Preact component for displaying extensions of the given name.
|
|
32
|
-
*/
|
|
33
|
-
PreactExtension: ComponentType<ExtensionSlotProps>;
|
|
34
|
-
}
|
package/esm/types.js
DELETED
package/esm/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|