piral-vue 1.0.0-pre.2296 → 1.0.1-beta.5640

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 - 2021 smapiot
3
+ Copyright (c) 2019 - 2023 smapiot
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- [![Piral Logo](https://github.com/smapiot/piral/raw/master/docs/assets/logo.png)](https://piral.io)
1
+ [![Piral Logo](https://github.com/smapiot/piral/raw/main/docs/assets/logo.png)](https://piral.io)
2
2
 
3
- # [Piral Vue](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-vue.svg?style=flat)](https://www.npmjs.com/package/piral-vue) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
3
+ # [Piral Vue](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-vue.svg?style=flat)](https://www.npmjs.com/package/piral-vue) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
4
4
 
5
- This is a plugin that only has a peer dependency to `piral-core`. What `piral-vue` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
5
+ This is a plugin that only has a peer dependency to `vue`. What `piral-vue` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
6
6
 
7
- The set includes a Vue converter for any component registration, as well as a `fromVue` shortcut and a `VueExtension` component.
7
+ The set includes a Vue@2 converter for any component registration, as well as a `fromVue` shortcut and a `VueExtension` component.
8
8
 
9
9
  By default, these API extensions are not integrated in `piral`, so you'd need to add them to your Piral instance.
10
10
 
@@ -14,17 +14,17 @@ The following functions are brought to the Pilet API.
14
14
 
15
15
  ### `fromVue()`
16
16
 
17
- Transforms a standard Vue component into a component that can be used in Piral, essentially wrapping it with a reference to the corresponding converter.
17
+ Transforms a standard Vue@2 component into a component that can be used in Piral, essentially wrapping it with a reference to the corresponding converter.
18
18
 
19
19
  ### `VueExtension`
20
20
 
21
- The extension slot component to be used in Vue components. This is not really needed, as it is made available automatically via a Vue custom element named `extension-component`.
21
+ The extension slot component to be used in Vue@2 components. This is not really needed, as it is made available automatically via a Vue@2 custom element named `extension-component`.
22
22
 
23
23
  ## Usage
24
24
 
25
25
  ::: summary: For pilet authors
26
26
 
27
- You can use the `fromVue` function from the Pilet API to convert your Vue components to components usable by your Piral instance.
27
+ You can use the `fromVue` function from the Pilet API to convert your Vue@2 components to components usable by your Piral instance.
28
28
 
29
29
  Example use:
30
30
 
@@ -37,7 +37,7 @@ export function setup(piral: PiletApi) {
37
37
  }
38
38
  ```
39
39
 
40
- Within Vue components the Piral Vue extension component can be used by referring to `extension-component`, e.g.,
40
+ Within Vue@2 components the Piral Vue@2 extension component can be used by referring to `extension-component`, e.g.,
41
41
 
42
42
  ```html
43
43
  <extension-component name="name-of-extension"></extension-component>
@@ -47,7 +47,7 @@ Alternatively, if `piral-vue` has not been added to the Piral instance you can i
47
47
 
48
48
  ```ts
49
49
  import { PiletApi } from '<name-of-piral-instance>';
50
- import { fromVue } from 'piral-vue';
50
+ import { fromVue } from 'piral-vue/convert';
51
51
  import VuePage from './Page.vue';
52
52
 
53
53
  export function setup(piral: PiletApi) {
@@ -59,10 +59,9 @@ export function setup(piral: PiletApi) {
59
59
 
60
60
  ::: summary: For Piral instance developers
61
61
 
62
- Using Vue with Piral is as simple as installing `piral-vue` and `vue`.
62
+ Using Vue with Piral is as simple as installing `piral-vue` and `vue@^2`.
63
63
 
64
64
  ```ts
65
- import 'vue';
66
65
  import { createVueApi } from 'piral-vue';
67
66
  ```
68
67
 
@@ -80,16 +79,75 @@ The `vue` package should be shared with the pilets via the *package.json*:
80
79
 
81
80
  ```json
82
81
  {
83
- "pilets": {
84
- "externals": [
85
- "vue"
86
- ]
82
+ "importmap": {
83
+ "imports": {
84
+ "vue": ""
85
+ }
87
86
  }
88
87
  }
89
88
  ```
90
89
 
91
90
  :::
92
91
 
92
+ ## Development Setup
93
+
94
+ For your bundler additional packages may be necessary. For instance, for Webpack the following setup is required:
95
+
96
+ First, install the additional dev dependencies
97
+
98
+ ```sh
99
+ npm i vue-loader@^15 @vue/compiler-sfc@^2 --save-dev
100
+ ```
101
+
102
+ then add a *webpack.config.js* to use them
103
+
104
+ ```js
105
+ const { VueLoaderPlugin } = require('vue-loader');
106
+
107
+ module.exports = function (config) {
108
+ config.module.rules.unshift({
109
+ test: /\.vue$/,
110
+ use: 'vue-loader'
111
+ });
112
+ config.plugins.push(new VueLoaderPlugin());
113
+ return config;
114
+ };
115
+ ```
116
+
117
+ Now, *.vue* files are correctly picked up and handled.
118
+
119
+ Alternatively, the Webpack configuration can be rather simplistic. In many cases you can use the convenience `extend-webpack` module.
120
+
121
+ This is how your *webpack.config.js* can look like with the convenience module:
122
+
123
+ ```js
124
+ const extendWebpack = require('piral-vue/extend-webpack');
125
+
126
+ module.exports = extendWebpack({});
127
+ ```
128
+
129
+ For using `piral-vue/extend-webpack` you must have installed:
130
+
131
+ - `vue-loader` (at version 15)
132
+ - `@vue/compiler-sfc^2`
133
+ - `webpack`, e.g., via `piral-cli-webpack5`
134
+
135
+ You can do that via:
136
+
137
+ ```sh
138
+ npm i vue-loader@^15 @vue/compiler-sfc^2 piral-cli-webpack5 --save-dev
139
+ ```
140
+
141
+ The available options for `piral-vue/extend-webpack` are the same as for the options of the `vue-loader`, e.g.:
142
+
143
+ ```js
144
+ const extendWebpack = require('piral-vue/extend-webpack');
145
+
146
+ module.exports = extendWebpack({
147
+ customElement: /\.ce\.vue$/,
148
+ });
149
+ ```
150
+
93
151
  ## License
94
152
 
95
153
  Piral is released using the MIT license. For more information see the [license file](./LICENSE).
package/convert.d.ts CHANGED
@@ -1,9 +1,18 @@
1
- import type { HtmlComponent } from 'piral-core';
2
- import { createExtension } from './lib/extension';
3
- declare const convert: <TProps extends import("piral-core").BaseComponentProps>(root: import("vue").Component<TProps, import("vue/types/options").DefaultMethods<never>, import("vue/types/options").DefaultComputed, Record<string, any>>, captured?: Record<string, any>) => import("piral-core").ForeignComponent<TProps>;
1
+ import { createConverter } from './esm/converter';
2
+ export interface HtmlComponent<TProps> {
3
+ component: {
4
+ mount(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
5
+ update?(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
6
+ unmount?(element: HTMLElement, locals: any): void;
7
+ };
8
+ type: 'html';
9
+ }
4
10
  export interface VueConverter {
5
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
11
+ (...params: Parameters<ReturnType<typeof createConverter>>): HtmlComponent<any>;
6
12
  }
7
- export declare const fromVue: VueConverter;
8
- export declare const createVueExtension: typeof createExtension;
9
- export {};
13
+ export declare function createVueConverter(...params: Parameters<typeof createConverter>): {
14
+ from: VueConverter;
15
+ Extension: Component<any>;
16
+ };
17
+ declare const fromVue: VueConverter, VueExtension: Component<any>;
18
+ export { fromVue, VueExtension };
package/convert.js CHANGED
@@ -1,11 +1,16 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.createVueExtension = exports.fromVue = void 0;
4
- var converter_1 = require("./lib/converter");
5
- var extension_1 = require("./lib/extension");
6
- var convert = converter_1.createConverter();
7
- exports.fromVue = function (root, captured) { return ({
8
- type: 'html',
9
- component: convert(root, captured)
10
- }); };
11
- exports.createVueExtension = extension_1.createExtension;
1
+ import { createConverter } from './esm/converter';
2
+ export function createVueConverter() {
3
+ var params = [];
4
+ for (var _i = 0; _i < arguments.length; _i++) {
5
+ params[_i] = arguments[_i];
6
+ }
7
+ var convert = createConverter.apply(void 0, params);
8
+ var Extension = convert.Extension;
9
+ var from = function (root, captured) { return ({
10
+ type: 'html',
11
+ component: convert(root, captured),
12
+ }); };
13
+ return { from: from, Extension: Extension };
14
+ }
15
+ var _a = createVueConverter(), fromVue = _a.from, VueExtension = _a.Extension;
16
+ export { fromVue, VueExtension };
@@ -1,3 +1,18 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
2
  import { Component } from 'vue';
3
- export declare function createConverter(rootName?: string): <TProps extends BaseComponentProps>(root: Component<TProps, import("vue/types/options").DefaultMethods<never>, import("vue/types/options").DefaultComputed, Record<string, any>>, captured?: Record<string, any>) => ForeignComponent<TProps>;
3
+ export interface VueConverterOptions {
4
+ /**
5
+ * Defines the name of the extension component.
6
+ * @default extension-component
7
+ */
8
+ selector?: string;
9
+ /**
10
+ * Defines the name of the root element.
11
+ * @default piral-slot
12
+ */
13
+ rootName?: string;
14
+ }
15
+ export declare function createConverter(config?: VueConverterOptions): {
16
+ <TProps extends BaseComponentProps>(root: Component<TProps>, captured?: Record<string, any>): ForeignComponent<TProps>;
17
+ Extension: Component<import("piral-core").ExtensionSlotProps>;
18
+ };
package/esm/converter.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { mountVue } from './mount';
2
- export function createConverter(rootName) {
3
- if (rootName === void 0) { rootName = 'slot'; }
4
- var convert = function (root, captured) {
5
- var instance = undefined;
6
- return {
7
- mount: function (parent, data, ctx) {
8
- var el = parent.appendChild(document.createElement(rootName));
9
- instance = mountVue(el, root, data, ctx, captured);
10
- },
11
- update: function (_, data) {
12
- for (var prop in data) {
13
- instance[prop] = data[prop];
14
- }
15
- },
16
- unmount: function (el) {
17
- instance.$destroy();
18
- el.innerHTML = '';
19
- instance = undefined;
20
- },
21
- };
22
- };
2
+ import { createExtension } from './extension';
3
+ export function createConverter(config = {}) {
4
+ const { rootName = 'piral-slot', selector = 'extension-component' } = config;
5
+ const Extension = createExtension(rootName, selector);
6
+ const convert = (root, captured) => ({
7
+ mount(parent, data, ctx, locals) {
8
+ const el = parent.appendChild(document.createElement(rootName));
9
+ locals.instance = mountVue(el, root, data, ctx, captured);
10
+ },
11
+ update(parent, data, ctx, locals) {
12
+ for (const prop in data) {
13
+ locals.instance[prop] = data[prop];
14
+ }
15
+ },
16
+ unmount(parent, locals) {
17
+ locals.instance.$destroy();
18
+ parent.innerHTML = '';
19
+ locals.instance = undefined;
20
+ },
21
+ });
22
+ convert.Extension = Extension;
23
23
  return convert;
24
24
  }
25
25
  //# sourceMappingURL=converter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,UAAU,eAAe,CAAC,QAAiB;IAAjB,yBAAA,EAAA,iBAAiB;IAC/C,IAAM,OAAO,GAAG,UACd,IAAuB,EACvB,QAA8B;QAE9B,IAAI,QAAQ,GAAQ,SAAS,CAAC;QAE9B,OAAO;YACL,KAAK,YAAC,MAAM,EAAE,IAAI,EAAE,GAAG;gBACrB,IAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAChE,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,YAAC,CAAC,EAAE,IAAI;gBACZ,KAAK,IAAM,IAAI,IAAI,IAAI,EAAE;oBACvB,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7B;YACH,CAAC;YACD,OAAO,YAAC,EAAE;gBACR,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACpB,E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G,SAAS,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/esm/create.d.ts CHANGED
@@ -1,19 +1,9 @@
1
- import { PiralPlugin } from 'piral-core';
2
- import { PiletVueApi } from './types';
1
+ import type { PiralPlugin } from 'piral-core';
2
+ import type { PiletVueApi } from './types';
3
3
  /**
4
4
  * Available configuration options for the Vue plugin.
5
5
  */
6
6
  export interface VueConfig {
7
- /**
8
- * Defines the name of the extension component.
9
- * @default extension-component
10
- */
11
- selector?: string;
12
- /**
13
- * Defines the name of the root element.
14
- * @default slot
15
- */
16
- rootName?: string;
17
7
  }
18
8
  /**
19
9
  * Creates new Pilet API extensions for integration of Vue.
package/esm/create.js CHANGED
@@ -1,26 +1,20 @@
1
1
  import { createConverter } from './converter';
2
- import { createExtension } from './extension';
3
2
  /**
4
3
  * Creates new Pilet API extensions for integration of Vue.
5
4
  */
6
- export function createVueApi(config) {
7
- if (config === void 0) { config = {}; }
8
- var rootName = config.rootName, selector = config.selector;
9
- return function (context) {
10
- var convert = createConverter(rootName);
11
- context.converters.vue = function (_a) {
12
- var root = _a.root, captured = _a.captured;
13
- return convert(root, captured);
14
- };
5
+ export function createVueApi(config = {}) {
6
+ return (context) => {
7
+ const convert = createConverter(config);
8
+ context.converters.vue = ({ root, captured }) => convert(root, captured);
15
9
  return {
16
- fromVue: function (root, captured) {
10
+ fromVue(root, captured) {
17
11
  return {
18
12
  type: 'vue',
19
- root: root,
20
- captured: captured,
13
+ root,
14
+ captured,
21
15
  };
22
16
  },
23
- VueExtension: createExtension(rootName, selector),
17
+ VueExtension: convert.Extension,
24
18
  };
25
19
  };
26
20
  }
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,EAAE,MAAM,aAAa,CAAC;AAE9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YAAY,EAAE,OAAO,CAAC,SAAS;SAChC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import type { ExtensionSlotProps } from 'piral-core';
2
2
  import type { Component } from 'vue';
3
- export declare function createExtension(rootName?: string, selector?: string): Component<ExtensionSlotProps>;
3
+ export declare function createExtension(rootName: string, selector: string): Component<ExtensionSlotProps>;
package/esm/extension.js CHANGED
@@ -1,15 +1,42 @@
1
1
  import { register } from './mount';
2
2
  export function createExtension(rootName, selector) {
3
- if (rootName === void 0) { rootName = 'slot'; }
4
- if (selector === void 0) { selector = 'extension-component'; }
5
- var VueExtension = {
3
+ const VueExtension = {
6
4
  functional: false,
7
5
  props: ['name', 'empty', 'render', 'params'],
8
6
  inject: ['piral'],
9
- render: function (createElement) {
7
+ render(createElement) {
10
8
  return createElement(rootName);
11
9
  },
12
- mounted: function () {
10
+ watch: {
11
+ params(newValue, oldValue) {
12
+ if (newValue !== oldValue) {
13
+ const newKeys = Object.keys(newValue);
14
+ const oldKeys = Object.keys(oldValue);
15
+ if (newKeys.length === oldKeys.length) {
16
+ let changed = false;
17
+ for (const key of newKeys) {
18
+ if (!oldKeys.includes(key) || newValue[key] !== oldValue[key]) {
19
+ changed = true;
20
+ break;
21
+ }
22
+ }
23
+ if (!changed) {
24
+ return;
25
+ }
26
+ }
27
+ const ev = new CustomEvent('extension-props-changed', {
28
+ detail: {
29
+ empty: this.empty,
30
+ params: newValue,
31
+ render: this.render,
32
+ name: this.name,
33
+ },
34
+ });
35
+ this.$el.dispatchEvent(ev);
36
+ }
37
+ },
38
+ },
39
+ mounted() {
13
40
  this.piral.renderHtmlExtension(this.$el, {
14
41
  empty: this.empty,
15
42
  params: this.params,
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,UAAU,eAAe,CAAC,QAAi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+ import type { BaseComponentProps, ComponentContext } from 'piral-core';
3
3
  export declare function register<T>(name: string, component: Vue.Component<T>): void;
4
- export declare function mountVue<T extends BaseComponentProps>(el: HTMLElement, root: Vue.Component<T>, props: T, ctx: ComponentContext, captured?: Record<string, any>): import("vue/types/vue").CombinedVueInstance<Vue, object, object, object, Record<never, any>>;
4
+ export declare function mountVue<T extends BaseComponentProps>(el: HTMLElement, root: Vue.Component<T>, props: T, ctx: ComponentContext, captured?: Record<string, any>): import("vue/types/vue").CombinedVueInstance<Vue, object, object, object, Record<never, any>, {}>;
package/esm/mount.js CHANGED
@@ -1,15 +1,14 @@
1
- import { __assign } from "tslib";
2
1
  import Vue from 'vue';
3
2
  export function register(name, component) {
4
3
  Vue.component(name, component);
5
4
  }
6
5
  export function mountVue(el, root, props, ctx, captured) {
7
6
  return new Vue({
8
- el: el,
9
- provide: __assign({ piral: props.piral }, ctx),
10
- render: function (h) {
7
+ el,
8
+ provide: Object.assign({ piral: props.piral }, ctx),
9
+ render(h) {
11
10
  return h(root, {
12
- props: __assign(__assign({}, captured), props),
11
+ props: Object.assign(Object.assign({}, captured), props),
13
12
  });
14
13
  },
15
14
  });
package/esm/mount.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";AAAA,OAAO,GAAuB,MAAM,KAAK,CAAC;AAG1C,MAAM,UAAU,QAAQ,CAAI,IAAY,EAAE,SAA2B;IACnE,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAA2B,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,EAAe,EACf,IAAsB,EACtB,KAAQ,EACR,GAAqB,EACrB,QAA8B;IAE9B,OAAO,IAAI,GAAG,CAAC;QACb,EAAE,IAAA;QACF,OAAO,aACL,KAAK,EAAE,KAAK,CAAC,KAAK,IACf,GAAG,CACP;QACD,MAAM,YAAC,CAAC;YACN,OAAO,CAAC,CAAC,IAAI,EAAE;gBACb,KAAK,wBACA,QAAQ,GACR,KAAK,CACT;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,GAAuB,MAAM,KAAK,CAAC;AAG1C,MAAM,UAAU,QAAQ,CAAI,IAAY,EAAE,SAA2B;IACnE,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAA2B,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,EAAe,EACf,IAAsB,EACtB,KAAQ,EACR,GAAqB,EACrB,QAA8B;IAE9B,OAAO,IAAI,GAAG,CAAC;QACb,EAAE;QACF,OAAO,kBACL,KAAK,EAAE,KAAK,CAAC,KAAK,IACf,GAAG,CACP;QACD,MAAM,CAAC,CAAC;YACN,OAAO,CAAC,CAAC,IAAI,EAAE;gBACb,KAAK,kCACA,QAAQ,GACR,KAAK,CACT;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
package/esm/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Component } from 'vue';
2
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { Component } from 'vue';
2
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletVueApi {
5
5
  }
@@ -0,0 +1,19 @@
1
+ const { VueLoaderPlugin } = require('vue-loader');
2
+
3
+ const vueLoader = require.resolve('vue-loader');
4
+
5
+ module.exports =
6
+ (options = {}) =>
7
+ (config) => {
8
+ config.plugins.push(new VueLoaderPlugin());
9
+
10
+ config.module.rules.unshift({
11
+ test: /\.vue$/,
12
+ use: {
13
+ loader: vueLoader,
14
+ options,
15
+ },
16
+ });
17
+
18
+ return config;
19
+ };
@@ -1,3 +1,18 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
2
  import { Component } from 'vue';
3
- export declare function createConverter(rootName?: string): <TProps extends BaseComponentProps>(root: Component<TProps, import("vue/types/options").DefaultMethods<never>, import("vue/types/options").DefaultComputed, Record<string, any>>, captured?: Record<string, any>) => ForeignComponent<TProps>;
3
+ export interface VueConverterOptions {
4
+ /**
5
+ * Defines the name of the extension component.
6
+ * @default extension-component
7
+ */
8
+ selector?: string;
9
+ /**
10
+ * Defines the name of the root element.
11
+ * @default piral-slot
12
+ */
13
+ rootName?: string;
14
+ }
15
+ export declare function createConverter(config?: VueConverterOptions): {
16
+ <TProps extends BaseComponentProps>(root: Component<TProps>, captured?: Record<string, any>): ForeignComponent<TProps>;
17
+ Extension: Component<import("piral-core").ExtensionSlotProps>;
18
+ };
package/lib/converter.js CHANGED
@@ -1,28 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createConverter = void 0;
4
- var mount_1 = require("./mount");
5
- function createConverter(rootName) {
6
- if (rootName === void 0) { rootName = 'slot'; }
7
- var convert = function (root, captured) {
8
- var instance = undefined;
9
- return {
10
- mount: function (parent, data, ctx) {
11
- var el = parent.appendChild(document.createElement(rootName));
12
- instance = mount_1.mountVue(el, root, data, ctx, captured);
13
- },
14
- update: function (_, data) {
15
- for (var prop in data) {
16
- instance[prop] = data[prop];
17
- }
18
- },
19
- unmount: function (el) {
20
- instance.$destroy();
21
- el.innerHTML = '';
22
- instance = undefined;
23
- },
24
- };
25
- };
4
+ const mount_1 = require("./mount");
5
+ const extension_1 = require("./extension");
6
+ function createConverter(config = {}) {
7
+ const { rootName = 'piral-slot', selector = 'extension-component' } = config;
8
+ const Extension = (0, extension_1.createExtension)(rootName, selector);
9
+ const convert = (root, captured) => ({
10
+ mount(parent, data, ctx, locals) {
11
+ const el = parent.appendChild(document.createElement(rootName));
12
+ locals.instance = (0, mount_1.mountVue)(el, root, data, ctx, captured);
13
+ },
14
+ update(parent, data, ctx, locals) {
15
+ for (const prop in data) {
16
+ locals.instance[prop] = data[prop];
17
+ }
18
+ },
19
+ unmount(parent, locals) {
20
+ locals.instance.$destroy();
21
+ parent.innerHTML = '';
22
+ locals.instance = undefined;
23
+ },
24
+ });
25
+ convert.Extension = Extension;
26
26
  return convert;
27
27
  }
28
28
  exports.createConverter = createConverter;
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAEA,iCAAmC;AAEnC,SAAgB,eAAe,CAAC,QAAiB;IAAjB,yBAAA,EAAA,iBAAiB;IAC/C,IAAM,OAAO,GAAG,UACd,IAAuB,EACvB,QAA8B;QAE9B,IAAI,QAAQ,GAAQ,SAAS,CAAC;QAE9B,OAAO;YACL,KAAK,YAAC,MAAM,EAAE,IAAI,EAAE,GAAG;gBACrB,IAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAChE,QAAQ,GAAG,gBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,YAAC,CAAC,EAAE,IAAI;gBACZ,KAAK,IAAM,IAAI,IAAI,IAAI,EAAE;oBACvB,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7B;YACH,CAAC;YACD,OAAO,YAAC,EAAE;gBACR,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACpB,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;gBAClB,QAAQ,GAAG,SAAS,CAAC;YACvB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAzBD,0CAyBC"}
1
+ {"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAEA,mCAAmC;AACnC,2CAA8C;AAmB9C,SAAgB,eAAe,CAAC,SAA8B,EAAE;IAC9D,MAAM,EAAE,QAAQ,GAAG,YAAY,EAAE,QAAQ,GAAG,qBAAqB,EAAE,GAAG,MAAM,CAAC;IAC7E,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,QAA8B,EACJ,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAgB;YACvC,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChE,MAAM,CAAC,QAAQ,GAAG,IAAA,gBAAQ,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAgB;YACxC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;gBACvB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;aACpC;QACH,CAAC;QACD,OAAO,CAAC,MAAM,EAAE,MAAgB;YAC9B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC3B,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;YACtB,MAAM,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAxBD,0CAwBC"}
package/lib/create.d.ts CHANGED
@@ -1,19 +1,9 @@
1
- import { PiralPlugin } from 'piral-core';
2
- import { PiletVueApi } from './types';
1
+ import type { PiralPlugin } from 'piral-core';
2
+ import type { PiletVueApi } from './types';
3
3
  /**
4
4
  * Available configuration options for the Vue plugin.
5
5
  */
6
6
  export interface VueConfig {
7
- /**
8
- * Defines the name of the extension component.
9
- * @default extension-component
10
- */
11
- selector?: string;
12
- /**
13
- * Defines the name of the root element.
14
- * @default slot
15
- */
16
- rootName?: string;
17
7
  }
18
8
  /**
19
9
  * Creates new Pilet API extensions for integration of Vue.
package/lib/create.js CHANGED
@@ -1,29 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createVueApi = void 0;
4
- var converter_1 = require("./converter");
5
- var extension_1 = require("./extension");
4
+ const converter_1 = require("./converter");
6
5
  /**
7
6
  * Creates new Pilet API extensions for integration of Vue.
8
7
  */
9
- function createVueApi(config) {
10
- if (config === void 0) { config = {}; }
11
- var rootName = config.rootName, selector = config.selector;
12
- return function (context) {
13
- var convert = converter_1.createConverter(rootName);
14
- context.converters.vue = function (_a) {
15
- var root = _a.root, captured = _a.captured;
16
- return convert(root, captured);
17
- };
8
+ function createVueApi(config = {}) {
9
+ return (context) => {
10
+ const convert = (0, converter_1.createConverter)(config);
11
+ context.converters.vue = ({ root, captured }) => convert(root, captured);
18
12
  return {
19
- fromVue: function (root, captured) {
13
+ fromVue(root, captured) {
20
14
  return {
21
15
  type: 'vue',
22
- root: root,
23
- captured: captured,
16
+ root,
17
+ captured,
24
18
  };
25
19
  },
26
- VueExtension: extension_1.createExtension(rootName, selector),
20
+ VueExtension: convert.Extension,
27
21
  };
28
22
  };
29
23
  }
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,yCAA8C;AAE9C,yCAA8C;AAkB9C;;GAEG;AACH,SAAgB,YAAY,CAAC,MAAsB;IAAtB,uBAAA,EAAA,WAAsB;IACzC,IAAA,QAAQ,GAAe,MAAM,SAArB,EAAE,QAAQ,GAAK,MAAM,SAAX,CAAY;IAEtC,OAAO,UAAC,OAAO;QACb,IAAM,OAAO,GAAG,2BAAe,CAAC,QAAQ,CAAC,CAAC;QAC1C,OAAO,CAAC,UAAU,CAAC,GAAG,GAAG,UAAC,EAAkB;gBAAhB,IAAI,UAAA,EAAE,QAAQ,cAAA;YAAO,OAAA,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAvB,CAAuB,CAAC;QAEzE,OAAO;YACL,OAAO,YAAC,IAAI,EAAE,QAAQ;gBACpB,OAAO;oBACL,IAAI,EAAE,KAAK;oBACX,IAAI,MAAA;oBACJ,QAAQ,UAAA;iBACT,CAAC;YACJ,CAAC;YACD,YAAY,EAAE,2BAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC;SAClD,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAlBD,oCAkBC"}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAQ9C;;GAEG;AACH,SAAgB,YAAY,CAAC,SAAoB,EAAE;IACjD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEzE,OAAO;YACL,OAAO,CAAC,IAAI,EAAE,QAAQ;gBACpB,OAAO;oBACL,IAAI,EAAE,KAAK;oBACX,IAAI;oBACJ,QAAQ;iBACT,CAAC;YACJ,CAAC;YACD,YAAY,EAAE,OAAO,CAAC,SAAS;SAChC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAhBD,oCAgBC"}
@@ -1,3 +1,3 @@
1
1
  import type { ExtensionSlotProps } from 'piral-core';
2
2
  import type { Component } from 'vue';
3
- export declare function createExtension(rootName?: string, selector?: string): Component<ExtensionSlotProps>;
3
+ export declare function createExtension(rootName: string, selector: string): Component<ExtensionSlotProps>;
package/lib/extension.js CHANGED
@@ -1,18 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createExtension = void 0;
4
- var mount_1 = require("./mount");
4
+ const mount_1 = require("./mount");
5
5
  function createExtension(rootName, selector) {
6
- if (rootName === void 0) { rootName = 'slot'; }
7
- if (selector === void 0) { selector = 'extension-component'; }
8
- var VueExtension = {
6
+ const VueExtension = {
9
7
  functional: false,
10
8
  props: ['name', 'empty', 'render', 'params'],
11
9
  inject: ['piral'],
12
- render: function (createElement) {
10
+ render(createElement) {
13
11
  return createElement(rootName);
14
12
  },
15
- mounted: function () {
13
+ watch: {
14
+ params(newValue, oldValue) {
15
+ if (newValue !== oldValue) {
16
+ const newKeys = Object.keys(newValue);
17
+ const oldKeys = Object.keys(oldValue);
18
+ if (newKeys.length === oldKeys.length) {
19
+ let changed = false;
20
+ for (const key of newKeys) {
21
+ if (!oldKeys.includes(key) || newValue[key] !== oldValue[key]) {
22
+ changed = true;
23
+ break;
24
+ }
25
+ }
26
+ if (!changed) {
27
+ return;
28
+ }
29
+ }
30
+ const ev = new CustomEvent('extension-props-changed', {
31
+ detail: {
32
+ empty: this.empty,
33
+ params: newValue,
34
+ render: this.render,
35
+ name: this.name,
36
+ },
37
+ });
38
+ this.$el.dispatchEvent(ev);
39
+ }
40
+ },
41
+ },
42
+ mounted() {
16
43
  this.piral.renderHtmlExtension(this.$el, {
17
44
  empty: this.empty,
18
45
  params: this.params,
@@ -21,7 +48,7 @@ function createExtension(rootName, selector) {
21
48
  });
22
49
  },
23
50
  };
24
- mount_1.register(selector, VueExtension);
51
+ (0, mount_1.register)(selector, VueExtension);
25
52
  return VueExtension;
26
53
  }
27
54
  exports.createExtension = createExtension;
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAEA,iCAAmC;AAEnC,SAAgB,eAAe,CAAC,QAAi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("tslib");
3
+ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./create"), exports);
5
5
  tslib_1.__exportStar(require("./types"), exports);
6
6
  //# sourceMappingURL=index.js.map
package/lib/mount.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import Vue from 'vue';
2
- import { BaseComponentProps, ComponentContext } from 'piral-core';
2
+ import type { BaseComponentProps, ComponentContext } from 'piral-core';
3
3
  export declare function register<T>(name: string, component: Vue.Component<T>): void;
4
- export declare function mountVue<T extends BaseComponentProps>(el: HTMLElement, root: Vue.Component<T>, props: T, ctx: ComponentContext, captured?: Record<string, any>): import("vue/types/vue").CombinedVueInstance<Vue, object, object, object, Record<never, any>>;
4
+ export declare function mountVue<T extends BaseComponentProps>(el: HTMLElement, root: Vue.Component<T>, props: T, ctx: ComponentContext, captured?: Record<string, any>): import("vue/types/vue").CombinedVueInstance<Vue, object, object, object, Record<never, any>, {}>;
package/lib/mount.js CHANGED
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mountVue = exports.register = void 0;
4
- var tslib_1 = require("tslib");
5
- var vue_1 = require("vue");
4
+ const vue_1 = require("vue");
6
5
  function register(name, component) {
7
6
  vue_1.default.component(name, component);
8
7
  }
9
8
  exports.register = register;
10
9
  function mountVue(el, root, props, ctx, captured) {
11
10
  return new vue_1.default({
12
- el: el,
13
- provide: tslib_1.__assign({ piral: props.piral }, ctx),
14
- render: function (h) {
11
+ el,
12
+ provide: Object.assign({ piral: props.piral }, ctx),
13
+ render(h) {
15
14
  return h(root, {
16
- props: tslib_1.__assign(tslib_1.__assign({}, captured), props),
15
+ props: Object.assign(Object.assign({}, captured), props),
17
16
  });
18
17
  },
19
18
  });
package/lib/mount.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;;;AAAA,2BAA0C;AAG1C,SAAgB,QAAQ,CAAI,IAAY,EAAE,SAA2B;IACnE,aAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAA2B,CAAC,CAAC;AACnD,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CACtB,EAAe,EACf,IAAsB,EACtB,KAAQ,EACR,GAAqB,EACrB,QAA8B;IAE9B,OAAO,IAAI,aAAG,CAAC;QACb,EAAE,IAAA;QACF,OAAO,qBACL,KAAK,EAAE,KAAK,CAAC,KAAK,IACf,GAAG,CACP;QACD,MAAM,YAAC,CAAC;YACN,OAAO,CAAC,CAAC,IAAI,EAAE;gBACb,KAAK,wCACA,QAAQ,GACR,KAAK,CACT;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAtBD,4BAsBC"}
1
+ {"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":";;;AAAA,6BAA0C;AAG1C,SAAgB,QAAQ,CAAI,IAAY,EAAE,SAA2B;IACnE,aAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAA2B,CAAC,CAAC;AACnD,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CACtB,EAAe,EACf,IAAsB,EACtB,KAAQ,EACR,GAAqB,EACrB,QAA8B;IAE9B,OAAO,IAAI,aAAG,CAAC;QACb,EAAE;QACF,OAAO,kBACL,KAAK,EAAE,KAAK,CAAC,KAAK,IACf,GAAG,CACP;QACD,MAAM,CAAC,CAAC;YACN,OAAO,CAAC,CAAC,IAAI,EAAE;gBACb,KAAK,kCACA,QAAQ,GACR,KAAK,CACT;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAtBD,4BAsBC"}
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Component } from 'vue';
2
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { Component } from 'vue';
2
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
3
3
  declare module 'piral-core/lib/types/custom' {
4
4
  interface PiletCustomApi extends PiletVueApi {
5
5
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "piral-vue",
3
- "version": "1.0.0-pre.2296",
4
- "description": "Plugin for integrating Vue components in Piral.",
3
+ "version": "1.0.1-beta.5640",
4
+ "description": "Plugin for integrating Vue@2 components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
7
7
  "pilet-api",
@@ -20,14 +20,37 @@
20
20
  "module": "esm/index.js",
21
21
  "main": "lib/index.js",
22
22
  "typings": "lib/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": "./esm/index.js",
26
+ "require": "./lib/index.js"
27
+ },
28
+ "./convert": {
29
+ "import": "./convert.js"
30
+ },
31
+ "./extend-webpack": {
32
+ "require": "./extend-webpack.js"
33
+ },
34
+ "./esm/*": {
35
+ "import": "./esm/*"
36
+ },
37
+ "./lib/*": {
38
+ "require": "./lib/*"
39
+ },
40
+ "./_/*": {
41
+ "import": "./esm/*.js",
42
+ "require": "./lib/*.js"
43
+ },
44
+ "./package.json": "./package.json"
45
+ },
23
46
  "sideEffects": false,
24
47
  "files": [
25
48
  "esm",
26
49
  "lib",
27
50
  "src",
28
51
  "convert.d.ts",
29
- "convert.ts",
30
- "convert.js"
52
+ "convert.js",
53
+ "extend-webpack.js"
31
54
  ],
32
55
  "repository": {
33
56
  "type": "git",
@@ -37,20 +60,17 @@
37
60
  "url": "https://github.com/smapiot/piral/issues"
38
61
  },
39
62
  "scripts": {
63
+ "cleanup": "rimraf esm lib convert.d.ts convert.js",
40
64
  "build": "yarn build:commonjs && yarn build:esnext && yarn build:convert",
41
- "build:convert": "tsc convert.ts --skipLibCheck --declaration",
65
+ "build:convert": "tsc convert.ts --skipLibCheck --declaration --module esnext",
42
66
  "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
43
67
  "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
44
68
  "typedoc": "typedoc --json ../../../docs/types/piral-vue.json src --exclude \"src/**/*.test.*\"",
45
69
  "test": "echo \"Error: run tests from root\" && exit 1"
46
70
  },
47
71
  "devDependencies": {
48
- "piral-core": "^1.0.0-pre.2296",
72
+ "piral-core": "1.0.1-beta.5640",
49
73
  "vue": "^2.6.10"
50
74
  },
51
- "peerDependencies": {
52
- "piral-core": "0.13.x",
53
- "vue": "^2.0.0"
54
- },
55
- "gitHead": "8dc47ff93be1eefcc3e226a1e7dd4d58615b4e0c"
75
+ "gitHead": "fa0a72b28fd0a20afec7ef491ec19e93c090fc72"
56
76
  }
package/src/converter.ts CHANGED
@@ -1,30 +1,47 @@
1
- import { ForeignComponent, BaseComponentProps } from 'piral-core';
1
+ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
2
  import { Component } from 'vue';
3
3
  import { mountVue } from './mount';
4
+ import { createExtension } from './extension';
4
5
 
5
- export function createConverter(rootName = 'slot') {
6
+ export interface VueConverterOptions {
7
+ /**
8
+ * Defines the name of the extension component.
9
+ * @default extension-component
10
+ */
11
+ selector?: string;
12
+ /**
13
+ * Defines the name of the root element.
14
+ * @default piral-slot
15
+ */
16
+ rootName?: string;
17
+ }
18
+
19
+ interface VueState {
20
+ instance: any;
21
+ }
22
+
23
+ export function createConverter(config: VueConverterOptions = {}) {
24
+ const { rootName = 'piral-slot', selector = 'extension-component' } = config;
25
+ const Extension = createExtension(rootName, selector);
6
26
  const convert = <TProps extends BaseComponentProps>(
7
27
  root: Component<TProps>,
8
28
  captured?: Record<string, any>,
9
- ): ForeignComponent<TProps> => {
10
- let instance: any = undefined;
11
-
12
- return {
13
- mount(parent, data, ctx) {
14
- const el = parent.appendChild(document.createElement(rootName));
15
- instance = mountVue(el, root, data, ctx, captured);
16
- },
17
- update(_, data) {
18
- for (const prop in data) {
19
- instance[prop] = data[prop];
20
- }
21
- },
22
- unmount(el) {
23
- instance.$destroy();
24
- el.innerHTML = '';
25
- instance = undefined;
26
- },
27
- };
28
- };
29
+ ): ForeignComponent<TProps> => ({
30
+ mount(parent, data, ctx, locals: VueState) {
31
+ const el = parent.appendChild(document.createElement(rootName));
32
+ locals.instance = mountVue(el, root, data, ctx, captured);
33
+ },
34
+ update(parent, data, ctx, locals: VueState) {
35
+ for (const prop in data) {
36
+ locals.instance[prop] = data[prop];
37
+ }
38
+ },
39
+ unmount(parent, locals: VueState) {
40
+ locals.instance.$destroy();
41
+ parent.innerHTML = '';
42
+ locals.instance = undefined;
43
+ },
44
+ });
45
+ convert.Extension = Extension;
29
46
  return convert;
30
47
  }
package/src/create.ts CHANGED
@@ -1,32 +1,18 @@
1
- import { PiralPlugin, ExtensionSlotProps } from 'piral-core';
1
+ import type { PiralPlugin } from 'piral-core';
2
2
  import { createConverter } from './converter';
3
- import { PiletVueApi } from './types';
4
- import { createExtension } from './extension';
3
+ import type { PiletVueApi } from './types';
5
4
 
6
5
  /**
7
6
  * Available configuration options for the Vue plugin.
8
7
  */
9
- export interface VueConfig {
10
- /**
11
- * Defines the name of the extension component.
12
- * @default extension-component
13
- */
14
- selector?: string;
15
- /**
16
- * Defines the name of the root element.
17
- * @default slot
18
- */
19
- rootName?: string;
20
- }
8
+ export interface VueConfig {}
21
9
 
22
10
  /**
23
11
  * Creates new Pilet API extensions for integration of Vue.
24
12
  */
25
13
  export function createVueApi(config: VueConfig = {}): PiralPlugin<PiletVueApi> {
26
- const { rootName, selector } = config;
27
-
28
14
  return (context) => {
29
- const convert = createConverter(rootName);
15
+ const convert = createConverter(config);
30
16
  context.converters.vue = ({ root, captured }) => convert(root, captured);
31
17
 
32
18
  return {
@@ -37,7 +23,7 @@ export function createVueApi(config: VueConfig = {}): PiralPlugin<PiletVueApi> {
37
23
  captured,
38
24
  };
39
25
  },
40
- VueExtension: createExtension(rootName, selector),
26
+ VueExtension: convert.Extension,
41
27
  };
42
28
  };
43
29
  }
package/src/extension.ts CHANGED
@@ -2,7 +2,7 @@ import type { ExtensionSlotProps } from 'piral-core';
2
2
  import type { Component } from 'vue';
3
3
  import { register } from './mount';
4
4
 
5
- export function createExtension(rootName = 'slot', selector = 'extension-component'): Component<ExtensionSlotProps> {
5
+ export function createExtension(rootName: string, selector: string): Component<ExtensionSlotProps> {
6
6
  const VueExtension: Component<ExtensionSlotProps> = {
7
7
  functional: false,
8
8
  props: ['name', 'empty', 'render', 'params'],
@@ -10,6 +10,39 @@ export function createExtension(rootName = 'slot', selector = 'extension-compone
10
10
  render(createElement) {
11
11
  return createElement(rootName);
12
12
  },
13
+ watch: {
14
+ params(newValue, oldValue) {
15
+ if (newValue !== oldValue) {
16
+ const newKeys = Object.keys(newValue);
17
+ const oldKeys = Object.keys(oldValue);
18
+
19
+ if (newKeys.length === oldKeys.length) {
20
+ let changed = false;
21
+
22
+ for (const key of newKeys) {
23
+ if (!oldKeys.includes(key) || newValue[key] !== oldValue[key]) {
24
+ changed = true;
25
+ break;
26
+ }
27
+ }
28
+
29
+ if (!changed) {
30
+ return;
31
+ }
32
+ }
33
+
34
+ const ev = new CustomEvent('extension-props-changed', {
35
+ detail: {
36
+ empty: this.empty,
37
+ params: newValue,
38
+ render: this.render,
39
+ name: this.name,
40
+ },
41
+ });
42
+ this.$el.dispatchEvent(ev);
43
+ }
44
+ },
45
+ },
13
46
  mounted() {
14
47
  this.piral.renderHtmlExtension(this.$el, {
15
48
  empty: this.empty,
package/src/mount.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Vue, { VueConstructor } from 'vue';
2
- import { BaseComponentProps, ComponentContext } from 'piral-core';
2
+ import type { BaseComponentProps, ComponentContext } from 'piral-core';
3
3
 
4
4
  export function register<T>(name: string, component: Vue.Component<T>) {
5
5
  Vue.component(name, component as VueConstructor);
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Component } from 'vue';
2
- import { ForeignComponent, ExtensionSlotProps } from 'piral-core';
1
+ import type { Component } from 'vue';
2
+ import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
3
3
 
4
4
  declare module 'piral-core/lib/types/custom' {
5
5
  interface PiletCustomApi extends PiletVueApi {}
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 VueConverter {
8
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
9
- }
10
-
11
- export const fromVue: VueConverter = (root, captured) => ({
12
- type: 'html',
13
- component: convert(root, captured),
14
- });
15
-
16
- export const createVueExtension = createExtension;