piral-svelte 0.15.0-alpha.3809 → 0.15.0-alpha.3933
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 +1 -1
- package/esm/converter.js +18 -21
- package/esm/converter.js.map +1 -1
- package/lib/converter.js +18 -21
- package/lib/converter.js.map +1 -1
- package/package.json +3 -6
- package/src/converter.ts +26 -26
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# [Piral Svelte](https://piral.io) · [](https://github.com/smapiot/piral/blob/main/LICENSE) [](https://www.npmjs.com/package/piral-svelte) [](https://jestjs.io) [](https://gitter.im/piral-io/community)
|
|
4
4
|
|
|
5
|
-
This is a plugin that
|
|
5
|
+
This is a plugin that has no peer dependencies. What `piral-svelte` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
|
|
6
6
|
|
|
7
7
|
The set includes a Svelte converter for any component registration, as well as a `fromSvelte` shortcut together with a `svelte-extension` web component.
|
|
8
8
|
|
package/esm/converter.js
CHANGED
|
@@ -2,27 +2,24 @@ import { createExtension } from './extension';
|
|
|
2
2
|
export function createConverter(config = {}) {
|
|
3
3
|
const { selector = 'svelte-extension' } = config;
|
|
4
4
|
const Extension = createExtension(selector);
|
|
5
|
-
const convert = (Component, captured) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|
|
5
|
+
const convert = (Component, captured) => ({
|
|
6
|
+
mount(parent, data, ctx, locals) {
|
|
7
|
+
locals.instance = new Component({
|
|
8
|
+
target: parent,
|
|
9
|
+
props: Object.assign(Object.assign(Object.assign({}, captured), ctx), data),
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
update(el, data, ctx, locals) {
|
|
13
|
+
Object.keys(data).forEach((key) => {
|
|
14
|
+
locals.instance[key] = data[key];
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
unmount(el, locals) {
|
|
18
|
+
locals.instance.$destroy();
|
|
19
|
+
locals.instance = undefined;
|
|
20
|
+
el.innerHTML = '';
|
|
21
|
+
},
|
|
22
|
+
});
|
|
26
23
|
convert.Extension = Extension;
|
|
27
24
|
return convert;
|
|
28
25
|
}
|
package/esm/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAe9C,MAAM,UAAU,eAAe,CAAC,SAAiC,EAAE;IACjE,MAAM,EAAE,QAAQ,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IACjD,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,SAA+B,EAC/B,QAA8B,EACJ,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAmB;YAC1C,MAAM,CAAC,QAAQ,GAAG,IAAI,SAAS,CAAC;gBAC9B,MAAM,EAAE,MAAM;gBACd,KAAK,gDACA,QAAQ,GACR,GAAG,GACH,IAAI,CACR;aACF,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAmB;YACvC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAChC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAmB;YAC7B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC3B,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;YAC5B,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib/converter.js
CHANGED
|
@@ -5,27 +5,24 @@ const extension_1 = require("./extension");
|
|
|
5
5
|
function createConverter(config = {}) {
|
|
6
6
|
const { selector = 'svelte-extension' } = config;
|
|
7
7
|
const Extension = (0, extension_1.createExtension)(selector);
|
|
8
|
-
const convert = (Component, captured) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
};
|
|
8
|
+
const convert = (Component, captured) => ({
|
|
9
|
+
mount(parent, data, ctx, locals) {
|
|
10
|
+
locals.instance = new Component({
|
|
11
|
+
target: parent,
|
|
12
|
+
props: Object.assign(Object.assign(Object.assign({}, captured), ctx), data),
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
update(el, data, ctx, locals) {
|
|
16
|
+
Object.keys(data).forEach((key) => {
|
|
17
|
+
locals.instance[key] = data[key];
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
unmount(el, locals) {
|
|
21
|
+
locals.instance.$destroy();
|
|
22
|
+
locals.instance = undefined;
|
|
23
|
+
el.innerHTML = '';
|
|
24
|
+
},
|
|
25
|
+
});
|
|
29
26
|
convert.Extension = Extension;
|
|
30
27
|
return convert;
|
|
31
28
|
}
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,2CAA8C;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAe9C,SAAgB,eAAe,CAAC,SAAiC,EAAE;IACjE,MAAM,EAAE,QAAQ,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IACjD,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CACd,SAA+B,EAC/B,QAA8B,EACJ,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAmB;YAC1C,MAAM,CAAC,QAAQ,GAAG,IAAI,SAAS,CAAC;gBAC9B,MAAM,EAAE,MAAM;gBACd,KAAK,gDACA,QAAQ,GACR,GAAG,GACH,IAAI,CACR;aACF,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAmB;YACvC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAChC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAmB;YAC7B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC3B,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;YAC5B,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AA9BD,0CA8BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-svelte",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.3933",
|
|
4
4
|
"description": "Plugin for integrating Svelte components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -45,10 +45,7 @@
|
|
|
45
45
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"piral-core": "0.15.0-alpha.
|
|
48
|
+
"piral-core": "0.15.0-alpha.3933"
|
|
49
49
|
},
|
|
50
|
-
"
|
|
51
|
-
"piral-core": "0.14.x"
|
|
52
|
-
},
|
|
53
|
-
"gitHead": "e26067cdcbbe90ff72d1d0815929655c05126e3a"
|
|
50
|
+
"gitHead": "520a272d09f02543153f1d8b2ae23a3ae10acd6f"
|
|
54
51
|
}
|
package/src/converter.ts
CHANGED
|
@@ -10,38 +10,38 @@ export interface SvelteConverterOptions {
|
|
|
10
10
|
selector?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface SvelteState {
|
|
14
|
+
instance: SvelteComponentInstance<any>;
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
export function createConverter(config: SvelteConverterOptions = {}) {
|
|
14
18
|
const { selector = 'svelte-extension' } = config;
|
|
15
19
|
const Extension = createExtension(selector);
|
|
16
20
|
const convert = <TProps extends BaseComponentProps>(
|
|
17
21
|
Component: SvelteModule<TProps>,
|
|
18
22
|
captured?: Record<string, any>,
|
|
19
|
-
): ForeignComponent<TProps> => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
el.innerHTML = '';
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
};
|
|
23
|
+
): ForeignComponent<TProps> => ({
|
|
24
|
+
mount(parent, data, ctx, locals: SvelteState) {
|
|
25
|
+
locals.instance = new Component({
|
|
26
|
+
target: parent,
|
|
27
|
+
props: {
|
|
28
|
+
...captured,
|
|
29
|
+
...ctx,
|
|
30
|
+
...data,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
update(el, data, ctx, locals: SvelteState) {
|
|
35
|
+
Object.keys(data).forEach((key) => {
|
|
36
|
+
locals.instance[key] = data[key];
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
unmount(el, locals: SvelteState) {
|
|
40
|
+
locals.instance.$destroy();
|
|
41
|
+
locals.instance = undefined;
|
|
42
|
+
el.innerHTML = '';
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
45
|
convert.Extension = Extension;
|
|
46
46
|
return convert;
|
|
47
47
|
}
|