@data-fair/frame 0.15.1 → 0.16.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.
@@ -4,5 +4,6 @@ import type { Router } from 'vue-router';
4
4
  export declare const useDFrameParentUrls: (dFrameContent: DFrameContent, router?: Router) => {
5
5
  get: (childHref: string) => Ref<string | undefined>;
6
6
  clear: () => void;
7
+ parentUrls: Record<string, string | null>;
7
8
  };
8
9
  export default useDFrameParentUrls;
@@ -1,27 +1,27 @@
1
- import { onScopeDispose, ref } from 'vue';
1
+ import { onScopeDispose, toRef, reactive } from 'vue';
2
2
  export const useDFrameParentUrls = (dFrameContent, router) => {
3
- let computedParentUrls = {};
3
+ let parentUrls = reactive({});
4
4
  let listeners = {};
5
5
  const get = (childHref) => {
6
- if (computedParentUrls[childHref])
7
- return computedParentUrls[childHref];
8
- const resolvedChildHref = router ? router.resolve(childHref).href : childHref;
9
- const parentUrl = computedParentUrls[childHref] = ref();
10
- const listener = (result) => {
11
- parentUrl.value = result;
12
- };
13
- listeners[resolvedChildHref] = listener;
14
- dFrameContent.addParentUrlListener(resolvedChildHref, listener);
15
- return parentUrl;
6
+ if (parentUrls[childHref] === undefined) {
7
+ const resolvedChildHref = router ? router.resolve(childHref).href : childHref;
8
+ parentUrls[childHref] = null;
9
+ const listener = (result) => {
10
+ parentUrls[childHref] = result;
11
+ };
12
+ listeners[resolvedChildHref] = listener;
13
+ dFrameContent.addParentUrlListener(resolvedChildHref, listener);
14
+ }
15
+ return toRef(() => parentUrls[childHref] ?? undefined);
16
16
  };
17
17
  const clear = () => {
18
18
  for (const [resolvedChildHref, listener] of Object.entries(listeners)) {
19
19
  dFrameContent.removeParentUrlListener(resolvedChildHref, listener);
20
20
  }
21
- computedParentUrls = {};
21
+ parentUrls = {};
22
22
  listeners = {};
23
23
  };
24
24
  onScopeDispose(clear);
25
- return { get, clear };
25
+ return { get, clear, parentUrls };
26
26
  };
27
27
  export default useDFrameParentUrls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/frame",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "An iframe wrapper for powerful web app integrations.",
5
5
  "main": "dist/frame.min.js",
6
6
  "directories": {