@kookapp/web-bridge 0.0.1 → 0.0.2
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/child/ChildBridge.d.ts +2 -2
- package/dist/child/ChildBridge.js +2 -2
- package/dist/child/index.d.ts +3 -3
- package/dist/child/index.js +2 -2
- package/dist/errors/BridgeError.d.ts +1 -1
- package/dist/errors/BridgeError.js +1 -1
- package/dist/errors/errorFactory.d.ts +1 -1
- package/dist/errors/errorFactory.js +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.js +9 -9
- package/dist/parent/IframeChannel.d.ts +2 -2
- package/dist/parent/IframeChannel.js +1 -1
- package/dist/parent/ParentBridge.d.ts +3 -3
- package/dist/parent/ParentBridge.js +3 -3
- package/dist/parent/index.d.ts +5 -5
- package/dist/parent/index.js +3 -3
- package/dist/shared/EventEmitter.d.ts +1 -1
- package/dist/shared/MessageHandler.d.ts +4 -4
- package/dist/shared/MessageHandler.js +5 -5
- package/dist/shared/OriginValidator.d.ts +1 -1
- package/package.json +5 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ChildBridge for communication from inside an iframe
|
|
3
3
|
*/
|
|
4
|
-
import { ChildBridgeConfig, BridgeMessage } from '
|
|
5
|
-
import { MessageHandler } from '
|
|
4
|
+
import { ChildBridgeConfig, BridgeMessage } from '../types';
|
|
5
|
+
import { MessageHandler } from '../shared/MessageHandler';
|
|
6
6
|
export declare class ChildBridge extends MessageHandler {
|
|
7
7
|
private parentWindow;
|
|
8
8
|
private parentOrigin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ChildBridge for communication from inside an iframe
|
|
3
3
|
*/
|
|
4
|
-
import { MessageHandler } from '
|
|
5
|
-
import { DEFAULT_TIMEOUT } from '
|
|
4
|
+
import { MessageHandler } from '../shared/MessageHandler';
|
|
5
|
+
import { DEFAULT_TIMEOUT } from '../constants';
|
|
6
6
|
export class ChildBridge extends MessageHandler {
|
|
7
7
|
constructor(config) {
|
|
8
8
|
const timeout = config.timeout || DEFAULT_TIMEOUT;
|
package/dist/child/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ChildBridge } from '
|
|
2
|
-
export type { ChildBridgeConfig } from '
|
|
3
|
-
export * from '
|
|
1
|
+
export { ChildBridge } from '../child/ChildBridge';
|
|
2
|
+
export type { ChildBridgeConfig } from '../types';
|
|
3
|
+
export * from '../child/utils';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/child/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ChildBridge } from '
|
|
2
|
-
export * from '
|
|
1
|
+
export { ChildBridge } from '../child/ChildBridge';
|
|
2
|
+
export * from '../child/utils';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Custom error class for WebBridge
|
|
3
3
|
*/
|
|
4
|
-
import { ERROR_CODE } from '
|
|
4
|
+
import { ERROR_CODE } from '../constants';
|
|
5
5
|
export type BridgeErrorCode = keyof typeof ERROR_CODE;
|
|
6
6
|
export declare class BridgeError extends Error {
|
|
7
7
|
code: BridgeErrorCode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Custom error class for WebBridge
|
|
3
3
|
*/
|
|
4
|
-
import { ERROR_MESSAGE } from '
|
|
4
|
+
import { ERROR_MESSAGE } from '../constants';
|
|
5
5
|
export class BridgeError extends Error {
|
|
6
6
|
constructor(code, message, originalError) {
|
|
7
7
|
const errorMessage = message || ERROR_MESSAGE[code] || 'Unknown error';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error factory functions
|
|
3
3
|
*/
|
|
4
|
-
import { BridgeError, BridgeErrorCode } from '
|
|
4
|
+
import { BridgeError, BridgeErrorCode } from '../errors/BridgeError';
|
|
5
5
|
export declare const errorFactory: {
|
|
6
6
|
handlerNotFound: (handlerName: string) => BridgeError;
|
|
7
7
|
originNotAllowed: (origin: string) => BridgeError;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Error factory functions
|
|
3
3
|
*/
|
|
4
|
-
import { BridgeError } from '
|
|
4
|
+
import { BridgeError } from '../errors/BridgeError';
|
|
5
5
|
export const errorFactory = {
|
|
6
6
|
handlerNotFound: (handlerName) => BridgeError.create('HANDLER_NOT_FOUND', `Handler "${handlerName}" not found`),
|
|
7
7
|
originNotAllowed: (origin) => BridgeError.create('ORIGIN_NOT_ALLOWED', `Origin "${origin}" not allowed`),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main entry point for WebBridge
|
|
3
3
|
*/
|
|
4
|
-
export { ParentBridge } from '
|
|
5
|
-
export type { ParentBridgeConfig, IframeChannelInterface } from '
|
|
6
|
-
export { IframeChannel } from '
|
|
7
|
-
export { ChildBridge } from '
|
|
8
|
-
export type { ChildBridgeConfig } from '
|
|
9
|
-
export type { BridgeConfig, BridgeMessage, Handler, HandlerRegistry, MessageType } from '
|
|
10
|
-
export { BridgeError } from '
|
|
11
|
-
export type { BridgeErrorCode } from '
|
|
12
|
-
export { errorFactory } from '
|
|
13
|
-
export { BRIDGE_VERSION, DEFAULT_TIMEOUT, ERROR_CODE, MESSAGE_TYPE } from '
|
|
14
|
-
export { EventEmitter } from '
|
|
15
|
-
export { OriginValidator } from '
|
|
16
|
-
export { IdGenerator } from '
|
|
4
|
+
export { ParentBridge } from './parent/index';
|
|
5
|
+
export type { ParentBridgeConfig, IframeChannelInterface } from './parent/index';
|
|
6
|
+
export { IframeChannel } from './parent/IframeChannel';
|
|
7
|
+
export { ChildBridge } from './child/index';
|
|
8
|
+
export type { ChildBridgeConfig } from './child/index';
|
|
9
|
+
export type { BridgeConfig, BridgeMessage, Handler, HandlerRegistry, MessageType } from './types';
|
|
10
|
+
export { BridgeError } from './errors/BridgeError';
|
|
11
|
+
export type { BridgeErrorCode } from './errors/BridgeError';
|
|
12
|
+
export { errorFactory } from './errors/errorFactory';
|
|
13
|
+
export { BRIDGE_VERSION, DEFAULT_TIMEOUT, ERROR_CODE, MESSAGE_TYPE } from './constants';
|
|
14
|
+
export { EventEmitter } from './shared/EventEmitter';
|
|
15
|
+
export { OriginValidator } from './shared/OriginValidator';
|
|
16
|
+
export { IdGenerator } from './shared/IdGenerator';
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Main entry point for WebBridge
|
|
3
3
|
*/
|
|
4
4
|
// Export parent bridge
|
|
5
|
-
export { ParentBridge } from '
|
|
6
|
-
export { IframeChannel } from '
|
|
5
|
+
export { ParentBridge } from './parent/index';
|
|
6
|
+
export { IframeChannel } from './parent/IframeChannel';
|
|
7
7
|
// Export child bridge
|
|
8
|
-
export { ChildBridge } from '
|
|
8
|
+
export { ChildBridge } from './child/index';
|
|
9
9
|
// Export error handling
|
|
10
|
-
export { BridgeError } from '
|
|
11
|
-
export { errorFactory } from '
|
|
10
|
+
export { BridgeError } from './errors/BridgeError';
|
|
11
|
+
export { errorFactory } from './errors/errorFactory';
|
|
12
12
|
// Export constants
|
|
13
|
-
export { BRIDGE_VERSION, DEFAULT_TIMEOUT, ERROR_CODE, MESSAGE_TYPE } from '
|
|
13
|
+
export { BRIDGE_VERSION, DEFAULT_TIMEOUT, ERROR_CODE, MESSAGE_TYPE } from './constants';
|
|
14
14
|
// Export utilities
|
|
15
|
-
export { EventEmitter } from '
|
|
16
|
-
export { OriginValidator } from '
|
|
17
|
-
export { IdGenerator } from '
|
|
15
|
+
export { EventEmitter } from './shared/EventEmitter';
|
|
16
|
+
export { OriginValidator } from './shared/OriginValidator';
|
|
17
|
+
export { IdGenerator } from './shared/IdGenerator';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* IframeChannel for managing communication with a specific iframe
|
|
3
3
|
*/
|
|
4
|
-
import { BridgeMessage, IframeChannelInterface } from '
|
|
5
|
-
import { MessageHandler } from '
|
|
4
|
+
import { BridgeMessage, IframeChannelInterface } from '../types';
|
|
5
|
+
import { MessageHandler } from '../shared/MessageHandler';
|
|
6
6
|
export declare class IframeChannel extends MessageHandler implements IframeChannelInterface {
|
|
7
7
|
private iframe;
|
|
8
8
|
private iframeOrigin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* IframeChannel for managing communication with a specific iframe
|
|
3
3
|
*/
|
|
4
|
-
import { MessageHandler } from '
|
|
4
|
+
import { MessageHandler } from '../shared/MessageHandler';
|
|
5
5
|
export class IframeChannel extends MessageHandler {
|
|
6
6
|
constructor(iframe, allowedOrigins, timeout = 5000, debug = false) {
|
|
7
7
|
super(allowedOrigins, timeout, debug);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ParentBridge for managing iframe communication from parent
|
|
3
3
|
*/
|
|
4
|
-
import { ParentBridgeConfig, BridgeMessage } from '
|
|
5
|
-
import { MessageHandler } from '
|
|
6
|
-
import { IframeChannel } from '
|
|
4
|
+
import { ParentBridgeConfig, BridgeMessage } from '../types';
|
|
5
|
+
import { MessageHandler } from '../shared/MessageHandler';
|
|
6
|
+
import { IframeChannel } from '../parent/IframeChannel';
|
|
7
7
|
export declare class ParentBridge extends MessageHandler {
|
|
8
8
|
private channels;
|
|
9
9
|
constructor(config: ParentBridgeConfig);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ParentBridge for managing iframe communication from parent
|
|
3
3
|
*/
|
|
4
|
-
import { MessageHandler } from '
|
|
5
|
-
import { IframeChannel } from '
|
|
6
|
-
import { DEFAULT_TIMEOUT } from '
|
|
4
|
+
import { MessageHandler } from '../shared/MessageHandler';
|
|
5
|
+
import { IframeChannel } from '../parent/IframeChannel';
|
|
6
|
+
import { DEFAULT_TIMEOUT } from '../constants';
|
|
7
7
|
export class ParentBridge extends MessageHandler {
|
|
8
8
|
constructor(config) {
|
|
9
9
|
const timeout = config.timeout || DEFAULT_TIMEOUT;
|
package/dist/parent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ParentBridge } from '
|
|
2
|
-
export { IframeChannel } from '
|
|
3
|
-
export type { IframeChannelInterface } from '
|
|
4
|
-
export type { ParentBridgeConfig } from '
|
|
5
|
-
export * from '
|
|
1
|
+
export { ParentBridge } from '../parent/ParentBridge';
|
|
2
|
+
export { IframeChannel } from '../parent/IframeChannel';
|
|
3
|
+
export type { IframeChannelInterface } from '../types';
|
|
4
|
+
export type { ParentBridgeConfig } from '../types';
|
|
5
|
+
export * from '../parent/utils';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/parent/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ParentBridge } from '
|
|
2
|
-
export { IframeChannel } from '
|
|
3
|
-
export * from '
|
|
1
|
+
export { ParentBridge } from '../parent/ParentBridge';
|
|
2
|
+
export { IframeChannel } from '../parent/IframeChannel';
|
|
3
|
+
export * from '../parent/utils';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Simple EventEmitter for bridge events
|
|
3
3
|
*/
|
|
4
|
-
import { BridgeEventType } from '
|
|
4
|
+
import { BridgeEventType } from '../types';
|
|
5
5
|
export declare class EventEmitter {
|
|
6
6
|
private listeners;
|
|
7
7
|
on(type: BridgeEventType, callback: (data?: any) => void): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base class for handling postMessage communication
|
|
3
3
|
*/
|
|
4
|
-
import { BridgeMessage, HandlerRegistry, PendingRequest } from '
|
|
5
|
-
import { EventEmitter } from '
|
|
6
|
-
import { OriginValidator } from '
|
|
7
|
-
import { IdGenerator } from '
|
|
4
|
+
import { BridgeMessage, HandlerRegistry, PendingRequest } from '../types';
|
|
5
|
+
import { EventEmitter } from '../shared/EventEmitter';
|
|
6
|
+
import { OriginValidator } from '../shared/OriginValidator';
|
|
7
|
+
import { IdGenerator } from '../shared/IdGenerator';
|
|
8
8
|
export declare abstract class MessageHandler {
|
|
9
9
|
protected handlers: HandlerRegistry;
|
|
10
10
|
protected pendingRequests: Map<string, PendingRequest>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base class for handling postMessage communication
|
|
3
3
|
*/
|
|
4
|
-
import { EventEmitter } from '
|
|
5
|
-
import { OriginValidator } from '
|
|
6
|
-
import { IdGenerator } from '
|
|
7
|
-
import { errorFactory } from '
|
|
8
|
-
import { DEFAULT_TIMEOUT } from '
|
|
4
|
+
import { EventEmitter } from '../shared/EventEmitter';
|
|
5
|
+
import { OriginValidator } from '../shared/OriginValidator';
|
|
6
|
+
import { IdGenerator } from '../shared/IdGenerator';
|
|
7
|
+
import { errorFactory } from '../errors/errorFactory';
|
|
8
|
+
import { DEFAULT_TIMEOUT } from '../constants';
|
|
9
9
|
export class MessageHandler {
|
|
10
10
|
constructor(allowedOrigins, timeout = DEFAULT_TIMEOUT, debug = false) {
|
|
11
11
|
this.handlers = new Map();
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kookapp/web-bridge",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "PostMessage-based bridge for iframe communication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
8
|
+
"build": "tsc && tsc-alias",
|
|
9
9
|
"dev": "tsc --watch",
|
|
10
10
|
"test": "jest",
|
|
11
11
|
"test:watch": "jest --watch"
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/jest": "^29.5.0",
|
|
17
|
-
"typescript": "^5.0.0",
|
|
18
17
|
"jest": "^29.5.0",
|
|
19
18
|
"jest-environment-jsdom": "^29.5.0",
|
|
20
|
-
"ts-jest": "^29.1.0"
|
|
19
|
+
"ts-jest": "^29.1.0",
|
|
20
|
+
"tsc-alias": "^1.8.16",
|
|
21
|
+
"typescript": "^5.0.0"
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
24
|
"dist"
|