rx-postmessenger 2.0.1 → 4.0.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/LICENSE +2 -2
- package/README.md +83 -63
- package/{esm → dist}/MessageFactory.d.ts +1 -3
- package/dist/MessageFactory.js +34 -0
- package/{cjs → dist}/MessageIDGenerator.d.ts +1 -1
- package/dist/MessageIDGenerator.js +19 -0
- package/{cjs → dist}/MessageValidator.d.ts +3 -4
- package/{esm → dist}/MessageValidator.js +19 -20
- package/dist/Messenger.d.ts +52 -0
- package/dist/Messenger.js +79 -0
- package/{cjs → dist}/PostmessageAdapter.d.ts +1 -2
- package/dist/PostmessageAdapter.js +11 -0
- package/dist/RxPostmessengerRequest.d.ts +11 -0
- package/dist/RxPostmessengerRequest.js +23 -0
- package/dist/functions/GUIDGenerator.d.ts +1 -0
- package/dist/functions/GUIDGenerator.js +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -0
- package/dist/public-api.d.ts +55 -0
- package/dist/public-api.js +1 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.js +1 -0
- package/package.json +39 -47
- package/CHANGELOG.md +0 -159
- package/cjs/MessageFactory.d.ts +0 -11
- package/cjs/MessageFactory.js +0 -38
- package/cjs/MessageFactory.js.map +0 -1
- package/cjs/MessageIDGenerator.js +0 -24
- package/cjs/MessageIDGenerator.js.map +0 -1
- package/cjs/MessageValidator.js +0 -44
- package/cjs/MessageValidator.js.map +0 -1
- package/cjs/Messenger.d.ts +0 -99
- package/cjs/Messenger.js +0 -116
- package/cjs/Messenger.js.map +0 -1
- package/cjs/PostmessageAdapter.js +0 -14
- package/cjs/PostmessageAdapter.js.map +0 -1
- package/cjs/RxPostmessengerRequest.d.ts +0 -10
- package/cjs/RxPostmessengerRequest.js +0 -23
- package/cjs/RxPostmessengerRequest.js.map +0 -1
- package/cjs/functions/GUIDGenerator.d.ts +0 -1
- package/cjs/functions/GUIDGenerator.js +0 -59
- package/cjs/functions/GUIDGenerator.js.map +0 -1
- package/cjs/index.d.ts +0 -4
- package/cjs/index.js +0 -20
- package/cjs/index.js.map +0 -1
- package/cjs/interface/id-generator.d.ts +0 -11
- package/cjs/interface/id-generator.js +0 -3
- package/cjs/interface/id-generator.js.map +0 -1
- package/cjs/interface/message-factory.d.ts +0 -7
- package/cjs/interface/message-factory.js +0 -3
- package/cjs/interface/message-factory.js.map +0 -1
- package/cjs/interface/message-objects.d.ts +0 -30
- package/cjs/interface/message-objects.js +0 -3
- package/cjs/interface/message-objects.js.map +0 -1
- package/cjs/interface/message-validator.d.ts +0 -7
- package/cjs/interface/message-validator.js +0 -3
- package/cjs/interface/message-validator.js.map +0 -1
- package/cjs/interface/postmessage-adapter.d.ts +0 -6
- package/cjs/interface/postmessage-adapter.js +0 -3
- package/cjs/interface/postmessage-adapter.js.map +0 -1
- package/cjs/interface/public-interface.d.ts +0 -4
- package/cjs/interface/public-interface.js +0 -3
- package/cjs/interface/public-interface.js.map +0 -1
- package/esm/MessageFactory.js +0 -36
- package/esm/MessageFactory.js.map +0 -1
- package/esm/MessageIDGenerator.d.ts +0 -8
- package/esm/MessageIDGenerator.js +0 -22
- package/esm/MessageIDGenerator.js.map +0 -1
- package/esm/MessageValidator.d.ts +0 -30
- package/esm/MessageValidator.js.map +0 -1
- package/esm/Messenger.d.ts +0 -99
- package/esm/Messenger.js +0 -114
- package/esm/Messenger.js.map +0 -1
- package/esm/PostmessageAdapter.d.ts +0 -8
- package/esm/PostmessageAdapter.js +0 -12
- package/esm/PostmessageAdapter.js.map +0 -1
- package/esm/RxPostmessengerRequest.d.ts +0 -10
- package/esm/RxPostmessengerRequest.js +0 -21
- package/esm/RxPostmessengerRequest.js.map +0 -1
- package/esm/functions/GUIDGenerator.d.ts +0 -1
- package/esm/functions/GUIDGenerator.js +0 -56
- package/esm/functions/GUIDGenerator.js.map +0 -1
- package/esm/index.d.ts +0 -4
- package/esm/index.js +0 -17
- package/esm/index.js.map +0 -1
- package/esm/interface/id-generator.d.ts +0 -11
- package/esm/interface/id-generator.js +0 -1
- package/esm/interface/id-generator.js.map +0 -1
- package/esm/interface/message-factory.d.ts +0 -7
- package/esm/interface/message-factory.js +0 -1
- package/esm/interface/message-factory.js.map +0 -1
- package/esm/interface/message-objects.d.ts +0 -30
- package/esm/interface/message-objects.js +0 -1
- package/esm/interface/message-objects.js.map +0 -1
- package/esm/interface/message-validator.d.ts +0 -7
- package/esm/interface/message-validator.js +0 -1
- package/esm/interface/message-validator.js.map +0 -1
- package/esm/interface/postmessage-adapter.d.ts +0 -6
- package/esm/interface/postmessage-adapter.js +0 -1
- package/esm/interface/postmessage-adapter.js.map +0 -1
- package/esm/interface/public-interface.d.ts +0 -4
- package/esm/interface/public-interface.js +0 -1
- package/esm/interface/public-interface.js.map +0 -1
- package/karma.conf.js +0 -99
- package/rx-postmessenger.d.ts +0 -74
- package/umd/rx-postmessenger.js +0 -10827
- package/umd/rx-postmessenger.js.map +0 -1
- package/umd/rx-postmessenger.min.js +0 -17
- package/umd/rx-postmessenger.min.js.map +0 -1
- package/yarn-error.log +0 -4522
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
export interface Static {
|
|
3
|
+
/**
|
|
4
|
+
* Create a new messenger for given window object. The remoteOrigin URL is used both to give to window.postMessage
|
|
5
|
+
* calls on remoteWindow, and to filter inbound-message-events on the local window object.
|
|
6
|
+
*/
|
|
7
|
+
connect(remoteWindow: Window, remoteOrigin: string): Messenger;
|
|
8
|
+
}
|
|
9
|
+
export interface Messenger {
|
|
10
|
+
/**
|
|
11
|
+
* Returns an Observable that emits all incoming notifications for given notification-channel.
|
|
12
|
+
*/
|
|
13
|
+
notifications<T = any>(channel: string): Observable<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Send a notification over given channel with given payload.
|
|
16
|
+
*/
|
|
17
|
+
notify<T>(channel: string, payload?: T): void;
|
|
18
|
+
/**
|
|
19
|
+
* Send a request over given channel with given payload. Returns an observable that will emit the response
|
|
20
|
+
* and then complete.
|
|
21
|
+
*/
|
|
22
|
+
request<T = any, U = any>(channel: string, payload?: T): Observable<U>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns an Observable that emits all incoming requests for given request-channel.
|
|
25
|
+
*/
|
|
26
|
+
requests<T = any, U = any>(channel: string): Observable<Request<T, U>>;
|
|
27
|
+
}
|
|
28
|
+
export interface Request<T, U> {
|
|
29
|
+
/**
|
|
30
|
+
* The name of the channel the request was sent through. The
|
|
31
|
+
* channel literal is immutable. Attempts to override the
|
|
32
|
+
* channel property
|
|
33
|
+
*/
|
|
34
|
+
readonly channel: string;
|
|
35
|
+
/**
|
|
36
|
+
* The payload data for the request. The payload is immutable.
|
|
37
|
+
* Attempts to set / override payload values will silently fail.
|
|
38
|
+
* Attempts to mutate members of object-type payloads will
|
|
39
|
+
* silently fail as well.
|
|
40
|
+
*/
|
|
41
|
+
readonly payload: T;
|
|
42
|
+
/**
|
|
43
|
+
* Boolean indicating whether respond() has been called on the request
|
|
44
|
+
* previously.
|
|
45
|
+
*/
|
|
46
|
+
readonly isHandled: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The unique ID of the request.
|
|
49
|
+
*/
|
|
50
|
+
readonly id: string;
|
|
51
|
+
/**
|
|
52
|
+
* Respond to the request with given data.
|
|
53
|
+
*/
|
|
54
|
+
respond(data: U): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface IMessageIDGenerator {
|
|
2
|
+
/**
|
|
3
|
+
* Get a new unique ID value for message objects.
|
|
4
|
+
*/
|
|
5
|
+
generateID(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Invalidates an ID value - marks it a used. This is a required
|
|
8
|
+
* feature for syncing the used ID values
|
|
9
|
+
*/
|
|
10
|
+
invalidateID(id: string): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The IMessageObject interface defines the format for data property values of MessageEvent objects.
|
|
14
|
+
* This interface describes the actual format of data sent with postMessage that is required for
|
|
15
|
+
* another RxPostmessenger on the other end of the line to be able to correctly interpret the
|
|
16
|
+
* message.
|
|
17
|
+
*/
|
|
18
|
+
export interface IMessageObject<T = any> {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly type: MessageType;
|
|
21
|
+
readonly channel: string;
|
|
22
|
+
readonly payload: T;
|
|
23
|
+
}
|
|
24
|
+
export interface IRequestObject<T = any> extends IMessageObject<T> {
|
|
25
|
+
readonly type: 'request';
|
|
26
|
+
}
|
|
27
|
+
export interface IResponseObject<T = any> extends IMessageObject<T> {
|
|
28
|
+
readonly requestId: string;
|
|
29
|
+
readonly type: 'response';
|
|
30
|
+
}
|
|
31
|
+
export interface INotificationObject<T = any> extends IMessageObject<T> {
|
|
32
|
+
readonly type: 'notification';
|
|
33
|
+
}
|
|
34
|
+
export type AnyMessage = IRequestObject | IResponseObject | INotificationObject;
|
|
35
|
+
export interface IMessageTypeMap<T = any> {
|
|
36
|
+
request: IRequestObject<T>;
|
|
37
|
+
response: IResponseObject<T>;
|
|
38
|
+
notification: INotificationObject<T>;
|
|
39
|
+
}
|
|
40
|
+
export type MessageType = keyof IMessageTypeMap;
|
|
41
|
+
export type MappedMessage<T extends MessageType> = IMessageTypeMap[T];
|
|
42
|
+
export interface IMessageFactory {
|
|
43
|
+
invalidateID(id: string): void;
|
|
44
|
+
makeRequest<T>(channel: string, payload: T): IRequestObject<T>;
|
|
45
|
+
makeResponse<T>(requestId: string, channel: string, payload: T): IResponseObject<T>;
|
|
46
|
+
makeNotification<T>(channel: string, payload: T): INotificationObject<T>;
|
|
47
|
+
}
|
|
48
|
+
export interface IOwnMessageEvent<T> extends MessageEvent {
|
|
49
|
+
readonly data: T;
|
|
50
|
+
}
|
|
51
|
+
export interface IMessageValidator {
|
|
52
|
+
validate(message: MessageEvent): message is IOwnMessageEvent<AnyMessage>;
|
|
53
|
+
}
|
|
54
|
+
export interface IPostmessageAdapter {
|
|
55
|
+
readonly targetWindow: Window;
|
|
56
|
+
readonly targetOrigin: string;
|
|
57
|
+
postMessage<T extends AnyMessage>(data: T): void;
|
|
58
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rx-postmessenger",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"author": "Jeffrey Westerkamp",
|
|
5
5
|
"repository": "git+https://github.com/JJWesterkamp/rx-postmessenger.git",
|
|
6
6
|
"description": "Minimal RxJS adapter for the window.postMessage API for request-response streams and notification streams across frame windows.",
|
|
@@ -16,56 +16,48 @@
|
|
|
16
16
|
"typescript"
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"main": "./
|
|
20
|
-
"module": "./
|
|
21
|
-
"types": "./
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
22
28
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
-
"build": "run-p build:**",
|
|
25
|
-
"build:cjs": "tsc",
|
|
26
|
-
"build:esm": "tsc -m es6 --outDir esm",
|
|
27
|
-
"build:umd": "webpack",
|
|
28
|
-
"clean:dist": "rm -rf esm cjs umd",
|
|
29
|
+
"clean:dist": "rm -rf dist",
|
|
29
30
|
"clean:coverage": "rm -rf coverage",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"test": "
|
|
37
|
-
"
|
|
31
|
+
"dev": "tsc --project tsconfig.app.json --watch",
|
|
32
|
+
"build": "npm run clean:dist && tsc --project tsconfig.app.json",
|
|
33
|
+
"check": "tsc --project tsconfig.app.json --noEmit && tsc --project tsconfig.spec.json",
|
|
34
|
+
"prepublishOnly": "npm run check && npm test && npm run build",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest",
|
|
37
|
+
"test:coverage": "vitest run --coverage",
|
|
38
|
+
"fmt": "oxfmt --check",
|
|
39
|
+
"lint": "oxlint",
|
|
40
|
+
"lint:fix": "oxfmt && oxlint --fix"
|
|
38
41
|
},
|
|
39
|
-
"
|
|
40
|
-
"rxjs": "
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"rxjs": "6.x || 7.x"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
|
-
"@types/
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"karma-sourcemap-loader": "^0.3.7",
|
|
60
|
-
"karma-webpack": "^4.0.2",
|
|
61
|
-
"mocha": "^6.1.4",
|
|
62
|
-
"npm-run-all": "^4.1.2",
|
|
63
|
-
"sinon": "^7.3.2",
|
|
64
|
-
"ts-loader": "^6.0.4",
|
|
65
|
-
"tslint": "^5.18.0",
|
|
66
|
-
"typescript": "^3.5.2",
|
|
67
|
-
"uglifyjs-webpack-plugin": "^2.1.3",
|
|
68
|
-
"webpack": "^4.35.0",
|
|
69
|
-
"webpack-cli": "^3.3.4"
|
|
46
|
+
"@types/node": "^26.6.6",
|
|
47
|
+
"@vitest/coverage-v8": "^5.1.1",
|
|
48
|
+
"jsdom": "^31.0.1",
|
|
49
|
+
"oxfmt": "0.80.0",
|
|
50
|
+
"oxlint": "1.95.0",
|
|
51
|
+
"oxlint-tsgolint": "7.0.2008",
|
|
52
|
+
"rxjs": "^7.8.2",
|
|
53
|
+
"typescript": "^7.0.2",
|
|
54
|
+
"vitest": "^5.1.1"
|
|
55
|
+
},
|
|
56
|
+
"type": "module",
|
|
57
|
+
"files": [
|
|
58
|
+
"dist"
|
|
59
|
+
],
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
70
62
|
}
|
|
71
63
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
[](https://badge.fury.io/js/rx-postmessenger)
|
|
3
|
-
|
|
4
|
-
All notable changes to `rx-postmessenger` will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
-
|
|
7
|
-
## [Unreleased]
|
|
8
|
-
|
|
9
|
-
## [2.0.1] (2019-06-22)
|
|
10
|
-
- Updated all npm dev-dependencies latest versions, fixing vulnerability issues reported by Github.
|
|
11
|
-
|
|
12
|
-
## [2.0.0] (2019-05-27)
|
|
13
|
-
### Changed
|
|
14
|
-
- Documented alpha.1 changes in README.
|
|
15
|
-
|
|
16
|
-
## [2.0.0-alpha.1] (2019-01-06)
|
|
17
|
-
### BREAKING CHANGES
|
|
18
|
-
- **Removed EventMap feature**
|
|
19
|
-
|
|
20
|
-
This proved to be unmaintainable in terms of type-mapping in private implementations
|
|
21
|
-
and also made the package less 'portable'. Payload type constraints are from now on
|
|
22
|
-
enforced directly on Messenger method calls.
|
|
23
|
-
|
|
24
|
-
- **RxJS v6**
|
|
25
|
-
|
|
26
|
-
Upgraded the RxJS dependency from v5 to v6.
|
|
27
|
-
|
|
28
|
-
- **Removed `Static.useObservable()` and `Static.getObservable()`**
|
|
29
|
-
|
|
30
|
-
These methods are obsolete as of RxJS v6, as the Observable operators are no longer
|
|
31
|
-
provided through prototype patching, but explicitly supplied with `Observable.pipe()`.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## [1.0.4] (2019-01-06)
|
|
35
|
-
### Added
|
|
36
|
-
- 🧪 Test suite
|
|
37
|
-
- Added TravisCI Build status to README
|
|
38
|
-
|
|
39
|
-
### Changed
|
|
40
|
-
- Major refactor of package internals: better SOC and adherence to SRP.
|
|
41
|
-
- Refactor public interface definition of EventMap structure.
|
|
42
|
-
|
|
43
|
-
## [1.0.3] (2018-05-15)
|
|
44
|
-
### Changed
|
|
45
|
-
- Internal naming of TS interfaces.
|
|
46
|
-
- Documentation of Public interface in `rx-postmessenger.d.ts`
|
|
47
|
-
|
|
48
|
-
## [1.0.2] (2018-03-17)
|
|
49
|
-
README update only.
|
|
50
|
-
|
|
51
|
-
## [1.0.1] (2018-03-17)
|
|
52
|
-
README update only.
|
|
53
|
-
|
|
54
|
-
## [1.0.0] (2018-03-12)
|
|
55
|
-
No code changes.
|
|
56
|
-
|
|
57
|
-
### Added
|
|
58
|
-
- LICENSE file
|
|
59
|
-
|
|
60
|
-
## [1.0.0-beta.1] (2018-01-14)
|
|
61
|
-
README update only.
|
|
62
|
-
|
|
63
|
-
## [0.2.1] (2018-01-01)
|
|
64
|
-
### Fixed
|
|
65
|
-
- npm distribution config: rename CommonJS build folder
|
|
66
|
-
- npm distribution config: ignore `/src` folder
|
|
67
|
-
|
|
68
|
-
## [0.2.0] (2018-01-01)
|
|
69
|
-
### Added
|
|
70
|
-
- Support for mapping event-channel names to payload types
|
|
71
|
-
|
|
72
|
-
## [0.1.12] (2017-12-07)
|
|
73
|
-
README update only.
|
|
74
|
-
|
|
75
|
-
## [0.1.11] (2017-12-07)
|
|
76
|
-
README update only.
|
|
77
|
-
|
|
78
|
-
## [0.1.10] (2017-12-07)
|
|
79
|
-
|
|
80
|
-
### Changed
|
|
81
|
-
- **TS declaration pointer** Package now relies on the dedicated declaration file and no longer generates declarations for CommonJS builds.
|
|
82
|
-
## [0.1.9] (2017-12-07)
|
|
83
|
-
General development, no notable changes
|
|
84
|
-
|
|
85
|
-
## [0.1.8] (2017-12-02)
|
|
86
|
-
|
|
87
|
-
### Fixed
|
|
88
|
-
- README error: Code example accessing properties in the wrong way.
|
|
89
|
-
|
|
90
|
-
## [0.1.7] (2017-12-01)
|
|
91
|
-
### Added
|
|
92
|
-
- Method to override the used RxJS Observable implementation allowing for custom sets of prototype methods.
|
|
93
|
-
|
|
94
|
-
## 0.1.6 (2018-12-01)
|
|
95
|
-
⚠️ this release has been unpublished from npm due to issues.
|
|
96
|
-
|
|
97
|
-
## [0.1.5] (2017-11-29)
|
|
98
|
-
|
|
99
|
-
### Changed
|
|
100
|
-
- Use full build of RxJS for faster development
|
|
101
|
-
- README content
|
|
102
|
-
|
|
103
|
-
## [0.1.4] (2017-11-28)
|
|
104
|
-
|
|
105
|
-
### Added
|
|
106
|
-
- Initial (serious) README content
|
|
107
|
-
|
|
108
|
-
### Changed
|
|
109
|
-
- Signature of `RxPostmessenger ~ createMessageObject`
|
|
110
|
-
|
|
111
|
-
## [0.1.3] (2017-11-27)
|
|
112
|
-
|
|
113
|
-
### Changed
|
|
114
|
-
- Messenger methods visibility + other development
|
|
115
|
-
- Package.json meta info
|
|
116
|
-
|
|
117
|
-
## [0.1.2] (2017-11-26)
|
|
118
|
-
|
|
119
|
-
### Added
|
|
120
|
-
- Minified and non-minified UMD bundle builds
|
|
121
|
-
|
|
122
|
-
### Changed
|
|
123
|
-
- Temporarily removed `/src` from gitignore
|
|
124
|
-
|
|
125
|
-
## [0.1.1] (2017-11-26)
|
|
126
|
-
|
|
127
|
-
### Fixed
|
|
128
|
-
- Wrong value for `"main""` entry in package.json.
|
|
129
|
-
|
|
130
|
-
## [0.1.0] (2017-11-26, initial release)
|
|
131
|
-
|
|
132
|
-
### Added
|
|
133
|
-
- Bade messenger class
|
|
134
|
-
- Project setup (builds, configuration etc.)
|
|
135
|
-
|
|
136
|
-
[Unreleased]: https://github.com/PXLWidgets/php-composer-version/compare/v2.0.1...HEAD
|
|
137
|
-
[2.0.1]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v2.0.0...v2.0.1
|
|
138
|
-
[2.0.0]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v2.0.0-alpha.1...v2.0.0
|
|
139
|
-
[2.0.0-alpha.1]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v1.0.4...v2.0.0-alpha.1
|
|
140
|
-
[1.0.4]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v1.0.3...v1.0.4
|
|
141
|
-
[1.0.3]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v1.0.2...v1.0.3
|
|
142
|
-
[1.0.2]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v1.0.1...v1.0.2
|
|
143
|
-
[1.0.1]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v1.0.0...v1.0.1
|
|
144
|
-
[1.0.0]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v1.0.0-beta.1...v1.0.0
|
|
145
|
-
[1.0.0-beta.1]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.2.1...v1.0.0-beta.1
|
|
146
|
-
[0.2.1]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.2.0...v0.2.1
|
|
147
|
-
[0.2.0]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.12...v0.2.0
|
|
148
|
-
[0.1.12]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.11...v0.1.12
|
|
149
|
-
[0.1.11]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.10...v0.1.11
|
|
150
|
-
[0.1.10]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.9...v0.1.10
|
|
151
|
-
[0.1.9]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.8...v0.1.9
|
|
152
|
-
[0.1.8]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.7...v0.1.8
|
|
153
|
-
[0.1.7]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.5...v0.1.7
|
|
154
|
-
[0.1.5]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.4...v0.1.5
|
|
155
|
-
[0.1.4]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.3...v0.1.4
|
|
156
|
-
[0.1.3]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.2...v0.1.3
|
|
157
|
-
[0.1.2]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.1...v0.1.2
|
|
158
|
-
[0.1.1]: https://github.com/JJWesterkamp/rx-postmessenger/compare/v0.1.0...v0.1.1
|
|
159
|
-
[0.1.0]: https://github.com/JJWesterkamp/rx-postmessenger/tree/v0.1.0
|
package/cjs/MessageFactory.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IMessageIDGenerator } from './interface/id-generator';
|
|
2
|
-
import { IMessageFactory } from './interface/message-factory';
|
|
3
|
-
import { INotificationObject, IRequestObject, IResponseObject } from './interface/message-objects';
|
|
4
|
-
export declare class MessageFactory implements IMessageFactory {
|
|
5
|
-
protected readonly IDGenerator: IMessageIDGenerator;
|
|
6
|
-
constructor(IDGenerator: IMessageIDGenerator);
|
|
7
|
-
makeNotification<T>(channel: string, payload: T): INotificationObject<T>;
|
|
8
|
-
makeRequest<T>(channel: string, payload: T): IRequestObject<T>;
|
|
9
|
-
makeResponse<T>(requestId: string, channel: string, payload: T): IResponseObject<T>;
|
|
10
|
-
invalidateID(id: string): void;
|
|
11
|
-
}
|
package/cjs/MessageFactory.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var MessageFactory = /** @class */ (function () {
|
|
4
|
-
function MessageFactory(IDGenerator) {
|
|
5
|
-
this.IDGenerator = IDGenerator;
|
|
6
|
-
}
|
|
7
|
-
MessageFactory.prototype.makeNotification = function (channel, payload) {
|
|
8
|
-
return {
|
|
9
|
-
channel: channel,
|
|
10
|
-
id: this.IDGenerator.generateID(),
|
|
11
|
-
payload: payload,
|
|
12
|
-
type: 'notification',
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
MessageFactory.prototype.makeRequest = function (channel, payload) {
|
|
16
|
-
return {
|
|
17
|
-
channel: channel,
|
|
18
|
-
id: this.IDGenerator.generateID(),
|
|
19
|
-
payload: payload,
|
|
20
|
-
type: 'request',
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
MessageFactory.prototype.makeResponse = function (requestId, channel, payload) {
|
|
24
|
-
return {
|
|
25
|
-
channel: channel,
|
|
26
|
-
id: this.IDGenerator.generateID(),
|
|
27
|
-
payload: payload,
|
|
28
|
-
requestId: requestId,
|
|
29
|
-
type: 'response',
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
MessageFactory.prototype.invalidateID = function (id) {
|
|
33
|
-
this.IDGenerator.invalidateID(id);
|
|
34
|
-
};
|
|
35
|
-
return MessageFactory;
|
|
36
|
-
}());
|
|
37
|
-
exports.MessageFactory = MessageFactory;
|
|
38
|
-
//# sourceMappingURL=MessageFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageFactory.js","sourceRoot":"","sources":["../src/MessageFactory.ts"],"names":[],"mappings":";;AAIA;IAEI,wBAA+B,WAAgC;QAAhC,gBAAW,GAAX,WAAW,CAAqB;IAAI,CAAC;IAE7D,yCAAgB,GAAvB,UAA2B,OAAe,EAAE,OAAU;QAClD,OAAO;YACH,OAAO,SAAA;YACP,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;YACjC,OAAO,SAAA;YACP,IAAI,EAAE,cAAc;SACvB,CAAC;IACN,CAAC;IAEM,oCAAW,GAAlB,UAAsB,OAAe,EAAE,OAAU;QAC7C,OAAO;YACH,OAAO,SAAA;YACP,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;YACjC,OAAO,SAAA;YACP,IAAI,EAAE,SAAS;SAClB,CAAC;IACN,CAAC;IAEM,qCAAY,GAAnB,UAAuB,SAAiB,EAAE,OAAe,EAAE,OAAU;QACjE,OAAO;YACH,OAAO,SAAA;YACP,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;YACjC,OAAO,SAAA;YACP,SAAS,WAAA;YACT,IAAI,EAAE,UAAU;SACnB,CAAC;IACN,CAAC;IAEM,qCAAY,GAAnB,UAAoB,EAAU;QAC1B,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IACL,qBAAC;AAAD,CAAC,AAnCD,IAmCC;AAnCY,wCAAc"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var GUIDGenerator_1 = require("./functions/GUIDGenerator");
|
|
4
|
-
var MessageIDGenerator = /** @class */ (function () {
|
|
5
|
-
function MessageIDGenerator(gen) {
|
|
6
|
-
if (gen === void 0) { gen = GUIDGenerator_1.GUIDGenerator(); }
|
|
7
|
-
this.gen = gen;
|
|
8
|
-
this.usedIDValues = [];
|
|
9
|
-
}
|
|
10
|
-
MessageIDGenerator.prototype.generateID = function () {
|
|
11
|
-
var newID;
|
|
12
|
-
do {
|
|
13
|
-
newID = this.gen.next().value;
|
|
14
|
-
} while (this.usedIDValues.indexOf(newID) >= 0);
|
|
15
|
-
this.invalidateID(newID);
|
|
16
|
-
return newID;
|
|
17
|
-
};
|
|
18
|
-
MessageIDGenerator.prototype.invalidateID = function (id) {
|
|
19
|
-
this.usedIDValues.push(id);
|
|
20
|
-
};
|
|
21
|
-
return MessageIDGenerator;
|
|
22
|
-
}());
|
|
23
|
-
exports.MessageIDGenerator = MessageIDGenerator;
|
|
24
|
-
//# sourceMappingURL=MessageIDGenerator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageIDGenerator.js","sourceRoot":"","sources":["../src/MessageIDGenerator.ts"],"names":[],"mappings":";;AAAA,2DAA0D;AAG1D;IAII,4BAA+B,GAAuC;QAAvC,oBAAA,EAAA,MAAwB,6BAAa,EAAE;QAAvC,QAAG,GAAH,GAAG,CAAoC;QAFnD,iBAAY,GAAa,EAAE,CAAC;IAE0B,CAAC;IAEnE,uCAAU,GAAjB;QACI,IAAI,KAAa,CAAC;QAElB,GAAG;YACC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;SACjC,QAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QAEhD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACzB,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,yCAAY,GAAnB,UAAoB,EAAU;QAC1B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IACL,yBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,gDAAkB"}
|
package/cjs/MessageValidator.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var MessageValidator = /** @class */ (function () {
|
|
4
|
-
function MessageValidator(acceptedSource, acceptedOrigin) {
|
|
5
|
-
this.acceptedSource = acceptedSource;
|
|
6
|
-
this.acceptedOrigin = acceptedOrigin;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Validates the identity of the message's sender and the format of the message's data.
|
|
10
|
-
*
|
|
11
|
-
* Checks whether the remoteOrigin location matches any allowed origins.
|
|
12
|
-
* Separate assertion of the remoteOrigin allows for cross-domain navigation
|
|
13
|
-
* within this.frame, and still treating inbound messages from the
|
|
14
|
-
* frame as being equal.
|
|
15
|
-
*
|
|
16
|
-
* Checks whether the source Window object equals the remoteWindow object.
|
|
17
|
-
* This check allows for implementation of multiple i-frames that share the
|
|
18
|
-
* same remoteOrigin, and still being able to distinguish between messages from
|
|
19
|
-
* such frames.
|
|
20
|
-
*/
|
|
21
|
-
MessageValidator.prototype.validate = function (message) {
|
|
22
|
-
return message instanceof MessageEvent
|
|
23
|
-
&& message.origin === this.acceptedOrigin
|
|
24
|
-
&& message.source === this.acceptedSource
|
|
25
|
-
&& this.isWellFormedMessage(message.data);
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Tests whether the data sent through postMessage is a well-formed message
|
|
29
|
-
* object. This serves as runtime data format validation. If messages do not
|
|
30
|
-
* comply to the AnyMessage compound interface, the entire event is ignored.
|
|
31
|
-
*
|
|
32
|
-
* @param {*} message
|
|
33
|
-
* @return {boolean}
|
|
34
|
-
*/
|
|
35
|
-
MessageValidator.prototype.isWellFormedMessage = function (message) {
|
|
36
|
-
return (typeof message.id === 'string')
|
|
37
|
-
&& (['request', 'response', 'notification'].indexOf(message.type) >= 0)
|
|
38
|
-
&& (typeof message.channel === 'string')
|
|
39
|
-
&& (message.type !== 'response' || (typeof message.requestId === 'string'));
|
|
40
|
-
};
|
|
41
|
-
return MessageValidator;
|
|
42
|
-
}());
|
|
43
|
-
exports.MessageValidator = MessageValidator;
|
|
44
|
-
//# sourceMappingURL=MessageValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageValidator.js","sourceRoot":"","sources":["../src/MessageValidator.ts"],"names":[],"mappings":";;AAGA;IAEI,0BAAsB,cAAsB,EAAY,cAAsB;QAAxD,mBAAc,GAAd,cAAc,CAAQ;QAAY,mBAAc,GAAd,cAAc,CAAQ;IAAI,CAAC;IAEnF;;;;;;;;;;;;OAYG;IACI,mCAAQ,GAAf,UAAgB,OAAqB;QACjC,OAAO,OAAO,YAAY,YAAY;eAC/B,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,cAAc;eACtC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,cAAc;eACtC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;OAOG;IACI,8CAAmB,GAA1B,UAA2B,OAAY;QACnC,OAAO,CAAC,OAAO,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC;eAChC,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;eACpE,CAAC,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC;eACrC,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC;IACpF,CAAC;IACL,uBAAC;AAAD,CAAC,AAtCD,IAsCC;AAtCY,4CAAgB"}
|
package/cjs/Messenger.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { IMessageFactory } from './interface/message-factory';
|
|
3
|
-
import { IMessageValidator } from './interface/message-validator';
|
|
4
|
-
import { IPostmessageAdapter } from './interface/postmessage-adapter';
|
|
5
|
-
import { IMessenger, IRequest } from './interface/public-interface';
|
|
6
|
-
import { AnyMessage, INotificationObject, IRequestObject, IResponseObject, MappedMessage, MessageType } from './interface/message-objects';
|
|
7
|
-
export declare class Messenger implements IMessenger {
|
|
8
|
-
protected readonly messageFactory: IMessageFactory;
|
|
9
|
-
protected readonly messageValidator: IMessageValidator;
|
|
10
|
-
protected readonly adapter: IPostmessageAdapter;
|
|
11
|
-
/**
|
|
12
|
-
* Observable stream of all incoming messages that originate from remoteWindow with a
|
|
13
|
-
* remoteOrigin url matching this.remoteOrigin.
|
|
14
|
-
*/
|
|
15
|
-
readonly inboundMessages$: Observable<AnyMessage>;
|
|
16
|
-
/**
|
|
17
|
-
* Filtered subset of inboundMessages$, emitting all messages of type 'notification'
|
|
18
|
-
*/
|
|
19
|
-
readonly notifications$: Observable<INotificationObject>;
|
|
20
|
-
/**
|
|
21
|
-
* Filtered subset of inboundMessages$, emitting all messages of type 'request'
|
|
22
|
-
*/
|
|
23
|
-
readonly requests$: Observable<IRequestObject>;
|
|
24
|
-
/**
|
|
25
|
-
* Filtered subset of inboundMessages$, emitting all messages of type 'response'
|
|
26
|
-
*/
|
|
27
|
-
readonly responses$: Observable<IResponseObject>;
|
|
28
|
-
/**
|
|
29
|
-
* @param {IMessageFactory} messageFactory - Factory instance for scalar message objects.
|
|
30
|
-
* @param {IMessageValidator} messageValidator - Validator instance for incoming messages.
|
|
31
|
-
* @param {IPostmessageAdapter} adapter - Adapter for interacting with the postMessage API
|
|
32
|
-
*/
|
|
33
|
-
constructor(messageFactory: IMessageFactory, messageValidator: IMessageValidator, adapter: IPostmessageAdapter);
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* Send a request over given channel with given payload. Returns an observable that will
|
|
37
|
-
* emit the response and then complete.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} channel The channel name of the request.
|
|
40
|
-
* @param {*} [payload] The payload to send along with the request.
|
|
41
|
-
*/
|
|
42
|
-
request<T = any, U = any>(channel: string, payload?: T): Observable<U>;
|
|
43
|
-
/**
|
|
44
|
-
* Send a notification over given channel with given payload.
|
|
45
|
-
*
|
|
46
|
-
* @param {string} channel - The channel name of the notification.
|
|
47
|
-
* @param {*} [payload] - The payload to send along with the notification.
|
|
48
|
-
*/
|
|
49
|
-
notify<T>(channel: string, payload?: T): void;
|
|
50
|
-
/**
|
|
51
|
-
* Returns an Observable that emits the subset of inbound notification messages where their
|
|
52
|
-
* channel equals given channel name.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} channel - The request channel name to listen to.
|
|
55
|
-
* @return {Observable<object>}
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
requests<T = any, U = any>(channel: string): Observable<IRequest<T, U>>;
|
|
59
|
-
/**
|
|
60
|
-
* Returns an Observable that emits the subset of inbound notification messages where their
|
|
61
|
-
* channel equals given channel name.
|
|
62
|
-
*
|
|
63
|
-
* @param {string} channel - The notification channel name to listen to.
|
|
64
|
-
* @return {Observable<*>}
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
|
-
notifications<T = any>(channel: string): Observable<T>;
|
|
68
|
-
/**
|
|
69
|
-
* Sends a response through given channel to the remote window, carrying given payload.
|
|
70
|
-
*
|
|
71
|
-
* @param {string} requestId - The request ID of the original request
|
|
72
|
-
* @param {string} channel - The request-channel name to send the response over
|
|
73
|
-
* @param {*} payload - The response payload
|
|
74
|
-
* @return {Messenger}
|
|
75
|
-
* @protected
|
|
76
|
-
*/
|
|
77
|
-
protected respond<T>(requestId: string, channel: string, payload: T): this;
|
|
78
|
-
/**
|
|
79
|
-
* Creates an Observable that completes after a single emission of the MessageEvent response for request of given
|
|
80
|
-
* requestId. If no matching response is ever received, the Observable never completes.
|
|
81
|
-
*
|
|
82
|
-
* @param {string} requestId
|
|
83
|
-
* @return {Observable<object>}
|
|
84
|
-
* @protected
|
|
85
|
-
*/
|
|
86
|
-
protected createResponseObservable<T>(requestId: string): Observable<T>;
|
|
87
|
-
/**
|
|
88
|
-
* Returns an Observable emitting all inbound messages` of given type.
|
|
89
|
-
*
|
|
90
|
-
* Returns an Observable emitting a subset of MessageEvent objects emitted
|
|
91
|
-
* by this.inboundMessages$, passing through all MessageEvent objects whose
|
|
92
|
-
* data.type property matches given type.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} type
|
|
95
|
-
* @return {Observable<object>}
|
|
96
|
-
* @protected
|
|
97
|
-
*/
|
|
98
|
-
protected messagesOfType<T extends MessageType>(type: T): Observable<MappedMessage<T>>;
|
|
99
|
-
}
|