@dotbase/safe-frame-sync 1.3.0 → 1.5.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # safe-frame-sync
2
2
 
3
- Typesafe iframe and parent communication between Dotstudio and Dotclinic.
3
+ Typesafe iframe and parent communication between Frontend and Dotclinic.
4
4
 
5
5
  This library provides a **Pub/Sub** system for secure, typesafe communication between a parent host and an iframe, abstracting `window.top.postMessage` and `window.onmessage`. Events and corresponding payloads are typed to ensure error-free communication and improve developer experience.
6
6
 
@@ -0,0 +1,58 @@
1
+ export type MessageType = "editResource" | "createResource" | "closeBuilder" | "setBreadcrumbs" | "goToPatient" | "iframeRouteChange" | "sessionExpired" | "iframeReady";
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 interface IframeReadyType {
43
+ type: "iframeReady";
44
+ }
45
+ export type MesssageDataType = EditResourceType | CreateResourceType | CloseBuilderType | SetBreadcrumbsType | GoToPatientType | IframeRouteChangeType | SessionExpiredType | IframeReadyType;
46
+ export interface MessageDataMapType {
47
+ editResource: EditResourceType;
48
+ createResource: CreateResourceType;
49
+ closeBuilder: CloseBuilderType;
50
+ setBreadcrumbs: SetBreadcrumbsType;
51
+ goToPatient: GoToPatientType;
52
+ iframeRouteChange: IframeRouteChangeType;
53
+ sessionExpired: SessionExpiredType;
54
+ iframeReady: IframeReadyType;
55
+ }
56
+ export declare const publishMessage: (data: MesssageDataType, target?: Window) => void;
57
+ declare function subscribeMessage<T extends MessageType>(type: T, callback: (data: MessageDataMapType[T]) => void): void;
58
+ 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.5.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",
@@ -27,18 +27,18 @@
27
27
  "typecheck": "tsc --noEmit --incremental --tsBuildInfoFile .cache/tsbuildinfo"
28
28
  },
29
29
  "devDependencies": {
30
- "@eslint/js": "^9.39.1",
31
- "@types/node": "^24.10.0",
32
- "eslint": "^9.39.1",
33
- "eslint-config-prettier": "^10.1.8",
34
- "globals": "^16.5.0",
35
- "jsdom": "^27.1.0",
36
- "prettier": "3.6.2",
37
- "typescript": "^5.9.3",
38
- "vitest": "^4.0.8",
39
- "typescript-eslint": "^8.46.3",
40
- "vite": "^7.2.2",
41
- "vite-plugin-dts": "^4.5.4"
30
+ "@eslint/js": "9.39.2",
31
+ "@types/node": "25.0.10",
32
+ "eslint": "9.39.2",
33
+ "eslint-config-prettier": "10.1.8",
34
+ "globals": "17.2.0",
35
+ "jsdom": "27.4.0",
36
+ "prettier": "3.8.1",
37
+ "typescript": "5.9.3",
38
+ "vitest": "4.0.18",
39
+ "typescript-eslint": "8.54.0",
40
+ "vite": "7.3.1",
41
+ "vite-plugin-dts": "4.5.4"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",