@notionhq/custom-blocks 0.3.3 → 0.3.5
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/LICENSE +21 -0
- package/README.md +13 -11
- package/dist/bridge/SandboxBridge.d.ts +28 -509
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +89 -689
- package/dist/bridge/getBridge.d.ts +3 -0
- package/dist/bridge/getBridge.d.ts.map +1 -0
- package/dist/bridge/getBridge.js +8 -0
- package/dist/bridge/{SandboxInitialization.d.ts → initialization/SandboxInitialization.d.ts} +6 -9
- package/dist/bridge/initialization/SandboxInitialization.d.ts.map +1 -0
- package/dist/bridge/{SandboxInitialization.js → initialization/SandboxInitialization.js} +18 -26
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +2 -2
- package/dist/context/applyContextMessage.d.ts +6 -0
- package/dist/context/applyContextMessage.d.ts.map +1 -0
- package/dist/context/applyContextMessage.js +35 -0
- package/dist/context/backgroundColors.d.ts +7 -0
- package/dist/context/backgroundColors.d.ts.map +1 -0
- package/dist/context/backgroundColors.js +6 -0
- package/dist/context/getBlockId.d.ts +7 -0
- package/dist/context/getBlockId.d.ts.map +1 -0
- package/dist/context/getBlockId.js +8 -0
- package/dist/context/getContrastMode.d.ts +7 -0
- package/dist/context/getContrastMode.d.ts.map +1 -0
- package/dist/context/getContrastMode.js +8 -0
- package/dist/context/getInitializedHostState.d.ts +3 -0
- package/dist/context/getInitializedHostState.d.ts.map +1 -0
- package/dist/context/getInitializedHostState.js +8 -0
- package/dist/context/getPage.d.ts +7 -0
- package/dist/context/getPage.d.ts.map +1 -0
- package/dist/context/getPage.js +8 -0
- package/dist/context/getParent.d.ts +7 -0
- package/dist/context/getParent.d.ts.map +1 -0
- package/dist/context/getParent.js +8 -0
- package/dist/context/getTheme.d.ts +7 -0
- package/dist/context/getTheme.d.ts.map +1 -0
- package/dist/context/getTheme.js +8 -0
- package/dist/context/hostState.d.ts +15 -0
- package/dist/context/hostState.d.ts.map +1 -0
- package/dist/context/index.d.ts +42 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +41 -0
- package/dist/context/react/useBlockId.d.ts +11 -0
- package/dist/context/react/useBlockId.d.ts.map +1 -0
- package/dist/context/react/useBlockId.js +14 -0
- package/dist/context/react/useContrastMode.d.ts +11 -0
- package/dist/context/react/useContrastMode.d.ts.map +1 -0
- package/dist/context/react/useContrastMode.js +14 -0
- package/dist/context/react/usePage.d.ts +12 -0
- package/dist/context/react/usePage.d.ts.map +1 -0
- package/dist/context/react/usePage.js +15 -0
- package/dist/context/react/useParent.d.ts +12 -0
- package/dist/context/react/useParent.d.ts.map +1 -0
- package/dist/context/react/useParent.js +15 -0
- package/dist/context/react/useTheme.d.ts +11 -0
- package/dist/context/react/useTheme.d.ts.map +1 -0
- package/dist/context/react/useTheme.js +14 -0
- package/dist/context/subscribeToBlockId.d.ts +8 -0
- package/dist/context/subscribeToBlockId.d.ts.map +1 -0
- package/dist/context/subscribeToBlockId.js +8 -0
- package/dist/context/subscribeToContext.d.ts +12 -0
- package/dist/context/subscribeToContext.d.ts.map +1 -0
- package/dist/context/subscribeToContext.js +35 -0
- package/dist/context/subscribeToContrastMode.d.ts +8 -0
- package/dist/context/subscribeToContrastMode.d.ts.map +1 -0
- package/dist/context/subscribeToContrastMode.js +8 -0
- package/dist/context/subscribeToPage.d.ts +8 -0
- package/dist/context/subscribeToPage.d.ts.map +1 -0
- package/dist/context/subscribeToPage.js +8 -0
- package/dist/context/subscribeToParent.d.ts +8 -0
- package/dist/context/subscribeToParent.d.ts.map +1 -0
- package/dist/context/subscribeToParent.js +8 -0
- package/dist/context/subscribeToTheme.d.ts +8 -0
- package/dist/context/subscribeToTheme.d.ts.map +1 -0
- package/dist/context/subscribeToTheme.js +8 -0
- package/dist/context/syncDocumentAppearance.d.ts +14 -0
- package/dist/context/syncDocumentAppearance.d.ts.map +1 -0
- package/dist/context/syncDocumentAppearance.js +22 -0
- package/dist/dataSources/bridge/applyDataSourceBindings.d.ts +4 -0
- package/dist/dataSources/bridge/applyDataSourceBindings.d.ts.map +1 -0
- package/dist/dataSources/bridge/applyDataSourceBindings.js +17 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts +17 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts.map +1 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.js +188 -0
- package/dist/dataSources/bridge/resolveDataSources.d.ts +15 -0
- package/dist/dataSources/bridge/resolveDataSources.d.ts.map +1 -0
- package/dist/{bridge/dataSources/resolve.js → dataSources/bridge/resolveDataSources.js} +10 -11
- package/dist/dataSources/bridge/resolveSorts.d.ts +10 -0
- package/dist/dataSources/bridge/resolveSorts.d.ts.map +1 -0
- package/dist/dataSources/bridge/resolveSorts.js +80 -0
- package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.d.ts +16 -0
- package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.d.ts.map +1 -0
- package/dist/dataSources/bridge/reuseDataSourcesForUnchangedBindings.js +19 -0
- package/dist/dataSources/createDataSourcePage.d.ts +4 -0
- package/dist/dataSources/createDataSourcePage.d.ts.map +1 -0
- package/dist/dataSources/createDataSourcePage.js +40 -0
- package/dist/dataSources/dataSourceInaccessibleError.d.ts +4 -0
- package/dist/dataSources/dataSourceInaccessibleError.d.ts.map +1 -0
- package/dist/dataSources/dataSourceInaccessibleError.js +9 -0
- package/dist/dataSources/filters/resolveFilter.d.ts +10 -0
- package/dist/dataSources/filters/resolveFilter.d.ts.map +1 -0
- package/dist/dataSources/filters/resolveFilter.js +127 -0
- package/dist/dataSources/filters/types.d.ts +66 -0
- package/dist/dataSources/filters/types.d.ts.map +1 -0
- package/dist/dataSources/getDataSourcePage.d.ts +4 -0
- package/dist/dataSources/getDataSourcePage.d.ts.map +1 -0
- package/dist/dataSources/getDataSourcePage.js +18 -0
- package/dist/dataSources/index.d.ts +9 -0
- package/dist/dataSources/index.d.ts.map +1 -0
- package/dist/dataSources/index.js +8 -0
- package/dist/dataSources/properties/resolvePropertyAddress.d.ts +10 -0
- package/dist/dataSources/properties/resolvePropertyAddress.d.ts.map +1 -0
- package/dist/dataSources/properties/resolvePropertyAddress.js +55 -0
- package/dist/{bridge/dataSources/resolveProperty.d.ts → dataSources/properties/resolvePropertyWriteMapForDataSource.d.ts} +4 -4
- package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.d.ts.map +1 -0
- package/dist/{bridge/dataSources/resolveProperty.js → dataSources/properties/resolvePropertyWriteMapForDataSource.js} +2 -2
- package/dist/dataSources/queryDataSource.d.ts +3 -0
- package/dist/dataSources/queryDataSource.d.ts.map +1 -0
- package/dist/dataSources/queryDataSource.js +56 -0
- package/dist/{react → dataSources/react}/useDataSource.d.ts +2 -2
- package/dist/dataSources/react/useDataSource.d.ts.map +1 -0
- package/dist/{react → dataSources/react}/useDataSource.js +4 -4
- package/dist/dataSources/resolvePageDataSource.d.ts +16 -0
- package/dist/dataSources/resolvePageDataSource.d.ts.map +1 -0
- package/dist/dataSources/resolvePageDataSource.js +43 -0
- package/dist/{bridge/dataSources/subscribe.d.ts → dataSources/subscribeToDataSource.d.ts} +3 -3
- package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -0
- package/dist/dataSources/subscribeToDataSource.js +109 -0
- package/dist/dataSources/types.d.ts +47 -0
- package/dist/dataSources/types.d.ts.map +1 -0
- package/dist/dataSources/types.js +1 -0
- package/dist/index.d.ts +38 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/initialization/NotInIframeError.d.ts +12 -0
- package/dist/initialization/NotInIframeError.d.ts.map +1 -0
- package/dist/{initTypes.js → initialization/NotInIframeError.js} +3 -3
- package/dist/initialization/getInitBindingError.d.ts +5 -0
- package/dist/initialization/getInitBindingError.d.ts.map +1 -0
- package/dist/initialization/getInitBindingError.js +26 -0
- package/dist/{init.d.ts → initialization/initCustomBlock.d.ts} +2 -3
- package/dist/initialization/initCustomBlock.d.ts.map +1 -0
- package/dist/{init.js → initialization/initCustomBlock.js} +2 -3
- package/dist/{react → initialization/react}/useCustomBlockInit.d.ts +2 -2
- package/dist/initialization/react/useCustomBlockInit.d.ts.map +1 -0
- package/dist/{react → initialization/react}/useCustomBlockInit.js +1 -1
- package/dist/initialization/resolveInitialState.d.ts +13 -0
- package/dist/initialization/resolveInitialState.d.ts.map +1 -0
- package/dist/initialization/resolveInitialState.js +28 -0
- package/dist/initialization/types.d.ts +20 -0
- package/dist/initialization/types.d.ts.map +1 -0
- package/dist/initialization/types.js +1 -0
- package/dist/layout/autoResize.d.ts.map +1 -0
- package/dist/{autoResize.js → layout/autoResize.js} +2 -2
- package/dist/layout/getInitialContentHeight.d.ts +2 -0
- package/dist/layout/getInitialContentHeight.d.ts.map +1 -0
- package/dist/layout/getInitialContentHeight.js +10 -0
- package/dist/layout/postResize.d.ts +2 -0
- package/dist/layout/postResize.d.ts.map +1 -0
- package/dist/layout/postResize.js +12 -0
- package/dist/manifest/getManifest.d.ts +7 -0
- package/dist/manifest/getManifest.d.ts.map +1 -0
- package/dist/manifest/getManifest.js +8 -0
- package/dist/manifest/react/useManifest.d.ts +15 -0
- package/dist/manifest/react/useManifest.d.ts.map +1 -0
- package/dist/manifest/react/useManifest.js +18 -0
- package/dist/manifest/readLocalManifest.d.ts +23 -0
- package/dist/manifest/readLocalManifest.d.ts.map +1 -0
- package/dist/manifest/readLocalManifest.js +46 -0
- package/dist/manifest/subscribeToManifest.d.ts +8 -0
- package/dist/manifest/subscribeToManifest.d.ts.map +1 -0
- package/dist/manifest/subscribeToManifest.js +8 -0
- package/dist/manifest/types.d.ts +6 -0
- package/dist/manifest/types.d.ts.map +1 -0
- package/dist/manifest/types.js +1 -0
- package/dist/navigation/index.d.ts +5 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +4 -0
- package/dist/navigation/openExternalUrl.d.ts +4 -0
- package/dist/navigation/openExternalUrl.d.ts.map +1 -0
- package/dist/navigation/openExternalUrl.js +5 -0
- package/dist/navigation/types.d.ts +4 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +1 -0
- package/dist/pages/bridge/buildCreatePageRequest.d.ts +16 -0
- package/dist/pages/bridge/buildCreatePageRequest.d.ts.map +1 -0
- package/dist/pages/bridge/buildCreatePageRequest.js +38 -0
- package/dist/pages/bridge/getPageForDataSource.d.ts +9 -0
- package/dist/pages/bridge/getPageForDataSource.d.ts.map +1 -0
- package/dist/pages/bridge/getPageForDataSource.js +13 -0
- package/dist/pages/bridge/makeUpdatePageByKey.d.ts +8 -0
- package/dist/pages/bridge/makeUpdatePageByKey.d.ts.map +1 -0
- package/dist/{bridge/page.js → pages/bridge/makeUpdatePageByKey.js} +0 -12
- package/dist/pages/bridge/resolveCreatePageDestination.d.ts +24 -0
- package/dist/pages/bridge/resolveCreatePageDestination.d.ts.map +1 -0
- package/dist/pages/bridge/resolveCreatePageDestination.js +45 -0
- package/dist/pages/bridge/sendCreatePageRequest.d.ts +11 -0
- package/dist/pages/bridge/sendCreatePageRequest.d.ts.map +1 -0
- package/dist/pages/bridge/sendCreatePageRequest.js +12 -0
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts +77 -0
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts.map +1 -0
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.js +25 -0
- package/dist/pages/bridge/toNotionPageFromBridgePage.d.ts +11 -0
- package/dist/pages/bridge/toNotionPageFromBridgePage.d.ts.map +1 -0
- package/dist/pages/bridge/toNotionPageFromBridgePage.js +12 -0
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts +4 -0
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts.map +1 -0
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.js +92 -0
- package/dist/pages/bridge/updateNotionPageFromBridgePage.d.ts +4 -0
- package/dist/pages/bridge/updateNotionPageFromBridgePage.d.ts.map +1 -0
- package/dist/pages/bridge/updateNotionPageFromBridgePage.js +4 -0
- package/dist/pages/bridge/updatePage.d.ts +12 -0
- package/dist/pages/bridge/updatePage.d.ts.map +1 -0
- package/dist/pages/bridge/updatePage.js +60 -0
- package/dist/pages/createPage.d.ts +3 -0
- package/dist/pages/createPage.d.ts.map +1 -0
- package/dist/pages/createPage.js +27 -0
- package/dist/pages/getPage.d.ts +7 -0
- package/dist/pages/getPage.d.ts.map +1 -0
- package/dist/pages/getPage.js +11 -0
- package/dist/pages/index.d.ts +9 -0
- package/dist/pages/index.d.ts.map +1 -0
- package/dist/pages/index.js +8 -0
- package/dist/pages/makeNotionPage.d.ts +11 -0
- package/dist/pages/makeNotionPage.d.ts.map +1 -0
- package/dist/pages/makeNotionPage.js +34 -0
- package/dist/pages/openPage.d.ts +7 -0
- package/dist/pages/openPage.d.ts.map +1 -0
- package/dist/pages/openPage.js +7 -0
- package/dist/pages/parent.d.ts +7 -0
- package/dist/pages/parent.d.ts.map +1 -0
- package/dist/pages/parent.js +1 -0
- package/dist/pages/properties/getPropertyById.d.ts +6 -0
- package/dist/pages/properties/getPropertyById.d.ts.map +1 -0
- package/dist/pages/properties/getPropertyById.js +3 -0
- package/dist/pages/properties/getPropertyByKey.d.ts +9 -0
- package/dist/pages/properties/getPropertyByKey.d.ts.map +1 -0
- package/dist/pages/properties/getPropertyByKey.js +16 -0
- package/dist/pages/types.d.ts +208 -0
- package/dist/pages/types.d.ts.map +1 -0
- package/dist/pages/types.js +1 -0
- package/dist/protocol/{messages/updatePage.d.ts → compatibility/protocol3To5/bridgePage.d.ts} +32 -22
- package/dist/protocol/compatibility/protocol3To5/bridgePage.js +21 -0
- package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourcePage.d.ts +3 -4
- package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourcePage.js +3 -4
- package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourceValue.js +2 -2
- package/dist/protocol/context/containingPage.d.ts +31 -0
- package/dist/protocol/context/containingPage.js +18 -0
- package/dist/protocol/{messages → context/messages}/pageChanged.js +1 -1
- package/dist/protocol/{parent.d.ts → context/parent.d.ts} +11 -1
- package/dist/protocol/context/parent.js +31 -0
- package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +164 -0
- package/dist/protocol/dataSources/bridgeDataSourceBinding.js +25 -0
- package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +148 -0
- package/dist/protocol/dataSources/bridgeDataSourceBindings.js +3 -0
- package/dist/protocol/dataSources/collectionPointer.d.ts +7 -0
- package/dist/protocol/dataSources/collectionPointer.js +7 -0
- package/dist/protocol/dataSources/collectionSchema.d.ts +144 -0
- package/dist/protocol/dataSources/collectionSchema.js +12 -0
- package/dist/protocol/dataSources/errors.d.ts +2 -2
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.d.ts +505 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.js +8 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.d.ts +253 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.js +69 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceSort.d.ts +11 -0
- package/dist/protocol/dataSources/filters/bridgeDataSourceSort.js +8 -0
- package/dist/protocol/dataSources/filters/checkboxFilterOperator.d.ts +7 -0
- package/dist/protocol/dataSources/filters/checkboxFilterOperator.js +5 -0
- package/dist/protocol/dataSources/filters/containsFilterOperator.d.ts +13 -0
- package/dist/protocol/dataSources/filters/containsFilterOperator.js +9 -0
- package/dist/protocol/dataSources/filters/createdByFilterOperator.d.ts +17 -0
- package/dist/protocol/dataSources/filters/createdByFilterOperator.js +11 -0
- package/dist/protocol/dataSources/filters/dateFilterOperator.d.ts +47 -0
- package/dist/protocol/dataSources/filters/dateFilterOperator.js +73 -0
- package/dist/protocol/dataSources/filters/emptyOperator.d.ts +6 -0
- package/dist/protocol/dataSources/filters/emptyOperator.js +5 -0
- package/dist/protocol/dataSources/filters/numberFilterOperator.d.ts +19 -0
- package/dist/protocol/dataSources/filters/numberFilterOperator.js +11 -0
- package/dist/protocol/dataSources/filters/optionFilterOperator.d.ts +11 -0
- package/dist/protocol/dataSources/filters/optionFilterOperator.js +8 -0
- package/dist/protocol/dataSources/filters/peopleFilterOperator.d.ts +23 -0
- package/dist/protocol/dataSources/filters/peopleFilterOperator.js +11 -0
- package/dist/protocol/dataSources/filters/relationFilterOperator.d.ts +11 -0
- package/dist/protocol/dataSources/filters/relationFilterOperator.js +12 -0
- package/dist/protocol/dataSources/filters/statusFilterOperator.d.ts +15 -0
- package/dist/protocol/dataSources/filters/statusFilterOperator.js +7 -0
- package/dist/protocol/dataSources/filters/statusGroupFilterOperator.d.ts +9 -0
- package/dist/protocol/dataSources/filters/statusGroupFilterOperator.js +18 -0
- package/dist/protocol/dataSources/filters/stringOrStringArray.d.ts +2 -0
- package/dist/protocol/dataSources/filters/stringOrStringArray.js +5 -0
- package/dist/protocol/dataSources/filters/textFilterOperator.d.ts +19 -0
- package/dist/protocol/dataSources/filters/textFilterOperator.js +11 -0
- package/dist/protocol/dataSources/makeBridgeDataSourceBinding.d.ts +6 -0
- package/dist/protocol/dataSources/makeBridgeDataSourceBinding.js +6 -0
- package/dist/protocol/{messages → dataSources/messages}/dataSourcesChanged.d.ts +1 -0
- package/dist/protocol/{messages → dataSources/messages}/dataSourcesChanged.js +2 -2
- package/dist/protocol/{messages/queryDataSourceResult.d.ts → dataSources/messages/queryDataSource.d.ts} +527 -4
- package/dist/protocol/dataSources/messages/queryDataSource.js +64 -0
- package/dist/protocol/dataSources/notionDataSource.d.ts +309 -0
- package/dist/protocol/dataSources/notionDataSource.js +38 -0
- package/dist/protocol/dataSources/resolveDataSourceBinding.d.ts +32 -0
- package/dist/protocol/dataSources/resolveDataSourceBinding.js +33 -0
- package/dist/protocol/{messages → handshake}/connect.d.ts +6 -2
- package/dist/protocol/{messages → handshake}/connect.js +4 -4
- package/dist/protocol/{messages → handshake}/init.d.ts +7 -2
- package/dist/protocol/{messages → handshake}/init.js +10 -10
- package/dist/protocol/{messages → handshake}/initResult.d.ts +1 -1
- package/dist/protocol/{messages → handshake}/isInitHandshakeMessage.d.ts +2 -2
- package/dist/protocol/index.d.ts +150 -53
- package/dist/protocol/index.js +73 -53
- package/dist/protocol/manifest/capabilities.d.ts +37 -0
- package/dist/protocol/manifest/capabilities.js +13 -0
- package/dist/protocol/{manifest.d.ts → manifest/manifest.d.ts} +12 -2
- package/dist/protocol/{manifest.js → manifest/manifest.js} +8 -1
- package/dist/protocol/messages/hostToSandbox.d.ts +15 -3
- package/dist/protocol/messages/hostToSandbox.js +21 -21
- package/dist/protocol/messages/messagePayload.d.ts +1 -1
- package/dist/protocol/messages/sandboxToHost.d.ts +240 -8
- package/dist/protocol/messages/sandboxToHost.js +12 -12
- package/dist/protocol/{messages → navigation}/openExternalUrl.d.ts +1 -1
- package/dist/protocol/{messages/createPage.d.ts → pages/bridgePage.d.ts} +67 -65
- package/dist/protocol/pages/bridgePage.js +25 -0
- package/dist/protocol/pages/makeBridgePage.d.ts +4 -0
- package/dist/protocol/pages/makeBridgePage.js +12 -0
- package/dist/protocol/{messages/createPageResult.d.ts → pages/messages/createPage.d.ts} +502 -4
- package/dist/protocol/pages/messages/createPage.js +104 -0
- package/dist/protocol/{messages → pages/messages}/getPage.d.ts +4 -4
- package/dist/protocol/{messages → pages/messages}/getPage.js +6 -5
- package/dist/protocol/{messages → pages/messages}/openPage.d.ts +2 -2
- package/dist/protocol/{messages → pages/messages}/openPage.js +1 -1
- package/dist/protocol/{messages/updatePageResult.d.ts → pages/messages/updatePage.d.ts} +274 -4
- package/dist/protocol/pages/messages/updatePage.js +65 -0
- package/dist/protocol/pages/pageAppearance.d.ts +62 -0
- package/dist/protocol/pages/pageAppearance.js +34 -0
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +433 -0
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.js +4 -0
- package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +217 -0
- package/dist/protocol/pages/properties/bridgePagePropertyValue.js +144 -0
- package/dist/protocol/pages/properties/dateInput.d.ts +45 -0
- package/dist/protocol/pages/properties/dateInput.js +23 -0
- package/dist/protocol/pages/properties/fileInput.d.ts +16 -0
- package/dist/protocol/pages/properties/fileInput.js +16 -0
- package/dist/protocol/pages/properties/metadataActor.d.ts +6 -0
- package/dist/protocol/pages/properties/metadataActor.js +7 -0
- package/dist/protocol/pages/properties/placeInput.d.ts +10 -0
- package/dist/protocol/pages/properties/placeInput.js +10 -0
- package/dist/protocol/pages/properties/relationInput.d.ts +5 -0
- package/dist/protocol/pages/properties/relationInput.js +2 -0
- package/dist/protocol/pages/properties/richText.d.ts +3 -0
- package/dist/protocol/pages/properties/richText.js +2 -0
- package/dist/protocol/pages/properties/selectOption.d.ts +13 -0
- package/dist/protocol/pages/properties/selectOption.js +16 -0
- package/dist/protocol/pages/properties/userInput.d.ts +10 -0
- package/dist/protocol/pages/properties/userInput.js +13 -0
- package/dist/protocol/users/bridgeUser.d.ts +12 -0
- package/dist/protocol/users/bridgeUser.js +12 -0
- package/dist/protocol/users/{user.d.ts → bridgeUserList.d.ts} +2 -15
- package/dist/protocol/users/bridgeUserList.js +10 -0
- package/dist/protocol/users/makeBridgeUser.d.ts +4 -0
- package/dist/protocol/users/makeBridgeUser.js +11 -0
- package/dist/protocol/{messages → users/messages}/currentUserChanged.js +2 -2
- package/dist/protocol/{messages → users/messages}/getUser.d.ts +2 -2
- package/dist/protocol/{messages → users/messages}/getUser.js +3 -2
- package/dist/protocol/{messages → users/messages}/listUsers.d.ts +2 -2
- package/dist/protocol/{messages → users/messages}/listUsers.js +2 -2
- package/dist/protocol/users/userId.d.ts +3 -0
- package/dist/protocol/users/userId.js +2 -0
- package/dist/protocol/{errors.d.ts → utils/errors.d.ts} +6 -0
- package/dist/protocol/utils/errors.js +11 -0
- package/dist/protocol/utils/isLocalBlockServerUrl.d.ts +2 -0
- package/dist/protocol/utils/isLocalBlockServerUrl.js +9 -0
- package/dist/protocol/utils/nullableStringSchema.d.ts +2 -0
- package/dist/protocol/utils/nullableStringSchema.js +2 -0
- package/dist/protocol/{protocolVersion.d.ts → utils/protocolVersion.d.ts} +2 -2
- package/dist/protocol/{protocolVersion.js → utils/protocolVersion.js} +2 -2
- package/dist/react/DebugMessageLog.d.ts.map +1 -1
- package/dist/react/DebugMessageLog.js +3 -2
- package/dist/react/InitializationErrorDetails.d.ts +7 -0
- package/dist/react/InitializationErrorDetails.d.ts.map +1 -0
- package/dist/react/InitializationErrorDetails.js +9 -0
- package/dist/react/{NotionCustomBlock.css → InitializationErrorScreen.css} +0 -20
- package/dist/react/MissingHostCommand.d.ts +2 -0
- package/dist/react/MissingHostCommand.d.ts.map +1 -0
- package/dist/react/MissingHostCommand.js +20 -0
- package/dist/react/MissingHostScreen.css +85 -0
- package/dist/react/MissingHostScreen.d.ts +7 -0
- package/dist/react/MissingHostScreen.d.ts.map +1 -0
- package/dist/react/MissingHostScreen.js +7 -0
- package/dist/react/NotionCustomBlock.d.ts +2 -2
- package/dist/react/NotionCustomBlock.d.ts.map +1 -1
- package/dist/react/NotionCustomBlock.js +14 -35
- package/dist/react/NotionTokenScope.d.ts.map +1 -1
- package/dist/react/NotionTokenScope.js +2 -1
- package/dist/react/index.d.ts +14 -5
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +11 -5
- package/dist/users/bridge/toNotionUserFromBridgeUser.d.ts +4 -0
- package/dist/users/bridge/toNotionUserFromBridgeUser.d.ts.map +1 -0
- package/dist/users/bridge/toNotionUserFromBridgeUser.js +10 -0
- package/dist/users/getCurrentUser.d.ts +7 -0
- package/dist/users/getCurrentUser.d.ts.map +1 -0
- package/dist/users/getCurrentUser.js +8 -0
- package/dist/users/getUser.d.ts +7 -0
- package/dist/users/getUser.d.ts.map +1 -0
- package/dist/users/getUser.js +11 -0
- package/dist/users/index.d.ts +7 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/users/index.js +6 -0
- package/dist/users/listUsers.d.ts +6 -0
- package/dist/users/listUsers.d.ts.map +1 -0
- package/dist/users/listUsers.js +19 -0
- package/dist/users/react/useCurrentUser.d.ts +12 -0
- package/dist/users/react/useCurrentUser.d.ts.map +1 -0
- package/dist/users/react/useCurrentUser.js +15 -0
- package/dist/users/subscribeToCurrentUser.d.ts +8 -0
- package/dist/users/subscribeToCurrentUser.d.ts.map +1 -0
- package/dist/users/subscribeToCurrentUser.js +8 -0
- package/dist/users/types.d.ts +41 -0
- package/dist/users/types.d.ts.map +1 -0
- package/dist/users/types.js +1 -0
- package/dist/utils/notifyListener.d.ts.map +1 -0
- package/dist/utils/typeUtils.d.ts.map +1 -0
- package/dist/utils/typeUtils.js +1 -0
- package/dist/{utils.d.ts → utils/unreachable.d.ts} +1 -1
- package/dist/utils/unreachable.d.ts.map +1 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/{version.js → utils/version.js} +1 -1
- package/docs/block-location.md +9 -6
- package/docs/bridge-interceptors.md +4 -0
- package/docs/build-tools.md +5 -2
- package/docs/capabilities.md +111 -0
- package/docs/data-sources.md +27 -19
- package/docs/deployment.md +18 -12
- package/docs/errors.md +20 -1
- package/docs/lifecycle.md +16 -9
- package/docs/pages.md +6 -5
- package/docs/users.md +7 -4
- package/package.json +3 -2
- package/src/bridge/SandboxBridge.ts +159 -904
- package/src/bridge/getBridge.ts +10 -0
- package/src/bridge/{SandboxInitialization.ts → initialization/SandboxInitialization.ts} +24 -40
- package/src/bridge.ts +2 -2
- package/src/context/applyContextMessage.ts +55 -0
- package/src/context/backgroundColors.ts +6 -0
- package/src/context/getBlockId.ts +10 -0
- package/src/context/getContrastMode.ts +10 -0
- package/src/context/getInitializedHostState.ts +14 -0
- package/src/context/getPage.ts +10 -0
- package/src/context/getParent.ts +10 -0
- package/src/context/getTheme.ts +10 -0
- package/src/context/hostState.ts +17 -0
- package/src/context/index.ts +42 -0
- package/src/context/react/useBlockId.ts +16 -0
- package/src/context/react/useContrastMode.ts +16 -0
- package/src/context/react/usePage.ts +17 -0
- package/src/context/react/useParent.ts +17 -0
- package/src/context/react/useTheme.ts +16 -0
- package/src/context/subscribeToBlockId.ts +13 -0
- package/src/context/subscribeToContext.ts +42 -0
- package/src/context/subscribeToContrastMode.ts +13 -0
- package/src/context/subscribeToPage.ts +13 -0
- package/src/context/subscribeToParent.ts +13 -0
- package/src/context/subscribeToTheme.ts +13 -0
- package/src/context/syncDocumentAppearance.ts +31 -0
- package/src/dataSources/bridge/applyDataSourceBindings.ts +25 -0
- package/src/dataSources/bridge/resolveDataSourceQuery.ts +243 -0
- package/src/dataSources/bridge/resolveDataSources.ts +44 -0
- package/src/dataSources/bridge/resolveSorts.ts +105 -0
- package/src/dataSources/bridge/reuseDataSourcesForUnchangedBindings.ts +32 -0
- package/src/dataSources/createDataSourcePage.ts +46 -0
- package/src/dataSources/dataSourceInaccessibleError.ts +13 -0
- package/src/dataSources/filters/resolveFilter.ts +179 -0
- package/src/dataSources/filters/types.ts +77 -0
- package/src/dataSources/getDataSourcePage.ts +24 -0
- package/src/dataSources/index.ts +9 -0
- package/src/dataSources/properties/resolvePropertyAddress.ts +62 -0
- package/src/{bridge/dataSources/resolveProperty.ts → dataSources/properties/resolvePropertyWriteMapForDataSource.ts} +5 -5
- package/src/dataSources/queryDataSource.ts +62 -0
- package/src/{react → dataSources/react}/useDataSource.ts +4 -4
- package/src/dataSources/resolvePageDataSource.ts +57 -0
- package/src/dataSources/subscribeToDataSource.ts +143 -0
- package/src/dataSources/types.ts +53 -0
- package/src/index.ts +70 -68
- package/src/initialization/NotInIframeError.ts +23 -0
- package/src/initialization/getInitBindingError.ts +39 -0
- package/src/initialization/initCustomBlock.ts +10 -0
- package/src/{react → initialization/react}/useCustomBlockInit.ts +3 -2
- package/src/initialization/resolveInitialState.ts +37 -0
- package/src/initialization/types.ts +20 -0
- package/src/{autoResize.ts → layout/autoResize.ts} +2 -2
- package/src/layout/getInitialContentHeight.ts +10 -0
- package/src/layout/postResize.ts +15 -0
- package/src/manifest/getManifest.ts +10 -0
- package/src/manifest/react/useManifest.ts +20 -0
- package/src/manifest/readLocalManifest.ts +58 -0
- package/src/manifest/subscribeToManifest.ts +13 -0
- package/src/manifest/types.ts +7 -0
- package/src/navigation/index.ts +5 -0
- package/src/navigation/openExternalUrl.ts +9 -0
- package/src/navigation/types.ts +10 -0
- package/src/pages/bridge/buildCreatePageRequest.ts +49 -0
- package/src/pages/bridge/getPageForDataSource.ts +25 -0
- package/src/pages/bridge/makeUpdatePageByKey.ts +25 -0
- package/src/pages/bridge/resolveCreatePageDestination.ts +75 -0
- package/src/pages/bridge/sendCreatePageRequest.ts +22 -0
- package/src/pages/bridge/toNotionPageFieldsFromBridgePage.ts +28 -0
- package/src/pages/bridge/toNotionPageFromBridgePage.ts +22 -0
- package/src/pages/bridge/toNotionPagePropertyFromBridgeProperty.ts +97 -0
- package/src/pages/bridge/updateNotionPageFromBridgePage.ts +10 -0
- package/src/pages/bridge/updatePage.ts +90 -0
- package/src/pages/createPage.ts +31 -0
- package/src/pages/getPage.ts +14 -0
- package/src/pages/index.ts +9 -0
- package/src/pages/makeNotionPage.ts +55 -0
- package/src/pages/openPage.ts +13 -0
- package/src/pages/parent.ts +14 -0
- package/src/pages/properties/getPropertyById.ts +12 -0
- package/src/pages/properties/getPropertyByKey.ts +30 -0
- package/src/pages/types.ts +189 -0
- package/src/react/DebugMessageLog.tsx +6 -2
- package/src/react/InitializationErrorDetails.tsx +30 -0
- package/src/react/{NotionCustomBlock.css → InitializationErrorScreen.css} +0 -20
- package/src/react/MissingHostCommand.tsx +49 -0
- package/src/react/MissingHostScreen.css +85 -0
- package/src/react/MissingHostScreen.tsx +34 -0
- package/src/react/NotionCustomBlock.tsx +17 -55
- package/src/react/NotionTokenScope.tsx +2 -1
- package/src/react/index.ts +14 -22
- package/src/users/bridge/toNotionUserFromBridgeUser.ts +13 -0
- package/src/users/getCurrentUser.ts +10 -0
- package/src/users/getUser.ts +14 -0
- package/src/users/index.ts +7 -0
- package/src/users/listUsers.ts +23 -0
- package/src/users/react/useCurrentUser.ts +17 -0
- package/src/users/subscribeToCurrentUser.ts +13 -0
- package/src/users/types.ts +36 -0
- package/dist/autoResize.d.ts.map +0 -1
- package/dist/bridge/SandboxInitialization.d.ts.map +0 -1
- package/dist/bridge/appearance.d.ts +0 -15
- package/dist/bridge/appearance.d.ts.map +0 -1
- package/dist/bridge/appearance.js +0 -14
- package/dist/bridge/dataSources/query.d.ts +0 -28
- package/dist/bridge/dataSources/query.d.ts.map +0 -1
- package/dist/bridge/dataSources/query.js +0 -575
- package/dist/bridge/dataSources/resolve.d.ts +0 -14
- package/dist/bridge/dataSources/resolve.d.ts.map +0 -1
- package/dist/bridge/dataSources/resolveProperty.d.ts.map +0 -1
- package/dist/bridge/dataSources/subscribe.d.ts.map +0 -1
- package/dist/bridge/dataSources/subscribe.js +0 -76
- package/dist/bridge/hostState.d.ts +0 -46
- package/dist/bridge/hostState.d.ts.map +0 -1
- package/dist/bridge/hostState.js +0 -32
- package/dist/bridge/loadManifest.d.ts +0 -21
- package/dist/bridge/loadManifest.d.ts.map +0 -1
- package/dist/bridge/loadManifest.js +0 -85
- package/dist/bridge/notifyListener.d.ts.map +0 -1
- package/dist/bridge/page.d.ts +0 -18
- package/dist/bridge/page.d.ts.map +0 -1
- package/dist/bridge/sandboxClient.d.ts +0 -68
- package/dist/bridge/sandboxClient.d.ts.map +0 -1
- package/dist/bridge/sandboxClient.js +0 -135
- package/dist/customBlock.d.ts +0 -97
- package/dist/customBlock.d.ts.map +0 -1
- package/dist/customBlock.js +0 -157
- package/dist/dataSources.d.ts +0 -8
- package/dist/dataSources.d.ts.map +0 -1
- package/dist/dataSources.js +0 -105
- package/dist/init.d.ts.map +0 -1
- package/dist/initTypes.d.ts +0 -31
- package/dist/initTypes.d.ts.map +0 -1
- package/dist/protocol/dataSources/dataSource.d.ts +0 -786
- package/dist/protocol/dataSources/dataSource.js +0 -66
- package/dist/protocol/errors.js +0 -6
- package/dist/protocol/messages/createPage.js +0 -51
- package/dist/protocol/messages/createPageResult.js +0 -43
- package/dist/protocol/messages/queryDataSource.d.ts +0 -1446
- package/dist/protocol/messages/queryDataSource.js +0 -252
- package/dist/protocol/messages/queryDataSourceResult.js +0 -44
- package/dist/protocol/messages/updatePage.js +0 -23
- package/dist/protocol/messages/updatePageResult.js +0 -41
- package/dist/protocol/pages/page.d.ts +0 -1422
- package/dist/protocol/pages/page.js +0 -318
- package/dist/protocol/parent.js +0 -13
- package/dist/protocol/users/user.js +0 -20
- package/dist/react/standalonePreview.d.ts +0 -2
- package/dist/react/standalonePreview.d.ts.map +0 -1
- package/dist/react/standalonePreview.js +0 -36
- package/dist/react/useCustomBlockInit.d.ts.map +0 -1
- package/dist/react/useDataSource.d.ts.map +0 -1
- package/dist/react/useHostState.d.ts +0 -2
- package/dist/react/useHostState.d.ts.map +0 -1
- package/dist/react/useHostState.js +0 -5
- package/dist/react/useRuntimeState.d.ts +0 -78
- package/dist/react/useRuntimeState.d.ts.map +0 -1
- package/dist/react/useRuntimeState.js +0 -86
- package/dist/typeUtils.d.ts.map +0 -1
- package/dist/types.d.ts +0 -204
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/src/bridge/appearance.ts +0 -14
- package/src/bridge/dataSources/query.ts +0 -771
- package/src/bridge/dataSources/resolve.ts +0 -50
- package/src/bridge/dataSources/subscribe.ts +0 -124
- package/src/bridge/hostState.ts +0 -99
- package/src/bridge/loadManifest.ts +0 -114
- package/src/bridge/page.ts +0 -47
- package/src/bridge/sandboxClient.ts +0 -203
- package/src/customBlock.ts +0 -193
- package/src/dataSources.ts +0 -136
- package/src/init.ts +0 -15
- package/src/initTypes.ts +0 -43
- package/src/react/standalonePreview.ts +0 -41
- package/src/react/useHostState.ts +0 -9
- package/src/react/useRuntimeState.ts +0 -118
- package/src/types.ts +0 -284
- /package/dist/{typeUtils.js → context/hostState.js} +0 -0
- /package/dist/{types.js → dataSources/filters/types.js} +0 -0
- /package/dist/{autoResize.d.ts → layout/autoResize.d.ts} +0 -0
- /package/dist/protocol/{dataSources → compatibility/protocol3To5}/dataSourceValue.d.ts +0 -0
- /package/dist/protocol/{contrast.d.ts → context/contrast.d.ts} +0 -0
- /package/dist/protocol/{contrast.js → context/contrast.js} +0 -0
- /package/dist/protocol/{messages → context/messages}/contrastModeChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/contrastModeChanged.js +0 -0
- /package/dist/protocol/{messages → context/messages}/pageChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/parentChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/parentChanged.js +0 -0
- /package/dist/protocol/{messages → context/messages}/resize.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/resize.js +0 -0
- /package/dist/protocol/{messages → context/messages}/themeChanged.d.ts +0 -0
- /package/dist/protocol/{messages → context/messages}/themeChanged.js +0 -0
- /package/dist/protocol/{theme.d.ts → context/theme.d.ts} +0 -0
- /package/dist/protocol/{theme.js → context/theme.js} +0 -0
- /package/dist/protocol/{messages → dataSources/messages}/unsubscribeDataSourceQuery.d.ts +0 -0
- /package/dist/protocol/{messages → dataSources/messages}/unsubscribeDataSourceQuery.js +0 -0
- /package/dist/protocol/dataSources/{dateValue.d.ts → properties/dateValue.d.ts} +0 -0
- /package/dist/protocol/dataSources/{dateValue.js → properties/dateValue.js} +0 -0
- /package/dist/protocol/dataSources/{propertySchema.d.ts → properties/propertySchema.d.ts} +0 -0
- /package/dist/protocol/dataSources/{propertySchema.js → properties/propertySchema.js} +0 -0
- /package/dist/protocol/{messages → handshake}/initResult.js +0 -0
- /package/dist/protocol/{messages → handshake}/isInitHandshakeMessage.js +0 -0
- /package/dist/protocol/{messages → navigation}/openExternalUrl.js +0 -0
- /package/dist/protocol/{messages → users/messages}/currentUserChanged.d.ts +0 -0
- /package/dist/protocol/{ids.d.ts → utils/ids.d.ts} +0 -0
- /package/dist/protocol/{ids.js → utils/ids.js} +0 -0
- /package/dist/protocol/{dataSources → utils}/recordPointer.d.ts +0 -0
- /package/dist/protocol/{dataSources → utils}/recordPointer.js +0 -0
- /package/dist/{bridge → utils}/notifyListener.d.ts +0 -0
- /package/dist/{bridge → utils}/notifyListener.js +0 -0
- /package/dist/{typeUtils.d.ts → utils/typeUtils.d.ts} +0 -0
- /package/dist/{utils.js → utils/unreachable.js} +0 -0
- /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
- /package/src/{bridge → utils}/notifyListener.ts +0 -0
- /package/src/{typeUtils.ts → utils/typeUtils.ts} +0 -0
- /package/src/{utils.ts → utils/unreachable.ts} +0 -0
- /package/src/{version.ts → utils/version.ts} +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { NotionContrastMode } from "../protocol/contrast.js";
|
|
2
|
-
import type { NotionDataSource } from "../protocol/dataSources/dataSource.js";
|
|
3
|
-
import type { NotionBlockId } from "../protocol/ids.js";
|
|
4
|
-
import type { CustomBlockManifest } from "../protocol/manifest.js";
|
|
5
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "../protocol/messages/queryDataSourceResult.js";
|
|
6
|
-
import type { CustomBlockPage, notionPageDataSchema } from "../protocol/pages/page.js";
|
|
7
|
-
import type { NotionParent } from "../protocol/parent.js";
|
|
8
|
-
import type { NotionTheme } from "../protocol/theme.js";
|
|
9
|
-
import type { NotionUser } from "../protocol/users/user.js";
|
|
10
|
-
import type { InferOutput } from "valibot";
|
|
11
|
-
import type { DataSourceSnapshot, NotionPage } from "../types.js";
|
|
12
|
-
export type CustomBlockHostState = UninitializedHostState | InitializedHostState;
|
|
13
|
-
export type UninitializedHostState = {
|
|
14
|
-
status: "uninitialized";
|
|
15
|
-
theme: NotionTheme;
|
|
16
|
-
contrastMode: NotionContrastMode;
|
|
17
|
-
};
|
|
18
|
-
export type InitializedHostState = {
|
|
19
|
-
status: "initialized";
|
|
20
|
-
theme: NotionTheme;
|
|
21
|
-
contrastMode: NotionContrastMode;
|
|
22
|
-
blockId: NotionBlockId;
|
|
23
|
-
parent: NotionParent;
|
|
24
|
-
page: CustomBlockPage;
|
|
25
|
-
currentUser: NotionUser;
|
|
26
|
-
manifest: CustomBlockManifest;
|
|
27
|
-
dataSources: NotionDataSource[];
|
|
28
|
-
dataSourceState: Record<string, DataSourceQueryState>;
|
|
29
|
-
};
|
|
30
|
-
export type DataSourceQueryState = {
|
|
31
|
-
dataSourceKey: string;
|
|
32
|
-
/** Latest pages from the host as parsed from the bridge. */
|
|
33
|
-
items: InferOutput<typeof notionPageDataSchema>[];
|
|
34
|
-
isLoading: boolean;
|
|
35
|
-
hasMore: boolean;
|
|
36
|
-
error?: CustomBlockQueryDataSourceErrorInfo;
|
|
37
|
-
latestLimit?: number;
|
|
38
|
-
latestQueryIdentity?: string;
|
|
39
|
-
};
|
|
40
|
-
export declare function createEmptyDataSourceQueryState(dataSourceKey: string): DataSourceQueryState;
|
|
41
|
-
export type DataSourceQueryView = DataSourceSnapshot;
|
|
42
|
-
export declare function getDataSourceQueryView(hostState: CustomBlockHostState, key: string, subscriptionId: string, createNotionPage: (args: {
|
|
43
|
-
page: InferOutput<typeof notionPageDataSchema>;
|
|
44
|
-
dataSource: NotionDataSource | undefined;
|
|
45
|
-
}) => NotionPage): DataSourceQueryView;
|
|
46
|
-
//# sourceMappingURL=hostState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../src/bridge/hostState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAC7H,OAAO,KAAK,EACX,eAAe,EACf,oBAAoB,EACpB,MAAM,gDAAgD,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEjE,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,GAAG,oBAAoB,CAAA;AAEhF,MAAM,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,WAAW,CAAA;IAClB,YAAY,EAAE,kBAAkB,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,aAAa,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,YAAY,EAAE,kBAAkB,CAAA;IAChC,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAClC,aAAa,EAAE,MAAM,CAAA;IACrB,4DAA4D;IAC5D,KAAK,EAAE,WAAW,CAAC,OAAO,oBAAoB,CAAC,EAAE,CAAA;IACjD,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,mCAAmC,CAAA;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED,wBAAgB,+BAA+B,CAC9C,aAAa,EAAE,MAAM,GACnB,oBAAoB,CAOtB;AAED,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AASpD,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,CAAC,IAAI,EAAE;IACxB,IAAI,EAAE,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAA;IAC9C,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAA;CACxC,KAAK,UAAU,GACd,mBAAmB,CAuBrB"}
|
package/dist/bridge/hostState.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export function createEmptyDataSourceQueryState(dataSourceKey) {
|
|
2
|
-
return {
|
|
3
|
-
dataSourceKey,
|
|
4
|
-
items: [],
|
|
5
|
-
isLoading: false,
|
|
6
|
-
hasMore: false,
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
const EMPTY_QUERY_VIEW = {
|
|
10
|
-
items: [],
|
|
11
|
-
propertyIdsByKey: {},
|
|
12
|
-
isLoading: false,
|
|
13
|
-
hasMore: false,
|
|
14
|
-
};
|
|
15
|
-
export function getDataSourceQueryView(hostState, key, subscriptionId, createNotionPage) {
|
|
16
|
-
if (hostState.status !== "initialized") {
|
|
17
|
-
return EMPTY_QUERY_VIEW;
|
|
18
|
-
}
|
|
19
|
-
const dataSource = hostState.dataSources.find(entry => entry.key === key);
|
|
20
|
-
const subscriptionState = hostState.dataSourceState[subscriptionId];
|
|
21
|
-
const queryState = subscriptionState?.dataSourceKey === key
|
|
22
|
-
? subscriptionState
|
|
23
|
-
: createEmptyDataSourceQueryState(key);
|
|
24
|
-
return {
|
|
25
|
-
items: dataSource === undefined
|
|
26
|
-
? []
|
|
27
|
-
: queryState.items.map(entry => createNotionPage({ page: entry, dataSource })),
|
|
28
|
-
propertyIdsByKey: dataSource?.propertyIdsByKey ?? {},
|
|
29
|
-
isLoading: queryState.isLoading,
|
|
30
|
-
hasMore: queryState.hasMore,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { CustomBlockErrorInfo } from "../protocol/errors.js";
|
|
2
|
-
import { type CustomBlockManifest } from "../protocol/manifest.js";
|
|
3
|
-
type CustomBlockConnectErrorCode = "manifest_unavailable" | "manifest_invalid" | (string & {});
|
|
4
|
-
type CustomBlockConnectError = CustomBlockErrorInfo<CustomBlockConnectErrorCode>;
|
|
5
|
-
export type ManifestLoadResult = {
|
|
6
|
-
manifest: CustomBlockManifest | null;
|
|
7
|
-
error?: undefined;
|
|
8
|
-
} | {
|
|
9
|
-
manifest: null;
|
|
10
|
-
error: CustomBlockConnectError;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* On the literal `localhost` hostname, attempts to load the custom block's optional self-hosted
|
|
14
|
-
* manifest exposed by the worker dev shell, requested at the page-relative `manifest` path so
|
|
15
|
-
* blocks served from a subpath resolve it against their own base.
|
|
16
|
-
*
|
|
17
|
-
* It is up to the host to decide whether to use this manifest or provide its own persisted manifest.
|
|
18
|
-
*/
|
|
19
|
-
export declare function attemptToLoadSelfHostedManifest(hostname?: string | undefined): Promise<ManifestLoadResult>;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=loadManifest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadManifest.d.ts","sourceRoot":"","sources":["../../src/bridge/loadManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,8CAA8C,CAAA;AAKrD,KAAK,2BAA2B,GAC7B,sBAAsB,GACtB,kBAAkB,GAClB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhB,KAAK,uBAAuB,GAAG,oBAAoB,CAAC,2BAA2B,CAAC,CAAA;AAEhF,MAAM,MAAM,kBAAkB,GAC3B;IACA,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,EAAE,SAAS,CAAA;CAChB,GACD;IACA,QAAQ,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,uBAAuB,CAAA;CAC7B,CAAA;AAEJ;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CACpD,QAAQ,GAAE,MAAM,GAAG,SAEQ,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAgE7B"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { manifestSchema, } from "../protocol/manifest.js";
|
|
2
|
-
import * as v from "valibot";
|
|
3
|
-
const MANIFEST_URL = "manifest";
|
|
4
|
-
/**
|
|
5
|
-
* On the literal `localhost` hostname, attempts to load the custom block's optional self-hosted
|
|
6
|
-
* manifest exposed by the worker dev shell, requested at the page-relative `manifest` path so
|
|
7
|
-
* blocks served from a subpath resolve it against their own base.
|
|
8
|
-
*
|
|
9
|
-
* It is up to the host to decide whether to use this manifest or provide its own persisted manifest.
|
|
10
|
-
*/
|
|
11
|
-
export async function attemptToLoadSelfHostedManifest(hostname = typeof window === "undefined"
|
|
12
|
-
? undefined
|
|
13
|
-
: window.location.hostname) {
|
|
14
|
-
// Runtime manifests are a localhost-only development fallback. Deployed
|
|
15
|
-
// blocks receive their authoritative manifest from the host during init.
|
|
16
|
-
if (hostname !== "localhost") {
|
|
17
|
-
return { manifest: null };
|
|
18
|
-
}
|
|
19
|
-
let response;
|
|
20
|
-
try {
|
|
21
|
-
response = await fetch(MANIFEST_URL, { credentials: "omit" });
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
const message = `Could not fetch ${MANIFEST_URL}.`;
|
|
25
|
-
console.warn(`[custom-blocks-sdk] ${message}`, error);
|
|
26
|
-
return {
|
|
27
|
-
manifest: null,
|
|
28
|
-
// Consider this retryable because it may have just been a network issue. Because `init`
|
|
29
|
-
// errors are considered terminal, the host should "retry" by reloading the iframe and
|
|
30
|
-
// sending another `connect` message.
|
|
31
|
-
error: { code: "manifest_unavailable", message, isRetryable: true },
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
if (response.status === 404) {
|
|
35
|
-
const message = `No manifest found at ${MANIFEST_URL} (status ${response.status}).`;
|
|
36
|
-
console.warn(`[custom-blocks-sdk] ${message}`);
|
|
37
|
-
return { manifest: null };
|
|
38
|
-
}
|
|
39
|
-
if (!response.ok) {
|
|
40
|
-
const message = `Could not fetch ${MANIFEST_URL} (status ${response.status}).`;
|
|
41
|
-
console.warn(`[custom-blocks-sdk] ${message}`);
|
|
42
|
-
return {
|
|
43
|
-
manifest: null,
|
|
44
|
-
error: {
|
|
45
|
-
code: "manifest_unavailable",
|
|
46
|
-
message,
|
|
47
|
-
isRetryable: isRetryableManifestHttpStatus(response.status),
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
let json;
|
|
52
|
-
try {
|
|
53
|
-
json = await response.json();
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
const message = `Manifest at ${MANIFEST_URL} was not valid JSON.`;
|
|
57
|
-
console.warn(`[custom-blocks-sdk] ${message}`, error);
|
|
58
|
-
return {
|
|
59
|
-
manifest: null,
|
|
60
|
-
// Consider invalid manifests as unrecoverable errors.
|
|
61
|
-
error: { code: "manifest_invalid", message, isRetryable: false },
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const parsed = v.safeParse(manifestSchema, json);
|
|
65
|
-
if (!parsed.success) {
|
|
66
|
-
const message = `Manifest at ${MANIFEST_URL} did not match schema.`;
|
|
67
|
-
console.warn(`[custom-blocks-sdk] ${message}`, parsed.issues);
|
|
68
|
-
return {
|
|
69
|
-
manifest: null,
|
|
70
|
-
// Consider invalid manifests as unrecoverable errors.
|
|
71
|
-
error: { code: "manifest_invalid", message, isRetryable: false },
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return { manifest: parsed.output };
|
|
75
|
-
}
|
|
76
|
-
function isRetryableManifestHttpStatus(status) {
|
|
77
|
-
// Consider these statuses retryable because they may reflect transient failures.
|
|
78
|
-
return (status === 408 || // Request Timeout
|
|
79
|
-
status === 425 || // Too Early
|
|
80
|
-
status === 500 || // Internal Server Error
|
|
81
|
-
status === 502 || // Bad Gateway
|
|
82
|
-
status === 503 || // Service Unavailable
|
|
83
|
-
status === 504 // Gateway Timeout
|
|
84
|
-
);
|
|
85
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notifyListener.d.ts","sourceRoot":"","sources":["../../src/bridge/notifyListener.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAYzD"}
|
package/dist/bridge/page.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { NotionDataSource } from "../protocol/dataSources/dataSource.js";
|
|
2
|
-
import type { notionPageDataSchema } from "../protocol/pages/page.js";
|
|
3
|
-
import type { InferOutput } from "valibot";
|
|
4
|
-
import type { NotionPage } from "../types.js";
|
|
5
|
-
export declare function toNotionPageFromNotionPageData(args: {
|
|
6
|
-
page: InferOutput<typeof notionPageDataSchema>;
|
|
7
|
-
dataSourceKey: string | undefined;
|
|
8
|
-
getPropertyById: NotionPage["getPropertyById"];
|
|
9
|
-
getPropertyByKey: NotionPage["getPropertyByKey"];
|
|
10
|
-
updateById: NotionPage["updateById"];
|
|
11
|
-
updateByKey: NotionPage["updateByKey"];
|
|
12
|
-
}): NotionPage;
|
|
13
|
-
/** Prevents key-based property updates from falling back to raw IDs without data source context. */
|
|
14
|
-
export declare function makeUpdatePageByKey(args: {
|
|
15
|
-
dataSource: NotionDataSource | undefined;
|
|
16
|
-
update: NotionPage["updateByKey"];
|
|
17
|
-
}): NotionPage["updateByKey"];
|
|
18
|
-
//# sourceMappingURL=page.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/bridge/page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,wBAAgB,8BAA8B,CAAC,IAAI,EAAE;IACpD,IAAI,EAAE,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAA;IAC9C,aAAa,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,eAAe,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC9C,gBAAgB,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAA;IAChD,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAA;IACpC,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;CACtC,GAAG,UAAU,CAWb;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACzC,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACxC,MAAM,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;CACjC,GAAG,UAAU,CAAC,aAAa,CAAC,CAiB5B"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { NotionPageId } from "../protocol/ids.js";
|
|
2
|
-
import type { InitMessage } from "../protocol/messages/init.js";
|
|
3
|
-
import type { CreatePageArgs, CreatePageResult, GetPageResult, GetUserResult, ListUsersArgs, ListUsersResult, NotionUserId, OpenExternalUrlResult, OpenPageOptions, OpenPageResult } from "../types.js";
|
|
4
|
-
import { type CustomBlockHostState, type DataSourceQueryView } from "./hostState.js";
|
|
5
|
-
import type { ManifestLoadResult } from "./loadManifest.js";
|
|
6
|
-
import type { MessageInterceptor } from "./messageInterceptor.js";
|
|
7
|
-
import { type MessageLogEntry, type QueryDataSourceArgs, SandboxBridge } from "./SandboxBridge.js";
|
|
8
|
-
export declare function getBridge(): SandboxBridge;
|
|
9
|
-
export declare const customBlockHost: {
|
|
10
|
-
registerMessageInterceptor: (interceptor: MessageInterceptor) => (() => void);
|
|
11
|
-
sendConnect: (manifestResult: ManifestLoadResult) => void;
|
|
12
|
-
initialize: () => Promise<import("../initTypes.js").CustomBlockInitPayload>;
|
|
13
|
-
subscribe: (listener: () => void) => () => boolean;
|
|
14
|
-
getState: () => CustomBlockHostState;
|
|
15
|
-
/**
|
|
16
|
-
* Apply an `init` payload directly, bypassing the postMessage handshake for
|
|
17
|
-
* standalone preview state.
|
|
18
|
-
*/
|
|
19
|
-
setMockState: (message: InitMessage) => void;
|
|
20
|
-
completeInitialization: () => void;
|
|
21
|
-
postResize: (height: number) => void;
|
|
22
|
-
};
|
|
23
|
-
export declare const customBlockDataSources: {
|
|
24
|
-
createSubscriptionId: () => string;
|
|
25
|
-
query: (args: QueryDataSourceArgs) => void;
|
|
26
|
-
release: (subscriptionId: string) => void;
|
|
27
|
-
getView: (hostState: CustomBlockHostState, key: string, subscriptionId: string) => DataSourceQueryView;
|
|
28
|
-
};
|
|
29
|
-
export declare const messageLog: {
|
|
30
|
-
getSnapshot: () => readonly MessageLogEntry[];
|
|
31
|
-
subscribe: (listener: () => void) => () => boolean;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Page-related SDK APIs exposed under `sdk.pages.*`.
|
|
35
|
-
*/
|
|
36
|
-
export declare const pages: {
|
|
37
|
-
/**
|
|
38
|
-
* Creates a new Notion page.
|
|
39
|
-
*/
|
|
40
|
-
create: (input: CreatePageArgs) => Promise<CreatePageResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Fetches a page by id.
|
|
43
|
-
*/
|
|
44
|
-
get: (pageId: NotionPageId) => Promise<GetPageResult>;
|
|
45
|
-
/**
|
|
46
|
-
* Requests that the Notion host open a page.
|
|
47
|
-
*/
|
|
48
|
-
open: (pageId: NotionPageId, options: OpenPageOptions) => Promise<OpenPageResult>;
|
|
49
|
-
};
|
|
50
|
-
/** External-link APIs exposed under `sdk.links.*`. */
|
|
51
|
-
export declare const links: {
|
|
52
|
-
/** Requests host-owned approval before opening an HTTPS URL. */
|
|
53
|
-
open: (url: string) => Promise<OpenExternalUrlResult>;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* User-related SDK APIs exposed under `sdk.users.*`.
|
|
57
|
-
*/
|
|
58
|
-
export declare const users: {
|
|
59
|
-
/**
|
|
60
|
-
* Lists users visible in the current custom block workspace.
|
|
61
|
-
*/
|
|
62
|
-
list: (input?: ListUsersArgs) => Promise<ListUsersResult>;
|
|
63
|
-
/**
|
|
64
|
-
* Fetches a user by id.
|
|
65
|
-
*/
|
|
66
|
-
get: (userId: NotionUserId) => Promise<GetUserResult>;
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=sandboxClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAA;AACpF,OAAO,KAAK,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EAEf,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,cAAc,EAEd,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,aAAa,EACb,MAAM,oBAAoB,CAAA;AAI3B,wBAAgB,SAAS,IAAI,aAAa,CAKzC;AAED,eAAO,MAAM,eAAe;IAC3B,0BAA0B,gBACZ,kBAAkB,KAC7B,CAAC,MAAM,IAAI,CAAC;IAIf,WAAW,mBAAmB,kBAAkB;IAIhD,UAAU;IAEV,SAAS,aAAa,MAAM,IAAI;IAIhC,QAAQ,QAAM,oBAAoB;IAIlC;;;OAGG;IACH,YAAY,YAAY,WAAW;IAInC,sBAAsB;IAItB,UAAU,WAAW,MAAM;CAG3B,CAAA;AAED,eAAO,MAAM,sBAAsB;IAClC,oBAAoB;IAIpB,KAAK,SAAS,mBAAmB;IAIjC,OAAO,mBAAmB,MAAM;IAIhC,OAAO,cACK,oBAAoB,OAC1B,MAAM,kBACK,MAAM,KACpB,mBAAmB;CAoCtB,CAAA;AAED,eAAO,MAAM,UAAU;IACtB,WAAW,QAAM,SAAS,eAAe,EAAE;IAI3C,SAAS,aAAa,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;IACH,MAAM,UAAU,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAO1D;;OAEG;IACH,GAAG,WAAW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAOnD;;OAEG;IACH,IAAI,WACK,YAAY,WACX,eAAe,KACtB,OAAO,CAAC,cAAc,CAAC;CAG1B,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,KAAK;IACjB,gEAAgE;IAChE,IAAI,QAAQ,MAAM,KAAG,OAAO,CAAC,qBAAqB,CAAC;CAGnD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;IACH,IAAI,WAAW,aAAa,KAAG,OAAO,CAAC,eAAe,CAAC;IAIvD;;OAEG;IACH,GAAG,WAAW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { getDataSourceQueryView as getDataSourceQueryViewWithBridge, } from "./hostState.js";
|
|
2
|
-
import { makeUpdatePageByKey, toNotionPageFromNotionPageData } from "./page.js";
|
|
3
|
-
import { SandboxBridge, } from "./SandboxBridge.js";
|
|
4
|
-
let bridge;
|
|
5
|
-
export function getBridge() {
|
|
6
|
-
if (!bridge) {
|
|
7
|
-
bridge = new SandboxBridge();
|
|
8
|
-
}
|
|
9
|
-
return bridge;
|
|
10
|
-
}
|
|
11
|
-
export const customBlockHost = {
|
|
12
|
-
registerMessageInterceptor: (interceptor) => {
|
|
13
|
-
return getBridge().registerMessageInterceptor(interceptor);
|
|
14
|
-
},
|
|
15
|
-
sendConnect: (manifestResult) => {
|
|
16
|
-
getBridge().sendConnect(manifestResult);
|
|
17
|
-
},
|
|
18
|
-
initialize: () => getBridge().initialize(),
|
|
19
|
-
subscribe: (listener) => {
|
|
20
|
-
return getBridge().subscribe(listener);
|
|
21
|
-
},
|
|
22
|
-
getState: () => {
|
|
23
|
-
return getBridge().getHostState();
|
|
24
|
-
},
|
|
25
|
-
/**
|
|
26
|
-
* Apply an `init` payload directly, bypassing the postMessage handshake for
|
|
27
|
-
* standalone preview state.
|
|
28
|
-
*/
|
|
29
|
-
setMockState: (message) => {
|
|
30
|
-
getBridge().setMockState(message);
|
|
31
|
-
},
|
|
32
|
-
completeInitialization: () => {
|
|
33
|
-
getBridge().completeInitialization();
|
|
34
|
-
},
|
|
35
|
-
postResize: (height) => {
|
|
36
|
-
getBridge().postResize(height);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
export const customBlockDataSources = {
|
|
40
|
-
createSubscriptionId: () => {
|
|
41
|
-
return getBridge().createDataSourceSubscriptionId();
|
|
42
|
-
},
|
|
43
|
-
query: (args) => {
|
|
44
|
-
getBridge().queryDataSource(args);
|
|
45
|
-
},
|
|
46
|
-
release: (subscriptionId) => {
|
|
47
|
-
getBridge().releaseDataSourceSubscription(subscriptionId);
|
|
48
|
-
},
|
|
49
|
-
getView: (hostState, key, subscriptionId) => {
|
|
50
|
-
return getDataSourceQueryViewWithBridge(hostState, key, subscriptionId, ({ page: pageData, dataSource }) => {
|
|
51
|
-
const bridge = getBridge();
|
|
52
|
-
const update = async (args) => {
|
|
53
|
-
const result = await bridge.updatePage(args);
|
|
54
|
-
if (result.status === "error") {
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
Object.assign(page, result.page);
|
|
58
|
-
return { status: "success", page };
|
|
59
|
-
};
|
|
60
|
-
const page = toNotionPageFromNotionPageData({
|
|
61
|
-
page: pageData,
|
|
62
|
-
dataSourceKey: key,
|
|
63
|
-
getPropertyById: propertyId => bridge.getPropertyById({ page, propertyId }),
|
|
64
|
-
getPropertyByKey: propertyKey => bridge.getPropertyByKey({ page, dataSource, propertyKey }),
|
|
65
|
-
updateById: payload => update({ ...payload, pageId: page.id, dataSource: undefined }),
|
|
66
|
-
updateByKey: makeUpdatePageByKey({
|
|
67
|
-
dataSource,
|
|
68
|
-
update: payload => update({ ...payload, pageId: page.id, dataSource }),
|
|
69
|
-
}),
|
|
70
|
-
});
|
|
71
|
-
return page;
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
export const messageLog = {
|
|
76
|
-
getSnapshot: () => {
|
|
77
|
-
return getBridge().getMessageLog();
|
|
78
|
-
},
|
|
79
|
-
subscribe: (listener) => {
|
|
80
|
-
return getBridge().subscribeToMessageLog(listener);
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Page-related SDK APIs exposed under `sdk.pages.*`.
|
|
85
|
-
*/
|
|
86
|
-
export const pages = {
|
|
87
|
-
/**
|
|
88
|
-
* Creates a new Notion page.
|
|
89
|
-
*/
|
|
90
|
-
create: (input) => {
|
|
91
|
-
return getBridge().createPage({
|
|
92
|
-
...input,
|
|
93
|
-
dataSource: undefined,
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
/**
|
|
97
|
-
* Fetches a page by id.
|
|
98
|
-
*/
|
|
99
|
-
get: (pageId) => {
|
|
100
|
-
return getBridge().getPage({
|
|
101
|
-
pageId,
|
|
102
|
-
dataSource: undefined,
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* Requests that the Notion host open a page.
|
|
107
|
-
*/
|
|
108
|
-
open: (pageId, options) => {
|
|
109
|
-
return getBridge().openPage(pageId, options);
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
/** External-link APIs exposed under `sdk.links.*`. */
|
|
113
|
-
export const links = {
|
|
114
|
-
/** Requests host-owned approval before opening an HTTPS URL. */
|
|
115
|
-
open: (url) => {
|
|
116
|
-
return getBridge().openExternalUrl(url);
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* User-related SDK APIs exposed under `sdk.users.*`.
|
|
121
|
-
*/
|
|
122
|
-
export const users = {
|
|
123
|
-
/**
|
|
124
|
-
* Lists users visible in the current custom block workspace.
|
|
125
|
-
*/
|
|
126
|
-
list: (input) => {
|
|
127
|
-
return getBridge().listUsers(input);
|
|
128
|
-
},
|
|
129
|
-
/**
|
|
130
|
-
* Fetches a user by id.
|
|
131
|
-
*/
|
|
132
|
-
get: (userId) => {
|
|
133
|
-
return getBridge().getUser(userId);
|
|
134
|
-
},
|
|
135
|
-
};
|
package/dist/customBlock.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import type { NotionContrastMode } from "./protocol/contrast.js";
|
|
2
|
-
import type { NotionBlockId } from "./protocol/ids.js";
|
|
3
|
-
import type { CustomBlockManifest } from "./protocol/manifest.js";
|
|
4
|
-
import type { CustomBlockPage } from "./protocol/pages/page.js";
|
|
5
|
-
import type { NotionParent } from "./protocol/parent.js";
|
|
6
|
-
import type { NotionTheme } from "./protocol/theme.js";
|
|
7
|
-
import type { NotionUser } from "./protocol/users/user.js";
|
|
8
|
-
import { subscribeToDataSource } from "./bridge/dataSources/subscribe.js";
|
|
9
|
-
type Unsubscribe = () => void;
|
|
10
|
-
/**
|
|
11
|
-
* Read block and app context with getters, or follow changes with subscriptions.
|
|
12
|
-
* Getters throw if called before `initCustomBlock()` completes. Subscriptions
|
|
13
|
-
* can be registered before initialization and deliver the initial value once
|
|
14
|
-
* initialization completes, followed by changes to that value.
|
|
15
|
-
*
|
|
16
|
-
* Each subscription returns an unsubscribe function. Call it when the
|
|
17
|
-
* subscription is no longer needed.
|
|
18
|
-
*/
|
|
19
|
-
export declare const customBlock: {
|
|
20
|
-
/**
|
|
21
|
-
* Get the current user viewing the block.
|
|
22
|
-
* Throws if called before SDK initialization completes.
|
|
23
|
-
*/
|
|
24
|
-
getCurrentUser(): NotionUser;
|
|
25
|
-
/**
|
|
26
|
-
* Subscribes to the current `currentUser` and future changes.
|
|
27
|
-
* Waits for initialization before delivering the initial value.
|
|
28
|
-
*/
|
|
29
|
-
subscribeToCurrentUser(listener: (value: NotionUser) => void): Unsubscribe;
|
|
30
|
-
/**
|
|
31
|
-
* Get the host's current theme.
|
|
32
|
-
* Throws if called before SDK initialization completes.
|
|
33
|
-
*/
|
|
34
|
-
getTheme(): NotionTheme;
|
|
35
|
-
/**
|
|
36
|
-
* Subscribes to the current `theme` and future changes.
|
|
37
|
-
* Waits for initialization before delivering the initial value.
|
|
38
|
-
*/
|
|
39
|
-
subscribeToTheme(listener: (value: NotionTheme) => void): Unsubscribe;
|
|
40
|
-
/**
|
|
41
|
-
* Get the host's current contrast mode.
|
|
42
|
-
* Throws if called before SDK initialization completes.
|
|
43
|
-
*/
|
|
44
|
-
getContrastMode(): NotionContrastMode;
|
|
45
|
-
/**
|
|
46
|
-
* Subscribes to the current `contrastMode` and future changes.
|
|
47
|
-
* Waits for initialization before delivering the initial value.
|
|
48
|
-
*/
|
|
49
|
-
subscribeToContrastMode(listener: (value: NotionContrastMode) => void): Unsubscribe;
|
|
50
|
-
/**
|
|
51
|
-
* Get the custom block's ID. The ID is stable for the lifetime of the block.
|
|
52
|
-
* Throws if called before SDK initialization completes.
|
|
53
|
-
*/
|
|
54
|
-
getBlockId(): NotionBlockId;
|
|
55
|
-
/**
|
|
56
|
-
* Delivers the block ID once. The ID is stable for the lifetime of the block.
|
|
57
|
-
* Waits for initialization before delivering the initial value.
|
|
58
|
-
*/
|
|
59
|
-
subscribeToBlockId(listener: (value: NotionBlockId) => void): Unsubscribe;
|
|
60
|
-
/**
|
|
61
|
-
* Get the custom block's parent.
|
|
62
|
-
* Throws if called before SDK initialization completes.
|
|
63
|
-
*/
|
|
64
|
-
getParent(): NotionParent;
|
|
65
|
-
/**
|
|
66
|
-
* Subscribes to the current `parent` and future changes.
|
|
67
|
-
* Waits for initialization before delivering the initial value.
|
|
68
|
-
*/
|
|
69
|
-
subscribeToParent(listener: (value: NotionParent) => void): Unsubscribe;
|
|
70
|
-
/**
|
|
71
|
-
* Get the containing page and its parent.
|
|
72
|
-
* Throws if called before SDK initialization completes.
|
|
73
|
-
*/
|
|
74
|
-
getPage(): CustomBlockPage;
|
|
75
|
-
/**
|
|
76
|
-
* Subscribes to the current `page` and future changes.
|
|
77
|
-
* Waits for initialization before delivering the initial value.
|
|
78
|
-
*/
|
|
79
|
-
subscribeToPage(listener: (value: CustomBlockPage) => void): Unsubscribe;
|
|
80
|
-
/**
|
|
81
|
-
* Get the block's declared data source manifest.
|
|
82
|
-
* Throws if called before SDK initialization completes.
|
|
83
|
-
*/
|
|
84
|
-
getManifest(): CustomBlockManifest;
|
|
85
|
-
/**
|
|
86
|
-
* Subscribes to the current `manifest` and future changes.
|
|
87
|
-
* Waits for initialization before delivering the initial value.
|
|
88
|
-
*/
|
|
89
|
-
subscribeToManifest(listener: (value: CustomBlockManifest) => void): Unsubscribe;
|
|
90
|
-
/**
|
|
91
|
-
* Registers a listener that receives the current query snapshot and later updates.
|
|
92
|
-
* Returns a function that removes this listener. Other listeners remain subscribed.
|
|
93
|
-
*/
|
|
94
|
-
subscribeToDataSource: typeof subscribeToDataSource;
|
|
95
|
-
};
|
|
96
|
-
export {};
|
|
97
|
-
//# sourceMappingURL=customBlock.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customBlock.d.ts","sourceRoot":"","sources":["../src/customBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAKzE,KAAK,WAAW,GAAG,MAAM,IAAI,CAAA;AAE7B;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW;IACvB;;;OAGG;sBACe,UAAU;IAI5B;;;OAGG;qCAC8B,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,WAAW;IAI1E;;;OAGG;gBACS,WAAW;IAIvB;;;OAGG;+BACwB,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,WAAW;IAIrE;;;OAGG;uBACgB,kBAAkB;IAIrC;;;OAGG;sCAEQ,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAC3C,WAAW;IAId;;;OAGG;kBACW,aAAa;IAI3B;;;OAGG;iCAC0B,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,WAAW;IAIzE;;;OAGG;iBACU,YAAY;IAIzB;;;OAGG;gCACyB,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,WAAW;IAIvE;;;OAGG;eACQ,eAAe;IAI1B;;;OAGG;8BACuB,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,WAAW;IAIxE;;;OAGG;mBACY,mBAAmB;IAIlC;;;OAGG;kCAEQ,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAC5C,WAAW;IAId;;;OAGG;;CAEH,CAAA"}
|