jazz-tools 2.0.0-alpha.60 → 2.0.0-alpha.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/jazz-tools.js +3 -0
- package/dist/_dev/native-account-session.d.ts +8 -1
- package/dist/_dev/native-account-session.d.ts.map +1 -1
- package/dist/_dev/native-account-session.js +10 -0
- package/dist/_dev/native-account-session.js.map +1 -1
- package/dist/accounts/account-manager-core.d.ts +6 -0
- package/dist/accounts/account-manager-core.d.ts.map +1 -1
- package/dist/accounts/account-manager-core.js +26 -2
- package/dist/accounts/account-manager-core.js.map +1 -1
- package/dist/accounts/enrollment.d.ts.map +1 -1
- package/dist/accounts/enrollment.js +13 -4
- package/dist/accounts/enrollment.js.map +1 -1
- package/dist/accounts/exports.d.ts +1 -2
- package/dist/accounts/exports.d.ts.map +1 -1
- package/dist/accounts/exports.js +4 -1
- package/dist/accounts/exports.js.map +1 -1
- package/dist/accounts/persistence.d.ts +38 -2
- package/dist/accounts/persistence.d.ts.map +1 -1
- package/dist/accounts/persistence.js +123 -6
- package/dist/accounts/persistence.js.map +1 -1
- package/dist/accounts/registry-client.d.ts +29 -0
- package/dist/accounts/registry-client.d.ts.map +1 -1
- package/dist/accounts/registry-client.js +45 -0
- package/dist/accounts/registry-client.js.map +1 -1
- package/dist/accounts/state.d.ts.map +1 -1
- package/dist/accounts/state.js +2 -1
- package/dist/accounts/state.js.map +1 -1
- package/dist/backend/create-jazz-context.d.ts +7 -0
- package/dist/backend/create-jazz-context.d.ts.map +1 -1
- package/dist/backend/create-jazz-context.js +115 -18
- package/dist/backend/create-jazz-context.js.map +1 -1
- package/dist/backend/create-jazz-session.d.ts +9 -7
- package/dist/backend/create-jazz-session.d.ts.map +1 -1
- package/dist/backend/create-jazz-session.js +55 -17
- package/dist/backend/create-jazz-session.js.map +1 -1
- package/dist/backend/create-jazz.d.ts +196 -38
- package/dist/backend/create-jazz.d.ts.map +1 -1
- package/dist/backend/create-jazz.js +935 -147
- package/dist/backend/create-jazz.js.map +1 -1
- package/dist/backend/early-db.d.ts.map +1 -1
- package/dist/backend/early-db.js +1 -0
- package/dist/backend/early-db.js.map +1 -1
- package/dist/backend/external-jwt.d.ts.map +1 -1
- package/dist/backend/external-jwt.js +34 -10
- package/dist/backend/external-jwt.js.map +1 -1
- package/dist/backend/from-jwt.d.ts +6 -4
- package/dist/backend/from-jwt.d.ts.map +1 -1
- package/dist/backend/from-jwt.js +11 -3
- package/dist/backend/from-jwt.js.map +1 -1
- package/dist/backend/index.d.ts +2 -1
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +3 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/inspect-ui.d.ts +14 -0
- package/dist/backend/inspect-ui.d.ts.map +1 -0
- package/dist/backend/inspect-ui.js +156 -0
- package/dist/backend/inspect-ui.js.map +1 -0
- package/dist/backend/inspect.d.ts +133 -0
- package/dist/backend/inspect.d.ts.map +1 -0
- package/dist/backend/inspect.js +983 -0
- package/dist/backend/inspect.js.map +1 -0
- package/dist/backend/inspector-ui/0.js +2 -0
- package/dist/backend/inspector-ui/1.js +2 -0
- package/dist/backend/inspector-ui/10.js +2 -0
- package/dist/backend/inspector-ui/11.js +2 -0
- package/dist/backend/inspector-ui/12.js +2 -0
- package/dist/backend/inspector-ui/13.js +2 -0
- package/dist/backend/inspector-ui/14.js +2 -0
- package/dist/backend/inspector-ui/15.js +2 -0
- package/dist/backend/inspector-ui/16.js +2 -0
- package/dist/backend/inspector-ui/17.js +2 -0
- package/dist/backend/inspector-ui/18.js +2 -0
- package/dist/backend/inspector-ui/19.js +2 -0
- package/dist/backend/inspector-ui/2.js +2 -0
- package/dist/backend/inspector-ui/20.js +2 -0
- package/dist/backend/inspector-ui/3.js +2 -0
- package/dist/backend/inspector-ui/4.js +2 -0
- package/dist/backend/inspector-ui/5.js +2 -0
- package/dist/backend/inspector-ui/6.js +2 -0
- package/dist/backend/inspector-ui/7.js +2 -0
- package/dist/backend/inspector-ui/8.js +2 -0
- package/dist/backend/inspector-ui/9.js +2 -0
- package/dist/backend/inspector-ui-files.d.ts +4 -0
- package/dist/backend/inspector-ui-files.d.ts.map +1 -0
- package/dist/backend/inspector-ui-files.js +25 -0
- package/dist/backend/request-auth.d.ts +11 -0
- package/dist/backend/request-auth.d.ts.map +1 -1
- package/dist/backend/request-auth.js +14 -0
- package/dist/backend/request-auth.js.map +1 -1
- package/dist/backend/session-expiry.d.ts +61 -0
- package/dist/backend/session-expiry.d.ts.map +1 -0
- package/dist/backend/session-expiry.js +102 -0
- package/dist/backend/session-expiry.js.map +1 -0
- package/dist/backend/signing-key.d.ts +10 -0
- package/dist/backend/signing-key.d.ts.map +1 -0
- package/dist/backend/signing-key.js +15 -0
- package/dist/backend/signing-key.js.map +1 -0
- package/dist/backend/store-log.d.ts +3 -0
- package/dist/backend/store-log.d.ts.map +1 -0
- package/dist/backend/store-log.js +16 -0
- package/dist/backend/store-log.js.map +1 -0
- package/dist/backend/upgrade-status.d.ts +19 -0
- package/dist/backend/upgrade-status.d.ts.map +1 -0
- package/dist/backend/upgrade-status.js +55 -0
- package/dist/backend/upgrade-status.js.map +1 -0
- package/dist/backend/vercel-store.d.ts +88 -12
- package/dist/backend/vercel-store.d.ts.map +1 -1
- package/dist/backend/vercel-store.js +303 -44
- package/dist/backend/vercel-store.js.map +1 -1
- package/dist/backend/ws-peer.d.ts +32 -0
- package/dist/backend/ws-peer.d.ts.map +1 -0
- package/dist/backend/ws-peer.js +40 -0
- package/dist/backend/ws-peer.js.map +1 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts +134 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts.map +1 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js +121 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js.map +1 -0
- package/dist/better-auth-adapter/fixtures/schema.d.ts +2 -1
- package/dist/better-auth-adapter/fixtures/schema.d.ts.map +1 -1
- package/dist/better-auth-adapter/fixtures/schema.js +2 -1
- package/dist/better-auth-adapter/fixtures/schema.js.map +1 -1
- package/dist/better-auth-adapter/index.d.ts.map +1 -1
- package/dist/better-auth-adapter/index.js +47 -0
- package/dist/better-auth-adapter/index.js.map +1 -1
- package/dist/classic-api.d.ts.map +1 -1
- package/dist/classic-api.js +36 -0
- package/dist/classic-api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +54 -11
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +2 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -3
- package/dist/client/index.js.map +1 -1
- package/dist/cloud/credentials.d.ts +1 -1
- package/dist/cloud/credentials.d.ts.map +1 -1
- package/dist/cloud/credentials.js.map +1 -1
- package/dist/dev/catalogue-project.d.ts +12 -3
- package/dist/dev/catalogue-project.d.ts.map +1 -1
- package/dist/dev/catalogue-project.js +29 -4
- package/dist/dev/catalogue-project.js.map +1 -1
- package/dist/dev/catalogue.d.ts +12 -0
- package/dist/dev/catalogue.d.ts.map +1 -1
- package/dist/dev/catalogue.js +94 -15
- package/dist/dev/catalogue.js.map +1 -1
- package/dist/dev/dev-server.d.ts +4 -1
- package/dist/dev/dev-server.d.ts.map +1 -1
- package/dist/dev/dev-server.js +41 -3
- package/dist/dev/dev-server.js.map +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/backend-C6JfNAB2.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/backend-DHeT1LCS.css +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{create-legacy-browser-delegate-X_T_QKCN.js → create-legacy-browser-delegate-Bf58kV5i.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-aRzpnC3u.js → esm-B8Fn7-qJ.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-ezD5H765.js → esm-C3BWHq-S.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/esm-DC_mAoiW.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{esm-7mP3GQX4.js → esm-D_R-EGgt.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-BX6IY2Mv.js → esm-WihpI9g6.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/index-C_pcvEcg.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-XRRxJUcx.js → jazz-broker-worker-Cv6-V0tc.js} +787 -608
- package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-Db-pNME-.js +5 -0
- package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-CTwPHZcZ.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-KR7h3v27.wasm → jazz_wasm_bg-HpkRDlj-.wasm} +0 -0
- package/dist/dev/inspector-overlay/embedded/assets/src-B5UtjtXQ.js +22 -0
- package/dist/dev/inspector-overlay/embedded/assets/{index-C78Pprka.css → src-Cq8gSOLx.css} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{trace-api-B5CaetI0.js → trace-api-BctnwbUf.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/backend.html +16 -0
- package/dist/dev/inspector-overlay/embedded/embedded.html +3 -2
- package/dist/dev/inspector-overlay/host-bridge.d.ts.map +1 -1
- package/dist/dev/inspector-overlay/host-bridge.js +4 -1
- package/dist/dev/inspector-overlay/host-bridge.js.map +1 -1
- package/dist/dev/inspector-overlay/loader.d.ts +12 -1
- package/dist/dev/inspector-overlay/loader.d.ts.map +1 -1
- package/dist/dev/inspector-overlay/loader.js +31 -4
- package/dist/dev/inspector-overlay/loader.js.map +1 -1
- package/dist/dev/migrations.d.ts.map +1 -1
- package/dist/dev/migrations.js +53 -7
- package/dist/dev/migrations.js.map +1 -1
- package/dist/drivers/schema-wire.d.ts +6 -2
- package/dist/drivers/schema-wire.d.ts.map +1 -1
- package/dist/drivers/schema-wire.js +6 -2
- package/dist/drivers/schema-wire.js.map +1 -1
- package/dist/effect/jazz.d.ts +12 -5
- package/dist/effect/jazz.d.ts.map +1 -1
- package/dist/effect/jazz.js +28 -5
- package/dist/effect/jazz.js.map +1 -1
- package/dist/expo/create-account-manager.d.ts +1 -1
- package/dist/expo/create-account-manager.d.ts.map +1 -1
- package/dist/expo/create-jazz-session.d.ts +37 -17
- package/dist/expo/create-jazz-session.d.ts.map +1 -1
- package/dist/expo/create-jazz-session.js +53 -10
- package/dist/expo/create-jazz-session.js.map +1 -1
- package/dist/expo/index.d.ts +5 -8
- package/dist/expo/index.d.ts.map +1 -1
- package/dist/expo/index.js +5 -7
- package/dist/expo/index.js.map +1 -1
- package/dist/expo/metro.d.ts +20 -0
- package/dist/expo/metro.d.ts.map +1 -0
- package/dist/expo/metro.js +58 -0
- package/dist/expo/metro.js.map +1 -0
- package/dist/expo/provider.d.ts +6 -3
- package/dist/expo/provider.d.ts.map +1 -1
- package/dist/expo/provider.js +7 -6
- package/dist/expo/provider.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inspect/cli.d.ts +12 -0
- package/dist/inspect/cli.d.ts.map +1 -0
- package/dist/inspect/cli.js +320 -0
- package/dist/inspect/cli.js.map +1 -0
- package/dist/inspect/client.d.ts +67 -0
- package/dist/inspect/client.d.ts.map +1 -0
- package/dist/inspect/client.js +254 -0
- package/dist/inspect/client.js.map +1 -0
- package/dist/inspect/mcp.d.ts +28 -0
- package/dist/inspect/mcp.d.ts.map +1 -0
- package/dist/inspect/mcp.js +441 -0
- package/dist/inspect/mcp.js.map +1 -0
- package/dist/inspect/protocol.d.ts +317 -0
- package/dist/inspect/protocol.d.ts.map +1 -0
- package/dist/inspect/protocol.js +544 -0
- package/dist/inspect/protocol.js.map +1 -0
- package/dist/inspector/index.d.ts +10 -0
- package/dist/inspector/index.d.ts.map +1 -0
- package/dist/inspector/index.js +27 -0
- package/dist/inspector/index.js.map +1 -0
- package/dist/local-first/index.d.ts +2 -0
- package/dist/local-first/index.d.ts.map +1 -1
- package/dist/local-first/index.js +2 -0
- package/dist/local-first/index.js.map +1 -1
- package/dist/migrations.d.ts +23 -3
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +28 -6
- package/dist/migrations.js.map +1 -1
- package/dist/module-interop.d.ts +17 -0
- package/dist/module-interop.d.ts.map +1 -0
- package/dist/module-interop.js +32 -0
- package/dist/module-interop.js.map +1 -0
- package/dist/permissions/index.d.ts +1 -1
- package/dist/permissions/index.d.ts.map +1 -1
- package/dist/permissions/index.js +31 -10
- package/dist/permissions/index.js.map +1 -1
- package/dist/prosemirror/sync.d.ts.map +1 -1
- package/dist/prosemirror/sync.js +43 -21
- package/dist/prosemirror/sync.js.map +1 -1
- package/dist/react/index.d.ts +4 -9
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +4 -6
- package/dist/react/index.js.map +1 -1
- package/dist/react/provider-props.d.ts +7 -0
- package/dist/react/provider-props.d.ts.map +1 -0
- package/dist/react/provider-props.js +15 -0
- package/dist/react/provider-props.js.map +1 -0
- package/dist/react/provider.d.ts +9 -15
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.js +19 -38
- package/dist/react/provider.js.map +1 -1
- package/dist/react-core/index.d.ts +3 -4
- package/dist/react-core/index.d.ts.map +1 -1
- package/dist/react-core/index.js +8 -4
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/provider.d.ts +6 -6
- package/dist/react-core/provider.d.ts.map +1 -1
- package/dist/react-core/provider.js +5 -6
- package/dist/react-core/provider.js.map +1 -1
- package/dist/react-core/session.d.ts +41 -33
- package/dist/react-core/session.d.ts.map +1 -1
- package/dist/react-core/session.js +42 -90
- package/dist/react-core/session.js.map +1 -1
- package/dist/react-native/account-session.js +1 -1
- package/dist/react-native/account-session.js.map +1 -1
- package/dist/react-native/create-account-manager.d.ts +1 -1
- package/dist/react-native/create-account-manager.d.ts.map +1 -1
- package/dist/react-native/create-jazz-session.d.ts +37 -17
- package/dist/react-native/create-jazz-session.d.ts.map +1 -1
- package/dist/react-native/create-jazz-session.js +53 -10
- package/dist/react-native/create-jazz-session.js.map +1 -1
- package/dist/react-native/index.d.ts +5 -10
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +5 -7
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/native-foreground-db.d.ts +21 -0
- package/dist/react-native/native-foreground-db.d.ts.map +1 -1
- package/dist/react-native/native-foreground-db.js +47 -1
- package/dist/react-native/native-foreground-db.js.map +1 -1
- package/dist/react-native/provider.d.ts +14 -19
- package/dist/react-native/provider.d.ts.map +1 -1
- package/dist/react-native/provider.js +19 -18
- package/dist/react-native/provider.js.map +1 -1
- package/dist/react-native/runtime-source.d.ts +22 -0
- package/dist/react-native/runtime-source.d.ts.map +1 -1
- package/dist/react-native/runtime-source.js +68 -5
- package/dist/react-native/runtime-source.js.map +1 -1
- package/dist/removed-api.d.ts +87 -0
- package/dist/removed-api.d.ts.map +1 -0
- package/dist/removed-api.js +95 -0
- package/dist/removed-api.js.map +1 -0
- package/dist/runtime/auth-secret-store.d.ts +0 -44
- package/dist/runtime/auth-secret-store.d.ts.map +1 -1
- package/dist/runtime/auth-secret-store.js +1 -103
- package/dist/runtime/auth-secret-store.js.map +1 -1
- package/dist/runtime/authority-changed-error.d.ts +5 -3
- package/dist/runtime/authority-changed-error.d.ts.map +1 -1
- package/dist/runtime/authority-changed-error.js +5 -3
- package/dist/runtime/authority-changed-error.js.map +1 -1
- package/dist/runtime/browser-worker-assets.d.ts +19 -1
- package/dist/runtime/browser-worker-assets.d.ts.map +1 -1
- package/dist/runtime/browser-worker-assets.js +23 -1
- package/dist/runtime/browser-worker-assets.js.map +1 -1
- package/dist/runtime/browser-worker-assets.metro.d.ts +28 -0
- package/dist/runtime/browser-worker-assets.metro.d.ts.map +1 -0
- package/dist/runtime/browser-worker-assets.metro.js +52 -0
- package/dist/runtime/browser-worker-assets.metro.js.map +1 -0
- package/dist/runtime/browser-worker-assets.native.d.ts +2 -0
- package/dist/runtime/browser-worker-assets.native.d.ts.map +1 -1
- package/dist/runtime/browser-worker-assets.native.js +2 -0
- package/dist/runtime/browser-worker-assets.native.js.map +1 -1
- package/dist/runtime/browser-worker-config.d.ts +23 -0
- package/dist/runtime/browser-worker-config.d.ts.map +1 -1
- package/dist/runtime/browser-worker-config.js +72 -4
- package/dist/runtime/browser-worker-config.js.map +1 -1
- package/dist/runtime/client-migrations.d.ts +6 -4
- package/dist/runtime/client-migrations.d.ts.map +1 -1
- package/dist/runtime/client-migrations.js +20 -2
- package/dist/runtime/client-migrations.js.map +1 -1
- package/dist/runtime/client.d.ts +46 -6
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +65 -13
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/connection-manager/browser-connection-manager.d.ts +5 -1
- package/dist/runtime/connection-manager/browser-connection-manager.d.ts.map +1 -1
- package/dist/runtime/connection-manager/browser-connection-manager.js +38 -2
- package/dist/runtime/connection-manager/browser-connection-manager.js.map +1 -1
- package/dist/runtime/connection-manager/direct-connection-manager.d.ts +3 -1
- package/dist/runtime/connection-manager/direct-connection-manager.d.ts.map +1 -1
- package/dist/runtime/connection-manager/direct-connection-manager.js +7 -3
- package/dist/runtime/connection-manager/direct-connection-manager.js.map +1 -1
- package/dist/runtime/connection-manager/types.d.ts +23 -2
- package/dist/runtime/connection-manager/types.d.ts.map +1 -1
- package/dist/runtime/connection-manager/types.js +49 -6
- package/dist/runtime/connection-manager/types.js.map +1 -1
- package/dist/runtime/context.d.ts +5 -1
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/core-tick-failed-error.d.ts +31 -0
- package/dist/runtime/core-tick-failed-error.d.ts.map +1 -0
- package/dist/runtime/core-tick-failed-error.js +45 -0
- package/dist/runtime/core-tick-failed-error.js.map +1 -0
- package/dist/runtime/credentialed-transport.d.ts +18 -3
- package/dist/runtime/credentialed-transport.d.ts.map +1 -1
- package/dist/runtime/credentialed-transport.js +34 -11
- package/dist/runtime/credentialed-transport.js.map +1 -1
- package/dist/runtime/db-replaced-error.d.ts +3 -1
- package/dist/runtime/db-replaced-error.d.ts.map +1 -1
- package/dist/runtime/db-replaced-error.js +4 -2
- package/dist/runtime/db-replaced-error.js.map +1 -1
- package/dist/runtime/db.d.ts +40 -8
- package/dist/runtime/db.d.ts.map +1 -1
- package/dist/runtime/db.js +76 -9
- package/dist/runtime/db.js.map +1 -1
- package/dist/runtime/default-runtime-source.d.ts.map +1 -1
- package/dist/runtime/default-runtime-source.js +6 -1
- package/dist/runtime/default-runtime-source.js.map +1 -1
- package/dist/runtime/delete-local-first-store.d.ts +12 -0
- package/dist/runtime/delete-local-first-store.d.ts.map +1 -0
- package/dist/runtime/delete-local-first-store.js +12 -0
- package/dist/runtime/delete-local-first-store.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -4
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/local-first-upgrade.d.ts +9 -0
- package/dist/runtime/local-first-upgrade.d.ts.map +1 -1
- package/dist/runtime/local-first-upgrade.js.map +1 -1
- package/dist/runtime/metro-setup-error.d.ts +20 -0
- package/dist/runtime/metro-setup-error.d.ts.map +1 -0
- package/dist/runtime/metro-setup-error.js +22 -0
- package/dist/runtime/metro-setup-error.js.map +1 -0
- package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
- package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
- package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
- package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
- package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts +4 -1
- package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/attached-browser-worker-connection.js +3 -0
- package/dist/runtime/native-runtime/attached-browser-worker-connection.js.map +1 -1
- package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts +34 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts.map +1 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.js +61 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.js.map +1 -0
- package/dist/runtime/native-runtime/browser-follower-connection.d.ts +6 -1
- package/dist/runtime/native-runtime/browser-follower-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-follower-connection.js +9 -3
- package/dist/runtime/native-runtime/browser-follower-connection.js.map +1 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts +12 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.js +140 -7
- package/dist/runtime/native-runtime/browser-shared-worker-connection.js.map +1 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.d.ts +29 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.js.map +1 -1
- package/dist/runtime/native-runtime/http-stream-socket.d.ts +25 -7
- package/dist/runtime/native-runtime/http-stream-socket.d.ts.map +1 -1
- package/dist/runtime/native-runtime/http-stream-socket.js +148 -44
- package/dist/runtime/native-runtime/http-stream-socket.js.map +1 -1
- package/dist/runtime/native-runtime/native-error-code.d.ts +1 -1
- package/dist/runtime/native-runtime/native-error-code.d.ts.map +1 -1
- package/dist/runtime/native-runtime/native-error-code.js +1 -0
- package/dist/runtime/native-runtime/native-error-code.js.map +1 -1
- package/dist/runtime/native-runtime/native-runtime-adapter.d.ts +105 -7
- package/dist/runtime/native-runtime/native-runtime-adapter.d.ts.map +1 -1
- package/dist/runtime/native-runtime/native-runtime-adapter.js +306 -27
- package/dist/runtime/native-runtime/native-runtime-adapter.js.map +1 -1
- package/dist/runtime/native-runtime/session-renewal-wire.d.ts +48 -0
- package/dist/runtime/native-runtime/session-renewal-wire.d.ts.map +1 -0
- package/dist/runtime/native-runtime/session-renewal-wire.js +107 -0
- package/dist/runtime/native-runtime/session-renewal-wire.js.map +1 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts +22 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts.map +1 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.js +69 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.js.map +1 -0
- package/dist/runtime/native-runtime/websocket.d.ts +51 -1
- package/dist/runtime/native-runtime/websocket.d.ts.map +1 -1
- package/dist/runtime/native-runtime/websocket.js +187 -7
- package/dist/runtime/native-runtime/websocket.js.map +1 -1
- package/dist/runtime/page-handle.d.ts +83 -0
- package/dist/runtime/page-handle.d.ts.map +1 -0
- package/dist/runtime/page-handle.js +151 -0
- package/dist/runtime/page-handle.js.map +1 -0
- package/dist/runtime/removed-provider-props.d.ts +17 -0
- package/dist/runtime/removed-provider-props.d.ts.map +1 -0
- package/dist/runtime/removed-provider-props.js +16 -0
- package/dist/runtime/removed-provider-props.js.map +1 -0
- package/dist/runtime/row-transformer.d.ts.map +1 -1
- package/dist/runtime/row-transformer.js +20 -0
- package/dist/runtime/row-transformer.js.map +1 -1
- package/dist/runtime/runtime-config.d.ts +5 -1
- package/dist/runtime/runtime-config.d.ts.map +1 -1
- package/dist/runtime/runtime-config.js +5 -1
- package/dist/runtime/runtime-config.js.map +1 -1
- package/dist/runtime/runtime-source.d.ts +6 -1
- package/dist/runtime/runtime-source.d.ts.map +1 -1
- package/dist/runtime/runtime-source.js.map +1 -1
- package/dist/runtime/schema-metadata.d.ts +17 -0
- package/dist/runtime/schema-metadata.d.ts.map +1 -1
- package/dist/runtime/schema-metadata.js +28 -0
- package/dist/runtime/schema-metadata.js.map +1 -1
- package/dist/runtime/store-held-by-another-tab-error.d.ts +11 -0
- package/dist/runtime/store-held-by-another-tab-error.d.ts.map +1 -1
- package/dist/runtime/store-held-by-another-tab-error.js +11 -0
- package/dist/runtime/store-held-by-another-tab-error.js.map +1 -1
- package/dist/runtime/sync-status.d.ts +60 -1
- package/dist/runtime/sync-status.d.ts.map +1 -1
- package/dist/runtime/sync-status.js +64 -4
- package/dist/runtime/sync-status.js.map +1 -1
- package/dist/runtime/wasm-loader.d.ts.map +1 -1
- package/dist/runtime/wasm-loader.js +8 -1
- package/dist/runtime/wasm-loader.js.map +1 -1
- package/dist/schema-loader.d.ts +2 -0
- package/dist/schema-loader.d.ts.map +1 -1
- package/dist/schema-loader.js +7 -2
- package/dist/schema-loader.js.map +1 -1
- package/dist/schema-permissions.d.ts.map +1 -1
- package/dist/schema-permissions.js +19 -0
- package/dist/schema-permissions.js.map +1 -1
- package/dist/schema-source.d.ts.map +1 -1
- package/dist/schema-source.js +14 -0
- package/dist/schema-source.js.map +1 -1
- package/dist/session/backend-watch.d.ts +56 -15
- package/dist/session/backend-watch.d.ts.map +1 -1
- package/dist/session/backend-watch.js +127 -31
- package/dist/session/backend-watch.js.map +1 -1
- package/dist/session/config-options.d.ts +15 -0
- package/dist/session/config-options.d.ts.map +1 -0
- package/dist/session/config-options.js +55 -0
- package/dist/session/config-options.js.map +1 -0
- package/dist/session/consumer.d.ts +1 -1
- package/dist/session/consumer.js +1 -1
- package/dist/session/consumer.js.map +1 -1
- package/dist/session/create-jazz-session.d.ts +55 -21
- package/dist/session/create-jazz-session.d.ts.map +1 -1
- package/dist/session/create-jazz-session.js +215 -166
- package/dist/session/create-jazz-session.js.map +1 -1
- package/dist/session/follow-user.d.ts +30 -11
- package/dist/session/follow-user.d.ts.map +1 -1
- package/dist/session/follow-user.js +49 -9
- package/dist/session/follow-user.js.map +1 -1
- package/dist/session/jazz-session.d.ts +182 -0
- package/dist/session/jazz-session.d.ts.map +1 -0
- package/dist/session/jazz-session.js +459 -0
- package/dist/session/jazz-session.js.map +1 -0
- package/dist/session/no-kept-device-account-error.d.ts +6 -0
- package/dist/session/no-kept-device-account-error.d.ts.map +1 -0
- package/dist/session/no-kept-device-account-error.js +8 -0
- package/dist/session/no-kept-device-account-error.js.map +1 -0
- package/dist/session/replica-ledger.d.ts +164 -0
- package/dist/session/replica-ledger.d.ts.map +1 -0
- package/dist/session/replica-ledger.js +450 -0
- package/dist/session/replica-ledger.js.map +1 -0
- package/dist/session/state.d.ts +50 -13
- package/dist/session/state.d.ts.map +1 -1
- package/dist/session/state.js +158 -29
- package/dist/session/state.js.map +1 -1
- package/dist/solid/index.d.ts +3 -9
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.js +8 -11
- package/dist/solid/index.ssr.js +3 -6
- package/dist/solid/provider.d.ts +3 -3
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.js +23 -39
- package/dist/solid/provider.js.map +1 -1
- package/dist/solid/provider.ssr.js +6 -23
- package/dist/solid/provider.ssr.js.map +1 -1
- package/dist/solid/session.d.ts +42 -12
- package/dist/solid/session.d.ts.map +1 -1
- package/dist/solid/session.js +82 -35
- package/dist/solid/session.js.map +1 -1
- package/dist/solid/session.ssr.js +86 -23
- package/dist/solid/session.ssr.js.map +1 -1
- package/dist/svelte/JazzProvider.svelte +54 -20
- package/dist/svelte/JazzProvider.svelte.d.ts +14 -4
- package/dist/svelte/JazzProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/JazzSvelteClientProvider.svelte +1 -7
- package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts +0 -1
- package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/JazzSvelteProvider.svelte +5 -4
- package/dist/svelte/JazzSvelteProvider.svelte.d.ts +2 -2
- package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/index.d.ts +4 -12
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +4 -8
- package/dist/svelte/session-state.d.ts +14 -4
- package/dist/svelte/session-state.d.ts.map +1 -1
- package/dist/svelte/session-state.js +10 -4
- package/dist/testing/client-migrations.d.ts +8 -1
- package/dist/testing/client-migrations.d.ts.map +1 -1
- package/dist/testing/client-migrations.js +11 -0
- package/dist/testing/client-migrations.js.map +1 -1
- package/dist/testing/policy-test-app.d.ts.map +1 -1
- package/dist/testing/policy-test-app.js +5 -4
- package/dist/testing/policy-test-app.js.map +1 -1
- package/dist/testing/test-jazz.d.ts +2 -2
- package/dist/testing/test-jazz.d.ts.map +1 -1
- package/dist/testing/test-jazz.js +6 -3
- package/dist/testing/test-jazz.js.map +1 -1
- package/dist/thin/index.d.ts +7 -10
- package/dist/thin/index.d.ts.map +1 -1
- package/dist/thin/index.js +28 -11
- package/dist/thin/index.js.map +1 -1
- package/dist/thin/thin-runtime.d.ts +53 -3
- package/dist/thin/thin-runtime.d.ts.map +1 -1
- package/dist/thin/thin-runtime.js +256 -33
- package/dist/thin/thin-runtime.js.map +1 -1
- package/dist/typed-app.d.ts +10 -4
- package/dist/typed-app.d.ts.map +1 -1
- package/dist/typed-app.js +44 -18
- package/dist/typed-app.js.map +1 -1
- package/dist/vue/index.d.ts +3 -8
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +3 -5
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/provider.d.ts +6 -27
- package/dist/vue/provider.d.ts.map +1 -1
- package/dist/vue/provider.js +10 -19
- package/dist/vue/provider.js.map +1 -1
- package/dist/vue/session.d.ts +29 -28
- package/dist/vue/session.d.ts.map +1 -1
- package/dist/vue/session.js +80 -23
- package/dist/vue/session.js.map +1 -1
- package/dist/web/create-jazz-client.d.ts +5 -1
- package/dist/web/create-jazz-client.d.ts.map +1 -1
- package/dist/web/create-jazz-client.js +30 -3
- package/dist/web/create-jazz-client.js.map +1 -1
- package/dist/window-client-storage.d.ts +4 -30
- package/dist/window-client-storage.d.ts.map +1 -1
- package/dist/window-client-storage.js +2 -63
- package/dist/window-client-storage.js.map +1 -1
- package/dist/worker/jazz-broker-worker-core.d.ts.map +1 -1
- package/dist/worker/jazz-broker-worker-core.js +118 -20
- package/dist/worker/jazz-broker-worker-core.js.map +1 -1
- package/dist/worker/jazz-broker-worker.js +787 -608
- package/dist/worker/jazz_wasm_bg.wasm +0 -0
- package/dist/worker/runtime-admission.d.ts +19 -0
- package/dist/worker/runtime-admission.d.ts.map +1 -0
- package/dist/worker/runtime-admission.js +34 -0
- package/dist/worker/runtime-admission.js.map +1 -0
- package/dist/worker/vite-dev-broker.d.ts +2 -0
- package/dist/worker/vite-dev-broker.d.ts.map +1 -0
- package/dist/worker/vite-dev-broker.js +8 -0
- package/dist/worker/vite-dev-broker.js.map +1 -0
- package/package.json +30 -10
- package/dist/backend/session-recheck.d.ts +0 -18
- package/dist/backend/session-recheck.d.ts.map +0 -1
- package/dist/backend/session-recheck.js +0 -57
- package/dist/backend/session-recheck.js.map +0 -1
- package/dist/dev/inspector-overlay/embedded/assets/esm-k3rsq4Gn.js +0 -1
- package/dist/dev/inspector-overlay/embedded/assets/index-C-btvLcw.js +0 -20
- package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CAMcDeUa.js +0 -3
- package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-Cc71x_6y.js +0 -1
- package/dist/dev/inspector-overlay/serve.d.ts +0 -46
- package/dist/dev/inspector-overlay/serve.d.ts.map +0 -1
- package/dist/dev/inspector-overlay/serve.js +0 -131
- package/dist/dev/inspector-overlay/serve.js.map +0 -1
- package/dist/dev-tools/auto-attach.d.ts +0 -11
- package/dist/dev-tools/auto-attach.d.ts.map +0 -1
- package/dist/dev-tools/auto-attach.js +0 -26
- package/dist/dev-tools/auto-attach.js.map +0 -1
- package/dist/expo/auth-secret-store.d.ts +0 -37
- package/dist/expo/auth-secret-store.d.ts.map +0 -1
- package/dist/expo/auth-secret-store.js +0 -139
- package/dist/expo/auth-secret-store.js.map +0 -1
- package/dist/expo/session.d.ts +0 -10
- package/dist/expo/session.d.ts.map +0 -1
- package/dist/expo/session.js +0 -5
- package/dist/expo/session.js.map +0 -1
- package/dist/expo/use-local-first-auth.d.ts +0 -12
- package/dist/expo/use-local-first-auth.d.ts.map +0 -1
- package/dist/expo/use-local-first-auth.js +0 -13
- package/dist/expo/use-local-first-auth.js.map +0 -1
- package/dist/react/devtools-auto-attach.d.ts +0 -2
- package/dist/react/devtools-auto-attach.d.ts.map +0 -1
- package/dist/react/devtools-auto-attach.js +0 -11
- package/dist/react/devtools-auto-attach.js.map +0 -1
- package/dist/react/session.d.ts +0 -18
- package/dist/react/session.d.ts.map +0 -1
- package/dist/react/session.js +0 -28
- package/dist/react/session.js.map +0 -1
- package/dist/react/use-local-first-auth.d.ts +0 -11
- package/dist/react/use-local-first-auth.d.ts.map +0 -1
- package/dist/react/use-local-first-auth.js +0 -13
- package/dist/react/use-local-first-auth.js.map +0 -1
- package/dist/react-core/app.d.ts +0 -31
- package/dist/react-core/app.d.ts.map +0 -1
- package/dist/react-core/app.js +0 -65
- package/dist/react-core/app.js.map +0 -1
- package/dist/react-core/use-account-state.d.ts +0 -4
- package/dist/react-core/use-account-state.d.ts.map +0 -1
- package/dist/react-core/use-account-state.js +0 -6
- package/dist/react-core/use-account-state.js.map +0 -1
- package/dist/react-core/use-local-first-auth.d.ts +0 -12
- package/dist/react-core/use-local-first-auth.d.ts.map +0 -1
- package/dist/react-core/use-local-first-auth.js +0 -14
- package/dist/react-core/use-local-first-auth.js.map +0 -1
- package/dist/react-native/session.d.ts +0 -10
- package/dist/react-native/session.d.ts.map +0 -1
- package/dist/react-native/session.js +0 -5
- package/dist/react-native/session.js.map +0 -1
- package/dist/react-native/use-local-first-auth.d.ts +0 -15
- package/dist/react-native/use-local-first-auth.d.ts.map +0 -1
- package/dist/react-native/use-local-first-auth.js +0 -14
- package/dist/react-native/use-local-first-auth.js.map +0 -1
- package/dist/runtime/local-first-auth-controller.d.ts +0 -29
- package/dist/runtime/local-first-auth-controller.d.ts.map +0 -1
- package/dist/runtime/local-first-auth-controller.js +0 -101
- package/dist/runtime/local-first-auth-controller.js.map +0 -1
- package/dist/session/app.d.ts +0 -58
- package/dist/session/app.d.ts.map +0 -1
- package/dist/session/app.js +0 -325
- package/dist/session/app.js.map +0 -1
- package/dist/session/create-jazz-app.d.ts +0 -11
- package/dist/session/create-jazz-app.d.ts.map +0 -1
- package/dist/session/create-jazz-app.js +0 -11
- package/dist/session/create-jazz-app.js.map +0 -1
- package/dist/session/left-behind-replicas.d.ts +0 -62
- package/dist/session/left-behind-replicas.d.ts.map +0 -1
- package/dist/session/left-behind-replicas.js +0 -146
- package/dist/session/left-behind-replicas.js.map +0 -1
- package/dist/solid/app.d.ts +0 -30
- package/dist/solid/app.d.ts.map +0 -1
- package/dist/solid/app.js +0 -95
- package/dist/solid/app.js.map +0 -1
- package/dist/solid/app.ssr.js +0 -109
- package/dist/solid/app.ssr.js.map +0 -1
- package/dist/solid/create-account-state.d.ts +0 -4
- package/dist/solid/create-account-state.d.ts.map +0 -1
- package/dist/solid/create-account-state.js +0 -10
- package/dist/solid/create-account-state.js.map +0 -1
- package/dist/solid/create-account-state.ssr.js +0 -12
- package/dist/solid/create-account-state.ssr.js.map +0 -1
- package/dist/solid/use-local-first-auth.d.ts +0 -11
- package/dist/solid/use-local-first-auth.d.ts.map +0 -1
- package/dist/solid/use-local-first-auth.js +0 -30
- package/dist/solid/use-local-first-auth.js.map +0 -1
- package/dist/solid/use-local-first-auth.ssr.js +0 -31
- package/dist/solid/use-local-first-auth.ssr.js.map +0 -1
- package/dist/svelte/JazzSessionClientProvider.svelte +0 -42
- package/dist/svelte/JazzSessionClientProvider.svelte.d.ts +0 -13
- package/dist/svelte/JazzSessionClientProvider.svelte.d.ts.map +0 -1
- package/dist/svelte/JazzSessionProvider.svelte +0 -68
- package/dist/svelte/JazzSessionProvider.svelte.d.ts +0 -19
- package/dist/svelte/JazzSessionProvider.svelte.d.ts.map +0 -1
- package/dist/svelte/account-state.d.ts +0 -5
- package/dist/svelte/account-state.d.ts.map +0 -1
- package/dist/svelte/account-state.js +0 -9
- package/dist/svelte/auth-state.d.ts +0 -23
- package/dist/svelte/auth-state.d.ts.map +0 -1
- package/dist/svelte/auth-state.js +0 -16
- package/dist/svelte/local-first-auth.svelte.d.ts +0 -50
- package/dist/svelte/local-first-auth.svelte.d.ts.map +0 -1
- package/dist/svelte/local-first-auth.svelte.js +0 -58
- package/dist/vue/app.d.ts +0 -76
- package/dist/vue/app.d.ts.map +0 -1
- package/dist/vue/app.js +0 -100
- package/dist/vue/app.js.map +0 -1
- package/dist/vue/use-account-state.d.ts +0 -5
- package/dist/vue/use-account-state.d.ts.map +0 -1
- package/dist/vue/use-account-state.js +0 -10
- package/dist/vue/use-account-state.js.map +0 -1
- package/dist/vue/use-local-first-auth.d.ts +0 -53
- package/dist/vue/use-local-first-auth.d.ts.map +0 -1
- package/dist/vue/use-local-first-auth.js +0 -67
- package/dist/vue/use-local-first-auth.js.map +0 -1
- /package/dist/dev/inspector-overlay/embedded/assets/{esm-CH5eVyQQ.js → esm-xNe3wI_B.js} +0 -0
- /package/dist/dev/inspector-overlay/embedded/assets/{node-foreground-node-lease.browser-Bm3gYjlT.js → node-foreground-node-lease.browser-CH8w-D6S.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-source.js","sourceRoot":"","sources":["../../src/runtime/runtime-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AA0HrE;;;;;;;GAOG;AACH,MAAM,OAAgB,aAAa;IACjC,uFAAuF;IAC9E,qBAAqB,GAAY,KAAK,CAAC;IAChD,8EAA8E;IACrE,oBAAoB,GAAY,IAAI,CAAC;IAE9C,KAAK,CAAC,IAAI,CAAC,MAAqB;QAC9B,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,+EAA+E;IAC/E,gBAAgB,CAYd;IAEF,qFAAqF;IACrF,uBAAuB,KAAU,CAAC;IAElC,gFAAgF;IAChF,mBAAmB,CAAC,MAAc;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gFAAgF;IAChF,WAAW,CAAC,OAAsB,IAAS,CAAC;IAK5C;0EACsE;IACtE,KAAK,CAAC,QAAQ,KAAmB,CAAC;IAExB,KAAK,CAAC,WAAW,CAAC,OAAsB;QAChD,OAAO,SAAS,CAAC;IACnB,CAAC;IAID;;;OAGG;IACH,KAAK,CAAC,0BAA0B,CAC9B,OAAsB;QAEtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,iCAAiC,CAAC,OAAsB;QACtD,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAC1E,CAAC;IACJ,CAAC;IAED,6BAA6B,CAC3B,QAAuD;QAEvD,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,+BAA+B,CAC7B,QAAyD;QAEzD,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAED,gBAAgB,CACd,QAAgD;QAEhD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IAC1E,mBAAmB,CAAC,OAA4B;QAC9C,OAAO,2BAA2B,CAChC,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,UAAU,EAClB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAC3B,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,QAA6B;QAC9C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,WAAW;QACT,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import { mintLocalFirstTokenFromSeed } from \"./local-first-token.js\";\nimport type { ClientMigrations } from \"./client-migrations.js\";\nimport type { RemoteLinkState } from \"./remote-link-state.js\";\nimport type { LinkStatus } from \"./sync-status.js\";\nimport type { WasmSchema } from \"../drivers/types.js\";\nimport type { JazzClient } from \"./client.js\";\nimport type { DbConfig } from \"./db.js\";\nimport type { AuthFailureReason } from \"./auth-state.js\";\nimport type { TextAnchors } from \"./text-anchors.js\";\n\nexport interface RuntimeTokenOptions {\n secret: string;\n audience: string;\n ttlSeconds: number;\n nowSeconds: bigint;\n}\n\nexport interface RuntimeClientContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n /** The migrations the app defining `schema` ships (see {@link ClientMigrations}). */\n migrations?: ClientMigrations;\n onAuthFailure: (reason: AuthFailureReason) => void;\n /**\n * Browser-only identity leased by the durable SharedWorker before the\n * synchronous foreground client is constructed.\n */\n foregroundNodeLease?: ForegroundNodeLease;\n}\n\n/** Internal foreground TxId lease, never exposed as application API. */\nexport interface ForegroundNodeLease {\n readonly node: Uint8Array;\n readonly confirmedTxTime: bigint;\n /** Atomically persists runtime high-water and makes this node reusable. */\n returnWithHighWater(highWater: bigint): Promise<void>;\n /** Permanently retires this node when clean handoff is not certain. */\n retire(): Promise<void>;\n}\n\n/** Browser-only terminal cleanup; the durable retirement outcome remains unknown. */\nexport interface BrowserForegroundNodeLease extends ForegroundNodeLease {\n /** Ephemeral owner identity; a successor realm cannot acknowledge this port. */\n readonly workerRealmId?: string;\n /** The caller must first disable the foreground lifetime that can mint this node's TxIds. */\n abandonAfterWorkerFailure(error: Error): void;\n /** Locally releases an erased epoch after its worker-authored reset receipt; never writes a handoff. */\n releaseAfterStorageReset(reason: Error): void;\n /** Release a dead owner's port after quiescing; its node remains non-reusable. */\n releaseAfterWorkerReplacement?(reason: Error): void;\n}\n\nexport interface RuntimeTelemetryContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n collectorUrl: string;\n runtimeThread: \"main\" | \"worker\";\n}\n\nexport interface BrowserWorkerConnection {\n /** Only a rejected initial configuration admission permits a later API call to retry. */\n canRetryInitialConfigurationAdmission?(): boolean;\n /**\n * The worker refused this connection because another tab holds the store\n * under another sign-in to the same account: the tab tries again on its\n * own (see `BROWSER_STORE_HELD_BY_ANOTHER_SIGN_IN`).\n */\n waitsForAnotherSignIn?(): boolean;\n ready(): Promise<void>;\n getWorkerRealmId?(): string | undefined;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n disconnect(): Promise<void>;\n reconnect(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n deleteStorage(): Promise<void>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n openInspectorControlPort(signal?: AbortSignal): Promise<MessagePort>;\n shutdown(): Promise<void>;\n /** Present only after an authenticated Inspector control-port attachment. */\n getAuthenticatedInspectorAttachmentPhysicalDbName?(): string | null;\n}\n\nexport interface BrowserFollowerConnection {\n ready(): Promise<void>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): void;\n detachForReconnect(): void;\n shutdown(): Promise<void>;\n}\n\nexport interface BrowserWorkerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n client: JazzClient;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\nexport interface BrowserFollowerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n client: JazzClient;\n port: MessagePort;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\n/**\n * Internal source for loading and wiring the native runtime.\n *\n * This keeps platform/source differences (WASM, NAPI, browser storage, React\n * Native support status) out of Db. The active database path is native-runtime backed:\n * implementations preload the runtime, then create JazzClient instances for\n * concrete schemas.\n */\nexport abstract class RuntimeSource<RuntimeConfig extends DbConfig = DbConfig> {\n /** Set to true when this source can host browser persistence in a dedicated worker. */\n readonly supportsBrowserWorker: boolean = false;\n /** Set to false when the runtime must receive schemas exactly as declared. */\n readonly supportsPolicyBypass: boolean = true;\n\n async load(config: RuntimeConfig): Promise<void> {\n await this.loadRuntime(config);\n }\n\n /** Native hosts own their transport before a schema client is materialized. */\n nativeConnection?: {\n configured(): boolean;\n disconnect(): void | Promise<void>;\n reconnect(): void | Promise<void>;\n /**\n * Native hosts that share one transport between several Db facades own\n * explicit-offline state at the host, rather than on an individual facade.\n */\n isExplicitlyOffline?(): boolean;\n waitForTransportTransition?(): Promise<void>;\n waitForReconnect?(signal?: AbortSignal): Promise<void>;\n onExplicitOfflineChange?(listener: (offline: boolean) => void, signal: AbortSignal): void;\n };\n\n /** Admission-bound native sources reject updates before any public state changes. */\n assertAuthUpdateAllowed(): void {}\n\n /** Return true when the native host renewed its own same-identity transport. */\n refreshAccountToken(_token: string): boolean {\n return false;\n }\n\n /** Apply source-specific admission after the shared auth config is resolved. */\n admitConfig(_config: RuntimeConfig): void {}\n\n /** Shared native hosts supply the pending-write barrier for all their facades. */\n waitForPendingWrites?(signal?: AbortSignal): Promise<void>;\n\n /** Release runtime admission after ordinary client shutdown, including a\n * prepared source whose lazy schema client was never materialized. */\n async shutdown(): Promise<void> {}\n\n protected async loadRuntime(_config: RuntimeConfig): Promise<unknown> {\n return undefined;\n }\n\n abstract createClient(context: RuntimeClientContext<RuntimeConfig>): JazzClient;\n\n /**\n * Optional pre-runtime foreground identity lease for non-browser hosts.\n * Browser persistence uses the dedicated SharedWorker variant below.\n */\n async acquireForegroundNodeLease(\n _config: RuntimeConfig,\n ): Promise<ForegroundNodeLease | undefined> {\n return undefined;\n }\n\n acquireBrowserForegroundNodeLease(_config: RuntimeConfig): Promise<BrowserForegroundNodeLease> {\n return Promise.reject(\n new Error(\"Db runtime source does not support browser foreground leases\"),\n );\n }\n\n createBrowserWorkerConnection(\n _context: BrowserWorkerConnectionContext<RuntimeConfig>,\n ): BrowserWorkerConnection {\n throw new Error(\"Db runtime source does not support browser worker connections\");\n }\n\n createBrowserFollowerConnection(\n _context: BrowserFollowerConnectionContext<RuntimeConfig>,\n ): BrowserFollowerConnection {\n throw new Error(\"Db runtime source does not support browser follower connections\");\n }\n\n installTelemetry(\n _context: RuntimeTelemetryContext<RuntimeConfig>,\n ): (() => void) | null | undefined {\n return null;\n }\n\n /** Same on every host: minted in TypeScript by `src/local-first-auth`. */\n mintLocalFirstToken(options: RuntimeTokenOptions): string {\n return mintLocalFirstTokenFromSeed(\n options.secret,\n options.audience,\n options.ttlSeconds,\n Number(options.nowSeconds),\n );\n }\n\n mintAnonymousToken(_options: RuntimeTokenOptions): string {\n throw new Error(\"Db runtime source does not support anonymous auth\");\n }\n\n textAnchors(): TextAnchors {\n throw new Error(\"Db runtime source does not support text anchors yet\");\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime-source.js","sourceRoot":"","sources":["../../src/runtime/runtime-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AA6HrE;;;;;;;GAOG;AACH,MAAM,OAAgB,aAAa;IACjC,uFAAuF;IAC9E,qBAAqB,GAAY,KAAK,CAAC;IAChD,8EAA8E;IACrE,oBAAoB,GAAY,IAAI,CAAC;IAE9C,KAAK,CAAC,IAAI,CAAC,MAAqB;QAC9B,MAAM,IAAI,CA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from \"./local-first-token.js\";\nimport type { ClientMigrations } from \"./client-migrations.js\";\nimport type { RemoteLinkState } from \"./remote-link-state.js\";\nimport type { LinkStatus } from \"./sync-status.js\";\nimport type { WasmSchema } from \"../drivers/types.js\";\nimport type { JazzClient } from \"./client.js\";\nimport type { DbConfig } from \"./db.js\";\nimport type { AuthFailureReason } from \"./auth-state.js\";\nimport type { TextAnchors } from \"./text-anchors.js\";\n\nexport interface RuntimeTokenOptions {\n secret: string;\n audience: string;\n ttlSeconds: number;\n nowSeconds: bigint;\n}\n\nexport interface RuntimeClientContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n /** The migrations the app defining `schema` ships (see {@link ClientMigrations}). */\n migrations?: ClientMigrations;\n onAuthFailure: (reason: AuthFailureReason) => void;\n /**\n * Browser-only identity leased by the durable SharedWorker before the\n * synchronous foreground client is constructed.\n */\n foregroundNodeLease?: ForegroundNodeLease;\n}\n\n/** Internal foreground TxId lease, never exposed as application API. */\nexport interface ForegroundNodeLease {\n readonly node: Uint8Array;\n readonly confirmedTxTime: bigint;\n /** Atomically persists runtime high-water and makes this node reusable. */\n returnWithHighWater(highWater: bigint): Promise<void>;\n /** Permanently retires this node when clean handoff is not certain. */\n retire(): Promise<void>;\n}\n\n/** Browser-only terminal cleanup; the durable retirement outcome remains unknown. */\nexport interface BrowserForegroundNodeLease extends ForegroundNodeLease {\n /** Ephemeral owner identity; a successor realm cannot acknowledge this port. */\n readonly workerRealmId?: string;\n /** The caller must first disable the foreground lifetime that can mint this node's TxIds. */\n abandonAfterWorkerFailure(error: Error): void;\n /** Locally releases an erased epoch after its worker-authored reset receipt; never writes a handoff. */\n releaseAfterStorageReset(reason: Error): void;\n /** Release a dead owner's port after quiescing; its node remains non-reusable. */\n releaseAfterWorkerReplacement?(reason: Error): void;\n}\n\nexport interface RuntimeTelemetryContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n collectorUrl: string;\n runtimeThread: \"main\" | \"worker\";\n}\n\nexport interface BrowserWorkerConnection {\n /** Only a rejected initial configuration admission permits a later API call to retry. */\n canRetryInitialConfigurationAdmission?(): boolean;\n /**\n * The worker refused this connection because another tab holds the store\n * under another sign-in to the same account: the tab tries again on its\n * own (see `BROWSER_STORE_HELD_BY_ANOTHER_SIGN_IN`).\n */\n waitsForAnotherSignIn?(): boolean;\n ready(): Promise<void>;\n getWorkerRealmId?(): string | undefined;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n disconnect(): Promise<void>;\n reconnect(authJson: string, sessionClaims: Record<string, unknown>): Promise<void>;\n /** Delete the store; resolves with how many unconfirmed writes it took, when the worker says. */\n deleteStorage(): Promise<{ pendingUploads?: number } | void>;\n /** How many of the store's writes (every tab's) the server hasn't confirmed, when the worker says. */\n storePendingUploads?(): Promise<number | undefined>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n openInspectorControlPort(signal?: AbortSignal): Promise<MessagePort>;\n shutdown(): Promise<void>;\n /** Present only after an authenticated Inspector control-port attachment. */\n getAuthenticatedInspectorAttachmentPhysicalDbName?(): string | null;\n}\n\nexport interface BrowserFollowerConnection {\n ready(): Promise<void>;\n flushLocal(): Promise<void>;\n waitForPendingWrites(): Promise<void>;\n waitForServerConnection(): Promise<void>;\n updateAuth(authJson: string, sessionClaims: Record<string, unknown>): void;\n detachForReconnect(): void;\n shutdown(): Promise<void>;\n}\n\nexport interface BrowserWorkerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n schema: WasmSchema;\n client: JazzClient;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\nexport interface BrowserFollowerConnectionContext<RuntimeConfig extends DbConfig = DbConfig> {\n config: RuntimeConfig;\n client: JazzClient;\n port: MessagePort;\n onAuthFailure: (reason: AuthFailureReason) => void;\n onAuthRestored: () => void;\n /** The worker namespace's explicit offline state changed. */\n onExplicitOfflineChange?: (offline: boolean) => void;\n /** The worker's live upstream server reachability changed. */\n onRemoteLinkChange?: (state: RemoteLinkState, link?: LinkStatus) => void;\n onFailure: (error: unknown) => void;\n onStorageReset?: (resetId: number) => void;\n onStorageInvalidated?: () => void;\n}\n\n/**\n * Internal source for loading and wiring the native runtime.\n *\n * This keeps platform/source differences (WASM, NAPI, browser storage, React\n * Native support status) out of Db. The active database path is native-runtime backed:\n * implementations preload the runtime, then create JazzClient instances for\n * concrete schemas.\n */\nexport abstract class RuntimeSource<RuntimeConfig extends DbConfig = DbConfig> {\n /** Set to true when this source can host browser persistence in a dedicated worker. */\n readonly supportsBrowserWorker: boolean = false;\n /** Set to false when the runtime must receive schemas exactly as declared. */\n readonly supportsPolicyBypass: boolean = true;\n\n async load(config: RuntimeConfig): Promise<void> {\n await this.loadRuntime(config);\n }\n\n /** Native hosts own their transport before a schema client is materialized. */\n nativeConnection?: {\n configured(): boolean;\n disconnect(): void | Promise<void>;\n reconnect(): void | Promise<void>;\n /**\n * Native hosts that share one transport between several Db facades own\n * explicit-offline state at the host, rather than on an individual facade.\n */\n isExplicitlyOffline?(): boolean;\n waitForTransportTransition?(): Promise<void>;\n waitForReconnect?(signal?: AbortSignal): Promise<void>;\n onExplicitOfflineChange?(listener: (offline: boolean) => void, signal: AbortSignal): void;\n };\n\n /** Admission-bound native sources reject updates before any public state changes. */\n assertAuthUpdateAllowed(): void {}\n\n /** Return true when the native host renewed its own same-identity transport. */\n refreshAccountToken(_token: string): boolean {\n return false;\n }\n\n /** Apply source-specific admission after the shared auth config is resolved. */\n admitConfig(_config: RuntimeConfig): void {}\n\n /** Shared native hosts supply the pending-write barrier for all their facades. */\n waitForPendingWrites?(signal?: AbortSignal): Promise<void>;\n\n /** Release runtime admission after ordinary client shutdown, including a\n * prepared source whose lazy schema client was never materialized. */\n async shutdown(): Promise<void> {}\n\n protected async loadRuntime(_config: RuntimeConfig): Promise<unknown> {\n return undefined;\n }\n\n abstract createClient(context: RuntimeClientContext<RuntimeConfig>): JazzClient;\n\n /**\n * Optional pre-runtime foreground identity lease for non-browser hosts.\n * Browser persistence uses the dedicated SharedWorker variant below.\n */\n async acquireForegroundNodeLease(\n _config: RuntimeConfig,\n ): Promise<ForegroundNodeLease | undefined> {\n return undefined;\n }\n\n acquireBrowserForegroundNodeLease(_config: RuntimeConfig): Promise<BrowserForegroundNodeLease> {\n return Promise.reject(\n new Error(\"Db runtime source does not support browser foreground leases\"),\n );\n }\n\n createBrowserWorkerConnection(\n _context: BrowserWorkerConnectionContext<RuntimeConfig>,\n ): BrowserWorkerConnection {\n throw new Error(\"Db runtime source does not support browser worker connections\");\n }\n\n createBrowserFollowerConnection(\n _context: BrowserFollowerConnectionContext<RuntimeConfig>,\n ): BrowserFollowerConnection {\n throw new Error(\"Db runtime source does not support browser follower connections\");\n }\n\n installTelemetry(\n _context: RuntimeTelemetryContext<RuntimeConfig>,\n ): (() => void) | null | undefined {\n return null;\n }\n\n /** Same on every host: minted in TypeScript by `src/local-first-auth`. */\n mintLocalFirstToken(options: RuntimeTokenOptions): string {\n return mintLocalFirstTokenFromSeed(\n options.secret,\n options.audience,\n options.ttlSeconds,\n Number(options.nowSeconds),\n );\n }\n\n mintAnonymousToken(_options: RuntimeTokenOptions): string {\n throw new Error(\"Db runtime source does not support anonymous auth\");\n }\n\n textAnchors(): TextAnchors {\n throw new Error(\"Db runtime source does not support text anchors yet\");\n }\n}\n"]}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import type { ColumnType } from "../drivers/types.js";
|
|
2
2
|
/** Normalize only JSON-schema object key order; semantic arrays remain ordered. */
|
|
3
3
|
export declare function columnTypeSignature(columnType: ColumnType): string;
|
|
4
|
+
/**
|
|
5
|
+
* How an enum column's variants change between two column types that are
|
|
6
|
+
* otherwise the same (an enum, or an array of enums at any depth), or null
|
|
7
|
+
* when they differ in anything else. `inPlace` says whether the source's
|
|
8
|
+
* variants keep their order at the start of the target's list.
|
|
9
|
+
*/
|
|
10
|
+
export declare function enumVariantChange(source: ColumnType, target: ColumnType): {
|
|
11
|
+
added: string[];
|
|
12
|
+
dropped: string[];
|
|
13
|
+
inPlace: boolean;
|
|
14
|
+
} | null;
|
|
15
|
+
/**
|
|
16
|
+
* Whether `target` is `source` with enum variants appended to its list:
|
|
17
|
+
* rows written under `source` pass unchanged, and the earlier variants
|
|
18
|
+
* keep their sort order (so no store renumbers its stored tags).
|
|
19
|
+
*/
|
|
20
|
+
export declare function onlyAddsEnumVariants(source: ColumnType, target: ColumnType): boolean;
|
|
4
21
|
export declare function canonicalJsonSchema(value: unknown): string;
|
|
5
22
|
//# sourceMappingURL=schema-metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-metadata.d.ts","sourceRoot":"","sources":["../../src/runtime/schema-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAMlE;AAeD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU1D"}
|
|
1
|
+
{"version":3,"file":"schema-metadata.d.ts","sourceRoot":"","sources":["../../src/runtime/schema-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAMlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,UAAU,GACjB;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAYjE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAGpF;AAeD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU1D"}
|
|
@@ -6,6 +6,34 @@ export function columnTypeSignature(columnType) {
|
|
|
6
6
|
: value;
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* How an enum column's variants change between two column types that are
|
|
11
|
+
* otherwise the same (an enum, or an array of enums at any depth), or null
|
|
12
|
+
* when they differ in anything else. `inPlace` says whether the source's
|
|
13
|
+
* variants keep their order at the start of the target's list.
|
|
14
|
+
*/
|
|
15
|
+
export function enumVariantChange(source, target) {
|
|
16
|
+
if (source.type === "Enum" && target.type === "Enum") {
|
|
17
|
+
return {
|
|
18
|
+
added: target.variants.filter((variant) => !source.variants.includes(variant)),
|
|
19
|
+
dropped: source.variants.filter((variant) => !target.variants.includes(variant)),
|
|
20
|
+
inPlace: source.variants.every((variant, index) => target.variants[index] === variant),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (source.type === "Array" && target.type === "Array") {
|
|
24
|
+
return enumVariantChange(source.element, target.element);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether `target` is `source` with enum variants appended to its list:
|
|
30
|
+
* rows written under `source` pass unchanged, and the earlier variants
|
|
31
|
+
* keep their sort order (so no store renumbers its stored tags).
|
|
32
|
+
*/
|
|
33
|
+
export function onlyAddsEnumVariants(source, target) {
|
|
34
|
+
const change = enumVariantChange(source, target);
|
|
35
|
+
return change !== null && change.dropped.length === 0 && change.inPlace;
|
|
36
|
+
}
|
|
9
37
|
// Rust's UTF-8 string order follows Unicode scalar order, unlike UTF-16 sort.
|
|
10
38
|
function compareUnicodeScalars(left, right) {
|
|
11
39
|
const leftPoints = Array.from(left, (character) => character.codePointAt(0));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-metadata.js","sourceRoot":"","sources":["../../src/runtime/schema-metadata.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,UAAsB;IACxD,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,EAAE,KAAK;QACpD,OAAO,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS;YACpE,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC;YAC5B,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,SAAS,qBAAqB,CAAC,IAAY,EAAE,KAAa;IACxD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC,CAAC;IAC9E,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC,CAAC;IAChF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACrF,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAE,GAAG,WAAW,CAAC,KAAK,CAAE,CAAC;QAC5D,IAAI,UAAU,KAAK,CAAC;YAAE,OAAO,UAAU,CAAC;IAC1C,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,6EAA6E;AAC7E,8EAA8E;AAC9E,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACjF,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,KAAgC,CAAC;QAChD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aAC3B,IAAI,CAAC,qBAAqB,CAAC;aAC3B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAC1E,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import type { ColumnType } from \"../drivers/types.js\";\n\n/** Normalize only JSON-schema object key order; semantic arrays remain ordered. */\nexport function columnTypeSignature(columnType: ColumnType): string {\n return JSON.stringify(columnType, function (key, value) {\n return key === \"schema\" && this.type === \"Json\" && value !== undefined\n ? canonicalJsonSchema(value)\n : value;\n });\n}\n\n// Rust's UTF-8 string order follows Unicode scalar order, unlike UTF-16 sort.\nfunction compareUnicodeScalars(left: string, right: string): number {\n const leftPoints = Array.from(left, (character) => character.codePointAt(0)!);\n const rightPoints = Array.from(right, (character) => character.codePointAt(0)!);\n for (let index = 0; index < Math.min(leftPoints.length, rightPoints.length); index++) {\n const difference = leftPoints[index]! - rightPoints[index]!;\n if (difference !== 0) return difference;\n }\n return leftPoints.length - rightPoints.length;\n}\n\n// Rust's serde_json::Value uses sorted object keys for JSON-schema metadata.\n// This does not normalize stored JSON default text, whose bytes are identity.\nexport function canonicalJsonSchema(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonicalJsonSchema).join(\",\")}]`;\n if (value !== null && typeof value === \"object\") {\n const object = value as Record<string, unknown>;\n return `{${Object.keys(object)\n .sort(compareUnicodeScalars)\n .map((key) => `${JSON.stringify(key)}:${canonicalJsonSchema(object[key])}`)\n .join(\",\")}}`;\n }\n return JSON.stringify(value);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema-metadata.js","sourceRoot":"","sources":["../../src/runtime/schema-metadata.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,UAAsB;IACxD,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,EAAE,KAAK;QACpD,OAAO,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS;YACpE,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC;YAC5B,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAkB,EAClB,MAAkB;IAElB,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACrD,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC9E,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAChF,OAAO,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U,KAAK,CAAC;YAAE,OAAO,UAAU,CAAC;IAC1C,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,6EAA6E;AAC7E,8EAA8E;AAC9E,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACjF,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,KAAgC,CAAC;QAChD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aAC3B,IAAI,CAAC,qBAAqB,CAAC;aAC3B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAC1E,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import type { ColumnType } from \"../drivers/types.js\";\n\n/** Normalize only JSON-schema object key order; semantic arrays remain ordered. */\nexport function columnTypeSignature(columnType: ColumnType): string {\n return JSON.stringify(columnType, function (key, value) {\n return key === \"schema\" && this.type === \"Json\" && value !== undefined\n ? canonicalJsonSchema(value)\n : value;\n });\n}\n\n/**\n * How an enum column's variants change between two column types that are\n * otherwise the same (an enum, or an array of enums at any depth), or null\n * when they differ in anything else. `inPlace` says whether the source's\n * variants keep their order at the start of the target's list.\n */\nexport function enumVariantChange(\n source: ColumnType,\n target: ColumnType,\n): { added: string[]; dropped: string[]; inPlace: boolean } | null {\n if (source.type === \"Enum\" && target.type === \"Enum\") {\n return {\n added: target.variants.filter((variant) => !source.variants.includes(variant)),\n dropped: source.variants.filter((variant) => !target.variants.includes(variant)),\n inPlace: source.variants.every((variant, index) => target.variants[index] === variant),\n };\n }\n if (source.type === \"Array\" && target.type === \"Array\") {\n return enumVariantChange(source.element, target.element);\n }\n return null;\n}\n\n/**\n * Whether `target` is `source` with enum variants appended to its list:\n * rows written under `source` pass unchanged, and the earlier variants\n * keep their sort order (so no store renumbers its stored tags).\n */\nexport function onlyAddsEnumVariants(source: ColumnType, target: ColumnType): boolean {\n const change = enumVariantChange(source, target);\n return change !== null && change.dropped.length === 0 && change.inPlace;\n}\n\n// Rust's UTF-8 string order follows Unicode scalar order, unlike UTF-16 sort.\nfunction compareUnicodeScalars(left: string, right: string): number {\n const leftPoints = Array.from(left, (character) => character.codePointAt(0)!);\n const rightPoints = Array.from(right, (character) => character.codePointAt(0)!);\n for (let index = 0; index < Math.min(leftPoints.length, rightPoints.length); index++) {\n const difference = leftPoints[index]! - rightPoints[index]!;\n if (difference !== 0) return difference;\n }\n return leftPoints.length - rightPoints.length;\n}\n\n// Rust's serde_json::Value uses sorted object keys for JSON-schema metadata.\n// This does not normalize stored JSON default text, whose bytes are identity.\nexport function canonicalJsonSchema(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonicalJsonSchema).join(\",\")}]`;\n if (value !== null && typeof value === \"object\") {\n const object = value as Record<string, unknown>;\n return `{${Object.keys(object)\n .sort(compareUnicodeScalars)\n .map((key) => `${JSON.stringify(key)}:${canonicalJsonSchema(object[key])}`)\n .join(\",\")}}`;\n }\n return JSON.stringify(value);\n}\n"]}
|
|
@@ -19,6 +19,17 @@ export declare const STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE = "store_held_by_anoth
|
|
|
19
19
|
* the other tab lets go. Writes made in the meantime stay in this tab's
|
|
20
20
|
* memory until it joins: a reload before then loses them.
|
|
21
21
|
*
|
|
22
|
+
* A wait or read that failed with this error stays failed: it doesn't
|
|
23
|
+
* resume when the tab joins. The writes behind a failed `wait()` are not
|
|
24
|
+
* lost; they go to the store once the tab joins. Call `wait()` (or the
|
|
25
|
+
* read) again once the sync status is no longer `held-by-another-tab`.
|
|
26
|
+
* Calling it while the store is still held fails at once with this error.
|
|
27
|
+
* Live queries that read only this tab's own data keep running throughout.
|
|
28
|
+
*
|
|
29
|
+
* `db.deleteClientStorage()` waits for the store the same way, and fails
|
|
30
|
+
* with this error past the same patience; called again once the other tab
|
|
31
|
+
* lets go, it deletes the store.
|
|
32
|
+
*
|
|
22
33
|
* Detect it with {@link isStoreHeldByAnotherTabError}, which checks the
|
|
23
34
|
* stable `code`.
|
|
24
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-held-by-another-tab-error.d.ts","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,oCAAoC,8BAA8B,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"store-held-by-another-tab-error.d.ts","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,eAAO,MAAM,oCAAoC,8BAA8B,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAkB,IAAI,gCAAgC;IACtD,QAAQ,CAAC,IAAI,+BAAwC;gBAGnD,OAAO,SAA2L,EAClM,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIhC;AAED,qFAAqF;AACrF,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,oCAAoC,CAAA;CAAE,CAGjF"}
|
|
@@ -19,6 +19,17 @@ export const STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE = "store_held_by_another_tab";
|
|
|
19
19
|
* the other tab lets go. Writes made in the meantime stay in this tab's
|
|
20
20
|
* memory until it joins: a reload before then loses them.
|
|
21
21
|
*
|
|
22
|
+
* A wait or read that failed with this error stays failed: it doesn't
|
|
23
|
+
* resume when the tab joins. The writes behind a failed `wait()` are not
|
|
24
|
+
* lost; they go to the store once the tab joins. Call `wait()` (or the
|
|
25
|
+
* read) again once the sync status is no longer `held-by-another-tab`.
|
|
26
|
+
* Calling it while the store is still held fails at once with this error.
|
|
27
|
+
* Live queries that read only this tab's own data keep running throughout.
|
|
28
|
+
*
|
|
29
|
+
* `db.deleteClientStorage()` waits for the store the same way, and fails
|
|
30
|
+
* with this error past the same patience; called again once the other tab
|
|
31
|
+
* lets go, it deletes the store.
|
|
32
|
+
*
|
|
22
33
|
* Detect it with {@link isStoreHeldByAnotherTabError}, which checks the
|
|
23
34
|
* stable `code`.
|
|
24
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-held-by-another-tab-error.js","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oCAAoC,GAAG,2BAA2B,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"store-held-by-another-tab-error.js","sourceRoot":"","sources":["../../src/runtime/store-held-by-another-tab-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oCAAoC,GAAG,2BAA2B,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACjC,IAAI,GAAG,4BAA4B,CAAC;IAC7C,IAAI,GAAG,oCAAoC,CAAC;IAErD,YACE,OAAO,GAAG,wLAAwL,EAClM,OAA6B;QAE7B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,qFAAqF;AACrF,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,OAAQ,KAA4B,CAAC,IAAI,KAAK,oCAAoC,CAAC;AACrF,CAAC","sourcesContent":["/** Stable `code` of a {@link StoreHeldByAnotherTabError}. */\nexport const STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE = \"store_held_by_another_tab\";\n\n/**\n * Another tab of this browser holds this account's local store under\n * another sign-in, so this tab cannot open it yet.\n *\n * This happens when a guest signs up (or in) in one tab while another tab is\n * still the guest: the store is the same account's, and one store serves one\n * sign-in at a time. The other tab normally follows the sign-up within\n * moments, or closes, and this tab joins on its own. Until then its sync\n * status is `connecting`.\n *\n * If the other tab does not let go for a while (it is frozen in the\n * background, or runs an app build that does not follow sign-ups), the\n * status becomes `{ state: \"offline\", reason: \"held-by-another-tab\",\n * retrying: true }`, and reads and waits that were waiting for the store\n * fail with this error, so the app can ask the user to close or reload the\n * other tab. The tab keeps trying in the background and joins as soon as\n * the other tab lets go. Writes made in the meantime stay in this tab's\n * memory until it joins: a reload before then loses them.\n *\n * A wait or read that failed with this error stays failed: it doesn't\n * resume when the tab joins. The writes behind a failed `wait()` are not\n * lost; they go to the store once the tab joins. Call `wait()` (or the\n * read) again once the sync status is no longer `held-by-another-tab`.\n * Calling it while the store is still held fails at once with this error.\n * Live queries that read only this tab's own data keep running throughout.\n *\n * `db.deleteClientStorage()` waits for the store the same way, and fails\n * with this error past the same patience; called again once the other tab\n * lets go, it deletes the store.\n *\n * Detect it with {@link isStoreHeldByAnotherTabError}, which checks the\n * stable `code`.\n */\nexport class StoreHeldByAnotherTabError extends Error {\n override readonly name = \"StoreHeldByAnotherTabError\";\n readonly code = STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE;\n\n constructor(\n message = \"Another tab holds this account's local store under another sign-in: close or reload that other tab. This tab joins once it lets go; reloading this tab first loses its unsynced writes\",\n options?: { cause?: unknown },\n ) {\n super(message, options);\n }\n}\n\n/** Whether `error` is a {@link StoreHeldByAnotherTabError}, by its stable `code`. */\nexport function isStoreHeldByAnotherTabError(\n error: unknown,\n): error is Error & { readonly code: typeof STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE } {\n if (!error || typeof error !== \"object\") return false;\n return (error as { code?: unknown }).code === STORE_HELD_BY_ANOTHER_TAB_ERROR_CODE;\n}\n"]}
|
|
@@ -52,12 +52,69 @@ export interface SyncStatus {
|
|
|
52
52
|
* reported through `db.onMutationError`.
|
|
53
53
|
*/
|
|
54
54
|
pendingUploads: number;
|
|
55
|
+
/**
|
|
56
|
+
* When the oldest of {@link pendingUploads} was committed, in Unix ms, or
|
|
57
|
+
* null when none waits. How long a write has been stuck is
|
|
58
|
+
* `Date.now() - oldestPendingAt`.
|
|
59
|
+
*/
|
|
60
|
+
oldestPendingAt: number | null;
|
|
61
|
+
/**
|
|
62
|
+
* This client's transactions the server rejected since the Db opened.
|
|
63
|
+
* Each is also reported through `db.onMutationError`, or to the write
|
|
64
|
+
* whose `wait()` claimed it.
|
|
65
|
+
*/
|
|
66
|
+
rejected: number;
|
|
67
|
+
/**
|
|
68
|
+
* The latest thing that went wrong with sync since the Db opened, and
|
|
69
|
+
* when: a rejected transaction, or the link failing. It stays after the
|
|
70
|
+
* link recovers (`link` says how things are now), so an agent or a
|
|
71
|
+
* debugging person can see what happened and when.
|
|
72
|
+
*/
|
|
73
|
+
lastError: SyncError | null;
|
|
55
74
|
/**
|
|
56
75
|
* Nothing waits for upload and the link is connected, or no server is
|
|
57
76
|
* configured.
|
|
58
77
|
*/
|
|
59
78
|
synced: boolean;
|
|
60
79
|
}
|
|
80
|
+
/** What went wrong, as {@link SyncStatus.lastError} reports it. */
|
|
81
|
+
export type SyncError = {
|
|
82
|
+
/** The server rejected a transaction this client committed. */
|
|
83
|
+
kind: "rejected";
|
|
84
|
+
/** The public error code, such as `permission_denied`. */
|
|
85
|
+
code: string;
|
|
86
|
+
message: string;
|
|
87
|
+
/** When the rejection arrived, in Unix ms. */
|
|
88
|
+
at: number;
|
|
89
|
+
} | LinkFailure;
|
|
90
|
+
/** The link failing, as {@link SyncError} reports it. */
|
|
91
|
+
export interface LinkFailure {
|
|
92
|
+
/** Why, as an offline {@link LinkStatus} names it. */
|
|
93
|
+
kind: Exclude<OfflineReason, "disconnected">;
|
|
94
|
+
message: string;
|
|
95
|
+
/** When the link failed this way, in Unix ms. */
|
|
96
|
+
at: number;
|
|
97
|
+
}
|
|
98
|
+
/** @internal A client's uploads, as the core reports them. */
|
|
99
|
+
export interface UploadStatus {
|
|
100
|
+
pending: number;
|
|
101
|
+
oldestPendingAt: number | null;
|
|
102
|
+
rejected: number;
|
|
103
|
+
lastRejection: {
|
|
104
|
+
code: string;
|
|
105
|
+
message: string;
|
|
106
|
+
at: number;
|
|
107
|
+
} | null;
|
|
108
|
+
}
|
|
109
|
+
/** @internal The upload status of a client that has uploaded nothing. */
|
|
110
|
+
export declare const NO_UPLOADS: UploadStatus;
|
|
111
|
+
/** @internal The upload status from a count alone (a host without the full status). */
|
|
112
|
+
export declare function uploadStatusFromCount(pending: number): UploadStatus;
|
|
113
|
+
/** @internal The later of a rejection and a link failure. */
|
|
114
|
+
export declare function latestSyncError(uploads: UploadStatus, link: LinkFailure | null): SyncError | null;
|
|
115
|
+
/** @internal The failure an offline link reports, or null for a link that is not failing. */
|
|
116
|
+
export declare function linkFailureOf(link: LinkStatus, message: string | undefined): LinkFailure | null;
|
|
117
|
+
export declare function sameSyncError(a: SyncError | null, b: SyncError | null): boolean;
|
|
61
118
|
/** @internal The upstream link machine's status, as the core reports it to its host. */
|
|
62
119
|
export interface UpstreamLinkStatus {
|
|
63
120
|
phase: "noServer" | "offline" | "connecting" | "live" | "backoff" | "awaitingCredential" | "stopped";
|
|
@@ -76,8 +133,10 @@ export declare function offlineLink(reason: OfflineReason, retrying?: boolean):
|
|
|
76
133
|
export declare function linkStatusFromUpstream(status: UpstreamLinkStatus | null): LinkStatus;
|
|
77
134
|
export declare function sameLinkStatus(a: LinkStatus, b: LinkStatus): boolean;
|
|
78
135
|
/** @internal Assemble a {@link SyncStatus}. */
|
|
79
|
-
export declare function syncStatus(link: LinkStatus,
|
|
136
|
+
export declare function syncStatus(link: LinkStatus, uploads?: UploadStatus, linkFailure?: LinkFailure | null): SyncStatus;
|
|
80
137
|
export declare function sameSyncStatus(a: SyncStatus, b: SyncStatus): boolean;
|
|
138
|
+
/** @internal Whether two upload statuses report the same. */
|
|
139
|
+
export declare function sameUploadStatus(a: UploadStatus, b: UploadStatus): boolean;
|
|
81
140
|
/**
|
|
82
141
|
* @internal Listener set that publishes a derived value only when it changed.
|
|
83
142
|
* Publication is deferred to a microtask so that intermediate values inside
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-status.d.ts","sourceRoot":"","sources":["../../src/runtime/sync-status.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,SAAS,GACT,MAAM,GACN,SAAS,GACT,mBAAmB,GACnB,qBAAqB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IACE,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEN,6FAA6F;AAC7F,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EACD,UAAU,GACV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AAS,CAAiC;IAC3D,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,SAAS,CAAS;gBAGP,IAAI,EAAE,MAAM,CAAC,EACb,IAAI,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAmB;IAG5D,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAUlE,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,8DAA8D;IAC9D,OAAO,IAAI,IAAI;CAWhB"}
|
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
/** @internal The upload status of a client that has uploaded nothing. */
|
|
2
|
+
export const NO_UPLOADS = Object.freeze({
|
|
3
|
+
pending: 0,
|
|
4
|
+
oldestPendingAt: null,
|
|
5
|
+
rejected: 0,
|
|
6
|
+
lastRejection: null,
|
|
7
|
+
});
|
|
8
|
+
/** @internal The upload status from a count alone (a host without the full status). */
|
|
9
|
+
export function uploadStatusFromCount(pending) {
|
|
10
|
+
return { ...NO_UPLOADS, pending };
|
|
11
|
+
}
|
|
12
|
+
/** @internal The later of a rejection and a link failure. */
|
|
13
|
+
export function latestSyncError(uploads, link) {
|
|
14
|
+
const rejection = uploads.lastRejection
|
|
15
|
+
? { kind: "rejected", ...uploads.lastRejection }
|
|
16
|
+
: null;
|
|
17
|
+
if (!rejection)
|
|
18
|
+
return link;
|
|
19
|
+
if (!link)
|
|
20
|
+
return rejection;
|
|
21
|
+
return link.at > rejection.at ? link : rejection;
|
|
22
|
+
}
|
|
23
|
+
/** @internal The failure an offline link reports, or null for a link that is not failing. */
|
|
24
|
+
export function linkFailureOf(link, message) {
|
|
25
|
+
if (link.state !== "offline" || link.reason === "disconnected")
|
|
26
|
+
return null;
|
|
27
|
+
const said = {
|
|
28
|
+
network: "The server is unreachable; retrying.",
|
|
29
|
+
auth: "The server refused this client's credential.",
|
|
30
|
+
stopped: "The link stopped for good; only db.reconnect() tries again.",
|
|
31
|
+
"authority-changed": "The server serves another history than this client's local store.",
|
|
32
|
+
"held-by-another-tab": "Another tab holds this account's local store under another sign-in.",
|
|
33
|
+
}[link.reason];
|
|
34
|
+
return { kind: link.reason, message: message || said, at: Date.now() };
|
|
35
|
+
}
|
|
36
|
+
export function sameSyncError(a, b) {
|
|
37
|
+
if (a === b)
|
|
38
|
+
return true;
|
|
39
|
+
if (!a || !b)
|
|
40
|
+
return false;
|
|
41
|
+
return (a.kind === b.kind &&
|
|
42
|
+
a.at === b.at &&
|
|
43
|
+
a.message === b.message &&
|
|
44
|
+
(a.kind !== "rejected" || (b.kind === "rejected" && a.code === b.code)));
|
|
45
|
+
}
|
|
1
46
|
export const LOCAL_ONLY = Object.freeze({ state: "local-only" });
|
|
2
47
|
export const CONNECTING = Object.freeze({ state: "connecting" });
|
|
3
48
|
export const CONNECTED = Object.freeze({ state: "connected" });
|
|
@@ -35,15 +80,30 @@ export function sameLinkStatus(a, b) {
|
|
|
35
80
|
return a.reason === b.reason && a.retrying === b.retrying;
|
|
36
81
|
}
|
|
37
82
|
/** @internal Assemble a {@link SyncStatus}. */
|
|
38
|
-
export function syncStatus(link,
|
|
83
|
+
export function syncStatus(link, uploads = NO_UPLOADS, linkFailure = null) {
|
|
39
84
|
return {
|
|
40
85
|
link,
|
|
41
|
-
pendingUploads,
|
|
42
|
-
|
|
86
|
+
pendingUploads: uploads.pending,
|
|
87
|
+
oldestPendingAt: uploads.pending === 0 ? null : uploads.oldestPendingAt,
|
|
88
|
+
rejected: uploads.rejected,
|
|
89
|
+
lastError: latestSyncError(uploads, linkFailure),
|
|
90
|
+
synced: uploads.pending === 0 && (link.state === "connected" || link.state === "local-only"),
|
|
43
91
|
};
|
|
44
92
|
}
|
|
45
93
|
export function sameSyncStatus(a, b) {
|
|
46
|
-
return a.pendingUploads === b.pendingUploads &&
|
|
94
|
+
return (a.pendingUploads === b.pendingUploads &&
|
|
95
|
+
a.oldestPendingAt === b.oldestPendingAt &&
|
|
96
|
+
a.rejected === b.rejected &&
|
|
97
|
+
sameSyncError(a.lastError, b.lastError) &&
|
|
98
|
+
sameLinkStatus(a.link, b.link));
|
|
99
|
+
}
|
|
100
|
+
/** @internal Whether two upload statuses report the same. */
|
|
101
|
+
export function sameUploadStatus(a, b) {
|
|
102
|
+
return (a.pending === b.pending &&
|
|
103
|
+
a.oldestPendingAt === b.oldestPendingAt &&
|
|
104
|
+
a.rejected === b.rejected &&
|
|
105
|
+
a.lastRejection?.at === b.lastRejection?.at &&
|
|
106
|
+
a.lastRejection?.code === b.lastRejection?.code);
|
|
47
107
|
}
|
|
48
108
|
/**
|
|
49
109
|
* @internal Listener set that publishes a derived value only when it changed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-status.js","sourceRoot":"","sources":["../../src/runtime/sync-status.ts"],"names":[],"mappings":"AAgFA,MAAM,CAAC,MAAM,UAAU,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,SAAS,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;AAE3E,0DAA0D;AAC1D,MAAM,UAAU,WAAW,CAAC,MAAqB,EAAE,QAAQ,GAAG,MAAM,KAAK,SAAS;IAChF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAiC;IACtE,QAAQ,MAAM,EAAE,KAAK,IAAI,UAAU,EAAE,CAAC;QACpC,KAAK,UAAU;YACb,OAAO,UAAU,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,WAAW,CAAC,cAAc,C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K,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/** Why a {@link LinkStatus} is `offline`. */\nexport type OfflineReason =\n | \"disconnected\"\n | \"network\"\n | \"auth\"\n | \"stopped\"\n | \"authority-changed\"\n | \"held-by-another-tab\";\n\n/**\n * The upstream connection as an app should show it.\n *\n * - `local-only`: no server is configured; nothing is ever uploaded.\n * - `connecting`: the first connection attempt, or a reconnect after a short\n * drop that has not been reported as an outage yet.\n * - `connected`: the server admitted this client.\n * - `offline`: not connected, with the reason:\n * - `disconnected`: the app called `db.disconnect()`.\n * - `network`: the server has been unreachable for a while; the client\n * keeps retrying (`retrying: true`).\n * - `auth`: the server refused the credential. The client waits for a new\n * one (`db.updateAuthToken(...)`, or a fresh sign-in through the app's\n * backend).\n * - `stopped`: a failure retrying cannot fix (a protocol error or an\n * incompatible server); only `db.reconnect()` tries again.\n * - `authority-changed`: the server serves another history than this\n * client's local store (its store was recreated, or it is another app's\n * server), so nothing syncs with it. Waits for the server fail with an\n * `AuthorityChangedError`, which says how to recover: reset the local\n * store (`db.deleteClientStorage()` in the browser). Nothing is reset\n * automatically, so unsynced writes are never discarded behind the\n * app's back.\n * - `held-by-another-tab` (browser): another tab holds this account's\n * local store under another sign-in (it was still the guest when this\n * tab signed up) and has not let go for a while. The tab keeps trying\n * (`retrying: true`) and joins once the other tab follows or closes;\n * waits fail meanwhile with a `StoreHeldByAnotherTabError`.\n */\nexport type LinkStatus =\n | { state: \"local-only\" }\n | { state: \"connecting\" }\n | { state: \"connected\" }\n | {\n state: \"offline\";\n reason: OfflineReason;\n retrying: boolean;\n };\n\n/** Whether this client's data has reached the server, as `db.getSyncStatus()` reports it. */\nexport interface SyncStatus {\n /** The upstream connection. */\n link: LinkStatus;\n /**\n * Transactions this client committed that the server has neither accepted\n * nor rejected yet. In Node and React Native this includes ones recovered\n * from local storage after a restart; a browser tab counts only its own\n * commits, since the shared worker uploads recovered ones. Rejections are\n * reported through `db.onMutationError`.\n */\n pendingUploads: number;\n /**\n * Nothing waits for upload and the link is connected, or no server is\n * configured.\n */\n synced: boolean;\n}\n\n/** @internal The upstream link machine's status, as the core reports it to its host. */\nexport interface UpstreamLinkStatus {\n phase:\n | \"noServer\"\n | \"offline\"\n | \"connecting\"\n | \"live\"\n | \"backoff\"\n | \"awaitingCredential\"\n | \"stopped\";\n outagePublished: boolean;\n}\n\nexport const LOCAL_ONLY: LinkStatus = Object.freeze({ state: \"local-only\" });\nexport const CONNECTING: LinkStatus = Object.freeze({ state: \"connecting\" });\nexport const CONNECTED: LinkStatus = Object.freeze({ state: \"connected\" });\n\n/** @internal The app-facing status of an offline link. */\nexport function offlineLink(reason: OfflineReason, retrying = reason === \"network\"): LinkStatus {\n return { state: \"offline\", reason, retrying };\n}\n\n/**\n * @internal Map the core link machine's status to {@link LinkStatus}. A\n * dropped link that is retrying reads as `connecting` until the machine\n * publishes an outage, so a short blip never shows as offline.\n */\nexport function linkStatusFromUpstream(status: UpstreamLinkStatus | null): LinkStatus {\n switch (status?.phase ?? \"noServer\") {\n case \"noServer\":\n return LOCAL_ONLY;\n case \"offline\":\n return offlineLink(\"disconnected\");\n case \"live\":\n return CONNECTED;\n case \"connecting\":\n case \"backoff\":\n return status!.outagePublished ? offlineLink(\"network\") : CONNECTING;\n case \"awaitingCredential\":\n return offlineLink(\"auth\");\n case \"stopped\":\n return offlineLink(\"stopped\");\n }\n}\n\nexport function sameLinkStatus(a: LinkStatus, b: LinkStatus): boolean {\n if (a.state !== b.state) return false;\n if (a.state !== \"offline\" || b.state !== \"offline\") return true;\n return a.reason === b.reason && a.retrying === b.retrying;\n}\n\n/** @internal Assemble a {@link SyncStatus}. */\nexport function syncStatus(link: LinkStatus, pendingUploads: number): SyncStatus {\n return {\n link,\n pendingUploads,\n synced: pendingUploads === 0 && (link.state === \"connected\" || link.state === \"local-only\"),\n };\n}\n\nexport function sameSyncStatus(a: SyncStatus, b: SyncStatus): boolean {\n return a.pendingUploads === b.pendingUploads && sameLinkStatus(a.link, b.link);\n}\n\n/**\n * @internal Listener set that publishes a derived value only when it changed.\n * Publication is deferred to a microtask so that intermediate values inside\n * one synchronous transition are never observed.\n */\nexport class DerivedStatePublisher<T> {\n private readonly listeners = new Set<(value: T) => void>();\n private published: T | undefined;\n private scheduled = false;\n\n constructor(\n private readonly read: () => T,\n private readonly same: (a: T, b: T) => boolean = Object.is,\n ) {}\n\n subscribe(listener: (value: T) => void, signal: AbortSignal): void {\n if (signal.aborted) return;\n // Changes are not tracked while nobody listens; resynchronize first.\n if (this.listeners.size === 0) this.published = this.read();\n this.listeners.add(listener);\n signal.addEventListener(\"abort\", () => this.listeners.delete(listener), {\n once: true,\n });\n }\n\n get hasListeners(): boolean {\n return this.listeners.size > 0;\n }\n\n /** Schedule a comparison against the last published value. */\n changed(): void {\n if (this.scheduled || this.listeners.size === 0) return;\n this.scheduled = true;\n queueMicrotask(() => {\n this.scheduled = false;\n const value = this.read();\n if (this.published !== undefined && this.same(value, this.published)) return;\n this.published = value;\n for (const listener of [...this.listeners]) listener(value);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sync-status.js","sourceRoot":"","sources":["../../src/runtime/sync-status.ts"],"names":[],"mappings":"AAoHA,yEAAyE;AACzE,MAAM,CAAC,MAAM,UAAU,GAAiB,MAAM,CAAC,MAAM,CAAC;IACpD,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,IAAI;IACrB,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,IAAI;CACpB,CAAC,CAAC;AAEH,uFAAuF;AACvF,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,eAAe,CAAC,OAAqB,EAAE,IAAwB;IAC7E,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa;QACrC,CAAC,CAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO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CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;gBAAE,OAAO;YAC7E,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;gBAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/** Why a {@link LinkStatus} is `offline`. */\nexport type OfflineReason =\n | \"disconnected\"\n | \"network\"\n | \"auth\"\n | \"stopped\"\n | \"authority-changed\"\n | \"held-by-another-tab\";\n\n/**\n * The upstream connection as an app should show it.\n *\n * - `local-only`: no server is configured; nothing is ever uploaded.\n * - `connecting`: the first connection attempt, or a reconnect after a short\n * drop that has not been reported as an outage yet.\n * - `connected`: the server admitted this client.\n * - `offline`: not connected, with the reason:\n * - `disconnected`: the app called `db.disconnect()`.\n * - `network`: the server has been unreachable for a while; the client\n * keeps retrying (`retrying: true`).\n * - `auth`: the server refused the credential. The client waits for a new\n * one (`db.updateAuthToken(...)`, or a fresh sign-in through the app's\n * backend).\n * - `stopped`: a failure retrying cannot fix (a protocol error or an\n * incompatible server); only `db.reconnect()` tries again.\n * - `authority-changed`: the server serves another history than this\n * client's local store (its store was recreated, or it is another app's\n * server), so nothing syncs with it. Waits for the server fail with an\n * `AuthorityChangedError`, which says how to recover: reset the local\n * store (`db.deleteClientStorage()` in the browser). Nothing is reset\n * automatically, so unsynced writes are never discarded behind the\n * app's back.\n * - `held-by-another-tab` (browser): another tab holds this account's\n * local store under another sign-in (it was still the guest when this\n * tab signed up) and has not let go for a while. The tab keeps trying\n * (`retrying: true`) and joins once the other tab follows or closes;\n * waits fail meanwhile with a `StoreHeldByAnotherTabError`.\n */\nexport type LinkStatus =\n | { state: \"local-only\" }\n | { state: \"connecting\" }\n | { state: \"connected\" }\n | {\n state: \"offline\";\n reason: OfflineReason;\n retrying: boolean;\n };\n\n/** Whether this client's data has reached the server, as `db.getSyncStatus()` reports it. */\nexport interface SyncStatus {\n /** The upstream connection. */\n link: LinkStatus;\n /**\n * Transactions this client committed that the server has neither accepted\n * nor rejected yet. In Node and React Native this includes ones recovered\n * from local storage after a restart; a browser tab counts only its own\n * commits, since the shared worker uploads recovered ones. Rejections are\n * reported through `db.onMutationError`.\n */\n pendingUploads: number;\n /**\n * When the oldest of {@link pendingUploads} was committed, in Unix ms, or\n * null when none waits. How long a write has been stuck is\n * `Date.now() - oldestPendingAt`.\n */\n oldestPendingAt: number | null;\n /**\n * This client's transactions the server rejected since the Db opened.\n * Each is also reported through `db.onMutationError`, or to the write\n * whose `wait()` claimed it.\n */\n rejected: number;\n /**\n * The latest thing that went wrong with sync since the Db opened, and\n * when: a rejected transaction, or the link failing. It stays after the\n * link recovers (`link` says how things are now), so an agent or a\n * debugging person can see what happened and when.\n */\n lastError: SyncError | null;\n /**\n * Nothing waits for upload and the link is connected, or no server is\n * configured.\n */\n synced: boolean;\n}\n\n/** What went wrong, as {@link SyncStatus.lastError} reports it. */\nexport type SyncError =\n | {\n /** The server rejected a transaction this client committed. */\n kind: \"rejected\";\n /** The public error code, such as `permission_denied`. */\n code: string;\n message: string;\n /** When the rejection arrived, in Unix ms. */\n at: number;\n }\n | LinkFailure;\n\n/** The link failing, as {@link SyncError} reports it. */\nexport interface LinkFailure {\n /** Why, as an offline {@link LinkStatus} names it. */\n kind: Exclude<OfflineReason, \"disconnected\">;\n message: string;\n /** When the link failed this way, in Unix ms. */\n at: number;\n}\n\n/** @internal A client's uploads, as the core reports them. */\nexport interface UploadStatus {\n pending: number;\n oldestPendingAt: number | null;\n rejected: number;\n lastRejection: { code: string; message: string; at: number } | null;\n}\n\n/** @internal The upload status of a client that has uploaded nothing. */\nexport const NO_UPLOADS: UploadStatus = Object.freeze({\n pending: 0,\n oldestPendingAt: null,\n rejected: 0,\n lastRejection: null,\n});\n\n/** @internal The upload status from a count alone (a host without the full status). */\nexport function uploadStatusFromCount(pending: number): UploadStatus {\n return { ...NO_UPLOADS, pending };\n}\n\n/** @internal The later of a rejection and a link failure. */\nexport function latestSyncError(uploads: UploadStatus, link: LinkFailure | null): SyncError | null {\n const rejection = uploads.lastRejection\n ? ({ kind: \"rejected\", ...uploads.lastRejection } as const)\n : null;\n if (!rejection) return link;\n if (!link) return rejection;\n return link.at > rejection.at ? link : rejection;\n}\n\n/** @internal The failure an offline link reports, or null for a link that is not failing. */\nexport function linkFailureOf(link: LinkStatus, message: string | undefined): LinkFailure | null {\n if (link.state !== \"offline\" || link.reason === \"disconnected\") return null;\n const said = {\n network: \"The server is unreachable; retrying.\",\n auth: \"The server refused this client's credential.\",\n stopped: \"The link stopped for good; only db.reconnect() tries again.\",\n \"authority-changed\": \"The server serves another history than this client's local store.\",\n \"held-by-another-tab\": \"Another tab holds this account's local store under another sign-in.\",\n }[link.reason];\n return { kind: link.reason, message: message || said, at: Date.now() };\n}\n\nexport function sameSyncError(a: SyncError | null, b: SyncError | null): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return (\n a.kind === b.kind &&\n a.at === b.at &&\n a.message === b.message &&\n (a.kind !== \"rejected\" || (b.kind === \"rejected\" && a.code === b.code))\n );\n}\n\n/** @internal The upstream link machine's status, as the core reports it to its host. */\nexport interface UpstreamLinkStatus {\n phase:\n | \"noServer\"\n | \"offline\"\n | \"connecting\"\n | \"live\"\n | \"backoff\"\n | \"awaitingCredential\"\n | \"stopped\";\n outagePublished: boolean;\n}\n\nexport const LOCAL_ONLY: LinkStatus = Object.freeze({ state: \"local-only\" });\nexport const CONNECTING: LinkStatus = Object.freeze({ state: \"connecting\" });\nexport const CONNECTED: LinkStatus = Object.freeze({ state: \"connected\" });\n\n/** @internal The app-facing status of an offline link. */\nexport function offlineLink(reason: OfflineReason, retrying = reason === \"network\"): LinkStatus {\n return { state: \"offline\", reason, retrying };\n}\n\n/**\n * @internal Map the core link machine's status to {@link LinkStatus}. A\n * dropped link that is retrying reads as `connecting` until the machine\n * publishes an outage, so a short blip never shows as offline.\n */\nexport function linkStatusFromUpstream(status: UpstreamLinkStatus | null): LinkStatus {\n switch (status?.phase ?? \"noServer\") {\n case \"noServer\":\n return LOCAL_ONLY;\n case \"offline\":\n return offlineLink(\"disconnected\");\n case \"live\":\n return CONNECTED;\n case \"connecting\":\n case \"backoff\":\n return status!.outagePublished ? offlineLink(\"network\") : CONNECTING;\n case \"awaitingCredential\":\n return offlineLink(\"auth\");\n case \"stopped\":\n return offlineLink(\"stopped\");\n }\n}\n\nexport function sameLinkStatus(a: LinkStatus, b: LinkStatus): boolean {\n if (a.state !== b.state) return false;\n if (a.state !== \"offline\" || b.state !== \"offline\") return true;\n return a.reason === b.reason && a.retrying === b.retrying;\n}\n\n/** @internal Assemble a {@link SyncStatus}. */\nexport function syncStatus(\n link: LinkStatus,\n uploads: UploadStatus = NO_UPLOADS,\n linkFailure: LinkFailure | null = null,\n): SyncStatus {\n return {\n link,\n pendingUploads: uploads.pending,\n oldestPendingAt: uploads.pending === 0 ? null : uploads.oldestPendingAt,\n rejected: uploads.rejected,\n lastError: latestSyncError(uploads, linkFailure),\n synced: uploads.pending === 0 && (link.state === \"connected\" || link.state === \"local-only\"),\n };\n}\n\nexport function sameSyncStatus(a: SyncStatus, b: SyncStatus): boolean {\n return (\n a.pendingUploads === b.pendingUploads &&\n a.oldestPendingAt === b.oldestPendingAt &&\n a.rejected === b.rejected &&\n sameSyncError(a.lastError, b.lastError) &&\n sameLinkStatus(a.link, b.link)\n );\n}\n\n/** @internal Whether two upload statuses report the same. */\nexport function sameUploadStatus(a: UploadStatus, b: UploadStatus): boolean {\n return (\n a.pending === b.pending &&\n a.oldestPendingAt === b.oldestPendingAt &&\n a.rejected === b.rejected &&\n a.lastRejection?.at === b.lastRejection?.at &&\n a.lastRejection?.code === b.lastRejection?.code\n );\n}\n\n/**\n * @internal Listener set that publishes a derived value only when it changed.\n * Publication is deferred to a microtask so that intermediate values inside\n * one synchronous transition are never observed.\n */\nexport class DerivedStatePublisher<T> {\n private readonly listeners = new Set<(value: T) => void>();\n private published: T | undefined;\n private scheduled = false;\n\n constructor(\n private readonly read: () => T,\n private readonly same: (a: T, b: T) => boolean = Object.is,\n ) {}\n\n subscribe(listener: (value: T) => void, signal: AbortSignal): void {\n if (signal.aborted) return;\n // Changes are not tracked while nobody listens; resynchronize first.\n if (this.listeners.size === 0) this.published = this.read();\n this.listeners.add(listener);\n signal.addEventListener(\"abort\", () => this.listeners.delete(listener), {\n once: true,\n });\n }\n\n get hasListeners(): boolean {\n return this.listeners.size > 0;\n }\n\n /** Schedule a comparison against the last published value. */\n changed(): void {\n if (this.scheduled || this.listeners.size === 0) return;\n this.scheduled = true;\n queueMicrotask(() => {\n this.scheduled = false;\n const value = this.read();\n if (this.published !== undefined && this.same(value, this.published)) return;\n this.published = value;\n for (const listener of [...this.listeners]) listener(value);\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-loader.d.ts","sourceRoot":"","sources":["../../src/runtime/wasm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"wasm-loader.d.ts","sourceRoot":"","sources":["../../src/runtime/wasm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAUzD,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG,cAAc,WAAW,CAAC,CAAC;AA8BpD,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CAOlF"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { resolveRuntimeConfigSyncInitInput, resolveRuntimeConfigWasmUrl, } from "./runtime-config.js";
|
|
2
2
|
import { assertNativeArtifactCompatibility } from "./native-artifact-compatibility.js";
|
|
3
3
|
import { installJsonSchemaValidator } from "./json-schema-validator.js";
|
|
4
|
+
import { browserRuntimeModuleUrl, bundledWasmUrl } from "./browser-worker-assets.js";
|
|
5
|
+
import { isMetroBundle, METRO_SETUP_ERROR } from "./metro-setup-error.js";
|
|
4
6
|
async function tryLoadNodePackagedWasmBinary() {
|
|
5
7
|
const moduleBuiltin = process.getBuiltinModule?.("module");
|
|
6
8
|
const fsBuiltin = process.getBuiltinModule?.("fs");
|
|
@@ -51,11 +53,16 @@ async function initializeWasmModule(runtime) {
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
if (!nodeInitDone && typeof wasmModule.default === "function") {
|
|
56
|
+
// A bundler that does not follow wasm-bindgen's own reference to the
|
|
57
|
+
// binary (Metro) names its URL for it instead.
|
|
54
58
|
const wasmUrl = typeof location !== "undefined"
|
|
55
|
-
? resolveRuntimeConfigWasmUrl(
|
|
59
|
+
? (resolveRuntimeConfigWasmUrl(browserRuntimeModuleUrl, location.href, runtime) ??
|
|
60
|
+
bundledWasmUrl())
|
|
56
61
|
: null;
|
|
57
62
|
if (wasmUrl)
|
|
58
63
|
await initializeWasmFromUrl(wasmModule, wasmUrl);
|
|
64
|
+
else if (typeof location !== "undefined" && isMetroBundle())
|
|
65
|
+
throw new Error(METRO_SETUP_ERROR);
|
|
59
66
|
else
|
|
60
67
|
await wasmModule.default();
|
|
61
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-loader.js","sourceRoot":"","sources":["../../src/runtime/wasm-loader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA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C,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC9C,MAAM,IAAI,KAAK,CACb,uDAAuD,OAAO,KAAK,WAAW,MAAM,KAAK,CAAC,OAAO,EAAE,CACpG,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvD,kBAAkB,GAAG,OAAO,CAAC;QAC7B,OAAO;IACT,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,IACE,KAAK,CAAC,MAAM,GAAG,CAAC;QAChB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QACjB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QACjB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QACjB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EACjB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,uDAAuD,OAAO,KAAK,WAAW,IAAI,sBAAsB,GAAG,CAC5G,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,kBAAkB,GAAG,OAAO,CAAC;AAC/B,CAAC;AAED,SAAS,mBAAmB,CAAC,WAA0B;IACrD,IAAI,OAAO,WAAW,CAAC,gBAAgB,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC;IACrE,0EAA0E;IAC1E,yEAAyE;IACzE,2DAA2D;IAC3D,OAAO,WAAW,EAAE,IAAI,EAAE,KAAK,kBAAkB,CAAC;AACpD,CAAC","sourcesContent":["import type { RuntimeSourcesConfig } from \"./context.js\";\nimport {\n resolveRuntimeConfigSyncInitInput,\n resolveRuntimeConfigWasmUrl,\n} from \"./runtime-config.js\";\nimport { assertNativeArtifactCompatibility } from \"./native-artifact-compatibility.js\";\nimport { installJsonSchemaValidator } from \"./json-schema-validator.js\";\n\n/** WASM-only loader, deliberately outside the shared client implementation. */\nexport type WasmModule = typeof import(\"jazz-wasm\");\n\nasync function tryLoadNodePackagedWasmBinary(): Promise<Uint8Array | null> {\n const moduleBuiltin = process.getBuiltinModule?.(\"module\");\n const fsBuiltin = process.getBuiltinModule?.(\"fs\");\n const pathBuiltin = process.getBuiltinModule?.(\"path\");\n\n if (!moduleBuiltin || !fsBuiltin || !pathBuiltin) return null;\n\n const { createRequire } = moduleBuiltin;\n const { existsSync, readFileSync } = fsBuiltin;\n const { dirname, resolve } = pathBuiltin;\n\n const sealedWasmPackage = process.env.JAZZ_CORRECTNESS_WASM_PACKAGE;\n if (process.env.JAZZ_CORRECTNESS_ARTIFACT_RUN === \"1\" && !sealedWasmPackage)\n throw new Error(\"sealed correctness consumer is missing its admitted WASM package\");\n if (sealedWasmPackage) {\n const wasmPath = resolve(sealedWasmPackage, \"jazz_wasm_bg.wasm\");\n return existsSync(wasmPath) ? readFileSync(wasmPath) : null;\n }\n\n const require = createRequire(import.meta.url);\n const packageJsonPath = require.resolve(\"jazz-wasm/package.json\");\n const wasmPath = resolve(dirname(packageJsonPath), \"pkg/jazz_wasm_bg.wasm\");\n return existsSync(wasmPath) ? readFileSync(wasmPath) : null;\n}\n\nlet wasmInitializationTail: Promise<void> = Promise.resolve();\nlet initializedWasmUrl: string | undefined;\n\n/** Load and initialize the browser/Node WASM runtime. */\nexport function loadWasmModule(runtime?: RuntimeSourcesConfig): Promise<WasmModule> {\n const initialization = wasmInitializationTail.then(() => initializeWasmModule(runtime));\n wasmInitializationTail = initialization.then(\n () => undefined,\n () => undefined,\n );\n return initialization;\n}\n\nasync function initializeWasmModule(runtime?: RuntimeSourcesConfig): Promise<WasmModule> {\n const wasmModule: any = await import(\"jazz-wasm\");\n const syncInitInput = resolveRuntimeConfigSyncInitInput(runtime);\n if (syncInitInput) {\n wasmModule.initSync(syncInitInput);\n return readyWasmModule(wasmModule);\n }\n\n let nodeInitDone = false;\n if (typeof process !== \"undefined\" && process.versions?.node) {\n try {\n const wasmBinary = await tryLoadNodePackagedWasmBinary();\n if (wasmBinary) {\n wasmModule.initSync({ module: wasmBinary });\n nodeInitDone = true;\n }\n } catch {\n // Node builtins can be polyfilled but unavailable in browser-like hosts.\n }\n }\n if (!nodeInitDone && typeof wasmModule.default === \"function\") {\n const wasmUrl =\n typeof location !== \"undefined\"\n ? resolveRuntimeConfigWasmUrl(import.meta.url, location.href, runtime)\n : null;\n if (wasmUrl) await initializeWasmFromUrl(wasmModule, wasmUrl);\n else await wasmModule.default();\n }\n\n return readyWasmModule(wasmModule);\n}\n\nfunction readyWasmModule(wasmModule: any): WasmModule {\n assertNativeArtifactCompatibility(wasmModule, \"WASM\", [\n \"initSync\",\n \"WasmDb\",\n \"setJsonSchemaValidator\",\n ]);\n installJsonSchemaValidator(wasmModule);\n return wasmModule;\n}\n\nasync function initializeWasmFromUrl(wasmModule: any, wasmUrl: string): Promise<void> {\n // The initialization tail serializes callers within this realm. Reuse a\n // successful URL load across account-manager and database initialization.\n if (initializedWasmUrl === wasmUrl) return;\n\n const response = await fetch(wasmUrl);\n if (!response.ok) {\n throw new Error(\n `WASM asset request failed (${response.status} ${response.statusText}) for ${wasmUrl}`,\n );\n }\n const contentType = response.headers.get(\"content-type\");\n if (canCompileStreaming(contentType)) {\n // Compile while the body downloads. compileStreaming requires the exact\n // application/wasm content type; any other response takes the buffered\n // path below, which also validates the magic bytes.\n let compiled: WebAssembly.Module;\n try {\n compiled = await WebAssembly.compileStreaming(response);\n } catch (error) {\n if (error instanceof WebAssembly.CompileError) {\n throw new Error(\n `WASM asset response is not a WebAssembly binary for ${wasmUrl} (${contentType}): ${error.message}`,\n );\n }\n throw error;\n }\n await wasmModule.default({ module_or_path: compiled });\n initializedWasmUrl = wasmUrl;\n return;\n }\n const bytes = new Uint8Array(await response.arrayBuffer());\n if (\n bytes.length < 4 ||\n bytes[0] !== 0x00 ||\n bytes[1] !== 0x61 ||\n bytes[2] !== 0x73 ||\n bytes[3] !== 0x6d\n ) {\n throw new Error(\n `WASM asset response is not a WebAssembly binary for ${wasmUrl} (${contentType ?? \"unknown content type\"})`,\n );\n }\n await wasmModule.default({ module_or_path: bytes });\n initializedWasmUrl = wasmUrl;\n}\n\nfunction canCompileStreaming(contentType: string | null): boolean {\n if (typeof WebAssembly.compileStreaming !== \"function\") return false;\n // compileStreaming rejects anything but exactly application/wasm (engines\n // differ on case, and parameters are never accepted), so only that exact\n // type streams; everything else is buffered and validated.\n return contentType?.trim() === \"application/wasm\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wasm-loader.js","sourceRoot":"","sources":["../../src/runtime/wasm-loader.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK1E,KAAK,UAAU,6BAA6B;IAC1C,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,CAAC;IAEvD,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAE9D,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;IACxC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GA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,CAAC;QACvD,kBAAkB,GAAG,OAAO,CAAC;QAC7B,OAAO;IACT,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,IACE,KAAK,CAAC,MAAM,GAAG,CAAC;QAChB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QACjB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QACjB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI;QACjB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EACjB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,uDAAuD,OAAO,KAAK,WAAW,IAAI,sBAAsB,GAAG,CAC5G,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,kBAAkB,GAAG,OAAO,CAAC;AAC/B,CAAC;AAED,SAAS,mBAAmB,CAAC,WAA0B;IACrD,IAAI,OAAO,WAAW,CAAC,gBAAgB,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC;IACrE,0EAA0E;IAC1E,yEAAyE;IACzE,2DAA2D;IAC3D,OAAO,WAAW,EAAE,IAAI,EAAE,KAAK,kBAAkB,CAAC;AACpD,CAAC","sourcesContent":["import type { RuntimeSourcesConfig } from \"./context.js\";\nimport {\n resolveRuntimeConfigSyncInitInput,\n resolveRuntimeConfigWasmUrl,\n} from \"./runtime-config.js\";\nimport { assertNativeArtifactCompatibility } from \"./native-artifact-compatibility.js\";\nimport { installJsonSchemaValidator } from \"./json-schema-validator.js\";\nimport { browserRuntimeModuleUrl, bundledWasmUrl } from \"./browser-worker-assets.js\";\nimport { isMetroBundle, METRO_SETUP_ERROR } from \"./metro-setup-error.js\";\n\n/** WASM-only loader, deliberately outside the shared client implementation. */\nexport type WasmModule = typeof import(\"jazz-wasm\");\n\nasync function tryLoadNodePackagedWasmBinary(): Promise<Uint8Array | null> {\n const moduleBuiltin = process.getBuiltinModule?.(\"module\");\n const fsBuiltin = process.getBuiltinModule?.(\"fs\");\n const pathBuiltin = process.getBuiltinModule?.(\"path\");\n\n if (!moduleBuiltin || !fsBuiltin || !pathBuiltin) return null;\n\n const { createRequire } = moduleBuiltin;\n const { existsSync, readFileSync } = fsBuiltin;\n const { dirname, resolve } = pathBuiltin;\n\n const sealedWasmPackage = process.env.JAZZ_CORRECTNESS_WASM_PACKAGE;\n if (process.env.JAZZ_CORRECTNESS_ARTIFACT_RUN === \"1\" && !sealedWasmPackage)\n throw new Error(\"sealed correctness consumer is missing its admitted WASM package\");\n if (sealedWasmPackage) {\n const wasmPath = resolve(sealedWasmPackage, \"jazz_wasm_bg.wasm\");\n return existsSync(wasmPath) ? readFileSync(wasmPath) : null;\n }\n\n const require = createRequire(import.meta.url);\n const packageJsonPath = require.resolve(\"jazz-wasm/package.json\");\n const wasmPath = resolve(dirname(packageJsonPath), \"pkg/jazz_wasm_bg.wasm\");\n return existsSync(wasmPath) ? readFileSync(wasmPath) : null;\n}\n\nlet wasmInitializationTail: Promise<void> = Promise.resolve();\nlet initializedWasmUrl: string | undefined;\n\n/** Load and initialize the browser/Node WASM runtime. */\nexport function loadWasmModule(runtime?: RuntimeSourcesConfig): Promise<WasmModule> {\n const initialization = wasmInitializationTail.then(() => initializeWasmModule(runtime));\n wasmInitializationTail = initialization.then(\n () => undefined,\n () => undefined,\n );\n return initialization;\n}\n\nasync function initializeWasmModule(runtime?: RuntimeSourcesConfig): Promise<WasmModule> {\n const wasmModule: any = await import(\"jazz-wasm\");\n const syncInitInput = resolveRuntimeConfigSyncInitInput(runtime);\n if (syncInitInput) {\n wasmModule.initSync(syncInitInput);\n return readyWasmModule(wasmModule);\n }\n\n let nodeInitDone = false;\n if (typeof process !== \"undefined\" && process.versions?.node) {\n try {\n const wasmBinary = await tryLoadNodePackagedWasmBinary();\n if (wasmBinary) {\n wasmModule.initSync({ module: wasmBinary });\n nodeInitDone = true;\n }\n } catch {\n // Node builtins can be polyfilled but unavailable in browser-like hosts.\n }\n }\n if (!nodeInitDone && typeof wasmModule.default === \"function\") {\n // A bundler that does not follow wasm-bindgen's own reference to the\n // binary (Metro) names its URL for it instead.\n const wasmUrl =\n typeof location !== \"undefined\"\n ? (resolveRuntimeConfigWasmUrl(browserRuntimeModuleUrl, location.href, runtime) ??\n bundledWasmUrl())\n : null;\n if (wasmUrl) await initializeWasmFromUrl(wasmModule, wasmUrl);\n else if (typeof location !== \"undefined\" && isMetroBundle()) throw new Error(METRO_SETUP_ERROR);\n else await wasmModule.default();\n }\n\n return readyWasmModule(wasmModule);\n}\n\nfunction readyWasmModule(wasmModule: any): WasmModule {\n assertNativeArtifactCompatibility(wasmModule, \"WASM\", [\n \"initSync\",\n \"WasmDb\",\n \"setJsonSchemaValidator\",\n ]);\n installJsonSchemaValidator(wasmModule);\n return wasmModule;\n}\n\nasync function initializeWasmFromUrl(wasmModule: any, wasmUrl: string): Promise<void> {\n // The initialization tail serializes callers within this realm. Reuse a\n // successful URL load across account-manager and database initialization.\n if (initializedWasmUrl === wasmUrl) return;\n\n const response = await fetch(wasmUrl);\n if (!response.ok) {\n throw new Error(\n `WASM asset request failed (${response.status} ${response.statusText}) for ${wasmUrl}`,\n );\n }\n const contentType = response.headers.get(\"content-type\");\n if (canCompileStreaming(contentType)) {\n // Compile while the body downloads. compileStreaming requires the exact\n // application/wasm content type; any other response takes the buffered\n // path below, which also validates the magic bytes.\n let compiled: WebAssembly.Module;\n try {\n compiled = await WebAssembly.compileStreaming(response);\n } catch (error) {\n if (error instanceof WebAssembly.CompileError) {\n throw new Error(\n `WASM asset response is not a WebAssembly binary for ${wasmUrl} (${contentType}): ${error.message}`,\n );\n }\n throw error;\n }\n await wasmModule.default({ module_or_path: compiled });\n initializedWasmUrl = wasmUrl;\n return;\n }\n const bytes = new Uint8Array(await response.arrayBuffer());\n if (\n bytes.length < 4 ||\n bytes[0] !== 0x00 ||\n bytes[1] !== 0x61 ||\n bytes[2] !== 0x73 ||\n bytes[3] !== 0x6d\n ) {\n throw new Error(\n `WASM asset response is not a WebAssembly binary for ${wasmUrl} (${contentType ?? \"unknown content type\"})`,\n );\n }\n await wasmModule.default({ module_or_path: bytes });\n initializedWasmUrl = wasmUrl;\n}\n\nfunction canCompileStreaming(contentType: string | null): boolean {\n if (typeof WebAssembly.compileStreaming !== \"function\") return false;\n // compileStreaming rejects anything but exactly application/wasm (engines\n // differ on case, and parameters are never accepted), so only that exact\n // type streams; everything else is buffered and validated.\n return contentType?.trim() === \"application/wasm\";\n}\n"]}
|
package/dist/schema-loader.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface LoadedSchemaProject {
|
|
|
13
13
|
wasmSchema: WasmSchema;
|
|
14
14
|
}
|
|
15
15
|
export declare function hasRootSchema(schemaDir: string): Promise<boolean>;
|
|
16
|
+
/** The root schema.ts of the project in `schemaDir`, if it has one. */
|
|
17
|
+
export declare function rootSchemaFile(schemaDir: string): string | null;
|
|
16
18
|
/** The generated module an app imports its `migrations` from. */
|
|
17
19
|
export declare const CLIENT_MIGRATIONS_MODULE = "index.ts";
|
|
18
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-loader.d.ts","sourceRoot":"","sources":["../src/schema-loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAA2B,MAAM,EAA0B,MAAM,aAAa,CAAC;AAC3F,OAAO,KAAK,EAKV,UAAU,EACX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAatE,eAAO,MAAM,qBAAqB,EAAE;IAClC,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAGzD,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAA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B;AA6dD,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEvE;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE/D;AAED,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,aAAa,CAAC;AAInD;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAElF;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA+DxF"}
|
package/dist/schema-loader.js
CHANGED
|
@@ -415,6 +415,10 @@ function resolveRootSchemaFiles(schemaDir) {
|
|
|
415
415
|
export async function hasRootSchema(schemaDir) {
|
|
416
416
|
return resolveRootSchemaFiles(schemaDir) !== null;
|
|
417
417
|
}
|
|
418
|
+
/** The root schema.ts of the project in `schemaDir`, if it has one. */
|
|
419
|
+
export function rootSchemaFile(schemaDir) {
|
|
420
|
+
return resolveRootSchemaFiles(schemaDir)?.schemaFile ?? null;
|
|
421
|
+
}
|
|
418
422
|
/** The generated module an app imports its `migrations` from. */
|
|
419
423
|
export const CLIENT_MIGRATIONS_MODULE = "index.ts";
|
|
420
424
|
const IMPORTS_CLIENT_MIGRATIONS = /from\s+["']\.\/migrations(?:\/index(?:\.[jt]s)?)?["']/;
|
|
@@ -436,7 +440,7 @@ export function clientMigrationsPath(schemaFile) {
|
|
|
436
440
|
export async function writeClientMigrationsModule(path, bundle) {
|
|
437
441
|
const contents = [
|
|
438
442
|
"// Generated by jazz-tools from schema.ts and its migrations. Do not edit:",
|
|
439
|
-
"// `jazz-tools validate` and `
|
|
443
|
+
"// `jazz-tools validate` and `jazz-tools migrations create` rewrite it.",
|
|
440
444
|
'import type { ClientMigrations } from "jazz-tools";',
|
|
441
445
|
"",
|
|
442
446
|
"// JSON, which Rust apps read too: formatters leave it as it is.",
|
|
@@ -459,7 +463,8 @@ export async function loadCompiledSchema(schemaDir) {
|
|
|
459
463
|
`Pass --schema-dir <path> to point at a different root.`);
|
|
460
464
|
}
|
|
461
465
|
// schema.ts imports the migrations module `jazz-tools` generates from it:
|
|
462
|
-
// a fresh project gets an empty one, which validate and
|
|
466
|
+
// a fresh project gets an empty one, which validate and migrations create
|
|
467
|
+
// write whole.
|
|
463
468
|
const migrationsModule = clientMigrationsPath(resolved.schemaFile);
|
|
464
469
|
if (!existsSync(migrationsModule) && (await importsClientMigrations(resolved.schemaFile))) {
|
|
465
470
|
await writeClientMigrationsModule(migrationsModule, null);
|