@notionhq/custom-blocks 0.0.77 → 0.0.78

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.
Files changed (92) hide show
  1. package/HOST.md +60 -33
  2. package/bin/src/bridge/manifest.js +3 -3
  3. package/dist/bridge/SandboxBridge.d.ts +7 -12
  4. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  5. package/dist/bridge/SandboxBridge.js +109 -38
  6. package/dist/bridge/dataSources/resolve.d.ts +3 -4
  7. package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
  8. package/dist/bridge/dataSources/resolve.js +2 -12
  9. package/dist/bridge/hostState.d.ts +2 -0
  10. package/dist/bridge/hostState.d.ts.map +1 -1
  11. package/dist/bridge/loadManifest.d.ts +4 -4
  12. package/dist/bridge/loadManifest.d.ts.map +1 -1
  13. package/dist/bridge/loadManifest.js +2 -2
  14. package/dist/bridge/manifest.d.ts +3 -3
  15. package/dist/bridge/manifest.js +3 -3
  16. package/dist/bridge/messages/{ready.d.ts → connect.d.ts} +13 -11
  17. package/dist/bridge/messages/connect.d.ts.map +1 -0
  18. package/dist/bridge/messages/{ready.js → connect.js} +14 -13
  19. package/dist/bridge/messages/hostToSandbox.d.ts +21 -0
  20. package/dist/bridge/messages/hostToSandbox.d.ts.map +1 -1
  21. package/dist/bridge/messages/init.d.ts +35 -6
  22. package/dist/bridge/messages/init.d.ts.map +1 -1
  23. package/dist/bridge/messages/init.js +8 -4
  24. package/dist/bridge/messages/initResult.d.ts +29 -0
  25. package/dist/bridge/messages/initResult.d.ts.map +1 -0
  26. package/dist/bridge/messages/initResult.js +25 -0
  27. package/dist/bridge/messages/sandboxToHost.d.ts +20 -5
  28. package/dist/bridge/messages/sandboxToHost.d.ts.map +1 -1
  29. package/dist/bridge/messages/sandboxToHost.js +4 -2
  30. package/dist/bridge/sandboxClient.d.ts +2 -4
  31. package/dist/bridge/sandboxClient.d.ts.map +1 -1
  32. package/dist/bridge/sandboxClient.js +2 -5
  33. package/dist/customBlock.d.ts +1 -1
  34. package/dist/customBlock.d.ts.map +1 -1
  35. package/dist/customBlock.js +1 -1
  36. package/dist/host/createCustomBlockHost.d.ts +6 -3
  37. package/dist/host/createCustomBlockHost.d.ts.map +1 -1
  38. package/dist/host/createCustomBlockHost.js +202 -38
  39. package/dist/host/lifecycle/initErrors.d.ts +1 -1
  40. package/dist/host/lifecycle/initErrors.d.ts.map +1 -1
  41. package/dist/host/lifecycle/initErrors.js +25 -7
  42. package/dist/host/lifecycle/types.d.ts +6 -4
  43. package/dist/host/lifecycle/types.d.ts.map +1 -1
  44. package/dist/host/messages/invalidSandboxMessage.js +0 -3
  45. package/dist/host.d.ts +5 -3
  46. package/dist/host.d.ts.map +1 -1
  47. package/dist/host.js +2 -1
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1 -1
  51. package/dist/init.d.ts +7 -7
  52. package/dist/init.d.ts.map +1 -1
  53. package/dist/init.js +70 -50
  54. package/dist/react/index.d.ts +1 -1
  55. package/dist/react/index.d.ts.map +1 -1
  56. package/dist/react/standalonePreview.d.ts.map +1 -1
  57. package/dist/react/standalonePreview.js +2 -0
  58. package/dist/react/useCustomBlockInit.d.ts +5 -6
  59. package/dist/react/useCustomBlockInit.d.ts.map +1 -1
  60. package/dist/react/useCustomBlockInit.js +3 -19
  61. package/dist/react/useRuntimeState.d.ts +4 -3
  62. package/dist/react/useRuntimeState.d.ts.map +1 -1
  63. package/dist/react/useRuntimeState.js +3 -2
  64. package/dist/version.js +1 -1
  65. package/docs/data-sources.md +7 -5
  66. package/docs/errors.md +5 -1
  67. package/docs/lifecycle.md +19 -31
  68. package/docs/manifest.md +1 -1
  69. package/package.json +1 -1
  70. package/src/bridge/SandboxBridge.ts +137 -43
  71. package/src/bridge/dataSources/resolve.ts +3 -14
  72. package/src/bridge/hostState.ts +2 -0
  73. package/src/bridge/loadManifest.ts +6 -6
  74. package/src/bridge/manifest.ts +3 -3
  75. package/src/bridge/messages/{ready.ts → connect.ts} +15 -14
  76. package/src/bridge/messages/init.ts +24 -10
  77. package/src/bridge/messages/initResult.ts +37 -0
  78. package/src/bridge/messages/sandboxToHost.ts +4 -2
  79. package/src/bridge/sandboxClient.ts +3 -8
  80. package/src/customBlock.ts +2 -2
  81. package/src/host/createCustomBlockHost.ts +242 -42
  82. package/src/host/lifecycle/initErrors.ts +25 -7
  83. package/src/host/lifecycle/types.ts +13 -4
  84. package/src/host/messages/invalidSandboxMessage.ts +0 -3
  85. package/src/host.ts +13 -2
  86. package/src/index.ts +3 -1
  87. package/src/init.ts +73 -60
  88. package/src/react/index.ts +0 -1
  89. package/src/react/standalonePreview.ts +2 -0
  90. package/src/react/useCustomBlockInit.ts +6 -27
  91. package/src/react/useRuntimeState.ts +4 -3
  92. package/dist/bridge/messages/ready.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"loadManifest.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/loadManifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,eAAe,CAAA;AAIxE,MAAM,MAAM,yBAAyB,GAClC,sBAAsB,GACtB,kBAAkB,GAClB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,MAAM,MAAM,qBAAqB,GAChC,oBAAoB,CAAC,yBAAyB,CAAC,CAAA;AAEhD,MAAM,MAAM,kBAAkB,GAC3B;IACA,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,EAAE,SAAS,CAAA;CAChB,GACD;IACA,QAAQ,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,qBAAqB,CAAA;CAC3B,CAAA;AAEJ;;;;;;GAMG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAkEhE"}
