@astrogate/sdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/THIRD_PARTY_NOTICES.md +17 -0
- package/dist/browser.d.ts +85 -0
- package/dist/browser.js +16 -0
- package/dist/database-binding.d.ts +7 -0
- package/dist/database-binding.js +11 -0
- package/dist/hosted-session.d.ts +1 -0
- package/dist/hosted-session.js +11 -0
- package/dist/http.d.ts +24 -0
- package/dist/http.js +92 -0
- package/dist/inventory.d.ts +7 -0
- package/dist/inventory.js +18 -0
- package/dist/management-read.d.ts +17 -0
- package/dist/management-read.js +104 -0
- package/dist/management.d.ts +347 -0
- package/dist/management.js +137 -0
- package/dist/operator.d.ts +136 -0
- package/dist/operator.js +53 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +10 -0
- package/dist/server.d.ts +27 -0
- package/dist/server.js +30 -0
- package/dist/services.d.ts +7 -0
- package/dist/services.js +53 -0
- package/dist/storage.d.ts +68 -0
- package/dist/storage.js +30 -0
- package/dist/tasks.d.ts +42 -0
- package/dist/tasks.js +24 -0
- package/dist/wire.gen.d.ts +7107 -0
- package/dist/wire.gen.js +5 -0
- package/native-provenance.json +15 -0
- package/node_modules/@instantdb/admin/LICENSE +202 -0
- package/node_modules/@instantdb/admin/dist/esm/index.d.ts +607 -0
- package/node_modules/@instantdb/admin/dist/esm/index.js +1036 -0
- package/node_modules/@instantdb/admin/dist/esm/polyfill.d.ts +16 -0
- package/node_modules/@instantdb/admin/dist/esm/polyfill.js +21 -0
- package/node_modules/@instantdb/admin/dist/esm/subscribe.d.ts +38 -0
- package/node_modules/@instantdb/admin/dist/esm/subscribe.js +301 -0
- package/node_modules/@instantdb/admin/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/admin/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/admin/package.json +23 -0
- package/node_modules/@instantdb/core/LICENSE +202 -0
- package/node_modules/@instantdb/core/dist/esm/Connection.d.ts +92 -0
- package/node_modules/@instantdb/core/dist/esm/Connection.js +188 -0
- package/node_modules/@instantdb/core/dist/esm/InMemoryStorage.d.ts +10 -0
- package/node_modules/@instantdb/core/dist/esm/InMemoryStorage.js +25 -0
- package/node_modules/@instantdb/core/dist/esm/IndexedDBStorage.d.ts +17 -0
- package/node_modules/@instantdb/core/dist/esm/IndexedDBStorage.js +309 -0
- package/node_modules/@instantdb/core/dist/esm/InstantError.d.ts +6 -0
- package/node_modules/@instantdb/core/dist/esm/InstantError.js +23 -0
- package/node_modules/@instantdb/core/dist/esm/Reactor.d.ts +430 -0
- package/node_modules/@instantdb/core/dist/esm/Reactor.js +2369 -0
- package/node_modules/@instantdb/core/dist/esm/StorageAPI.d.ts +39 -0
- package/node_modules/@instantdb/core/dist/esm/StorageAPI.js +65 -0
- package/node_modules/@instantdb/core/dist/esm/Stream.d.ts +120 -0
- package/node_modules/@instantdb/core/dist/esm/Stream.js +811 -0
- package/node_modules/@instantdb/core/dist/esm/SyncTable.d.ts +144 -0
- package/node_modules/@instantdb/core/dist/esm/SyncTable.js +523 -0
- package/node_modules/@instantdb/core/dist/esm/WindowNetworkListener.d.ts +4 -0
- package/node_modules/@instantdb/core/dist/esm/WindowNetworkListener.js +19 -0
- package/node_modules/@instantdb/core/dist/esm/attrTypes.d.ts +25 -0
- package/node_modules/@instantdb/core/dist/esm/attrTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/authAPI.d.ts +64 -0
- package/node_modules/@instantdb/core/dist/esm/authAPI.js +103 -0
- package/node_modules/@instantdb/core/dist/esm/clientTypes.d.ts +40 -0
- package/node_modules/@instantdb/core/dist/esm/clientTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/coreTypes.d.ts +33 -0
- package/node_modules/@instantdb/core/dist/esm/coreTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/createRouteHandler.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/createRouteHandler.js +51 -0
- package/node_modules/@instantdb/core/dist/esm/datalog.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/datalog.js +99 -0
- package/node_modules/@instantdb/core/dist/esm/devtool.d.ts +3 -0
- package/node_modules/@instantdb/core/dist/esm/devtool.js +144 -0
- package/node_modules/@instantdb/core/dist/esm/framework.d.ts +80 -0
- package/node_modules/@instantdb/core/dist/esm/framework.js +243 -0
- package/node_modules/@instantdb/core/dist/esm/helperTypes.d.ts +75 -0
- package/node_modules/@instantdb/core/dist/esm/helperTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/index.d.ts +597 -0
- package/node_modules/@instantdb/core/dist/esm/index.js +649 -0
- package/node_modules/@instantdb/core/dist/esm/infiniteQuery.d.ts +25 -0
- package/node_modules/@instantdb/core/dist/esm/infiniteQuery.js +430 -0
- package/node_modules/@instantdb/core/dist/esm/instaml.d.ts +17 -0
- package/node_modules/@instantdb/core/dist/esm/instaml.js +576 -0
- package/node_modules/@instantdb/core/dist/esm/instaql.d.ts +12 -0
- package/node_modules/@instantdb/core/dist/esm/instaql.js +632 -0
- package/node_modules/@instantdb/core/dist/esm/instatx.d.ts +127 -0
- package/node_modules/@instantdb/core/dist/esm/instatx.js +93 -0
- package/node_modules/@instantdb/core/dist/esm/model/instaqlResult.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/model/instaqlResult.js +24 -0
- package/node_modules/@instantdb/core/dist/esm/parseSchemaFromJSON.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/parseSchemaFromJSON.js +142 -0
- package/node_modules/@instantdb/core/dist/esm/presence.d.ts +50 -0
- package/node_modules/@instantdb/core/dist/esm/presence.js +50 -0
- package/node_modules/@instantdb/core/dist/esm/presenceTypes.d.ts +9 -0
- package/node_modules/@instantdb/core/dist/esm/presenceTypes.js +3 -0
- package/node_modules/@instantdb/core/dist/esm/queryTypes.d.ts +271 -0
- package/node_modules/@instantdb/core/dist/esm/queryTypes.js +3 -0
- package/node_modules/@instantdb/core/dist/esm/queryValidation.d.ts +5 -0
- package/node_modules/@instantdb/core/dist/esm/queryValidation.js +287 -0
- package/node_modules/@instantdb/core/dist/esm/reactorTypes.d.ts +29 -0
- package/node_modules/@instantdb/core/dist/esm/reactorTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/routeHandlerProtocol.d.ts +19 -0
- package/node_modules/@instantdb/core/dist/esm/routeHandlerProtocol.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/rulesTypes.d.ts +85 -0
- package/node_modules/@instantdb/core/dist/esm/rulesTypes.js +1 -0
- package/node_modules/@instantdb/core/dist/esm/sanityCheckQueries.d.ts +18 -0
- package/node_modules/@instantdb/core/dist/esm/sanityCheckQueries.js +152 -0
- package/node_modules/@instantdb/core/dist/esm/schema.d.ts +72 -0
- package/node_modules/@instantdb/core/dist/esm/schema.js +128 -0
- package/node_modules/@instantdb/core/dist/esm/schemaTypes.d.ts +244 -0
- package/node_modules/@instantdb/core/dist/esm/schemaTypes.js +106 -0
- package/node_modules/@instantdb/core/dist/esm/store.d.ts +89 -0
- package/node_modules/@instantdb/core/dist/esm/store.js +722 -0
- package/node_modules/@instantdb/core/dist/esm/transactionValidation.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/transactionValidation.js +130 -0
- package/node_modules/@instantdb/core/dist/esm/utils/Deferred.d.ts +8 -0
- package/node_modules/@instantdb/core/dist/esm/utils/Deferred.js +17 -0
- package/node_modules/@instantdb/core/dist/esm/utils/PersistedObject.d.ts +80 -0
- package/node_modules/@instantdb/core/dist/esm/utils/PersistedObject.js +448 -0
- package/node_modules/@instantdb/core/dist/esm/utils/dates.d.ts +1 -0
- package/node_modules/@instantdb/core/dist/esm/utils/dates.js +211 -0
- package/node_modules/@instantdb/core/dist/esm/utils/error.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/utils/error.js +8 -0
- package/node_modules/@instantdb/core/dist/esm/utils/fetch.d.ts +125 -0
- package/node_modules/@instantdb/core/dist/esm/utils/fetch.js +31 -0
- package/node_modules/@instantdb/core/dist/esm/utils/flags.d.ts +4 -0
- package/node_modules/@instantdb/core/dist/esm/utils/flags.js +10 -0
- package/node_modules/@instantdb/core/dist/esm/utils/id.d.ts +3 -0
- package/node_modules/@instantdb/core/dist/esm/utils/id.js +25 -0
- package/node_modules/@instantdb/core/dist/esm/utils/linkIndex.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/utils/linkIndex.js +17 -0
- package/node_modules/@instantdb/core/dist/esm/utils/log.d.ts +6 -0
- package/node_modules/@instantdb/core/dist/esm/utils/log.js +13 -0
- package/node_modules/@instantdb/core/dist/esm/utils/object.d.ts +16 -0
- package/node_modules/@instantdb/core/dist/esm/utils/object.js +143 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pgtime.d.ts +197 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pgtime.js +197 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pick.d.ts +1 -0
- package/node_modules/@instantdb/core/dist/esm/utils/pick.js +9 -0
- package/node_modules/@instantdb/core/dist/esm/utils/strings.d.ts +1 -0
- package/node_modules/@instantdb/core/dist/esm/utils/strings.js +15 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHash.d.ts +15 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHash.js +71 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHashLegacy.d.ts +7 -0
- package/node_modules/@instantdb/core/dist/esm/utils/weakHashLegacy.js +72 -0
- package/node_modules/@instantdb/core/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/core/dist/esm/warningToggle.d.ts +2 -0
- package/node_modules/@instantdb/core/dist/esm/warningToggle.js +4 -0
- package/node_modules/@instantdb/core/package.json +20 -0
- package/node_modules/@instantdb/eventsource/LICENSE +22 -0
- package/node_modules/@instantdb/eventsource/README.md +226 -0
- package/node_modules/@instantdb/eventsource/dist/index.cjs +279 -0
- package/node_modules/@instantdb/eventsource/dist/index.cjs.map +1 -0
- package/node_modules/@instantdb/eventsource/dist/index.d.cts +346 -0
- package/node_modules/@instantdb/eventsource/dist/index.d.ts +346 -0
- package/node_modules/@instantdb/eventsource/dist/index.js +279 -0
- package/node_modules/@instantdb/eventsource/dist/index.js.map +1 -0
- package/node_modules/@instantdb/eventsource/package.json +128 -0
- package/node_modules/@instantdb/eventsource/src/EventSource.ts +614 -0
- package/node_modules/@instantdb/eventsource/src/errors.ts +141 -0
- package/node_modules/@instantdb/eventsource/src/index.ts +3 -0
- package/node_modules/@instantdb/eventsource/src/types.ts +164 -0
- package/node_modules/@instantdb/react/LICENSE +202 -0
- package/node_modules/@instantdb/react/dist/esm/Cursors.d.ts +18 -0
- package/node_modules/@instantdb/react/dist/esm/Cursors.js +103 -0
- package/node_modules/@instantdb/react/dist/esm/InstantReactWebDatabase.d.ts +5 -0
- package/node_modules/@instantdb/react/dist/esm/InstantReactWebDatabase.js +5 -0
- package/node_modules/@instantdb/react/dist/esm/index.d.ts +6 -0
- package/node_modules/@instantdb/react/dist/esm/index.js +22 -0
- package/node_modules/@instantdb/react/dist/esm/init.d.ts +40 -0
- package/node_modules/@instantdb/react/dist/esm/init.js +49 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/HydrationStreamProvider.d.ts +65 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/HydrationStreamProvider.js +96 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantNextDatabase.d.ts +11 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantNextDatabase.js +31 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantSuspenseProvider.d.ts +24 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/InstantSuspenseProvider.js +162 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/getUserFromInstantCookie.d.ts +9 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/getUserFromInstantCookie.js +16 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/htmlescape.d.ts +2 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/htmlescape.js +20 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/index.d.ts +29 -0
- package/node_modules/@instantdb/react/dist/esm/next-ssr/index.js +34 -0
- package/node_modules/@instantdb/react/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/react/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/react/package.json +24 -0
- package/node_modules/@instantdb/react-common/LICENSE +202 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactAbstractDatabase.d.ts +282 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactAbstractDatabase.js +386 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactRoom.d.ts +182 -0
- package/node_modules/@instantdb/react-common/dist/esm/InstantReactRoom.js +280 -0
- package/node_modules/@instantdb/react-common/dist/esm/index.d.ts +4 -0
- package/node_modules/@instantdb/react-common/dist/esm/index.js +3 -0
- package/node_modules/@instantdb/react-common/dist/esm/useInfiniteQuerySubscription.d.ts +27 -0
- package/node_modules/@instantdb/react-common/dist/esm/useInfiniteQuerySubscription.js +53 -0
- package/node_modules/@instantdb/react-common/dist/esm/useQuery.d.ts +6 -0
- package/node_modules/@instantdb/react-common/dist/esm/useQuery.js +75 -0
- package/node_modules/@instantdb/react-common/dist/esm/useTimeout.d.ts +4 -0
- package/node_modules/@instantdb/react-common/dist/esm/useTimeout.js +17 -0
- package/node_modules/@instantdb/react-common/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/react-common/dist/esm/version.js +2 -0
- package/node_modules/@instantdb/react-common/package.json +22 -0
- package/node_modules/@instantdb/version/LICENSE +202 -0
- package/node_modules/@instantdb/version/dist/esm/index.d.ts +2 -0
- package/node_modules/@instantdb/version/dist/esm/index.js +2 -0
- package/node_modules/@instantdb/version/dist/esm/version.d.ts +2 -0
- package/node_modules/@instantdb/version/dist/esm/version.js +5 -0
- package/node_modules/@instantdb/version/package.json +16 -0
- package/node_modules/@instantdb/webhooks/LICENSE +202 -0
- package/node_modules/@instantdb/webhooks/dist/esm/index.d.ts +587 -0
- package/node_modules/@instantdb/webhooks/dist/esm/index.js +748 -0
- package/node_modules/@instantdb/webhooks/package.json +18 -0
- package/node_modules/cookie/LICENSE +24 -0
- package/node_modules/cookie/README.md +295 -0
- package/node_modules/cookie/dist/index.d.ts +143 -0
- package/node_modules/cookie/dist/index.js +355 -0
- package/node_modules/cookie/dist/index.js.map +1 -0
- package/node_modules/cookie/package.json +57 -0
- package/node_modules/eventsource/LICENSE +22 -0
- package/node_modules/eventsource/README.md +252 -0
- package/node_modules/eventsource/dist/EventSource.d.ts +128 -0
- package/node_modules/eventsource/dist/EventSource.d.ts.map +1 -0
- package/node_modules/eventsource/dist/EventSource.js +556 -0
- package/node_modules/eventsource/dist/EventSource.js.map +1 -0
- package/node_modules/eventsource/dist/errors.d.ts +53 -0
- package/node_modules/eventsource/dist/errors.d.ts.map +1 -0
- package/node_modules/eventsource/dist/errors.js +120 -0
- package/node_modules/eventsource/dist/errors.js.map +1 -0
- package/node_modules/eventsource/dist/index.d.ts +4 -0
- package/node_modules/eventsource/dist/index.d.ts.map +1 -0
- package/node_modules/eventsource/dist/index.js +3 -0
- package/node_modules/eventsource/dist/index.js.map +1 -0
- package/node_modules/eventsource/dist/types.d.ts +156 -0
- package/node_modules/eventsource/dist/types.d.ts.map +1 -0
- package/node_modules/eventsource/dist/types.js +2 -0
- package/node_modules/eventsource/dist/types.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/LICENSE +21 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/README.md +177 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.d.ts +35 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.js +16 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/errors.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.d.ts +4 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.js +3 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/index.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.d.ts +12 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.js +509 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/parse.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.d.ts +76 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.js +59 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/stream.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.d.ts +130 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.d.ts.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.js +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/dist/types.js.map +1 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/package.json +96 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/errors.ts +44 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/index.ts +3 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/parse.ts +576 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/stream.ts +118 -0
- package/node_modules/eventsource/node_modules/eventsource-parser/src/types.ts +138 -0
- package/node_modules/eventsource/package.json +103 -0
- package/node_modules/eventsource/src/EventSource.ts +844 -0
- package/node_modules/eventsource/src/errors.ts +141 -0
- package/node_modules/eventsource/src/index.ts +3 -0
- package/node_modules/eventsource/src/types.ts +166 -0
- package/node_modules/eventsource-parser/LICENSE +21 -0
- package/node_modules/eventsource-parser/README.md +157 -0
- package/node_modules/eventsource-parser/dist/index.cjs +177 -0
- package/node_modules/eventsource-parser/dist/index.cjs.map +1 -0
- package/node_modules/eventsource-parser/dist/index.d.cts +169 -0
- package/node_modules/eventsource-parser/dist/index.d.ts +169 -0
- package/node_modules/eventsource-parser/dist/index.js +177 -0
- package/node_modules/eventsource-parser/dist/index.js.map +1 -0
- package/node_modules/eventsource-parser/dist/stream.cjs +29 -0
- package/node_modules/eventsource-parser/dist/stream.cjs.map +1 -0
- package/node_modules/eventsource-parser/dist/stream.d.cts +134 -0
- package/node_modules/eventsource-parser/dist/stream.d.ts +134 -0
- package/node_modules/eventsource-parser/dist/stream.js +30 -0
- package/node_modules/eventsource-parser/dist/stream.js.map +1 -0
- package/node_modules/eventsource-parser/package.json +92 -0
- package/node_modules/eventsource-parser/src/errors.ts +44 -0
- package/node_modules/eventsource-parser/src/index.ts +8 -0
- package/node_modules/eventsource-parser/src/parse.ts +439 -0
- package/node_modules/eventsource-parser/src/stream.ts +107 -0
- package/node_modules/eventsource-parser/src/types.ts +122 -0
- package/node_modules/eventsource-parser/stream.js +2 -0
- package/node_modules/mutative/LICENSE +21 -0
- package/node_modules/mutative/README.md +870 -0
- package/node_modules/mutative/dist/apply.d.ts +31 -0
- package/node_modules/mutative/dist/array.d.ts +45 -0
- package/node_modules/mutative/dist/constant.d.ts +8 -0
- package/node_modules/mutative/dist/create.d.ts +46 -0
- package/node_modules/mutative/dist/current.d.ts +23 -0
- package/node_modules/mutative/dist/draft.d.ts +3 -0
- package/node_modules/mutative/dist/draftify.d.ts +2 -0
- package/node_modules/mutative/dist/error.d.ts +54 -0
- package/node_modules/mutative/dist/index.d.mts +1 -0
- package/node_modules/mutative/dist/index.d.ts +12 -0
- package/node_modules/mutative/dist/index.js +8 -0
- package/node_modules/mutative/dist/index.mjs +3 -0
- package/node_modules/mutative/dist/interface.d.ts +200 -0
- package/node_modules/mutative/dist/internal.d.ts +4 -0
- package/node_modules/mutative/dist/makeCreator.d.ts +54 -0
- package/node_modules/mutative/dist/map.d.ts +15 -0
- package/node_modules/mutative/dist/mutative.cjs.development.js +2126 -0
- package/node_modules/mutative/dist/mutative.cjs.development.js.map +1 -0
- package/node_modules/mutative/dist/mutative.cjs.production.min.js +2 -0
- package/node_modules/mutative/dist/mutative.cjs.production.min.js.map +1 -0
- package/node_modules/mutative/dist/mutative.esm.js +2123 -0
- package/node_modules/mutative/dist/mutative.esm.js.map +1 -0
- package/node_modules/mutative/dist/mutative.esm.mjs +2123 -0
- package/node_modules/mutative/dist/mutative.esm.mjs.map +1 -0
- package/node_modules/mutative/dist/mutative.esm.production.min.mjs +2 -0
- package/node_modules/mutative/dist/mutative.esm.production.min.mjs.map +1 -0
- package/node_modules/mutative/dist/mutative.umd.development.js +2132 -0
- package/node_modules/mutative/dist/mutative.umd.development.js.map +1 -0
- package/node_modules/mutative/dist/mutative.umd.production.min.js +2 -0
- package/node_modules/mutative/dist/mutative.umd.production.min.js.map +1 -0
- package/node_modules/mutative/dist/original.d.ts +19 -0
- package/node_modules/mutative/dist/patch.d.ts +2 -0
- package/node_modules/mutative/dist/rawReturn.d.ts +19 -0
- package/node_modules/mutative/dist/set.d.ts +14 -0
- package/node_modules/mutative/dist/unsafe.d.ts +34 -0
- package/node_modules/mutative/dist/utils/cast.d.ts +13 -0
- package/node_modules/mutative/dist/utils/copy.d.ts +5 -0
- package/node_modules/mutative/dist/utils/deepFreeze.d.ts +1 -0
- package/node_modules/mutative/dist/utils/draft.d.ts +27 -0
- package/node_modules/mutative/dist/utils/finalize.d.ts +13 -0
- package/node_modules/mutative/dist/utils/forEach.d.ts +1 -0
- package/node_modules/mutative/dist/utils/index.d.ts +7 -0
- package/node_modules/mutative/dist/utils/mark.d.ts +2 -0
- package/node_modules/mutative/dist/utils/marker.d.ts +5 -0
- package/node_modules/mutative/dist/utils/proto.d.ts +10 -0
- package/node_modules/mutative/package.json +142 -0
- package/node_modules/mutative/src/apply.ts +239 -0
- package/node_modules/mutative/src/array.ts +679 -0
- package/node_modules/mutative/src/constant.ts +17 -0
- package/node_modules/mutative/src/create.ts +27 -0
- package/node_modules/mutative/src/current.ts +206 -0
- package/node_modules/mutative/src/draft.ts +489 -0
- package/node_modules/mutative/src/draftify.ts +57 -0
- package/node_modules/mutative/src/error.ts +129 -0
- package/node_modules/mutative/src/index.ts +21 -0
- package/node_modules/mutative/src/interface.ts +321 -0
- package/node_modules/mutative/src/internal.ts +5 -0
- package/node_modules/mutative/src/makeCreator.ts +382 -0
- package/node_modules/mutative/src/map.ts +160 -0
- package/node_modules/mutative/src/original.ts +28 -0
- package/node_modules/mutative/src/patch.ts +386 -0
- package/node_modules/mutative/src/rawReturn.ts +41 -0
- package/node_modules/mutative/src/set.ts +201 -0
- package/node_modules/mutative/src/unsafe.ts +66 -0
- package/node_modules/mutative/src/utils/cast.ts +22 -0
- package/node_modules/mutative/src/utils/copy.ts +224 -0
- package/node_modules/mutative/src/utils/deepFreeze.ts +103 -0
- package/node_modules/mutative/src/utils/draft.ts +189 -0
- package/node_modules/mutative/src/utils/finalize.ts +232 -0
- package/node_modules/mutative/src/utils/forEach.ts +24 -0
- package/node_modules/mutative/src/utils/index.ts +7 -0
- package/node_modules/mutative/src/utils/mark.ts +11 -0
- package/node_modules/mutative/src/utils/marker.ts +34 -0
- package/node_modules/mutative/src/utils/proto.ts +38 -0
- package/node_modules/uuid/LICENSE.md +9 -0
- package/node_modules/uuid/README.md +491 -0
- package/node_modules/uuid/dist/index.d.ts +15 -0
- package/node_modules/uuid/dist/index.js +14 -0
- package/node_modules/uuid/dist/max.d.ts +2 -0
- package/node_modules/uuid/dist/max.js +1 -0
- package/node_modules/uuid/dist/md5.d.ts +2 -0
- package/node_modules/uuid/dist/md5.js +135 -0
- package/node_modules/uuid/dist/nil.d.ts +2 -0
- package/node_modules/uuid/dist/nil.js +1 -0
- package/node_modules/uuid/dist/parse.d.ts +3 -0
- package/node_modules/uuid/dist/parse.js +9 -0
- package/node_modules/uuid/dist/regex.d.ts +2 -0
- package/node_modules/uuid/dist/regex.js +1 -0
- package/node_modules/uuid/dist/rng.d.ts +1 -0
- package/node_modules/uuid/dist/rng.js +4 -0
- package/node_modules/uuid/dist/sha1.d.ts +2 -0
- package/node_modules/uuid/dist/sha1.js +70 -0
- package/node_modules/uuid/dist/stringify.d.ts +3 -0
- package/node_modules/uuid/dist/stringify.js +35 -0
- package/node_modules/uuid/dist/types.d.ts +22 -0
- package/node_modules/uuid/dist/types.js +1 -0
- package/node_modules/uuid/dist/uuid-bin.d.ts +1 -0
- package/node_modules/uuid/dist/uuid-bin.js +70 -0
- package/node_modules/uuid/dist/v1.d.ts +11 -0
- package/node_modules/uuid/dist/v1.js +87 -0
- package/node_modules/uuid/dist/v1ToV6.d.ts +3 -0
- package/node_modules/uuid/dist/v1ToV6.js +10 -0
- package/node_modules/uuid/dist/v3.d.ts +9 -0
- package/node_modules/uuid/dist/v3.js +9 -0
- package/node_modules/uuid/dist/v35.d.ts +7 -0
- package/node_modules/uuid/dist/v35.js +39 -0
- package/node_modules/uuid/dist/v4.d.ts +4 -0
- package/node_modules/uuid/dist/v4.js +29 -0
- package/node_modules/uuid/dist/v5.d.ts +9 -0
- package/node_modules/uuid/dist/v5.js +9 -0
- package/node_modules/uuid/dist/v6.d.ts +4 -0
- package/node_modules/uuid/dist/v6.js +20 -0
- package/node_modules/uuid/dist/v6ToV1.d.ts +2 -0
- package/node_modules/uuid/dist/v6ToV1.js +10 -0
- package/node_modules/uuid/dist/v7.d.ts +9 -0
- package/node_modules/uuid/dist/v7.js +68 -0
- package/node_modules/uuid/dist/validate.d.ts +2 -0
- package/node_modules/uuid/dist/validate.js +5 -0
- package/node_modules/uuid/dist/version.d.ts +2 -0
- package/node_modules/uuid/dist/version.js +8 -0
- package/node_modules/uuid/dist-node/bin/uuid +2 -0
- package/node_modules/uuid/dist-node/index.js +14 -0
- package/node_modules/uuid/dist-node/max.js +1 -0
- package/node_modules/uuid/dist-node/md5.js +11 -0
- package/node_modules/uuid/dist-node/nil.js +1 -0
- package/node_modules/uuid/dist-node/parse.js +9 -0
- package/node_modules/uuid/dist-node/regex.js +1 -0
- package/node_modules/uuid/dist-node/rng.js +4 -0
- package/node_modules/uuid/dist-node/sha1.js +11 -0
- package/node_modules/uuid/dist-node/stringify.js +35 -0
- package/node_modules/uuid/dist-node/types.js +1 -0
- package/node_modules/uuid/dist-node/uuid-bin.js +70 -0
- package/node_modules/uuid/dist-node/v1.js +87 -0
- package/node_modules/uuid/dist-node/v1ToV6.js +10 -0
- package/node_modules/uuid/dist-node/v3.js +9 -0
- package/node_modules/uuid/dist-node/v35.js +39 -0
- package/node_modules/uuid/dist-node/v4.js +29 -0
- package/node_modules/uuid/dist-node/v5.js +9 -0
- package/node_modules/uuid/dist-node/v6.js +20 -0
- package/node_modules/uuid/dist-node/v6ToV1.js +10 -0
- package/node_modules/uuid/dist-node/v7.js +68 -0
- package/node_modules/uuid/dist-node/validate.js +5 -0
- package/node_modules/uuid/dist-node/version.js +8 -0
- package/node_modules/uuid/package.json +115 -0
- package/package.json +80 -4
- package/release.json +78 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { id, tx, lookup, i,
|
|
2
|
+
// error
|
|
3
|
+
InstantAPIError,
|
|
4
|
+
// sync table enums
|
|
5
|
+
SyncTableCallbackEventType, setInstantWarningsEnabled, StoreInterface, createInstantRouteHandler, } from '@instantdb/core';
|
|
6
|
+
import { InstantReactAbstractDatabase } from '@instantdb/react-common';
|
|
7
|
+
import InstantReactWebDatabase from './InstantReactWebDatabase.js';
|
|
8
|
+
import { init, init_experimental } from './init.js';
|
|
9
|
+
import { Cursors } from './Cursors.js';
|
|
10
|
+
export { id, tx, lookup, init, init_experimental, InstantReactWebDatabase, Cursors, i,
|
|
11
|
+
// error
|
|
12
|
+
InstantAPIError,
|
|
13
|
+
// internal
|
|
14
|
+
InstantReactAbstractDatabase,
|
|
15
|
+
// sync table enums
|
|
16
|
+
SyncTableCallbackEventType,
|
|
17
|
+
// warnings
|
|
18
|
+
setInstantWarningsEnabled,
|
|
19
|
+
// custom store
|
|
20
|
+
StoreInterface,
|
|
21
|
+
// Server helper
|
|
22
|
+
createInstantRouteHandler, };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { InstantConfig, InstantSchemaDef, InstantUnknownSchema } from '@instantdb/core';
|
|
2
|
+
import InstantReactWebDatabase from './InstantReactWebDatabase.ts';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* The first step: init your application!
|
|
6
|
+
*
|
|
7
|
+
* Visit https://instantdb.com/dash to get your `appId` :)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { init } from "@instantdb/react"
|
|
11
|
+
*
|
|
12
|
+
* const db = init({ appId: "my-app-id" })
|
|
13
|
+
*
|
|
14
|
+
* // You can also provide a schema for type safety and editor autocomplete!
|
|
15
|
+
*
|
|
16
|
+
* import { init } from "@instantdb/react"
|
|
17
|
+
* import schema from ""../instant.schema.ts";
|
|
18
|
+
*
|
|
19
|
+
* const db = init({ appId: "my-app-id", schema })
|
|
20
|
+
*
|
|
21
|
+
* // To learn more: https://instantdb.com/docs/modeling-data
|
|
22
|
+
*/
|
|
23
|
+
export declare function init<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
|
|
24
|
+
useDateObjects?: UseDates;
|
|
25
|
+
}): InstantReactWebDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>>;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated
|
|
28
|
+
* `init_experimental` is deprecated. You can replace it with `init`.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
*
|
|
32
|
+
* // Before
|
|
33
|
+
* import { init_experimental } from "@instantdb/react"
|
|
34
|
+
* const db = init_experimental({ ... });
|
|
35
|
+
*
|
|
36
|
+
* // After
|
|
37
|
+
* import { init } from "@instantdb/react"
|
|
38
|
+
* const db = init({ ... });
|
|
39
|
+
*/
|
|
40
|
+
export declare const init_experimental: typeof init;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import InstantReactWebDatabase from './InstantReactWebDatabase.js';
|
|
2
|
+
import version from './version.js';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* The first step: init your application!
|
|
6
|
+
*
|
|
7
|
+
* Visit https://instantdb.com/dash to get your `appId` :)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { init } from "@instantdb/react"
|
|
11
|
+
*
|
|
12
|
+
* const db = init({ appId: "my-app-id" })
|
|
13
|
+
*
|
|
14
|
+
* // You can also provide a schema for type safety and editor autocomplete!
|
|
15
|
+
*
|
|
16
|
+
* import { init } from "@instantdb/react"
|
|
17
|
+
* import schema from ""../instant.schema.ts";
|
|
18
|
+
*
|
|
19
|
+
* const db = init({ appId: "my-app-id", schema })
|
|
20
|
+
*
|
|
21
|
+
* // To learn more: https://instantdb.com/docs/modeling-data
|
|
22
|
+
*/
|
|
23
|
+
export function init(
|
|
24
|
+
// Allows config with missing `useDateObjects`, but keeps `UseDates`
|
|
25
|
+
// as a non-nullable in the InstantConfig type.
|
|
26
|
+
config) {
|
|
27
|
+
const configStrict = {
|
|
28
|
+
...config,
|
|
29
|
+
useDateObjects: (config.useDateObjects ?? false),
|
|
30
|
+
};
|
|
31
|
+
return new InstantReactWebDatabase(configStrict, {
|
|
32
|
+
'@instantdb/react': version,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated
|
|
37
|
+
* `init_experimental` is deprecated. You can replace it with `init`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
*
|
|
41
|
+
* // Before
|
|
42
|
+
* import { init_experimental } from "@instantdb/react"
|
|
43
|
+
* const db = init_experimental({ ... });
|
|
44
|
+
*
|
|
45
|
+
* // After
|
|
46
|
+
* import { init } from "@instantdb/react"
|
|
47
|
+
* const db = init({ ... });
|
|
48
|
+
*/
|
|
49
|
+
export const init_experimental = init;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare const isServer: boolean;
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface DataTransformer {
|
|
4
|
+
serialize: (object: any) => any;
|
|
5
|
+
deserialize: (object: any) => any;
|
|
6
|
+
}
|
|
7
|
+
interface HydrationStreamContext<TShape> {
|
|
8
|
+
id: string;
|
|
9
|
+
stream: {
|
|
10
|
+
/**
|
|
11
|
+
* **Server method**
|
|
12
|
+
* Push a new entry to the stream
|
|
13
|
+
* Will be ignored on the client
|
|
14
|
+
*/
|
|
15
|
+
push: (...shape: Array<TShape>) => void;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface HydrationStreamProviderProps<TShape> {
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Optional transformer to serialize/deserialize the data
|
|
22
|
+
* Example devalue, superjson et al
|
|
23
|
+
*/
|
|
24
|
+
transformer?: DataTransformer;
|
|
25
|
+
/**
|
|
26
|
+
* **Client method**
|
|
27
|
+
* Called in the browser when new entries are received
|
|
28
|
+
*/
|
|
29
|
+
onEntries: (entries: Array<TShape>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* **Server method**
|
|
32
|
+
* onFlush is called on the server when the cache is flushed
|
|
33
|
+
*/
|
|
34
|
+
onFlush?: () => Array<TShape>;
|
|
35
|
+
/**
|
|
36
|
+
* A nonce that'll allow the inline script to be executed when Content Security Policy is enforced
|
|
37
|
+
*/
|
|
38
|
+
nonce?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function createHydrationStreamProvider<TShape>(): {
|
|
41
|
+
Provider: (props: {
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Optional transformer to serialize/deserialize the data
|
|
45
|
+
* Example devalue, superjson et al
|
|
46
|
+
*/
|
|
47
|
+
transformer?: DataTransformer;
|
|
48
|
+
/**
|
|
49
|
+
* **Client method**
|
|
50
|
+
* Called in the browser when new entries are received
|
|
51
|
+
*/
|
|
52
|
+
onEntries: (entries: Array<TShape>) => void;
|
|
53
|
+
/**
|
|
54
|
+
* **Server method**
|
|
55
|
+
* onFlush is called on the server when the cache is flushed
|
|
56
|
+
*/
|
|
57
|
+
onFlush?: () => Array<TShape>;
|
|
58
|
+
/**
|
|
59
|
+
* A nonce that'll allow the inline script to be executed when Content Security Policy is enforced
|
|
60
|
+
*/
|
|
61
|
+
nonce?: string;
|
|
62
|
+
}) => React.JSX.Element;
|
|
63
|
+
context: React.Context<HydrationStreamContext<TShape>>;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
// This allows us to send serialized json from the server to the client using 'useServerInsertedHTML'
|
|
4
|
+
// We are allowed to send whatever json we want, however it must be triggered at the same time as the client is recieving new html to display
|
|
5
|
+
// after a suspsense boundary resolves
|
|
6
|
+
// We do this to send a list of triples and attrs for each query that the server made so they can be pre-filled on the client render.
|
|
7
|
+
// useServerInsertedHTML is called whenever a suspense boundary resolves, resulting in new html being streamed down to the client.
|
|
8
|
+
export const isServer = typeof window === 'undefined' || 'Deno' in globalThis;
|
|
9
|
+
import { useServerInsertedHTML } from 'next/navigation.js';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import { htmlEscapeJsonString } from './htmlescape.js';
|
|
12
|
+
const serializedSymbol = Symbol('serialized');
|
|
13
|
+
export function createHydrationStreamProvider() {
|
|
14
|
+
const context = React.createContext(null);
|
|
15
|
+
/**
|
|
16
|
+
|
|
17
|
+
* 1. (Happens on server): `useServerInsertedHTML()` is called **on the server** whenever a `Suspense`-boundary completes
|
|
18
|
+
* - This means that we might have some new entries in the cache that needs to be flushed
|
|
19
|
+
* - We pass these to the client by inserting a `<script>`-tag where we do `window[id].push(serializedVersionOfCache)`
|
|
20
|
+
* 2. (Happens in browser) In `useEffect()`:
|
|
21
|
+
* - We check if `window[id]` is set to an array and call `push()` on all the entries which will call `onEntries()` with the new entries
|
|
22
|
+
* - We replace `window[id]` with a `push()`-method that will be called whenever new entries are received
|
|
23
|
+
**/
|
|
24
|
+
function UseClientHydrationStreamProvider(props) {
|
|
25
|
+
// unique id for the cache provider
|
|
26
|
+
const id = `__RQ${React.useId()}`;
|
|
27
|
+
const idJSON = htmlEscapeJsonString(JSON.stringify(id));
|
|
28
|
+
const [transformer] = React.useState(() => (props.transformer ?? {
|
|
29
|
+
// noop
|
|
30
|
+
serialize: (obj) => obj,
|
|
31
|
+
deserialize: (obj) => obj,
|
|
32
|
+
}));
|
|
33
|
+
// <server stuff>
|
|
34
|
+
const [stream] = React.useState(() => {
|
|
35
|
+
if (!isServer) {
|
|
36
|
+
return {
|
|
37
|
+
push() {
|
|
38
|
+
// no-op on the client
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
});
|
|
44
|
+
const count = React.useRef(0);
|
|
45
|
+
useServerInsertedHTML(() => {
|
|
46
|
+
// This only happens on the server
|
|
47
|
+
stream.push(...(props.onFlush?.() ?? []));
|
|
48
|
+
if (!stream.length) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const serializedCacheArgs = stream
|
|
52
|
+
.map((entry) => transformer.serialize(entry))
|
|
53
|
+
.map((entry) => JSON.stringify(entry))
|
|
54
|
+
.join(',');
|
|
55
|
+
// Flush stream
|
|
56
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
57
|
+
stream.length = 0;
|
|
58
|
+
const html = [
|
|
59
|
+
`window[${idJSON}] = window[${idJSON}] || [];`,
|
|
60
|
+
`window[${idJSON}].push(${htmlEscapeJsonString(serializedCacheArgs)});`,
|
|
61
|
+
];
|
|
62
|
+
return (_jsx("script", { nonce: props.nonce, dangerouslySetInnerHTML: {
|
|
63
|
+
__html: html.join(''),
|
|
64
|
+
} }, count.current++));
|
|
65
|
+
});
|
|
66
|
+
// </server stuff>
|
|
67
|
+
// <client stuff>
|
|
68
|
+
// Setup and run the onEntries handler on the client only, but do it during
|
|
69
|
+
// the initial render so children have access to the data immediately
|
|
70
|
+
// This is important to avoid the client suspending during the initial render
|
|
71
|
+
// if the data has not yet been hydrated.
|
|
72
|
+
if (!isServer) {
|
|
73
|
+
const win = window;
|
|
74
|
+
if (!win[id]?.initialized) {
|
|
75
|
+
// Client: consume cache:
|
|
76
|
+
const onEntries = (...serializedEntries) => {
|
|
77
|
+
const entries = serializedEntries.map((serialized) => transformer.deserialize(serialized));
|
|
78
|
+
props.onEntries(entries);
|
|
79
|
+
};
|
|
80
|
+
const winStream = win[id] ?? [];
|
|
81
|
+
onEntries(...winStream);
|
|
82
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
83
|
+
win[id] = {
|
|
84
|
+
initialized: true,
|
|
85
|
+
push: onEntries,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// </client stuff>
|
|
90
|
+
return (_jsx(context.Provider, { value: { stream, id }, children: props.children }));
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
Provider: UseClientHydrationStreamProvider,
|
|
94
|
+
context,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthState, InstantSchemaDef, InstaQLResponse, PageInfoResponse, RuleParams, ValidQuery } from '@instantdb/core';
|
|
2
|
+
import InstantReactWebDatabase from '../InstantReactWebDatabase.ts';
|
|
3
|
+
export declare class InstantNextDatabase<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean> extends InstantReactWebDatabase<Schema, UseDates> {
|
|
4
|
+
useSuspenseQuery: <Q extends ValidQuery<Q, Schema>>(q: Q, opts?: {
|
|
5
|
+
ruleParams: RuleParams;
|
|
6
|
+
}) => {
|
|
7
|
+
data: InstaQLResponse<Schema, Q, NonNullable<UseDates>>;
|
|
8
|
+
pageInfo?: PageInfoResponse<Q>;
|
|
9
|
+
};
|
|
10
|
+
useAuth: () => AuthState;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import InstantReactWebDatabase from '../InstantReactWebDatabase.js';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { SuspsenseQueryContext } from './InstantSuspenseProvider.js';
|
|
4
|
+
export class InstantNextDatabase extends InstantReactWebDatabase {
|
|
5
|
+
useSuspenseQuery = (q, opts) => {
|
|
6
|
+
const ctx = useContext(SuspsenseQueryContext);
|
|
7
|
+
if (!ctx) {
|
|
8
|
+
throw new Error('useSuspenseQuery must be used within a SuspenseQueryProvider');
|
|
9
|
+
}
|
|
10
|
+
return ctx.useSuspenseQuery(q, opts);
|
|
11
|
+
};
|
|
12
|
+
useAuth = () => {
|
|
13
|
+
const ctx = useContext(SuspsenseQueryContext);
|
|
14
|
+
const realAuthResult = this._useAuth();
|
|
15
|
+
if (!ctx) {
|
|
16
|
+
return realAuthResult;
|
|
17
|
+
}
|
|
18
|
+
const { ssrUser } = ctx;
|
|
19
|
+
if (ssrUser === undefined) {
|
|
20
|
+
return realAuthResult;
|
|
21
|
+
}
|
|
22
|
+
if (realAuthResult.isLoading) {
|
|
23
|
+
return {
|
|
24
|
+
error: undefined,
|
|
25
|
+
isLoading: false,
|
|
26
|
+
user: ssrUser ?? undefined, // null -> undefined for the response
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return realAuthResult;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InstantSchemaDef, InstaQLResponse, PageInfoResponse, RuleParams, User, ValidQuery } from '@instantdb/core';
|
|
2
|
+
import InstantReactWebDatabase from '../InstantReactWebDatabase.ts';
|
|
3
|
+
type InstantSuspenseProviderProps<Schema extends InstantSchemaDef<any, any, any>> = {
|
|
4
|
+
nonce?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
db: InstantReactWebDatabase<Schema, any>;
|
|
7
|
+
user?: User | null;
|
|
8
|
+
};
|
|
9
|
+
type SuspenseQueryContextValue = {
|
|
10
|
+
useSuspenseQuery: (query: any, opts?: SuspenseQueryOpts) => any;
|
|
11
|
+
ssrUser: User | null | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare const SuspsenseQueryContext: import("react").Context<SuspenseQueryContextValue | null>;
|
|
14
|
+
export declare const createUseSuspenseQuery: <Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean>(_db: InstantReactWebDatabase<Schema, UseDates>) => (<Q extends ValidQuery<Q, Schema>>(q: Q, opts?: {
|
|
15
|
+
ruleParams: RuleParams;
|
|
16
|
+
}) => {
|
|
17
|
+
data: InstaQLResponse<Schema, Q, NonNullable<UseDates>>;
|
|
18
|
+
pageInfo?: PageInfoResponse<Q>;
|
|
19
|
+
});
|
|
20
|
+
type SuspenseQueryOpts = {
|
|
21
|
+
ruleParams: RuleParams;
|
|
22
|
+
};
|
|
23
|
+
export declare const InstantSuspenseProvider: (props: InstantSuspenseProviderProps<any>) => import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
// InstantSuspenseProvider can only be used in a client context so this prevents errors from trying to use it in a server component.
|
|
4
|
+
import { FrameworkClient, } from '@instantdb/core';
|
|
5
|
+
import { createHydrationStreamProvider, isServer, } from './HydrationStreamProvider.js';
|
|
6
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState, useEffect, } from 'react';
|
|
7
|
+
import { useQueryInternal, } from '@instantdb/react-common';
|
|
8
|
+
const stream = createHydrationStreamProvider();
|
|
9
|
+
export const SuspsenseQueryContext = createContext(null);
|
|
10
|
+
// Creates a typed useSuspense hook
|
|
11
|
+
export const createUseSuspenseQuery = (_db) => {
|
|
12
|
+
return (q, opts) => {
|
|
13
|
+
const ctx = useContext(SuspsenseQueryContext);
|
|
14
|
+
if (!ctx) {
|
|
15
|
+
throw new Error('useSuspenseQuery must be used within a SuspenseQueryProvider');
|
|
16
|
+
}
|
|
17
|
+
return ctx.useSuspenseQuery(q, opts);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
function makeUseSuspenseQueryServer(client) {
|
|
21
|
+
return function useSuspenseQueryServer(query, opts) {
|
|
22
|
+
let entry = client.getExistingResultForQuery(query, opts);
|
|
23
|
+
if (!entry) {
|
|
24
|
+
entry = client.query(query, opts);
|
|
25
|
+
}
|
|
26
|
+
if (entry.status === 'pending') {
|
|
27
|
+
throw entry.promise;
|
|
28
|
+
}
|
|
29
|
+
if (entry.status === 'error') {
|
|
30
|
+
throw entry.error;
|
|
31
|
+
}
|
|
32
|
+
if (entry.status === 'success') {
|
|
33
|
+
switch (entry.type) {
|
|
34
|
+
case 'session': {
|
|
35
|
+
return entry.data;
|
|
36
|
+
}
|
|
37
|
+
case 'http': {
|
|
38
|
+
const data = entry.data;
|
|
39
|
+
const result = client.completeIsomorphic(query, data.triples, data.attrs, data.pageInfo);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function makeUseSuspenseQueryClient(db, client) {
|
|
47
|
+
function getEntry(query, opts, allowFetch) {
|
|
48
|
+
const entry = client.getExistingResultForQuery(query, opts);
|
|
49
|
+
if (entry?.status === 'pending') {
|
|
50
|
+
throw entry.promise;
|
|
51
|
+
}
|
|
52
|
+
if (entry?.status === 'error') {
|
|
53
|
+
throw entry.error;
|
|
54
|
+
}
|
|
55
|
+
if (entry?.status === 'success') {
|
|
56
|
+
switch (entry.type) {
|
|
57
|
+
case 'session': {
|
|
58
|
+
return entry.data;
|
|
59
|
+
}
|
|
60
|
+
case 'http': {
|
|
61
|
+
const data = entry.data;
|
|
62
|
+
const result = client.completeIsomorphic(query, data.triples, data.attrs, data.pageInfo);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (allowFetch) {
|
|
68
|
+
const promise = client.queryClient(query, opts);
|
|
69
|
+
throw promise;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return function useSuspenseQueryClient(query, opts) {
|
|
73
|
+
const useQueryResult = useQueryInternal(db.core, query, opts,
|
|
74
|
+
// Returns the server result for useSyncExternalStore
|
|
75
|
+
() => {
|
|
76
|
+
try {
|
|
77
|
+
const res = getEntry(query, opts, false);
|
|
78
|
+
return res;
|
|
79
|
+
}
|
|
80
|
+
catch (throwable) {
|
|
81
|
+
return { error: throwable };
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const hasData = !!useQueryResult.state.data;
|
|
85
|
+
const queryHash = useQueryResult.queryHash;
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (hasData) {
|
|
88
|
+
// We have a newer result, so remove the cached SSR or suspended
|
|
89
|
+
// result from the framework client cache
|
|
90
|
+
client.removeCachedQueryResult(queryHash);
|
|
91
|
+
}
|
|
92
|
+
}, [hasData, queryHash]);
|
|
93
|
+
if (useQueryResult.state.data) {
|
|
94
|
+
return {
|
|
95
|
+
data: useQueryResult.state.data,
|
|
96
|
+
pageInfo: useQueryResult.state.pageInfo,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (useQueryResult.state.error) {
|
|
100
|
+
throw useQueryResult.state.error;
|
|
101
|
+
}
|
|
102
|
+
return getEntry(query, opts, true);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function createFrameworkClient(db, user) {
|
|
106
|
+
if (isServer) {
|
|
107
|
+
if (user && !user.refresh_token) {
|
|
108
|
+
throw new Error('User must have a refresh_token field. Recieved: ' +
|
|
109
|
+
JSON.stringify(user, null, 2));
|
|
110
|
+
}
|
|
111
|
+
return new FrameworkClient({
|
|
112
|
+
token: user?.refresh_token,
|
|
113
|
+
db: db.core,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// On the client, make sure we only have a single framework
|
|
117
|
+
// in case our suspense provider gets unmounted
|
|
118
|
+
const existing = db.core._reactor._frameworkClient;
|
|
119
|
+
if (existing) {
|
|
120
|
+
return existing;
|
|
121
|
+
}
|
|
122
|
+
const client = new FrameworkClient({ db: db.core });
|
|
123
|
+
db.core._reactor.setFrameworkClient(client);
|
|
124
|
+
return client;
|
|
125
|
+
}
|
|
126
|
+
export const InstantSuspenseProvider = (props) => {
|
|
127
|
+
if (!props.db) {
|
|
128
|
+
throw new Error('Must provide db to InstantSuspenseProvider');
|
|
129
|
+
}
|
|
130
|
+
const db = props.db;
|
|
131
|
+
const [trackedKeys] = useState(() => new Set());
|
|
132
|
+
const clientRef = useRef(createFrameworkClient(props.db, props.user));
|
|
133
|
+
if (isServer) {
|
|
134
|
+
clientRef.current.subscribe((result) => {
|
|
135
|
+
const { queryHash } = result;
|
|
136
|
+
trackedKeys.add(queryHash);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const useSuspenseQuery = useCallback(isServer
|
|
140
|
+
? makeUseSuspenseQueryServer(clientRef.current)
|
|
141
|
+
: makeUseSuspenseQueryClient(db, clientRef.current), []);
|
|
142
|
+
const contextValue = useMemo(() => {
|
|
143
|
+
return { useSuspenseQuery, ssrUser: props.user };
|
|
144
|
+
}, [useSuspenseQuery, props.user]);
|
|
145
|
+
return (_jsx(SuspsenseQueryContext.Provider, { value: contextValue, children: _jsx(stream.Provider, { nonce: props.nonce, onFlush: () => {
|
|
146
|
+
const toSend = [];
|
|
147
|
+
for (const [key, value] of clientRef.current.resultMap.entries()) {
|
|
148
|
+
if (trackedKeys.has(key) && value.status === 'success') {
|
|
149
|
+
toSend.push({
|
|
150
|
+
queryKey: key,
|
|
151
|
+
value: value.data,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
trackedKeys.clear();
|
|
156
|
+
return toSend;
|
|
157
|
+
}, onEntries: (entries) => {
|
|
158
|
+
entries.forEach((entry) => {
|
|
159
|
+
clientRef.current.addQueryResult(entry.queryKey, entry.value);
|
|
160
|
+
});
|
|
161
|
+
}, children: props.children }) }));
|
|
162
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { User } from '@instantdb/core';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Please use `getUnverifiedUserFromInstantCookie` instead
|
|
4
|
+
*/
|
|
5
|
+
export declare const getUserFromInstantCookie: (appId: string) => Promise<User | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Parses a user object from current Next.JS request context's cookies.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getUnverifiedUserFromInstantCookie: (appId: string) => Promise<User | null>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { cookies } from 'next/headers.js';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Please use `getUnverifiedUserFromInstantCookie` instead
|
|
4
|
+
*/
|
|
5
|
+
export const getUserFromInstantCookie = async (appId) => {
|
|
6
|
+
return getUnverifiedUserFromInstantCookie(appId);
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Parses a user object from current Next.JS request context's cookies.
|
|
10
|
+
*/
|
|
11
|
+
export const getUnverifiedUserFromInstantCookie = async (appId) => {
|
|
12
|
+
const cookieStore = await cookies();
|
|
13
|
+
const userJSON = cookieStore.get('instant_user_' + appId);
|
|
14
|
+
const user = userJSON ? JSON.parse(decodeURIComponent(userJSON.value)) : null;
|
|
15
|
+
return user;
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// --------------------------------------------------------------------------------
|
|
2
|
+
//
|
|
3
|
+
// copied from
|
|
4
|
+
// https://github.com/vercel/next.js/blob/6bc07792a4462a4bf921a72ab30dc4ab2c4e1bda/packages/next/src/server/htmlescape.ts
|
|
5
|
+
// License: https://github.com/vercel/next.js/blob/6bc07792a4462a4bf921a72ab30dc4ab2c4e1bda/packages/next/license.md
|
|
6
|
+
//
|
|
7
|
+
// --------------------------------------------------------------------------------
|
|
8
|
+
// This utility is based on https://github.com/zertosh/htmlescape
|
|
9
|
+
// License: https://github.com/zertosh/htmlescape/blob/0527ca7156a524d256101bb310a9f970f63078ad/LICENSE
|
|
10
|
+
const ESCAPE_LOOKUP = {
|
|
11
|
+
'&': '\\u0026',
|
|
12
|
+
'>': '\\u003e',
|
|
13
|
+
'<': '\\u003c',
|
|
14
|
+
'\u2028': '\\u2028',
|
|
15
|
+
'\u2029': '\\u2029',
|
|
16
|
+
};
|
|
17
|
+
export const ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
18
|
+
export function htmlEscapeJsonString(str) {
|
|
19
|
+
return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { InstantConfig, InstantSchemaDef, InstantUnknownSchema } from '@instantdb/core';
|
|
2
|
+
import { InstantNextDatabase } from './InstantNextDatabase.tsx';
|
|
3
|
+
export { getUnverifiedUserFromInstantCookie, getUserFromInstantCookie, } from './getUserFromInstantCookie.ts';
|
|
4
|
+
export { InstantNextDatabase } from './InstantNextDatabase.tsx';
|
|
5
|
+
export { InstantSuspenseProvider } from './InstantSuspenseProvider.tsx';
|
|
6
|
+
export { createInstantRouteHandler } from '@instantdb/core';
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* The first step: init your application!
|
|
10
|
+
*
|
|
11
|
+
* Visit https://instantdb.com/dash to get your `appId` :)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { init } from "@instantdb/react"
|
|
15
|
+
*
|
|
16
|
+
* const db = init({ appId: "my-app-id" })
|
|
17
|
+
*
|
|
18
|
+
* // You can also provide a schema for type safety and editor autocomplete!
|
|
19
|
+
*
|
|
20
|
+
* import { init } from "@instantdb/react"
|
|
21
|
+
* import schema from ""../instant.schema.ts";
|
|
22
|
+
*
|
|
23
|
+
* const db = init({ appId: "my-app-id", schema })
|
|
24
|
+
*
|
|
25
|
+
* // To learn more: https://instantdb.com/docs/modeling-data
|
|
26
|
+
*/
|
|
27
|
+
export declare function init<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
|
|
28
|
+
useDateObjects?: UseDates;
|
|
29
|
+
}): InstantNextDatabase<Schema, UseDates>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import version from '../version.js';
|
|
2
|
+
import { InstantNextDatabase } from './InstantNextDatabase.js';
|
|
3
|
+
export { getUnverifiedUserFromInstantCookie, getUserFromInstantCookie, } from './getUserFromInstantCookie.js';
|
|
4
|
+
export { InstantNextDatabase } from './InstantNextDatabase.js';
|
|
5
|
+
export { InstantSuspenseProvider } from './InstantSuspenseProvider.js';
|
|
6
|
+
export { createInstantRouteHandler } from '@instantdb/core';
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* The first step: init your application!
|
|
10
|
+
*
|
|
11
|
+
* Visit https://instantdb.com/dash to get your `appId` :)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { init } from "@instantdb/react"
|
|
15
|
+
*
|
|
16
|
+
* const db = init({ appId: "my-app-id" })
|
|
17
|
+
*
|
|
18
|
+
* // You can also provide a schema for type safety and editor autocomplete!
|
|
19
|
+
*
|
|
20
|
+
* import { init } from "@instantdb/react"
|
|
21
|
+
* import schema from ""../instant.schema.ts";
|
|
22
|
+
*
|
|
23
|
+
* const db = init({ appId: "my-app-id", schema })
|
|
24
|
+
*
|
|
25
|
+
* // To learn more: https://instantdb.com/docs/modeling-data
|
|
26
|
+
*/
|
|
27
|
+
export function init(
|
|
28
|
+
// Allows config with missing `useDateObjects`, but keeps `UseDates`
|
|
29
|
+
// as a non-nullable in the InstantConfig type.
|
|
30
|
+
config) {
|
|
31
|
+
return new InstantNextDatabase(config, {
|
|
32
|
+
'@instantdb/react': version,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@instantdb/react",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"types": "./dist/esm/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"import": "./dist/esm/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@instantdb/core": "0.0.0",
|
|
17
|
+
"@instantdb/react-common": "0.0.0",
|
|
18
|
+
"@instantdb/version": "0.0.0",
|
|
19
|
+
"eventsource": "5.1.3"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": ">=16"
|
|
23
|
+
}
|
|
24
|
+
}
|