jazz-tools 0.14.28 → 0.15.1
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 +26 -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-VBDJM6Z5.js +4938 -0
- package/dist/chunk-VBDJM6Z5.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 +2053 -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-open-inspector.d.ts +2 -0
- package/dist/inspector/viewer/use-open-inspector.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 +698 -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 +3 -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 +653 -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 +377 -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 +625 -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 +116 -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 +64 -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 +15 -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 +47 -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 +172 -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-open-inspector.ts +18 -0
- package/src/inspector/viewer/use-page-path.ts +65 -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 +79 -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 +981 -0
- package/src/tools/coValues/coMap.ts +929 -0
- package/src/tools/coValues/interfaces.ts +464 -0
- package/src/tools/exports.ts +117 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +188 -0
- package/src/tools/implementation/zodSchema/zodCo.ts +370 -0
- package/src/tools/index.ts +8 -0
- package/src/tools/subscribe/CoValueCoreSubscription.ts +74 -0
- package/src/tools/subscribe/SubscriptionScope.ts +626 -0
- package/src/tools/testing.ts +301 -0
- package/src/tools/tests/coFeed.test.ts +840 -0
- package/src/tools/tests/coMap.test.ts +2113 -0
- package/src/tools/tests/fixtures.ts +2050 -0
- package/src/tools/tests/load.test.ts +117 -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-AUQIX4E7.js +0 -4827
- package/dist/chunk-AUQIX4E7.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 -368
- package/dist/coValues/coFeed.d.ts.map +0 -1
- package/dist/coValues/coList.d.ts.map +0 -1
- package/dist/coValues/coMap.d.ts +0 -529
- 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 +0 -113
- 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 +0 -52
- 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 +0 -14
- package/dist/subscribe/CoValueCoreSubscription.d.ts.map +0 -1
- package/dist/subscribe/JazzError.d.ts.map +0 -1
- package/dist/subscribe/SubscriptionScope.d.ts +0 -46
- 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 -943
- package/src/coValues/coMap.ts +0 -825
- package/src/coValues/interfaces.ts +0 -454
- package/src/exports.ts +0 -108
- package/src/implementation/zodSchema/schemaTypes/CoMapSchema.ts +0 -150
- package/src/implementation/zodSchema/zodCo.ts +0 -364
- package/src/subscribe/CoValueCoreSubscription.ts +0 -71
- package/src/subscribe/SubscriptionScope.ts +0 -614
- package/src/tests/coFeed.test.ts +0 -771
- package/src/tests/coMap.test.ts +0 -1637
- package/src/tests/load.test.ts +0 -116
- /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}/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}/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/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}/JazzError.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}/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}/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/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/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}/JazzError.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}/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}/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,929 @@
|
|
1
|
+
import {
|
2
|
+
AgentID,
|
3
|
+
type CoValueUniqueness,
|
4
|
+
CojsonInternalTypes,
|
5
|
+
type JsonValue,
|
6
|
+
RawAccountID,
|
7
|
+
RawCoID,
|
8
|
+
type RawCoMap,
|
9
|
+
cojsonInternals,
|
10
|
+
} from "cojson";
|
11
|
+
import type {
|
12
|
+
AnonymousJazzAgent,
|
13
|
+
CoValue,
|
14
|
+
CoValueClass,
|
15
|
+
Group,
|
16
|
+
ID,
|
17
|
+
RefEncoded,
|
18
|
+
RefIfCoValue,
|
19
|
+
RefsToResolve,
|
20
|
+
RefsToResolveStrict,
|
21
|
+
Resolved,
|
22
|
+
Schema,
|
23
|
+
SubscribeListenerOptions,
|
24
|
+
SubscribeRestArgs,
|
25
|
+
} from "../internal.js";
|
26
|
+
import {
|
27
|
+
Account,
|
28
|
+
CoValueBase,
|
29
|
+
ItemsSym,
|
30
|
+
Ref,
|
31
|
+
RegisteredSchemas,
|
32
|
+
SchemaInit,
|
33
|
+
accessChildById,
|
34
|
+
accessChildByKey,
|
35
|
+
activeAccountContext,
|
36
|
+
ensureCoValueLoaded,
|
37
|
+
inspect,
|
38
|
+
isRefEncoded,
|
39
|
+
loadCoValueWithoutMe,
|
40
|
+
makeRefs,
|
41
|
+
parseCoValueCreateOptions,
|
42
|
+
parseSubscribeRestArgs,
|
43
|
+
subscribeToCoValueWithoutMe,
|
44
|
+
subscribeToExistingCoValue,
|
45
|
+
} from "../internal.js";
|
46
|
+
|
47
|
+
type CoMapEdit<V> = {
|
48
|
+
value?: V;
|
49
|
+
ref?: RefIfCoValue<V>;
|
50
|
+
by: Account | null;
|
51
|
+
madeAt: Date;
|
52
|
+
key?: string;
|
53
|
+
};
|
54
|
+
|
55
|
+
type LastAndAllCoMapEdits<V> = CoMapEdit<V> & { all: CoMapEdit<V>[] };
|
56
|
+
|
57
|
+
export type Simplify<A> = {
|
58
|
+
[K in keyof A]: A[K];
|
59
|
+
} extends infer B
|
60
|
+
? B
|
61
|
+
: never;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* CoMaps are collaborative versions of plain objects, mapping string-like keys to values.
|
65
|
+
*
|
66
|
+
* @categoryDescription Declaration
|
67
|
+
* Declare your own CoMap schemas by subclassing `CoMap` and assigning field schemas with `co`.
|
68
|
+
*
|
69
|
+
* Optional `coField.ref(...)` fields must be marked with `{ optional: true }`.
|
70
|
+
*
|
71
|
+
* ```ts
|
72
|
+
* import { coField, CoMap } from "jazz-tools";
|
73
|
+
*
|
74
|
+
* class Person extends CoMap {
|
75
|
+
* name = coField.string;
|
76
|
+
* age = coField.number;
|
77
|
+
* pet = coField.ref(Animal);
|
78
|
+
* car = coField.ref(Car, { optional: true });
|
79
|
+
* }
|
80
|
+
* ```
|
81
|
+
*
|
82
|
+
* @categoryDescription Content
|
83
|
+
* You can access properties you declare on a `CoMap` (using `co`) as if they were normal properties on a plain object, using dot notation, `Object.keys()`, etc.
|
84
|
+
*
|
85
|
+
* ```ts
|
86
|
+
* person.name;
|
87
|
+
* person["age"];
|
88
|
+
* person.age = 42;
|
89
|
+
* person.pet?.name;
|
90
|
+
* Object.keys(person);
|
91
|
+
* // => ["name", "age", "pet"]
|
92
|
+
* ```
|
93
|
+
*
|
94
|
+
* @category CoValues
|
95
|
+
* */
|
96
|
+
export class CoMap extends CoValueBase implements CoValue {
|
97
|
+
/**
|
98
|
+
* The ID of this `CoMap`
|
99
|
+
* @category Content */
|
100
|
+
declare id: ID<this>;
|
101
|
+
/** @category Type Helpers */
|
102
|
+
declare _type: "CoMap";
|
103
|
+
static {
|
104
|
+
this.prototype._type = "CoMap";
|
105
|
+
}
|
106
|
+
/** @category Internals */
|
107
|
+
declare _raw: RawCoMap;
|
108
|
+
|
109
|
+
/** @internal */
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
111
|
+
static _schema: any;
|
112
|
+
/** @internal */
|
113
|
+
get _schema() {
|
114
|
+
return (this.constructor as typeof CoMap)._schema as {
|
115
|
+
[key: string]: Schema;
|
116
|
+
} & { [ItemsSym]?: Schema };
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* The timestamp of the creation time of the CoMap
|
121
|
+
*/
|
122
|
+
get _createdAt() {
|
123
|
+
return this._raw.earliestTxMadeAt ?? Number.MAX_SAFE_INTEGER;
|
124
|
+
}
|
125
|
+
|
126
|
+
/**
|
127
|
+
* The timestamp of the last updated time of the CoMap
|
128
|
+
*/
|
129
|
+
get _lastUpdatedAt() {
|
130
|
+
return this._raw.latestTxMadeAt;
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
* If property `prop` is a `coField.ref(...)`, you can use `coMaps._refs.prop` to access
|
135
|
+
* the `Ref` instead of the potentially loaded/null value.
|
136
|
+
*
|
137
|
+
* This allows you to always get the ID or load the value manually.
|
138
|
+
*
|
139
|
+
* @example
|
140
|
+
* ```ts
|
141
|
+
* person._refs.pet.id; // => ID<Animal>
|
142
|
+
* person._refs.pet.value;
|
143
|
+
* // => Animal | null
|
144
|
+
* const pet = await person._refs.pet.load();
|
145
|
+
* ```
|
146
|
+
*
|
147
|
+
* @category Content
|
148
|
+
**/
|
149
|
+
get _refs(): Simplify<
|
150
|
+
{
|
151
|
+
[Key in CoKeys<this> as NonNullable<this[Key]> extends CoValue
|
152
|
+
? Key
|
153
|
+
: never]?: RefIfCoValue<this[Key]>;
|
154
|
+
} & {
|
155
|
+
[Key in CoKeys<this> as this[Key] extends undefined
|
156
|
+
? never
|
157
|
+
: this[Key] extends CoValue
|
158
|
+
? Key
|
159
|
+
: never]: RefIfCoValue<this[Key]>;
|
160
|
+
}
|
161
|
+
> {
|
162
|
+
return makeRefs<CoKeys<this>>(
|
163
|
+
this,
|
164
|
+
(key) => this._raw.get(key as string) as unknown as ID<CoValue>,
|
165
|
+
() => {
|
166
|
+
const keys = this._raw.keys().filter((key) => {
|
167
|
+
const descriptor = this.getDescriptor(key as string);
|
168
|
+
return (
|
169
|
+
descriptor && descriptor !== "json" && isRefEncoded(descriptor)
|
170
|
+
);
|
171
|
+
}) as CoKeys<this>[];
|
172
|
+
|
173
|
+
return keys;
|
174
|
+
},
|
175
|
+
this._loadedAs,
|
176
|
+
(key) => this.getDescriptor(key as string) as RefEncoded<CoValue>,
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
178
|
+
) as any;
|
179
|
+
}
|
180
|
+
|
181
|
+
/** @internal */
|
182
|
+
public getEditFromRaw(
|
183
|
+
target: CoMap,
|
184
|
+
rawEdit: {
|
185
|
+
by: RawAccountID | AgentID;
|
186
|
+
tx: CojsonInternalTypes.TransactionID;
|
187
|
+
at: Date;
|
188
|
+
value?: JsonValue | undefined;
|
189
|
+
},
|
190
|
+
descriptor: Schema,
|
191
|
+
key: string,
|
192
|
+
) {
|
193
|
+
return {
|
194
|
+
value:
|
195
|
+
descriptor === "json"
|
196
|
+
? rawEdit.value
|
197
|
+
: "encoded" in descriptor
|
198
|
+
? rawEdit.value === null || rawEdit.value === undefined
|
199
|
+
? rawEdit.value
|
200
|
+
: descriptor.encoded.decode(rawEdit.value)
|
201
|
+
: accessChildById(target, rawEdit.value as string, descriptor),
|
202
|
+
ref:
|
203
|
+
descriptor !== "json" && isRefEncoded(descriptor)
|
204
|
+
? new Ref(
|
205
|
+
rawEdit.value as ID<CoValue>,
|
206
|
+
target._loadedAs,
|
207
|
+
descriptor,
|
208
|
+
target,
|
209
|
+
)
|
210
|
+
: undefined,
|
211
|
+
get by() {
|
212
|
+
return (
|
213
|
+
rawEdit.by &&
|
214
|
+
accessChildById(target, rawEdit.by, {
|
215
|
+
ref: Account,
|
216
|
+
optional: false,
|
217
|
+
})
|
218
|
+
);
|
219
|
+
},
|
220
|
+
madeAt: rawEdit.at,
|
221
|
+
key,
|
222
|
+
};
|
223
|
+
}
|
224
|
+
|
225
|
+
/** @category Collaboration */
|
226
|
+
get _edits() {
|
227
|
+
const map = this;
|
228
|
+
return new Proxy(
|
229
|
+
{},
|
230
|
+
{
|
231
|
+
get(_target, key) {
|
232
|
+
const rawEdit = map._raw.lastEditAt(key as string);
|
233
|
+
if (!rawEdit) return undefined;
|
234
|
+
|
235
|
+
const descriptor = map.getDescriptor(key as string);
|
236
|
+
|
237
|
+
if (!descriptor) return undefined;
|
238
|
+
|
239
|
+
return {
|
240
|
+
...map.getEditFromRaw(map, rawEdit, descriptor, key as string),
|
241
|
+
get all() {
|
242
|
+
return [...map._raw.editsAt(key as string)].map((rawEdit) =>
|
243
|
+
map.getEditFromRaw(map, rawEdit, descriptor, key as string),
|
244
|
+
);
|
245
|
+
},
|
246
|
+
};
|
247
|
+
},
|
248
|
+
ownKeys(_target) {
|
249
|
+
return map._raw.keys();
|
250
|
+
},
|
251
|
+
getOwnPropertyDescriptor(target, key) {
|
252
|
+
return {
|
253
|
+
value: Reflect.get(target, key),
|
254
|
+
writable: false,
|
255
|
+
enumerable: true,
|
256
|
+
configurable: true,
|
257
|
+
};
|
258
|
+
},
|
259
|
+
},
|
260
|
+
) as {
|
261
|
+
[Key in CoKeys<this>]?: LastAndAllCoMapEdits<this[Key]>;
|
262
|
+
};
|
263
|
+
}
|
264
|
+
|
265
|
+
/** @internal */
|
266
|
+
constructor(
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
268
|
+
options: { fromRaw: RawCoMap } | undefined,
|
269
|
+
) {
|
270
|
+
super();
|
271
|
+
|
272
|
+
if (options) {
|
273
|
+
if ("fromRaw" in options) {
|
274
|
+
Object.defineProperties(this, {
|
275
|
+
id: {
|
276
|
+
value: options.fromRaw.id as unknown as ID<this>,
|
277
|
+
enumerable: false,
|
278
|
+
},
|
279
|
+
_raw: { value: options.fromRaw, enumerable: false },
|
280
|
+
});
|
281
|
+
} else {
|
282
|
+
throw new Error("Invalid CoMap constructor arguments");
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
return new Proxy(this, CoMapProxyHandler as ProxyHandler<this>);
|
287
|
+
}
|
288
|
+
|
289
|
+
/**
|
290
|
+
* Create a new CoMap with the given initial values and owner.
|
291
|
+
*
|
292
|
+
* The owner (a Group or Account) determines access rights to the CoMap.
|
293
|
+
*
|
294
|
+
* The CoMap will immediately be persisted and synced to connected peers.
|
295
|
+
*
|
296
|
+
* @example
|
297
|
+
* ```ts
|
298
|
+
* const person = Person.create({
|
299
|
+
* name: "Alice",
|
300
|
+
* age: 42,
|
301
|
+
* pet: cat,
|
302
|
+
* }, { owner: friendGroup });
|
303
|
+
* ```
|
304
|
+
*
|
305
|
+
* @category Creation
|
306
|
+
**/
|
307
|
+
static create<M extends CoMap>(
|
308
|
+
this: CoValueClass<M>,
|
309
|
+
init: Simplify<CoMapInit<M>>,
|
310
|
+
options?:
|
311
|
+
| {
|
312
|
+
owner: Account | Group;
|
313
|
+
unique?: CoValueUniqueness["uniqueness"];
|
314
|
+
}
|
315
|
+
| Account
|
316
|
+
| Group,
|
317
|
+
) {
|
318
|
+
const instance = new this();
|
319
|
+
|
320
|
+
return instance._createCoMap(init, options);
|
321
|
+
}
|
322
|
+
|
323
|
+
/**
|
324
|
+
* Return a JSON representation of the `CoMap`
|
325
|
+
* @category Content
|
326
|
+
*/
|
327
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
328
|
+
toJSON(_key?: string, processedValues?: ID<CoValue>[]): any {
|
329
|
+
const result = {
|
330
|
+
id: this.id,
|
331
|
+
_type: this._type,
|
332
|
+
} as Record<string, any>;
|
333
|
+
|
334
|
+
for (const key of this._raw.keys()) {
|
335
|
+
const tKey = key as CoKeys<this>;
|
336
|
+
const descriptor = this.getDescriptor(tKey);
|
337
|
+
|
338
|
+
if (!descriptor) {
|
339
|
+
continue;
|
340
|
+
}
|
341
|
+
|
342
|
+
if (descriptor == "json" || "encoded" in descriptor) {
|
343
|
+
result[key] = this._raw.get(key);
|
344
|
+
} else if (isRefEncoded(descriptor)) {
|
345
|
+
const id = this._raw.get(key) as ID<CoValue>;
|
346
|
+
|
347
|
+
if (processedValues?.includes(id) || id === this.id) {
|
348
|
+
result[key] = { _circular: id };
|
349
|
+
continue;
|
350
|
+
}
|
351
|
+
|
352
|
+
const ref = this[tKey];
|
353
|
+
|
354
|
+
if (
|
355
|
+
ref &&
|
356
|
+
typeof ref === "object" &&
|
357
|
+
"toJSON" in ref &&
|
358
|
+
typeof ref.toJSON === "function"
|
359
|
+
) {
|
360
|
+
const jsonedRef = ref.toJSON(tKey, [
|
361
|
+
...(processedValues || []),
|
362
|
+
this.id,
|
363
|
+
]);
|
364
|
+
result[key] = jsonedRef;
|
365
|
+
}
|
366
|
+
} else {
|
367
|
+
result[key] = undefined;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
return result;
|
372
|
+
}
|
373
|
+
|
374
|
+
[inspect]() {
|
375
|
+
return this.toJSON();
|
376
|
+
}
|
377
|
+
|
378
|
+
_createCoMap(
|
379
|
+
init: Simplify<CoMapInit<typeof this>>,
|
380
|
+
options?:
|
381
|
+
| {
|
382
|
+
owner: Account | Group;
|
383
|
+
unique?: CoValueUniqueness["uniqueness"];
|
384
|
+
}
|
385
|
+
| Account
|
386
|
+
| Group,
|
387
|
+
): typeof this {
|
388
|
+
const { owner, uniqueness } = parseCoValueCreateOptions(options);
|
389
|
+
const raw = this.rawFromInit(init, owner, uniqueness);
|
390
|
+
|
391
|
+
Object.defineProperties(this, {
|
392
|
+
id: {
|
393
|
+
value: raw.id,
|
394
|
+
enumerable: false,
|
395
|
+
},
|
396
|
+
_raw: { value: raw, enumerable: false },
|
397
|
+
});
|
398
|
+
|
399
|
+
return this;
|
400
|
+
}
|
401
|
+
|
402
|
+
/**
|
403
|
+
* Create a new `RawCoMap` from an initialization object
|
404
|
+
* @internal
|
405
|
+
*/
|
406
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
407
|
+
rawFromInit<Fields extends object = Record<string, any>>(
|
408
|
+
init: Simplify<CoMapInit<Fields>> | undefined,
|
409
|
+
owner: Account | Group,
|
410
|
+
uniqueness?: CoValueUniqueness,
|
411
|
+
) {
|
412
|
+
const rawOwner = owner._raw;
|
413
|
+
|
414
|
+
const rawInit = {} as {
|
415
|
+
[key in keyof Fields]: JsonValue | undefined;
|
416
|
+
};
|
417
|
+
|
418
|
+
if (init)
|
419
|
+
for (const key of Object.keys(init) as (keyof Fields)[]) {
|
420
|
+
const initValue = init[key as keyof typeof init];
|
421
|
+
|
422
|
+
const descriptor = this.getDescriptor(key as string);
|
423
|
+
|
424
|
+
if (!descriptor) {
|
425
|
+
continue;
|
426
|
+
}
|
427
|
+
|
428
|
+
if (descriptor === "json") {
|
429
|
+
rawInit[key] = initValue as JsonValue;
|
430
|
+
} else if (isRefEncoded(descriptor)) {
|
431
|
+
if (initValue) {
|
432
|
+
rawInit[key] = (initValue as unknown as CoValue).id;
|
433
|
+
}
|
434
|
+
} else if ("encoded" in descriptor) {
|
435
|
+
rawInit[key] = descriptor.encoded.encode(
|
436
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
437
|
+
initValue as any,
|
438
|
+
);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
return rawOwner.createMap(rawInit, null, "private", uniqueness);
|
443
|
+
}
|
444
|
+
|
445
|
+
getDescriptor(key: string) {
|
446
|
+
return this._schema?.[key] || this._schema?.[ItemsSym];
|
447
|
+
}
|
448
|
+
|
449
|
+
/**
|
450
|
+
* Declare a Record-like CoMap schema, by extending `CoMap.Record(...)` and passing the value schema using `co`. Keys are always `string`.
|
451
|
+
*
|
452
|
+
* @example
|
453
|
+
* ```ts
|
454
|
+
* import { coField, CoMap } from "jazz-tools";
|
455
|
+
*
|
456
|
+
* class ColorToFruitMap extends CoMap.Record(
|
457
|
+
* coField.ref(Fruit)
|
458
|
+
* ) {}
|
459
|
+
*
|
460
|
+
* // assume we have map: ColorToFruitMap
|
461
|
+
* // and strawberry: Fruit
|
462
|
+
* map["red"] = strawberry;
|
463
|
+
* ```
|
464
|
+
*
|
465
|
+
* @category Declaration
|
466
|
+
*/
|
467
|
+
static Record<Value>(value: Value) {
|
468
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
469
|
+
class RecordLikeCoMap extends CoMap {
|
470
|
+
[ItemsSym] = value;
|
471
|
+
}
|
472
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
473
|
+
interface RecordLikeCoMap extends Record<string, Value> {}
|
474
|
+
|
475
|
+
return RecordLikeCoMap;
|
476
|
+
}
|
477
|
+
|
478
|
+
/**
|
479
|
+
* Load a `CoMap` with a given ID, as a given account.
|
480
|
+
*
|
481
|
+
* `depth` specifies which (if any) fields that reference other CoValues to load as well before resolving.
|
482
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
483
|
+
*
|
484
|
+
* You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.
|
485
|
+
*
|
486
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoFeed`/`Group`/`Account` to see which depth structures are valid to nest.
|
487
|
+
*
|
488
|
+
* @example
|
489
|
+
* ```ts
|
490
|
+
* const person = await Person.load(
|
491
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
492
|
+
* { pet: {} }
|
493
|
+
* );
|
494
|
+
* ```
|
495
|
+
*
|
496
|
+
* @category Subscription & Loading
|
497
|
+
*/
|
498
|
+
static load<M extends CoMap, const R extends RefsToResolve<M> = true>(
|
499
|
+
this: CoValueClass<M>,
|
500
|
+
id: ID<M>,
|
501
|
+
options?: {
|
502
|
+
resolve?: RefsToResolveStrict<M, R>;
|
503
|
+
loadAs?: Account | AnonymousJazzAgent;
|
504
|
+
skipRetry?: boolean;
|
505
|
+
},
|
506
|
+
): Promise<Resolved<M, R> | null> {
|
507
|
+
return loadCoValueWithoutMe(this, id, options);
|
508
|
+
}
|
509
|
+
|
510
|
+
/**
|
511
|
+
* Load and subscribe to a `CoMap` with a given ID, as a given account.
|
512
|
+
*
|
513
|
+
* Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.
|
514
|
+
*
|
515
|
+
* `depth` specifies which (if any) fields that reference other CoValues to load as well before calling `listener` for the first time.
|
516
|
+
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
517
|
+
*
|
518
|
+
* You can pass `[]` or `{}` for shallowly loading only this CoMap, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.
|
519
|
+
*
|
520
|
+
* Check out the `load` methods on `CoMap`/`CoList`/`CoFeed`/`Group`/`Account` to see which depth structures are valid to nest.
|
521
|
+
*
|
522
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
523
|
+
*
|
524
|
+
* Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.
|
525
|
+
*
|
526
|
+
* @example
|
527
|
+
* ```ts
|
528
|
+
* const unsub = Person.subscribe(
|
529
|
+
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
530
|
+
* { pet: {} },
|
531
|
+
* (person) => console.log(person)
|
532
|
+
* );
|
533
|
+
* ```
|
534
|
+
*
|
535
|
+
* @category Subscription & Loading
|
536
|
+
*/
|
537
|
+
static subscribe<M extends CoMap, const R extends RefsToResolve<M> = true>(
|
538
|
+
this: CoValueClass<M>,
|
539
|
+
id: ID<M>,
|
540
|
+
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void,
|
541
|
+
): () => void;
|
542
|
+
static subscribe<M extends CoMap, const R extends RefsToResolve<M> = true>(
|
543
|
+
this: CoValueClass<M>,
|
544
|
+
id: ID<M>,
|
545
|
+
options: SubscribeListenerOptions<M, R>,
|
546
|
+
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void,
|
547
|
+
): () => void;
|
548
|
+
static subscribe<M extends CoMap, const R extends RefsToResolve<M>>(
|
549
|
+
this: CoValueClass<M>,
|
550
|
+
id: ID<M>,
|
551
|
+
...args: SubscribeRestArgs<M, R>
|
552
|
+
): () => void {
|
553
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
554
|
+
return subscribeToCoValueWithoutMe<M, R>(this, id, options, listener);
|
555
|
+
}
|
556
|
+
|
557
|
+
/** @deprecated Use `CoMap.upsertUnique` and `CoMap.loadUnique` instead. */
|
558
|
+
static findUnique<M extends CoMap>(
|
559
|
+
this: CoValueClass<M>,
|
560
|
+
unique: CoValueUniqueness["uniqueness"],
|
561
|
+
ownerID: ID<Account> | ID<Group>,
|
562
|
+
as?: Account | Group | AnonymousJazzAgent,
|
563
|
+
) {
|
564
|
+
return CoMap._findUnique(unique, ownerID, as);
|
565
|
+
}
|
566
|
+
|
567
|
+
/** @internal */
|
568
|
+
static _findUnique<M extends CoMap>(
|
569
|
+
this: CoValueClass<M>,
|
570
|
+
unique: CoValueUniqueness["uniqueness"],
|
571
|
+
ownerID: ID<Account> | ID<Group>,
|
572
|
+
as?: Account | Group | AnonymousJazzAgent,
|
573
|
+
) {
|
574
|
+
as ||= activeAccountContext.get();
|
575
|
+
|
576
|
+
const header = {
|
577
|
+
type: "comap" as const,
|
578
|
+
ruleset: {
|
579
|
+
type: "ownedByGroup" as const,
|
580
|
+
group: ownerID as RawCoID,
|
581
|
+
},
|
582
|
+
meta: null,
|
583
|
+
uniqueness: unique,
|
584
|
+
};
|
585
|
+
const crypto =
|
586
|
+
as._type === "Anonymous" ? as.node.crypto : as._raw.core.node.crypto;
|
587
|
+
return cojsonInternals.idforHeader(header, crypto) as ID<M>;
|
588
|
+
}
|
589
|
+
|
590
|
+
/**
|
591
|
+
* Given some data, updates an existing CoMap or initialises a new one if none exists.
|
592
|
+
*
|
593
|
+
* Note: This method respects resolve options, and thus can return `null` if the references cannot be resolved.
|
594
|
+
*
|
595
|
+
* @example
|
596
|
+
* ```ts
|
597
|
+
* const activeEvent = await Event.upsertUnique(
|
598
|
+
* sourceData.identifier,
|
599
|
+
* workspace.id,
|
600
|
+
* {
|
601
|
+
* title: sourceData.title,
|
602
|
+
* identifier: sourceData.identifier,
|
603
|
+
* external_id: sourceData._id,
|
604
|
+
* },
|
605
|
+
* workspace
|
606
|
+
* );
|
607
|
+
* ```
|
608
|
+
*
|
609
|
+
* @param options The options for creating or loading the CoMap. This includes the intended state of the CoMap, its unique identifier, its owner, and the references to resolve.
|
610
|
+
* @returns Either an existing & modified CoMap, or a new initialised CoMap if none exists.
|
611
|
+
* @category Subscription & Loading
|
612
|
+
*/
|
613
|
+
static async upsertUnique<
|
614
|
+
M extends CoMap,
|
615
|
+
const R extends RefsToResolve<M> = true,
|
616
|
+
>(
|
617
|
+
this: CoValueClass<M>,
|
618
|
+
options: {
|
619
|
+
value: Simplify<CoMapInit<M>>;
|
620
|
+
unique: CoValueUniqueness["uniqueness"];
|
621
|
+
owner: Account | Group;
|
622
|
+
resolve?: RefsToResolveStrict<M, R>;
|
623
|
+
},
|
624
|
+
): Promise<Resolved<M, R> | null> {
|
625
|
+
let mapId = CoMap._findUnique(options.unique, options.owner.id);
|
626
|
+
let map: Resolved<M, R> | null = await loadCoValueWithoutMe(this, mapId, {
|
627
|
+
...options,
|
628
|
+
loadAs: options.owner._loadedAs,
|
629
|
+
skipRetry: true,
|
630
|
+
});
|
631
|
+
if (!map) {
|
632
|
+
const instance = new this();
|
633
|
+
map = instance._createCoMap(options.value, {
|
634
|
+
owner: options.owner,
|
635
|
+
unique: options.unique,
|
636
|
+
}) as Resolved<M, R>;
|
637
|
+
} else {
|
638
|
+
(map as M).applyDiff(options.value as Partial<CoMapInit<M>>);
|
639
|
+
}
|
640
|
+
|
641
|
+
return await loadCoValueWithoutMe(this, mapId, {
|
642
|
+
...options,
|
643
|
+
loadAs: options.owner._loadedAs,
|
644
|
+
skipRetry: true,
|
645
|
+
});
|
646
|
+
}
|
647
|
+
|
648
|
+
/**
|
649
|
+
* Loads a CoMap by its unique identifier and owner's ID.
|
650
|
+
* @param unique The unique identifier of the CoMap to load.
|
651
|
+
* @param ownerID The ID of the owner of the CoMap.
|
652
|
+
* @param options Additional options for loading the CoMap.
|
653
|
+
* @returns The loaded CoMap, or null if unavailable.
|
654
|
+
*/
|
655
|
+
static loadUnique<M extends CoMap, const R extends RefsToResolve<M> = true>(
|
656
|
+
this: CoValueClass<M>,
|
657
|
+
unique: CoValueUniqueness["uniqueness"],
|
658
|
+
ownerID: ID<Account> | ID<Group>,
|
659
|
+
options?: {
|
660
|
+
resolve?: RefsToResolveStrict<M, R>;
|
661
|
+
loadAs?: Account | AnonymousJazzAgent;
|
662
|
+
},
|
663
|
+
): Promise<Resolved<M, R> | null> {
|
664
|
+
return loadCoValueWithoutMe(
|
665
|
+
this,
|
666
|
+
CoMap._findUnique(unique, ownerID, options?.loadAs),
|
667
|
+
{ ...options, skipRetry: true },
|
668
|
+
);
|
669
|
+
}
|
670
|
+
|
671
|
+
/**
|
672
|
+
* Given an already loaded `CoMap`, ensure that the specified fields are loaded to the specified depth.
|
673
|
+
*
|
674
|
+
* Works like `CoMap.load()`, but you don't need to pass the ID or the account to load as again.
|
675
|
+
*
|
676
|
+
* @category Subscription & Loading
|
677
|
+
*/
|
678
|
+
ensureLoaded<M extends CoMap, const R extends RefsToResolve<M>>(
|
679
|
+
this: M,
|
680
|
+
options: { resolve: RefsToResolveStrict<M, R> },
|
681
|
+
): Promise<Resolved<M, R>> {
|
682
|
+
return ensureCoValueLoaded(this, options);
|
683
|
+
}
|
684
|
+
|
685
|
+
/**
|
686
|
+
* Given an already loaded `CoMap`, subscribe to updates to the `CoMap` and ensure that the specified fields are loaded to the specified depth.
|
687
|
+
*
|
688
|
+
* Works like `CoMap.subscribe()`, but you don't need to pass the ID or the account to load as again.
|
689
|
+
*
|
690
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
691
|
+
*
|
692
|
+
* @category Subscription & Loading
|
693
|
+
**/
|
694
|
+
subscribe<M extends CoMap, const R extends RefsToResolve<M> = true>(
|
695
|
+
this: M,
|
696
|
+
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void,
|
697
|
+
): () => void;
|
698
|
+
subscribe<M extends CoMap, const R extends RefsToResolve<M> = true>(
|
699
|
+
this: M,
|
700
|
+
options: { resolve?: RefsToResolveStrict<M, R> },
|
701
|
+
listener: (value: Resolved<M, R>, unsubscribe: () => void) => void,
|
702
|
+
): () => void;
|
703
|
+
subscribe<M extends CoMap, const R extends RefsToResolve<M>>(
|
704
|
+
this: M,
|
705
|
+
...args: SubscribeRestArgs<M, R>
|
706
|
+
): () => void {
|
707
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
708
|
+
return subscribeToExistingCoValue<M, R>(this, options, listener);
|
709
|
+
}
|
710
|
+
|
711
|
+
applyDiff<N extends Partial<CoMapInit<this>>>(newValues: N) {
|
712
|
+
for (const key in newValues) {
|
713
|
+
if (Object.prototype.hasOwnProperty.call(newValues, key)) {
|
714
|
+
const tKey = key as keyof typeof newValues & keyof this;
|
715
|
+
const descriptor = this.getDescriptor(key);
|
716
|
+
|
717
|
+
if (!descriptor) continue;
|
718
|
+
|
719
|
+
const newValue = newValues[tKey];
|
720
|
+
const currentValue = (this as unknown as N)[tKey];
|
721
|
+
|
722
|
+
if (descriptor === "json" || "encoded" in descriptor) {
|
723
|
+
if (currentValue !== newValue) {
|
724
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
725
|
+
(this as any)[tKey] = newValue;
|
726
|
+
}
|
727
|
+
} else if (isRefEncoded(descriptor)) {
|
728
|
+
const currentId = (currentValue as CoValue | undefined)?.id;
|
729
|
+
const newId = (newValue as CoValue | undefined)?.id;
|
730
|
+
if (currentId !== newId) {
|
731
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
732
|
+
(this as any)[tKey] = newValue;
|
733
|
+
}
|
734
|
+
}
|
735
|
+
}
|
736
|
+
}
|
737
|
+
return this;
|
738
|
+
}
|
739
|
+
|
740
|
+
/**
|
741
|
+
* Wait for the `CoMap` to be uploaded to the other peers.
|
742
|
+
*
|
743
|
+
* @category Subscription & Loading
|
744
|
+
*/
|
745
|
+
waitForSync(options?: { timeout?: number }) {
|
746
|
+
return this._raw.core.waitForSync(options);
|
747
|
+
}
|
748
|
+
}
|
749
|
+
|
750
|
+
export type CoKeys<Map extends object> = Exclude<
|
751
|
+
keyof Map & string,
|
752
|
+
keyof CoMap
|
753
|
+
>;
|
754
|
+
|
755
|
+
/**
|
756
|
+
* Force required ref fields to be non nullable
|
757
|
+
*
|
758
|
+
* Considering that:
|
759
|
+
* - Optional refs are typed as coField<InstanceType<CoValueClass> | null | undefined>
|
760
|
+
* - Required refs are typed as coField<InstanceType<CoValueClass> | null>
|
761
|
+
*
|
762
|
+
* This type works in two steps:
|
763
|
+
* - Remove the null from both types
|
764
|
+
* - Then we check if the input type accepts undefined, if positive we put the null union back
|
765
|
+
*
|
766
|
+
* So the optional refs stays unchanged while we safely remove the null union
|
767
|
+
* from required refs
|
768
|
+
*
|
769
|
+
* This way required refs can be marked as required in the CoMapInit while
|
770
|
+
* staying a nullable property for value access.
|
771
|
+
*
|
772
|
+
* Example:
|
773
|
+
*
|
774
|
+
* const map = MyCoMap.create({
|
775
|
+
* requiredRef: NestedMap.create({}) // null is not valid here
|
776
|
+
* })
|
777
|
+
*
|
778
|
+
* map.requiredRef // this value is still nullable
|
779
|
+
*/
|
780
|
+
type ForceRequiredRef<V> = V extends InstanceType<CoValueClass> | null
|
781
|
+
? NonNullable<V>
|
782
|
+
: V extends InstanceType<CoValueClass> | undefined
|
783
|
+
? V | null
|
784
|
+
: V;
|
785
|
+
|
786
|
+
export type CoMapInit<Map extends object> = {
|
787
|
+
[Key in CoKeys<Map> as undefined extends Map[Key]
|
788
|
+
? never
|
789
|
+
: Key]: ForceRequiredRef<Map[Key]>;
|
790
|
+
} & {
|
791
|
+
[Key in CoKeys<Map>]?: ForceRequiredRef<Map[Key]>;
|
792
|
+
};
|
793
|
+
|
794
|
+
// TODO: cache handlers per descriptor for performance?
|
795
|
+
const CoMapProxyHandler: ProxyHandler<CoMap> = {
|
796
|
+
get(target, key, receiver) {
|
797
|
+
if (key === "_schema") {
|
798
|
+
return Reflect.get(target, key);
|
799
|
+
} else if (key in target) {
|
800
|
+
return Reflect.get(target, key, receiver);
|
801
|
+
} else {
|
802
|
+
if (typeof key !== "string") {
|
803
|
+
return undefined;
|
804
|
+
}
|
805
|
+
|
806
|
+
const descriptor = target.getDescriptor(key as string);
|
807
|
+
|
808
|
+
if (!descriptor) {
|
809
|
+
return undefined;
|
810
|
+
}
|
811
|
+
|
812
|
+
const raw = target._raw.get(key);
|
813
|
+
|
814
|
+
if (descriptor === "json") {
|
815
|
+
return raw;
|
816
|
+
} else if ("encoded" in descriptor) {
|
817
|
+
return raw === undefined ? undefined : descriptor.encoded.decode(raw);
|
818
|
+
} else if (isRefEncoded(descriptor)) {
|
819
|
+
return raw === undefined || raw === null
|
820
|
+
? undefined
|
821
|
+
: accessChildByKey(target, raw as string, key);
|
822
|
+
}
|
823
|
+
}
|
824
|
+
},
|
825
|
+
set(target, key, value, receiver) {
|
826
|
+
if (
|
827
|
+
(typeof key === "string" || ItemsSym) &&
|
828
|
+
typeof value === "object" &&
|
829
|
+
value !== null &&
|
830
|
+
SchemaInit in value
|
831
|
+
) {
|
832
|
+
(target.constructor as typeof CoMap)._schema ||= {};
|
833
|
+
(target.constructor as typeof CoMap)._schema[key] = value[SchemaInit];
|
834
|
+
return true;
|
835
|
+
}
|
836
|
+
|
837
|
+
const descriptor = target.getDescriptor(key as string);
|
838
|
+
|
839
|
+
if (!descriptor) return false;
|
840
|
+
|
841
|
+
if (typeof key === "string") {
|
842
|
+
if (descriptor === "json") {
|
843
|
+
target._raw.set(key, value);
|
844
|
+
} else if ("encoded" in descriptor) {
|
845
|
+
target._raw.set(key, descriptor.encoded.encode(value));
|
846
|
+
} else if (isRefEncoded(descriptor)) {
|
847
|
+
if (value === undefined) {
|
848
|
+
if (descriptor.optional) {
|
849
|
+
target._raw.set(key, null);
|
850
|
+
} else {
|
851
|
+
throw new Error(
|
852
|
+
`Cannot set required reference ${key} to undefined`,
|
853
|
+
);
|
854
|
+
}
|
855
|
+
} else if (value?.id) {
|
856
|
+
target._raw.set(key, value.id);
|
857
|
+
} else {
|
858
|
+
throw new Error(
|
859
|
+
`Cannot set reference ${key} to a non-CoValue. Got ${value}`,
|
860
|
+
);
|
861
|
+
}
|
862
|
+
}
|
863
|
+
return true;
|
864
|
+
} else {
|
865
|
+
return Reflect.set(target, key, value, receiver);
|
866
|
+
}
|
867
|
+
},
|
868
|
+
defineProperty(target, key, attributes) {
|
869
|
+
if (
|
870
|
+
"value" in attributes &&
|
871
|
+
typeof attributes.value === "object" &&
|
872
|
+
SchemaInit in attributes.value
|
873
|
+
) {
|
874
|
+
(target.constructor as typeof CoMap)._schema ||= {};
|
875
|
+
(target.constructor as typeof CoMap)._schema[key as string] =
|
876
|
+
attributes.value[SchemaInit];
|
877
|
+
return true;
|
878
|
+
} else {
|
879
|
+
return Reflect.defineProperty(target, key, attributes);
|
880
|
+
}
|
881
|
+
},
|
882
|
+
ownKeys(target) {
|
883
|
+
const keys = Reflect.ownKeys(target).filter((k) => k !== ItemsSym);
|
884
|
+
|
885
|
+
for (const key of target._raw.keys()) {
|
886
|
+
if (!keys.includes(key)) {
|
887
|
+
keys.push(key);
|
888
|
+
}
|
889
|
+
}
|
890
|
+
|
891
|
+
return keys;
|
892
|
+
},
|
893
|
+
getOwnPropertyDescriptor(target, key) {
|
894
|
+
if (key in target) {
|
895
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
896
|
+
} else {
|
897
|
+
const descriptor = target.getDescriptor(key as string);
|
898
|
+
|
899
|
+
if (descriptor || key in target._raw.latest) {
|
900
|
+
return {
|
901
|
+
enumerable: true,
|
902
|
+
configurable: true,
|
903
|
+
writable: true,
|
904
|
+
};
|
905
|
+
}
|
906
|
+
}
|
907
|
+
},
|
908
|
+
has(target, key) {
|
909
|
+
const descriptor = target.getDescriptor(key as string);
|
910
|
+
|
911
|
+
if (target._raw && typeof key === "string" && descriptor) {
|
912
|
+
return target._raw.get(key) !== undefined;
|
913
|
+
} else {
|
914
|
+
return Reflect.has(target, key);
|
915
|
+
}
|
916
|
+
},
|
917
|
+
deleteProperty(target, key) {
|
918
|
+
const descriptor = target.getDescriptor(key as string);
|
919
|
+
|
920
|
+
if (typeof key === "string" && descriptor) {
|
921
|
+
target._raw.delete(key);
|
922
|
+
return true;
|
923
|
+
} else {
|
924
|
+
return Reflect.deleteProperty(target, key);
|
925
|
+
}
|
926
|
+
},
|
927
|
+
};
|
928
|
+
|
929
|
+
RegisteredSchemas["CoMap"] = CoMap;
|