1
+ {"version":3,"file":"loadManifest.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/loadManifest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,eAAe,CAAA;AAIxE,MAAM,MAAM,2BAA2B,GACpC,sBAAsB,GACtB,kBAAkB,GAClB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,MAAM,MAAM,uBAAuB,GAClC,oBAAoB,CAAC,2BAA2B,CAAC,CAAA;AAElD,MAAM,MAAM,kBAAkB,GAC3B;IACA,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,EAAE,SAAS,CAAA;CAChB,GACD;IACA,QAAQ,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,uBAAuB,CAAA;CAC7B,CAAA;AAEJ;;;;;;GAMG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAkEhE"}
@@ -6,7 +6,7 @@ const MANIFEST_URL = "custom_blocks.json";
6
6
  * A missing manifest means the block has no declared data requirements.
7
7
  * Other failures return a structured error so the host can reject the manifest.
8
8
  * The SDK validates the manifest locally for author feedback; the host still
9
- * validates the ready message as the iframe trust boundary.
9
+ * validates the connect message as the iframe trust boundary.
10
10
  */
11
11
  export async function loadManifest() {
12
12
  if (typeof fetch !== "function") {
@@ -28,7 +28,7 @@ export async function loadManifest() {
28
28
  manifest: null,
29
29
  // Consider this retryable because it may have just been a network issue. Because `init`
30
30
  // errors are considered terminal, the host should "retry" by reloading the iframe and
31
- // sending another `ready` message.
31
+ // sending another `connect` message.
32
32
  error: { code: "manifest_unavailable", message, isRetryable: true },
33
33
  };
34
34
  }
@@ -1,9 +1,9 @@
1
1
  import * as v from "valibot";
2
2
  /**
3
3
  * User-authored manifest declaring the data sources the custom block expects.
4
- * Lives at `custom_blocks.json` in the project root and is forwarded to the host with
5
- * the bridge `ready` message so the host can pre-bind data sources, surface
6
- * configuration UI, etc. The `notionCustomBlock` Vite plugin from
4
+ * Lives at `custom_blocks.json` in the project root. The sandbox may send it in
5
+ * `connect`, and the host returns the authoritative manifest in `init`. The
6
+ * `notionCustomBlock` Vite plugin from
7
7
  * `@notionhq/custom-blocks/vite` wires the JSON file into the dev server and
8
8
  * the build output.
9
9
  */
@@ -2,9 +2,9 @@ import * as v from "valibot";
2
2
  import { notionPropertyTypeSchema } from "./dataSources/propertySchema.js";
3
3
  /**
4
4
  * User-authored manifest declaring the data sources the custom block expects.
5
- * Lives at `custom_blocks.json` in the project root and is forwarded to the host with
6
- * the bridge `ready` message so the host can pre-bind data sources, surface
7
- * configuration UI, etc. The `notionCustomBlock` Vite plugin from
5
+ * Lives at `custom_blocks.json` in the project root. The sandbox may send it in
6
+ * `connect`, and the host returns the authoritative manifest in `init`. The
7
+ * `notionCustomBlock` Vite plugin from
8
8
  * `@notionhq/custom-blocks/vite` wires the JSON file into the dev server and
9
9
  * the build output.
10
10
  */
@@ -1,18 +1,19 @@
1
1
  import * as v from "valibot";
2
2
  /**
3
- * First message the sandbox sends after mount, kicking off the bridge handshake. The host replies
4
- * with `init`.
3
+ * First message the sandbox sends after mount. It identifies the sandbox and starts the bridge
4
+ * initialization exchange. The host echoes `initializationId` in its `init` response.
5
5
  */
6
- export declare const readyMessageSchema: v.UnionSchema<[v.ObjectSchema<{
7
- readonly type: v.LiteralSchema<"ready", undefined>;
6
+ export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
7
+ readonly type: v.LiteralSchema<"connect", undefined>;
8
+ readonly initializationId: v.StringSchema<undefined>;
8
9
  readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
9
10
  readonly sdkVersion: v.StringSchema<undefined>;
10
11
  readonly status: v.LiteralSchema<"success", undefined>;
11
12
  /**
12
- * The data sources and settings the custom block expects, or null when the
13
- * block has no manifest and no declared data requirements.
13
+ * The data sources and settings the custom block expects. Hosts may omit
14
+ * this when they already have an authoritative manifest.
14
15
  */
15
- readonly manifest: v.UnionSchema<[v.ObjectSchema<{
16
+ readonly manifest: v.OptionalSchema<v.ObjectSchema<{
16
17
  readonly version: v.LiteralSchema<1, undefined>;
17
18
  readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
18
19
  readonly name: v.StringSchema<undefined>;
@@ -30,9 +31,10 @@ export declare const readyMessageSchema: v.UnionSchema<[v.ObjectSchema<{
30
31
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
31
32
  }, undefined>, undefined>, {}>;
32
33
  }, undefined>, undefined>;
33
- }, undefined>, v.NullSchema<undefined>], undefined>;
34
+ }, undefined>, undefined>;
34
35
  }, undefined>, v.ObjectSchema<{
35
- readonly type: v.LiteralSchema<"ready", undefined>;
36
+ readonly type: v.LiteralSchema<"connect", undefined>;
37
+ readonly initializationId: v.StringSchema<undefined>;
36
38
  readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
37
39
  readonly sdkVersion: v.StringSchema<undefined>;
38
40
  readonly status: v.LiteralSchema<"error", undefined>;
@@ -42,5 +44,5 @@ export declare const readyMessageSchema: v.UnionSchema<[v.ObjectSchema<{
42
44
  readonly isRetryable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
43
45
  }, undefined>;
44
46
  }, undefined>], undefined>;
45
- export type ReadyMessage = v.InferOutput<typeof readyMessageSchema>;
46
- //# sourceMappingURL=ready.d.ts.map
47
+ export type ConnectMessage = v.InferOutput<typeof connectMessageSchema>;
48
+ //# sourceMappingURL=connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AA2B5B;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;IAG/B;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BASH,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
@@ -1,7 +1,8 @@
1
1
  import * as v from "valibot";
2
2
  import { manifestSchema } from "../manifest.js";
3
- const readyMessageCommonEntries = {
4
- type: v.literal("ready"),
3
+ const connectMessageCommonEntries = {
4
+ type: v.literal("connect"),
5
+ initializationId: v.string(),
5
6
  /**
6
7
  * Used to ensure that the host and client are using the same version of the bridge protocol. A
7
8
  * single host needs to support multiple custom blocks built with different versions of the bridge
@@ -9,35 +10,35 @@ const readyMessageCommonEntries = {
9
10
  */
10
11
  bridgeProtocolVersion: v.number(),
11
12
  /**
12
- * Semver version of the SDK package that sent this ready message. Should only be used for
13
+ * Semver version of the SDK package that sent this connect message. Should only be used for
13
14
  * analytics purposes. Business logic should compare against `bridgeProtocolVersion` instead.
14
15
  */
15
16
  sdkVersion: v.string(),
16
17
  };
17
18
  // TODO(custom-blocks): Replace with `customBlockErrorInfoSchema` which makes `isRetryable` required
18
19
  // once min supported bridge protocol version is bumped to 3.
19
- const readyErrorSchema = v.object({
20
+ const connectErrorSchema = v.object({
20
21
  code: v.string(),
21
22
  message: v.string(),
22
23
  isRetryable: v.optional(v.boolean(), false),
23
24
  });
24
25
  /**
25
- * First message the sandbox sends after mount, kicking off the bridge handshake. The host replies
26
- * with `init`.
26
+ * First message the sandbox sends after mount. It identifies the sandbox and starts the bridge
27
+ * initialization exchange. The host echoes `initializationId` in its `init` response.
27
28
  */
28
- export const readyMessageSchema = v.union([
29
+ export const connectMessageSchema = v.variant("status", [
29
30
  v.object({
30
31
  status: v.literal("success"),
31
32
  /**
32
- * The data sources and settings the custom block expects, or null when the
33
- * block has no manifest and no declared data requirements.
33
+ * The data sources and settings the custom block expects. Hosts may omit
34
+ * this when they already have an authoritative manifest.
34
35
  */
35
- manifest: v.union([manifestSchema, v.null_()]),
36
- ...readyMessageCommonEntries,
36
+ manifest: v.optional(manifestSchema),
37
+ ...connectMessageCommonEntries,
37
38
  }),
38
39
  v.object({
39
40
  status: v.literal("error"),
40
- error: readyErrorSchema,
41
- ...readyMessageCommonEntries,
41
+ error: connectErrorSchema,
42
+ ...connectMessageCommonEntries,
42
43
  }),
43
44
  ]);
@@ -4,6 +4,7 @@ import * as v from "valibot";
4
4
  */
5
5
  export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.VariantSchema<"status", [v.ObjectSchema<{
6
6
  readonly type: v.LiteralSchema<"init", undefined>;
7
+ readonly initializationId: v.StringSchema<undefined>;
7
8
  readonly status: v.LiteralSchema<"success", undefined>;
8
9
  readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
9
10
  readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
@@ -42,6 +43,25 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
42
43
  readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
43
44
  }, undefined>], undefined>;
44
45
  }, undefined>;
46
+ readonly manifest: v.ObjectSchema<{
47
+ readonly version: v.LiteralSchema<1, undefined>;
48
+ readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
49
+ readonly name: v.StringSchema<undefined>;
50
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
51
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
52
+ readonly type: v.LiteralSchema<"emoji", undefined>;
53
+ readonly emoji: v.StringSchema<undefined>;
54
+ }, undefined>, v.ObjectSchema<{
55
+ readonly type: v.LiteralSchema<"external", undefined>;
56
+ readonly url: v.StringSchema<undefined>;
57
+ }, undefined>], undefined>, undefined>;
58
+ readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
59
+ readonly name: v.StringSchema<undefined>;
60
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
61
+ readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
62
+ }, undefined>, undefined>, {}>;
63
+ }, undefined>, undefined>;
64
+ }, undefined>;
45
65
  readonly dataSources: v.ObjectSchema<{
46
66
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
47
67
  readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
@@ -201,6 +221,7 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
201
221
  }, undefined>;
202
222
  }, undefined>, v.ObjectSchema<{
203
223
  readonly type: v.LiteralSchema<"init", undefined>;
224
+ readonly initializationId: v.StringSchema<undefined>;
204
225
  readonly status: v.LiteralSchema<"error", undefined>;
205
226
  readonly error: v.ObjectSchema<{
206
227
  readonly code: v.StringSchema<undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"hostToSandbox.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/hostToSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAe5B;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAcrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
@@ -1,25 +1,34 @@
1
1
  import * as v from "valibot";
2
2
  import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
+ import type { CustomBlockInitResultErrorCode } from "./initResult.js";
3
4
  export declare const customBlockInitErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockInitErrorCode = CustomBlockErrorCode<"no_ready" | "invalid_ready" | "manifest_unavailable" | "manifest_invalid" | "invalid_protocol_version" | "unsupported_protocol_version" | "context_unavailable" | "current_user_unavailable" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding" | "not_in_iframe" | "init_timeout">;
5
+ export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_protocol_version" | "unsupported_protocol_version" | "context_unavailable" | "current_user_unavailable" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
5
6
  export type CustomBlockInitErrorInfo = CustomBlockErrorInfo<CustomBlockInitErrorCode>;
7
+ /**
8
+ * Every initialization failure visible to block code. This combines errors
9
+ * received in `init`, errors the sandbox reports in `initResult`, and failures
10
+ * detected locally while running `initCustomBlock()`.
11
+ */
12
+ export type CustomBlockInitializationErrorCode = CustomBlockInitErrorCode | CustomBlockInitResultErrorCode | CustomBlockErrorCode<"not_in_iframe" | "init_timeout">;
13
+ export type CustomBlockInitializationErrorInfo = CustomBlockErrorInfo<CustomBlockInitializationErrorCode>;
6
14
  export declare const customBlockInitErrorInfoSchema: v.ObjectSchema<{
7
15
  readonly code: v.StringSchema<undefined>;
8
16
  readonly message: v.StringSchema<undefined>;
9
17
  readonly isRetryable: v.BooleanSchema<undefined>;
10
18
  }, undefined>;
11
- export declare class CustomBlockInitError extends Error implements CustomBlockErrorInfo {
12
- constructor(error: CustomBlockInitErrorInfo);
13
- code: CustomBlockInitErrorCode;
19
+ export declare class CustomBlockInitializationError extends Error implements CustomBlockErrorInfo {
20
+ constructor(error: CustomBlockInitializationErrorInfo);
21
+ code: CustomBlockInitializationErrorCode;
14
22
  isRetryable: boolean;
15
23
  }
16
24
  /**
17
25
  * Initialization message sent by the host to the sandbox exactly once, in response to the
18
- * sandbox's `ready` message. After init, live updates flow through narrower messages
19
- * (`themeChanged`, `parentChanged`, `pageChanged`, `dataSourcesChanged`).
26
+ * sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
27
+ * successful initialization, live updates flow through narrower messages.
20
28
  */
21
29
  export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
22
30
  readonly type: v.LiteralSchema<"init", undefined>;
31
+ readonly initializationId: v.StringSchema<undefined>;
23
32
  readonly status: v.LiteralSchema<"success", undefined>;
24
33
  readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
25
34
  readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
@@ -58,6 +67,25 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
58
67
  readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
59
68
  }, undefined>], undefined>;
60
69
  }, undefined>;
70
+ readonly manifest: v.ObjectSchema<{
71
+ readonly version: v.LiteralSchema<1, undefined>;
72
+ readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
73
+ readonly name: v.StringSchema<undefined>;
74
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
75
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
76
+ readonly type: v.LiteralSchema<"emoji", undefined>;
77
+ readonly emoji: v.StringSchema<undefined>;
78
+ }, undefined>, v.ObjectSchema<{
79
+ readonly type: v.LiteralSchema<"external", undefined>;
80
+ readonly url: v.StringSchema<undefined>;
81
+ }, undefined>], undefined>, undefined>;
82
+ readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
83
+ readonly name: v.StringSchema<undefined>;
84
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
85
+ readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
86
+ }, undefined>, undefined>, {}>;
87
+ }, undefined>, undefined>;
88
+ }, undefined>;
61
89
  readonly dataSources: v.ObjectSchema<{
62
90
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
63
91
  readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
@@ -217,6 +245,7 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
217
245
  }, undefined>;
