@data-fair/frame 0.18.6 → 0.19.0
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/dist/d-frame-content.min.js +1 -1
- package/dist/d-frame-content.min.js.map +1 -1
- package/dist/d-frame.min.js +2 -2
- package/dist/d-frame.min.js.map +1 -1
- package/dist/v-iframe-compat/d-frame-content.min.js +1 -1
- package/dist/v-iframe-compat/d-frame-content.min.js.map +1 -1
- package/lib/DFrameContent.d.ts +2 -1
- package/lib/DFrameContent.js +29 -23
- package/lib/DFrameElement.d.ts +2 -1
- package/lib/DFrameElement.js +49 -15
- package/lib/messages.js +7 -4
- package/lib/utils/sync-params.js +10 -8
- package/lib/utils/url.d.ts +1 -0
- package/lib/utils/url.js +11 -0
- package/lib/v-iframe-compat/ui-notif.js +1 -1
- package/lib/vue/use-parent-urls.js +1 -1
- package/lib/vue-reactive/state-change-adapter.d.ts +1 -1
- package/lib/vue-reactive/state-change-adapter.js +1 -1
- package/lib/vue-reactive/util.js +4 -5
- package/lib/vue-router/state-change-adapter.d.ts +1 -1
- package/lib/vue-router/state-change-adapter.js +13 -3
- package/lib/vue-router/use-parent-url.js +9 -4
- package/package.json +9 -6
- package/lib/vue-router/router-type.d.ts +0 -17
- package/lib/vue-router/router-type.js +0 -7
- package/lib/vue-router/util.d.ts +0 -17
- package/lib/vue-router/util.js +0 -3
|
@@ -17,13 +17,23 @@ class VueRouterDFrameStateChangeAdapter {
|
|
|
17
17
|
if (!newRoute.startsWith('/'))
|
|
18
18
|
newRoute = '/' + newRoute;
|
|
19
19
|
element.log('debug', 'apply state change on vue.router', action, newRoute);
|
|
20
|
+
// a guard that throws rejects the navigation without calling afterEach: the parent stays on its URL,
|
|
21
|
+
// the child is brought back to it like after an aborted navigation
|
|
22
|
+
const onError = (err) => {
|
|
23
|
+
element.log('error', 'failed to apply state change on vue.router', err);
|
|
24
|
+
element.updateSrc();
|
|
25
|
+
};
|
|
20
26
|
if (action === 'push')
|
|
21
|
-
this.router.push(newRoute);
|
|
27
|
+
this.router.push(newRoute).catch(onError);
|
|
22
28
|
if (action === 'replace')
|
|
23
|
-
this.router.replace(newRoute);
|
|
29
|
+
this.router.replace(newRoute).catch(onError);
|
|
24
30
|
}
|
|
25
31
|
onStateChange(callback) {
|
|
26
|
-
|
|
32
|
+
// a cancelled navigation is superseded by a newer one: syncing the child from the parent URL
|
|
33
|
+
// would send back stale params while the child has already moved on (fast clicks in the child).
|
|
34
|
+
// An aborted one (4 = NavigationFailureType.aborted) was refused by a guard: the child must go back to the parent URL
|
|
35
|
+
return this.router.afterEach((_to, _from, failure) => { if (!failure || failure.type === 4)
|
|
36
|
+
callback(); });
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
export default (router) => new VueRouterDFrameStateChangeAdapter(router);
|
|
@@ -17,16 +17,21 @@ export const useParentUrl = (location, router, dFrameContent) => {
|
|
|
17
17
|
let listener = null;
|
|
18
18
|
const parentUrl = ref(null);
|
|
19
19
|
watch(() => toValue(location), (to) => {
|
|
20
|
+
const href = to === undefined ? undefined : router.resolve(to).href;
|
|
21
|
+
// a getter can return a new location object for the same target: keep the listener and its result
|
|
22
|
+
if (href === resolved)
|
|
23
|
+
return;
|
|
20
24
|
if (listener && resolved)
|
|
21
25
|
dFrameContent.removeParentUrlListener(resolved, listener);
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
resolved = href;
|
|
27
|
+
listener = null;
|
|
28
|
+
if (href === undefined) {
|
|
29
|
+
parentUrl.value = undefined;
|
|
24
30
|
}
|
|
25
31
|
else {
|
|
26
32
|
parentUrl.value = null;
|
|
27
|
-
resolved = router.resolve(to).href;
|
|
28
33
|
listener = (result) => { parentUrl.value = result; };
|
|
29
|
-
dFrameContent.addParentUrlListener(
|
|
34
|
+
dFrameContent.addParentUrlListener(href, listener);
|
|
30
35
|
}
|
|
31
36
|
}, { immediate: true });
|
|
32
37
|
onScopeDispose(() => {
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-fair/frame",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "An iframe wrapper for powerful web app integrations.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "lib/d-frame.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"doc": "doc"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@commitlint/config-conventional": "^19.6.0",
|
|
11
11
|
"@koumoul/gh-pages-multi": "^0.7.2",
|
|
12
|
+
"@playwright/test": "^1.64.1",
|
|
12
13
|
"commitlint": "^19.6.0",
|
|
13
14
|
"eslint": "^9.16.0",
|
|
14
15
|
"husky": "^9.1.7",
|
|
@@ -19,14 +20,16 @@
|
|
|
19
20
|
"vue-router": "^5.0.0"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
22
|
-
"check-types": "tsc",
|
|
23
|
+
"check-types": "tsc --noEmit && tsc -p tests",
|
|
23
24
|
"lint": "eslint .",
|
|
24
25
|
"lint:fix": "eslint . --fix",
|
|
25
26
|
"dev-zellij": "zellij --layout .zellij.kdl",
|
|
26
27
|
"prepare": "husky",
|
|
27
|
-
"test": "
|
|
28
|
-
"test:
|
|
29
|
-
"
|
|
28
|
+
"test": "playwright test && playwright test -c playwright.doc.config.ts",
|
|
29
|
+
"test:unit": "playwright test --project=unit",
|
|
30
|
+
"test:e2e": "playwright test --project=e2e",
|
|
31
|
+
"test:doc": "playwright test -c playwright.doc.config.ts",
|
|
32
|
+
"build": "find lib \\( -name '*.js' -o -name '*.d.ts' \\) -delete && tsc -p tsconfig.json && rm -rf dist && vite -c vite.config.d-frame.js build && vite -c vite.config.d-frame-content.js build && vite -c vite.config.v-iframe-compat-d-frame-content.js build",
|
|
30
33
|
"prepublishOnly": "npm run lint && npm run test && npm run build",
|
|
31
34
|
"publish:main": "cd doc && npm run build:main && cd .. && gh-pages-multi deploy -v -s doc/.output/public -t main",
|
|
32
35
|
"publish:latest": "cd doc && npm run build:latest && cd .. && gh-pages-multi deploy -v -s doc/.output/public -t latest"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Router as Router4, RouteLocationRaw as RouteLocationRaw4 } from 'vue-router';
|
|
2
|
-
type Router4Options = {
|
|
3
|
-
base?: string;
|
|
4
|
-
history?: {
|
|
5
|
-
base?: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
type Router5Options = {
|
|
9
|
-
base?: string;
|
|
10
|
-
};
|
|
11
|
-
export type Router = Router4 & {
|
|
12
|
-
options: Router4Options | Router5Options;
|
|
13
|
-
};
|
|
14
|
-
export type RouteLocationRaw = RouteLocationRaw4;
|
|
15
|
-
export declare function isRouter4(router: Router): router is Router4;
|
|
16
|
-
export declare function getRouterBase(router: Router): string | undefined;
|
|
17
|
-
export {};
|
package/lib/vue-router/util.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { RouteLocationRaw as RouteLocationRaw5 } from 'vue-router';
|
|
2
|
-
export type Router = {
|
|
3
|
-
options: {
|
|
4
|
-
base?: string;
|
|
5
|
-
history?: {
|
|
6
|
-
base?: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
push: (to: RouteLocationRaw5) => Promise<any>;
|
|
10
|
-
replace: (to: RouteLocationRaw5) => Promise<any>;
|
|
11
|
-
resolve: (to: RouteLocationRaw5) => {
|
|
12
|
-
href: string;
|
|
13
|
-
};
|
|
14
|
-
afterEach: (callback: () => any) => any;
|
|
15
|
-
};
|
|
16
|
-
export type RouteLocationRaw = RouteLocationRaw5;
|
|
17
|
-
export declare function getRouterBase(router: Router): string | undefined;
|
package/lib/vue-router/util.js
DELETED