@dotbase/safe-frame-sync 1.0.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/README.md +3 -7
- package/dist/index.d.ts +28 -6
- package/dist/index.es.js +7 -7
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,7 +27,9 @@ npm run build
|
|
|
27
27
|
The package is published on npmjs.
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
npm
|
|
30
|
+
npm run build
|
|
31
|
+
npm login
|
|
32
|
+
npm publish --access public
|
|
31
33
|
```
|
|
32
34
|
|
|
33
35
|
## Usage
|
|
@@ -43,12 +45,6 @@ The package provides two essential functions:
|
|
|
43
45
|
* `publishMessage` for sending typed messages
|
|
44
46
|
* `subscribeMessage` for listening to specific typed messages
|
|
45
47
|
|
|
46
|
-
Currently there are three message types and each of them specifies a data interface:
|
|
47
|
-
|
|
48
|
-
* `editResource`
|
|
49
|
-
* `createResource`
|
|
50
|
-
* `closeBuilder`
|
|
51
|
-
|
|
52
48
|
### Message Types
|
|
53
49
|
|
|
54
50
|
### In Parent
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
export type MessageType = "editResource" | "createResource" | "closeBuilder";
|
|
1
|
+
export type MessageType = "editResource" | "createResource" | "closeBuilder" | "setBreadcrumbs" | "goToPatient" | "iframeRouteChange";
|
|
2
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
|
+
}
|
|
3
12
|
export interface EditResourceType {
|
|
4
13
|
type: "editResource";
|
|
5
14
|
resourceId: string;
|
|
@@ -15,14 +24,27 @@ export interface CreateResourceType {
|
|
|
15
24
|
export interface CloseBuilderType {
|
|
16
25
|
type: "closeBuilder";
|
|
17
26
|
}
|
|
18
|
-
export
|
|
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 type MesssageDataType = EditResourceType | CreateResourceType | CloseBuilderType | SetBreadcrumbsType | GoToPatientType | IframeRouteChangeType;
|
|
19
40
|
export interface MessageDataMapType {
|
|
20
41
|
editResource: EditResourceType;
|
|
21
42
|
createResource: CreateResourceType;
|
|
22
43
|
closeBuilder: CloseBuilderType;
|
|
44
|
+
setBreadcrumbs: SetBreadcrumbsType;
|
|
45
|
+
goToPatient: GoToPatientType;
|
|
46
|
+
iframeRouteChange: IframeRouteChangeType;
|
|
23
47
|
}
|
|
24
|
-
export declare const publishMessage: (data: MesssageDataType) => void;
|
|
25
|
-
declare function subscribeMessage(type:
|
|
26
|
-
declare function subscribeMessage(type: "editResource", callback: (data: MessageDataMapType["editResource"]) => void): void;
|
|
27
|
-
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;
|
|
28
50
|
export { subscribeMessage };
|
package/dist/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
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
|
|
6
|
-
window.onmessage = function(
|
|
7
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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=
|
|
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