218
246
  }, undefined>, v.ObjectSchema<{
219
247
  readonly type: v.LiteralSchema<"init", undefined>;
248
+ readonly initializationId: v.StringSchema<undefined>;
220
249
  readonly status: v.LiteralSchema<"error", undefined>;
221
250
  readonly error: v.ObjectSchema<{
222
251
  readonly code: v.StringSchema<undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAS9E,eAAO,MAAM,8BAA8B,2BAAa,CAAA;AAExD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CACxD,UAAU,GACV,eAAe,GACf,sBAAsB,GACtB,kBAAkB,GAClB,0BAA0B,GAC1B,8BAA8B,GAC9B,qBAAqB,GACrB,0BAA0B,GAC1B,6BAA6B,GAC7B,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,eAAe,GACf,cAAc,CAChB,CAAA;AAED,MAAM,MAAM,wBAAwB,GACnC,oBAAoB,CAAC,wBAAwB,CAAC,CAAA;AAE/C,eAAO,MAAM,8BAA8B;;;;aAIzC,CAAA;AAEF,qBAAa,oBACZ,SAAQ,KACR,YAAW,oBAAoB;gBAEnB,KAAK,EAAE,wBAAwB;IAO3C,IAAI,EAAE,wBAAwB,CAAA;IAC9B,WAAW,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAkB5B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAA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O,iBAAiB,CAAC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import * as v from "valibot";
2
2
  import { notionDataSourceBindingsSchema } from "../dataSources/dataSource.js";
3
3
  import { notionBlockIdSchema } from "../ids.js";
4
+ import { manifestSchema } from "../manifest.js";
4
5
  import { customBlockPageSchema } from "../pages/page.js";
5
6
  import { notionParentSchema } from "../parent.js";
6
7
  import { notionThemeSchema } from "../theme.js";
@@ -13,27 +14,29 @@ export const customBlockInitErrorInfoSchema = v.object({
13
14
  message: v.string(),
14
15
  isRetryable: v.boolean(),
15
16
  });
16
- export class CustomBlockInitError extends Error {
17
+ export class CustomBlockInitializationError extends Error {
17
18
  constructor(error) {
18
19
  super(error.message);
19
- this.name = "CustomBlockInitError";
20
+ this.name = "CustomBlockInitializationError";
20
21
  this.code = error.code;
21
22
  this.isRetryable = error.isRetryable;
22
23
  }
23
24
  }
24
25
  /**
25
26
  * Initialization message sent by the host to the sandbox exactly once, in response to the
26
- * sandbox's `ready` message. After init, live updates flow through narrower messages
27
- * (`themeChanged`, `parentChanged`, `pageChanged`, `dataSourcesChanged`).
27
+ * sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
28
+ * successful initialization, live updates flow through narrower messages.
28
29
  */
29
30
  export const initMessageSchema = v.variant("status", [
30
31
  v.object({
31
32
  type: v.literal("init"),
33
+ initializationId: v.string(),
32
34
  status: v.literal("success"),
33
35
  theme: notionThemeSchema,
34
36
  blockId: notionBlockIdSchema,
35
37
  parent: notionParentSchema,
36
38
  page: customBlockPageSchema,
39
+ manifest: manifestSchema,
37
40
  dataSources: v.object({
38
41
  bindings: notionDataSourceBindingsSchema,
39
42
  }),
@@ -41,6 +44,7 @@ export const initMessageSchema = v.variant("status", [
41
44
  }),
42
45
  v.object({
43
46
  type: v.literal("init"),
47
+ initializationId: v.string(),
44
48
  status: v.literal("error"),
45
49
  error: customBlockInitErrorInfoSchema,
46
50
  }),
@@ -0,0 +1,29 @@
1
+ import * as v from "valibot";
2
+ import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
+ export declare const customBlockInitResultErrorCodeSchema: v.StringSchema<undefined>;
4
+ export type CustomBlockInitResultErrorCode = CustomBlockErrorCode<"invalid_init_bindings">;
5
+ export type CustomBlockInitResultErrorInfo = CustomBlockErrorInfo<CustomBlockInitResultErrorCode>;
6
+ export declare const customBlockInitResultErrorInfoSchema: v.ObjectSchema<{
7
+ readonly code: v.StringSchema<undefined>;
8
+ readonly message: v.StringSchema<undefined>;
9
+ readonly isRetryable: v.BooleanSchema<undefined>;
10
+ }, undefined>;
11
+ /**
12
+ * Acknowledges whether the sandbox successfully applied the host's `init` response.
13
+ */
14
+ export declare const initResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
15
+ readonly type: v.LiteralSchema<"initResult", undefined>;
16
+ readonly initializationId: v.StringSchema<undefined>;
17
+ readonly status: v.LiteralSchema<"success", undefined>;
18
+ }, undefined>, v.ObjectSchema<{
19
+ readonly type: v.LiteralSchema<"initResult", undefined>;
20
+ readonly initializationId: v.StringSchema<undefined>;
21
+ readonly status: v.LiteralSchema<"error", undefined>;
22
+ readonly error: v.ObjectSchema<{
23
+ readonly code: v.StringSchema<undefined>;
24
+ readonly message: v.StringSchema<undefined>;
25
+ readonly isRetryable: v.BooleanSchema<undefined>;
26
+ }, undefined>;
27
+ }, undefined>], undefined>;
28
+ export type InitResultMessage = v.InferOutput<typeof initResultMessageSchema>;
29
+ //# sourceMappingURL=initResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initResult.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/initResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAI9E,eAAO,MAAM,oCAAoC,2BAAa,CAAA;AAE9D,MAAM,MAAM,8BAA8B,GACzC,oBAAoB,CAAC,uBAAuB,CAAC,CAAA;AAE9C,MAAM,MAAM,8BAA8B,GACzC,oBAAoB,CAAC,8BAA8B,CAAC,CAAA;AAErD,eAAO,MAAM,oCAAoC;;;;aAI/C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;0BAYlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import * as v from "valibot";
2
+ // The schema accepts any string code. The type lists known codes for
3
+ // autocomplete, with an open string fallback for newer senders.
4
+ export const customBlockInitResultErrorCodeSchema = v.string();
5
+ export const customBlockInitResultErrorInfoSchema = v.object({
6
+ code: customBlockInitResultErrorCodeSchema,
7
+ message: v.string(),
8
+ isRetryable: v.boolean(),
9
+ });
10
+ /**
11
+ * Acknowledges whether the sandbox successfully applied the host's `init` response.
12
+ */
13
+ export const initResultMessageSchema = v.variant("status", [
14
+ v.object({
15
+ type: v.literal("initResult"),
16
+ initializationId: v.string(),
17
+ status: v.literal("success"),
18
+ }),
19
+ v.object({
20
+ type: v.literal("initResult"),
21
+ initializationId: v.string(),
22
+ status: v.literal("error"),
23
+ error: customBlockInitResultErrorInfoSchema,
24
+ }),
25
+ ]);
@@ -3,12 +3,13 @@ import * as v from "valibot";
3
3
  * Union of every message the sandbox is allowed to send the host. Useful for hosts to validate
4
4
  * inbound traffic from sandboxes without re-implementing validation logic.
5
5
  */
6
- export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.UnionSchema<[v.ObjectSchema<{
7
- readonly type: v.LiteralSchema<"ready", undefined>;
6
+ export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.VariantSchema<"status", [v.ObjectSchema<{
7
+ readonly type: v.LiteralSchema<"connect", undefined>;
8
+ readonly initializationId: v.StringSchema<undefined>;
8
9
  readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
9
10
  readonly sdkVersion: v.StringSchema<undefined>;
10
11
  readonly status: v.LiteralSchema<"success", undefined>;
11
- readonly manifest: v.UnionSchema<[v.ObjectSchema<{
12
+ readonly manifest: v.OptionalSchema<v.ObjectSchema<{
12
13
  readonly version: v.LiteralSchema<1, undefined>;
13
14
  readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
14
15
  readonly name: v.StringSchema<undefined>;
@@ -26,9 +27,10 @@ export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.UnionSchema<[v
26
27
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
27
28
  }, undefined>, undefined>, {}>;
28
29
  }, undefined>, undefined>;
29
- }, undefined>, v.NullSchema<undefined>], undefined>;
30
+ }, undefined>, undefined>;
30
31
  }, undefined>, v.ObjectSchema<{
31
- readonly type: v.LiteralSchema<"ready", undefined>;
32
+ readonly type: v.LiteralSchema<"connect", undefined>;
33
+ readonly initializationId: v.StringSchema<undefined>;
32
34
  readonly bridgeProtocolVersion: v.NumberSchema<undefined>;
33
35
  readonly sdkVersion: v.StringSchema<undefined>;
34
36
  readonly status: v.LiteralSchema<"error", undefined>;
@@ -37,6 +39,19 @@ export declare const sandboxToHostMessageSchema: v.UnionSchema<[v.UnionSchema<[v
37
39
  readonly message: v.StringSchema<undefined>;
38
40
  readonly isRetryable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
39
41
  }, undefined>;
42
+ }, undefined>], undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
43
+ readonly type: v.LiteralSchema<"initResult", undefined>;
44
+ readonly initializationId: v.StringSchema<undefined>;
45
+ readonly status: v.LiteralSchema<"success", undefined>;
46
+ }, undefined>, v.ObjectSchema<{
47
+ readonly type: v.LiteralSchema<"initResult", undefined>;
48
+ readonly initializationId: v.StringSchema<undefined>;
49
+ readonly status: v.LiteralSchema<"error", undefined>;
50
+ readonly error: v.ObjectSchema<{
51
+ readonly code: v.StringSchema<undefined>;
52
+ readonly message: v.StringSchema<undefined>;
53
+ readonly isRetryable: v.BooleanSchema<undefined>;
54
+ }, undefined>;
40
55
  }, undefined>], undefined>, v.ObjectSchema<{
41
56
  readonly type: v.LiteralSchema<"queryDataSource", undefined>;
42
57
  readonly subscriptionId: v.StringSchema<undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAW5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAUrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
1
+ {"version":3,"file":"sandboxToHost.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/messages/sandboxToHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAY5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAWrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAC/C,OAAO,0BAA0B,CACjC,CAAA"}
@@ -1,11 +1,12 @@
1
1
  import * as v from "valibot";
2
+ import { connectMessageSchema } from "./connect.js";
2
3
  import { createPageMessageSchema } from "./createPage.js";
3
4
  import { getPageMessageSchema } from "./getPage.js";
4
5
  import { getUserMessageSchema } from "./getUser.js";
6
+ import { initResultMessageSchema } from "./initResult.js";
5
7
  import { invalidHostMessageSchema } from "./invalidHostMessage.js";
6
8
  import { listUsersMessageSchema } from "./listUsers.js";
7
9
  import { queryDataSourceMessageSchema } from "./queryDataSource.js";
8
- import { readyMessageSchema } from "./ready.js";
9
10
  import { resizeMessageSchema } from "./resize.js";
10
11
  import { updatePageMessageSchema } from "./updatePage.js";
11
12
  /**
@@ -13,7 +14,8 @@ import { updatePageMessageSchema } from "./updatePage.js";
13
14
  * inbound traffic from sandboxes without re-implementing validation logic.
14
15
  */
15
16
  export const sandboxToHostMessageSchema = v.union([
16
- readyMessageSchema,
17
+ connectMessageSchema,
18
+ initResultMessageSchema,
17
19
  queryDataSourceMessageSchema,
18
20
  createPageMessageSchema,
19
21
  getPageMessageSchema,
@@ -1,16 +1,14 @@
1
1
  import type { CreatePageInput, CreatePageResult, GetPageResult, GetUserResult, ListUsersInput, ListUsersResult, NotionPageId, NotionUserId, UpdatePageInput, UpdatePageResult, UseDataSourceOptions } from "../types.js";
2
2
  import { type CustomBlockHostState, type DataSourceQueryView } from "./hostState.js";
3
3
  import type { ManifestLoadResult } from "./loadManifest.js";
4
- import type { CustomBlockManifest } from "./manifest.js";
5
4
  import type { InitMessage } from "./messages/init.js";
6
5
  import { type MessageLogEntry } from "./SandboxBridge.js";
7
6
  export type { MessageLogEntry };
8
7
  export declare const customBlockHost: {
9
- sendReady: (manifestResult: ManifestLoadResult) => void;
10
- awaitInit: (signal?: AbortSignal) => Promise<InitMessage>;
8
+ sendConnect: (manifestResult: ManifestLoadResult) => void;
9
+ awaitInit: (signal?: AbortSignal) => Promise<void>;
11
10
  subscribe: (listener: () => void) => () => boolean;
12
11
  getState: () => CustomBlockHostState;
13
- getManifest: () => CustomBlockManifest | null;
14
12
  /**
15
13
  * Apply an `init` payload directly, bypassing the postMessage handshake for
16
14
  * standalone preview state.
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,oBAAoB,CAAA;AAExE,YAAY,EAAE,eAAe,EAAE,CAAA;AAI/B,eAAO,MAAM,eAAe;gCACC,kBAAkB;yBAIzB,WAAW,KAAG,OAAO,CAAC,WAAW,CAAC;0BAIjC,MAAM,IAAI;oBAIlB,oBAAoB;uBAIjB,mBAAmB,GAAG,IAAI;IAI3C;;;OAGG;4BACqB,WAAW;yBAId,MAAM;CAG3B,CAAA;AAED,eAAO,MAAM,sBAAsB;iBACrB,MAAM,YAAY,oBAAoB;yBAKvC,oBAAoB,OAC1B,MAAM,KACT,mBAAmB;CAKtB,CAAA;AAED,eAAO,MAAM,UAAU;uBACL,SAAS,eAAe,EAAE;0BAIrB,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;oBACa,eAAe,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI3D;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAInD;;OAEG;oBACa,eAAe,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI3D;;OAEG;qBACc,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAAC;CAGzD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;mBACY,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC;IAIxD;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
1
+ {"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,oBAAoB,CAAA;AAExE,YAAY,EAAE,eAAe,EAAE,CAAA;AAI/B,eAAO,MAAM,eAAe;kCACG,kBAAkB;yBAI3B,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;0BAI1B,MAAM,IAAI;oBAIlB,oBAAoB;IAIlC;;;OAGG;4BACqB,WAAW;yBAId,MAAM;CAG3B,CAAA;AAED,eAAO,MAAM,sBAAsB;iBACrB,MAAM,YAAY,oBAAoB;yBAKvC,oBAAoB,OAC1B,MAAM,KACT,mBAAmB;CAKtB,CAAA;AAED,eAAO,MAAM,UAAU;uBACL,SAAS,eAAe,EAAE;0BAIrB,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;oBACa,eAAe,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI3D;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAInD;;OAEG;oBACa,eAAe,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI3D;;OAEG;qBACc,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAAC;CAGzD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;mBACY,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC;IAIxD;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
@@ -2,8 +2,8 @@ import { getDataSourceQueryView as getDataSourceQueryViewWithBridge, } from "./h
2
2
  import { SandboxBridge } from "./SandboxBridge.js";
3
3
  const bridge = new SandboxBridge();
4
4
  export const customBlockHost = {
5
- sendReady: (manifestResult) => {
6
- bridge.sendReady(manifestResult);
5
+ sendConnect: (manifestResult) => {
6
+ bridge.sendConnect(manifestResult);
7
7
  },
8
8
  awaitInit: (signal) => {
9
9
  return bridge.awaitInit(signal);
@@ -14,9 +14,6 @@ export const customBlockHost = {
14
14
  getState: () => {
15
15
  return bridge.getHostState();
16
16
  },
17
- getManifest: () => {
18
- return bridge.getManifest();
19
- },
20
17
  /**
21
18
  * Apply an `init` payload directly, bypassing the postMessage handshake for
22
19
  * standalone preview state.
@@ -30,7 +30,7 @@ export declare const customBlock: {
30
30
  getBlockId(): NotionBlockId;
31
31
  getParent(): NotionParent;
32
32
  getPage(): CustomBlockPage;
33
- getManifest(): CustomBlockManifest | null;
33
+ getManifest(): CustomBlockManifest;
34
34
  autoResize: typeof autoResize;
35
35
  };
36
36
  //# sourceMappingURL=customBlock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"customBlock.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/customBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAK1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,MAAM,gBAAgB,GACzB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAC/C;IACA,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAC9B,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW;wBACH,MAAM,IAAI,GAAG,MAAM,IAAI;gBAI/B,gBAAgB;sBAIV,UAAU;gBAIhB,WAAW;kBAIT,aAAa;iBAId,YAAY;eAId,eAAe;mBAIX,mBAAmB,GAAG,IAAI;;CAKzC,CAAA"}
1
+ {"version":3,"file":"customBlock.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/customBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAK1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,MAAM,gBAAgB,GACzB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAC/C;IACA,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAC9B,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW;wBACH,MAAM,IAAI,GAAG,MAAM,IAAI;gBAI/B,gBAAgB;sBAIV,UAAU;gBAIhB,WAAW;kBAIT,aAAa;iBAId,YAAY;eAId,eAAe;mBAIX,mBAAmB;;CAKlC,CAAA"}
@@ -27,7 +27,7 @@ export const customBlock = {
27
27
  return getInitializedHostState("getPage").page;
28
28
  },
29
29
  getManifest() {
30
- return customBlockHost.getManifest();
30
+ return getInitializedHostState("getManifest").manifest;
31
31
  },
32
32
  autoResize,
33
33
  };
@@ -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, ReadySuccessMessage } from "./lifecycle/types.js";
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
14
  minBridgeProtocolVersion?: number;
14
- noReadyTimeoutMs?: number;
15
+ noConnectTimeoutMs?: number;
16
+ noInitResultTimeoutMs?: number;
15
17
  initialState: CustomBlockHostInitialState;
16
18
  handlers: CustomBlockHostHandlers;
17
- onReady?: (message: ReadySuccessMessage) => void;
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 = {