piral-vue-3 1.7.0 → 1.7.1
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/lib/converter.js +10 -4
- package/lib/converter.js.map +1 -1
- package/lib/mount.d.ts +1 -1
- package/lib/mount.js +3 -8
- package/lib/mount.js.map +1 -1
- package/package.json +3 -3
- package/src/converter.ts +11 -6
- package/src/mount.ts +2 -8
package/lib/converter.js
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
|
+
import { reactive } from 'vue';
|
|
1
2
|
import { createExtension } from './extension';
|
|
2
3
|
import { mountVue } from './mount';
|
|
3
4
|
export function createConverter(config = {}) {
|
|
4
5
|
const { rootName = 'piral-slot', selector = 'extension-component' } = config;
|
|
5
6
|
const Extension = createExtension(rootName);
|
|
6
7
|
const middlewares = [];
|
|
7
|
-
const convert = (root, captured) => ({
|
|
8
|
+
const convert = (root, captured = {}) => ({
|
|
8
9
|
mount(parent, data, ctx, locals) {
|
|
9
10
|
const el = parent.appendChild(document.createElement(rootName));
|
|
10
|
-
const
|
|
11
|
+
const props = reactive({
|
|
12
|
+
...captured,
|
|
13
|
+
...data,
|
|
14
|
+
});
|
|
15
|
+
const app = mountVue(root, props, ctx);
|
|
11
16
|
middlewares.forEach((middleware) => middleware(app));
|
|
12
17
|
app.component(selector, createExtension(rootName));
|
|
13
18
|
app.mount(el);
|
|
14
19
|
locals.instance = app;
|
|
20
|
+
locals.props = props;
|
|
15
21
|
},
|
|
16
22
|
update(parent, data, ctx, locals) {
|
|
17
|
-
const appInstance = locals.instance._instance;
|
|
18
23
|
for (const prop in data) {
|
|
19
|
-
|
|
24
|
+
locals.props[prop] = data[prop];
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
unmount(parent, locals) {
|
|
23
28
|
locals.instance.unmount();
|
|
24
29
|
parent.innerHTML = '';
|
|
25
30
|
locals.instance = undefined;
|
|
31
|
+
locals.props = undefined;
|
|
26
32
|
},
|
|
27
33
|
});
|
|
28
34
|
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,OAAO,EAAkB,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAqBnC,MAAM,UAAU,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,QAAQ,GAAG,YAAY,EAAE,QAAQ,GAAG,qBAAqB,EAAE,GAAG,MAAM,CAAC;IAC7E,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAiC,EAAE,CAAC;IACrD,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,WAAgC,EAAE,EACR,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAiB;YACxC,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChE,MAAM,KAAK,GAAG,QAAQ,CAAC;gBACnB,GAAG,QAAQ;gBACX,GAAG,IAAI;aACV,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACvC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YACrD,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACd,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC;YACtB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACvB,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAiB;YACzC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;gBACrB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;aACnC;QACH,CAAC;QACD,OAAO,CAAC,MAAM,EAAE,MAAiB;YAC/B,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC1B,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;YACtB,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;YAC5B,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QAC3B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,CAAC,gBAAgB,GAAG,CAAC,UAAiC,EAAE,EAAE;QAC/D,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACrC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib/mount.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BaseComponentProps, ComponentContext } from 'piral-core';
|
|
2
2
|
import { Component } from 'vue';
|
|
3
|
-
export declare function mountVue<T extends BaseComponentProps>(component: Component<T>, props: T, ctx: ComponentContext
|
|
3
|
+
export declare function mountVue<T extends BaseComponentProps>(component: Component<T>, props: T, ctx: ComponentContext): import("vue").App<Element>;
|
package/lib/mount.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { createApp, h } from 'vue';
|
|
2
|
-
export function mountVue(component, props, ctx
|
|
3
|
-
const data = {
|
|
4
|
-
...captured,
|
|
5
|
-
...props,
|
|
6
|
-
};
|
|
2
|
+
export function mountVue(component, props, ctx) {
|
|
7
3
|
const root = {
|
|
8
4
|
provide: {
|
|
9
5
|
piral: props.piral,
|
|
10
6
|
...ctx,
|
|
11
7
|
},
|
|
12
|
-
props: Object.keys(data),
|
|
13
8
|
render() {
|
|
14
|
-
return h(component,
|
|
9
|
+
return h(component, props);
|
|
15
10
|
},
|
|
16
11
|
};
|
|
17
|
-
return createApp(root
|
|
12
|
+
return createApp(root);
|
|
18
13
|
}
|
|
19
14
|
//# 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":"AACA,OAAO,EAAE,SAAS,EAAa,CAAC,EAAE,MAAM,KAAK,CAAC;AAE9C,MAAM,UAAU,QAAQ,CACtB,SAAuB,EACvB,KAAQ,EACR,GAAqB
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,CAAC,EAAE,MAAM,KAAK,CAAC;AAE9C,MAAM,UAAU,QAAQ,CACtB,SAAuB,EACvB,KAAQ,EACR,GAAqB;IAErB,MAAM,IAAI,GAAc;QACtB,OAAO,EAAE;YACP,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,GAAG;SACP;QACD,MAAM;YACJ,OAAO,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;KACF,CAAC;IAEF,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-vue-3",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Plugin for integrating Vue@3 components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"piral-core": "^1.7.
|
|
57
|
+
"piral-core": "^1.7.1",
|
|
58
58
|
"vue": "^3.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "83508f650da0fbb300642d0e8fcaeddbd904d81b"
|
|
61
61
|
}
|
package/src/converter.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
|
-
import { Component, App } from 'vue';
|
|
2
|
+
import { Component, App, reactive } from 'vue';
|
|
3
3
|
import { createExtension } from './extension';
|
|
4
4
|
import { mountVue } from './mount';
|
|
5
5
|
import { Vue3MiddlewareHandler } from './types';
|
|
@@ -19,6 +19,7 @@ export interface Vue3ConverterOptions {
|
|
|
19
19
|
|
|
20
20
|
interface Vue3State {
|
|
21
21
|
instance: App;
|
|
22
|
+
props: any;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function createConverter(config: Vue3ConverterOptions = {}) {
|
|
@@ -27,27 +28,31 @@ export function createConverter(config: Vue3ConverterOptions = {}) {
|
|
|
27
28
|
const middlewares: Array<Vue3MiddlewareHandler> = [];
|
|
28
29
|
const convert = <TProps extends BaseComponentProps>(
|
|
29
30
|
root: Component<TProps>,
|
|
30
|
-
captured
|
|
31
|
+
captured: Record<string, any> = {},
|
|
31
32
|
): ForeignComponent<TProps> => ({
|
|
32
33
|
mount(parent, data, ctx, locals: Vue3State) {
|
|
33
34
|
const el = parent.appendChild(document.createElement(rootName));
|
|
34
|
-
const
|
|
35
|
+
const props = reactive({
|
|
36
|
+
...captured,
|
|
37
|
+
...data,
|
|
38
|
+
});
|
|
39
|
+
const app = mountVue(root, props, ctx);
|
|
35
40
|
middlewares.forEach((middleware) => middleware(app));
|
|
36
41
|
app.component(selector, createExtension(rootName));
|
|
37
42
|
app.mount(el);
|
|
38
43
|
locals.instance = app;
|
|
44
|
+
locals.props = props;
|
|
39
45
|
},
|
|
40
46
|
update(parent, data, ctx, locals: Vue3State) {
|
|
41
|
-
const appInstance = locals.instance._instance;
|
|
42
|
-
|
|
43
47
|
for (const prop in data) {
|
|
44
|
-
|
|
48
|
+
locals.props[prop] = data[prop];
|
|
45
49
|
}
|
|
46
50
|
},
|
|
47
51
|
unmount(parent, locals: Vue3State) {
|
|
48
52
|
locals.instance.unmount();
|
|
49
53
|
parent.innerHTML = '';
|
|
50
54
|
locals.instance = undefined;
|
|
55
|
+
locals.props = undefined;
|
|
51
56
|
},
|
|
52
57
|
});
|
|
53
58
|
convert.Extension = Extension;
|
package/src/mount.ts
CHANGED
|
@@ -5,22 +5,16 @@ export function mountVue<T extends BaseComponentProps>(
|
|
|
5
5
|
component: Component<T>,
|
|
6
6
|
props: T,
|
|
7
7
|
ctx: ComponentContext,
|
|
8
|
-
captured?: Record<string, any>,
|
|
9
8
|
) {
|
|
10
|
-
const data = {
|
|
11
|
-
...captured,
|
|
12
|
-
...props,
|
|
13
|
-
};
|
|
14
9
|
const root: Component = {
|
|
15
10
|
provide: {
|
|
16
11
|
piral: props.piral,
|
|
17
12
|
...ctx,
|
|
18
13
|
},
|
|
19
|
-
props: Object.keys(data),
|
|
20
14
|
render() {
|
|
21
|
-
return h(component,
|
|
15
|
+
return h(component, props);
|
|
22
16
|
},
|
|
23
17
|
};
|
|
24
18
|
|
|
25
|
-
return createApp(root
|
|
19
|
+
return createApp(root);
|
|
26
20
|
}
|