@notionhq/custom-blocks 0.0.77 → 0.0.79
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/HOST.md +68 -34
- package/README.md +1 -1
- package/bin/src/bridge/manifest.js +3 -3
- package/dist/bridge/SandboxBridge.d.ts +8 -13
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +110 -39
- package/dist/bridge/dataSources/resolve.d.ts +3 -4
- package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolve.js +2 -12
- package/dist/bridge/hostState.d.ts +2 -0
- package/dist/bridge/hostState.d.ts.map +1 -1
- package/dist/bridge/loadManifest.d.ts +4 -4
- package/dist/bridge/loadManifest.d.ts.map +1 -1
- package/dist/bridge/loadManifest.js +2 -2
- package/dist/bridge/manifest.d.ts +3 -3
- package/dist/bridge/manifest.js +3 -3
- package/dist/bridge/messages/{ready.d.ts → connect.d.ts} +14 -12
- package/dist/bridge/messages/connect.d.ts.map +1 -0
- package/dist/bridge/messages/connect.js +38 -0
- package/dist/bridge/messages/hostToSandbox.d.ts +21 -0
- package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -1
- package/dist/bridge/messages/init.d.ts +35 -6
- package/dist/bridge/messages/init.d.ts.map +1 -1
- package/dist/bridge/messages/init.js +8 -4
- package/dist/bridge/messages/initResult.d.ts +29 -0
- package/dist/bridge/messages/initResult.d.ts.map +1 -0
- package/dist/bridge/messages/initResult.js +25 -0
- package/dist/bridge/messages/sandboxToHost.d.ts +21 -6
- package/dist/bridge/messages/sandboxToHost.d.ts.map +1 -1
- package/dist/bridge/messages/sandboxToHost.js +4 -2
- package/dist/bridge/sandboxClient.d.ts +2 -4
- package/dist/bridge/sandboxClient.d.ts.map +1 -1
- package/dist/bridge/sandboxClient.js +2 -5
- package/dist/customBlock.d.ts +1 -1
- package/dist/customBlock.d.ts.map +1 -1
- package/dist/customBlock.js +1 -1
- package/dist/host/createCustomBlockHost.d.ts +7 -4
- package/dist/host/createCustomBlockHost.d.ts.map +1 -1
- package/dist/host/createCustomBlockHost.js +215 -38
- package/dist/host/lifecycle/initErrors.d.ts +1 -1
- package/dist/host/lifecycle/initErrors.d.ts.map +1 -1
- package/dist/host/lifecycle/initErrors.js +25 -7
- package/dist/host/lifecycle/{ready.d.ts → protocolVersion.d.ts} +1 -1
- package/dist/host/lifecycle/protocolVersion.d.ts.map +1 -0
- package/dist/host/lifecycle/types.d.ts +6 -4
- package/dist/host/lifecycle/types.d.ts.map +1 -1
- package/dist/host/messages/invalidSandboxMessage.js +0 -3
- package/dist/host.d.ts +5 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/init.d.ts +7 -7
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +70 -50
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/standalonePreview.d.ts.map +1 -1
- package/dist/react/standalonePreview.js +2 -0
- package/dist/react/useCustomBlockInit.d.ts +5 -6
- package/dist/react/useCustomBlockInit.d.ts.map +1 -1
- package/dist/react/useCustomBlockInit.js +3 -19
- package/dist/react/useRuntimeState.d.ts +4 -3
- package/dist/react/useRuntimeState.d.ts.map +1 -1
- package/dist/react/useRuntimeState.js +3 -2
- package/dist/version.js +1 -1
- package/docs/data-sources.md +10 -8
- package/docs/errors.md +5 -1
- package/docs/lifecycle.md +19 -31
- package/docs/manifest.md +1 -1
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +138 -44
- package/src/bridge/dataSources/resolve.ts +3 -14
- package/src/bridge/hostState.ts +2 -0
- package/src/bridge/loadManifest.ts +6 -6
- package/src/bridge/manifest.ts +3 -3
- package/src/bridge/messages/connect.ts +42 -0
- package/src/bridge/messages/init.ts +24 -10
- package/src/bridge/messages/initResult.ts +37 -0
- package/src/bridge/messages/sandboxToHost.ts +4 -2
- package/src/bridge/sandboxClient.ts +3 -8
- package/src/customBlock.ts +2 -2
- package/src/host/createCustomBlockHost.ts +265 -45
- package/src/host/lifecycle/initErrors.ts +25 -7
- package/src/host/lifecycle/types.ts +13 -4
- package/src/host/messages/invalidSandboxMessage.ts +0 -3
- package/src/host.ts +13 -2
- package/src/index.ts +3 -1
- package/src/init.ts +73 -60
- package/src/react/index.ts +0 -1
- package/src/react/standalonePreview.ts +2 -0
- package/src/react/useCustomBlockInit.ts +6 -27
- package/src/react/useRuntimeState.ts +4 -3
- package/dist/bridge/messages/ready.d.ts.map +0 -1
- package/dist/bridge/messages/ready.js +0 -43
- package/dist/host/lifecycle/ready.d.ts.map +0 -1
- package/src/bridge/messages/ready.ts +0 -48
- /package/dist/host/lifecycle/{ready.js → protocolVersion.js} +0 -0
- /package/src/host/lifecycle/{ready.ts → protocolVersion.ts} +0 -0
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import type { NotionDataSourceId } from "../bridge/ids.js";
|
|
2
2
|
import type { HostToSandboxMessage } from "../bridge/messages/hostToSandbox.js";
|
|
3
|
+
import type { InitResultMessage } from "../bridge/messages/initResult.js";
|
|
3
4
|
import type { CustomBlockPage } from "../bridge/pages/page.js";
|
|
4
5
|
import type { NotionParent } from "../bridge/parent.js";
|
|
5
6
|
import type { NotionTheme } from "../bridge/theme.js";
|
|
6
7
|
import type { NotionUser } from "../bridge/users/user.js";
|
|
7
|
-
import type { CustomBlockHostDataSourcesPayload, CustomBlockHostInitialState
|
|
8
|
+
import type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostInitialState } from "./lifecycle/types.js";
|
|
8
9
|
import type { CustomBlockHostHandlers, CustomBlockHostLogDirection } from "./messages/types.js";
|
|
9
10
|
import type { CustomBlockHostQueryDataSourceResult } from "./queries/types.js";
|
|
10
11
|
export type CustomBlockHostOptions = {
|
|
11
12
|
iframe: HTMLIFrameElement;
|
|
12
13
|
targetOrigin?: string;
|
|
13
|
-
minBridgeProtocolVersion
|
|
14
|
-
|
|
14
|
+
minBridgeProtocolVersion: number;
|
|
15
|
+
noConnectTimeoutMs?: number;
|
|
16
|
+
noInitResultTimeoutMs?: number;
|
|
15
17
|
initialState: CustomBlockHostInitialState;
|
|
16
18
|
handlers: CustomBlockHostHandlers;
|
|
17
|
-
|
|
19
|
+
onConnect?: (message: ConnectSuccessMessage) => void;
|
|
20
|
+
onInitResult?: (message: InitResultMessage) => void;
|
|
18
21
|
onLog?: (direction: CustomBlockHostLogDirection, payload: unknown) => void;
|
|
19
22
|
};
|
|
20
23
|
export type CustomBlockHostHandle = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/createCustomBlockHost.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/createCustomBlockHost.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAc1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAM/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAazE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIzD,OAAO,KAAK,EACX,qBAAqB,EACrB,iCAAiC,EACjC,2BAA2B,EAE3B,MAAM,sBAAsB,CAAA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;AAQD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CA+fvB"}
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { sandboxToHostMessageSchema } from "../bridge/messages/sandboxToHost.js";
|
|
3
|
+
import { CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION } from "../bridge/SandboxBridge.js";
|
|
3
4
|
import { unreachable } from "../utils.js";
|
|
4
5
|
import { initErrorForFailureReason } from "./lifecycle/initErrors.js";
|
|
5
|
-
import { isValidBridgeProtocolVersion } from "./lifecycle/
|
|
6
|
+
import { isValidBridgeProtocolVersion } from "./lifecycle/protocolVersion.js";
|
|
6
7
|
import { getInvalidSandboxMessageResponse } from "./messages/invalidSandboxMessage.js";
|
|
7
8
|
import { QuerySubscriptions } from "./queries/querySubscriptions.js";
|
|
8
|
-
const
|
|
9
|
-
const
|
|
9
|
+
const DEFAULT_NO_CONNECT_TIMEOUT_MS = 5000;
|
|
10
|
+
const DEFAULT_NO_INIT_RESULT_TIMEOUT_MS = 5000;
|
|
11
|
+
const initializationIdentitySchema = v.object({
|
|
12
|
+
initializationId: v.string(),
|
|
13
|
+
});
|
|
10
14
|
export function createCustomBlockHost(options) {
|
|
11
|
-
const { iframe, initialState, handlers,
|
|
15
|
+
const { iframe, initialState, handlers, onConnect, onInitResult, onLog, targetOrigin = "*", minBridgeProtocolVersion: configuredMinBridgeProtocolVersion, noConnectTimeoutMs = DEFAULT_NO_CONNECT_TIMEOUT_MS, noInitResultTimeoutMs = DEFAULT_NO_INIT_RESULT_TIMEOUT_MS, } = options;
|
|
16
|
+
const minBridgeProtocolVersion = Math.max(configuredMinBridgeProtocolVersion ?? CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION, CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION);
|
|
12
17
|
let theme = initialState.theme;
|
|
13
18
|
let parent = initialState.parent;
|
|
14
19
|
let page = initialState.page;
|
|
15
20
|
let dataSources = initialState.dataSources;
|
|
21
|
+
let manifest = initialState.manifest;
|
|
16
22
|
let currentUser = initialState.currentUser;
|
|
17
|
-
let initStatus = "
|
|
18
|
-
let
|
|
23
|
+
let initStatus = "waitingForConnect";
|
|
24
|
+
let noConnectTimeoutId;
|
|
25
|
+
let noInitResultTimeoutId;
|
|
26
|
+
let activeInitializationId;
|
|
27
|
+
let connectedSandbox;
|
|
28
|
+
let pendingThemeChange = false;
|
|
29
|
+
let pendingParentChange = false;
|
|
30
|
+
let pendingPageChange = false;
|
|
31
|
+
let pendingDataSourcesChange;
|
|
32
|
+
let pendingCurrentUserChange = false;
|
|
19
33
|
const querySubscriptions = new QuerySubscriptions();
|
|
20
34
|
function emit(direction, payload) {
|
|
21
35
|
onLog?.(direction, payload);
|
|
@@ -41,52 +55,91 @@ export function createCustomBlockHost(options) {
|
|
|
41
55
|
};
|
|
42
56
|
post(message);
|
|
43
57
|
}
|
|
44
|
-
function
|
|
45
|
-
if (
|
|
46
|
-
window.clearTimeout(
|
|
47
|
-
|
|
58
|
+
function clearNoConnectTimeout() {
|
|
59
|
+
if (noConnectTimeoutId !== undefined) {
|
|
60
|
+
window.clearTimeout(noConnectTimeoutId);
|
|
61
|
+
noConnectTimeoutId = undefined;
|
|
48
62
|
}
|
|
49
63
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
64
|
+
function clearNoInitResultTimeout() {
|
|
65
|
+
if (noInitResultTimeoutId !== undefined) {
|
|
66
|
+
window.clearTimeout(noInitResultTimeoutId);
|
|
67
|
+
noInitResultTimeoutId = undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function resolveDataSourcesPayload(connect) {
|
|
71
|
+
return typeof dataSources === "function"
|
|
72
|
+
? dataSources(connect)
|
|
73
|
+
: dataSources;
|
|
52
74
|
}
|
|
53
|
-
function sendInit(
|
|
54
|
-
if (initStatus !== "
|
|
75
|
+
function sendInit(connect) {
|
|
76
|
+
if (initStatus !== "waitingForConnect") {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
onConnect?.(connect);
|
|
80
|
+
manifest = connect.manifest ?? initialState.manifest;
|
|
81
|
+
const resolvedDataSources = resolveDataSourcesPayload(connect);
|
|
82
|
+
const bindingErrorCode = getBindingErrorCode(manifest, resolvedDataSources);
|
|
83
|
+
if (bindingErrorCode !== undefined) {
|
|
84
|
+
sendInitError(connect.initializationId, initErrorForFailureReason(bindingErrorCode));
|
|
55
85
|
return false;
|
|
56
86
|
}
|
|
57
|
-
initStatus = "
|
|
58
|
-
|
|
87
|
+
initStatus = "waitingForInitResult";
|
|
88
|
+
activeInitializationId = connect.initializationId;
|
|
89
|
+
clearNoConnectTimeout();
|
|
59
90
|
const message = {
|
|
60
91
|
type: "init",
|
|
92
|
+
initializationId: connect.initializationId,
|
|
61
93
|
status: "success",
|
|
62
94
|
theme,
|
|
63
95
|
blockId: initialState.blockId,
|
|
64
96
|
parent,
|
|
65
97
|
page,
|
|
66
|
-
|
|
98
|
+
manifest,
|
|
99
|
+
dataSources: resolvedDataSources,
|
|
67
100
|
currentUser,
|
|
68
101
|
};
|
|
69
102
|
post(message);
|
|
103
|
+
noInitResultTimeoutId = window.setTimeout(() => {
|
|
104
|
+
if (initStatus !== "waitingForInitResult") {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
initStatus = "error";
|
|
108
|
+
emit("warn", {
|
|
109
|
+
message: "Sandbox did not send initResult",
|
|
110
|
+
initializationId: connect.initializationId,
|
|
111
|
+
});
|
|
112
|
+
}, noInitResultTimeoutMs);
|
|
70
113
|
return true;
|
|
71
114
|
}
|
|
72
|
-
function sendInitError(error) {
|
|
73
|
-
if (initStatus !== "
|
|
115
|
+
function sendInitError(initializationId, error) {
|
|
116
|
+
if (initStatus !== "waitingForConnect") {
|
|
74
117
|
return;
|
|
75
118
|
}
|
|
76
119
|
initStatus = "error";
|
|
77
|
-
|
|
120
|
+
activeInitializationId = initializationId;
|
|
121
|
+
clearNoConnectTimeout();
|
|
78
122
|
post({
|
|
79
123
|
type: "init",
|
|
124
|
+
initializationId,
|
|
80
125
|
status: "error",
|
|
81
126
|
error,
|
|
82
127
|
});
|
|
83
128
|
}
|
|
84
129
|
function onIframeLoad() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
130
|
+
clearNoConnectTimeout();
|
|
131
|
+
if (initStatus !== "waitingForConnect") {
|
|
132
|
+
// Only set the timeout if the iframe loaded before the `connect` message was sent.
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
noConnectTimeoutId = window.setTimeout(() => {
|
|
136
|
+
if (initStatus !== "waitingForConnect") {
|
|
137
|
+
// Only do anything if the iframe loaded before the `connect` message was sent.
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
initStatus = "error";
|
|
141
|
+
emit("warn", initErrorForFailureReason("no_connect"));
|
|
142
|
+
}, noConnectTimeoutMs);
|
|
90
143
|
}
|
|
91
144
|
async function handleQuery(message) {
|
|
92
145
|
const token = querySubscriptions.track(message);
|
|
@@ -159,13 +212,13 @@ export function createCustomBlockHost(options) {
|
|
|
159
212
|
};
|
|
160
213
|
post(result);
|
|
161
214
|
}
|
|
162
|
-
function
|
|
215
|
+
function handleConnect(message) {
|
|
163
216
|
// Verify the bridge protocol version is valid.
|
|
164
217
|
if (!isValidBridgeProtocolVersion(message.bridgeProtocolVersion)) {
|
|
165
218
|
const initError = initErrorForFailureReason("invalid_protocol_version", {
|
|
166
219
|
currentBridgeProtocolVersion: message.bridgeProtocolVersion,
|
|
167
220
|
});
|
|
168
|
-
sendInitError(initError);
|
|
221
|
+
sendInitError(message.initializationId, initError);
|
|
169
222
|
return;
|
|
170
223
|
}
|
|
171
224
|
if (message.bridgeProtocolVersion < minBridgeProtocolVersion) {
|
|
@@ -173,17 +226,62 @@ export function createCustomBlockHost(options) {
|
|
|
173
226
|
currentBridgeProtocolVersion: message.bridgeProtocolVersion,
|
|
174
227
|
minBridgeProtocolVersion,
|
|
175
228
|
});
|
|
176
|
-
sendInitError(initError);
|
|
229
|
+
sendInitError(message.initializationId, initError);
|
|
177
230
|
return;
|
|
178
231
|
}
|
|
179
|
-
// If the sandbox reported an error during `
|
|
232
|
+
// If the sandbox reported an error during `connect`, return it as an `init` error.
|
|
180
233
|
if (message.status === "error") {
|
|
181
|
-
sendInitError(message.error);
|
|
234
|
+
sendInitError(message.initializationId, message.error);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (!sendInit(message)) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
connectedSandbox = message;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sends any pending host state changes to the sandbox. It is possible for these to change
|
|
244
|
+
* between when the host sends `init` and when the sandbox responds with `initResult`. The host
|
|
245
|
+
* does send any pending state changes until hearing back from the sandbox.
|
|
246
|
+
*/
|
|
247
|
+
function flushPendingHostStateChanges() {
|
|
248
|
+
if (pendingThemeChange) {
|
|
249
|
+
pendingThemeChange = false;
|
|
250
|
+
post({ type: "themeChanged", theme });
|
|
251
|
+
}
|
|
252
|
+
if (pendingParentChange) {
|
|
253
|
+
pendingParentChange = false;
|
|
254
|
+
post({ type: "parentChanged", parent });
|
|
255
|
+
}
|
|
256
|
+
if (pendingPageChange) {
|
|
257
|
+
pendingPageChange = false;
|
|
258
|
+
post({ type: "pageChanged", page });
|
|
259
|
+
}
|
|
260
|
+
if (pendingDataSourcesChange !== undefined) {
|
|
261
|
+
const nextDataSources = pendingDataSourcesChange;
|
|
262
|
+
pendingDataSourcesChange = undefined;
|
|
263
|
+
post({ type: "dataSourcesChanged", dataSources: nextDataSources });
|
|
264
|
+
}
|
|
265
|
+
if (pendingCurrentUserChange) {
|
|
266
|
+
pendingCurrentUserChange = false;
|
|
267
|
+
post({ type: "currentUserChanged", currentUser });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function handleInitResult(message) {
|
|
271
|
+
if (initStatus !== "waitingForInitResult" ||
|
|
272
|
+
message.initializationId !== activeInitializationId) {
|
|
273
|
+
emit("warn", {
|
|
274
|
+
message: "Ignored stale or unexpected initResult",
|
|
275
|
+
payload: message,
|
|
276
|
+
});
|
|
182
277
|
return;
|
|
183
278
|
}
|
|
184
|
-
|
|
185
|
-
|
|
279
|
+
clearNoInitResultTimeout();
|
|
280
|
+
initStatus = message.status === "success" ? "success" : "error";
|
|
281
|
+
if (initStatus === "success") {
|
|
282
|
+
flushPendingHostStateChanges();
|
|
186
283
|
}
|
|
284
|
+
onInitResult?.(message);
|
|
187
285
|
}
|
|
188
286
|
function onInvalidSandboxMessage(data, issues) {
|
|
189
287
|
emit("warn", {
|
|
@@ -192,9 +290,14 @@ export function createCustomBlockHost(options) {
|
|
|
192
290
|
issues,
|
|
193
291
|
});
|
|
194
292
|
const response = getInvalidSandboxMessageResponse(data);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
293
|
+
const parsedIdentity = v.safeParse(initializationIdentitySchema, data);
|
|
294
|
+
const initializationId = parsedIdentity.success
|
|
295
|
+
? parsedIdentity.output.initializationId
|
|
296
|
+
: undefined;
|
|
297
|
+
if (initStatus === "waitingForConnect" &&
|
|
298
|
+
response.incomingType === "connect" &&
|
|
299
|
+
initializationId !== undefined) {
|
|
300
|
+
sendInitError(initializationId, initErrorForFailureReason("invalid_connect"));
|
|
198
301
|
}
|
|
199
302
|
else if (response.nack !== undefined) {
|
|
200
303
|
post(response.nack);
|
|
@@ -211,9 +314,21 @@ export function createCustomBlockHost(options) {
|
|
|
211
314
|
}
|
|
212
315
|
const message = parsed.output;
|
|
213
316
|
emit("in", message);
|
|
317
|
+
if (message.type !== "connect" &&
|
|
318
|
+
message.type !== "initResult" &&
|
|
319
|
+
initStatus !== "success") {
|
|
320
|
+
emit("warn", {
|
|
321
|
+
message: `Ignored ${message.type} before initialization completed`,
|
|
322
|
+
payload: message,
|
|
323
|
+
});
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
214
326
|
switch (message.type) {
|
|
215
|
-
case "
|
|
216
|
-
|
|
327
|
+
case "connect":
|
|
328
|
+
handleConnect(message);
|
|
329
|
+
return;
|
|
330
|
+
case "initResult":
|
|
331
|
+
handleInitResult(message);
|
|
217
332
|
return;
|
|
218
333
|
case "queryDataSource":
|
|
219
334
|
void handleQuery(message);
|
|
@@ -248,27 +363,60 @@ export function createCustomBlockHost(options) {
|
|
|
248
363
|
stop() {
|
|
249
364
|
window.removeEventListener("message", onMessage);
|
|
250
365
|
iframe.removeEventListener("load", onIframeLoad);
|
|
251
|
-
|
|
366
|
+
clearNoConnectTimeout();
|
|
367
|
+
clearNoInitResultTimeout();
|
|
252
368
|
querySubscriptions.clear();
|
|
253
369
|
},
|
|
254
370
|
post,
|
|
255
371
|
setTheme(nextTheme) {
|
|
256
372
|
theme = nextTheme;
|
|
373
|
+
if (initStatus !== "success") {
|
|
374
|
+
if (initStatus === "waitingForInitResult") {
|
|
375
|
+
pendingThemeChange = true;
|
|
376
|
+
}
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
257
379
|
const message = { type: "themeChanged", theme };
|
|
258
380
|
post(message);
|
|
259
381
|
},
|
|
260
382
|
setParent(nextParent) {
|
|
261
383
|
parent = nextParent;
|
|
384
|
+
if (initStatus !== "success") {
|
|
385
|
+
if (initStatus === "waitingForInitResult") {
|
|
386
|
+
pendingParentChange = true;
|
|
387
|
+
}
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
262
390
|
const message = { type: "parentChanged", parent };
|
|
263
391
|
post(message);
|
|
264
392
|
},
|
|
265
393
|
setPage(nextPage) {
|
|
266
394
|
page = nextPage;
|
|
395
|
+
if (initStatus !== "success") {
|
|
396
|
+
if (initStatus === "waitingForInitResult") {
|
|
397
|
+
pendingPageChange = true;
|
|
398
|
+
}
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
267
401
|
const message = { type: "pageChanged", page };
|
|
268
402
|
post(message);
|
|
269
403
|
},
|
|
270
404
|
setDataSources(nextDataSources) {
|
|
405
|
+
if (connectedSandbox !== undefined &&
|
|
406
|
+
getBindingErrorCode(manifest, nextDataSources) !== undefined) {
|
|
407
|
+
emit("warn", {
|
|
408
|
+
message: "Ignored invalid data source bindings update",
|
|
409
|
+
payload: nextDataSources,
|
|
410
|
+
});
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
271
413
|
dataSources = nextDataSources;
|
|
414
|
+
if (initStatus !== "success") {
|
|
415
|
+
if (initStatus === "waitingForInitResult") {
|
|
416
|
+
pendingDataSourcesChange = nextDataSources;
|
|
417
|
+
}
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
272
420
|
const message = {
|
|
273
421
|
type: "dataSourcesChanged",
|
|
274
422
|
dataSources: nextDataSources,
|
|
@@ -277,9 +425,18 @@ export function createCustomBlockHost(options) {
|
|
|
277
425
|
},
|
|
278
426
|
setCurrentUser(nextCurrentUser) {
|
|
279
427
|
currentUser = nextCurrentUser;
|
|
428
|
+
if (initStatus !== "success") {
|
|
429
|
+
if (initStatus === "waitingForInitResult") {
|
|
430
|
+
pendingCurrentUserChange = true;
|
|
431
|
+
}
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
280
434
|
post({ type: "currentUserChanged", currentUser });
|
|
281
435
|
},
|
|
282
436
|
refreshQuery({ dataSourceId, response }) {
|
|
437
|
+
if (initStatus !== "success") {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
283
440
|
const refreshes = querySubscriptions.resolveRefreshes({
|
|
284
441
|
dataSourceId,
|
|
285
442
|
response,
|
|
@@ -294,3 +451,23 @@ export function createCustomBlockHost(options) {
|
|
|
294
451
|
},
|
|
295
452
|
};
|
|
296
453
|
}
|
|
454
|
+
function getBindingErrorCode(manifest, dataSources) {
|
|
455
|
+
for (const [dataSourceKey, manifestDataSource] of Object.entries(manifest.dataSources)) {
|
|
456
|
+
const binding = dataSources.bindings[dataSourceKey];
|
|
457
|
+
if (binding?.collectionPointer === undefined ||
|
|
458
|
+
binding.collectionSchema === undefined) {
|
|
459
|
+
return "missing_data_source_binding";
|
|
460
|
+
}
|
|
461
|
+
for (const [propertyKey, manifestProperty] of Object.entries(manifestDataSource.properties ?? {})) {
|
|
462
|
+
const propertyId = binding.propertyIdsByKey?.[propertyKey];
|
|
463
|
+
if (propertyId === undefined) {
|
|
464
|
+
return "missing_property_binding";
|
|
465
|
+
}
|
|
466
|
+
if (binding.collectionSchema.propertiesById[propertyId]?.type !==
|
|
467
|
+
manifestProperty.type) {
|
|
468
|
+
return "invalid_property_binding";
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return undefined;
|
|
473
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { CustomBlockInitErrorCode, CustomBlockInitErrorInfo } from "../../b
|
|
|
3
3
|
* Returns the error info for a given `init` failure code.
|
|
4
4
|
*
|
|
5
5
|
* `init` handshakes are one-shot: after an `init` error, this host instance will not answer another
|
|
6
|
-
* `
|
|
6
|
+
* `connect` message. `isRetryable` means a fresh iframe / `init` attempt could plausibly succeed
|
|
7
7
|
* without changing block code or host configuration.
|
|
8
8
|
*/
|
|
9
9
|
export declare function initErrorForFailureReason(reason: CustomBlockInitErrorCode, data?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initErrors.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/lifecycle/initErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,+BAA+B,CAAA;AAKtC;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,wBAAwB,EAChC,IAAI,GAAE;IACL,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,4BAA4B,CAAC,EAAE,MAAM,CAAA;CAChC,GACJ,wBAAwB,
|
|
1
|
+
{"version":3,"file":"initErrors.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/lifecycle/initErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,+BAA+B,CAAA;AAKtC;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,wBAAwB,EAChC,IAAI,GAAE;IACL,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,4BAA4B,CAAC,EAAE,MAAM,CAAA;CAChC,GACJ,wBAAwB,CA+I1B"}
|
|
@@ -3,28 +3,28 @@ const UNKNOWN_ERROR_MESSAGE = "Unexpected error while initializing custom block.
|
|
|
3
3
|
* Returns the error info for a given `init` failure code.
|
|
4
4
|
*
|
|
5
5
|
* `init` handshakes are one-shot: after an `init` error, this host instance will not answer another
|
|
6
|
-
* `
|
|
6
|
+
* `connect` message. `isRetryable` means a fresh iframe / `init` attempt could plausibly succeed
|
|
7
7
|
* without changing block code or host configuration.
|
|
8
8
|
*/
|
|
9
9
|
export function initErrorForFailureReason(reason, data = {}) {
|
|
10
10
|
switch (reason) {
|
|
11
|
-
case "
|
|
11
|
+
case "no_connect":
|
|
12
12
|
return {
|
|
13
13
|
code: reason,
|
|
14
|
-
message: "Sandbox did not send a
|
|
14
|
+
message: "Sandbox did not send a connect message.",
|
|
15
15
|
isRetryable: true,
|
|
16
16
|
};
|
|
17
|
-
case "
|
|
17
|
+
case "invalid_connect":
|
|
18
18
|
return {
|
|
19
19
|
code: reason,
|
|
20
|
-
message: "Sandbox sent an invalid
|
|
21
|
-
// The sandbox must be updated to send a valid
|
|
20
|
+
message: "Sandbox sent an invalid connect message.",
|
|
21
|
+
// The sandbox must be updated to send a valid connect message.
|
|
22
22
|
isRetryable: false,
|
|
23
23
|
};
|
|
24
24
|
case "manifest_unavailable":
|
|
25
25
|
return {
|
|
26
26
|
code: reason,
|
|
27
|
-
message: "
|
|
27
|
+
message: "The custom block manifest is unavailable.",
|
|
28
28
|
isRetryable: true,
|
|
29
29
|
};
|
|
30
30
|
case "manifest_invalid":
|
|
@@ -102,6 +102,24 @@ export function initErrorForFailureReason(reason, data = {}) {
|
|
|
102
102
|
// a property with a compatible schema.
|
|
103
103
|
isRetryable: false,
|
|
104
104
|
};
|
|
105
|
+
case "no_init_result":
|
|
106
|
+
return {
|
|
107
|
+
code: reason,
|
|
108
|
+
message: "Sandbox did not acknowledge initialization.",
|
|
109
|
+
isRetryable: true,
|
|
110
|
+
};
|
|
111
|
+
case "invalid_init_result":
|
|
112
|
+
return {
|
|
113
|
+
code: reason,
|
|
114
|
+
message: "Sandbox sent an invalid initialization result.",
|
|
115
|
+
isRetryable: false,
|
|
116
|
+
};
|
|
117
|
+
case "invalid_init_bindings":
|
|
118
|
+
return {
|
|
119
|
+
code: reason,
|
|
120
|
+
message: "Sandbox rejected the host-provided data source bindings.",
|
|
121
|
+
isRetryable: false,
|
|
122
|
+
};
|
|
105
123
|
case "not_in_iframe":
|
|
106
124
|
return {
|
|
107
125
|
code: reason,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function isValidBridgeProtocolVersion(version: number): boolean;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=protocolVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocolVersion.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/lifecycle/protocolVersion.ts"],"names":[],"mappings":"AAAA,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErE"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import type { NotionDataSourceBindings } from "../../bridge/dataSources/dataSource.js";
|
|
2
2
|
import type { NotionBlockId } from "../../bridge/ids.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CustomBlockManifest } from "../../bridge/manifest.js";
|
|
4
|
+
import type { ConnectMessage } from "../../bridge/messages/connect.js";
|
|
4
5
|
import type { CustomBlockPage } from "../../bridge/pages/page.js";
|
|
5
6
|
import type { NotionParent } from "../../bridge/parent.js";
|
|
6
7
|
import type { NotionTheme } from "../../bridge/theme.js";
|
|
7
8
|
import type { NotionUser } from "../../bridge/users/user.js";
|
|
8
|
-
export type
|
|
9
|
+
export type ConnectSuccessMessage = Extract<ConnectMessage, {
|
|
9
10
|
status: "success";
|
|
10
11
|
}>;
|
|
11
|
-
export type InitStatus = "
|
|
12
|
+
export type InitStatus = "waitingForConnect" | "waitingForInitResult" | "success" | "error";
|
|
12
13
|
export type CustomBlockHostDataSourcesPayload = {
|
|
13
14
|
bindings: NotionDataSourceBindings;
|
|
14
15
|
};
|
|
15
|
-
export type CustomBlockHostInitialDataSources = CustomBlockHostDataSourcesPayload | ((
|
|
16
|
+
export type CustomBlockHostInitialDataSources = CustomBlockHostDataSourcesPayload | ((connect: ConnectSuccessMessage) => CustomBlockHostDataSourcesPayload);
|
|
16
17
|
export type CustomBlockHostInitialState = {
|
|
17
18
|
theme: NotionTheme;
|
|
18
19
|
blockId: NotionBlockId;
|
|
19
20
|
parent: NotionParent;
|
|
20
21
|
page: CustomBlockPage;
|
|
22
|
+
manifest: CustomBlockManifest;
|
|
21
23
|
dataSources: CustomBlockHostInitialDataSources;
|
|
22
24
|
currentUser: NotionUser;
|
|
23
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/lifecycle/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host/lifecycle/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAC1C,cAAc,EACd;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CACrB,CAAA;AAED,MAAM,MAAM,UAAU,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,SAAS,GACT,OAAO,CAAA;AAEV,MAAM,MAAM,iCAAiC,GAAG;IAC/C,QAAQ,EAAE,wBAAwB,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,iCAAiC,GAC1C,iCAAiC,GACjC,CAAC,CAAC,OAAO,EAAE,qBAAqB,KAAK,iCAAiC,CAAC,CAAA;AAE1E,MAAM,MAAM,2BAA2B,GAAG;IACzC,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,WAAW,EAAE,iCAAiC,CAAA;IAC9C,WAAW,EAAE,UAAU,CAAA;CACvB,CAAA"}
|
|
@@ -14,9 +14,6 @@ export function getInvalidSandboxMessageResponse(data) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function nackReasonForInvalidSandboxMessage(incomingType) {
|
|
17
|
-
if (incomingType === "ready") {
|
|
18
|
-
return "Invalid manifest";
|
|
19
|
-
}
|
|
20
17
|
if (incomingType !== undefined) {
|
|
21
18
|
return `Unsupported sandbox message of type "${incomingType}"`;
|
|
22
19
|
}
|
package/dist/host.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type { CustomBlockErrorInfo } from "./bridge/errors.js";
|
|
|
21
21
|
export { customBlockErrorInfoSchema } from "./bridge/errors.js";
|
|
22
22
|
export { notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, } from "./bridge/ids.js";
|
|
23
23
|
export { readIncomingType } from "./bridge/incomingType.js";
|
|
24
|
+
export type { ConnectMessage } from "./bridge/messages/connect.js";
|
|
25
|
+
export { connectMessageSchema } from "./bridge/messages/connect.js";
|
|
24
26
|
export type { CreatePageMessage } from "./bridge/messages/createPage.js";
|
|
25
27
|
export { createPageMessageSchema } from "./bridge/messages/createPage.js";
|
|
26
28
|
export type { CreatePageResultMessage, CustomBlockCreatePageErrorCode, CustomBlockCreatePageErrorInfo, } from "./bridge/messages/createPageResult.js";
|
|
@@ -37,6 +39,8 @@ export type { HostToSandboxMessage } from "./bridge/messages/hostToSandbox.js";
|
|
|
37
39
|
export { hostToSandboxMessageSchema } from "./bridge/messages/hostToSandbox.js";
|
|
38
40
|
export type { CustomBlockInitErrorCode, CustomBlockInitErrorInfo, InitMessage, } from "./bridge/messages/init.js";
|
|
39
41
|
export { customBlockInitErrorCodeSchema, customBlockInitErrorInfoSchema, initMessageSchema, } from "./bridge/messages/init.js";
|
|
42
|
+
export type { CustomBlockInitResultErrorCode, CustomBlockInitResultErrorInfo, InitResultMessage, } from "./bridge/messages/initResult.js";
|
|
43
|
+
export { customBlockInitResultErrorCodeSchema, customBlockInitResultErrorInfoSchema, initResultMessageSchema, } from "./bridge/messages/initResult.js";
|
|
40
44
|
export type { InvalidHostMessage } from "./bridge/messages/invalidHostMessage.js";
|
|
41
45
|
export { invalidHostMessageSchema } from "./bridge/messages/invalidHostMessage.js";
|
|
42
46
|
export type { InvalidSandboxMessage } from "./bridge/messages/invalidSandboxMessage.js";
|
|
@@ -51,8 +55,6 @@ export type { QueryDataSourceMessage } from "./bridge/messages/queryDataSource.j
|
|
|
51
55
|
export { queryDataSourceMessageSchema } from "./bridge/messages/queryDataSource.js";
|
|
52
56
|
export type { CustomBlockQueryDataSourceErrorCode, CustomBlockQueryDataSourceErrorInfo, QueryDataSourceResultMessage, } from "./bridge/messages/queryDataSourceResult.js";
|
|
53
57
|
export { customBlockQueryDataSourceErrorCodeSchema, customBlockQueryDataSourceErrorInfoSchema, queryDataSourceResultMessageSchema, } from "./bridge/messages/queryDataSourceResult.js";
|
|
54
|
-
export type { ReadyMessage } from "./bridge/messages/ready.js";
|
|
55
|
-
export { readyMessageSchema } from "./bridge/messages/ready.js";
|
|
56
58
|
export type { ResizeMessage } from "./bridge/messages/resize.js";
|
|
57
59
|
export { resizeMessageSchema } from "./bridge/messages/resize.js";
|
|
58
60
|
export type { SandboxToHostMessage } from "./bridge/messages/sandboxToHost.js";
|
|
@@ -67,7 +69,7 @@ export type { CustomBlockPage } from "./bridge/pages/page.js";
|
|
|
67
69
|
export { customBlockPageSchema } from "./bridge/pages/page.js";
|
|
68
70
|
export { notionParentSchema } from "./bridge/parent.js";
|
|
69
71
|
export { type CustomBlockHostHandle, type CustomBlockHostOptions, createCustomBlockHost, } from "./host/createCustomBlockHost.js";
|
|
70
|
-
export type { CustomBlockHostDataSourcesPayload, CustomBlockHostInitialDataSources, CustomBlockHostInitialState, } from "./host/lifecycle/types.js";
|
|
72
|
+
export type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostInitialDataSources, CustomBlockHostInitialState, } from "./host/lifecycle/types.js";
|
|
71
73
|
export type { CustomBlockHostCreatePageResult, CustomBlockHostGetPageResult, CustomBlockHostGetUserResult, CustomBlockHostHandlers, CustomBlockHostListUsersResult, CustomBlockHostLogDirection, CustomBlockHostUpdatePageResult, } from "./host/messages/types.js";
|
|
72
74
|
export type { CustomBlockHostQueryDataSourceResult } from "./host/queries/types.js";
|
|
73
75
|
//# sourceMappingURL=host.d.ts.map
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACX,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACN,6BAA6B,EAC7B,8BAA8B,GAC9B,MAAM,oCAAoC,CAAA;AAC3C,YAAY,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAA;AACxF,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAA;AACzF,YAAY,EACX,wCAAwC,EACxC,wCAAwC,GACxC,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,8CAA8C,EAAE,MAAM,gCAAgC,CAAA;AAC/F,YAAY,EACX,4BAA4B,EAC5B,4BAA4B,GAC5B,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAA;AAC5F,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EACN,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACzE,YAAY,EACX,uBAAuB,EACvB,8BAA8B,EAC9B,8BAA8B,GAC9B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACN,6BAA6B,EAC7B,oCAAoC,EACpC,oCAAoC,GACpC,MAAM,uCAAuC,CAAA;AAC9C,YAAY,EAAE,yBAA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M,6BAA6B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,YAAY,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAC/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAC7E,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACzE,YAAY,EACX,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,GACvB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACN,oCAAoC,EACpC,oCAAoC,EACpC,6BAA6B,GAC7B,MAAM,uCAAuC,CAAA;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,iCAAiC,CAAA;AACxC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,GAC3B,MAAM,2BAA2B,CAAA;AAClC,YAAY,EACX,+BAA+B,EAC/B,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,+BAA+B,GAC/B,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAA"}
|
package/dist/host.js
CHANGED
|
@@ -16,6 +16,7 @@ export { customBlockPropertyErrorCodeSchema } from "./bridge/dataSources/resolve
|
|
|
16
16
|
export { customBlockErrorInfoSchema } from "./bridge/errors.js";
|
|
17
17
|
export { notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, } from "./bridge/ids.js";
|
|
18
18
|
export { readIncomingType } from "./bridge/incomingType.js";
|
|
19
|
+
export { connectMessageSchema } from "./bridge/messages/connect.js";
|
|
19
20
|
export { createPageMessageSchema } from "./bridge/messages/createPage.js";
|
|
20
21
|
export { createPageResultMessageSchema, customBlockCreatePageErrorCodeSchema, customBlockCreatePageErrorInfoSchema, } from "./bridge/messages/createPageResult.js";
|
|
21
22
|
export { currentUserChangedMessageSchema } from "./bridge/messages/currentUserChanged.js";
|
|
@@ -24,6 +25,7 @@ export { customBlockGetPageErrorCodeSchema, customBlockGetPageErrorInfoSchema, g
|
|
|
24
25
|
export { customBlockGetUserErrorCodeSchema, customBlockGetUserErrorInfoSchema, getUserMessageSchema, getUserResultMessageSchema, } from "./bridge/messages/getUser.js";
|
|
25
26
|
export { hostToSandboxMessageSchema } from "./bridge/messages/hostToSandbox.js";
|
|
26
27
|
export { customBlockInitErrorCodeSchema, customBlockInitErrorInfoSchema, initMessageSchema, } from "./bridge/messages/init.js";
|
|
28
|
+
export { customBlockInitResultErrorCodeSchema, customBlockInitResultErrorInfoSchema, initResultMessageSchema, } from "./bridge/messages/initResult.js";
|
|
27
29
|
export { invalidHostMessageSchema } from "./bridge/messages/invalidHostMessage.js";
|
|
28
30
|
export { invalidSandboxMessageSchema } from "./bridge/messages/invalidSandboxMessage.js";
|
|
29
31
|
export { customBlockListUsersErrorCodeSchema, customBlockListUsersErrorInfoSchema, listUsersMessageSchema, listUsersResultMessageSchema, } from "./bridge/messages/listUsers.js";
|
|
@@ -31,7 +33,6 @@ export { pageChangedMessageSchema } from "./bridge/messages/pageChanged.js";
|
|
|
31
33
|
export { parentChangedMessageSchema } from "./bridge/messages/parentChanged.js";
|
|
32
34
|
export { queryDataSourceMessageSchema } from "./bridge/messages/queryDataSource.js";
|
|
33
35
|
export { customBlockQueryDataSourceErrorCodeSchema, customBlockQueryDataSourceErrorInfoSchema, queryDataSourceResultMessageSchema, } from "./bridge/messages/queryDataSourceResult.js";
|
|
34
|
-
export { readyMessageSchema } from "./bridge/messages/ready.js";
|
|
35
36
|
export { resizeMessageSchema } from "./bridge/messages/resize.js";
|
|
36
37
|
export { sandboxToHostMessageSchema } from "./bridge/messages/sandboxToHost.js";
|
|
37
38
|
export { themeChangedMessageSchema } from "./bridge/messages/themeChanged.js";
|