chrome-in-iframe 2.0.1 → 2.1.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.
@@ -1,10 +1,10 @@
1
- import type { ClientContext, MessageMeta, MessageValue, PathKey, RequestId, SerializedError } from '../channel/types';
1
+ import type { ClientContext, MessageMeta, MessageValue, PathKey, RequestId } from '../channel/types.js';
2
2
  export declare function handleAccessPropertyRequest(data: {
3
3
  id: RequestId;
4
4
  path: PathKey[];
5
5
  }, ctx: ClientContext, meta: MessageMeta): void;
6
- export declare function handleAccessPropertyResponse(data: {
6
+ export declare const handleAccessPropertyResponse: (data: {
7
7
  id: RequestId;
8
8
  data?: MessageValue;
9
- error?: SerializedError;
10
- }, ctx: ClientContext, meta: MessageMeta): void;
9
+ error?: import("..").SerializedError;
10
+ }, ctx: ClientContext, meta: MessageMeta) => void;
@@ -0,0 +1,21 @@
1
+ import type { Callable, CallbackCacheOptions, ClientContext, MessageMeta, MessageValue, RequestId, SerializedError } from '../channel/types.js';
2
+ export type ResponseMessageType = 'invokeResponse' | 'accessPropertyResponse' | 'invokeFunctionByIdResponse';
3
+ export interface Responder {
4
+ respondError(message: string): void;
5
+ respondThrown(err: unknown): void;
6
+ respondSuccess(value: MessageValue): void;
7
+ }
8
+ export declare function createResponder(ctx: ClientContext, targetInstanceId: string, responseType: ResponseMessageType, id: RequestId): Responder;
9
+ export declare function createScopedRemoteCallback(ctx: ClientContext, remoteInstanceId: string): (id: string, invoke: (args: MessageValue[]) => MessageValue, options?: CallbackCacheOptions) => Callable;
10
+ export declare function createGenerateCallback(ctx: ClientContext, remoteInstanceId: string): (id: string, args: MessageValue[], options?: CallbackCacheOptions) => MessageValue;
11
+ export declare function safeInvokeReject(callbacks: {
12
+ onReject?: () => void;
13
+ }, scope: string, warn: (scope: string, ...args: unknown[]) => void): void;
14
+ export declare function safeInvokeResolve(callbacks: {
15
+ onResolve?: () => void;
16
+ }, scope: string, warn: (scope: string, ...args: unknown[]) => void): void;
17
+ export declare function createResponseHandler(scope: string, warn: (scope: string, ...args: unknown[]) => void): (data: {
18
+ id: RequestId;
19
+ data?: MessageValue;
20
+ error?: SerializedError;
21
+ }, ctx: ClientContext, meta: MessageMeta) => void;
@@ -1,11 +1,11 @@
1
- import type { ClientContext, MessageMeta, MessageValue, PathKey, RequestId, SerializedError } from '../channel/types';
1
+ import type { ClientContext, MessageMeta, MessageValue, PathKey, RequestId } from '../channel/types.js';
2
2
  export declare function handleInvokeRequest(data: {
3
3
  id: RequestId;
4
4
  path: PathKey[];
5
5
  args: MessageValue[];
6
6
  }, ctx: ClientContext, meta: MessageMeta): void;
7
- export declare function handleInvokeResponse(data: {
7
+ export declare const handleInvokeResponse: (data: {
8
8
  id: RequestId;
9
9
  data?: MessageValue;
10
- error?: SerializedError;
11
- }, ctx: ClientContext, meta: MessageMeta): void;
10
+ error?: import("..").SerializedError;
11
+ }, ctx: ClientContext, meta: MessageMeta) => void;
@@ -1,11 +1,11 @@
1
- import type { ClientContext, MessageMeta, MessageValue, RequestId, SerializedError } from '../channel/types';
1
+ import type { ClientContext, MessageMeta, MessageValue, RequestId } from '../channel/types.js';
2
2
  export declare function handleCallbackInvoke(data: {
3
3
  id: string;
4
4
  callId: RequestId;
5
5
  args: MessageValue[];
6
6
  }, ctx: ClientContext, meta: MessageMeta): void;
7
- export declare function handleCallbackInvokeResponse(data: {
7
+ export declare const handleCallbackInvokeResponse: (data: {
8
8
  id: RequestId;
9
9
  data?: MessageValue;
10
- error?: SerializedError;
11
- }, ctx: ClientContext, meta: MessageMeta): void;
10
+ error?: import("..").SerializedError;
11
+ }, ctx: ClientContext, meta: MessageMeta) => void;
@@ -1,3 +1,5 @@
1
- import type { ClientContext, MessageMeta, Messages } from '../channel/types';
1
+ import type { ClientContext, MessageMeta, Messages } from '../channel/types.js';
2
+ export declare function handleConnectRequest(_data: Messages['connectRequest'], ctx: ClientContext, meta: MessageMeta): void;
3
+ export declare function handleConnectResponse(_data: Messages['connectResponse'], ctx: ClientContext, meta: MessageMeta): void;
2
4
  export declare function handleReleaseCallbacks(data: Messages['releaseCallbacks'], ctx: ClientContext, meta: MessageMeta): void;
3
- export declare function handleDestroyEndpoint(_data: Messages['destroyEndpoint'], ctx: ClientContext, meta: MessageMeta): void;
5
+ export declare function handleDestroyEndpoint(data: Messages['destroyEndpoint'], ctx: ClientContext, meta: MessageMeta): void;
@@ -1,2 +1,2 @@
1
- import type { MessageValue, PathKey } from '../channel/types';
1
+ import type { MessageValue, PathKey } from '../channel/types.js';
2
2
  export declare function readProperty(target: MessageValue, key: PathKey): MessageValue;
@@ -1,4 +1,4 @@
1
- import type { MessageType, RequestHandler } from '../channel/types';
1
+ import type { MessageType, RequestHandler } from '../channel/types.js';
2
2
  export declare function createProcessorRegistry(): {
3
3
  register<K extends MessageType>(type: K, handler: RequestHandler<K>): void;
4
4
  get<K extends MessageType>(type: MessageType): RequestHandler<K> | undefined;
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "chrome-in-iframe",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Bridge library that allows iframes in Chrome extension pages to call Chrome extension APIs",
5
5
  "license": "ISC",
6
6
  "author": "GumerLee",
7
7
  "type": "module",
8
- "main": "./dist/index.js",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
9
10
  "types": "./dist/index.d.ts",
10
11
  "sideEffects": false,
11
12
  "exports": {
12
13
  ".": {
13
14
  "types": "./dist/index.d.ts",
14
15
  "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs",
15
17
  "default": "./dist/index.js"
16
18
  },
17
19
  "./package.json": "./package.json"
@@ -33,7 +35,7 @@
33
35
  "node": ">=18"
34
36
  },
35
37
  "scripts": {
36
- "build": "rollup -c",
38
+ "build": "rollup -c && node scripts/fix-dts-extensions.mjs",
37
39
  "dev": "rollup -c -w",
38
40
  "test": "vitest run",
39
41
  "lint": "eslint src test",
@@ -48,6 +50,7 @@
48
50
  "devDependencies": {
49
51
  "@eslint/js": "^9.39.4",
50
52
  "@ianvs/prettier-plugin-sort-imports": "^4.7.1",
53
+ "@rollup/plugin-node-resolve": "^16.0.3",
51
54
  "@rollup/plugin-typescript": "^12.3.0",
52
55
  "@types/chrome": "^0.1.42",
53
56
  "eslint": "^9.39.4",