@data-fair/frame 0.18.1 → 0.18.2
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/v-iframe-compat/d-frame-content.min.js +1 -1
- package/lib/v-iframe-compat/d-frame-content.d.ts +1 -1
- package/lib/vue/use-parent-urls.d.ts +1 -1
- package/lib/vue-router/d-frame-content.d.ts +1 -1
- package/lib/vue-router/router-type.d.ts +17 -0
- package/lib/vue-router/router-type.js +7 -0
- package/lib/vue-router/state-change-adapter.d.ts +1 -1
- package/lib/vue-router/use-parent-url.d.ts +1 -1
- package/lib/vue-router/util.d.ts +16 -1
- package/lib/vue-router/util.js +1 -2
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var VIframeCompatDFrameContent=function(){"use strict";var y=Object.defineProperty;var M=(c,h,l)=>h in c?y(c,h,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[h]=l;var a=(c,h,l)=>M(c,typeof h!="symbol"?h+"":h,l);function c(n){return n[0]==="df-global"&&n[1]==="mouse"}function h(n){return n[0]==="df-parent"&&n[1]==="init"}function l(n){return n[0]==="df-parent"&&n[1]==="updateSrc"}function u(n){return n[0]==="df-parent"&&n[1]==="parentUrl"}const w=(()=>{try{return window.top!==window.self}catch{return!0}})(),g=["animationstart","webkitAnimationStart","animationiteration","webkitAnimationIteration","animationend","webkitAnimationEnd","input","mouseup","mousedown","orientationchange","afterprint","beforeprint","readystatechange","touchstart","touchend","touchcancel","transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart","transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration","transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend","resize"];class p{constructor(e){a(this,"initialized",!1);a(this,"options");a(this,"pendingCheckHeight",!1);a(this,"debug",!1);a(this,"id");a(this,"throttledCheckHeight");a(this,"lastHeight",0);a(this,"parentUrlListeners",{});a(this,"parentUrlResults",{});a(this,"currentSyncedMouseEvents",new Set);if(this.options=e??{},typeof window>"u")return;if(window.__d_frame__content)throw new Error("DFrameContent was already initialized");window.__d_frame__content=this;const t=()=>{this.checkHeight(),this.pendingCheckHeight=!1};this.throttledCheckHeight=()=>{this.pendingCheckHeight||(this.pendingCheckHeight=!0,requestAnimationFrame(t))},window.addEventListener("message",i=>this.onMessage(i)),this.postMessageToParent(["df-child","init"])}log(e,...t){e==="debug"&&!this.debug||(e==="debug"&&console.timeLog(`d-frame:${this.id}:content`,...t),e==="info"&&console.info(`d-frame:${this.id}:content`,...t),e==="error"&&console.error(`d-frame:${this.id}:content`,...t))}onMessage(e){if(e.source===window.parent&&Array.isArray(e.data)){const t=e.data;if(h(t)&&(this.id=t[2].id,this.debug=!!t[2].debug,this.debug&&console.time(`d-frame:${this.id}:content`),this.log("debug","init handshake is ok",t,this.options),t[2].src&&t[2].src!==window.location.href&&this.log("error",`src mismatch at init, maybe the frame navigated before the initialization handshake: ${window.location.href} !== ${t[2].src}`),t[2].resize!=="no"&&this.initResize(),(t[2].syncParams||t[2].syncPath||t[2].stateChangeEvents)&&this.initStateChangeWatcher(),t[2].mouseEvents&&this.initMouseEvents(t[2].mouseEvents),this.initialized=!0),l(t)){const i=t[2].startsWith("/")?window.location.origin+t[2]:t[2];if(i===window.location.href)return;this.log("debug",`update src ${window.location.href} -> ${i}`),this.options.updateSrc?this.options.updateSrc(i,this):(this.log("debug","no updateSrc method available, falling back to updating window.location.href",i),window.location.href=i)}if(c(t)&&this.applySyncedMouseEvent(t),u(t))if(!this.parentUrlListeners[t[2]])this.log("error",`received getParentUrlResponse message but no matching callback is registered: ${t[2]}`);else for(const i of this.parentUrlListeners[t[2]])i(t[3])}}postMessageToParent(e){window.parent.postMessage(e,"*")}sendNotif(e){this.postMessageToParent(["df-child","notif",e])}sendMessage(e){this.postMessageToParent(["df-child","custom",e])}ready(){this.postMessageToParent(["df-child","ready"])}reinitHeight(){this.postMessageToParent(["df-child","reinit-height"])}addParentUrlListener(e,t){const i=new URL(e,window.location.href).href;if(!w){t(i);return}this.parentUrlResults[i]&&t(this.parentUrlResults[i]),this.parentUrlListeners[i]=this.parentUrlListeners[i]??[],this.parentUrlListeners[i].push(t),this.postMessageToParent(["df-child","addParentUrlListener",i])}removeParentUrlListener(e,t){const i=new URL(e,window.location.href).href;this.parentUrlListeners[i]&&(this.parentUrlListeners[i]=this.parentUrlListeners[i].filter(o=>o!==t),this.parentUrlListeners[i].length||(delete this.parentUrlListeners[i],this.postMessageToParent(["df-child","removeParentUrlListener",i])))}initMouseEvents(e){this.log("debug","initMouseEvents");for(const t of e)document.addEventListener(t,i=>{i instanceof MouseEvent&&this.transmitSyncedMouseEvent(["df-global","mouse",t,{altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}])},!0)}transmitSyncedMouseEvent(e){this.currentSyncedMouseEvents.has(e[2])?this.currentSyncedMouseEvents.delete(e[2]):this.postMessageToParent(e)}applySyncedMouseEvent(e){this.currentSyncedMouseEvents.add(e[2]);const t=new MouseEvent(e[2],{bubbles:!0,cancelable:!0,view:window,...e[3]});document.body.dispatchEvent(t)}initResize(){this.log("debug","initResize"),this.checkHeight(),this.createMutationObserver(),this.createWindowEventListeners()}initStateChangeWatcher(){this.log("debug","initStateChangeWatcher");const e=window.history.replaceState,t=(...o)=>{const r=window.location.href,s=e.apply(window.history,o);return window.location.href!==r&&this.postMessageToParent(["df-child","stateChange","push",window.location.href]),s};window.history.pushState=t;const i=(...o)=>{const r=window.location.href,s=e.apply(window.history,o);return window.location.href!==r&&this.postMessageToParent(["df-child","stateChange","replace",window.location.href]),s};window.history.replaceState=i}createMutationObserver(){const e=document.querySelector("body");if(!e)throw new Error("DFrameContentManager was initialized before the HTML body");if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");new window.MutationObserver(this.throttledCheckHeight).observe(e,{attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0})}createWindowEventListeners(){if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");for(const e of g)window.addEventListener(e,this.throttledCheckHeight,{passive:!0})}checkHeight(){const e=document.querySelectorAll("[data-iframe-height]");let t=0,i=0;for(const o of e){const r=o.getAttribute("data-iframe-height");if(r==="false"||r==="no")continue;const s=o.getBoundingClientRect().bottom+parseFloat(getComputedStyle(o).getPropertyValue("margin-bottom")),d=r?s+parseFloat(r):s;s>t&&(t=s),d>i&&(i=d)}i=Math.ceil(i),t>0&&i!==this.lastHeight&&(this.postMessageToParent(["df-child","height",i]),this.lastHeight=i)}}const b=(n,e)=>{const t=Object.keys(n);e.forEach((i,o)=>{n[o]=i,t.splice(t.indexOf(o),1)}),t.forEach(i=>{delete n[i]})};function m(n){var
|
|
1
|
+
var VIframeCompatDFrameContent=function(){"use strict";var y=Object.defineProperty;var M=(c,h,l)=>h in c?y(c,h,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[h]=l;var a=(c,h,l)=>M(c,typeof h!="symbol"?h+"":h,l);function c(n){return n[0]==="df-global"&&n[1]==="mouse"}function h(n){return n[0]==="df-parent"&&n[1]==="init"}function l(n){return n[0]==="df-parent"&&n[1]==="updateSrc"}function u(n){return n[0]==="df-parent"&&n[1]==="parentUrl"}const w=(()=>{try{return window.top!==window.self}catch{return!0}})(),g=["animationstart","webkitAnimationStart","animationiteration","webkitAnimationIteration","animationend","webkitAnimationEnd","input","mouseup","mousedown","orientationchange","afterprint","beforeprint","readystatechange","touchstart","touchend","touchcancel","transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart","transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration","transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend","resize"];class p{constructor(e){a(this,"initialized",!1);a(this,"options");a(this,"pendingCheckHeight",!1);a(this,"debug",!1);a(this,"id");a(this,"throttledCheckHeight");a(this,"lastHeight",0);a(this,"parentUrlListeners",{});a(this,"parentUrlResults",{});a(this,"currentSyncedMouseEvents",new Set);if(this.options=e??{},typeof window>"u")return;if(window.__d_frame__content)throw new Error("DFrameContent was already initialized");window.__d_frame__content=this;const t=()=>{this.checkHeight(),this.pendingCheckHeight=!1};this.throttledCheckHeight=()=>{this.pendingCheckHeight||(this.pendingCheckHeight=!0,requestAnimationFrame(t))},window.addEventListener("message",i=>this.onMessage(i)),this.postMessageToParent(["df-child","init"])}log(e,...t){e==="debug"&&!this.debug||(e==="debug"&&console.timeLog(`d-frame:${this.id}:content`,...t),e==="info"&&console.info(`d-frame:${this.id}:content`,...t),e==="error"&&console.error(`d-frame:${this.id}:content`,...t))}onMessage(e){if(e.source===window.parent&&Array.isArray(e.data)){const t=e.data;if(h(t)&&(this.id=t[2].id,this.debug=!!t[2].debug,this.debug&&console.time(`d-frame:${this.id}:content`),this.log("debug","init handshake is ok",t,this.options),t[2].src&&t[2].src!==window.location.href&&this.log("error",`src mismatch at init, maybe the frame navigated before the initialization handshake: ${window.location.href} !== ${t[2].src}`),t[2].resize!=="no"&&this.initResize(),(t[2].syncParams||t[2].syncPath||t[2].stateChangeEvents)&&this.initStateChangeWatcher(),t[2].mouseEvents&&this.initMouseEvents(t[2].mouseEvents),this.initialized=!0),l(t)){const i=t[2].startsWith("/")?window.location.origin+t[2]:t[2];if(i===window.location.href)return;this.log("debug",`update src ${window.location.href} -> ${i}`),this.options.updateSrc?this.options.updateSrc(i,this):(this.log("debug","no updateSrc method available, falling back to updating window.location.href",i),window.location.href=i)}if(c(t)&&this.applySyncedMouseEvent(t),u(t))if(!this.parentUrlListeners[t[2]])this.log("error",`received getParentUrlResponse message but no matching callback is registered: ${t[2]}`);else for(const i of this.parentUrlListeners[t[2]])i(t[3])}}postMessageToParent(e){window.parent.postMessage(e,"*")}sendNotif(e){this.postMessageToParent(["df-child","notif",e])}sendMessage(e){this.postMessageToParent(["df-child","custom",e])}ready(){this.postMessageToParent(["df-child","ready"])}reinitHeight(){this.postMessageToParent(["df-child","reinit-height"])}addParentUrlListener(e,t){const i=new URL(e,window.location.href).href;if(!w){t(i);return}this.parentUrlResults[i]&&t(this.parentUrlResults[i]),this.parentUrlListeners[i]=this.parentUrlListeners[i]??[],this.parentUrlListeners[i].push(t),this.postMessageToParent(["df-child","addParentUrlListener",i])}removeParentUrlListener(e,t){const i=new URL(e,window.location.href).href;this.parentUrlListeners[i]&&(this.parentUrlListeners[i]=this.parentUrlListeners[i].filter(o=>o!==t),this.parentUrlListeners[i].length||(delete this.parentUrlListeners[i],this.postMessageToParent(["df-child","removeParentUrlListener",i])))}initMouseEvents(e){this.log("debug","initMouseEvents");for(const t of e)document.addEventListener(t,i=>{i instanceof MouseEvent&&this.transmitSyncedMouseEvent(["df-global","mouse",t,{altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}])},!0)}transmitSyncedMouseEvent(e){this.currentSyncedMouseEvents.has(e[2])?this.currentSyncedMouseEvents.delete(e[2]):this.postMessageToParent(e)}applySyncedMouseEvent(e){this.currentSyncedMouseEvents.add(e[2]);const t=new MouseEvent(e[2],{bubbles:!0,cancelable:!0,view:window,...e[3]});document.body.dispatchEvent(t)}initResize(){this.log("debug","initResize"),this.checkHeight(),this.createMutationObserver(),this.createWindowEventListeners()}initStateChangeWatcher(){this.log("debug","initStateChangeWatcher");const e=window.history.replaceState,t=(...o)=>{const r=window.location.href,s=e.apply(window.history,o);return window.location.href!==r&&this.postMessageToParent(["df-child","stateChange","push",window.location.href]),s};window.history.pushState=t;const i=(...o)=>{const r=window.location.href,s=e.apply(window.history,o);return window.location.href!==r&&this.postMessageToParent(["df-child","stateChange","replace",window.location.href]),s};window.history.replaceState=i}createMutationObserver(){const e=document.querySelector("body");if(!e)throw new Error("DFrameContentManager was initialized before the HTML body");if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");new window.MutationObserver(this.throttledCheckHeight).observe(e,{attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0})}createWindowEventListeners(){if(!this.throttledCheckHeight)throw new Error("throttledCheckHeight is not defined");for(const e of g)window.addEventListener(e,this.throttledCheckHeight,{passive:!0})}checkHeight(){const e=document.querySelectorAll("[data-iframe-height]");let t=0,i=0;for(const o of e){const r=o.getAttribute("data-iframe-height");if(r==="false"||r==="no")continue;const s=o.getBoundingClientRect().bottom+parseFloat(getComputedStyle(o).getPropertyValue("margin-bottom")),d=r?s+parseFloat(r):s;s>t&&(t=s),d>i&&(i=d)}i=Math.ceil(i),t>0&&i!==this.lastHeight&&(this.postMessageToParent(["df-child","height",i]),this.lastHeight=i)}}const b=(n,e)=>{const t=Object.keys(n);e.forEach((i,o)=>{n[o]=i,t.splice(t.indexOf(o),1)}),t.forEach(i=>{delete n[i]})};function m(n){var e;return n.options.base??((e=n.options.history)==null?void 0:e.base)}const f=new p({updateSrc(n,e){const t=window.vIframeOptions,i=t==null?void 0:t.reactiveParams;if(i&&typeof i=="object"){const r=new URL(n);if(r.origin===window.location.origin&&r.pathname===window.location.pathname){e.log("debug","applying reactive params",r.searchParams),b(i,r.searchParams);return}}const o=t==null?void 0:t.router;if(o){const r=m(o);if(r==null)e.log("error","failed to access base path in router (no router.options.base nor router.options.history.base)",o);else{const s=window.location.origin+r;if(!n.startsWith(s))e.log("info","src does not start with base path",n,s);else{let d=n.replace(s,"");d.startsWith("/")||(d="/"+d),e.log("debug","applying router.replace",d),o.replace(d);return}}}e.log("info","falling back to updating window.location.href",n),window.location.href=n}});return window.dFrameContent=f,f}();
|
|
2
2
|
//# sourceMappingURL=d-frame-content.min.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
2
|
import type DFrameContent from '../DFrameContent.js';
|
|
3
|
-
import type { Router } from 'vue-router';
|
|
3
|
+
import type { Router } from '../vue-router/router-type.js';
|
|
4
4
|
export declare const useDFrameParentUrls: (dFrameContent: DFrameContent, router?: Router) => {
|
|
5
5
|
get: (childHref: string) => Ref<string | undefined>;
|
|
6
6
|
clear: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type App } from 'vue';
|
|
2
2
|
import DFrameContent, { type DFrameContentOptions } from '../DFrameContent.js';
|
|
3
|
-
import type { Router } from '
|
|
3
|
+
import type { Router } from './util.js';
|
|
4
4
|
type VueRouterDFrameContentOptions = Omit<DFrameContentOptions, 'updateSrc'>;
|
|
5
5
|
export declare function vueRouterDFrameContent(router: Router, options?: VueRouterDFrameContentOptions): DFrameContent;
|
|
6
6
|
export declare const vueRouterDFrameContentKey: unique symbol;
|
|
@@ -0,0 +1,17 @@
|
|
|
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 {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DFrameElement, type StateChangeAdapter } from '../DFrameElement.js';
|
|
2
|
-
import type { Router } from '
|
|
2
|
+
import type { Router } from './util.js';
|
|
3
3
|
declare class VueRouterDFrameStateChangeAdapter implements StateChangeAdapter {
|
|
4
4
|
router: Router;
|
|
5
5
|
constructor(router: Router);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Router, RouteLocationRaw } from './router-type.js';
|
|
3
3
|
import type DFrameContent from '../DFrameContent.js';
|
|
4
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;
|
package/lib/vue-router/util.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import type {
|
|
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<void>;
|
|
10
|
+
replace: (to: RouteLocationRaw5) => Promise<void>;
|
|
11
|
+
resolve: (to: RouteLocationRaw5) => {
|
|
12
|
+
href: string;
|
|
13
|
+
};
|
|
14
|
+
afterEach: (callback: () => void) => void;
|
|
15
|
+
};
|
|
16
|
+
export type RouteLocationRaw = RouteLocationRaw5;
|
|
2
17
|
export declare function getRouterBase(router: Router): string | undefined;
|
package/lib/vue-router/util.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-fair/frame",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "An iframe wrapper for powerful web app integrations.",
|
|
5
5
|
"main": "dist/frame.min.js",
|
|
6
6
|
"directories": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"typescript": "^5.7.2",
|
|
17
17
|
"vite": "^6.0.3",
|
|
18
18
|
"vue": "^3.5.13",
|
|
19
|
-
"vue-router": "^
|
|
19
|
+
"vue-router": "^5.0.0"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"check-types": "tsc",
|