piral-vue-3 1.5.4-beta.6998 → 1.5.4-beta.7014
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 +43 -0
- package/convert.d.ts +3 -2
- package/convert.js +4 -3
- package/esm/converter.d.ts +2 -0
- package/esm/converter.js +5 -0
- package/esm/converter.js.map +1 -1
- package/esm/create.js +1 -0
- package/esm/create.js.map +1 -1
- package/esm/types.d.ts +14 -1
- package/lib/converter.d.ts +2 -0
- package/lib/converter.js +5 -0
- package/lib/converter.js.map +1 -1
- package/lib/create.js +1 -0
- package/lib/create.js.map +1 -1
- package/lib/types.d.ts +14 -1
- package/package.json +3 -3
- package/src/converter.ts +6 -0
- package/src/create.ts +1 -0
- package/src/types.ts +15 -1
package/README.md
CHANGED
|
@@ -20,6 +20,49 @@ Transforms a standard Vue@3 component into a component that can be used in Piral
|
|
|
20
20
|
|
|
21
21
|
The extension slot component to be used in Vue@3 components. This is not really needed, as it is made available automatically via a Vue@3 custom element named `extension-component`.
|
|
22
22
|
|
|
23
|
+
### `defineVue3Middleware`
|
|
24
|
+
|
|
25
|
+
This function is used to declare additional middleware such as plugins when setting up Vue3.
|
|
26
|
+
|
|
27
|
+
Example in a standalone pilet:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { fromVue3, defineVue3Middleware } from 'piral-vue-3/convert';
|
|
31
|
+
import Page from './Page.vue';
|
|
32
|
+
import i18next from 'i18next';
|
|
33
|
+
import I18NextVue from 'i18next-vue';
|
|
34
|
+
import type { PiletApi } from 'sample-piral';
|
|
35
|
+
|
|
36
|
+
i18next.init({
|
|
37
|
+
lng: 'de',
|
|
38
|
+
interpolation: {
|
|
39
|
+
escapeValue: false
|
|
40
|
+
},
|
|
41
|
+
fallbackLng: false,
|
|
42
|
+
resources: {
|
|
43
|
+
en: {
|
|
44
|
+
translation: {
|
|
45
|
+
greeter: "Welcome",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
de: {
|
|
49
|
+
translation: {
|
|
50
|
+
greeter: "Willkommen",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export function setup(app: PiletApi) {
|
|
57
|
+
defineVue3Middleware(vue => {
|
|
58
|
+
vue.use(I18NextVue, { i18next });
|
|
59
|
+
});
|
|
60
|
+
app.registerPage('/sample', fromVue3(Page));
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Here we integrate the `i18next` plugin using the `i18next-vue` package. By defining the middleware using the `defineVue3Middleware` and the provided callback, we can integrate the plugin without requiring any access to the original `app` instance of Vue.
|
|
65
|
+
|
|
23
66
|
## Usage
|
|
24
67
|
|
|
25
68
|
::: summary: For pilet authors
|
package/convert.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface Vue3Converter {
|
|
|
13
13
|
export declare function createVue3Converter(...params: Parameters<typeof createConverter>): {
|
|
14
14
|
from: Vue3Converter;
|
|
15
15
|
Extension: Component<any>;
|
|
16
|
+
defineMiddleware: (setup: import("./esm/types").Vue3MiddlewareHandler) => void;
|
|
16
17
|
};
|
|
17
|
-
declare const fromVue3: Vue3Converter, Vue3Extension: Component<any
|
|
18
|
-
export { fromVue3, Vue3Extension };
|
|
18
|
+
declare const fromVue3: Vue3Converter, Vue3Extension: Component<any>, defineVue3Middleware: (setup: import("./esm/types").Vue3MiddlewareHandler) => void;
|
|
19
|
+
export { fromVue3, Vue3Extension, defineVue3Middleware };
|
package/convert.js
CHANGED
|
@@ -6,11 +6,12 @@ export function createVue3Converter() {
|
|
|
6
6
|
}
|
|
7
7
|
var convert = createConverter.apply(void 0, params);
|
|
8
8
|
var Extension = convert.Extension;
|
|
9
|
+
var defineMiddleware = convert.defineMiddleware;
|
|
9
10
|
var from = function (root, captured) { return ({
|
|
10
11
|
type: 'html',
|
|
11
12
|
component: convert(root, captured),
|
|
12
13
|
}); };
|
|
13
|
-
return { from: from, Extension: Extension };
|
|
14
|
+
return { from: from, Extension: Extension, defineMiddleware: defineMiddleware };
|
|
14
15
|
}
|
|
15
|
-
var _a = createVue3Converter(), fromVue3 = _a.from, Vue3Extension = _a.Extension;
|
|
16
|
-
export { fromVue3, Vue3Extension };
|
|
16
|
+
var _a = createVue3Converter(), fromVue3 = _a.from, Vue3Extension = _a.Extension, defineVue3Middleware = _a.defineMiddleware;
|
|
17
|
+
export { fromVue3, Vue3Extension, defineVue3Middleware };
|
package/esm/converter.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
2
|
import { Component } from 'vue';
|
|
3
|
+
import { Vue3MiddlewareHandler } from './types';
|
|
3
4
|
export interface Vue3ConverterOptions {
|
|
4
5
|
/**
|
|
5
6
|
* Defines the name of the extension component.
|
|
@@ -15,4 +16,5 @@ export interface Vue3ConverterOptions {
|
|
|
15
16
|
export declare function createConverter(config?: Vue3ConverterOptions): {
|
|
16
17
|
<TProps extends BaseComponentProps>(root: Component<TProps>, captured?: Record<string, any>): ForeignComponent<TProps>;
|
|
17
18
|
Extension: Component<import("piral-core").ExtensionSlotProps>;
|
|
19
|
+
defineMiddleware(setup: Vue3MiddlewareHandler): void;
|
|
18
20
|
};
|
package/esm/converter.js
CHANGED
|
@@ -3,10 +3,12 @@ import { mountVue } from './mount';
|
|
|
3
3
|
export function createConverter(config = {}) {
|
|
4
4
|
const { rootName = 'piral-slot', selector = 'extension-component' } = config;
|
|
5
5
|
const Extension = createExtension(rootName);
|
|
6
|
+
let middleware = () => { };
|
|
6
7
|
const convert = (root, captured) => ({
|
|
7
8
|
mount(parent, data, ctx, locals) {
|
|
8
9
|
const el = parent.appendChild(document.createElement(rootName));
|
|
9
10
|
const app = mountVue(root, data, ctx, captured);
|
|
11
|
+
middleware(app);
|
|
10
12
|
app.component(selector, createExtension(rootName));
|
|
11
13
|
app.mount(el);
|
|
12
14
|
!app._props && (app._props = {});
|
|
@@ -24,6 +26,9 @@ export function createConverter(config = {}) {
|
|
|
24
26
|
},
|
|
25
27
|
});
|
|
26
28
|
convert.Extension = Extension;
|
|
29
|
+
convert.defineMiddleware = (setup) => {
|
|
30
|
+
middleware = setup;
|
|
31
|
+
};
|
|
27
32
|
return convert;
|
|
28
33
|
}
|
|
29
34
|
//# 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,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAoBnC,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,IAAI,UAAU,GAA0B,GAAG,EAAE,GAAE,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,QAA8B,EACJ,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,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;YAChD,UAAU,CAAC,GAAG,CAAC,CAAC;YA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,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE1E,OAAO;YACL,QAAQ,CAAC,IAAI,EAAE,QAAQ;gBACrB,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,IAAI;oBACJ,QAAQ;iBACT,CAAC;YACJ,CAAC;YACD,aAAa,EAAE,OAAO,CAAC,SAAS;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAwB,MAAM,aAAa,CAAC;AAQpE;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,SAAqB,EAAE;IACnD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE1E,OAAO;YACL,QAAQ,CAAC,IAAI,EAAE,QAAQ;gBACrB,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,IAAI;oBACJ,QAAQ;iBACT,CAAC;YACJ,CAAC;YACD,aAAa,EAAE,OAAO,CAAC,SAAS;YAChC,oBAAoB,EAAE,OAAO,CAAC,gBAAgB;SAC/C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component } from 'vue';
|
|
1
|
+
import type { App, Component } from 'vue';
|
|
2
2
|
import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
|
|
3
3
|
declare module 'piral-core/lib/types/custom' {
|
|
4
4
|
interface PiletCustomApi extends PiletVue3Api {
|
|
@@ -7,6 +7,15 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
7
7
|
vue3(component: Vue3Component<TProps>): ForeignComponent<TProps>;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Defines a handler to set up Vue 3 middleware.
|
|
12
|
+
*/
|
|
13
|
+
export interface Vue3MiddlewareHandler {
|
|
14
|
+
/**
|
|
15
|
+
* Receives the app instance to integrate middleware.
|
|
16
|
+
*/
|
|
17
|
+
(app: App<Element>): void;
|
|
18
|
+
}
|
|
10
19
|
export interface Vue3Component<TProps> {
|
|
11
20
|
/**
|
|
12
21
|
* The root component of Vue rendering tree.
|
|
@@ -36,4 +45,8 @@ export interface PiletVue3Api {
|
|
|
36
45
|
* Vue component for displaying extensions of the given name.
|
|
37
46
|
*/
|
|
38
47
|
Vue3Extension: Component<ExtensionSlotProps>;
|
|
48
|
+
/**
|
|
49
|
+
* Function to use for declaring a callback to setup additional middleware.
|
|
50
|
+
*/
|
|
51
|
+
defineVue3Middleware(setup: Vue3MiddlewareHandler): void;
|
|
39
52
|
}
|
package/lib/converter.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
2
2
|
import { Component } from 'vue';
|
|
3
|
+
import { Vue3MiddlewareHandler } from './types';
|
|
3
4
|
export interface Vue3ConverterOptions {
|
|
4
5
|
/**
|
|
5
6
|
* Defines the name of the extension component.
|
|
@@ -15,4 +16,5 @@ export interface Vue3ConverterOptions {
|
|
|
15
16
|
export declare function createConverter(config?: Vue3ConverterOptions): {
|
|
16
17
|
<TProps extends BaseComponentProps>(root: Component<TProps>, captured?: Record<string, any>): ForeignComponent<TProps>;
|
|
17
18
|
Extension: Component<import("piral-core").ExtensionSlotProps>;
|
|
19
|
+
defineMiddleware(setup: Vue3MiddlewareHandler): void;
|
|
18
20
|
};
|
package/lib/converter.js
CHANGED
|
@@ -6,10 +6,12 @@ const mount_1 = require("./mount");
|
|
|
6
6
|
function createConverter(config = {}) {
|
|
7
7
|
const { rootName = 'piral-slot', selector = 'extension-component' } = config;
|
|
8
8
|
const Extension = (0, extension_1.createExtension)(rootName);
|
|
9
|
+
let middleware = () => { };
|
|
9
10
|
const convert = (root, captured) => ({
|
|
10
11
|
mount(parent, data, ctx, locals) {
|
|
11
12
|
const el = parent.appendChild(document.createElement(rootName));
|
|
12
13
|
const app = (0, mount_1.mountVue)(root, data, ctx, captured);
|
|
14
|
+
middleware(app);
|
|
13
15
|
app.component(selector, (0, extension_1.createExtension)(rootName));
|
|
14
16
|
app.mount(el);
|
|
15
17
|
!app._props && (app._props = {});
|
|
@@ -27,6 +29,9 @@ function createConverter(config = {}) {
|
|
|
27
29
|
},
|
|
28
30
|
});
|
|
29
31
|
convert.Extension = Extension;
|
|
32
|
+
convert.defineMiddleware = (setup) => {
|
|
33
|
+
middleware = setup;
|
|
34
|
+
};
|
|
30
35
|
return convert;
|
|
31
36
|
}
|
|
32
37
|
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,2CAA8C;AAC9C,mCAAmC;
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AAEA,2CAA8C;AAC9C,mCAAmC;AAoBnC,SAAgB,eAAe,CAAC,SAA+B,EAAE;IAC/D,MAAM,EAAE,QAAQ,GAAG,YAAY,EAAE,QAAQ,GAAG,qBAAqB,EAAE,GAAG,MAAM,CAAC;IAC7E,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,IAAI,UAAU,GAA0B,GAAG,EAAE,GAAE,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,QAA8B,EACJ,EAAE,CAAC,CAAC;QAC9B,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAiB;YACxC,MAAM,EA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[],"mappings":";;;AACA,2CAAoE;AAQpE;;GAEG;AACH,SAAgB,aAAa,CAAC,SAAqB,EAAE;IACnD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE1E,OAAO;YACL,QAAQ,CAAC,IAAI,EAAE,QAAQ;gBACrB,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,IAAI;oBACJ,QAAQ;iBACT,CAAC;YACJ,CAAC;YACD,aAAa,EAAE,OAAO,CAAC,SAAS;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AACA,2CAAoE;AAQpE;;GAEG;AACH,SAAgB,aAAa,CAAC,SAAqB,EAAE;IACnD,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE1E,OAAO;YACL,QAAQ,CAAC,IAAI,EAAE,QAAQ;gBACrB,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,IAAI;oBACJ,QAAQ;iBACT,CAAC;YACJ,CAAC;YACD,aAAa,EAAE,OAAO,CAAC,SAAS;YAChC,oBAAoB,EAAE,OAAO,CAAC,gBAAgB;SAC/C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,sCAiBC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component } from 'vue';
|
|
1
|
+
import type { App, Component } from 'vue';
|
|
2
2
|
import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
|
|
3
3
|
declare module 'piral-core/lib/types/custom' {
|
|
4
4
|
interface PiletCustomApi extends PiletVue3Api {
|
|
@@ -7,6 +7,15 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
7
7
|
vue3(component: Vue3Component<TProps>): ForeignComponent<TProps>;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Defines a handler to set up Vue 3 middleware.
|
|
12
|
+
*/
|
|
13
|
+
export interface Vue3MiddlewareHandler {
|
|
14
|
+
/**
|
|
15
|
+
* Receives the app instance to integrate middleware.
|
|
16
|
+
*/
|
|
17
|
+
(app: App<Element>): void;
|
|
18
|
+
}
|
|
10
19
|
export interface Vue3Component<TProps> {
|
|
11
20
|
/**
|
|
12
21
|
* The root component of Vue rendering tree.
|
|
@@ -36,4 +45,8 @@ export interface PiletVue3Api {
|
|
|
36
45
|
* Vue component for displaying extensions of the given name.
|
|
37
46
|
*/
|
|
38
47
|
Vue3Extension: Component<ExtensionSlotProps>;
|
|
48
|
+
/**
|
|
49
|
+
* Function to use for declaring a callback to setup additional middleware.
|
|
50
|
+
*/
|
|
51
|
+
defineVue3Middleware(setup: Vue3MiddlewareHandler): void;
|
|
39
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-vue-3",
|
|
3
|
-
"version": "1.5.4-beta.
|
|
3
|
+
"version": "1.5.4-beta.7014",
|
|
4
4
|
"description": "Plugin for integrating Vue@3 components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"piral-core": "1.5.4-beta.
|
|
72
|
+
"piral-core": "1.5.4-beta.7014",
|
|
73
73
|
"vue": "^3.0.0"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "ddd82bbabd5c2074e6c52df74383970ce4e28d45"
|
|
76
76
|
}
|
package/src/converter.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ForeignComponent, BaseComponentProps } from 'piral-core';
|
|
|
2
2
|
import { Component, App } from 'vue';
|
|
3
3
|
import { createExtension } from './extension';
|
|
4
4
|
import { mountVue } from './mount';
|
|
5
|
+
import { Vue3MiddlewareHandler } from './types';
|
|
5
6
|
|
|
6
7
|
export interface Vue3ConverterOptions {
|
|
7
8
|
/**
|
|
@@ -23,6 +24,7 @@ interface Vue3State {
|
|
|
23
24
|
export function createConverter(config: Vue3ConverterOptions = {}) {
|
|
24
25
|
const { rootName = 'piral-slot', selector = 'extension-component' } = config;
|
|
25
26
|
const Extension = createExtension(rootName);
|
|
27
|
+
let middleware: Vue3MiddlewareHandler = () => {};
|
|
26
28
|
const convert = <TProps extends BaseComponentProps>(
|
|
27
29
|
root: Component<TProps>,
|
|
28
30
|
captured?: Record<string, any>,
|
|
@@ -30,6 +32,7 @@ export function createConverter(config: Vue3ConverterOptions = {}) {
|
|
|
30
32
|
mount(parent, data, ctx, locals: Vue3State) {
|
|
31
33
|
const el = parent.appendChild(document.createElement(rootName));
|
|
32
34
|
const app = mountVue(root, data, ctx, captured);
|
|
35
|
+
middleware(app);
|
|
33
36
|
app.component(selector, createExtension(rootName));
|
|
34
37
|
app.mount(el);
|
|
35
38
|
!app._props && (app._props = {});
|
|
@@ -47,5 +50,8 @@ export function createConverter(config: Vue3ConverterOptions = {}) {
|
|
|
47
50
|
},
|
|
48
51
|
});
|
|
49
52
|
convert.Extension = Extension;
|
|
53
|
+
convert.defineMiddleware = (setup: Vue3MiddlewareHandler) => {
|
|
54
|
+
middleware = setup;
|
|
55
|
+
};
|
|
50
56
|
return convert;
|
|
51
57
|
}
|
package/src/create.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component } from 'vue';
|
|
1
|
+
import type { App, Component } from 'vue';
|
|
2
2
|
import type { ForeignComponent, ExtensionSlotProps } from 'piral-core';
|
|
3
3
|
|
|
4
4
|
declare module 'piral-core/lib/types/custom' {
|
|
@@ -9,6 +9,16 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Defines a handler to set up Vue 3 middleware.
|
|
14
|
+
*/
|
|
15
|
+
export interface Vue3MiddlewareHandler {
|
|
16
|
+
/**
|
|
17
|
+
* Receives the app instance to integrate middleware.
|
|
18
|
+
*/
|
|
19
|
+
(app: App<Element>): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
export interface Vue3Component<TProps> {
|
|
13
23
|
/**
|
|
14
24
|
* The root component of Vue rendering tree.
|
|
@@ -39,4 +49,8 @@ export interface PiletVue3Api {
|
|
|
39
49
|
* Vue component for displaying extensions of the given name.
|
|
40
50
|
*/
|
|
41
51
|
Vue3Extension: Component<ExtensionSlotProps>;
|
|
52
|
+
/**
|
|
53
|
+
* Function to use for declaring a callback to setup additional middleware.
|
|
54
|
+
*/
|
|
55
|
+
defineVue3Middleware(setup: Vue3MiddlewareHandler): void;
|
|
42
56
|
}
|