Skip to content

Commit

Permalink
Merge pull request #723 from smapiot/develop
Browse files Browse the repository at this point in the history
Release 1.7.1
  • Loading branch information
FlorianRappl authored Nov 2, 2024
2 parents e1f1b4e + 0114225 commit 744e94c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Piral Changelog

## 1.7.1 (tbd)

- Fixed `engines` field to have a constraint for Node.js >=18.17
- Fixed release mode behavior of `piral-vue3` reactivity (#720)

## 1.7.0 (October 16, 2024)

- Fixed issue in `piral-vue3` concerning reactivity of props (#720)
Expand Down
17 changes: 11 additions & 6 deletions src/converters/piral-vue-3/src/converter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ForeignComponent, BaseComponentProps } from 'piral-core';
import { Component, App } from 'vue';
import { Component, App, reactive } from 'vue';
import { createExtension } from './extension';
import { mountVue } from './mount';
import { Vue3MiddlewareHandler } from './types';
Expand All @@ -19,6 +19,7 @@ export interface Vue3ConverterOptions {

interface Vue3State {
instance: App;
props: any;
}

export function createConverter(config: Vue3ConverterOptions = {}) {
Expand All @@ -27,27 +28,31 @@ export function createConverter(config: Vue3ConverterOptions = {}) {
const middlewares: Array<Vue3MiddlewareHandler> = [];
const convert = <TProps extends BaseComponentProps>(
root: Component<TProps>,
captured?: Record<string, any>,
captured: Record<string, any> = {},
): ForeignComponent<TProps> => ({
mount(parent, data, ctx, locals: Vue3State) {
const el = parent.appendChild(document.createElement(rootName));
const app = mountVue(root, data, ctx, captured);
const props = reactive({
...captured,
...data,
});
const app = mountVue(root, props, ctx);
middlewares.forEach((middleware) => middleware(app));
app.component(selector, createExtension(rootName));
app.mount(el);
locals.instance = app;
locals.props = props;
},
update(parent, data, ctx, locals: Vue3State) {
const appInstance = locals.instance._instance;

for (const prop in data) {
appInstance.props[prop] = data[prop];
locals.props[prop] = data[prop];
}
},
unmount(parent, locals: Vue3State) {
locals.instance.unmount();
parent.innerHTML = '';
locals.instance = undefined;
locals.props = undefined;
},
});
convert.Extension = Extension;
Expand Down
10 changes: 2 additions & 8 deletions src/converters/piral-vue-3/src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@ export function mountVue<T extends BaseComponentProps>(
component: Component<T>,
props: T,
ctx: ComponentContext,
captured?: Record<string, any>,
) {
const data = {
...captured,
...props,
};
const root: Component = {
provide: {
piral: props.piral,
...ctx,
},
props: Object.keys(data),
render() {
return h(component, this.$props);
return h(component, props);
},
};

return createApp(root, data);
return createApp(root);
}
2 changes: 1 addition & 1 deletion src/initializers/create-pilet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"engines": {
"node": ">=16.0.0"
"node": ">=18.17"
},
"files": [
"lib",
Expand Down
2 changes: 1 addition & 1 deletion src/initializers/create-piral-instance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"engines": {
"node": ">=16.0.0"
"node": ">=18.17"
},
"files": [
"lib",
Expand Down
2 changes: 1 addition & 1 deletion src/tooling/piral-cli-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"engines": {
"node": ">=16.0.0"
"node": ">=18.17"
},
"files": [
"lib",
Expand Down
2 changes: 1 addition & 1 deletion src/tooling/piral-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"engines": {
"node": ">=16.0.0"
"node": ">=18.17"
},
"files": [
"lib",
Expand Down

0 comments on commit 744e94c

Please sign in to comment.