jazz-tools 0.14.27 → 0.15.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/.svelte-kit/__package__/Provider.svelte +61 -0
- package/.svelte-kit/__package__/Provider.svelte.d.ts +19 -0
- package/.svelte-kit/__package__/Provider.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/auth/PasskeyAuth.svelte.d.ts +11 -0
- package/.svelte-kit/__package__/auth/PasskeyAuth.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/auth/PasskeyAuth.svelte.js +20 -0
- package/.svelte-kit/__package__/auth/PasskeyAuthBasicUI.svelte +81 -0
- package/.svelte-kit/__package__/auth/PasskeyAuthBasicUI.svelte.d.ts +9 -0
- package/.svelte-kit/__package__/auth/PasskeyAuthBasicUI.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/auth/PassphraseAuth.svelte.d.ts +12 -0
- package/.svelte-kit/__package__/auth/PassphraseAuth.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/auth/PassphraseAuth.svelte.js +30 -0
- package/.svelte-kit/__package__/auth/index.d.ts +4 -0
- package/.svelte-kit/__package__/auth/index.d.ts.map +1 -0
- package/.svelte-kit/__package__/auth/index.js +3 -0
- package/.svelte-kit/__package__/auth/useIsAuthenticated.svelte.d.ts +6 -0
- package/.svelte-kit/__package__/auth/useIsAuthenticated.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/auth/useIsAuthenticated.svelte.js +22 -0
- package/.svelte-kit/__package__/index.d.ts +6 -0
- package/.svelte-kit/__package__/index.d.ts.map +1 -0
- package/.svelte-kit/__package__/index.js +5 -0
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts +21 -0
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/jazz.class.svelte.js +117 -0
- package/.svelte-kit/__package__/jazz.svelte.d.ts +39 -0
- package/.svelte-kit/__package__/jazz.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/jazz.svelte.js +70 -0
- package/.svelte-kit/__package__/testing.d.ts +10 -0
- package/.svelte-kit/__package__/testing.d.ts.map +1 -0
- package/.svelte-kit/__package__/testing.js +23 -0
- package/.turbo/turbo-build.log +180 -11
- package/CHANGELOG.md +21 -0
- package/README.md +2 -2
- package/dist/browser/BrowserContextManager.d.ts +31 -0
- package/dist/browser/BrowserContextManager.d.ts.map +1 -0
- package/dist/browser/auth/LocalStorageKVStore.d.ts +9 -0
- package/dist/browser/auth/LocalStorageKVStore.d.ts.map +1 -0
- package/dist/browser/auth/PasskeyAuth.d.ts +27 -0
- package/dist/browser/auth/PasskeyAuth.d.ts.map +1 -0
- package/dist/browser/createBrowserContext.d.ts +47 -0
- package/dist/browser/createBrowserContext.d.ts.map +1 -0
- package/dist/browser/index.d.ts +23 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +469 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/storageOptions.d.ts +8 -0
- package/dist/browser/storageOptions.d.ts.map +1 -0
- package/dist/browser/tests/LocalStorageKVStore.test.d.ts +2 -0
- package/dist/browser/tests/LocalStorageKVStore.test.d.ts.map +1 -0
- package/dist/browser/tests/PasskeyAuth.test.d.ts +2 -0
- package/dist/browser/tests/PasskeyAuth.test.d.ts.map +1 -0
- package/dist/browser/tests/createInviteLink.test.d.ts +2 -0
- package/dist/browser/tests/createInviteLink.test.d.ts.map +1 -0
- package/dist/browser/tests/storageOptions.test.d.ts +2 -0
- package/dist/browser/tests/storageOptions.test.d.ts.map +1 -0
- package/dist/browser/tests/utils.d.ts +11 -0
- package/dist/browser/tests/utils.d.ts.map +1 -0
- package/dist/browser/utils/export-account-inspector.d.ts +6 -0
- package/dist/browser/utils/export-account-inspector.d.ts.map +1 -0
- package/dist/browser-media-images/index.d.ts +7 -0
- package/dist/browser-media-images/index.d.ts.map +1 -0
- package/dist/browser-media-images/index.js +70 -0
- package/dist/browser-media-images/index.js.map +1 -0
- package/dist/chunk-FSIM7N33.js +4827 -0
- package/dist/chunk-FSIM7N33.js.map +1 -0
- package/dist/expo/auth/clerk/index.d.ts +7 -0
- package/dist/expo/auth/clerk/index.d.ts.map +1 -0
- package/dist/expo/crypto.d.ts +2 -0
- package/dist/expo/crypto.d.ts.map +1 -0
- package/dist/expo/crypto.js +3 -0
- package/dist/expo/crypto.js.map +1 -0
- package/dist/expo/index.d.ts +6 -0
- package/dist/expo/index.d.ts.map +1 -0
- package/dist/expo/index.js +168 -0
- package/dist/expo/index.js.map +1 -0
- package/dist/expo/provider.d.ts +4 -0
- package/dist/expo/provider.d.ts.map +1 -0
- package/dist/expo/storage/expo-secure-store-adapter.d.ts +8 -0
- package/dist/expo/storage/expo-secure-store-adapter.d.ts.map +1 -0
- package/dist/expo/storage/expo-sqlite-adapter.d.ts +18 -0
- package/dist/expo/storage/expo-sqlite-adapter.d.ts.map +1 -0
- package/dist/expo/testing.d.ts +2 -0
- package/dist/expo/testing.d.ts.map +1 -0
- package/dist/expo/testing.js +3 -0
- package/dist/expo/testing.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +172 -6
- package/dist/index.js.map +1 -1
- package/dist/inspector/custom-element-CWW72LEG.js +31971 -0
- package/dist/inspector/custom-element-CWW72LEG.js.map +1 -0
- package/dist/inspector/custom-element.d.ts +13 -0
- package/dist/inspector/custom-element.d.ts.map +1 -0
- package/dist/inspector/index.d.ts +12 -0
- package/dist/inspector/index.d.ts.map +1 -0
- package/dist/inspector/index.js +2027 -0
- package/dist/inspector/index.js.map +1 -0
- package/dist/inspector/register-custom-element.d.ts +2 -0
- package/dist/inspector/register-custom-element.d.ts.map +1 -0
- package/dist/inspector/register-custom-element.js +5 -0
- package/dist/inspector/register-custom-element.js.map +1 -0
- package/dist/inspector/ui/badge.d.ts +4 -0
- package/dist/inspector/ui/badge.d.ts.map +1 -0
- package/dist/inspector/ui/button.d.ts +9 -0
- package/dist/inspector/ui/button.d.ts.map +1 -0
- package/dist/inspector/ui/card.d.ts +10 -0
- package/dist/inspector/ui/card.d.ts.map +1 -0
- package/dist/inspector/ui/global-styles.d.ts +4 -0
- package/dist/inspector/ui/global-styles.d.ts.map +1 -0
- package/dist/inspector/ui/grid.d.ts +4 -0
- package/dist/inspector/ui/grid.d.ts.map +1 -0
- package/dist/inspector/ui/heading.d.ts +4 -0
- package/dist/inspector/ui/heading.d.ts.map +1 -0
- package/dist/inspector/ui/icon.d.ts +30 -0
- package/dist/inspector/ui/icon.d.ts.map +1 -0
- package/dist/inspector/ui/icons/chevron-down-icon.d.ts +2 -0
- package/dist/inspector/ui/icons/chevron-down-icon.d.ts.map +1 -0
- package/dist/inspector/ui/icons/delete-icon.d.ts +2 -0
- package/dist/inspector/ui/icons/delete-icon.d.ts.map +1 -0
- package/dist/inspector/ui/icons/link-icon.d.ts +2 -0
- package/dist/inspector/ui/icons/link-icon.d.ts.map +1 -0
- package/dist/inspector/ui/input.d.ts +11 -0
- package/dist/inspector/ui/input.d.ts.map +1 -0
- package/dist/inspector/ui/select.d.ts +5 -0
- package/dist/inspector/ui/select.d.ts.map +1 -0
- package/dist/inspector/ui/table.d.ts +8 -0
- package/dist/inspector/ui/table.d.ts.map +1 -0
- package/dist/inspector/ui/text.d.ts +10 -0
- package/dist/inspector/ui/text.d.ts.map +1 -0
- package/dist/inspector/viewer/account-or-group-text.d.ts +8 -0
- package/dist/inspector/viewer/account-or-group-text.d.ts.map +1 -0
- package/dist/inspector/viewer/account-view.d.ts +8 -0
- package/dist/inspector/viewer/account-view.d.ts.map +1 -0
- package/dist/inspector/viewer/breadcrumbs.d.ts +9 -0
- package/dist/inspector/viewer/breadcrumbs.d.ts.map +1 -0
- package/dist/inspector/viewer/co-stream-view.d.ts +18 -0
- package/dist/inspector/viewer/co-stream-view.d.ts.map +1 -0
- package/dist/inspector/viewer/grid-view.d.ts +9 -0
- package/dist/inspector/viewer/grid-view.d.ts.map +1 -0
- package/dist/inspector/viewer/group-view.d.ts +8 -0
- package/dist/inspector/viewer/group-view.d.ts.map +1 -0
- package/dist/inspector/viewer/inpsector-button.d.ts +6 -0
- package/dist/inspector/viewer/inpsector-button.d.ts.map +1 -0
- package/dist/inspector/viewer/new-app.d.ts +11 -0
- package/dist/inspector/viewer/new-app.d.ts.map +1 -0
- package/dist/inspector/viewer/page-stack.d.ts +15 -0
- package/dist/inspector/viewer/page-stack.d.ts.map +1 -0
- package/dist/inspector/viewer/page.d.ts +16 -0
- package/dist/inspector/viewer/page.d.ts.map +1 -0
- package/dist/inspector/viewer/raw-data-card.d.ts +5 -0
- package/dist/inspector/viewer/raw-data-card.d.ts.map +1 -0
- package/dist/inspector/viewer/role-display.d.ts +6 -0
- package/dist/inspector/viewer/role-display.d.ts.map +1 -0
- package/dist/inspector/viewer/table-viewer.d.ts +9 -0
- package/dist/inspector/viewer/table-viewer.d.ts.map +1 -0
- package/dist/inspector/viewer/type-icon.d.ts +11 -0
- package/dist/inspector/viewer/type-icon.d.ts.map +1 -0
- package/dist/inspector/viewer/types.d.ts +7 -0
- package/dist/inspector/viewer/types.d.ts.map +1 -0
- package/dist/inspector/viewer/use-page-path.d.ts +10 -0
- package/dist/inspector/viewer/use-page-path.d.ts.map +1 -0
- package/dist/inspector/viewer/use-resolve-covalue.d.ts +67 -0
- package/dist/inspector/viewer/use-resolve-covalue.d.ts.map +1 -0
- package/dist/inspector/viewer/value-renderer.d.ts +12 -0
- package/dist/inspector/viewer/value-renderer.d.ts.map +1 -0
- package/dist/prosemirror/index.d.ts +3 -0
- package/dist/prosemirror/index.d.ts.map +1 -0
- package/dist/prosemirror/index.js +2185 -0
- package/dist/prosemirror/index.js.map +1 -0
- package/dist/prosemirror/lib/converter.d.ts +33 -0
- package/dist/prosemirror/lib/converter.d.ts.map +1 -0
- package/dist/prosemirror/lib/plugin.d.ts +43 -0
- package/dist/prosemirror/lib/plugin.d.ts.map +1 -0
- package/dist/prosemirror/lib/sync.d.ts +35 -0
- package/dist/prosemirror/lib/sync.d.ts.map +1 -0
- package/dist/prosemirror/tests/plugin.test.d.ts +2 -0
- package/dist/prosemirror/tests/plugin.test.d.ts.map +1 -0
- package/dist/react/auth/Clerk.d.ts +7 -0
- package/dist/react/auth/Clerk.d.ts.map +1 -0
- package/dist/react/auth/DemoAuth.d.ts +5 -0
- package/dist/react/auth/DemoAuth.d.ts.map +1 -0
- package/dist/react/auth/PasskeyAuth.d.ts +24 -0
- package/dist/react/auth/PasskeyAuth.d.ts.map +1 -0
- package/dist/react/auth/PassphraseAuth.d.ts +6 -0
- package/dist/react/auth/PassphraseAuth.d.ts.map +1 -0
- package/dist/react/auth/auth.d.ts +6 -0
- package/dist/react/auth/auth.d.ts.map +1 -0
- package/dist/react/hooks.d.ts +9 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +700 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/media.d.ts +24 -0
- package/dist/react/media.d.ts.map +1 -0
- package/dist/react/provider.d.ts +10 -0
- package/dist/react/provider.d.ts.map +1 -0
- package/dist/react/ssr.d.ts +4 -0
- package/dist/react/ssr.d.ts.map +1 -0
- package/dist/react/ssr.js +25 -0
- package/dist/react/ssr.js.map +1 -0
- package/dist/react/testing.d.ts +2 -0
- package/dist/react/testing.d.ts.map +1 -0
- package/dist/react/testing.js +5 -0
- package/dist/react/testing.js.map +1 -0
- package/dist/react/tests/testUtils.d.ts +14 -0
- package/dist/react/tests/testUtils.d.ts.map +1 -0
- package/dist/react/tests/useAcceptInvite.test.d.ts +2 -0
- package/dist/react/tests/useAcceptInvite.test.d.ts.map +1 -0
- package/dist/react-core/auth/DemoAuth.d.ts +17 -0
- package/dist/react-core/auth/DemoAuth.d.ts.map +1 -0
- package/dist/react-core/auth/PassphraseAuth.d.ts +21 -0
- package/dist/react-core/auth/PassphraseAuth.d.ts.map +1 -0
- package/dist/react-core/auth/index.d.ts +3 -0
- package/dist/react-core/auth/index.d.ts.map +1 -0
- package/dist/react-core/chunk-7DYMJ74I.js +12 -0
- package/dist/react-core/chunk-7DYMJ74I.js.map +1 -0
- package/dist/react-core/hooks.d.ts +17 -0
- package/dist/react-core/hooks.d.ts.map +1 -0
- package/dist/react-core/index.d.ts +4 -0
- package/dist/react-core/index.d.ts.map +1 -0
- package/dist/react-core/index.js +302 -0
- package/dist/react-core/index.js.map +1 -0
- package/dist/react-core/provider.d.ts +5 -0
- package/dist/react-core/provider.d.ts.map +1 -0
- package/dist/react-core/testing.d.ts +10 -0
- package/dist/react-core/testing.d.ts.map +1 -0
- package/dist/react-core/testing.js +43 -0
- package/dist/react-core/testing.js.map +1 -0
- package/dist/react-core/tests/fixtures.d.ts.map +1 -0
- package/dist/react-core/tests/testUtils.d.ts +15 -0
- package/dist/react-core/tests/testUtils.d.ts.map +1 -0
- package/dist/react-core/tests/useAccount.test.d.ts +2 -0
- package/dist/react-core/tests/useAccount.test.d.ts.map +1 -0
- package/dist/react-core/tests/useCoState.test.d.ts +2 -0
- package/dist/react-core/tests/useCoState.test.d.ts.map +1 -0
- package/dist/react-core/tests/useInboxSender.test.d.ts +2 -0
- package/dist/react-core/tests/useInboxSender.test.d.ts.map +1 -0
- package/dist/react-core/tests/useIsAuthenticated.test.d.ts +2 -0
- package/dist/react-core/tests/useIsAuthenticated.test.d.ts.map +1 -0
- package/dist/react-core/tests/usePassPhraseAuth.test.d.ts +2 -0
- package/dist/react-core/tests/usePassPhraseAuth.test.d.ts.map +1 -0
- package/dist/react-core/utils.d.ts +4 -0
- package/dist/react-core/utils.d.ts.map +1 -0
- package/dist/react-native/crypto.d.ts +2 -0
- package/dist/react-native/crypto.d.ts.map +1 -0
- package/dist/react-native/crypto.js +3 -0
- package/dist/react-native/crypto.js.map +1 -0
- package/dist/react-native/index.d.ts +5 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +103 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/provider.d.ts +4 -0
- package/dist/react-native/provider.d.ts.map +1 -0
- package/dist/react-native/storage/mmkv-store-adapter.d.ts +8 -0
- package/dist/react-native/storage/mmkv-store-adapter.d.ts.map +1 -0
- package/dist/react-native/storage/op-sqlite-adapter.d.ts +13 -0
- package/dist/react-native/storage/op-sqlite-adapter.d.ts.map +1 -0
- package/dist/react-native/testing.d.ts +2 -0
- package/dist/react-native/testing.d.ts.map +1 -0
- package/dist/react-native/testing.js +3 -0
- package/dist/react-native/testing.js.map +1 -0
- package/dist/react-native-core/ReactNativeContextManager.d.ts +31 -0
- package/dist/react-native-core/ReactNativeContextManager.d.ts.map +1 -0
- package/dist/react-native-core/auth/DemoAuthUI.d.ts +8 -0
- package/dist/react-native-core/auth/DemoAuthUI.d.ts.map +1 -0
- package/dist/react-native-core/auth/auth.d.ts +3 -0
- package/dist/react-native-core/auth/auth.d.ts.map +1 -0
- package/dist/react-native-core/crypto/RNQuickCrypto.d.ts +15 -0
- package/dist/react-native-core/crypto/RNQuickCrypto.d.ts.map +1 -0
- package/dist/react-native-core/crypto/index.d.ts +2 -0
- package/dist/react-native-core/crypto/index.d.ts.map +1 -0
- package/dist/react-native-core/crypto.js +65 -0
- package/dist/react-native-core/crypto.js.map +1 -0
- package/dist/react-native-core/hooks.d.ts +8 -0
- package/dist/react-native-core/hooks.d.ts.map +1 -0
- package/dist/react-native-core/index.d.ts +9 -0
- package/dist/react-native-core/index.d.ts.map +1 -0
- package/dist/react-native-core/index.js +669 -0
- package/dist/react-native-core/index.js.map +1 -0
- package/dist/react-native-core/media.d.ts +24 -0
- package/dist/react-native-core/media.d.ts.map +1 -0
- package/dist/react-native-core/platform.d.ts +45 -0
- package/dist/react-native-core/platform.d.ts.map +1 -0
- package/dist/react-native-core/provider.d.ts +10 -0
- package/dist/react-native-core/provider.d.ts.map +1 -0
- package/dist/react-native-core/storage/kv-store-context.d.ts +17 -0
- package/dist/react-native-core/storage/kv-store-context.d.ts.map +1 -0
- package/dist/react-native-core/storage/sqlite-react-native.d.ts +9 -0
- package/dist/react-native-core/storage/sqlite-react-native.d.ts.map +1 -0
- package/dist/react-native-core/testing.js +3 -0
- package/dist/react-native-core/testing.js.map +1 -0
- package/dist/react-native-media-images/index.d.ts +7 -0
- package/dist/react-native-media-images/index.d.ts.map +1 -0
- package/dist/react-native-media-images/index.js +177 -0
- package/dist/react-native-media-images/index.js.map +1 -0
- package/dist/svelte/Provider.svelte +61 -0
- package/dist/svelte/Provider.svelte.d.ts +19 -0
- package/dist/svelte/Provider.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/PasskeyAuth.svelte.d.ts +11 -0
- package/dist/svelte/auth/PasskeyAuth.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/PasskeyAuth.svelte.js +20 -0
- package/dist/svelte/auth/PasskeyAuthBasicUI.svelte +81 -0
- package/dist/svelte/auth/PasskeyAuthBasicUI.svelte.d.ts +9 -0
- package/dist/svelte/auth/PasskeyAuthBasicUI.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/PassphraseAuth.svelte.d.ts +12 -0
- package/dist/svelte/auth/PassphraseAuth.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/PassphraseAuth.svelte.js +30 -0
- package/dist/svelte/auth/index.d.ts +4 -0
- package/dist/svelte/auth/index.d.ts.map +1 -0
- package/dist/svelte/auth/index.js +3 -0
- package/dist/svelte/auth/useIsAuthenticated.svelte.d.ts +6 -0
- package/dist/svelte/auth/useIsAuthenticated.svelte.d.ts.map +1 -0
- package/dist/svelte/auth/useIsAuthenticated.svelte.js +22 -0
- package/dist/svelte/index.d.ts +6 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +5 -0
- package/dist/svelte/jazz.class.svelte.d.ts +21 -0
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -0
- package/dist/svelte/jazz.class.svelte.js +117 -0
- package/dist/svelte/jazz.svelte.d.ts +39 -0
- package/dist/svelte/jazz.svelte.d.ts.map +1 -0
- package/dist/svelte/jazz.svelte.js +70 -0
- package/dist/svelte/testing.d.ts +10 -0
- package/dist/svelte/testing.d.ts.map +1 -0
- package/dist/svelte/testing.js +23 -0
- package/dist/testing.d.ts +1 -42
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/dist/tiptap/index.d.ts +11 -0
- package/dist/tiptap/index.d.ts.map +1 -0
- package/dist/tiptap/index.js +22 -0
- package/dist/tiptap/index.js.map +1 -0
- package/dist/tools/auth/AuthSecretStorage.d.ts.map +1 -0
- package/dist/tools/auth/DemoAuth.d.ts.map +1 -0
- package/dist/tools/auth/InMemoryKVStore.d.ts.map +1 -0
- package/dist/tools/auth/KvStoreContext.d.ts.map +1 -0
- package/dist/tools/auth/PassphraseAuth.d.ts.map +1 -0
- package/dist/tools/auth/clerk/getClerkUsername.d.ts +3 -0
- package/dist/tools/auth/clerk/getClerkUsername.d.ts.map +1 -0
- package/dist/tools/auth/clerk/index.d.ts +25 -0
- package/dist/tools/auth/clerk/index.d.ts.map +1 -0
- package/dist/tools/auth/clerk/tests/JazzClerkAuth.test.d.ts +2 -0
- package/dist/tools/auth/clerk/tests/JazzClerkAuth.test.d.ts.map +1 -0
- package/dist/tools/auth/clerk/tests/getClerkUsername.test.d.ts +2 -0
- package/dist/tools/auth/clerk/tests/getClerkUsername.test.d.ts.map +1 -0
- package/dist/tools/auth/clerk/tests/types.test.d.ts +2 -0
- package/dist/tools/auth/clerk/tests/types.test.d.ts.map +1 -0
- package/dist/tools/auth/clerk/types.d.ts +32 -0
- package/dist/tools/auth/clerk/types.d.ts.map +1 -0
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -0
- package/dist/tools/coValues/account.d.ts.map +1 -0
- package/dist/tools/coValues/coFeed.d.ts +368 -0
- package/dist/tools/coValues/coFeed.d.ts.map +1 -0
- package/dist/tools/coValues/coList.d.ts.map +1 -0
- package/dist/tools/coValues/coMap.d.ts.map +1 -0
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -0
- package/dist/tools/coValues/coRichText.d.ts.map +1 -0
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -0
- package/dist/tools/coValues/extensions/imageDef.d.ts.map +1 -0
- package/dist/tools/coValues/group.d.ts.map +1 -0
- package/dist/tools/coValues/inbox.d.ts.map +1 -0
- package/dist/tools/coValues/interfaces.d.ts.map +1 -0
- package/dist/tools/coValues/profile.d.ts.map +1 -0
- package/dist/tools/coValues/registeredSchemas.d.ts.map +1 -0
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -0
- package/dist/tools/exports.d.ts +24 -0
- package/dist/tools/exports.d.ts.map +1 -0
- package/dist/tools/implementation/ContextManager.d.ts.map +1 -0
- package/dist/tools/implementation/activeAccountContext.d.ts.map +1 -0
- package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -0
- package/dist/tools/implementation/createContext.d.ts.map +1 -0
- package/dist/tools/implementation/devtoolsFormatters.d.ts.map +1 -0
- package/dist/tools/implementation/errors.d.ts.map +1 -0
- package/dist/tools/implementation/inspect.d.ts.map +1 -0
- package/dist/tools/implementation/invites.d.ts.map +1 -0
- package/dist/tools/implementation/refs.d.ts.map +1 -0
- package/dist/tools/implementation/schema.d.ts.map +1 -0
- package/dist/tools/implementation/symbols.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/internal.d.ts.map +1 -0
- package/dist/tools/lib/cache.d.ts.map +1 -0
- package/dist/tools/lib/cache.test.d.ts.map +1 -0
- package/dist/tools/lib/migration.d.ts.map +1 -0
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -0
- package/dist/tools/subscribe/JazzError.d.ts.map +1 -0
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -0
- package/dist/tools/subscribe/index.d.ts.map +1 -0
- package/dist/tools/subscribe/types.d.ts.map +1 -0
- package/dist/tools/subscribe/utils.d.ts.map +1 -0
- package/dist/tools/testing.d.ts +43 -0
- package/dist/tools/testing.d.ts.map +1 -0
- package/dist/tools/tests/AuthSecretStorage.test.d.ts.map +1 -0
- package/dist/tools/tests/ContextManager.test.d.ts.map +1 -0
- package/dist/tools/tests/DemoAuth.test.d.ts.map +1 -0
- package/dist/tools/tests/PassphraseAuth.test.d.ts.map +1 -0
- package/dist/tools/tests/account.test.d.ts.map +1 -0
- package/dist/tools/tests/coFeed.test-d.d.ts.map +1 -0
- package/dist/tools/tests/coFeed.test.d.ts.map +1 -0
- package/dist/tools/tests/coList.test-d.d.ts.map +1 -0
- package/dist/tools/tests/coList.test.d.ts.map +1 -0
- package/dist/tools/tests/coMap.record.test-d.d.ts.map +1 -0
- package/dist/tools/tests/coMap.record.test.d.ts.map +1 -0
- package/dist/tools/tests/coMap.test-d.d.ts.map +1 -0
- package/dist/tools/tests/coMap.test.d.ts.map +1 -0
- package/dist/tools/tests/coPlainText.test.d.ts.map +1 -0
- package/dist/tools/tests/createContext.test.d.ts.map +1 -0
- package/dist/tools/tests/deepLoading.test.d.ts.map +1 -0
- package/dist/tools/tests/fixtures.d.ts +2 -0
- package/dist/tools/tests/fixtures.d.ts.map +1 -0
- package/dist/tools/tests/groupsAndAccounts.test.d.ts.map +1 -0
- package/dist/tools/tests/imageDef.test.d.ts.map +1 -0
- package/dist/tools/tests/inbox.test.d.ts.map +1 -0
- package/dist/tools/tests/interfaces.test.d.ts.map +1 -0
- package/dist/tools/tests/invites.test.d.ts.map +1 -0
- package/dist/tools/tests/load.test.d.ts.map +1 -0
- package/dist/tools/tests/patterns/notifications.test.d.ts.map +1 -0
- package/dist/tools/tests/patterns/requestToJoin.test.d.ts.map +1 -0
- package/dist/tools/tests/schema.test.d.ts.map +1 -0
- package/dist/tools/tests/schemaUnion.test.d.ts.map +1 -0
- package/dist/tools/tests/subscribe.test.d.ts.map +1 -0
- package/dist/tools/tests/testing.test.d.ts.map +1 -0
- package/dist/tools/tests/utils.d.ts.map +1 -0
- package/dist/tools/tests/zod.test.d.ts.map +1 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/worker/index.d.ts +25 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +93 -0
- package/dist/worker/index.js.map +1 -0
- package/package.json +193 -11
- package/src/browser/BrowserContextManager.ts +85 -0
- package/src/browser/auth/LocalStorageKVStore.ts +21 -0
- package/src/browser/auth/PasskeyAuth.ts +175 -0
- package/src/browser/createBrowserContext.ts +326 -0
- package/src/browser/index.ts +72 -0
- package/src/browser/storageOptions.ts +17 -0
- package/src/browser/tests/LocalStorageKVStore.test.ts +67 -0
- package/src/browser/tests/PasskeyAuth.test.ts +242 -0
- package/src/browser/tests/createInviteLink.test.ts +18 -0
- package/src/browser/tests/storageOptions.test.ts +33 -0
- package/src/browser/tests/utils.ts +93 -0
- package/src/browser/utils/export-account-inspector.ts +58 -0
- package/src/browser-media-images/index.ts +130 -0
- package/src/expo/auth/clerk/README.md +44 -0
- package/src/expo/auth/clerk/index.tsx +80 -0
- package/src/expo/crypto.ts +1 -0
- package/src/expo/index.ts +6 -0
- package/src/expo/provider.tsx +29 -0
- package/src/expo/storage/expo-secure-store-adapter.ts +29 -0
- package/src/expo/storage/expo-sqlite-adapter.ts +94 -0
- package/src/expo/testing.ts +1 -0
- package/src/index.ts +1 -3
- package/src/inspector/custom-element.tsx +63 -0
- package/src/inspector/index.ts +23 -0
- package/src/inspector/register-custom-element.ts +3 -0
- package/src/inspector/ui/badge.tsx +20 -0
- package/src/inspector/ui/button.tsx +81 -0
- package/src/inspector/ui/card.tsx +23 -0
- package/src/inspector/ui/global-styles.tsx +74 -0
- package/src/inspector/ui/grid.tsx +48 -0
- package/src/inspector/ui/heading.tsx +15 -0
- package/src/inspector/ui/icon.tsx +71 -0
- package/src/inspector/ui/icons/chevron-down-icon.tsx +16 -0
- package/src/inspector/ui/icons/delete-icon.tsx +19 -0
- package/src/inspector/ui/icons/link-icon.tsx +18 -0
- package/src/inspector/ui/input.tsx +51 -0
- package/src/inspector/ui/select.tsx +73 -0
- package/src/inspector/ui/table.tsx +90 -0
- package/src/inspector/ui/text.tsx +62 -0
- package/src/inspector/viewer/account-or-group-text.tsx +52 -0
- package/src/inspector/viewer/account-view.tsx +34 -0
- package/src/inspector/viewer/breadcrumbs.tsx +52 -0
- package/src/inspector/viewer/co-stream-view.tsx +374 -0
- package/src/inspector/viewer/grid-view.tsx +90 -0
- package/src/inspector/viewer/group-view.tsx +67 -0
- package/src/inspector/viewer/inpsector-button.tsx +89 -0
- package/src/inspector/viewer/new-app.tsx +171 -0
- package/src/inspector/viewer/page-stack.tsx +56 -0
- package/src/inspector/viewer/page.tsx +199 -0
- package/src/inspector/viewer/raw-data-card.tsx +53 -0
- package/src/inspector/viewer/role-display.tsx +28 -0
- package/src/inspector/viewer/table-viewer.tsx +184 -0
- package/src/inspector/viewer/type-icon.tsx +63 -0
- package/src/inspector/viewer/types.ts +11 -0
- package/src/inspector/viewer/use-page-path.ts +52 -0
- package/src/inspector/viewer/use-resolve-covalue.ts +214 -0
- package/src/inspector/viewer/value-renderer.tsx +266 -0
- package/src/prosemirror/index.ts +2 -0
- package/src/prosemirror/lib/converter.ts +50 -0
- package/src/prosemirror/lib/plugin.ts +120 -0
- package/src/prosemirror/lib/sync.ts +96 -0
- package/src/prosemirror/tests/plugin.test.ts +127 -0
- package/src/react/auth/Clerk.tsx +82 -0
- package/src/react/auth/DemoAuth.tsx +121 -0
- package/src/react/auth/PasskeyAuth.tsx +168 -0
- package/src/react/auth/PassphraseAuth.tsx +196 -0
- package/src/react/auth/auth.ts +9 -0
- package/src/react/hooks.tsx +53 -0
- package/src/react/index.ts +16 -0
- package/src/react/media.tsx +74 -0
- package/src/react/provider.tsx +114 -0
- package/src/react/scratch.tsx +50 -0
- package/src/react/ssr.ts +25 -0
- package/src/react/testing.tsx +1 -0
- package/src/react/tests/testUtils.tsx +54 -0
- package/src/react/tests/useAcceptInvite.test.ts +55 -0
- package/src/react-core/auth/DemoAuth.tsx +47 -0
- package/src/react-core/auth/PassphraseAuth.tsx +58 -0
- package/src/react-core/auth/index.ts +2 -0
- package/src/react-core/hooks.ts +310 -0
- package/src/react-core/index.ts +3 -0
- package/src/react-core/provider.tsx +11 -0
- package/src/react-core/testing.tsx +42 -0
- package/src/react-core/tests/testUtils.tsx +65 -0
- package/src/react-core/tests/useAccount.test.ts +238 -0
- package/src/react-core/tests/useCoState.test.ts +553 -0
- package/src/react-core/tests/useDemoAuth.test.tsx +84 -0
- package/src/react-core/tests/useInboxSender.test.ts +58 -0
- package/src/react-core/tests/useIsAuthenticated.test.ts +34 -0
- package/src/react-core/tests/usePassPhraseAuth.test.ts +180 -0
- package/src/react-core/utils.ts +28 -0
- package/src/react-native/crypto.ts +1 -0
- package/src/react-native/index.ts +5 -0
- package/src/react-native/provider.tsx +30 -0
- package/src/react-native/storage/mmkv-store-adapter.ts +24 -0
- package/src/react-native/storage/op-sqlite-adapter.ts +79 -0
- package/src/react-native/testing.ts +1 -0
- package/src/react-native-core/ReactNativeContextManager.ts +84 -0
- package/src/react-native-core/auth/DemoAuthUI.tsx +202 -0
- package/src/react-native-core/auth/auth.ts +14 -0
- package/src/react-native-core/crypto/RNQuickCrypto.ts +92 -0
- package/src/react-native-core/crypto/index.ts +1 -0
- package/src/react-native-core/hooks.tsx +64 -0
- package/src/react-native-core/index.ts +9 -0
- package/src/react-native-core/media.tsx +99 -0
- package/src/react-native-core/platform.ts +250 -0
- package/src/react-native-core/provider.tsx +115 -0
- package/src/react-native-core/storage/sqlite-react-native.ts +19 -0
- package/src/react-native-core/testing.tsx +1 -0
- package/src/react-native-media-images/index.ts +238 -0
- package/src/svelte/Provider.svelte +61 -0
- package/src/svelte/auth/PasskeyAuth.svelte.ts +42 -0
- package/src/svelte/auth/PasskeyAuthBasicUI.svelte +81 -0
- package/src/svelte/auth/PassphraseAuth.svelte.ts +49 -0
- package/src/svelte/auth/index.ts +3 -0
- package/src/svelte/auth/useIsAuthenticated.svelte.ts +28 -0
- package/src/svelte/index.ts +5 -0
- package/src/svelte/jazz.class.svelte.ts +172 -0
- package/src/svelte/jazz.svelte.ts +109 -0
- package/src/svelte/testing.ts +42 -0
- package/src/testing.ts +1 -312
- package/src/tiptap/index.ts +28 -0
- package/src/tools/auth/KvStoreContext.ts +39 -0
- package/src/tools/auth/clerk/getClerkUsername.ts +36 -0
- package/src/tools/auth/clerk/index.ts +174 -0
- package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +284 -0
- package/src/tools/auth/clerk/tests/getClerkUsername.test.ts +81 -0
- package/src/tools/auth/clerk/tests/types.test.ts +49 -0
- package/src/tools/auth/clerk/types.ts +56 -0
- package/src/tools/coValues/coFeed.ts +943 -0
- package/src/tools/exports.ts +117 -0
- package/src/tools/index.ts +8 -0
- package/src/tools/testing.ts +301 -0
- package/src/tools/tests/coFeed.test.ts +771 -0
- package/src/tools/tests/fixtures.ts +2050 -0
- package/src/worker/index.ts +127 -0
- package/tsconfig.json +10 -3
- package/tsconfig.svelte.json +6 -0
- package/tsup.config.ts +143 -9
- package/dist/auth/AuthSecretStorage.d.ts.map +0 -1
- package/dist/auth/DemoAuth.d.ts.map +0 -1
- package/dist/auth/InMemoryKVStore.d.ts.map +0 -1
- package/dist/auth/KvStoreContext.d.ts.map +0 -1
- package/dist/auth/PassphraseAuth.d.ts.map +0 -1
- package/dist/chunk-G3QC4FAY.js +0 -4826
- package/dist/chunk-G3QC4FAY.js.map +0 -1
- package/dist/coValues/CoValueBase.d.ts.map +0 -1
- package/dist/coValues/account.d.ts.map +0 -1
- package/dist/coValues/coFeed.d.ts +0 -367
- package/dist/coValues/coFeed.d.ts.map +0 -1
- package/dist/coValues/coList.d.ts.map +0 -1
- package/dist/coValues/coMap.d.ts.map +0 -1
- package/dist/coValues/coPlainText.d.ts.map +0 -1
- package/dist/coValues/coRichText.d.ts.map +0 -1
- package/dist/coValues/deepLoading.d.ts.map +0 -1
- package/dist/coValues/extensions/imageDef.d.ts.map +0 -1
- package/dist/coValues/group.d.ts.map +0 -1
- package/dist/coValues/inbox.d.ts.map +0 -1
- package/dist/coValues/interfaces.d.ts.map +0 -1
- package/dist/coValues/profile.d.ts.map +0 -1
- package/dist/coValues/registeredSchemas.d.ts.map +0 -1
- package/dist/coValues/schemaUnion.d.ts.map +0 -1
- package/dist/exports.d.ts +0 -23
- package/dist/exports.d.ts.map +0 -1
- package/dist/implementation/ContextManager.d.ts.map +0 -1
- package/dist/implementation/activeAccountContext.d.ts.map +0 -1
- package/dist/implementation/anonymousJazzAgent.d.ts.map +0 -1
- package/dist/implementation/createContext.d.ts.map +0 -1
- package/dist/implementation/devtoolsFormatters.d.ts.map +0 -1
- package/dist/implementation/errors.d.ts.map +0 -1
- package/dist/implementation/inspect.d.ts.map +0 -1
- package/dist/implementation/invites.d.ts.map +0 -1
- package/dist/implementation/refs.d.ts.map +0 -1
- package/dist/implementation/schema.d.ts.map +0 -1
- package/dist/implementation/symbols.d.ts.map +0 -1
- package/dist/implementation/zodSchema/coExport.d.ts.map +0 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +0 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +0 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +0 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +0 -1
- package/dist/implementation/zodSchema/unionUtils.d.ts.map +0 -1
- package/dist/implementation/zodSchema/zodCo.d.ts.map +0 -1
- package/dist/implementation/zodSchema/zodReExport.d.ts.map +0 -1
- package/dist/implementation/zodSchema/zodSchema.d.ts.map +0 -1
- package/dist/internal.d.ts.map +0 -1
- package/dist/lib/cache.d.ts.map +0 -1
- package/dist/lib/cache.test.d.ts.map +0 -1
- package/dist/lib/migration.d.ts.map +0 -1
- package/dist/subscribe/CoValueCoreSubscription.d.ts.map +0 -1
- package/dist/subscribe/JazzError.d.ts.map +0 -1
- package/dist/subscribe/SubscriptionScope.d.ts.map +0 -1
- package/dist/subscribe/index.d.ts.map +0 -1
- package/dist/subscribe/types.d.ts.map +0 -1
- package/dist/subscribe/utils.d.ts.map +0 -1
- package/dist/tests/AuthSecretStorage.test.d.ts.map +0 -1
- package/dist/tests/ContextManager.test.d.ts.map +0 -1
- package/dist/tests/DemoAuth.test.d.ts.map +0 -1
- package/dist/tests/PassphraseAuth.test.d.ts.map +0 -1
- package/dist/tests/account.test.d.ts.map +0 -1
- package/dist/tests/coFeed.test-d.d.ts.map +0 -1
- package/dist/tests/coFeed.test.d.ts.map +0 -1
- package/dist/tests/coList.test-d.d.ts.map +0 -1
- package/dist/tests/coList.test.d.ts.map +0 -1
- package/dist/tests/coMap.record.test-d.d.ts.map +0 -1
- package/dist/tests/coMap.record.test.d.ts.map +0 -1
- package/dist/tests/coMap.test-d.d.ts.map +0 -1
- package/dist/tests/coMap.test.d.ts.map +0 -1
- package/dist/tests/coPlainText.test.d.ts.map +0 -1
- package/dist/tests/createContext.test.d.ts.map +0 -1
- package/dist/tests/deepLoading.test.d.ts.map +0 -1
- package/dist/tests/fixtures.d.ts.map +0 -1
- package/dist/tests/groupsAndAccounts.test.d.ts.map +0 -1
- package/dist/tests/imageDef.test.d.ts.map +0 -1
- package/dist/tests/inbox.test.d.ts.map +0 -1
- package/dist/tests/interfaces.test.d.ts.map +0 -1
- package/dist/tests/invites.test.d.ts.map +0 -1
- package/dist/tests/load.test.d.ts.map +0 -1
- package/dist/tests/patterns/notifications.test.d.ts.map +0 -1
- package/dist/tests/patterns/requestToJoin.test.d.ts.map +0 -1
- package/dist/tests/schema.test.d.ts.map +0 -1
- package/dist/tests/schemaUnion.test.d.ts.map +0 -1
- package/dist/tests/subscribe.test.d.ts.map +0 -1
- package/dist/tests/testing.test.d.ts.map +0 -1
- package/dist/tests/utils.d.ts.map +0 -1
- package/dist/tests/zod.test.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/src/coValues/coFeed.ts +0 -938
- package/src/exports.ts +0 -108
- package/src/tests/coFeed.test.ts +0 -722
- /package/dist/{tests → react-core/tests}/fixtures.d.ts +0 -0
- /package/dist/{auth → tools/auth}/AuthSecretStorage.d.ts +0 -0
- /package/dist/{auth → tools/auth}/DemoAuth.d.ts +0 -0
- /package/dist/{auth → tools/auth}/InMemoryKVStore.d.ts +0 -0
- /package/dist/{auth → tools/auth}/KvStoreContext.d.ts +0 -0
- /package/dist/{auth → tools/auth}/PassphraseAuth.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/CoValueBase.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/account.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/coList.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/coMap.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/coPlainText.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/coRichText.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/deepLoading.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/extensions/imageDef.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/group.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/inbox.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/interfaces.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/profile.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/registeredSchemas.d.ts +0 -0
- /package/dist/{coValues → tools/coValues}/schemaUnion.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/ContextManager.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/activeAccountContext.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/anonymousJazzAgent.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/createContext.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/devtoolsFormatters.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/errors.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/inspect.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/invites.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/refs.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/schema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/symbols.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/coExport.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/AccountSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/CoFeedSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/CoListSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/CoMapSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/CoRecordSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/FileStreamSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/PlainTextSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/schemaTypes/RichTextSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOfSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/unionUtils.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/zodCo.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/zodReExport.d.ts +0 -0
- /package/dist/{implementation → tools/implementation}/zodSchema/zodSchema.d.ts +0 -0
- /package/dist/{internal.d.ts → tools/internal.d.ts} +0 -0
- /package/dist/{lib → tools/lib}/cache.d.ts +0 -0
- /package/dist/{lib → tools/lib}/cache.test.d.ts +0 -0
- /package/dist/{lib → tools/lib}/migration.d.ts +0 -0
- /package/dist/{subscribe → tools/subscribe}/CoValueCoreSubscription.d.ts +0 -0
- /package/dist/{subscribe → tools/subscribe}/JazzError.d.ts +0 -0
- /package/dist/{subscribe → tools/subscribe}/SubscriptionScope.d.ts +0 -0
- /package/dist/{subscribe → tools/subscribe}/index.d.ts +0 -0
- /package/dist/{subscribe → tools/subscribe}/types.d.ts +0 -0
- /package/dist/{subscribe → tools/subscribe}/utils.d.ts +0 -0
- /package/dist/{tests → tools/tests}/AuthSecretStorage.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/ContextManager.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/DemoAuth.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/PassphraseAuth.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/account.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coFeed.test-d.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coFeed.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coList.test-d.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coList.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coMap.record.test-d.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coMap.record.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coMap.test-d.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coMap.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/coPlainText.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/createContext.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/deepLoading.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/groupsAndAccounts.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/imageDef.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/inbox.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/interfaces.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/invites.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/load.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/patterns/notifications.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/patterns/requestToJoin.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/schema.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/schemaUnion.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/subscribe.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/testing.test.d.ts +0 -0
- /package/dist/{tests → tools/tests}/utils.d.ts +0 -0
- /package/dist/{tests → tools/tests}/zod.test.d.ts +0 -0
- /package/dist/{types.d.ts → tools/types.d.ts} +0 -0
- /package/src/{tests → react-core/tests}/fixtures.ts +0 -0
- /package/src/{auth/KvStoreContext.ts → react-native-core/storage/kv-store-context.ts} +0 -0
- /package/src/{auth → tools/auth}/AuthSecretStorage.ts +0 -0
- /package/src/{auth → tools/auth}/DemoAuth.ts +0 -0
- /package/src/{auth → tools/auth}/InMemoryKVStore.ts +0 -0
- /package/src/{auth → tools/auth}/PassphraseAuth.ts +0 -0
- /package/src/{coValues → tools/coValues}/CoValueBase.ts +0 -0
- /package/src/{coValues → tools/coValues}/account.ts +0 -0
- /package/src/{coValues → tools/coValues}/coList.ts +0 -0
- /package/src/{coValues → tools/coValues}/coMap.ts +0 -0
- /package/src/{coValues → tools/coValues}/coPlainText.ts +0 -0
- /package/src/{coValues → tools/coValues}/coRichText.ts +0 -0
- /package/src/{coValues → tools/coValues}/deepLoading.ts +0 -0
- /package/src/{coValues → tools/coValues}/extensions/imageDef.ts +0 -0
- /package/src/{coValues → tools/coValues}/group.ts +0 -0
- /package/src/{coValues → tools/coValues}/inbox.ts +0 -0
- /package/src/{coValues → tools/coValues}/interfaces.ts +0 -0
- /package/src/{coValues → tools/coValues}/profile.ts +0 -0
- /package/src/{coValues → tools/coValues}/registeredSchemas.ts +0 -0
- /package/src/{coValues → tools/coValues}/schemaUnion.ts +0 -0
- /package/src/{implementation → tools/implementation}/ContextManager.ts +0 -0
- /package/src/{implementation → tools/implementation}/activeAccountContext.ts +0 -0
- /package/src/{implementation → tools/implementation}/anonymousJazzAgent.ts +0 -0
- /package/src/{implementation → tools/implementation}/createContext.ts +0 -0
- /package/src/{implementation → tools/implementation}/devtoolsFormatters.ts +0 -0
- /package/src/{implementation → tools/implementation}/errors.ts +0 -0
- /package/src/{implementation → tools/implementation}/inspect.ts +0 -0
- /package/src/{implementation → tools/implementation}/invites.ts +0 -0
- /package/src/{implementation → tools/implementation}/refs.ts +0 -0
- /package/src/{implementation → tools/implementation}/schema.ts +0 -0
- /package/src/{implementation → tools/implementation}/symbols.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/coExport.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/AccountSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/CoFeedSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/CoListSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/CoMapSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/CoRecordSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/FileStreamSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/PlainTextSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/schemaTypes/RichTextSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOfSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/unionUtils.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/zodCo.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/zodReExport.ts +0 -0
- /package/src/{implementation → tools/implementation}/zodSchema/zodSchema.ts +0 -0
- /package/src/{internal.ts → tools/internal.ts} +0 -0
- /package/src/{lib → tools/lib}/cache.test.ts +0 -0
- /package/src/{lib → tools/lib}/cache.ts +0 -0
- /package/src/{lib → tools/lib}/migration.ts +0 -0
- /package/src/{subscribe → tools/subscribe}/CoValueCoreSubscription.ts +0 -0
- /package/src/{subscribe → tools/subscribe}/JazzError.ts +0 -0
- /package/src/{subscribe → tools/subscribe}/SubscriptionScope.ts +0 -0
- /package/src/{subscribe → tools/subscribe}/index.ts +0 -0
- /package/src/{subscribe → tools/subscribe}/types.ts +0 -0
- /package/src/{subscribe → tools/subscribe}/utils.ts +0 -0
- /package/src/{tests → tools/tests}/AuthSecretStorage.test.ts +0 -0
- /package/src/{tests → tools/tests}/ContextManager.test.ts +0 -0
- /package/src/{tests → tools/tests}/DemoAuth.test.ts +0 -0
- /package/src/{tests → tools/tests}/PassphraseAuth.test.ts +0 -0
- /package/src/{tests → tools/tests}/account.test.ts +0 -0
- /package/src/{tests → tools/tests}/coFeed.test-d.ts +0 -0
- /package/src/{tests → tools/tests}/coList.test-d.ts +0 -0
- /package/src/{tests → tools/tests}/coList.test.ts +0 -0
- /package/src/{tests → tools/tests}/coMap.record.test-d.ts +0 -0
- /package/src/{tests → tools/tests}/coMap.record.test.ts +0 -0
- /package/src/{tests → tools/tests}/coMap.test-d.ts +0 -0
- /package/src/{tests → tools/tests}/coMap.test.ts +0 -0
- /package/src/{tests → tools/tests}/coPlainText.test.ts +0 -0
- /package/src/{tests → tools/tests}/createContext.test.ts +0 -0
- /package/src/{tests → tools/tests}/deepLoading.test.ts +0 -0
- /package/src/{tests → tools/tests}/groupsAndAccounts.test.ts +0 -0
- /package/src/{tests → tools/tests}/imageDef.test.ts +0 -0
- /package/src/{tests → tools/tests}/inbox.test.ts +0 -0
- /package/src/{tests → tools/tests}/interfaces.test.ts +0 -0
- /package/src/{tests → tools/tests}/invites.test.ts +0 -0
- /package/src/{tests → tools/tests}/load.test.ts +0 -0
- /package/src/{tests → tools/tests}/patterns/notifications.test.ts +0 -0
- /package/src/{tests → tools/tests}/patterns/requestToJoin.test.ts +0 -0
- /package/src/{tests → tools/tests}/schema.test.ts +0 -0
- /package/src/{tests → tools/tests}/schemaUnion.test.ts +0 -0
- /package/src/{tests → tools/tests}/subscribe.test.ts +0 -0
- /package/src/{tests → tools/tests}/testing.test.ts +0 -0
- /package/src/{tests → tools/tests}/utils.ts +0 -0
- /package/src/{tests → tools/tests}/zod.test.ts +0 -0
- /package/src/{types.ts → tools/types.ts} +0 -0
@@ -0,0 +1,943 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
2
|
+
import type {
|
3
|
+
AgentID,
|
4
|
+
BinaryStreamInfo,
|
5
|
+
CojsonInternalTypes,
|
6
|
+
JsonValue,
|
7
|
+
RawAccountID,
|
8
|
+
RawBinaryCoStream,
|
9
|
+
RawCoStream,
|
10
|
+
SessionID,
|
11
|
+
} from "cojson";
|
12
|
+
import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from "cojson";
|
13
|
+
import type {
|
14
|
+
AnonymousJazzAgent,
|
15
|
+
AnyAccountSchema,
|
16
|
+
CoValue,
|
17
|
+
CoValueClass,
|
18
|
+
Group,
|
19
|
+
ID,
|
20
|
+
InstanceOfSchema,
|
21
|
+
RefsToResolve,
|
22
|
+
RefsToResolveStrict,
|
23
|
+
Resolved,
|
24
|
+
Schema,
|
25
|
+
SchemaFor,
|
26
|
+
SubscribeListenerOptions,
|
27
|
+
SubscribeRestArgs,
|
28
|
+
} from "../internal.js";
|
29
|
+
import {
|
30
|
+
Account,
|
31
|
+
CoValueBase,
|
32
|
+
ItemsSym,
|
33
|
+
Ref,
|
34
|
+
RegisteredSchemas,
|
35
|
+
SchemaInit,
|
36
|
+
accessChildById,
|
37
|
+
anySchemaToCoSchema,
|
38
|
+
coField,
|
39
|
+
ensureCoValueLoaded,
|
40
|
+
inspect,
|
41
|
+
isRefEncoded,
|
42
|
+
loadCoValueWithoutMe,
|
43
|
+
parseCoValueCreateOptions,
|
44
|
+
parseSubscribeRestArgs,
|
45
|
+
subscribeToCoValueWithoutMe,
|
46
|
+
subscribeToExistingCoValue,
|
47
|
+
} from "../internal.js";
|
48
|
+
|
49
|
+
/** @deprecated Use CoFeedEntry instead */
|
50
|
+
export type CoStreamEntry<Item> = CoFeedEntry<Item>;
|
51
|
+
|
52
|
+
export type CoFeedEntry<Item> = SingleCoFeedEntry<Item> & {
|
53
|
+
all: IterableIterator<SingleCoFeedEntry<Item>>;
|
54
|
+
};
|
55
|
+
|
56
|
+
/** @deprecated Use SingleCoFeedEntry instead */
|
57
|
+
export type SingleCoStreamEntry<Item> = SingleCoFeedEntry<Item>;
|
58
|
+
|
59
|
+
export type SingleCoFeedEntry<Item> = {
|
60
|
+
value: NonNullable<Item> extends CoValue ? NonNullable<Item> | null : Item;
|
61
|
+
ref: NonNullable<Item> extends CoValue ? Ref<NonNullable<Item>> : never;
|
62
|
+
by: Account | null;
|
63
|
+
madeAt: Date;
|
64
|
+
tx: CojsonInternalTypes.TransactionID;
|
65
|
+
};
|
66
|
+
|
67
|
+
/** @deprecated Use CoFeed instead */
|
68
|
+
export { CoFeed as CoStream };
|
69
|
+
|
70
|
+
/**
|
71
|
+
* CoFeeds are collaborative logs of data.
|
72
|
+
*
|
73
|
+
* @categoryDescription Content
|
74
|
+
* They are similar to `CoList`s, but with a few key differences:
|
75
|
+
* - They are append-only
|
76
|
+
* - They consist of several internal append-only logs, one per account session (tab, device, app instance, etc.)
|
77
|
+
* - They expose those as a per-account aggregated view (default) or a precise per-session view
|
78
|
+
*
|
79
|
+
* ```ts
|
80
|
+
* favDog.push("Poodle");
|
81
|
+
* favDog.push("Schnowzer");
|
82
|
+
* ```
|
83
|
+
*
|
84
|
+
* @category CoValues
|
85
|
+
*/
|
86
|
+
export class CoFeed<out Item = any> extends CoValueBase implements CoValue {
|
87
|
+
/**
|
88
|
+
* Declare a `CoFeed` by subclassing `CoFeed.Of(...)` and passing the item schema using a `co` primitive or a `coField.ref`.
|
89
|
+
*
|
90
|
+
* @example
|
91
|
+
* ```ts
|
92
|
+
* class ColorFeed extends CoFeed.Of(coField.string) {}
|
93
|
+
* class AnimalFeed extends CoFeed.Of(coField.ref(Animal)) {}
|
94
|
+
* ```
|
95
|
+
*
|
96
|
+
* @category Declaration
|
97
|
+
*/
|
98
|
+
static Of<Item>(item: Item): typeof CoFeed<Item> {
|
99
|
+
const cls = class CoFeedOf extends CoFeed<Item> {
|
100
|
+
[coField.items] = item;
|
101
|
+
};
|
102
|
+
|
103
|
+
cls._schema ||= {};
|
104
|
+
cls._schema[ItemsSym] = (item as any)[SchemaInit];
|
105
|
+
|
106
|
+
return cls;
|
107
|
+
}
|
108
|
+
|
109
|
+
/**
|
110
|
+
* The ID of this `CoFeed`
|
111
|
+
* @category Content */
|
112
|
+
declare id: ID<this>;
|
113
|
+
/** @category Type Helpers */
|
114
|
+
declare _type: "CoStream";
|
115
|
+
static {
|
116
|
+
this.prototype._type = "CoStream";
|
117
|
+
}
|
118
|
+
/** @category Internals */
|
119
|
+
declare _raw: RawCoStream;
|
120
|
+
|
121
|
+
/** @internal This is only a marker type and doesn't exist at runtime */
|
122
|
+
[ItemsSym]!: Item;
|
123
|
+
/** @internal */
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
125
|
+
static _schema: any;
|
126
|
+
/** @internal */
|
127
|
+
get _schema(): {
|
128
|
+
[ItemsSym]: SchemaFor<Item> | any;
|
129
|
+
} {
|
130
|
+
return (this.constructor as typeof CoFeed)._schema;
|
131
|
+
}
|
132
|
+
/**
|
133
|
+
* The current account's view of this `CoFeed`
|
134
|
+
* @category Content
|
135
|
+
*/
|
136
|
+
get byMe(): CoFeedEntry<Item> | undefined {
|
137
|
+
if (this._loadedAs._type === "Account") {
|
138
|
+
return this.perAccount[this._loadedAs.id];
|
139
|
+
} else {
|
140
|
+
return undefined;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
/**
|
145
|
+
* The per-account view of this `CoFeed`
|
146
|
+
*
|
147
|
+
* @example
|
148
|
+
* ```ts
|
149
|
+
* // Access entries directly by account ID
|
150
|
+
* const aliceEntries = feed[aliceAccount.id];
|
151
|
+
* console.log(aliceEntries.value); // Latest value from Alice
|
152
|
+
*
|
153
|
+
* // Iterate through all accounts' entries
|
154
|
+
* for (const [accountId, entries] of Object.entries(feed)) {
|
155
|
+
* console.log(`Latest entry from ${accountId}:`, entries.value);
|
156
|
+
*
|
157
|
+
* // Access all entries from this account
|
158
|
+
* for (const entry of entries.all) {
|
159
|
+
* console.log(`Entry made at ${entry.madeAt}:`, entry.value);
|
160
|
+
* }
|
161
|
+
* }
|
162
|
+
* ```
|
163
|
+
*
|
164
|
+
* @category Content
|
165
|
+
*/
|
166
|
+
get perAccount(): {
|
167
|
+
[key: ID<Account>]: CoFeedEntry<Item>;
|
168
|
+
} {
|
169
|
+
return new Proxy({}, CoStreamPerAccountProxyHandler(this)) as any;
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* The per-session view of this `CoFeed`
|
174
|
+
* @category Content
|
175
|
+
*/
|
176
|
+
get perSession(): {
|
177
|
+
[key: SessionID]: CoFeedEntry<Item>;
|
178
|
+
} {
|
179
|
+
return new Proxy(
|
180
|
+
{},
|
181
|
+
CoStreamPerSessionProxyHandler(this, this) as any,
|
182
|
+
) as any;
|
183
|
+
}
|
184
|
+
|
185
|
+
/**
|
186
|
+
* The current session's view of this `CoFeed`
|
187
|
+
*
|
188
|
+
* This is a shortcut for `this.perSession` where the session ID is the current session ID.
|
189
|
+
*
|
190
|
+
* @category Content
|
191
|
+
*/
|
192
|
+
get inCurrentSession(): CoFeedEntry<Item> | undefined {
|
193
|
+
if (this._loadedAs._type === "Account") {
|
194
|
+
return this.perSession[this._loadedAs.sessionID!];
|
195
|
+
} else {
|
196
|
+
return undefined;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
constructor(
|
201
|
+
options:
|
202
|
+
| { init: Item[]; owner: Account | Group }
|
203
|
+
| { fromRaw: RawCoStream },
|
204
|
+
) {
|
205
|
+
super();
|
206
|
+
|
207
|
+
if (options && "fromRaw" in options) {
|
208
|
+
Object.defineProperties(this, {
|
209
|
+
id: {
|
210
|
+
value: options.fromRaw.id,
|
211
|
+
enumerable: false,
|
212
|
+
},
|
213
|
+
_raw: { value: options.fromRaw, enumerable: false },
|
214
|
+
});
|
215
|
+
}
|
216
|
+
|
217
|
+
return this;
|
218
|
+
}
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Create a new `CoFeed`
|
222
|
+
* @category Creation
|
223
|
+
*/
|
224
|
+
static create<S extends CoFeed>(
|
225
|
+
this: CoValueClass<S>,
|
226
|
+
init: S extends CoFeed<infer Item> ? Item[] : never,
|
227
|
+
options?: { owner: Account | Group } | Account | Group,
|
228
|
+
) {
|
229
|
+
const { owner } = parseCoValueCreateOptions(options);
|
230
|
+
const instance = new this({ init, owner });
|
231
|
+
const raw = owner._raw.createStream();
|
232
|
+
|
233
|
+
Object.defineProperties(instance, {
|
234
|
+
id: {
|
235
|
+
value: raw.id,
|
236
|
+
enumerable: false,
|
237
|
+
},
|
238
|
+
_raw: { value: raw, enumerable: false },
|
239
|
+
});
|
240
|
+
|
241
|
+
if (init) {
|
242
|
+
instance.push(...init);
|
243
|
+
}
|
244
|
+
return instance;
|
245
|
+
}
|
246
|
+
|
247
|
+
getItemsDescriptor() {
|
248
|
+
return this._schema?.[ItemsSym];
|
249
|
+
}
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Push items to this `CoFeed`
|
253
|
+
*
|
254
|
+
* Items are appended to the current session's log. Each session (tab, device, app instance)
|
255
|
+
* maintains its own append-only log, which is then aggregated into the per-account view.
|
256
|
+
*
|
257
|
+
* @example
|
258
|
+
* ```ts
|
259
|
+
* // Adds items to current session's log
|
260
|
+
* feed.push("item1", "item2");
|
261
|
+
*
|
262
|
+
* // View items from current session
|
263
|
+
* console.log(feed.inCurrentSession);
|
264
|
+
*
|
265
|
+
* // View aggregated items from all sessions for current account
|
266
|
+
* console.log(feed.byMe);
|
267
|
+
* ```
|
268
|
+
*
|
269
|
+
* @category Content
|
270
|
+
*/
|
271
|
+
push(...items: Item[]) {
|
272
|
+
for (const item of items) {
|
273
|
+
this.pushItem(item);
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
private pushItem(item: Item) {
|
278
|
+
const itemDescriptor = this._schema[ItemsSym] as Schema;
|
279
|
+
|
280
|
+
if (itemDescriptor === "json") {
|
281
|
+
this._raw.push(item as JsonValue);
|
282
|
+
} else if ("encoded" in itemDescriptor) {
|
283
|
+
this._raw.push(itemDescriptor.encoded.encode(item));
|
284
|
+
} else if (isRefEncoded(itemDescriptor)) {
|
285
|
+
this._raw.push((item as unknown as CoValue).id);
|
286
|
+
}
|
287
|
+
}
|
288
|
+
|
289
|
+
/**
|
290
|
+
* Get a JSON representation of the `CoFeed`
|
291
|
+
* @category
|
292
|
+
*/
|
293
|
+
toJSON(): {
|
294
|
+
id: string;
|
295
|
+
_type: "CoStream";
|
296
|
+
[key: string]: unknown;
|
297
|
+
in: { [key: string]: unknown };
|
298
|
+
} {
|
299
|
+
const itemDescriptor = this._schema[ItemsSym] as Schema;
|
300
|
+
const mapper =
|
301
|
+
itemDescriptor === "json"
|
302
|
+
? (v: unknown) => v
|
303
|
+
: "encoded" in itemDescriptor
|
304
|
+
? itemDescriptor.encoded.encode
|
305
|
+
: (v: unknown) => v && (v as CoValue).id;
|
306
|
+
|
307
|
+
return {
|
308
|
+
id: this.id,
|
309
|
+
_type: this._type,
|
310
|
+
...Object.fromEntries(
|
311
|
+
Object.entries(this).map(([account, entry]) => [
|
312
|
+
account,
|
313
|
+
mapper(entry.value),
|
314
|
+
]),
|
315
|
+
),
|
316
|
+
in: Object.fromEntries(
|
317
|
+
Object.entries(this.perSession).map(([session, entry]) => [
|
318
|
+
session,
|
319
|
+
mapper(entry.value),
|
320
|
+
]),
|
321
|
+
),
|
322
|
+
};
|
323
|
+
}
|
324
|
+
|
325
|
+
/** @internal */
|
326
|
+
[inspect](): {
|
327
|
+
id: string;
|
328
|
+
_type: "CoStream";
|
329
|
+
[key: string]: unknown;
|
330
|
+
in: { [key: string]: unknown };
|
331
|
+
} {
|
332
|
+
return this.toJSON();
|
333
|
+
}
|
334
|
+
|
335
|
+
/** @internal */
|
336
|
+
static schema<V extends CoFeed>(
|
337
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
338
|
+
this: { new (...args: any): V } & typeof CoFeed,
|
339
|
+
def: { [ItemsSym]: V["_schema"][ItemsSym] },
|
340
|
+
) {
|
341
|
+
this._schema ||= {};
|
342
|
+
Object.assign(this._schema, def);
|
343
|
+
}
|
344
|
+
|
345
|
+
/**
|
346
|
+
* Load a `CoFeed`
|
347
|
+
* @category Subscription & Loading
|
348
|
+
*/
|
349
|
+
static load<F extends CoFeed, const R extends RefsToResolve<F> = true>(
|
350
|
+
this: CoValueClass<F>,
|
351
|
+
id: ID<F>,
|
352
|
+
options: {
|
353
|
+
resolve?: RefsToResolveStrict<F, R>;
|
354
|
+
loadAs?: Account | AnonymousJazzAgent;
|
355
|
+
},
|
356
|
+
): Promise<Resolved<F, R> | null> {
|
357
|
+
return loadCoValueWithoutMe(this, id, options);
|
358
|
+
}
|
359
|
+
|
360
|
+
/**
|
361
|
+
* Subscribe to a `CoFeed`, when you have an ID but don't have a `CoFeed` instance yet
|
362
|
+
* @category Subscription & Loading
|
363
|
+
*/
|
364
|
+
static subscribe<F extends CoFeed, const R extends RefsToResolve<F> = true>(
|
365
|
+
this: CoValueClass<F>,
|
366
|
+
id: ID<F>,
|
367
|
+
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void,
|
368
|
+
): () => void;
|
369
|
+
static subscribe<F extends CoFeed, const R extends RefsToResolve<F> = true>(
|
370
|
+
this: CoValueClass<F>,
|
371
|
+
id: ID<F>,
|
372
|
+
options: SubscribeListenerOptions<F, R>,
|
373
|
+
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void,
|
374
|
+
): () => void;
|
375
|
+
static subscribe<F extends CoFeed, const R extends RefsToResolve<F>>(
|
376
|
+
this: CoValueClass<F>,
|
377
|
+
id: ID<F>,
|
378
|
+
...args: SubscribeRestArgs<F, R>
|
379
|
+
): () => void {
|
380
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
381
|
+
return subscribeToCoValueWithoutMe<F, R>(this, id, options, listener);
|
382
|
+
}
|
383
|
+
|
384
|
+
/**
|
385
|
+
* Ensure a `CoFeed` is loaded to the specified depth
|
386
|
+
*
|
387
|
+
* @returns A new instance of the same CoFeed that's loaded to the specified depth
|
388
|
+
* @category Subscription & Loading
|
389
|
+
*/
|
390
|
+
ensureLoaded<F extends CoFeed, const R extends RefsToResolve<F>>(
|
391
|
+
this: F,
|
392
|
+
options?: { resolve?: RefsToResolveStrict<F, R> },
|
393
|
+
): Promise<Resolved<F, R>> {
|
394
|
+
return ensureCoValueLoaded(this, options);
|
395
|
+
}
|
396
|
+
|
397
|
+
/**
|
398
|
+
* An instance method to subscribe to an existing `CoFeed`
|
399
|
+
*
|
400
|
+
* No need to provide an ID or Account since they're already part of the instance.
|
401
|
+
* @category Subscription & Loading
|
402
|
+
*/
|
403
|
+
subscribe<F extends CoFeed, const R extends RefsToResolve<F>>(
|
404
|
+
this: F,
|
405
|
+
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void,
|
406
|
+
): () => void;
|
407
|
+
subscribe<F extends CoFeed, const R extends RefsToResolve<F>>(
|
408
|
+
this: F,
|
409
|
+
options: { resolve?: RefsToResolveStrict<F, R> },
|
410
|
+
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void,
|
411
|
+
): () => void;
|
412
|
+
subscribe<F extends CoFeed, const R extends RefsToResolve<F>>(
|
413
|
+
this: F,
|
414
|
+
...args: SubscribeRestArgs<F, R>
|
415
|
+
): () => void {
|
416
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
417
|
+
return subscribeToExistingCoValue(this, options, listener);
|
418
|
+
}
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Wait for the `CoFeed` to be uploaded to the other peers.
|
422
|
+
*
|
423
|
+
* @category Subscription & Loading
|
424
|
+
*/
|
425
|
+
waitForSync(options?: {
|
426
|
+
timeout?: number;
|
427
|
+
}) {
|
428
|
+
return this._raw.core.waitForSync(options);
|
429
|
+
}
|
430
|
+
}
|
431
|
+
|
432
|
+
/**
|
433
|
+
* Converts a raw stream entry into a formatted CoFeed entry with proper typing and accessors.
|
434
|
+
* @internal
|
435
|
+
*/
|
436
|
+
function entryFromRawEntry<Item>(
|
437
|
+
accessFrom: CoValue,
|
438
|
+
rawEntry: {
|
439
|
+
by: RawAccountID | AgentID;
|
440
|
+
tx: CojsonInternalTypes.TransactionID;
|
441
|
+
at: Date;
|
442
|
+
value: JsonValue;
|
443
|
+
},
|
444
|
+
loadedAs: Account | AnonymousJazzAgent,
|
445
|
+
accountID: ID<Account> | undefined,
|
446
|
+
itemField: Schema,
|
447
|
+
): Omit<CoFeedEntry<Item>, "all"> {
|
448
|
+
return {
|
449
|
+
get value(): NonNullable<Item> extends CoValue
|
450
|
+
? (CoValue & Item) | null
|
451
|
+
: Item {
|
452
|
+
if (itemField === "json") {
|
453
|
+
return rawEntry.value as NonNullable<Item> extends CoValue
|
454
|
+
? (CoValue & Item) | null
|
455
|
+
: Item;
|
456
|
+
} else if ("encoded" in itemField) {
|
457
|
+
return itemField.encoded.decode(rawEntry.value);
|
458
|
+
} else if (isRefEncoded(itemField)) {
|
459
|
+
return accessChildById(
|
460
|
+
accessFrom,
|
461
|
+
rawEntry.value as string,
|
462
|
+
itemField,
|
463
|
+
) as NonNullable<Item> extends CoValue ? (CoValue & Item) | null : Item;
|
464
|
+
} else {
|
465
|
+
throw new Error("Invalid item field schema");
|
466
|
+
}
|
467
|
+
},
|
468
|
+
get ref(): NonNullable<Item> extends CoValue
|
469
|
+
? Ref<NonNullable<Item>>
|
470
|
+
: never {
|
471
|
+
if (itemField !== "json" && isRefEncoded(itemField)) {
|
472
|
+
const rawId = rawEntry.value;
|
473
|
+
return new Ref(
|
474
|
+
rawId as unknown as ID<CoValue>,
|
475
|
+
loadedAs,
|
476
|
+
itemField,
|
477
|
+
accessFrom,
|
478
|
+
) as NonNullable<Item> extends CoValue ? Ref<NonNullable<Item>> : never;
|
479
|
+
} else {
|
480
|
+
return undefined as never;
|
481
|
+
}
|
482
|
+
},
|
483
|
+
get by() {
|
484
|
+
return (
|
485
|
+
accountID &&
|
486
|
+
accessChildById(accessFrom, accountID, {
|
487
|
+
ref: Account,
|
488
|
+
optional: false,
|
489
|
+
})
|
490
|
+
);
|
491
|
+
},
|
492
|
+
madeAt: rawEntry.at,
|
493
|
+
tx: rawEntry.tx,
|
494
|
+
};
|
495
|
+
}
|
496
|
+
|
497
|
+
/**
|
498
|
+
* The proxy handler for `CoFeed` instances
|
499
|
+
* @internal
|
500
|
+
*/
|
501
|
+
export const CoStreamPerAccountProxyHandler = (
|
502
|
+
innerTarget: CoFeed,
|
503
|
+
): ProxyHandler<{}> => ({
|
504
|
+
get(_target, key, receiver) {
|
505
|
+
if (typeof key === "string" && key.startsWith("co_")) {
|
506
|
+
const rawEntry = innerTarget._raw.lastItemBy(key as RawAccountID);
|
507
|
+
|
508
|
+
if (!rawEntry) return;
|
509
|
+
const entry = entryFromRawEntry(
|
510
|
+
receiver,
|
511
|
+
rawEntry,
|
512
|
+
innerTarget._loadedAs,
|
513
|
+
key as unknown as ID<Account>,
|
514
|
+
innerTarget._schema[ItemsSym],
|
515
|
+
);
|
516
|
+
|
517
|
+
Object.defineProperty(entry, "all", {
|
518
|
+
get: () => {
|
519
|
+
const allRawEntries = innerTarget._raw.itemsBy(key as RawAccountID);
|
520
|
+
return (function* () {
|
521
|
+
while (true) {
|
522
|
+
const rawEntry = allRawEntries.next();
|
523
|
+
if (rawEntry.done) return;
|
524
|
+
yield entryFromRawEntry(
|
525
|
+
receiver,
|
526
|
+
rawEntry.value,
|
527
|
+
innerTarget._loadedAs,
|
528
|
+
key as unknown as ID<Account>,
|
529
|
+
innerTarget._schema[ItemsSym],
|
530
|
+
);
|
531
|
+
}
|
532
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
533
|
+
})() satisfies IterableIterator<SingleCoFeedEntry<any>>;
|
534
|
+
},
|
535
|
+
});
|
536
|
+
|
537
|
+
return entry;
|
538
|
+
} else {
|
539
|
+
return Reflect.get(innerTarget, key, receiver);
|
540
|
+
}
|
541
|
+
},
|
542
|
+
ownKeys(_target) {
|
543
|
+
return Array.from(innerTarget._raw.accounts());
|
544
|
+
},
|
545
|
+
getOwnPropertyDescriptor(_target, key) {
|
546
|
+
if (typeof key === "string" && key.startsWith("co_")) {
|
547
|
+
return {
|
548
|
+
configurable: true,
|
549
|
+
enumerable: true,
|
550
|
+
writable: false,
|
551
|
+
};
|
552
|
+
} else {
|
553
|
+
return Reflect.getOwnPropertyDescriptor(innerTarget, key);
|
554
|
+
}
|
555
|
+
},
|
556
|
+
});
|
557
|
+
|
558
|
+
/**
|
559
|
+
* The proxy handler for the per-session view of a `CoFeed`
|
560
|
+
* @internal
|
561
|
+
*/
|
562
|
+
const CoStreamPerSessionProxyHandler = (
|
563
|
+
innerTarget: CoFeed,
|
564
|
+
accessFrom: CoFeed,
|
565
|
+
): ProxyHandler<Record<string, never>> => ({
|
566
|
+
get(_target, key, receiver) {
|
567
|
+
if (typeof key === "string" && key.includes("session")) {
|
568
|
+
const sessionID = key as SessionID;
|
569
|
+
const rawEntry = innerTarget._raw.lastItemIn(sessionID);
|
570
|
+
|
571
|
+
if (!rawEntry) return;
|
572
|
+
const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
|
573
|
+
|
574
|
+
const entry = entryFromRawEntry(
|
575
|
+
accessFrom,
|
576
|
+
rawEntry,
|
577
|
+
innerTarget._loadedAs,
|
578
|
+
cojsonInternals.isAccountID(by)
|
579
|
+
? (by as unknown as ID<Account>)
|
580
|
+
: undefined,
|
581
|
+
innerTarget._schema[ItemsSym],
|
582
|
+
);
|
583
|
+
|
584
|
+
Object.defineProperty(entry, "all", {
|
585
|
+
get: () => {
|
586
|
+
const allRawEntries = innerTarget._raw.itemsIn(sessionID);
|
587
|
+
return (function* () {
|
588
|
+
while (true) {
|
589
|
+
const rawEntry = allRawEntries.next();
|
590
|
+
if (rawEntry.done) return;
|
591
|
+
yield entryFromRawEntry(
|
592
|
+
accessFrom,
|
593
|
+
rawEntry.value,
|
594
|
+
innerTarget._loadedAs,
|
595
|
+
cojsonInternals.isAccountID(by)
|
596
|
+
? (by as unknown as ID<Account>)
|
597
|
+
: undefined,
|
598
|
+
innerTarget._schema[ItemsSym],
|
599
|
+
);
|
600
|
+
}
|
601
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
602
|
+
})() satisfies IterableIterator<SingleCoFeedEntry<any>>;
|
603
|
+
},
|
604
|
+
});
|
605
|
+
|
606
|
+
return entry;
|
607
|
+
} else {
|
608
|
+
return Reflect.get(innerTarget, key, receiver);
|
609
|
+
}
|
610
|
+
},
|
611
|
+
ownKeys() {
|
612
|
+
return innerTarget._raw.sessions();
|
613
|
+
},
|
614
|
+
getOwnPropertyDescriptor(target, key) {
|
615
|
+
if (typeof key === "string" && key.startsWith("co_")) {
|
616
|
+
return {
|
617
|
+
configurable: true,
|
618
|
+
enumerable: true,
|
619
|
+
writable: false,
|
620
|
+
};
|
621
|
+
} else {
|
622
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
623
|
+
}
|
624
|
+
},
|
625
|
+
});
|
626
|
+
|
627
|
+
/** @deprecated Use FileStream instead */
|
628
|
+
export { FileStream as BinaryCoStream };
|
629
|
+
|
630
|
+
/**
|
631
|
+
* FileStreams are `CoFeed`s that contain binary data, collaborative versions of `Blob`s.
|
632
|
+
*
|
633
|
+
* @categoryDescription Declaration
|
634
|
+
* `FileStream` can be referenced in schemas.
|
635
|
+
*
|
636
|
+
* ```ts
|
637
|
+
* import { coField, FileStream } from "jazz-tools";
|
638
|
+
*
|
639
|
+
* class MyCoMap extends CoMap {
|
640
|
+
* file = coField.ref(FileStream);
|
641
|
+
* }
|
642
|
+
* ```
|
643
|
+
*
|
644
|
+
* @category CoValues
|
645
|
+
*/
|
646
|
+
export class FileStream extends CoValueBase implements CoValue {
|
647
|
+
/**
|
648
|
+
* The ID of this `FileStream`
|
649
|
+
* @category Content
|
650
|
+
*/
|
651
|
+
declare id: ID<this>;
|
652
|
+
/** @category Type Helpers */
|
653
|
+
declare _type: "BinaryCoStream";
|
654
|
+
/** @internal */
|
655
|
+
declare _raw: RawBinaryCoStream;
|
656
|
+
|
657
|
+
constructor(
|
658
|
+
options:
|
659
|
+
| {
|
660
|
+
owner: Account | Group;
|
661
|
+
}
|
662
|
+
| {
|
663
|
+
fromRaw: RawBinaryCoStream;
|
664
|
+
},
|
665
|
+
) {
|
666
|
+
super();
|
667
|
+
|
668
|
+
let raw: RawBinaryCoStream;
|
669
|
+
|
670
|
+
if ("fromRaw" in options) {
|
671
|
+
raw = options.fromRaw;
|
672
|
+
} else {
|
673
|
+
const rawOwner = options.owner._raw;
|
674
|
+
raw = rawOwner.createBinaryStream();
|
675
|
+
}
|
676
|
+
|
677
|
+
Object.defineProperties(this, {
|
678
|
+
id: {
|
679
|
+
value: raw.id,
|
680
|
+
enumerable: false,
|
681
|
+
},
|
682
|
+
_type: { value: "BinaryCoStream", enumerable: false },
|
683
|
+
_raw: { value: raw, enumerable: false },
|
684
|
+
});
|
685
|
+
}
|
686
|
+
|
687
|
+
/**
|
688
|
+
* Create a new empty `FileStream` instance.
|
689
|
+
*
|
690
|
+
* @param options - Configuration options for the new FileStream
|
691
|
+
* @param options.owner - The Account or Group that will own this FileStream and control access rights
|
692
|
+
*
|
693
|
+
* @example
|
694
|
+
* ```typescript
|
695
|
+
* // Create owned by an account
|
696
|
+
* const stream = FileStream.create({ owner: myAccount });
|
697
|
+
*
|
698
|
+
* // Create owned by a group
|
699
|
+
* const stream = FileStream.create({ owner: teamGroup });
|
700
|
+
*
|
701
|
+
* // Create with implicit owner
|
702
|
+
* const stream = FileStream.create(myAccount);
|
703
|
+
* ```
|
704
|
+
*
|
705
|
+
* @remarks
|
706
|
+
* For uploading an existing file or blob, use {@link FileStream.createFromBlob} instead.
|
707
|
+
*
|
708
|
+
* @category Creation
|
709
|
+
*/
|
710
|
+
static create<S extends FileStream>(
|
711
|
+
this: CoValueClass<S>,
|
712
|
+
options?: { owner?: Account | Group } | Account | Group,
|
713
|
+
) {
|
714
|
+
return new this(parseCoValueCreateOptions(options));
|
715
|
+
}
|
716
|
+
|
717
|
+
getMetadata(): BinaryStreamInfo | undefined {
|
718
|
+
return this._raw.getBinaryStreamInfo();
|
719
|
+
}
|
720
|
+
|
721
|
+
getChunks(options?: {
|
722
|
+
allowUnfinished?: boolean;
|
723
|
+
}):
|
724
|
+
| (BinaryStreamInfo & { chunks: Uint8Array[]; finished: boolean })
|
725
|
+
| undefined {
|
726
|
+
return this._raw.getBinaryChunks(options?.allowUnfinished);
|
727
|
+
}
|
728
|
+
|
729
|
+
isBinaryStreamEnded(): boolean {
|
730
|
+
return this._raw.isBinaryStreamEnded();
|
731
|
+
}
|
732
|
+
|
733
|
+
start(options: BinaryStreamInfo): void {
|
734
|
+
this._raw.startBinaryStream(options);
|
735
|
+
}
|
736
|
+
|
737
|
+
push(data: Uint8Array): void {
|
738
|
+
this._raw.pushBinaryStreamChunk(data);
|
739
|
+
}
|
740
|
+
|
741
|
+
end(): void {
|
742
|
+
this._raw.endBinaryStream();
|
743
|
+
}
|
744
|
+
|
745
|
+
toBlob(options?: { allowUnfinished?: boolean }): Blob | undefined {
|
746
|
+
const chunks = this.getChunks({
|
747
|
+
allowUnfinished: options?.allowUnfinished,
|
748
|
+
});
|
749
|
+
|
750
|
+
if (!chunks) {
|
751
|
+
return undefined;
|
752
|
+
}
|
753
|
+
|
754
|
+
// @ts-ignore
|
755
|
+
return new Blob(chunks.chunks, { type: chunks.mimeType });
|
756
|
+
}
|
757
|
+
|
758
|
+
/**
|
759
|
+
* Load a `FileStream` as a `Blob`
|
760
|
+
*
|
761
|
+
* @category Content
|
762
|
+
*/
|
763
|
+
static async loadAsBlob(
|
764
|
+
id: ID<FileStream>,
|
765
|
+
options?: {
|
766
|
+
allowUnfinished?: boolean;
|
767
|
+
loadAs?: Account | AnonymousJazzAgent;
|
768
|
+
},
|
769
|
+
): Promise<Blob | undefined> {
|
770
|
+
let stream = await this.load(id, options);
|
771
|
+
|
772
|
+
return stream?.toBlob({
|
773
|
+
allowUnfinished: options?.allowUnfinished,
|
774
|
+
});
|
775
|
+
}
|
776
|
+
|
777
|
+
/**
|
778
|
+
* Create a `FileStream` from a `Blob` or `File`
|
779
|
+
*
|
780
|
+
* @example
|
781
|
+
* ```ts
|
782
|
+
* import { coField, FileStream } from "jazz-tools";
|
783
|
+
*
|
784
|
+
* const fileStream = await FileStream.createFromBlob(file, {owner: group})
|
785
|
+
* ```
|
786
|
+
* @category Content
|
787
|
+
*/
|
788
|
+
static async createFromBlob(
|
789
|
+
blob: Blob | File,
|
790
|
+
options?:
|
791
|
+
| {
|
792
|
+
owner?: Group | Account;
|
793
|
+
onProgress?: (progress: number) => void;
|
794
|
+
}
|
795
|
+
| Account
|
796
|
+
| Group,
|
797
|
+
): Promise<FileStream> {
|
798
|
+
const stream = this.create(options);
|
799
|
+
const onProgress =
|
800
|
+
options && "onProgress" in options ? options.onProgress : undefined;
|
801
|
+
|
802
|
+
const start = Date.now();
|
803
|
+
|
804
|
+
const data = new Uint8Array(await blob.arrayBuffer());
|
805
|
+
stream.start({
|
806
|
+
mimeType: blob.type,
|
807
|
+
totalSizeBytes: blob.size,
|
808
|
+
fileName: blob instanceof File ? blob.name : undefined,
|
809
|
+
});
|
810
|
+
const chunkSize = MAX_RECOMMENDED_TX_SIZE;
|
811
|
+
|
812
|
+
let lastProgressUpdate = Date.now();
|
813
|
+
|
814
|
+
for (let idx = 0; idx < data.length; idx += chunkSize) {
|
815
|
+
stream.push(data.slice(idx, idx + chunkSize));
|
816
|
+
|
817
|
+
if (Date.now() - lastProgressUpdate > 100) {
|
818
|
+
onProgress?.(idx / data.length);
|
819
|
+
lastProgressUpdate = Date.now();
|
820
|
+
}
|
821
|
+
|
822
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
823
|
+
}
|
824
|
+
stream.end();
|
825
|
+
const end = Date.now();
|
826
|
+
|
827
|
+
console.debug(
|
828
|
+
"Finished creating binary stream in",
|
829
|
+
(end - start) / 1000,
|
830
|
+
"s - Throughput in MB/s",
|
831
|
+
(1000 * (blob.size / (end - start))) / (1024 * 1024),
|
832
|
+
);
|
833
|
+
onProgress?.(1);
|
834
|
+
|
835
|
+
return stream;
|
836
|
+
}
|
837
|
+
|
838
|
+
/**
|
839
|
+
* Get a JSON representation of the `FileStream`
|
840
|
+
* @category Content
|
841
|
+
*/
|
842
|
+
toJSON(): {
|
843
|
+
id: string;
|
844
|
+
_type: "BinaryCoStream";
|
845
|
+
mimeType?: string;
|
846
|
+
totalSizeBytes?: number;
|
847
|
+
fileName?: string;
|
848
|
+
chunks?: Uint8Array[];
|
849
|
+
finished?: boolean;
|
850
|
+
} {
|
851
|
+
return {
|
852
|
+
id: this.id,
|
853
|
+
_type: this._type,
|
854
|
+
...this.getChunks(),
|
855
|
+
};
|
856
|
+
}
|
857
|
+
|
858
|
+
/** @internal */
|
859
|
+
[inspect]() {
|
860
|
+
return this.toJSON();
|
861
|
+
}
|
862
|
+
|
863
|
+
/**
|
864
|
+
* Load a `FileStream`
|
865
|
+
* @category Subscription & Loading
|
866
|
+
*/
|
867
|
+
static async load<C extends FileStream>(
|
868
|
+
this: CoValueClass<C>,
|
869
|
+
id: ID<C>,
|
870
|
+
options?: {
|
871
|
+
loadAs?: Account | AnonymousJazzAgent;
|
872
|
+
allowUnfinished?: boolean;
|
873
|
+
},
|
874
|
+
): Promise<FileStream | null> {
|
875
|
+
const stream = await loadCoValueWithoutMe(this, id, options);
|
876
|
+
|
877
|
+
/**
|
878
|
+
* If the user hasn't requested an incomplete blob and the
|
879
|
+
* stream isn't complete wait for the stream download before progressing
|
880
|
+
*/
|
881
|
+
if (!options?.allowUnfinished && !stream?.isBinaryStreamEnded()) {
|
882
|
+
return new Promise<FileStream>((resolve) => {
|
883
|
+
subscribeToCoValueWithoutMe(
|
884
|
+
this,
|
885
|
+
id,
|
886
|
+
options || {},
|
887
|
+
(value, unsubscribe) => {
|
888
|
+
if (value.isBinaryStreamEnded()) {
|
889
|
+
unsubscribe();
|
890
|
+
resolve(value);
|
891
|
+
}
|
892
|
+
},
|
893
|
+
);
|
894
|
+
});
|
895
|
+
}
|
896
|
+
|
897
|
+
return stream;
|
898
|
+
}
|
899
|
+
|
900
|
+
/**
|
901
|
+
* Subscribe to a `FileStream`, when you have an ID but don't have a `FileStream` instance yet
|
902
|
+
* @category Subscription & Loading
|
903
|
+
*/
|
904
|
+
static subscribe<F extends FileStream, const R extends RefsToResolve<F>>(
|
905
|
+
this: CoValueClass<F>,
|
906
|
+
id: ID<F>,
|
907
|
+
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void,
|
908
|
+
): () => void;
|
909
|
+
static subscribe<F extends FileStream, const R extends RefsToResolve<F>>(
|
910
|
+
this: CoValueClass<F>,
|
911
|
+
id: ID<F>,
|
912
|
+
options: SubscribeListenerOptions<F, R>,
|
913
|
+
listener: (value: Resolved<F, R>, unsubscribe: () => void) => void,
|
914
|
+
): () => void;
|
915
|
+
static subscribe<F extends FileStream, const R extends RefsToResolve<F>>(
|
916
|
+
this: CoValueClass<F>,
|
917
|
+
id: ID<F>,
|
918
|
+
...args: SubscribeRestArgs<F, R>
|
919
|
+
): () => void {
|
920
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
921
|
+
return subscribeToCoValueWithoutMe<F, R>(this, id, options, listener);
|
922
|
+
}
|
923
|
+
|
924
|
+
/**
|
925
|
+
* An instance method to subscribe to an existing `FileStream`
|
926
|
+
* @category Subscription & Loading
|
927
|
+
*/
|
928
|
+
subscribe<B extends FileStream>(
|
929
|
+
this: B,
|
930
|
+
listener: (value: Resolved<B, true>) => void,
|
931
|
+
): () => void {
|
932
|
+
return subscribeToExistingCoValue(this, {}, listener);
|
933
|
+
}
|
934
|
+
|
935
|
+
/**
|
936
|
+
* Wait for the `FileStream` to be uploaded to the other peers.
|
937
|
+
*
|
938
|
+
* @category Subscription & Loading
|
939
|
+
*/
|
940
|
+
waitForSync(options?: { timeout?: number }) {
|
941
|
+
return this._raw.core.waitForSync(options);
|
942
|
+
}
|
943
|
+
}
|