@data-fair/frame 0.17.3 → 0.17.5
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import type { RouteLocationRaw, Router } from 'vue-router';
|
|
3
3
|
import type DFrameContent from '../DFrameContent.js';
|
|
4
|
-
export declare const useParentUrl: (location: MaybeRefOrGetter<RouteLocationRaw>, router: Router, dFrameContent?: DFrameContent) => import("vue").ComputedRef<string> | import("vue").Ref<string | null, string | null>;
|
|
4
|
+
export declare const useParentUrl: (location: MaybeRefOrGetter<RouteLocationRaw | undefined>, router: Router, dFrameContent?: DFrameContent) => import("vue").ComputedRef<string | undefined> | import("vue").Ref<string | null | undefined, string | null | undefined>;
|
|
5
5
|
export default useParentUrl;
|
|
@@ -2,9 +2,15 @@ import { onScopeDispose } from 'vue';
|
|
|
2
2
|
import { useVueRouterDFrameContent } from './d-frame-content.js';
|
|
3
3
|
import { toValue, ref, watch, computed } from 'vue';
|
|
4
4
|
import inIframe from '../utils/in-iframe.js';
|
|
5
|
+
const ssr = typeof window === 'undefined';
|
|
5
6
|
export const useParentUrl = (location, router, dFrameContent) => {
|
|
6
|
-
if (!inIframe) {
|
|
7
|
-
return computed(() =>
|
|
7
|
+
if (ssr || !inIframe) {
|
|
8
|
+
return computed(() => {
|
|
9
|
+
const to = toValue(location);
|
|
10
|
+
if (to === undefined)
|
|
11
|
+
return to;
|
|
12
|
+
return router.resolve(to).href;
|
|
13
|
+
});
|
|
8
14
|
}
|
|
9
15
|
dFrameContent = dFrameContent ?? useVueRouterDFrameContent();
|
|
10
16
|
let resolved = null;
|
|
@@ -13,10 +19,15 @@ export const useParentUrl = (location, router, dFrameContent) => {
|
|
|
13
19
|
watch(() => toValue(location), (to) => {
|
|
14
20
|
if (listener && resolved)
|
|
15
21
|
dFrameContent.removeParentUrlListener(resolved, listener);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
if (to === undefined) {
|
|
23
|
+
parentUrl.value = to;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
parentUrl.value = null;
|
|
27
|
+
resolved = router.resolve(to).href;
|
|
28
|
+
listener = (result) => { parentUrl.value = result; };
|
|
29
|
+
dFrameContent.addParentUrlListener(resolved, listener);
|
|
30
|
+
}
|
|
20
31
|
}, { immediate: true });
|
|
21
32
|
onScopeDispose(() => {
|
|
22
33
|
if (listener && resolved)
|