@farcaster/frame-host 0.0.8 → 0.0.9
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/comlink/comlink.d.ts +155 -0
- package/dist/comlink/comlink.js +367 -0
- package/dist/comlink/index.d.ts +1 -0
- package/dist/comlink/index.js +1 -0
- package/dist/comlink/node-adapter.d.ts +13 -0
- package/dist/comlink/node-adapter.js +32 -0
- package/dist/comlink/protocol.d.ts +75 -0
- package/dist/comlink/protocol.js +6 -0
- package/dist/helpers/endpoint.js +3 -2
- package/dist/iframe.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -5
- package/src/comlink/comlink.ts +655 -0
- package/src/comlink/index.ts +1 -0
- package/src/comlink/node-adapter.ts +49 -0
- package/src/comlink/protocol.ts +111 -0
- package/src/helpers/endpoint.ts +3 -2
- package/src/iframe.ts +1 -1
- package/src/types.ts +2 -2
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface EventSource {
|
|
8
|
+
addEventListener(
|
|
9
|
+
type: string,
|
|
10
|
+
listener: EventListenerOrEventListenerObject,
|
|
11
|
+
options?: {}
|
|
12
|
+
): void;
|
|
13
|
+
|
|
14
|
+
removeEventListener(
|
|
15
|
+
type: string,
|
|
16
|
+
listener: EventListenerOrEventListenerObject,
|
|
17
|
+
options?: {}
|
|
18
|
+
): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PostMessageWithOrigin {
|
|
22
|
+
postMessage(
|
|
23
|
+
message: any,
|
|
24
|
+
targetOrigin: string,
|
|
25
|
+
transfer?: Transferable[]
|
|
26
|
+
): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Endpoint extends EventSource {
|
|
30
|
+
postMessage(message: any, transfer?: Transferable[]): void;
|
|
31
|
+
|
|
32
|
+
start?: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const enum WireValueType {
|
|
36
|
+
RAW = "RAW",
|
|
37
|
+
PROXY = "PROXY",
|
|
38
|
+
THROW = "THROW",
|
|
39
|
+
HANDLER = "HANDLER",
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RawWireValue {
|
|
43
|
+
id?: string;
|
|
44
|
+
type: WireValueType.RAW;
|
|
45
|
+
value: {};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface HandlerWireValue {
|
|
49
|
+
id?: string;
|
|
50
|
+
type: WireValueType.HANDLER;
|
|
51
|
+
name: string;
|
|
52
|
+
value: unknown;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type WireValue = RawWireValue | HandlerWireValue;
|
|
56
|
+
|
|
57
|
+
export type MessageID = string;
|
|
58
|
+
|
|
59
|
+
export const enum MessageType {
|
|
60
|
+
GET = "GET",
|
|
61
|
+
SET = "SET",
|
|
62
|
+
APPLY = "APPLY",
|
|
63
|
+
CONSTRUCT = "CONSTRUCT",
|
|
64
|
+
ENDPOINT = "ENDPOINT",
|
|
65
|
+
RELEASE = "RELEASE",
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface GetMessage {
|
|
69
|
+
id?: MessageID;
|
|
70
|
+
type: MessageType.GET;
|
|
71
|
+
path: string[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface SetMessage {
|
|
75
|
+
id?: MessageID;
|
|
76
|
+
type: MessageType.SET;
|
|
77
|
+
path: string[];
|
|
78
|
+
value: WireValue;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ApplyMessage {
|
|
82
|
+
id?: MessageID;
|
|
83
|
+
type: MessageType.APPLY;
|
|
84
|
+
path: string[];
|
|
85
|
+
argumentList: WireValue[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ConstructMessage {
|
|
89
|
+
id?: MessageID;
|
|
90
|
+
type: MessageType.CONSTRUCT;
|
|
91
|
+
path: string[];
|
|
92
|
+
argumentList: WireValue[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface EndpointMessage {
|
|
96
|
+
id?: MessageID;
|
|
97
|
+
type: MessageType.ENDPOINT;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ReleaseMessage {
|
|
101
|
+
id?: MessageID;
|
|
102
|
+
type: MessageType.RELEASE;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type Message =
|
|
106
|
+
| GetMessage
|
|
107
|
+
| SetMessage
|
|
108
|
+
| ApplyMessage
|
|
109
|
+
| ConstructMessage
|
|
110
|
+
| EndpointMessage
|
|
111
|
+
| ReleaseMessage;
|
package/src/helpers/endpoint.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as Comlink from "comlink";
|
|
1
|
+
import * as Comlink from "../comlink";
|
|
2
2
|
import { FrameHost } from "@farcaster/frame-core";
|
|
3
3
|
import { Provider } from "ox";
|
|
4
4
|
import { forwardProviderEvents, wrapProviderRequest } from "./provider";
|
|
@@ -26,9 +26,10 @@ export function exposeToEndpoint({
|
|
|
26
26
|
cleanup = forwardProviderEvents(ethProvider, endpoint);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
Comlink.expose(extendedSdk, endpoint, [frameOrigin]);
|
|
29
|
+
const unexpose = Comlink.expose(extendedSdk, endpoint, [frameOrigin]);
|
|
30
30
|
|
|
31
31
|
return () => {
|
|
32
32
|
cleanup?.();
|
|
33
|
+
unexpose();
|
|
33
34
|
}
|
|
34
35
|
}
|
package/src/iframe.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Endpoint } from "./comlink";
|
|
2
2
|
import type { EmitEthProvider } from "@farcaster/frame-core";
|
|
3
3
|
|
|
4
|
-
export type HostEndpoint =
|
|
4
|
+
export type HostEndpoint = Endpoint & {
|
|
5
5
|
emit: (data: any) => void;
|
|
6
6
|
emitEthProvider: EmitEthProvider;
|
|
7
7
|
};
|