@dotbase/safe-frame-sync 1.1.0 → 1.2.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type MessageType = "editResource" | "createResource" | "closeBuilder" | "setBreadcrumbs" | "goToPatient";
1
+ export type MessageType = "editResource" | "createResource" | "closeBuilder" | "setBreadcrumbs" | "goToPatient" | "iframeRouteChange";
2
2
  export type WorkflowType = "document" | "patient-report";
3
3
  export interface BreadcrumbItemType {
4
4
  to: string;
@@ -32,18 +32,19 @@ export interface GoToPatientType {
32
32
  type: "goToPatient";
33
33
  patientId: string;
34
34
  }
35
- export type MesssageDataType = EditResourceType | CreateResourceType | CloseBuilderType | SetBreadcrumbsType | GoToPatientType;
35
+ export interface IframeRouteChangeType {
36
+ type: "iframeRouteChange";
37
+ path: string;
38
+ }
39
+ export type MesssageDataType = EditResourceType | CreateResourceType | CloseBuilderType | SetBreadcrumbsType | GoToPatientType | IframeRouteChangeType;
36
40
  export interface MessageDataMapType {
37
41
  editResource: EditResourceType;
38
42
  createResource: CreateResourceType;
39
43
  closeBuilder: CloseBuilderType;
40
44
  setBreadcrumbs: SetBreadcrumbsType;
41
45
  goToPatient: GoToPatientType;
46
+ iframeRouteChange: IframeRouteChangeType;
42
47
  }
43
- export declare const publishMessage: (data: MesssageDataType) => void;
44
- declare function subscribeMessage(type: "goToPatient", callback: (data: MessageDataMapType["goToPatient"]) => void): void;
45
- declare function subscribeMessage(type: "setBreadcrumbs", callback: (data: MessageDataMapType["setBreadcrumbs"]) => void): void;
46
- declare function subscribeMessage(type: "closeBuilder", callback: (data: MessageDataMapType["closeBuilder"]) => void): void;
47
- declare function subscribeMessage(type: "editResource", callback: (data: MessageDataMapType["editResource"]) => void): void;
48
- declare function subscribeMessage(type: "createResource", callback: (data: MessageDataMapType["createResource"]) => void): void;
48
+ export declare const publishMessage: (data: MesssageDataType, target?: Window) => void;
49
+ declare function subscribeMessage<T extends MessageType>(type: T, callback: (data: MessageDataMapType[T]) => void): void;
49
50
  export { subscribeMessage };
package/dist/index.es.js CHANGED
@@ -1,13 +1,13 @@
1
- const t = (e) => {
1
+ const i = (e, o) => {
2
2
  var s;
3
- (s = window.top) == null || s.postMessage(e, "*");
3
+ o !== void 0 && o.postMessage(e, "*"), (s = window.top) == null || s.postMessage(e, "*");
4
4
  };
5
- function a(e, s) {
6
- window.onmessage = function(o) {
7
- o.data.type === e && s(o.data);
5
+ function n(e, o) {
6
+ window.onmessage = function(s) {
7
+ s.data.type === e && o(s.data);
8
8
  };
9
9
  }
10
10
  export {
11
- t as publishMessage,
12
- a as subscribeMessage
11
+ i as publishMessage,
12
+ n as subscribeMessage
13
13
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(e,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(e=typeof globalThis<"u"?globalThis:e||self,s(e["safe-frame-sync"]={}))})(this,function(e){"use strict";const s=i=>{var n;(n=window.top)==null||n.postMessage(i,"*")};function o(i,n){window.onmessage=function(t){t.data.type===i&&n(t.data)}}e.publishMessage=s,e.subscribeMessage=o,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ (function(e,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(e=typeof globalThis<"u"?globalThis:e||self,s(e["safe-frame-sync"]={}))})(this,function(e){"use strict";const s=(n,o)=>{var i;o!==void 0&&o.postMessage(n,"*"),(i=window.top)==null||i.postMessage(n,"*")};function t(n,o){window.onmessage=function(i){i.data.type===n&&o(i.data)}}e.publishMessage=s,e.subscribeMessage=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotbase/safe-frame-sync",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Typesafe iframe and parent communication between Dotstudio and Dotclinic",
5
5
  "homepage": "https://github.com/dot-base/safe-frame-sync",
6
6
  "types": "dist/index.d.ts",