@notionhq/custom-blocks 0.5.1 → 0.6.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.
- package/README.md +43 -43
- package/bin/notion-custom-blocks/tar.js +1 -1
- package/dist/bridge/SandboxBridge.d.ts +96 -8
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +310 -54
- package/dist/{context/applyContextMessage.d.ts → bridge/applyHostStateMessage.d.ts} +3 -3
- package/dist/bridge/applyHostStateMessage.d.ts.map +1 -0
- package/dist/{context/applyContextMessage.js → bridge/applyHostStateMessage.js} +7 -8
- package/dist/bridge/getInitializedHostState.d.ts.map +1 -0
- package/dist/bridge/getInitializedHostState.js +8 -0
- package/dist/bridge/hostState.d.ts +29 -0
- package/dist/bridge/hostState.d.ts.map +1 -0
- package/dist/bridge/initialization/SandboxInitialization.d.ts +43 -21
- package/dist/bridge/initialization/SandboxInitialization.d.ts.map +1 -1
- package/dist/bridge/initialization/SandboxInitialization.js +258 -84
- package/dist/bridge/requests.d.ts +1 -1
- package/dist/bridge/requests.d.ts.map +1 -1
- package/dist/bridge/requests.js +4 -3
- package/dist/bridge/subscribeToHostStateField.d.ts +11 -0
- package/dist/bridge/subscribeToHostStateField.d.ts.map +1 -0
- package/dist/{context/subscribeToContext.js → bridge/subscribeToHostStateField.js} +8 -8
- package/dist/data-sources.d.ts +10 -0
- package/dist/data-sources.d.ts.map +1 -0
- package/dist/data-sources.js +1 -0
- package/dist/dataSources/NotionDataSource.d.ts +35 -0
- package/dist/dataSources/NotionDataSource.d.ts.map +1 -0
- package/dist/dataSources/NotionDataSource.js +50 -0
- package/dist/dataSources/bridge/applyDataSourceBindings.d.ts +1 -1
- package/dist/dataSources/bridge/applyDataSourceBindings.d.ts.map +1 -1
- package/dist/dataSources/bridge/makeDataSourceReadResponseSchema.d.ts +2001 -0
- package/dist/dataSources/bridge/makeDataSourceReadResponseSchema.d.ts.map +1 -0
- package/dist/dataSources/bridge/makeDataSourceReadResponseSchema.js +19 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts +2 -2
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts.map +1 -1
- package/dist/dataSources/bridge/resolveDataSources.d.ts +1 -1
- package/dist/dataSources/bridge/resolveDataSources.js +1 -1
- package/dist/dataSources/dataSourceState.d.ts +26 -0
- package/dist/dataSources/dataSourceState.d.ts.map +1 -0
- package/dist/dataSources/dataSourceState.js +39 -0
- package/dist/dataSources/ensureDataSource.d.ts +554 -0
- package/dist/dataSources/ensureDataSource.d.ts.map +1 -0
- package/dist/dataSources/ensureDataSource.js +24 -0
- package/dist/dataSources/getDataSourcePage.d.ts.map +1 -1
- package/dist/dataSources/getDataSourcePage.js +8 -3
- package/dist/dataSources/observeDataSource.d.ts +8 -0
- package/dist/dataSources/observeDataSource.d.ts.map +1 -0
- package/dist/dataSources/observeDataSource.js +76 -0
- package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.d.ts +1 -1
- package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.js +1 -1
- package/dist/dataSources/resolvePageDataSource.d.ts +1 -1
- package/dist/dataSources/resolvePageDataSource.d.ts.map +1 -1
- package/dist/dataSources/subscribeToDataSource.d.ts +1 -1
- package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -1
- package/dist/dataSources/subscribeToDataSource.js +75 -48
- package/dist/dataSources/types.d.ts +23 -15
- package/dist/dataSources/types.d.ts.map +1 -1
- package/dist/index.d.ts +18 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/initialization/initCustomBlock.d.ts +6 -4
- package/dist/initialization/initCustomBlock.d.ts.map +1 -1
- package/dist/initialization/initCustomBlock.js +6 -4
- package/dist/initialization/notifyReady.d.ts +14 -0
- package/dist/initialization/notifyReady.d.ts.map +1 -0
- package/dist/initialization/notifyReady.js +9 -0
- package/dist/initialization/react/useCustomBlockInit.d.ts +18 -36
- package/dist/initialization/react/useCustomBlockInit.d.ts.map +1 -1
- package/dist/initialization/react/useCustomBlockInit.js +9 -22
- package/dist/initialization/resolveInitialState.d.ts +3 -12
- package/dist/initialization/resolveInitialState.d.ts.map +1 -1
- package/dist/initialization/resolveInitialState.js +8 -25
- package/dist/initialization/types.d.ts +17 -14
- package/dist/initialization/types.d.ts.map +1 -1
- package/dist/layout/autoResize.d.ts +1 -0
- package/dist/layout/autoResize.d.ts.map +1 -1
- package/dist/layout/autoResize.js +57 -37
- package/dist/location/getContainingPage.d.ts +4 -0
- package/dist/location/getContainingPage.d.ts.map +1 -0
- package/dist/location/getContainingPage.js +10 -0
- package/dist/location/getInstance.d.ts +7 -0
- package/dist/location/getInstance.d.ts.map +1 -0
- package/dist/location/getInstance.js +8 -0
- package/dist/location/getParent.d.ts +4 -0
- package/dist/location/getParent.d.ts.map +1 -0
- package/dist/location/getParent.js +10 -0
- package/dist/location/mapContainingPage.d.ts +4 -0
- package/dist/location/mapContainingPage.d.ts.map +1 -0
- package/dist/location/mapContainingPage.js +10 -0
- package/dist/location/mapParent.d.ts +4 -0
- package/dist/location/mapParent.d.ts.map +1 -0
- package/dist/location/mapParent.js +20 -0
- package/dist/location/subscribeToContainingPage.d.ts +5 -0
- package/dist/location/subscribeToContainingPage.d.ts.map +1 -0
- package/dist/location/subscribeToContainingPage.js +9 -0
- package/dist/location/subscribeToParent.d.ts +5 -0
- package/dist/location/subscribeToParent.d.ts.map +1 -0
- package/dist/location/subscribeToParent.js +9 -0
- package/dist/location/types.d.ts +45 -0
- package/dist/location/types.d.ts.map +1 -0
- package/dist/location/types.js +1 -0
- package/dist/manifest/getManifest.d.ts +1 -1
- package/dist/manifest/getManifest.js +2 -2
- package/dist/navigation/openExternalUrl.d.ts +1 -1
- package/dist/navigation/openExternalUrl.d.ts.map +1 -1
- package/dist/navigation/openExternalUrl.js +1 -1
- package/dist/navigation.d.ts +16 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +21 -0
- package/dist/pages/NotionPage.d.ts +34 -0
- package/dist/pages/NotionPage.d.ts.map +1 -0
- package/dist/pages/NotionPage.js +105 -0
- package/dist/pages/bridge/getPageForDataSource.d.ts +1 -1
- package/dist/pages/bridge/getPageForDataSource.d.ts.map +1 -1
- package/dist/pages/bridge/getPageForDataSource.js +2 -2
- package/dist/pages/bridge/resolveCreatePageDestination.d.ts +1 -1
- package/dist/pages/bridge/resolveCreatePageDestination.d.ts.map +1 -1
- package/dist/pages/bridge/sendCreatePageRequest.d.ts.map +1 -1
- package/dist/pages/bridge/sendCreatePageRequest.js +3 -2
- package/dist/pages/bridge/toNotionPageFromBridgePage.d.ts +3 -9
- package/dist/pages/bridge/toNotionPageFromBridgePage.d.ts.map +1 -1
- package/dist/pages/bridge/toNotionPageFromBridgePage.js +36 -11
- package/dist/pages/bridge/updatePage.d.ts +4 -3
- package/dist/pages/bridge/updatePage.d.ts.map +1 -1
- package/dist/pages/bridge/updatePage.js +3 -3
- package/dist/pages/createPage.d.ts.map +1 -1
- package/dist/pages/createPage.js +9 -1
- package/dist/pages/getPage.d.ts +2 -2
- package/dist/pages/getPage.d.ts.map +1 -1
- package/dist/pages/getPage.js +1 -1
- package/dist/pages/identityBlockKey.d.ts +4 -0
- package/dist/pages/identityBlockKey.d.ts.map +1 -0
- package/dist/pages/identityBlockKey.js +6 -0
- package/dist/pages/identityPageKey.d.ts +7 -0
- package/dist/pages/identityPageKey.d.ts.map +1 -0
- package/dist/pages/identityPageKey.js +9 -0
- package/dist/pages/parent.d.ts +0 -2
- package/dist/pages/parent.d.ts.map +1 -1
- package/dist/pages/types.d.ts +20 -48
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/pages.d.ts +56 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +69 -0
- package/dist/preferences/backgroundColors.d.ts.map +1 -0
- package/dist/preferences/getContrastMode.d.ts.map +1 -0
- package/dist/{context → preferences}/getContrastMode.js +1 -1
- package/dist/preferences/getTheme.d.ts.map +1 -0
- package/dist/{context → preferences}/getTheme.js +1 -1
- package/dist/preferences/react/useContrastMode.d.ts.map +1 -0
- package/dist/preferences/react/useTheme.d.ts.map +1 -0
- package/dist/{context → preferences}/subscribeToContrastMode.d.ts +1 -1
- package/dist/preferences/subscribeToContrastMode.d.ts.map +1 -0
- package/dist/{context → preferences}/subscribeToContrastMode.js +2 -2
- package/dist/{context → preferences}/subscribeToTheme.d.ts +1 -1
- package/dist/preferences/subscribeToTheme.d.ts.map +1 -0
- package/dist/{context → preferences}/subscribeToTheme.js +2 -2
- package/dist/preferences/syncDocumentAppearance.d.ts +11 -0
- package/dist/preferences/syncDocumentAppearance.d.ts.map +1 -0
- package/dist/{context → preferences}/syncDocumentAppearance.js +2 -5
- package/dist/preferences.d.ts +7 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +4 -0
- package/dist/protocol/context/containingPage.d.ts +2 -0
- package/dist/protocol/context/containingPage.js +4 -2
- package/dist/protocol/context/instance.d.ts +13 -0
- package/dist/protocol/context/instance.js +8 -0
- package/dist/protocol/context/messages/pageChanged.d.ts +1 -0
- package/dist/protocol/context/messages/pageError.d.ts +11 -0
- package/dist/protocol/context/messages/pageError.js +7 -0
- package/dist/protocol/context/messages/parentError.d.ts +11 -0
- package/dist/protocol/context/messages/parentError.js +7 -0
- package/dist/protocol/context/parent.d.ts +6 -6
- package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +4 -4
- package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +4 -4
- package/dist/protocol/dataSources/bridgeDataSourceQueryLimitClamp.d.ts +10 -0
- package/dist/protocol/dataSources/bridgeDataSourceQueryLimitClamp.js +6 -0
- package/dist/protocol/dataSources/dataSourceSchema.d.ts +4 -4
- package/dist/protocol/dataSources/errors.d.ts +27 -3
- package/dist/protocol/dataSources/messages/getDataSource.d.ts +1857 -0
- package/dist/protocol/dataSources/messages/getDataSource.js +27 -0
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +44 -376
- package/dist/protocol/dataSources/messages/queryDataSource.js +2 -16
- package/dist/protocol/dataSources/notionDataSource.d.ts +8 -8
- package/dist/protocol/dataSources/properties/propertySchema.d.ts +15 -20
- package/dist/protocol/dataSources/properties/propertySchema.js +5 -10
- package/dist/protocol/handshake/connect.d.ts +11 -23
- package/dist/protocol/handshake/connect.js +12 -34
- package/dist/protocol/handshake/connectResult.d.ts +19 -0
- package/dist/protocol/handshake/connectResult.js +18 -0
- package/dist/protocol/handshake/init.d.ts +41 -219
- package/dist/protocol/handshake/init.js +11 -30
- package/dist/protocol/handshake/initResult.d.ts +9 -14
- package/dist/protocol/handshake/initResult.js +7 -10
- package/dist/protocol/handshake/isInitHandshakeMessage.d.ts +3 -3
- package/dist/protocol/handshake/isInitHandshakeMessage.js +1 -0
- package/dist/protocol/handshake/ready.d.ts +11 -0
- package/dist/protocol/handshake/ready.js +10 -0
- package/dist/protocol/icons.d.ts +1 -1
- package/dist/protocol/icons.js +1 -1
- package/dist/protocol/manifest/manifest.d.ts +2 -3
- package/dist/protocol/manifest/manifest.js +2 -3
- package/dist/protocol/messages/hostToSandbox.d.ts +1889 -2949
- package/dist/protocol/messages/hostToSandbox.js +21 -24
- package/dist/protocol/messages/incomingType.d.ts +2 -6
- package/dist/protocol/messages/incomingType.js +2 -6
- package/dist/protocol/messages/invalidHostMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidHostMessage.js +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.js +2 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +26 -28
- package/dist/protocol/messages/sandboxToHost.js +13 -8
- package/dist/protocol/pages/bridgePage.d.ts +12 -6
- package/dist/protocol/pages/bridgePage.js +6 -1
- package/dist/protocol/pages/messages/createPage.d.ts +49 -596
- package/dist/protocol/pages/messages/createPage.js +0 -16
- package/dist/protocol/pages/messages/getPage.d.ts +12 -586
- package/dist/protocol/pages/messages/getPage.js +0 -15
- package/dist/protocol/pages/messages/updatePage.d.ts +15 -589
- package/dist/protocol/pages/messages/updatePage.js +1 -16
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +4 -4
- package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +2 -2
- package/dist/protocol/pages/properties/metadataActor.d.ts +1 -1
- package/dist/protocol/pages/properties/metadataActor.js +0 -1
- package/dist/protocol/users/bridgeUser.d.ts +2 -1
- package/dist/protocol/users/bridgeUser.js +2 -1
- package/dist/protocol/users/bridgeUserList.d.ts +1 -1
- package/dist/protocol/users/makeBridgeUser.d.ts +1 -1
- package/dist/protocol/users/makeBridgeUser.js +2 -1
- package/dist/protocol/users/messages/getCurrentUser.d.ts +32 -0
- package/dist/protocol/users/messages/getCurrentUser.js +22 -0
- package/dist/protocol/users/messages/getUser.d.ts +1 -1
- package/dist/protocol/users/messages/getViewer.d.ts +29 -0
- package/dist/protocol/users/messages/getViewer.js +23 -0
- package/dist/protocol/users/messages/listUsers.d.ts +1 -1
- package/dist/protocol/users/viewer.d.ts +9 -0
- package/dist/protocol/users/viewer.js +10 -0
- package/dist/protocol/utils/errors.d.ts +33 -3
- package/dist/protocol/utils/ids.d.ts +3 -0
- package/dist/protocol/utils/ids.js +2 -0
- package/dist/protocol/utils/protocolVersion.d.ts +2 -5
- package/dist/protocol/utils/protocolVersion.js +3 -10
- package/dist/protocol/utils/readSubscriptionId.d.ts +2 -0
- package/dist/protocol/utils/readSubscriptionId.js +7 -0
- package/dist/react/NotionCustomBlock.d.ts +6 -26
- package/dist/react/NotionCustomBlock.d.ts.map +1 -1
- package/dist/react/NotionCustomBlock.js +15 -41
- package/dist/react/NotionTokenScope.js +2 -2
- package/dist/react/index.d.ts +12 -14
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +11 -14
- package/dist/react/useAsyncRead.d.ts +16 -0
- package/dist/react/useAsyncRead.d.ts.map +1 -0
- package/dist/react/useAsyncRead.js +25 -0
- package/dist/react/useContainingPage.d.ts +5 -0
- package/dist/react/useContainingPage.d.ts.map +1 -0
- package/dist/react/useContainingPage.js +16 -0
- package/dist/react/useLiveLocationRead.d.ts +14 -0
- package/dist/react/useLiveLocationRead.d.ts.map +1 -0
- package/dist/react/useLiveLocationRead.js +35 -0
- package/dist/react/usePage.d.ts +7 -0
- package/dist/react/usePage.d.ts.map +1 -0
- package/dist/react/usePage.js +38 -0
- package/dist/react/useParent.d.ts +7 -0
- package/dist/react/useParent.d.ts.map +1 -0
- package/dist/react/useParent.js +18 -0
- package/dist/react/useQuerySubscription.d.ts +22 -0
- package/dist/react/useQuerySubscription.d.ts.map +1 -0
- package/dist/react/useQuerySubscription.js +43 -0
- package/dist/react/useUserFields.d.ts +9 -0
- package/dist/react/useUserFields.d.ts.map +1 -0
- package/dist/react/useUserFields.js +14 -0
- package/dist/react/useViewer.d.ts +3 -0
- package/dist/react/useViewer.d.ts.map +1 -0
- package/dist/react/useViewer.js +6 -0
- package/dist/users/NotionUser.d.ts +21 -0
- package/dist/users/NotionUser.d.ts.map +1 -0
- package/dist/users/NotionUser.js +51 -0
- package/dist/users/bridge/toNotionUserDataFromBridgeUser.d.ts +4 -0
- package/dist/users/bridge/toNotionUserDataFromBridgeUser.d.ts.map +1 -0
- package/dist/users/bridge/{toNotionUserFromBridgeUser.js → toNotionUserDataFromBridgeUser.js} +2 -2
- package/dist/users/getUser.d.ts +1 -1
- package/dist/users/getUser.js +3 -3
- package/dist/users/getViewer.d.ts +19 -0
- package/dist/users/getViewer.d.ts.map +1 -0
- package/dist/users/getViewer.js +21 -0
- package/dist/users/listUsers.d.ts.map +1 -1
- package/dist/users/listUsers.js +15 -5
- package/dist/users/types.d.ts +9 -7
- package/dist/users/types.d.ts.map +1 -1
- package/dist/users.d.ts +9 -0
- package/dist/users.d.ts.map +1 -0
- package/dist/users.js +3 -0
- package/dist/utils/makeUuid.d.ts +2 -0
- package/dist/utils/makeUuid.d.ts.map +1 -0
- package/dist/utils/makeUuid.js +3 -0
- package/dist/utils/unreachable.d.ts +1 -5
- package/dist/utils/unreachable.d.ts.map +1 -1
- package/dist/utils/unreachable.js +1 -5
- package/dist/utils/version.js +1 -1
- package/docs/block-location.md +114 -134
- package/docs/data-sources.md +253 -385
- package/docs/deployment.md +8 -8
- package/docs/errors.md +88 -71
- package/docs/grants.md +18 -27
- package/docs/lifecycle.md +94 -188
- package/docs/links.md +14 -16
- package/docs/pages.md +136 -148
- package/docs/users.md +81 -126
- package/package.json +21 -1
- package/src/bridge/SandboxBridge.ts +387 -66
- package/src/{context/applyContextMessage.ts → bridge/applyHostStateMessage.ts} +9 -9
- package/src/{context → bridge}/getInitializedHostState.ts +2 -2
- package/src/bridge/hostState.ts +31 -0
- package/src/bridge/initialization/SandboxInitialization.ts +323 -117
- package/src/bridge/requests.ts +6 -3
- package/src/{context/subscribeToContext.ts → bridge/subscribeToHostStateField.ts} +11 -9
- package/src/data-sources.ts +24 -0
- package/src/dataSources/NotionDataSource.ts +114 -0
- package/src/dataSources/bridge/applyDataSourceBindings.ts +1 -1
- package/src/dataSources/bridge/makeDataSourceReadResponseSchema.ts +29 -0
- package/src/dataSources/bridge/resolveDataSourceQuery.ts +2 -2
- package/src/dataSources/bridge/resolveDataSources.ts +1 -1
- package/src/dataSources/dataSourceState.ts +65 -0
- package/src/dataSources/ensureDataSource.ts +33 -0
- package/src/dataSources/getDataSourcePage.ts +8 -3
- package/src/dataSources/observeDataSource.ts +94 -0
- package/src/dataSources/properties/resolvePropertyWriteMapForDataSource.ts +1 -1
- package/src/dataSources/resolvePageDataSource.ts +1 -1
- package/src/dataSources/subscribeToDataSource.ts +81 -49
- package/src/dataSources/types.ts +21 -15
- package/src/index.ts +25 -66
- package/src/initialization/initCustomBlock.ts +9 -5
- package/src/initialization/notifyReady.ts +15 -0
- package/src/initialization/react/useCustomBlockInit.ts +22 -37
- package/src/initialization/resolveInitialState.ts +13 -32
- package/src/initialization/types.ts +20 -14
- package/src/layout/autoResize.ts +57 -40
- package/src/location/getContainingPage.ts +14 -0
- package/src/location/getInstance.ts +10 -0
- package/src/location/getParent.ts +14 -0
- package/src/location/mapContainingPage.ts +13 -0
- package/src/location/mapParent.ts +23 -0
- package/src/location/subscribeToContainingPage.ts +14 -0
- package/src/location/subscribeToParent.ts +14 -0
- package/src/location/types.ts +29 -0
- package/src/manifest/getManifest.ts +2 -2
- package/src/navigation/openExternalUrl.ts +1 -1
- package/src/navigation.ts +45 -0
- package/src/pages/NotionPage.ts +144 -0
- package/src/pages/bridge/getPageForDataSource.ts +3 -3
- package/src/pages/bridge/resolveCreatePageDestination.ts +1 -1
- package/src/pages/bridge/sendCreatePageRequest.ts +3 -2
- package/src/pages/bridge/toNotionPageFromBridgePage.ts +45 -19
- package/src/pages/bridge/updatePage.ts +6 -6
- package/src/pages/createPage.ts +14 -1
- package/src/pages/getPage.ts +2 -2
- package/src/pages/identityBlockKey.ts +10 -0
- package/src/pages/identityPageKey.ts +13 -0
- package/src/pages/parent.ts +0 -10
- package/src/pages/types.ts +23 -42
- package/src/pages.ts +144 -0
- package/src/{context → preferences}/getContrastMode.ts +1 -1
- package/src/{context → preferences}/getTheme.ts +1 -1
- package/src/{context → preferences}/subscribeToContrastMode.ts +3 -3
- package/src/{context → preferences}/subscribeToTheme.ts +3 -3
- package/src/{context → preferences}/syncDocumentAppearance.ts +2 -5
- package/src/preferences.ts +6 -0
- package/src/react/NotionCustomBlock.tsx +21 -52
- package/src/react/NotionTokenScope.tsx +2 -2
- package/src/react/index.ts +20 -14
- package/src/react/useAsyncRead.ts +44 -0
- package/src/react/useContainingPage.ts +20 -0
- package/src/react/useLiveLocationRead.ts +53 -0
- package/src/react/usePage.ts +61 -0
- package/src/react/useParent.ts +22 -0
- package/src/react/useQuerySubscription.ts +71 -0
- package/src/react/useUserFields.ts +24 -0
- package/src/react/useViewer.ts +7 -0
- package/src/users/NotionUser.ts +70 -0
- package/src/users/bridge/{toNotionUserFromBridgeUser.ts → toNotionUserDataFromBridgeUser.ts} +6 -3
- package/src/users/getUser.ts +3 -3
- package/src/users/getViewer.ts +36 -0
- package/src/users/listUsers.ts +15 -5
- package/src/users/types.ts +9 -7
- package/src/users.ts +20 -0
- package/src/utils/makeUuid.ts +3 -0
- package/src/utils/unreachable.ts +1 -6
- package/dist/bridge/parseHostToSandboxMessage.d.ts +0 -3658
- package/dist/bridge/parseHostToSandboxMessage.d.ts.map +0 -1
- package/dist/bridge/parseHostToSandboxMessage.js +0 -47
- package/dist/context/applyContextMessage.d.ts.map +0 -1
- package/dist/context/backgroundColors.d.ts.map +0 -1
- package/dist/context/getBlockId.d.ts +0 -7
- package/dist/context/getBlockId.d.ts.map +0 -1
- package/dist/context/getBlockId.js +0 -8
- package/dist/context/getContrastMode.d.ts.map +0 -1
- package/dist/context/getInitializedHostState.d.ts.map +0 -1
- package/dist/context/getInitializedHostState.js +0 -8
- package/dist/context/getPage.d.ts +0 -7
- package/dist/context/getPage.d.ts.map +0 -1
- package/dist/context/getPage.js +0 -8
- package/dist/context/getParent.d.ts +0 -7
- package/dist/context/getParent.d.ts.map +0 -1
- package/dist/context/getParent.js +0 -8
- package/dist/context/getTheme.d.ts.map +0 -1
- package/dist/context/hostState.d.ts +0 -15
- package/dist/context/hostState.d.ts.map +0 -1
- package/dist/context/index.d.ts +0 -42
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -41
- package/dist/context/react/useBlockId.d.ts +0 -11
- package/dist/context/react/useBlockId.d.ts.map +0 -1
- package/dist/context/react/useBlockId.js +0 -14
- package/dist/context/react/useContrastMode.d.ts.map +0 -1
- package/dist/context/react/usePage.d.ts +0 -12
- package/dist/context/react/usePage.d.ts.map +0 -1
- package/dist/context/react/usePage.js +0 -15
- package/dist/context/react/useParent.d.ts +0 -12
- package/dist/context/react/useParent.d.ts.map +0 -1
- package/dist/context/react/useParent.js +0 -15
- package/dist/context/react/useTheme.d.ts.map +0 -1
- package/dist/context/subscribeToBlockId.d.ts +0 -8
- package/dist/context/subscribeToBlockId.d.ts.map +0 -1
- package/dist/context/subscribeToBlockId.js +0 -8
- package/dist/context/subscribeToContext.d.ts +0 -12
- package/dist/context/subscribeToContext.d.ts.map +0 -1
- package/dist/context/subscribeToContrastMode.d.ts.map +0 -1
- package/dist/context/subscribeToPage.d.ts +0 -8
- package/dist/context/subscribeToPage.d.ts.map +0 -1
- package/dist/context/subscribeToPage.js +0 -8
- package/dist/context/subscribeToParent.d.ts +0 -8
- package/dist/context/subscribeToParent.d.ts.map +0 -1
- package/dist/context/subscribeToParent.js +0 -8
- package/dist/context/subscribeToTheme.d.ts.map +0 -1
- package/dist/context/syncDocumentAppearance.d.ts +0 -14
- package/dist/context/syncDocumentAppearance.d.ts.map +0 -1
- package/dist/dataSources/createDataSourcePage.d.ts +0 -4
- package/dist/dataSources/createDataSourcePage.d.ts.map +0 -1
- package/dist/dataSources/createDataSourcePage.js +0 -44
- package/dist/dataSources/index.d.ts +0 -9
- package/dist/dataSources/index.d.ts.map +0 -1
- package/dist/dataSources/index.js +0 -8
- package/dist/dataSources/queryDataSource.d.ts +0 -3
- package/dist/dataSources/queryDataSource.d.ts.map +0 -1
- package/dist/dataSources/queryDataSource.js +0 -56
- package/dist/dataSources/react/useDataSource.d.ts +0 -13
- package/dist/dataSources/react/useDataSource.d.ts.map +0 -1
- package/dist/dataSources/react/useDataSource.js +0 -58
- package/dist/initialization/getInitBindingError.d.ts +0 -5
- package/dist/initialization/getInitBindingError.d.ts.map +0 -1
- package/dist/initialization/getInitBindingError.js +0 -26
- package/dist/layout/postResize.d.ts +0 -2
- package/dist/layout/postResize.d.ts.map +0 -1
- package/dist/layout/postResize.js +0 -12
- package/dist/manifest/react/useManifest.d.ts +0 -15
- package/dist/manifest/react/useManifest.d.ts.map +0 -1
- package/dist/manifest/react/useManifest.js +0 -18
- package/dist/manifest/subscribeToManifest.d.ts +0 -8
- package/dist/manifest/subscribeToManifest.d.ts.map +0 -1
- package/dist/manifest/subscribeToManifest.js +0 -8
- package/dist/navigation/index.d.ts +0 -5
- package/dist/navigation/index.d.ts.map +0 -1
- package/dist/navigation/index.js +0 -4
- package/dist/pages/bridge/makeUpdatePageByKey.d.ts +0 -8
- package/dist/pages/bridge/makeUpdatePageByKey.d.ts.map +0 -1
- package/dist/pages/bridge/makeUpdatePageByKey.js +0 -17
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts +0 -89
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts.map +0 -1
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.js +0 -24
- package/dist/pages/bridge/updateNotionPageFromBridgePage.d.ts +0 -4
- package/dist/pages/bridge/updateNotionPageFromBridgePage.d.ts.map +0 -1
- package/dist/pages/bridge/updateNotionPageFromBridgePage.js +0 -4
- package/dist/pages/index.d.ts +0 -9
- package/dist/pages/index.d.ts.map +0 -1
- package/dist/pages/index.js +0 -8
- package/dist/pages/makeNotionPage.d.ts +0 -11
- package/dist/pages/makeNotionPage.d.ts.map +0 -1
- package/dist/pages/makeNotionPage.js +0 -34
- package/dist/pages/properties/getPropertyById.d.ts +0 -6
- package/dist/pages/properties/getPropertyById.d.ts.map +0 -1
- package/dist/pages/properties/getPropertyById.js +0 -3
- package/dist/pages/properties/getPropertyByKey.d.ts +0 -9
- package/dist/pages/properties/getPropertyByKey.d.ts.map +0 -1
- package/dist/pages/properties/getPropertyByKey.js +0 -16
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.d.ts +0 -530
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.js +0 -25
- package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +0 -282
- package/dist/protocol/compatibility/protocol3To5/bridgePage.js +0 -21
- package/dist/protocol/compatibility/protocol3To5/dataSourcePage.d.ts +0 -73
- package/dist/protocol/compatibility/protocol3To5/dataSourcePage.js +0 -14
- package/dist/protocol/compatibility/protocol3To5/dataSourceValue.d.ts +0 -66
- package/dist/protocol/compatibility/protocol3To5/dataSourceValue.js +0 -14
- package/dist/protocol/dataSources/messages/dataSourcesChanged.d.ts +0 -150
- package/dist/protocol/dataSources/messages/dataSourcesChanged.js +0 -13
- package/dist/protocol/index.d.ts +0 -156
- package/dist/protocol/index.js +0 -79
- package/dist/protocol/users/messages/currentUserChanged.d.ts +0 -18
- package/dist/protocol/users/messages/currentUserChanged.js +0 -9
- package/dist/users/bridge/toNotionUserFromBridgeUser.d.ts +0 -4
- package/dist/users/bridge/toNotionUserFromBridgeUser.d.ts.map +0 -1
- package/dist/users/getCurrentUser.d.ts +0 -7
- package/dist/users/getCurrentUser.d.ts.map +0 -1
- package/dist/users/getCurrentUser.js +0 -8
- package/dist/users/index.d.ts +0 -7
- package/dist/users/index.d.ts.map +0 -1
- package/dist/users/index.js +0 -6
- package/dist/users/react/useCurrentUser.d.ts +0 -12
- package/dist/users/react/useCurrentUser.d.ts.map +0 -1
- package/dist/users/react/useCurrentUser.js +0 -15
- package/dist/users/subscribeToCurrentUser.d.ts +0 -8
- package/dist/users/subscribeToCurrentUser.d.ts.map +0 -1
- package/dist/users/subscribeToCurrentUser.js +0 -8
- package/src/bridge/parseHostToSandboxMessage.ts +0 -54
- package/src/context/getBlockId.ts +0 -10
- package/src/context/getPage.ts +0 -10
- package/src/context/getParent.ts +0 -10
- package/src/context/hostState.ts +0 -17
- package/src/context/index.ts +0 -42
- package/src/context/react/useBlockId.ts +0 -16
- package/src/context/react/usePage.ts +0 -17
- package/src/context/react/useParent.ts +0 -17
- package/src/context/subscribeToBlockId.ts +0 -13
- package/src/context/subscribeToPage.ts +0 -13
- package/src/context/subscribeToParent.ts +0 -13
- package/src/dataSources/createDataSourcePage.ts +0 -50
- package/src/dataSources/index.ts +0 -9
- package/src/dataSources/queryDataSource.ts +0 -62
- package/src/dataSources/react/useDataSource.ts +0 -71
- package/src/initialization/getInitBindingError.ts +0 -39
- package/src/layout/postResize.ts +0 -15
- package/src/manifest/react/useManifest.ts +0 -20
- package/src/manifest/subscribeToManifest.ts +0 -13
- package/src/navigation/index.ts +0 -5
- package/src/pages/bridge/makeUpdatePageByKey.ts +0 -25
- package/src/pages/bridge/toNotionPageFieldsFromBridgePage.ts +0 -27
- package/src/pages/bridge/updateNotionPageFromBridgePage.ts +0 -10
- package/src/pages/index.ts +0 -9
- package/src/pages/makeNotionPage.ts +0 -55
- package/src/pages/properties/getPropertyById.ts +0 -12
- package/src/pages/properties/getPropertyByKey.ts +0 -30
- package/src/styles/nds.css.metadata.json +0 -6
- package/src/users/getCurrentUser.ts +0 -10
- package/src/users/index.ts +0 -7
- package/src/users/react/useCurrentUser.ts +0 -17
- package/src/users/subscribeToCurrentUser.ts +0 -13
- /package/dist/{context → bridge}/getInitializedHostState.d.ts +0 -0
- /package/dist/{context → bridge}/hostState.js +0 -0
- /package/dist/{context → preferences}/backgroundColors.d.ts +0 -0
- /package/dist/{context → preferences}/backgroundColors.js +0 -0
- /package/dist/{context → preferences}/getContrastMode.d.ts +0 -0
- /package/dist/{context → preferences}/getTheme.d.ts +0 -0
- /package/dist/{context → preferences}/react/useContrastMode.d.ts +0 -0
- /package/dist/{context → preferences}/react/useContrastMode.js +0 -0
- /package/dist/{context → preferences}/react/useTheme.d.ts +0 -0
- /package/dist/{context → preferences}/react/useTheme.js +0 -0
- /package/src/{context → preferences}/backgroundColors.ts +0 -0
- /package/src/{context → preferences}/react/useContrastMode.ts +0 -0
- /package/src/{context → preferences}/react/useTheme.ts +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getBridge } from "../bridge/getBridge.js";
|
|
2
|
+
import { notifyListener } from "../utils/notifyListener.js";
|
|
3
|
+
import { getCachedDataSource } from "./ensureDataSource.js";
|
|
4
|
+
/** Follows one key across host invalidations and loads metadata when the cache is empty. */
|
|
5
|
+
export function observeDataSource(key, listener, options = {}) {
|
|
6
|
+
const bridge = getBridge();
|
|
7
|
+
let active = true;
|
|
8
|
+
let generation;
|
|
9
|
+
let source;
|
|
10
|
+
let stopObserving;
|
|
11
|
+
function deliver(state) {
|
|
12
|
+
if (active) {
|
|
13
|
+
notifyListener(() => listener(state));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function refresh() {
|
|
17
|
+
const nextGeneration = bridge.getDataSourceReadGeneration();
|
|
18
|
+
const nextSource = getCachedDataSource(bridge, key);
|
|
19
|
+
if (generation === nextGeneration && source === nextSource) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
generation = nextGeneration;
|
|
23
|
+
source = nextSource;
|
|
24
|
+
if (nextSource !== undefined) {
|
|
25
|
+
deliver({ status: "success", dataSource: nextSource });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
deliver({ status: "loading" });
|
|
29
|
+
if (!active) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
void bridge.readDataSource(key).then(result => {
|
|
33
|
+
// The cache update delivers successes. Ignore errors from superseded reads.
|
|
34
|
+
if (result.status === "error" &&
|
|
35
|
+
generation === nextGeneration &&
|
|
36
|
+
source === undefined) {
|
|
37
|
+
deliver(result);
|
|
38
|
+
}
|
|
39
|
+
}, error => {
|
|
40
|
+
if (generation === nextGeneration && source === undefined) {
|
|
41
|
+
deliver({
|
|
42
|
+
status: "error",
|
|
43
|
+
error: {
|
|
44
|
+
code: "unknown_error",
|
|
45
|
+
message: error instanceof Error ? error.message : String(error),
|
|
46
|
+
isRetryable: false,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function start() {
|
|
53
|
+
if (active) {
|
|
54
|
+
stopObserving = bridge.subscribe(refresh);
|
|
55
|
+
refresh();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!options.deferInitialDelivery &&
|
|
59
|
+
bridge.getHostState().status === "initialized") {
|
|
60
|
+
start();
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
void bridge.waitForInitialization().then(setup => {
|
|
64
|
+
if (setup.status === "error") {
|
|
65
|
+
deliver(setup);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
start();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return () => {
|
|
73
|
+
active = false;
|
|
74
|
+
stopObserving?.();
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -11,7 +11,7 @@ export type PropertyWriteMapResolutionResult = {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Resolves a public SDK property write map into the ID-keyed bridge shape.
|
|
14
|
-
* A data source makes every identifier a property key
|
|
14
|
+
* A data source makes every identifier a property key. Without one, identifiers are raw IDs.
|
|
15
15
|
*/
|
|
16
16
|
export declare function resolvePropertyWriteMapForDataSource(args: {
|
|
17
17
|
dataSource: NotionDataSource | undefined;
|
|
@@ -5,7 +5,7 @@ function makePropertyError(code, message) {
|
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Resolves a public SDK property write map into the ID-keyed bridge shape.
|
|
8
|
-
* A data source makes every identifier a property key
|
|
8
|
+
* A data source makes every identifier a property key. Without one, identifiers are raw IDs.
|
|
9
9
|
*/
|
|
10
10
|
export function resolvePropertyWriteMapForDataSource(args) {
|
|
11
11
|
const { dataSource, properties } = args;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CustomBlockDataSourceResolutionErrorInfo } from "../protocol/dataSources/errors.js";
|
|
2
2
|
import type { NotionDataSource } from "../protocol/dataSources/notionDataSource.js";
|
|
3
3
|
import type { NotionDataSourceId } from "../protocol/utils/ids.js";
|
|
4
|
-
import type { CustomBlockHostState } from "../
|
|
4
|
+
import type { CustomBlockHostState } from "../bridge/hostState.js";
|
|
5
5
|
export declare function resolvePageDataSource(args: {
|
|
6
6
|
hostState: CustomBlockHostState;
|
|
7
7
|
key: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePageDataSource.d.ts","sourceRoot":"","sources":["../../src/dataSources/resolvePageDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,wDAAwD,CAAA;AACtH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAA;AACxG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resolvePageDataSource.d.ts","sourceRoot":"","sources":["../../src/dataSources/resolvePageDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,wDAAwD,CAAA;AACtH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAA;AACxG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAGlE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC3C,SAAS,EAAE,oBAAoB,CAAA;IAC/B,GAAG,EAAE,MAAM,CAAA;CACX,GACE;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,kBAAkB,CAAA;CAC/B,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,wCAAwC,CAAA;CAAE,CAyCtE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SubscribeToDataSourceArgs } from "./types.js";
|
|
2
|
-
export declare function subscribeToDataSource({ key, onSnapshot, onError, options: providedOptions, }: SubscribeToDataSourceArgs): () => void;
|
|
2
|
+
export declare function subscribeToDataSource({ key, deferInitialDelivery, onSnapshot, onError, options: providedOptions, }: SubscribeToDataSourceArgs): () => void;
|
|
3
3
|
//# sourceMappingURL=subscribeToDataSource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribeToDataSource.d.ts","sourceRoot":"","sources":["../../src/dataSources/subscribeToDataSource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscribeToDataSource.d.ts","sourceRoot":"","sources":["../../src/dataSources/subscribeToDataSource.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAsB,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAE/E,wBAAgB,qBAAqB,CAAC,EACrC,GAAG,EACH,oBAAoB,EACpB,UAAU,EACV,OAAkB,EAClB,OAAO,EAAE,eAAoB,GAC7B,EAAE,yBAAyB,GAAG,MAAM,IAAI,CA8IxC"}
|
|
@@ -1,82 +1,93 @@
|
|
|
1
1
|
import { getBridge } from "../bridge/getBridge.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_REQUEST_TIMEOUT_MS } from "../bridge/requests.js";
|
|
3
|
+
import { toNotionPageFromBridgePage } from "../pages/bridge/toNotionPageFromBridgePage.js";
|
|
4
|
+
import { makeUuid } from "../utils/makeUuid.js";
|
|
3
5
|
import { notifyListener } from "../utils/notifyListener.js";
|
|
4
6
|
import { resolveDataSourceQuery } from "./bridge/resolveDataSourceQuery.js";
|
|
5
|
-
|
|
7
|
+
import { observeDataSource } from "./observeDataSource.js";
|
|
8
|
+
export function subscribeToDataSource({ key, deferInitialDelivery, onSnapshot, onError = () => { }, options: providedOptions = {}, }) {
|
|
6
9
|
const options = structuredClone(providedOptions);
|
|
7
10
|
const bridge = getBridge();
|
|
8
|
-
const subscriptionId =
|
|
11
|
+
const subscriptionId = makeUuid();
|
|
9
12
|
let active = true;
|
|
10
13
|
let dataSource;
|
|
11
14
|
let result;
|
|
12
|
-
let
|
|
15
|
+
let querySent = false;
|
|
16
|
+
let stopObserving;
|
|
17
|
+
let firstResponseTimeout;
|
|
18
|
+
let lastSnapshot;
|
|
13
19
|
const deliverSnapshot = (isLoading) => {
|
|
14
20
|
const source = dataSource;
|
|
15
21
|
const snapshot = {
|
|
16
22
|
items: result?.status === "success" && source !== undefined
|
|
17
|
-
? result.items.map(bridgePage =>
|
|
23
|
+
? result.items.map(bridgePage => toNotionPageFromBridgePage(bridgePage, source))
|
|
18
24
|
: [],
|
|
25
|
+
dataSource: source,
|
|
19
26
|
propertyIdsByKey: source?.propertyIdsByKey ?? {},
|
|
20
27
|
isLoading,
|
|
21
28
|
hasMore: result?.status === "success" && result.hasMore,
|
|
29
|
+
...(result?.status === "success" && result.limitClamp !== undefined
|
|
30
|
+
? { limitClamp: result.limitClamp }
|
|
31
|
+
: {}),
|
|
22
32
|
};
|
|
33
|
+
lastSnapshot = snapshot;
|
|
23
34
|
notifyListener(() => onSnapshot(snapshot));
|
|
24
35
|
};
|
|
25
36
|
const deliverError = (error) => {
|
|
26
|
-
|
|
37
|
+
const snapshot = {
|
|
38
|
+
items: lastSnapshot?.items ?? [],
|
|
39
|
+
dataSource,
|
|
40
|
+
propertyIdsByKey: dataSource?.propertyIdsByKey ?? {},
|
|
41
|
+
isLoading: false,
|
|
42
|
+
hasMore: lastSnapshot?.hasMore ?? false,
|
|
43
|
+
...(lastSnapshot?.limitClamp === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: { limitClamp: lastSnapshot.limitClamp }),
|
|
46
|
+
error,
|
|
47
|
+
};
|
|
48
|
+
lastSnapshot = snapshot;
|
|
49
|
+
notifyListener(() => onSnapshot(snapshot));
|
|
50
|
+
if (active) {
|
|
27
51
|
notifyListener(() => onError(error));
|
|
28
52
|
}
|
|
29
|
-
else {
|
|
30
|
-
deliverSnapshot(false);
|
|
31
|
-
}
|
|
32
53
|
};
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
const hostState = bridge.getHostState();
|
|
38
|
-
if (hostState.status !== "initialized") {
|
|
39
|
-
deliverSnapshot(false);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const nextSource = hostState.dataSources.find(source => source.key === key);
|
|
43
|
-
// Context updates and unchanged bindings preserve object identity. Skip
|
|
44
|
-
// after initial validation if the object has not changed.
|
|
45
|
-
if (bindingSignature !== undefined && nextSource === dataSource) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const signature = nextSource === undefined ? null : JSON.stringify(nextSource);
|
|
49
|
-
if (signature === bindingSignature) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const backingSourceChanged = bindingSignature !== undefined &&
|
|
53
|
-
dataSource?.dataSourcePointer?.id !== nextSource?.dataSourcePointer?.id;
|
|
54
|
-
bindingSignature = signature;
|
|
55
|
-
dataSource = nextSource;
|
|
56
|
-
if (backingSourceChanged) {
|
|
54
|
+
function startQuery(nextSource) {
|
|
55
|
+
if (dataSource?.dataSourcePointer?.id !== nextSource.dataSourcePointer?.id) {
|
|
56
|
+
lastSnapshot = undefined;
|
|
57
57
|
result = undefined;
|
|
58
58
|
}
|
|
59
|
+
dataSource = nextSource;
|
|
60
|
+
clearFirstResponseTimeout();
|
|
59
61
|
const resolved = resolveDataSourceQuery({
|
|
60
|
-
dataSources:
|
|
62
|
+
dataSources: [nextSource],
|
|
61
63
|
key,
|
|
62
64
|
options,
|
|
63
65
|
});
|
|
64
66
|
if (resolved.status === "error") {
|
|
65
|
-
// A new backing source must clear previously delivered rows even when validation fails.
|
|
66
|
-
if (backingSourceChanged && onError !== undefined) {
|
|
67
|
-
deliverSnapshot(false);
|
|
68
|
-
}
|
|
69
67
|
deliverError(resolved.error);
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
70
|
+
firstResponseTimeout = setTimeout(() => {
|
|
71
|
+
firstResponseTimeout = undefined;
|
|
72
|
+
deliverError({
|
|
73
|
+
code: "request_timeout",
|
|
74
|
+
message: `The host did not return an initial query result within ${DEFAULT_REQUEST_TIMEOUT_MS} ms.`,
|
|
75
|
+
isRetryable: false,
|
|
76
|
+
});
|
|
77
|
+
}, DEFAULT_REQUEST_TIMEOUT_MS);
|
|
78
|
+
querySent = true;
|
|
72
79
|
bridge.postToHost({
|
|
73
80
|
type: "queryDataSource",
|
|
74
81
|
subscriptionId,
|
|
75
82
|
...resolved.query,
|
|
76
83
|
});
|
|
77
84
|
deliverSnapshot(true);
|
|
78
|
-
}
|
|
85
|
+
}
|
|
79
86
|
const unsubscribeResults = bridge.subscribeToDataSourceQueryResults(subscriptionId, message => {
|
|
87
|
+
if (!querySent) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
clearFirstResponseTimeout();
|
|
80
91
|
result = message;
|
|
81
92
|
if (message.status === "error") {
|
|
82
93
|
deliverError(message.error);
|
|
@@ -85,23 +96,39 @@ export function subscribeToDataSource({ key, onSnapshot, onError, options: provi
|
|
|
85
96
|
deliverSnapshot(false);
|
|
86
97
|
}
|
|
87
98
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
stopObserving = observeDataSource(key, state => {
|
|
100
|
+
if (state.status === "success") {
|
|
101
|
+
startQuery(state.dataSource);
|
|
102
|
+
}
|
|
103
|
+
else if (state.status === "loading") {
|
|
104
|
+
clearFirstResponseTimeout();
|
|
105
|
+
querySent = false;
|
|
106
|
+
dataSource = undefined;
|
|
107
|
+
lastSnapshot = undefined;
|
|
108
|
+
result = undefined;
|
|
109
|
+
deliverSnapshot(true);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
deliverError(state.error);
|
|
113
|
+
}
|
|
114
|
+
}, { deferInitialDelivery });
|
|
115
|
+
if (!active) {
|
|
116
|
+
stopObserving();
|
|
95
117
|
}
|
|
96
118
|
return unsubscribe;
|
|
119
|
+
function clearFirstResponseTimeout() {
|
|
120
|
+
clearTimeout(firstResponseTimeout);
|
|
121
|
+
firstResponseTimeout = undefined;
|
|
122
|
+
}
|
|
97
123
|
function unsubscribe() {
|
|
98
124
|
if (!active) {
|
|
99
125
|
return;
|
|
100
126
|
}
|
|
101
127
|
active = false;
|
|
102
|
-
|
|
128
|
+
clearFirstResponseTimeout();
|
|
129
|
+
stopObserving?.();
|
|
103
130
|
unsubscribeResults();
|
|
104
|
-
if (
|
|
131
|
+
if (querySent) {
|
|
105
132
|
bridge.postToHost({ type: "unsubscribeDataSourceQuery", subscriptionId });
|
|
106
133
|
}
|
|
107
134
|
}
|
|
@@ -1,33 +1,44 @@
|
|
|
1
|
+
import type { BridgeDataSourceQueryLimitClamp } from "../protocol/dataSources/bridgeDataSourceQueryLimitClamp.js";
|
|
2
|
+
import type { CustomBlockDataSourceResolutionErrorInfo } from "../protocol/dataSources/errors.js";
|
|
1
3
|
import type { CustomBlockQueryDataSourceErrorInfo } from "../protocol/dataSources/messages/queryDataSource.js";
|
|
4
|
+
import type { NotionDataSource } from "../protocol/dataSources/notionDataSource.js";
|
|
2
5
|
import type { CustomBlockCreatePageErrorInfo } from "../protocol/pages/messages/createPage.js";
|
|
3
6
|
import type { CustomBlockGetPageErrorInfo } from "../protocol/pages/messages/getPage.js";
|
|
4
|
-
import type {
|
|
7
|
+
import type { NotionPageData } from "../pages/types.js";
|
|
5
8
|
import type { NotionDataSourceFilter, NotionDataSourceSort } from "./filters/types.js";
|
|
6
|
-
export type
|
|
9
|
+
export type DataSourceReadResult = {
|
|
7
10
|
status: "success";
|
|
8
|
-
|
|
9
|
-
propertyIdsByKey: Record<string, string | undefined>;
|
|
11
|
+
dataSource: NotionDataSource;
|
|
10
12
|
} | {
|
|
11
13
|
status: "error";
|
|
12
|
-
error:
|
|
14
|
+
error: CustomBlockDataSourceResolutionErrorInfo;
|
|
13
15
|
};
|
|
14
|
-
export type
|
|
16
|
+
export type DataSourcesPageResult = {
|
|
15
17
|
status: "success";
|
|
16
|
-
|
|
18
|
+
page: NotionPageData;
|
|
19
|
+
dataSource: NotionDataSource;
|
|
20
|
+
} | {
|
|
17
21
|
status: "error";
|
|
18
|
-
error:
|
|
22
|
+
error: CustomBlockGetPageErrorInfo | CustomBlockCreatePageErrorInfo;
|
|
19
23
|
};
|
|
24
|
+
/** A host-reported reduction of the requested row limit. */
|
|
25
|
+
export type DataSourceQueryLimitClamp = BridgeDataSourceQueryLimitClamp;
|
|
20
26
|
/** Latest live snapshot of a data source query. */
|
|
21
27
|
export type DataSourceSnapshot = {
|
|
22
|
-
items:
|
|
28
|
+
items: NotionPageData[];
|
|
29
|
+
dataSource: NotionDataSource | undefined;
|
|
23
30
|
propertyIdsByKey: {
|
|
24
31
|
[key: string]: string | undefined;
|
|
25
32
|
};
|
|
26
33
|
isLoading: boolean;
|
|
34
|
+
/** The latest failure. Cleared by the next query attempt or successful result. */
|
|
35
|
+
error?: CustomBlockQueryDataSourceErrorInfo;
|
|
27
36
|
hasMore: boolean;
|
|
37
|
+
/** A reported host cap. Older hosts may cap queries without reporting it. */
|
|
38
|
+
limitClamp?: DataSourceQueryLimitClamp;
|
|
28
39
|
};
|
|
29
40
|
export type NotionArchiveStatus = "active" | "archived" | "all";
|
|
30
|
-
export type
|
|
41
|
+
export type InternalDataSourceQueryOptions = {
|
|
31
42
|
/** Maximum number of rows to request from the host. Defaults to 20. */
|
|
32
43
|
limit?: number;
|
|
33
44
|
/** Optional property filter. The SDK resolves semantic keys before it sends the query. */
|
|
@@ -38,12 +49,9 @@ export type DataSourceQueryOptions = {
|
|
|
38
49
|
};
|
|
39
50
|
export type SubscribeToDataSourceArgs = {
|
|
40
51
|
key: string;
|
|
52
|
+
deferInitialDelivery?: boolean;
|
|
41
53
|
onSnapshot: (snapshot: DataSourceSnapshot) => void;
|
|
42
54
|
onError?: (error: CustomBlockQueryDataSourceErrorInfo) => void;
|
|
43
|
-
options?:
|
|
44
|
-
};
|
|
45
|
-
export type UseDataSourceResult = DataSourceSnapshot & {
|
|
46
|
-
error: CustomBlockQueryDataSourceErrorInfo | undefined;
|
|
55
|
+
options?: InternalDataSourceQueryOptions;
|
|
47
56
|
};
|
|
48
|
-
export type UseDataSourceOptions = DataSourceQueryOptions;
|
|
49
57
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dataSources/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,0EAA0E,CAAA;AACnI,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4DAA4D,CAAA;AAC7G,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dataSources/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iFAAiF,CAAA;AACtI,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,wDAAwD,CAAA;AACtH,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,0EAA0E,CAAA;AACnI,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAA;AACxG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4DAA4D,CAAA;AAC7G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EACX,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,MAAM,oBAAoB,GAC7B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,GACnD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,wCAAwC,CAAA;CAAE,CAAA;AAEvE,MAAM,MAAM,qBAAqB,GAC9B;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,EAAE,gBAAgB,CAAA;CAC3B,GACD;IACA,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,2BAA2B,GAAG,8BAA8B,CAAA;CAClE,CAAA;AAEJ,4DAA4D;AAC5D,MAAM,MAAM,yBAAyB,GAAG,+BAA+B,CAAA;AAEvE,mDAAmD;AACnD,MAAM,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACxC,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACvD,SAAS,EAAE,OAAO,CAAA;IAClB,kFAAkF;IAClF,KAAK,CAAC,EAAE,mCAAmC,CAAA;IAC3C,OAAO,EAAE,OAAO,CAAA;IAChB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,yBAAyB,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAA;AAE/D,MAAM,MAAM,8BAA8B,GAAG;IAC5C,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0FAA0F;IAC1F,MAAM,CAAC,EAAE,sBAAsB,CAAA;IAC/B,qEAAqE;IACrE,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAA;IAC9B,aAAa,CAAC,EAAE,mBAAmB,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,UAAU,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAClD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,mCAAmC,KAAK,IAAI,CAAA;IAC9D,OAAO,CAAC,EAAE,8BAA8B,CAAA;CACxC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,50 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public entrypoint for `@notionhq/custom-blocks`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* should import hooks and components from `@notionhq/custom-blocks/react`.
|
|
4
|
+
* Setup, block location, manifest, shared Notion models, and common errors live
|
|
5
|
+
* here. Import individual preferences and domain operations from their
|
|
6
|
+
* subpaths, and React components and hooks from `/react`.
|
|
8
7
|
*/
|
|
9
|
-
export type {
|
|
10
|
-
export type {
|
|
11
|
-
export type { NotionParent } from "./protocol/context/parent.js";
|
|
12
|
-
export type { NotionTheme } from "./protocol/context/theme.js";
|
|
13
|
-
export type { NotionDataSourceSchema } from "./protocol/dataSources/dataSourceSchema.js";
|
|
14
|
-
export type { CustomBlockDataSourceResolutionErrorCode, CustomBlockDataSourceResolutionErrorInfo, CustomBlockPropertyErrorCode, CustomBlockPropertyErrorInfo, } from "./protocol/dataSources/errors.js";
|
|
15
|
-
export type { CustomBlockQueryDataSourceErrorCode, CustomBlockQueryDataSourceErrorInfo, } from "./protocol/dataSources/messages/queryDataSource.js";
|
|
16
|
-
export type { NotionDataSource } from "./protocol/dataSources/notionDataSource.js";
|
|
8
|
+
export type { CustomBlockInstance } from "./protocol/context/instance.js";
|
|
9
|
+
export type { CustomBlockPropertyErrorCode, CustomBlockPropertyErrorInfo, } from "./protocol/dataSources/errors.js";
|
|
17
10
|
export type { NotionDateReminder, NotionDateTimeReminder, NotionDisabledReminder, NotionTimeReminder, } from "./protocol/dataSources/properties/dateValue.js";
|
|
18
11
|
export type { NotionDualProperty, NotionPropertyColor, NotionPropertyOption, NotionPropertySchema, NotionPropertyType, NotionStatusGroup, } from "./protocol/dataSources/properties/propertySchema.js";
|
|
19
12
|
export { NOTION_PROPERTY_TYPES } from "./protocol/dataSources/properties/propertySchema.js";
|
|
20
|
-
export type { NotionSortDirection } from "./protocol/dataSources/sortDirection.js";
|
|
21
13
|
export type { CustomBlockInitializationErrorCode, CustomBlockInitializationErrorInfo, } from "./protocol/handshake/init.js";
|
|
22
14
|
export { CustomBlockInitializationError } from "./protocol/handshake/init.js";
|
|
23
15
|
export type { CustomBlockGrant, CustomBlockGrantAction, CustomBlockGrantResourceName, } from "./protocol/manifest/grants.js";
|
|
24
|
-
export type {
|
|
25
|
-
export type {
|
|
26
|
-
export type { CustomBlockGetPageErrorCode, CustomBlockGetPageErrorInfo, } from "./protocol/pages/messages/getPage.js";
|
|
27
|
-
export type { CustomBlockOpenPageErrorCode, CustomBlockOpenPageErrorInfo, OpenPageMode, } from "./protocol/pages/messages/openPage.js";
|
|
28
|
-
export type { CustomBlockUpdatePageErrorCode, CustomBlockUpdatePageErrorInfo, } from "./protocol/pages/messages/updatePage.js";
|
|
29
|
-
export type { CustomBlockGetUserErrorCode, CustomBlockGetUserErrorInfo, } from "./protocol/users/messages/getUser.js";
|
|
30
|
-
export type { CustomBlockListUsersErrorCode, CustomBlockListUsersErrorInfo, } from "./protocol/users/messages/listUsers.js";
|
|
16
|
+
export type { NotionDateInput } from "./protocol/pages/properties/dateInput.js";
|
|
17
|
+
export type { NotionRichTextItem } from "./protocol/pages/properties/richText.js";
|
|
31
18
|
export type { CustomBlockErrorInfo } from "./protocol/utils/errors.js";
|
|
32
|
-
export type {
|
|
33
|
-
export type { NotionRecordPointer } from "./protocol/utils/recordPointer.js";
|
|
34
|
-
export { customBlock } from "./context/index.js";
|
|
35
|
-
export type * from "./dataSources/filters/types.js";
|
|
36
|
-
export { dataSources } from "./dataSources/index.js";
|
|
37
|
-
export type * from "./dataSources/types.js";
|
|
19
|
+
export type { NotionBlockId } from "./protocol/utils/ids.js";
|
|
38
20
|
export type * from "./files/files.js";
|
|
39
21
|
export type * from "./files/icons.js";
|
|
40
22
|
export { initCustomBlock } from "./initialization/initCustomBlock.js";
|
|
41
23
|
export { NotInIframeError } from "./initialization/NotInIframeError.js";
|
|
42
|
-
export type {
|
|
24
|
+
export type { NotifyReadyResult } from "./initialization/notifyReady.js";
|
|
25
|
+
export { notifyReady } from "./initialization/notifyReady.js";
|
|
26
|
+
export type { CustomBlockInitData, InitCustomBlockOptions, } from "./initialization/types.js";
|
|
27
|
+
export { getContainingPage } from "./location/getContainingPage.js";
|
|
28
|
+
export { getInstance } from "./location/getInstance.js";
|
|
29
|
+
export { getParent } from "./location/getParent.js";
|
|
30
|
+
export { subscribeToContainingPage } from "./location/subscribeToContainingPage.js";
|
|
31
|
+
export { subscribeToParent } from "./location/subscribeToParent.js";
|
|
32
|
+
export type { BlockLocationReadResult, NotionContainingPage, NotionParent, } from "./location/types.js";
|
|
33
|
+
export { getManifest } from "./manifest/getManifest.js";
|
|
43
34
|
export type { NotionCustomBlockManifest, NotionManifestDataSource, NotionManifestIcon, NotionManifestProperty, } from "./manifest/types.js";
|
|
44
|
-
export { links } from "./navigation/index.js";
|
|
45
|
-
export type * from "./navigation/types.js";
|
|
46
|
-
export { pages } from "./pages/index.js";
|
|
47
|
-
export type * from "./pages/types.js";
|
|
48
|
-
export { users } from "./users/index.js";
|
|
49
|
-
export type * from "./users/types.js";
|
|
50
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAA;AAE/F,YAAY,EACX,4BAA4B,EAC5B,4BAA4B,GAC5B,MAAM,wDAAwD,CAAA;AAC/D,YAAY,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,sEAAsE,CAAA;AAC7E,YAAY,EACX,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,2EAA2E,CAAA;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,2EAA2E,CAAA;AACjH,YAAY,EACX,kCAAkC,EAClC,kCAAkC,GAClC,MAAM,oDAAoD,CAAA;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAA;AACnG,YAAY,EACX,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,GAC5B,MAAM,qDAAqD,CAAA;AAC5D,YAAY,EAAE,eAAe,EAAE,MAAM,gEAAgE,CAAA;AACrG,YAAY,EAAE,kBAAkB,EAAE,MAAM,+DAA+D,CAAA;AACvG,YAAY,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAA;AAC5F,YAAY,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAA;AAClF,mBAAmB,kBAAkB,CAAA;AACrC,mBAAmB,kBAAkB,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AACvE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,YAAY,EACX,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,YAAY,EACX,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,GACZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,YAAY,EACX,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public entrypoint for `@notionhq/custom-blocks`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* should import hooks and components from `@notionhq/custom-blocks/react`.
|
|
4
|
+
* Setup, block location, manifest, shared Notion models, and common errors live
|
|
5
|
+
* here. Import individual preferences and domain operations from their
|
|
6
|
+
* subpaths, and React components and hooks from `/react`.
|
|
8
7
|
*/
|
|
9
8
|
export { NOTION_PROPERTY_TYPES } from "./protocol/dataSources/properties/propertySchema.js";
|
|
10
9
|
export { CustomBlockInitializationError } from "./protocol/handshake/init.js";
|
|
11
|
-
export { customBlock } from "./context/index.js";
|
|
12
|
-
export { dataSources } from "./dataSources/index.js";
|
|
13
10
|
export { initCustomBlock } from "./initialization/initCustomBlock.js";
|
|
14
11
|
export { NotInIframeError } from "./initialization/NotInIframeError.js";
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
12
|
+
export { notifyReady } from "./initialization/notifyReady.js";
|
|
13
|
+
export { getContainingPage } from "./location/getContainingPage.js";
|
|
14
|
+
export { getInstance } from "./location/getInstance.js";
|
|
15
|
+
export { getParent } from "./location/getParent.js";
|
|
16
|
+
export { subscribeToContainingPage } from "./location/subscribeToContainingPage.js";
|
|
17
|
+
export { subscribeToParent } from "./location/subscribeToParent.js";
|
|
18
|
+
export { getManifest } from "./manifest/getManifest.js";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CustomBlockInitData, InitCustomBlockOptions } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Starts initialization once and returns the same promise on later calls.
|
|
4
|
+
* The first call selects when the SDK reports readiness.
|
|
5
|
+
* Call before requesting data. Reads during startup await this attempt; reads do not start it.
|
|
6
|
+
* Await success before mounting SDK hooks that require initialized state.
|
|
5
7
|
*/
|
|
6
|
-
export declare function initCustomBlock(): Promise<
|
|
8
|
+
export declare function initCustomBlock(options?: InitCustomBlockOptions): Promise<CustomBlockInitData>;
|
|
7
9
|
//# sourceMappingURL=initCustomBlock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initCustomBlock.d.ts","sourceRoot":"","sources":["../../src/initialization/initCustomBlock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"initCustomBlock.d.ts","sourceRoot":"","sources":["../../src/initialization/initCustomBlock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAE7E;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,OAAO,GAAE,sBAA2B,GAClC,OAAO,CAAC,mBAAmB,CAAC,CAE9B"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { getBridge } from "../bridge/getBridge.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Starts initialization once and returns the same promise on later calls.
|
|
4
|
+
* The first call selects when the SDK reports readiness.
|
|
5
|
+
* Call before requesting data. Reads during startup await this attempt; reads do not start it.
|
|
6
|
+
* Await success before mounting SDK hooks that require initialized state.
|
|
5
7
|
*/
|
|
6
|
-
export function initCustomBlock() {
|
|
7
|
-
return getBridge().initialize();
|
|
8
|
+
export function initCustomBlock(options = {}) {
|
|
9
|
+
return getBridge().initialize(options.readiness);
|
|
8
10
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CustomBlockErrorInfo } from "../protocol/utils/errors.js";
|
|
2
|
+
export type NotifyReadyResult = {
|
|
3
|
+
status: "success";
|
|
4
|
+
} | {
|
|
5
|
+
status: "error";
|
|
6
|
+
error: CustomBlockErrorInfo;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Tells the host the application can be revealed and starts automatic resizing.
|
|
10
|
+
* With manual readiness, call after setup succeeds and your first view is in `#root`.
|
|
11
|
+
* Sends the container's initial height once, then observes height changes until the bridge is disposed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function notifyReady(): NotifyReadyResult;
|
|
14
|
+
//# sourceMappingURL=notifyReady.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifyReady.d.ts","sourceRoot":"","sources":["../../src/initialization/notifyReady.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAA;AAG5F,MAAM,MAAM,iBAAiB,GAC1B;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,oBAAoB,CAAA;CAAE,CAAA;AAEnD;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAE/C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getBridge } from "../bridge/getBridge.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tells the host the application can be revealed and starts automatic resizing.
|
|
4
|
+
* With manual readiness, call after setup succeeds and your first view is in `#root`.
|
|
5
|
+
* Sends the container's initial height once, then observes height changes until the bridge is disposed.
|
|
6
|
+
*/
|
|
7
|
+
export function notifyReady() {
|
|
8
|
+
return getBridge().notifyReady();
|
|
9
|
+
}
|