@notionhq/custom-blocks 0.6.0 β†’ 0.7.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.
Files changed (191) hide show
  1. package/README.md +32 -18
  2. package/dist/bridge/SandboxBridge.d.ts +7 -8
  3. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  4. package/dist/bridge/SandboxBridge.js +39 -114
  5. package/dist/bridge/applyHostStateMessage.d.ts.map +1 -1
  6. package/dist/bridge/createBrowserSandboxBridge.d.ts +3 -0
  7. package/dist/bridge/createBrowserSandboxBridge.d.ts.map +1 -0
  8. package/dist/bridge/createBrowserSandboxBridge.js +54 -0
  9. package/dist/bridge/getBridge.d.ts +1 -1
  10. package/dist/bridge/getBridge.d.ts.map +1 -1
  11. package/dist/bridge/getBridge.js +2 -2
  12. package/dist/bridge/getInitializedHostState.d.ts.map +1 -1
  13. package/dist/bridge/hostState.d.ts +2 -2
  14. package/dist/bridge/hostState.d.ts.map +1 -1
  15. package/dist/bridge/initialization/SandboxInitialization.d.ts +6 -0
  16. package/dist/bridge/initialization/SandboxInitialization.d.ts.map +1 -1
  17. package/dist/bridge/initialization/SandboxInitialization.js +13 -10
  18. package/dist/bridge/messageInterceptor.d.ts.map +1 -1
  19. package/dist/bridge/requests.d.ts.map +1 -1
  20. package/dist/bridge/sandboxEnvironment.d.ts +30 -0
  21. package/dist/bridge/sandboxEnvironment.d.ts.map +1 -0
  22. package/dist/bridge/sandboxEnvironment.js +1 -0
  23. package/dist/bridge/subscribeToHostStateField.d.ts.map +1 -1
  24. package/dist/bridge.d.ts.map +1 -1
  25. package/dist/data-sources.d.ts.map +1 -1
  26. package/dist/dataSources/NotionDataSource.d.ts.map +1 -1
  27. package/dist/dataSources/bridge/DataSourceCache.d.ts +18 -0
  28. package/dist/dataSources/bridge/DataSourceCache.d.ts.map +1 -0
  29. package/dist/dataSources/bridge/DataSourceCache.js +75 -0
  30. package/dist/dataSources/bridge/applyDataSourceBindings.d.ts.map +1 -1
  31. package/dist/dataSources/bridge/makeDataSourceReadResponseSchema.d.ts.map +1 -1
  32. package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts.map +1 -1
  33. package/dist/dataSources/bridge/resolveDataSources.d.ts.map +1 -1
  34. package/dist/dataSources/bridge/resolveSorts.d.ts.map +1 -1
  35. package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.d.ts +0 -3
  36. package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.d.ts.map +1 -1
  37. package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.js +2 -5
  38. package/dist/dataSources/dataSourceInaccessibleError.d.ts.map +1 -1
  39. package/dist/dataSources/dataSourceState.d.ts.map +1 -1
  40. package/dist/dataSources/ensureDataSource.d.ts.map +1 -1
  41. package/dist/dataSources/filters/resolveFilter.d.ts.map +1 -1
  42. package/dist/dataSources/filters/types.d.ts.map +1 -1
  43. package/dist/dataSources/getDataSourcePage.d.ts.map +1 -1
  44. package/dist/dataSources/observeDataSource.d.ts.map +1 -1
  45. package/dist/dataSources/properties/resolvePropertyAddress.d.ts.map +1 -1
  46. package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.d.ts.map +1 -1
  47. package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.js +2 -2
  48. package/dist/dataSources/resolvePageDataSource.d.ts.map +1 -1
  49. package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -1
  50. package/dist/dataSources/types.d.ts.map +1 -1
  51. package/dist/files/files.d.ts +1 -1
  52. package/dist/files/files.d.ts.map +1 -1
  53. package/dist/files/icons.d.ts.map +1 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/initialization/NotInIframeError.d.ts.map +1 -1
  56. package/dist/initialization/initCustomBlock.d.ts.map +1 -1
  57. package/dist/initialization/notifyReady.d.ts.map +1 -1
  58. package/dist/initialization/react/useCustomBlockInit.d.ts.map +1 -1
  59. package/dist/initialization/resolveInitialState.d.ts.map +1 -1
  60. package/dist/initialization/types.d.ts.map +1 -1
  61. package/dist/layout/autoResize.d.ts.map +1 -1
  62. package/dist/layout/getInitialContentHeight.d.ts.map +1 -1
  63. package/dist/location/getContainingPage.d.ts.map +1 -1
  64. package/dist/location/getInstance.d.ts.map +1 -1
  65. package/dist/location/getParent.d.ts.map +1 -1
  66. package/dist/location/mapContainingPage.d.ts +2 -2
  67. package/dist/location/mapContainingPage.d.ts.map +1 -1
  68. package/dist/location/mapParent.d.ts.map +1 -1
  69. package/dist/location/subscribeToContainingPage.d.ts.map +1 -1
  70. package/dist/location/subscribeToParent.d.ts.map +1 -1
  71. package/dist/location/types.d.ts.map +1 -1
  72. package/dist/manifest/getManifest.d.ts.map +1 -1
  73. package/dist/manifest/readLocalManifest.d.ts.map +1 -1
  74. package/dist/manifest/types.d.ts.map +1 -1
  75. package/dist/navigation/openExternalUrl.d.ts.map +1 -1
  76. package/dist/navigation/types.d.ts.map +1 -1
  77. package/dist/navigation.d.ts.map +1 -1
  78. package/dist/pages/NotionPage.d.ts.map +1 -1
  79. package/dist/pages/bridge/buildCreatePageRequest.d.ts.map +1 -1
  80. package/dist/pages/bridge/getPageForDataSource.d.ts.map +1 -1
  81. package/dist/pages/bridge/resolveCreatePageDestination.d.ts.map +1 -1
  82. package/dist/pages/bridge/sendCreatePageRequest.d.ts.map +1 -1
  83. package/dist/pages/bridge/toNotionPageFromBridgePage.d.ts.map +1 -1
  84. package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts +2 -2
  85. package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts.map +1 -1
  86. package/dist/pages/bridge/updatePage.d.ts.map +1 -1
  87. package/dist/pages/createPage.d.ts.map +1 -1
  88. package/dist/pages/getPage.d.ts.map +1 -1
  89. package/dist/pages/identityBlockKey.d.ts.map +1 -1
  90. package/dist/pages/identityPageKey.d.ts.map +1 -1
  91. package/dist/pages/openPage.d.ts.map +1 -1
  92. package/dist/pages/parent.d.ts.map +1 -1
  93. package/dist/pages/types.d.ts +5 -3
  94. package/dist/pages/types.d.ts.map +1 -1
  95. package/dist/pages.d.ts.map +1 -1
  96. package/dist/preferences/backgroundColors.d.ts.map +1 -1
  97. package/dist/preferences/getContrastMode.d.ts.map +1 -1
  98. package/dist/preferences/getTheme.d.ts.map +1 -1
  99. package/dist/preferences/react/useContrastMode.d.ts.map +1 -1
  100. package/dist/preferences/react/useTheme.d.ts.map +1 -1
  101. package/dist/preferences/subscribeToContrastMode.d.ts.map +1 -1
  102. package/dist/preferences/subscribeToTheme.d.ts.map +1 -1
  103. package/dist/preferences/syncDocumentAppearance.d.ts +1 -1
  104. package/dist/preferences/syncDocumentAppearance.d.ts.map +1 -1
  105. package/dist/preferences/syncDocumentAppearance.js +2 -1
  106. package/dist/preferences.d.ts.map +1 -1
  107. package/dist/protocol/compatibility/protocol12/hostToSandbox.d.ts +3356 -0
  108. package/dist/protocol/compatibility/protocol12/hostToSandbox.js +38 -0
  109. package/dist/protocol/compatibility/protocol12/page.d.ts +296 -0
  110. package/dist/protocol/compatibility/protocol12/page.js +7 -0
  111. package/dist/protocol/context/containingPage.d.ts +4 -2
  112. package/dist/protocol/context/containingPage.js +1 -1
  113. package/dist/protocol/context/messages/pageChanged.js +2 -2
  114. package/dist/protocol/dataSources/areDataSourceBindingsEqual.d.ts +3 -0
  115. package/dist/protocol/dataSources/areDataSourceBindingsEqual.js +26 -0
  116. package/dist/protocol/dataSources/messages/queryDataSource.d.ts +24 -19
  117. package/dist/protocol/dataSources/messages/queryDataSource.js +2 -0
  118. package/dist/protocol/files.d.ts +18 -0
  119. package/dist/protocol/files.js +9 -0
  120. package/dist/protocol/messages/hostToSandbox.d.ts +2200 -68
  121. package/dist/protocol/messages/hostToSandbox.js +6 -2
  122. package/dist/protocol/messages/sandboxToHost.d.ts +51 -51
  123. package/dist/protocol/pages/bridgePage.d.ts +20 -17
  124. package/dist/protocol/pages/messages/createPage.d.ts +88 -85
  125. package/dist/protocol/pages/messages/getPage.d.ts +24 -19
  126. package/dist/protocol/pages/messages/getPage.js +2 -0
  127. package/dist/protocol/pages/messages/updatePage.d.ts +37 -34
  128. package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +37 -34
  129. package/dist/protocol/pages/properties/bridgePagePropertyMaps.js +3 -3
  130. package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +236 -2
  131. package/dist/protocol/pages/properties/bridgePagePropertyValue.js +20 -7
  132. package/dist/protocol/utils/errors.d.ts +6 -0
  133. package/dist/protocol/utils/errors.js +8 -0
  134. package/dist/protocol/utils/protocolVersion.d.ts +4 -2
  135. package/dist/protocol/utils/protocolVersion.js +4 -2
  136. package/dist/react/InitializationErrorDetails.d.ts.map +1 -1
  137. package/dist/react/MissingHostCommand.d.ts.map +1 -1
  138. package/dist/react/MissingHostScreen.d.ts.map +1 -1
  139. package/dist/react/NotionCustomBlock.d.ts.map +1 -1
  140. package/dist/react/index.d.ts +0 -2
  141. package/dist/react/index.d.ts.map +1 -1
  142. package/dist/react/index.js +0 -1
  143. package/dist/react/useAsyncRead.d.ts.map +1 -1
  144. package/dist/react/useContainingPage.d.ts.map +1 -1
  145. package/dist/react/useLiveLocationRead.d.ts.map +1 -1
  146. package/dist/react/usePage.d.ts.map +1 -1
  147. package/dist/react/useParent.d.ts.map +1 -1
  148. package/dist/react/useQuerySubscription.d.ts.map +1 -1
  149. package/dist/react/useUserFields.d.ts.map +1 -1
  150. package/dist/react/useViewer.d.ts.map +1 -1
  151. package/dist/styles/scrollbars.css +18 -0
  152. package/dist/users/NotionUser.d.ts.map +1 -1
  153. package/dist/users/bridge/toNotionUserDataFromBridgeUser.d.ts.map +1 -1
  154. package/dist/users/getUser.d.ts.map +1 -1
  155. package/dist/users/getViewer.d.ts.map +1 -1
  156. package/dist/users/listUsers.d.ts.map +1 -1
  157. package/dist/users/types.d.ts.map +1 -1
  158. package/dist/users.d.ts.map +1 -1
  159. package/dist/utils/makeUuid.d.ts.map +1 -1
  160. package/dist/utils/notifyListener.d.ts.map +1 -1
  161. package/dist/utils/typeUtils.d.ts.map +1 -1
  162. package/dist/utils/unreachable.d.ts.map +1 -1
  163. package/dist/utils/version.d.ts.map +1 -1
  164. package/dist/utils/version.js +1 -1
  165. package/docs/block-location.md +22 -9
  166. package/docs/deployment.md +5 -11
  167. package/docs/errors.md +4 -0
  168. package/docs/grants.md +7 -2
  169. package/docs/local-development.md +39 -0
  170. package/docs/pages.md +97 -62
  171. package/package.json +2 -1
  172. package/src/bridge/SandboxBridge.ts +49 -144
  173. package/src/bridge/createBrowserSandboxBridge.ts +64 -0
  174. package/src/bridge/getBridge.ts +3 -2
  175. package/src/bridge/hostState.ts +2 -2
  176. package/src/bridge/initialization/SandboxInitialization.ts +24 -10
  177. package/src/bridge/sandboxEnvironment.ts +38 -0
  178. package/src/dataSources/bridge/DataSourceCache.ts +94 -0
  179. package/src/dataSources/bridge/reuseDataSourcesForUnchangedBindings.ts +5 -5
  180. package/src/dataSources/properties/resolvePropertyWriteMapForDataSource.ts +2 -2
  181. package/src/files/files.ts +1 -1
  182. package/src/location/mapContainingPage.ts +2 -2
  183. package/src/pages/bridge/toNotionPagePropertyFromBridgeProperty.ts +2 -2
  184. package/src/pages/types.ts +9 -3
  185. package/src/preferences/syncDocumentAppearance.ts +2 -1
  186. package/src/react/index.ts +0 -2
  187. package/src/styles/scrollbars.css +18 -0
  188. package/dist/react/NotionTokenScope.d.ts +0 -10
  189. package/dist/react/NotionTokenScope.d.ts.map +0 -1
  190. package/dist/react/NotionTokenScope.js +0 -12
  191. package/src/react/NotionTokenScope.tsx +0 -26
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/users/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4DAA4D,CAAA;AAC7G,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAA;AACjH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAA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+1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,2BAA2B,EAC3B,2BAA2B,GAC3B,MAAM,4DAA4D,CAAA;AACnE,YAAY,EACX,6BAA6B,EAC7B,6BAA6B,GAC7B,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,YAAY,EACX,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,cAAc,GACd,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"users.d.ts","sources":["../src/users.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,2BAA2B,EAC3B,2BAA2B,GAC3B,MAAM,4DAA4D,CAAA;AACnE,YAAY,EACX,6BAA6B,EAC7B,6BAA6B,GAC7B,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,YAAY,EACX,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,cAAc,GACd,MAAM,kBAAkB,CAAA","sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"makeUuid.d.ts","sourceRoot":"","sources":["../../src/utils/makeUuid.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,IAAI,MAAM,CAEjC"}
1
+ {"version":3,"file":"makeUuid.d.ts","sources":["../../src/utils/makeUuid.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,IAAI,MAAM,CAEjC","sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"notifyListener.d.ts","sourceRoot":"","sources":["../../src/utils/notifyListener.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAYzD"}
1
+ {"version":3,"file":"notifyListener.d.ts","sources":["../../src/utils/notifyListener.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAYzD","sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/typeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,CAAA;AAE9D,2EAA2E;AAC3E,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,GACzD,CAAC,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK;CAAE,GACzD,KAAK,CAAA"}
1
+ {"version":3,"file":"typeUtils.d.ts","sources":["../../src/utils/typeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,CAAA;AAE9D,2EAA2E;AAC3E,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,GACzD,CAAC,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK;CAAE,GACzD,KAAK,CAAA","sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"unreachable.d.ts","sourceRoot":"","sources":["../../src/utils/unreachable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAI/C"}
1
+ {"version":3,"file":"unreachable.d.ts","sources":["../../src/utils/unreachable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAI/C","sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/utils/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAgB,CAAA"}
1
+ {"version":3,"file":"version.d.ts","sources":["../../src/utils/version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAgB,CAAA","sourceRoot":""}
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * WARNING: Generated during SDK publish. Do not edit in the published package.
6
6
  */
7
- export const CUSTOM_BLOCKS_SDK_VERSION = "0.6.0"
7
+ export const CUSTOM_BLOCKS_SDK_VERSION = "0.7.0"
@@ -138,15 +138,28 @@ identity without a host request.
138
138
 
139
139
  ## Preferences
140
140
 
141
- `NotionTheme` is `"light" | "dark"`; `NotionContrastMode` is `"standard" | "high"`. The initial
142
- setup snapshot groups these two values under `preferences`. Subsequent host updates change the SDK
143
- cache even when the application has no subscriber, so getters and later subscribers see the current
144
- values.
145
-
146
- `getTheme()`, `getContrastMode()`, and their subscriptions are exported from
147
- `@notionhq/custom-blocks/preferences`. Their React hooks are exported from
148
- `@notionhq/custom-blocks/react`. Use `NotionTokenScope` and the Notion CSS variables stylesheet for
149
- automatic styling. These getters throw before initialization succeeds.
141
+ For styling, the SDK provides a set of [Notion design tokens](../README.md#notion-design-tokens).
142
+ Using these tokens is recommended. CSS that uses them follows Notion’s theme and contrast settings
143
+ automatically.
144
+
145
+ If your code needs to know whether Notion is in light or dark mode, use `getTheme()` or `useTheme()`
146
+ in React. The browser’s `prefers-color-scheme` can differ from the theme selected in Notion. Use
147
+ `getContrastMode()` or `useContrastMode()` to read the contrast setting.
148
+
149
+ The getters and their subscriptions are exported from `@notionhq/custom-blocks/preferences`. The
150
+ hooks are exported from `@notionhq/custom-blocks/react`. Both getters throw if called before SDK
151
+ initialization succeeds.
152
+
153
+ The initial setup snapshot includes these values under `preferences`.
154
+
155
+ ```ts
156
+ preferences: {
157
+ theme: "light" | "dark"
158
+ contrastMode: "standard" | "high"
159
+ }
160
+ ```
161
+
162
+ The SDK keeps both values current as Notion’s settings change, even when no code is subscribed.
150
163
 
151
164
  ## Manifest
152
165
 
@@ -11,9 +11,9 @@ manifest's single source of truth:
11
11
 
12
12
  - **Deployed**: deploying persists the manifest on the block's definition record in Notion. The host
13
13
  reads it from there and sends it to the SDK during initialization.
14
- - **Local development**: dev tooling extracts the same worker declaration and injects it into the
15
- block HTML as a JSON script with ID `notion-custom-block-manifest` and type `application/json`.
16
- The SDK reads the manifest from this metadata and sends it in `connect`.
14
+ - **Local development**: at startup, the dev shell extracts the same worker declaration and injects
15
+ the manifest into the block HTML as a JSON script with ID `notion-custom-block-manifest` and type
16
+ `application/json`. The SDK reads the manifest from this metadata and sends it in `connect`.
17
17
 
18
18
  Notion reconciles custom block definitions by their Worker capability keys during deployment.
19
19
 
@@ -27,14 +27,8 @@ Keep packages that the Worker's server code imports in `dependencies`.
27
27
 
28
28
  ## Local development
29
29
 
30
- Run `ntn workers customblocks dev` from your worker project. The dev shell builds the worker and
31
- reads its custom block declarations. It serves the shell and blocks on one port, with a separate
32
- localhost subdomain for each block. Open the shell URL printed by the command. The default port is
33
- `9873`. The launcher selects another port when needed. Vite provides source transforms and hot
34
- reload.
35
-
36
- Worker declarations are read when the dev shell starts. Restart it after changing a declaration to
37
- regenerate the injected metadata, then reload the block. Block source files hot reload.
30
+ Before you deploy, [verify your block locally](local-development.md) with the dev shell and sample
31
+ data.
38
32
 
39
33
  ## Types
40
34
 
package/docs/errors.md CHANGED
@@ -26,6 +26,10 @@ type CustomBlockErrorInfo<TCode extends string = string> = {
26
26
  API-specific error types list known codes for autocomplete and accept other strings. Keep a default
27
27
  branch when switching on `code`.
28
28
 
29
+ Some errors include a `details` object with extra debugging context. Before using a detail, check
30
+ that it exists and has the shape you expect. Use `code` and `isRetryable` to decide how to handle
31
+ the error.
32
+
29
33
  ## Initialization errors
30
34
 
31
35
  `initCustomBlock()` rejects with `CustomBlockInitializationError`. The React wrapper displays its
package/docs/grants.md CHANGED
@@ -93,7 +93,7 @@ connect to that origin, for example
93
93
  connections, plus images, media, fonts, stylesheets, and frames loaded from the origin. An
94
94
  `https://*.example.com` resource covers subdomains. Deploys reject resources that are not bare HTTPS
95
95
  origins. Notion allows an approved origin only while it is also on the workspace's custom block
96
- network allowlist. The dev shell does not limit network access.
96
+ network allowlist.
97
97
 
98
98
  The declared origins, written as a JSON array such as `["https://api.example.com"]`, can use at most
99
99
  2,048 characters. Deploys reject longer lists. Combine origins that share a domain into one
@@ -107,7 +107,12 @@ nothing.
107
107
 
108
108
  ## Dev shell
109
109
 
110
- The dev shell does not ask for approval. It loads every block as if its grants were approved.
110
+ The dev shell treats each declared `network.fetch` origin as approved. It blocks other external
111
+ origins. The block's own origin, hot reload, Notion-hosted media, and Google Fonts work without
112
+ grants.
113
+
114
+ The same grants govern writes of external HTTPS URLs to Files properties, page icons, and covers.
115
+ Restart the dev shell after changing grants.
111
116
 
112
117
  ## Types
113
118
 
@@ -0,0 +1,39 @@
1
+ # Verify a custom block locally
2
+
3
+ Use the dev shell to check how your custom block renders and responds to changes in sample data. The
4
+ dev shell runs the block in a mock Notion host.
5
+
6
+ ## Start the dev shell
7
+
8
+ From your Worker project, run:
9
+
10
+ ```sh
11
+ ntn workers customblocks dev
12
+ ```
13
+
14
+ The command prints the dev shell URL and keeps running. Use the printed URL each time because the
15
+ port can change.
16
+
17
+ ## Verify in the dev shell
18
+
19
+ 1. Open the dev shell URL.
20
+ 2. Select the block.
21
+ 3. If the block declares data sources, add sample rows and complete the property mappings.
22
+ 4. Try the interaction you changed with a sample value you can recognize. Check that the block shows
23
+ the expected result.
24
+
25
+ Use a deployed block to verify Notion permissions, persistence, and production browser restrictions.
26
+
27
+ ## Allow external origins
28
+
29
+ If your block needs to fetch an external URL, add a
30
+ [`network.fetch` grant](grants.md#network-access) for the HTTPS origin in the block declaration.
31
+
32
+ ## Iterate and diagnose
33
+
34
+ The dev shell hot reloads changes to block source files. Restart the dev shell after changing a
35
+ Worker declaration, including its grants.
36
+
37
+ If the block fails, check the launcher logs, selected sample files, and property mappings. If a
38
+ browser request fails, check the browser console for a content security policy error. In React
39
+ blocks, press `\` to open the SDK debug console.
package/docs/pages.md CHANGED
@@ -117,7 +117,8 @@ guidance. See [mutation save failures](errors.md#mutation-save-failures).
117
117
 
118
118
  Invalid values, duplicate targets, mismatched IDs, and unresolved keys fail before dispatch. An
119
119
  update needs at least one property or metadata change. See
120
- [local update errors](errors.md#local-page-update-errors) and [files and icons](#files-and-icons).
120
+ [local update errors](errors.md#local-page-update-errors) and
121
+ [files, page icons, and covers](#files-page-icons-and-covers).
121
122
 
122
123
  ## React
123
124
 
@@ -166,32 +167,32 @@ Property values can be `null` when empty or unavailable.
166
167
  - πŸ”’ **Read-only:** Notion sets this value. You cannot set it when creating or updating a page.
167
168
  - πŸ”΄ **Unavailable:** The SDK does not support this operation.
168
169
 
169
- | Property type | Read page | Create page | Update page |
170
- | ------------------ | ----------------------------------------- | ------------------ | ------------------ |
171
- | `title` | 🟑 Plain text array | 🟑 Plain text only | 🟑 Plain text only |
172
- | `rich_text` | 🟑 Plain text array | 🟑 Plain text only | 🟑 Plain text only |
173
- | `number` | 🟒 Number | 🟒 Supported | 🟒 Supported |
174
- | `checkbox` | 🟒 Boolean | 🟒 Supported | 🟒 Supported |
175
- | `url` | 🟒 String | 🟒 Supported | 🟒 Supported |
176
- | `email` | 🟒 String | 🟒 Supported | 🟒 Supported |
177
- | `phone_number` | 🟒 String | 🟒 Supported | 🟒 Supported |
178
- | `select` | 🟒 Selected option | 🟒 Supported | 🟒 Supported |
179
- | `multi_select` | 🟒 Selected options | 🟒 Supported | 🟒 Supported |
180
- | `status` | 🟒 Selected option | 🟒 Supported | 🟒 Supported |
181
- | `date` | 🟒 `start` and optional `end` strings | 🟒 Supported | 🟒 Supported |
182
- | `people` | 🟒 Array of user or group ID objects | 🟒 Supported | 🟒 Supported |
183
- | `relation` | 🟒 Array of page ID objects | 🟑 Replaces value | 🟑 Replaces value |
184
- | `place` | 🟒 Coordinates and optional place details | 🟒 Supported | 🟒 Supported |
185
- | `files` | 🟒 External links and hosted files | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
186
- | `unique_id` | 🟑 Formatted ID | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
187
- | `formula` | 🟑 Stored text | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
188
- | `rollup` | 🟑 Stored text | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
189
- | `button` | 🟑 Button label | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
190
- | `verification` | 🟑 Status text | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
191
- | `created_time` | 🟒 Timestamp | πŸ”’ Read-only | πŸ”’ Read-only |
192
- | `last_edited_time` | 🟒 Timestamp | πŸ”’ Read-only | πŸ”’ Read-only |
193
- | `created_by` | 🟒 Actor reference | πŸ”’ Read-only | πŸ”’ Read-only |
194
- | `last_edited_by` | 🟒 Actor reference | πŸ”’ Read-only | πŸ”’ Read-only |
170
+ | Property type | Read page | Create page | Update page |
171
+ | ------------------ | ----------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- |
172
+ | `title` | 🟑 Plain text array | 🟑 Plain text only | 🟑 Plain text only |
173
+ | `rich_text` | 🟑 Plain text array | 🟑 Plain text only | 🟑 Plain text only |
174
+ | `number` | 🟒 Number | 🟒 Supported | 🟒 Supported |
175
+ | `checkbox` | 🟒 Boolean | 🟒 Supported | 🟒 Supported |
176
+ | `url` | 🟒 String | 🟒 Supported | 🟒 Supported |
177
+ | `email` | 🟒 String | 🟒 Supported | 🟒 Supported |
178
+ | `phone_number` | 🟒 String | 🟒 Supported | 🟒 Supported |
179
+ | `select` | 🟒 Selected option | 🟒 Supported | 🟒 Supported |
180
+ | `multi_select` | 🟒 Selected options | 🟒 Supported | 🟒 Supported |
181
+ | `status` | 🟒 Selected option | 🟒 Supported | 🟒 Supported |
182
+ | `date` | 🟒 `start` and optional `end` strings | 🟒 Supported | 🟒 Supported |
183
+ | `people` | 🟒 Array of user or group ID objects | 🟒 Supported | 🟒 Supported |
184
+ | `relation` | 🟒 Array of page ID objects | 🟑 Replaces value | 🟑 Replaces value |
185
+ | `place` | 🟒 Coordinates and optional place details | 🟒 Supported | 🟒 Supported |
186
+ | `files` | 🟒 External links and hosted files | 🟑 Existing Notion-hosted file URLs only<br>πŸ”΄ No uploads | 🟑 Existing Notion-hosted file URLs only<br>πŸ”΄ No uploads |
187
+ | `unique_id` | 🟑 Formatted ID | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
188
+ | `formula` | 🟑 Stored text | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
189
+ | `rollup` | 🟑 Stored text | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
190
+ | `button` | 🟑 Button label | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
191
+ | `verification` | 🟑 Status text | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
192
+ | `created_time` | 🟒 Timestamp | πŸ”’ Read-only | πŸ”’ Read-only |
193
+ | `last_edited_time` | 🟒 Timestamp | πŸ”’ Read-only | πŸ”’ Read-only |
194
+ | `created_by` | 🟒 Actor reference | πŸ”’ Read-only | πŸ”’ Read-only |
195
+ | `last_edited_by` | 🟒 Actor reference | πŸ”’ Read-only | πŸ”’ Read-only |
195
196
 
196
197
  ### Notes
197
198
 
@@ -212,7 +213,7 @@ Property values can be `null` when empty or unavailable.
212
213
  - Date-time writes support minute precision. Seconds and milliseconds are not preserved.
213
214
  - Title and rich text use text arrays, but reads and writes preserve only plain text. Reads and
214
215
  writes do not preserve formatting, links, mentions, or equations as structured rich text.
215
- - Files reads return external links and signed URLs for Notion-hosted files.
216
+ - See [Files properties](#files-properties) for supported file references.
216
217
  - Relation writes replace the value and reject `has_more: true`.
217
218
  - Top-level `created_time` and `last_edited_time` do not depend on the data source schema.
218
219
 
@@ -234,50 +235,84 @@ handing the request to navigation; it does not wait for the new page to load. No
234
235
  page if the current surface cannot display the requested peek. Navigating inside a peek can unmount
235
236
  the block before the result arrives.
236
237
 
237
- ### Files reads
238
+ ## Files, page icons, and covers
238
239
 
239
- A Files entry is an external link (`type: "external"`) or a Notion-hosted file (`type: "file"`).
240
- Hosted `file.url` values are signed and expire at `file.expiry_time`, when supplied. Call
241
- `page.get()` again to request fresh URLs. Empty Files values return `[]`. A failure to resolve an
242
- entry fails the read rather than returning a partial list.
240
+ You can read both Notion-hosted files and external URLs. **File writes can only reference existing
241
+ Notion-hosted files.** The SDK has no file upload API. If you pass an external URL or an upload
242
+ reference when creating or updating a page, the write fails.
243
243
 
244
- ## Files and icons
244
+ | Value | SDK type | Files property | Page icon | Page cover |
245
+ | ---------------------- | -------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
246
+ | Notion-hosted file | `NotionHostedFile` | 🟒 Read<br>🟑 Reference an existing file | 🟒 Read<br>🟑 Reference an existing file | 🟒 Read<br>🟑 Reference an existing file |
247
+ | External URL | `NotionExternalFile` | 🟑 Read only | 🟑 Read only | 🟑 Read only |
248
+ | Built-in icon | `NotionIcon` | β€” | 🟒 Read / Write | β€” |
249
+ | Unicode emoji | `NotionEmoji` | β€” | 🟒 Read / Write | β€” |
250
+ | Workspace custom emoji | `NotionCustomEmoji` | β€” | 🟒 Read / Write | β€” |
245
251
 
246
- The SDK provides five types for icons and file references. Page icons, covers, and file properties
247
- accept different combinations of these types. Import them from `@notionhq/custom-blocks`.
252
+ The `β€”` indicates that the value doesn’t apply to that field.
248
253
 
249
- ### File and icon types
254
+ ### Files properties
250
255
 
251
- - `NotionIcon`: an icon from Notion's built-in catalog, identified by name with an optional color.
252
- - `NotionEmoji`: a Unicode emoji.
253
- - `NotionCustomEmoji`: a workspace custom emoji, identified by ID with an optional name and image
254
- URL.
255
- - `NotionExternalFile`: a file hosted outside Notion, referenced by URL.
256
- - `NotionHostedFile`: a file hosted by Notion, referenced by a URL with an optional expiration time.
256
+ A Files property holds files and links. Reads return entries in order. If a file is unavailable,
257
+ render a placeholder using its name when present. The host includes a name when it can read the
258
+ stored display label.
257
259
 
258
- ### Where these types are used
260
+ ```ts
261
+ type NotionFilePropertyItem =
262
+ | (NotionHostedFile & { name: string })
263
+ | (NotionExternalFile & { name: string })
264
+ | { type: "unavailable"; name?: string }
265
+ ```
266
+
267
+ Placeholders appear only in reads. To set the property to an existing Notion-hosted PDF, pass its
268
+ URL and display name. Replace `aB9z` with the ID of your Files property.
269
+
270
+ ```ts
271
+ await page.updateById({
272
+ properties: {
273
+ aB9z: {
274
+ type: "files",
275
+ files: [{ type: "file", name: "Report.pdf", file: { url: reportUrl } }],
276
+ },
277
+ },
278
+ })
279
+ ```
280
+
281
+ Hosted `file.url` values returned by reads are signed and expire at `file.expiry_time` when that
282
+ field is present. Call `page.get()` again for a fresh URL. An empty Files property returns `[]`.
283
+
284
+ ### Page icons
285
+
286
+ A page icon is the small image next to the page title.
259
287
 
260
- - **Page icons:** `NotionPageIcon` accepts any of the five types. The same type describes
261
- `NotionPageData.icon` and the `icon` field used to create or update a page. Unsupported icon types
262
- read as `null`.
263
- - **Page covers:** `NotionPageCover` accepts `NotionExternalFile` or `NotionHostedFile`. The same
264
- type describes `NotionPageData.cover` and the `cover` field used to create or update a page.
265
- - **Page file properties:** A property with `type: "files"` contains a `files` array of
266
- `NotionFilePropertyItem` entries. Each entry combines `NotionExternalFile` or `NotionHostedFile`
267
- with a required display name (`name`).
288
+ ```ts
289
+ type NotionPageIcon =
290
+ NotionIcon | NotionEmoji | NotionCustomEmoji | NotionHostedFile | NotionExternalFile
291
+ ```
292
+
293
+ To set a blue star, pass its name and color. If you omit `color`, it defaults to `"gray"`.
294
+
295
+ ```ts
296
+ await page.updateById({
297
+ icon: { type: "icon", icon: { name: "star", color: "blue" } },
298
+ })
299
+ ```
268
300
 
269
- File upload references are unsupported. File references point to existing URLs.
301
+ Icon aliases are supported. `NotionIconName` and `NotionIconColor` accept strings. `NotionIconColor`
302
+ suggests known colors in autocomplete. Unsupported icons read as `null`.
270
303
 
271
- ### Native page icons
304
+ ### Page covers
272
305
 
273
- `createPage`, `page.updateById`, and `page.updateByKey` accept
274
- `{ type: "icon", icon: { name: "star", color: "blue" } }` in the `icon` field.
306
+ A page cover is the banner image at the top of a page.
275
307
 
276
- The host resolves icon aliases and defaults omitted colors to gray. `NotionIconName` accepts any
277
- string. `NotionIconColor` accepts any string and suggests known colors for autocomplete.
308
+ ```ts
309
+ type NotionPageCover = NotionHostedFile | NotionExternalFile
310
+ ```
278
311
 
279
- ### URL permissions
312
+ To set a cover, use the URL of an existing Notion-hosted image.
280
313
 
281
- External icon and cover writes require an HTTPS origin allowed by the block's network permissions.
282
- The host checks the submitted URL. Allowlisted origins are trusted to redirect. Without network
283
- permission, URL-backed writes fail before changing the page.
314
+ ```ts
315
+ await page.updateById({
316
+ cover: { type: "file", file: { url: coverUrl } },
317
+ })
318
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,6 +14,7 @@
14
14
  "types": "./dist/index.d.ts"
15
15
  },
16
16
  "./nds.css": "./dist/styles/nds.css",
17
+ "./scrollbars.css": "./dist/styles/scrollbars.css",
17
18
  "./react": {
18
19
  "import": "./dist/react/index.js",
19
20
  "types": "./dist/react/index.d.ts"