@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,556 @@
|
|
|
1
|
+
import { createParser, } from 'eventsource-parser';
|
|
2
|
+
import { ErrorEvent, flattenError, syntaxError } from './errors.js';
|
|
3
|
+
const DEFAULT_MAX_BUFFER_SIZE = 100 * 1024 * 1024;
|
|
4
|
+
/**
|
|
5
|
+
* Implementation of the `EventSource` interface.
|
|
6
|
+
*
|
|
7
|
+
* Intentionally not exported: TypeScript emits a `#private` brand into declaration files for any
|
|
8
|
+
* class holding hard-private (`#`) fields, which makes the emitted type nominal. Exporting the
|
|
9
|
+
* interface and const instead keeps the public type structural, while the implementation keeps
|
|
10
|
+
* its actual, runtime-enforced private state.
|
|
11
|
+
*
|
|
12
|
+
* Public members are documented on the `EventSource` interface, which is what consumers see.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
class EventSourceImpl extends EventTarget {
|
|
17
|
+
static CONNECTING = 0;
|
|
18
|
+
static OPEN = 1;
|
|
19
|
+
static CLOSED = 2;
|
|
20
|
+
CONNECTING = 0;
|
|
21
|
+
OPEN = 1;
|
|
22
|
+
CLOSED = 2;
|
|
23
|
+
get readyState() {
|
|
24
|
+
return this.#readyState;
|
|
25
|
+
}
|
|
26
|
+
get url() {
|
|
27
|
+
return this.#url.href;
|
|
28
|
+
}
|
|
29
|
+
get withCredentials() {
|
|
30
|
+
return this.#withCredentials;
|
|
31
|
+
}
|
|
32
|
+
get onerror() {
|
|
33
|
+
return this.#onError;
|
|
34
|
+
}
|
|
35
|
+
set onerror(value) {
|
|
36
|
+
if (this.#onError) {
|
|
37
|
+
this.removeEventListener('error', this.#onError);
|
|
38
|
+
}
|
|
39
|
+
this.#onError = value;
|
|
40
|
+
if (value) {
|
|
41
|
+
this.addEventListener('error', value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
get onmessage() {
|
|
45
|
+
return this.#onMessage;
|
|
46
|
+
}
|
|
47
|
+
set onmessage(value) {
|
|
48
|
+
if (this.#onMessage) {
|
|
49
|
+
this.removeEventListener('message', this.#onMessage);
|
|
50
|
+
}
|
|
51
|
+
this.#onMessage = value;
|
|
52
|
+
if (value) {
|
|
53
|
+
this.addEventListener('message', value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
get onopen() {
|
|
57
|
+
return this.#onOpen;
|
|
58
|
+
}
|
|
59
|
+
set onopen(value) {
|
|
60
|
+
if (this.#onOpen) {
|
|
61
|
+
this.removeEventListener('open', this.#onOpen);
|
|
62
|
+
}
|
|
63
|
+
this.#onOpen = value;
|
|
64
|
+
if (value) {
|
|
65
|
+
this.addEventListener('open', value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
addEventListener(type, listener, options) {
|
|
69
|
+
const listen = listener;
|
|
70
|
+
super.addEventListener(type, listen, options);
|
|
71
|
+
}
|
|
72
|
+
removeEventListener(type, listener, options) {
|
|
73
|
+
const listen = listener;
|
|
74
|
+
super.removeEventListener(type, listen, options);
|
|
75
|
+
}
|
|
76
|
+
constructor(url, eventSourceInitDict) {
|
|
77
|
+
super();
|
|
78
|
+
try {
|
|
79
|
+
if (url instanceof URL) {
|
|
80
|
+
this.#url = url;
|
|
81
|
+
}
|
|
82
|
+
else if (typeof url === 'string') {
|
|
83
|
+
this.#url = new URL(url, getBaseURL());
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
throw new Error('Invalid URL');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
throw syntaxError('An invalid or illegal string was specified');
|
|
91
|
+
}
|
|
92
|
+
this.#parser = createParser({
|
|
93
|
+
maxBufferSize: eventSourceInitDict?.maxBufferSize ?? DEFAULT_MAX_BUFFER_SIZE,
|
|
94
|
+
onEvent: this.#onEvent,
|
|
95
|
+
onError: this.#onParseError,
|
|
96
|
+
onId: this.#onIdChange,
|
|
97
|
+
onRetry: this.#onRetryChange,
|
|
98
|
+
});
|
|
99
|
+
this.#readyState = this.CONNECTING;
|
|
100
|
+
this.#reconnectInterval = 3000;
|
|
101
|
+
this.#fetch = eventSourceInitDict?.fetch ?? globalThis.fetch;
|
|
102
|
+
this.#withCredentials = eventSourceInitDict?.withCredentials ?? false;
|
|
103
|
+
this.#connect();
|
|
104
|
+
}
|
|
105
|
+
close() {
|
|
106
|
+
if (this.#reconnectTimer)
|
|
107
|
+
clearTimeout(this.#reconnectTimer);
|
|
108
|
+
if (this.#readyState === this.CLOSED)
|
|
109
|
+
return;
|
|
110
|
+
if (this.#controller)
|
|
111
|
+
this.#controller.abort();
|
|
112
|
+
this.#readyState = this.CLOSED;
|
|
113
|
+
this.#controller = undefined;
|
|
114
|
+
}
|
|
115
|
+
// PRIVATES FOLLOW
|
|
116
|
+
/**
|
|
117
|
+
* Current connection state
|
|
118
|
+
*
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
#readyState;
|
|
122
|
+
/**
|
|
123
|
+
* Original URL used to connect.
|
|
124
|
+
*
|
|
125
|
+
* Note that this will stay the same even after a redirect.
|
|
126
|
+
*
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
#url;
|
|
130
|
+
/**
|
|
131
|
+
* The destination URL after a redirect. Is reset on reconnection.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
#redirectUrl;
|
|
136
|
+
/**
|
|
137
|
+
* Whether to include credentials in the request
|
|
138
|
+
*
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
#withCredentials;
|
|
142
|
+
/**
|
|
143
|
+
* The fetch implementation to use
|
|
144
|
+
*
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
#fetch;
|
|
148
|
+
/**
|
|
149
|
+
* The reconnection time in milliseconds
|
|
150
|
+
*
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
#reconnectInterval;
|
|
154
|
+
/**
|
|
155
|
+
* Reference to an ongoing reconnect attempt, if any
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
#reconnectTimer;
|
|
160
|
+
/**
|
|
161
|
+
* The last event ID seen by the EventSource, which will be sent as `Last-Event-ID` in the
|
|
162
|
+
* request headers on a reconnection attempt.
|
|
163
|
+
*
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
#lastEventId = null;
|
|
167
|
+
/**
|
|
168
|
+
* The AbortController instance used to abort the fetch request
|
|
169
|
+
*
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
#controller;
|
|
173
|
+
/**
|
|
174
|
+
* Instance of an EventSource parser (`eventsource-parser` npm module)
|
|
175
|
+
*
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
#parser;
|
|
179
|
+
/**
|
|
180
|
+
* Holds the current error handler, attached through `onerror` property directly.
|
|
181
|
+
* Note that `addEventListener('error', …)` will not be stored here.
|
|
182
|
+
*
|
|
183
|
+
* @internal
|
|
184
|
+
*/
|
|
185
|
+
#onError = null;
|
|
186
|
+
/**
|
|
187
|
+
* Holds the current message handler, attached through `onmessage` property directly.
|
|
188
|
+
* Note that `addEventListener('message', …)` will not be stored here.
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
#onMessage = null;
|
|
193
|
+
/**
|
|
194
|
+
* Holds the current open handler, attached through `onopen` property directly.
|
|
195
|
+
* Note that `addEventListener('open', …)` will not be stored here.
|
|
196
|
+
*
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
#onOpen = null;
|
|
200
|
+
/**
|
|
201
|
+
* Connect to the given URL and start receiving events
|
|
202
|
+
*
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
#connect() {
|
|
206
|
+
this.#readyState = this.CONNECTING;
|
|
207
|
+
this.#controller = new AbortController();
|
|
208
|
+
// Browser tests are failing if we directly call `this.#fetch()`, thus the indirection.
|
|
209
|
+
const fetch = this.#fetch;
|
|
210
|
+
fetch(this.#url, this.#getRequestOptions())
|
|
211
|
+
.then(this.#onFetchResponse)
|
|
212
|
+
.catch(this.#onFetchError);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Handles the fetch response
|
|
216
|
+
*
|
|
217
|
+
* @param response - The Fetch(ish) response
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
#onFetchResponse = async (response) => {
|
|
221
|
+
this.#parser.reset();
|
|
222
|
+
const { body, redirected, status, headers } = response;
|
|
223
|
+
// [spec] a client can be told to stop reconnecting using the HTTP 204 No Content response code.
|
|
224
|
+
if (status === 204) {
|
|
225
|
+
// We still need to emit an error event - this mirrors the browser behavior,
|
|
226
|
+
// and without it there is no way to tell the user that the connection was closed.
|
|
227
|
+
this.#failConnection('Server sent HTTP 204, not reconnecting', 204);
|
|
228
|
+
this.close();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
// [spec] …Event stream requests can be redirected using HTTP 301 and 307 redirects as with
|
|
232
|
+
// [spec] normal HTTP requests.
|
|
233
|
+
// Spec does not say anything about other redirect codes (302, 308), but this seems an
|
|
234
|
+
// unintended omission, rather than a feature. Browsers will happily redirect on other 3xxs's.
|
|
235
|
+
if (redirected) {
|
|
236
|
+
this.#redirectUrl = new URL(response.url);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.#redirectUrl = undefined;
|
|
240
|
+
}
|
|
241
|
+
// [spec] if res's status is not 200, …, then fail the connection.
|
|
242
|
+
if (status !== 200) {
|
|
243
|
+
this.#failConnection(`Non-200 status code (${status})`, status);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
// [spec] …or if res's `Content-Type` is not `text/event-stream`, then fail the connection.
|
|
247
|
+
const contentType = headers.get('content-type') || '';
|
|
248
|
+
if (!/^[\t\n\r ]*text\/event-stream[\t\n\r ]*(?:;|$)/i.test(contentType)) {
|
|
249
|
+
this.#failConnection('Invalid content type, expected "text/event-stream"', status);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
// [spec] …if the readyState attribute is set to a value other than CLOSED…
|
|
253
|
+
if (this.#readyState === this.CLOSED) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// [spec] …sets the readyState attribute to OPEN and fires an event
|
|
257
|
+
// [spec] …named open at the EventSource object.
|
|
258
|
+
this.#readyState = this.OPEN;
|
|
259
|
+
const openEvent = new Event('open');
|
|
260
|
+
this.dispatchEvent(openEvent);
|
|
261
|
+
// Ensure that the response stream is a web stream
|
|
262
|
+
if (typeof body !== 'object' || !body || !('getReader' in body)) {
|
|
263
|
+
this.#failConnection('Invalid response body, expected a web ReadableStream', status);
|
|
264
|
+
this.close(); // This should only happen if `fetch` provided is "faulty" - don't reconnect
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const decoder = new TextDecoder();
|
|
268
|
+
const reader = body.getReader();
|
|
269
|
+
let open = true;
|
|
270
|
+
do {
|
|
271
|
+
const { done, value } = await reader.read();
|
|
272
|
+
if (this.#readyState === this.CLOSED) {
|
|
273
|
+
open = false;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
if (value) {
|
|
277
|
+
this.#parser.feed(decoder.decode(value, { stream: !done }));
|
|
278
|
+
}
|
|
279
|
+
if (!done) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
open = false;
|
|
283
|
+
this.#parser.reset();
|
|
284
|
+
this.#scheduleReconnect();
|
|
285
|
+
} while (open);
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Handles rejected requests for the EventSource endpoint
|
|
289
|
+
*
|
|
290
|
+
* @param err - The error from `fetch()`
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
#onFetchError = (err) => {
|
|
294
|
+
this.#controller = undefined;
|
|
295
|
+
// We expect abort errors when the user manually calls `close()` - ignore those
|
|
296
|
+
if (err.name === 'AbortError' || err.type === 'aborted') {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
this.#scheduleReconnect(flattenError(err));
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Get request options for the `fetch()` request
|
|
303
|
+
*
|
|
304
|
+
* @returns The request options
|
|
305
|
+
* @internal
|
|
306
|
+
*/
|
|
307
|
+
#getRequestOptions() {
|
|
308
|
+
// [spec] If the last event ID string is not the empty string, set `Last-Event-ID` to the last
|
|
309
|
+
// event ID string, encoded as UTF-8.
|
|
310
|
+
// workerd's native fetch encodes header values as UTF-8 itself.
|
|
311
|
+
const lastEvent = this.#lastEventId
|
|
312
|
+
? {
|
|
313
|
+
'Last-Event-ID': this.#fetch === globalThis.fetch &&
|
|
314
|
+
globalThis.navigator?.userAgent === 'Cloudflare-Workers'
|
|
315
|
+
? this.#lastEventId
|
|
316
|
+
: utf8ToByteString(this.#lastEventId),
|
|
317
|
+
}
|
|
318
|
+
: undefined;
|
|
319
|
+
const init = {
|
|
320
|
+
// [spec] Let `corsAttributeState` be `Anonymous`…
|
|
321
|
+
// [spec] …will have their mode set to "cors"…
|
|
322
|
+
mode: 'cors',
|
|
323
|
+
redirect: 'follow',
|
|
324
|
+
headers: { Accept: 'text/event-stream', ...lastEvent },
|
|
325
|
+
cache: 'no-store',
|
|
326
|
+
signal: this.#controller?.signal,
|
|
327
|
+
};
|
|
328
|
+
// Some environments crash if attempting to set `credentials` where it is not supported,
|
|
329
|
+
// eg on Cloudflare Workers. To avoid this, we only set it in browser-like environments.
|
|
330
|
+
if ('window' in globalThis) {
|
|
331
|
+
// [spec] …and their credentials mode set to "same-origin"
|
|
332
|
+
// [spec] …if the `withCredentials` attribute is `true`, set the credentials mode to "include"…
|
|
333
|
+
init.credentials = this.withCredentials ? 'include' : 'same-origin';
|
|
334
|
+
}
|
|
335
|
+
return init;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Called by EventSourceParser when a blank line ends a block containing a valid `id` field.
|
|
339
|
+
* This runs before `#onEvent` when the same block also contains data.
|
|
340
|
+
*
|
|
341
|
+
* @param value - The value of the `id` field
|
|
342
|
+
* @internal
|
|
343
|
+
*/
|
|
344
|
+
#onIdChange = (value) => {
|
|
345
|
+
this.#lastEventId = value;
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Called by EventSourceParser instance when an event has successfully been parsed
|
|
349
|
+
* and is ready to be processed.
|
|
350
|
+
*
|
|
351
|
+
* @param event - The parsed event
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
#onEvent = (event) => {
|
|
355
|
+
// A listener can close the connection while the parser is still processing this chunk.
|
|
356
|
+
if (this.#readyState === this.CLOSED) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const origin = this.#redirectUrl ? this.#redirectUrl.origin : this.#url.origin;
|
|
360
|
+
// [spec] The `lastEventId` attribute is the last event ID string of the event
|
|
361
|
+
// source, i.e. the persisted buffer (`#lastEventId`) - not the current event's `id`.
|
|
362
|
+
// The buffer is only updated by an explicit `id` field and must survive an
|
|
363
|
+
// event that omits `id`.
|
|
364
|
+
const lastEventId = this.#lastEventId ?? '';
|
|
365
|
+
const messageEvent = new MessageEvent(event.event || 'message', {
|
|
366
|
+
data: event.data,
|
|
367
|
+
origin,
|
|
368
|
+
lastEventId,
|
|
369
|
+
});
|
|
370
|
+
// workerd (Cloudflare Workers) accepts `data` but silently drops `origin` and `lastEventId`
|
|
371
|
+
// from the constructor init, yielding `null` and `''`. Both are plain own properties there
|
|
372
|
+
// rather than prototype getters, so they can be assigned after the fact. Elsewhere the
|
|
373
|
+
// constructor honours them and this is skipped, so no runtime pays for it unnecessarily.
|
|
374
|
+
if (messageEvent.origin !== origin) {
|
|
375
|
+
defineEventProperty(messageEvent, 'origin', origin);
|
|
376
|
+
}
|
|
377
|
+
if (messageEvent.lastEventId !== lastEventId) {
|
|
378
|
+
defineEventProperty(messageEvent, 'lastEventId', lastEventId);
|
|
379
|
+
}
|
|
380
|
+
// The `onmessage` property only triggers on messages without an `event` field, or ones that
|
|
381
|
+
// explicitly set `message`. This is handled automatically: the event is dispatched with type
|
|
382
|
+
// `event.event || 'message'`, and `onmessage` is registered as a `message` event listener.
|
|
383
|
+
this.dispatchEvent(messageEvent);
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Called by EventSourceParser instance when a new reconnection interval is received
|
|
387
|
+
* from the EventSource endpoint.
|
|
388
|
+
*
|
|
389
|
+
* @param value - The new reconnection interval in milliseconds
|
|
390
|
+
* @internal
|
|
391
|
+
*/
|
|
392
|
+
#onRetryChange = (value) => {
|
|
393
|
+
this.#reconnectInterval = value;
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Called by EventSourceParser instance when a parse error occurs.
|
|
397
|
+
*
|
|
398
|
+
* @param error - The parser error
|
|
399
|
+
* @internal
|
|
400
|
+
*/
|
|
401
|
+
#onParseError = (error) => {
|
|
402
|
+
if (error.type !== 'max-buffer-size-exceeded') {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
this.close();
|
|
406
|
+
this.#failConnection(error.message);
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* Handles the process referred to in the EventSource specification as "failing a connection".
|
|
410
|
+
*
|
|
411
|
+
* @param error - The error causing the connection to fail
|
|
412
|
+
* @param code - The HTTP status code, if available
|
|
413
|
+
* @internal
|
|
414
|
+
*/
|
|
415
|
+
#failConnection(message, code) {
|
|
416
|
+
// [spec] …if the readyState attribute is set to a value other than CLOSED,
|
|
417
|
+
// [spec] sets the readyState attribute to CLOSED…
|
|
418
|
+
// Release the request before reporting failure, including responses with an unread body.
|
|
419
|
+
this.close();
|
|
420
|
+
// [spec] …and fires an event named `error` at the `EventSource` object.
|
|
421
|
+
// [spec] Once the user agent has failed the connection, it does not attempt to reconnect.
|
|
422
|
+
// [spec] > Implementations are especially encouraged to report detailed information
|
|
423
|
+
// [spec] > to their development consoles whenever an error event is fired, since little
|
|
424
|
+
// [spec] > to no information can be made available in the events themselves.
|
|
425
|
+
// Printing to console is not very programatically helpful, though, so we emit a custom event.
|
|
426
|
+
const errorEvent = new ErrorEvent('error', { code, message });
|
|
427
|
+
this.dispatchEvent(errorEvent);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Schedules a reconnection attempt against the EventSource endpoint.
|
|
431
|
+
*
|
|
432
|
+
* @param message - The error causing the connection to fail
|
|
433
|
+
* @param code - The HTTP status code, if available
|
|
434
|
+
* @internal
|
|
435
|
+
*/
|
|
436
|
+
#scheduleReconnect(message, code) {
|
|
437
|
+
// [spec] If the readyState attribute is set to CLOSED, abort the task.
|
|
438
|
+
if (this.#readyState === this.CLOSED) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
// [spec] Set the readyState attribute to CONNECTING.
|
|
442
|
+
this.#readyState = this.CONNECTING;
|
|
443
|
+
// [spec] Fire an event named `error` at the EventSource object.
|
|
444
|
+
const errorEvent = new ErrorEvent('error', { code, message });
|
|
445
|
+
this.dispatchEvent(errorEvent);
|
|
446
|
+
// [spec] Wait a delay equal to the reconnection time of the event source.
|
|
447
|
+
const timer = setTimeout(this.#reconnect, this.#reconnectInterval);
|
|
448
|
+
// In Node.js (and Bun), a pending timer keeps the event loop alive, preventing the
|
|
449
|
+
// process from exiting while we wait to reconnect. `unref()` opts out of that. Browsers
|
|
450
|
+
// and Deno return a numeric handle with no `unref()`, so only call it when available.
|
|
451
|
+
if (typeof timer === 'object' && timer !== null && 'unref' in timer) {
|
|
452
|
+
timer.unref();
|
|
453
|
+
}
|
|
454
|
+
this.#reconnectTimer = timer;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Reconnects to the EventSource endpoint after a disconnect/failure
|
|
458
|
+
*
|
|
459
|
+
* @internal
|
|
460
|
+
*/
|
|
461
|
+
#reconnect = () => {
|
|
462
|
+
this.#reconnectTimer = undefined;
|
|
463
|
+
// [spec] If the EventSource's readyState attribute is not set to CONNECTING, then return.
|
|
464
|
+
if (this.#readyState !== this.CONNECTING) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
this.#connect();
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
// The class is named `EventSourceImpl` to leave the `EventSource` name free for the interface and
|
|
471
|
+
// the const below. Restore the public name, so neither `EventSource.name` nor inspected instances
|
|
472
|
+
// (eg `console.log(eventSource)`) leak the implementation name.
|
|
473
|
+
Object.defineProperty(EventSourceImpl, 'name', { value: 'EventSource' });
|
|
474
|
+
// Provides a way to detect that the EventSource implementation supports passing `fetch`
|
|
475
|
+
// that can be used to customize the request, eg custom headers and similar.
|
|
476
|
+
Object.defineProperty(EventSourceImpl, Symbol.for('eventsource.supports-fetch-override'), {
|
|
477
|
+
value: true,
|
|
478
|
+
writable: false,
|
|
479
|
+
configurable: false,
|
|
480
|
+
enumerable: false,
|
|
481
|
+
});
|
|
482
|
+
/**
|
|
483
|
+
* An `EventSource` instance opens a persistent connection to an HTTP server, which sends events
|
|
484
|
+
* in `text/event-stream` format. The connection remains open until closed by calling `.close()`.
|
|
485
|
+
*
|
|
486
|
+
* @public
|
|
487
|
+
* @example
|
|
488
|
+
* ```js
|
|
489
|
+
* const eventSource = new EventSource('https://example.com/stream')
|
|
490
|
+
* eventSource.addEventListener('error', (error) => {
|
|
491
|
+
* console.error(error)
|
|
492
|
+
* })
|
|
493
|
+
* eventSource.addEventListener('message', (event) => {
|
|
494
|
+
* console.log('Received message:', event.data)
|
|
495
|
+
* })
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
export const EventSource = EventSourceImpl;
|
|
499
|
+
/**
|
|
500
|
+
* According to spec, when constructing a URL:
|
|
501
|
+
* > 1. Let baseURL be environment's base URL, if environment is a Document object
|
|
502
|
+
* > 2. Return the result of applying the URL parser to url, with baseURL.
|
|
503
|
+
*
|
|
504
|
+
* Thus we should use `document.baseURI` if available, since it can be set through a base tag.
|
|
505
|
+
*
|
|
506
|
+
* @returns The base URL, if available - otherwise `undefined`
|
|
507
|
+
* @internal
|
|
508
|
+
*/
|
|
509
|
+
function getBaseURL() {
|
|
510
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
511
|
+
const doc = 'document' in globalThis ? globalThis.document : undefined;
|
|
512
|
+
return doc && typeof doc === 'object' && 'baseURI' in doc && typeof doc.baseURI === 'string'
|
|
513
|
+
? doc.baseURI
|
|
514
|
+
: undefined;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Assigns a `MessageEvent` property that the constructor's init dictionary was supposed to have
|
|
518
|
+
* set, for runtimes that ignore it.
|
|
519
|
+
*
|
|
520
|
+
* Defined rather than assigned because on the runtimes that do implement the property as a
|
|
521
|
+
* prototype getter, a plain assignment would throw in strict mode. `enumerable` and
|
|
522
|
+
* `configurable` mirror how a spec-compliant implementation exposes it.
|
|
523
|
+
*
|
|
524
|
+
* @param event - The message event to define the property on
|
|
525
|
+
* @param property - The property to define
|
|
526
|
+
* @param value - The value the constructor should have set
|
|
527
|
+
* @internal
|
|
528
|
+
*/
|
|
529
|
+
function defineEventProperty(event, property, value) {
|
|
530
|
+
Object.defineProperty(event, property, {
|
|
531
|
+
value,
|
|
532
|
+
enumerable: true,
|
|
533
|
+
configurable: true,
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Encodes a string as UTF-8 and returns those bytes as a "byte string": one character per byte,
|
|
538
|
+
* each in the range U+0000 to U+00FF.
|
|
539
|
+
*
|
|
540
|
+
* Header values are byte strings. `fetch()` throws a `TypeError` for any character above U+00FF,
|
|
541
|
+
* and sends a character in U+0080 to U+00FF as a single Latin-1 byte, rather than as its UTF-8
|
|
542
|
+
* encoding. Passing the UTF-8 bytes through as characters makes `fetch()` put exactly those
|
|
543
|
+
* bytes on the wire.
|
|
544
|
+
*
|
|
545
|
+
* @param value - The string to encode
|
|
546
|
+
* @returns The UTF-8 bytes of `value`, one per character
|
|
547
|
+
* @internal
|
|
548
|
+
*/
|
|
549
|
+
function utf8ToByteString(value) {
|
|
550
|
+
let byteString = '';
|
|
551
|
+
for (const byte of new TextEncoder().encode(value)) {
|
|
552
|
+
byteString += String.fromCharCode(byte);
|
|
553
|
+
}
|
|
554
|
+
return byteString;
|
|
555
|
+
}
|
|
556
|
+
//# sourceMappingURL=EventSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventSource.js","sourceRoot":"","sources":["../src/EventSource.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAIb,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AAYjE,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAA;AAuJjD;;;;;;;;;;;GAWG;AACH,MAAM,eAAgB,SAAQ,WAAW;IACvC,MAAM,CAAC,UAAU,GAAG,CAAU,CAAA;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ElE;;;;;;;;;GASG;AACH,SAAS,UAAU;IACjB,8DAA8D;IAC9D,MAAM,GAAG,GAAG,UAAU,IAAI,UAAU,CAAC,CAAC,CAAE,UAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;IAC/E,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,SAAS,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAC1F,CAAC,CAAC,GAAG,CAAC,OAAO;QACb,CAAC,CAAC,SAAS,CAAA;AACf,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,mBAAmB,CAC1B,KAAmB,EACnB,QAAkC,EAClC,KAAa;IAEb,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE;QACrC,KAAK;QACL,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,KAAK,MAAM,IAAI,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnD,UAAU,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An extended version of the `Event` emitted by the `EventSource` object when an error occurs.
|
|
3
|
+
* While the spec does not include any additional properties, we intentionally go beyond the spec
|
|
4
|
+
* and provide some (minimal) additional information to aid in debugging.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class ErrorEvent extends Event {
|
|
9
|
+
/**
|
|
10
|
+
* HTTP status code, if this was triggered by an HTTP error
|
|
11
|
+
* Note: this is not part of the spec, but is included for better error handling.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
code?: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Optional message attached to the error.
|
|
18
|
+
* Note: this is not part of the spec, but is included for better error handling.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
message?: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
|
25
|
+
* but rather emitted by the `EventSource` object when an error occurs.
|
|
26
|
+
*
|
|
27
|
+
* @param type - The type of the event (should be "error")
|
|
28
|
+
* @param errorEventInitDict - Optional properties to include in the error event
|
|
29
|
+
*/
|
|
30
|
+
constructor(type: string, errorEventInitDict?: {
|
|
31
|
+
message?: string | undefined;
|
|
32
|
+
code?: number | undefined;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* For environments where DOMException may not exist, we will use a SyntaxError instead.
|
|
37
|
+
* While this isn't strictly according to spec, it is very close.
|
|
38
|
+
*
|
|
39
|
+
* @param message - The message to include in the error
|
|
40
|
+
* @returns A `DOMException` or `SyntaxError` instance
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare function syntaxError(message: string): SyntaxError;
|
|
44
|
+
/**
|
|
45
|
+
* Flatten an error into a single error message string.
|
|
46
|
+
* Unwraps nested errors and joins them with a comma.
|
|
47
|
+
*
|
|
48
|
+
* @param err - The error to flatten
|
|
49
|
+
* @returns A string representation of the error
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export declare function flattenError(err: unknown): string;
|
|
53
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC;;;;;OAKG;IACI,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAEhC;;;;;OAKG;IACI,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAEnC;;;;;;OAMG;IACH,YACE,IAAI,EAAE,MAAM,EACZ,kBAAkB,CAAC,EAAE;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAC,EAK/E;CAuCF;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAWxD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAcjD"}
|