@dotbase/safe-frame-sync 1.3.0 → 1.4.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.
@@ -0,0 +1,54 @@
1
+ export type MessageType = "editResource" | "createResource" | "closeBuilder" | "setBreadcrumbs" | "goToPatient" | "iframeRouteChange" | "sessionExpired";
2
+ export type WorkflowType = "document" | "patient-report";
3
+ export interface BreadcrumbItemType {
4
+ to: string;
5
+ label: string;
6
+ }
7
+ export interface BreadcrumbsType {
8
+ currentPage: string;
9
+ back?: BreadcrumbItemType;
10
+ links?: BreadcrumbItemType[];
11
+ }
12
+ export interface EditResourceType {
13
+ type: "editResource";
14
+ resourceId: string;
15
+ resourceName: string;
16
+ workflowType: WorkflowType;
17
+ }
18
+ export interface CreateResourceType {
19
+ type: "createResource";
20
+ resourceId: string;
21
+ resourceName: string;
22
+ workflowType: WorkflowType;
23
+ }
24
+ export interface CloseBuilderType {
25
+ type: "closeBuilder";
26
+ }
27
+ export interface SetBreadcrumbsType {
28
+ type: "setBreadcrumbs";
29
+ breadcrumbs: BreadcrumbsType;
30
+ }
31
+ export interface GoToPatientType {
32
+ type: "goToPatient";
33
+ patientId: string;
34
+ }
35
+ export interface IframeRouteChangeType {
36
+ type: "iframeRouteChange";
37
+ path: string;
38
+ }
39
+ export interface SessionExpiredType {
40
+ type: "sessionExpired";
41
+ }
42
+ export type MesssageDataType = EditResourceType | CreateResourceType | CloseBuilderType | SetBreadcrumbsType | GoToPatientType | IframeRouteChangeType | SessionExpiredType;
43
+ export interface MessageDataMapType {
44
+ editResource: EditResourceType;
45
+ createResource: CreateResourceType;
46
+ closeBuilder: CloseBuilderType;
47
+ setBreadcrumbs: SetBreadcrumbsType;
48
+ goToPatient: GoToPatientType;
49
+ iframeRouteChange: IframeRouteChangeType;
50
+ sessionExpired: SessionExpiredType;
51
+ }
52
+ export declare const publishMessage: (data: MesssageDataType, target?: Window) => void;
53
+ declare function subscribeMessage<T extends MessageType>(type: T, callback: (data: MessageDataMapType[T]) => void): void;
54
+ export { subscribeMessage };
@@ -0,0 +1,12 @@
1
+ const i = (s, e) => {
2
+ e !== void 0 && e.postMessage(s, "*"), window.top?.postMessage(s, "*");
3
+ };
4
+ function n(s, e) {
5
+ window.onmessage = function(o) {
6
+ o.data.type === s && e(o.data);
7
+ };
8
+ }
9
+ export {
10
+ i as publishMessage,
11
+ n as subscribeMessage
12
+ };
@@ -0,0 +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,n)=>{n!==void 0&&n.postMessage(i,"*"),window.top?.postMessage(i,"*")};function t(i,n){window.onmessage=function(o){o.data.type===i&&n(o.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.3.0",
3
+ "version": "1.4.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",