@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,252 @@
|
|
|
1
|
+
# eventsource
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/eventsource)[](https://bundlephobia.com/result?p=eventsource)[](https://www.npmjs.com/package/eventsource)
|
|
4
|
+
|
|
5
|
+
WhatWG/W3C-compatible [server-sent events/eventsource](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) client. The module attempts to implement an absolute minimal amount of features/changes beyond the specification.
|
|
6
|
+
|
|
7
|
+
If you're looking for a modern alternative with a less constrained API, check out the [`eventsource-client` package](https://www.npmjs.com/package/eventsource-client).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install --save eventsource
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Supported engines
|
|
16
|
+
|
|
17
|
+
- Node.js >= 22.12
|
|
18
|
+
- Chrome >= 84
|
|
19
|
+
- Safari >= 15 ([non-ASCII event ID limitation](#safari-and-webkit))
|
|
20
|
+
- Firefox >= 105
|
|
21
|
+
- Edge >= 84
|
|
22
|
+
- Deno >= 2
|
|
23
|
+
- Bun >= 1.1.23
|
|
24
|
+
- Cloudflare Workers: [partial](#cloudflare-workers)
|
|
25
|
+
|
|
26
|
+
Basically, any environment that supports:
|
|
27
|
+
|
|
28
|
+
- [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
|
|
29
|
+
- [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
|
30
|
+
- [TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)
|
|
31
|
+
- [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)
|
|
32
|
+
- [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event), [MessageEvent](https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent), [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)
|
|
33
|
+
- [Private class fields, methods, and accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_elements)
|
|
34
|
+
- [Symbol.for](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for)
|
|
35
|
+
|
|
36
|
+
If you need to support runtimes without private class fields, methods and accessors, try the `4.x` branch/version range.
|
|
37
|
+
|
|
38
|
+
If you need to support even older runtimes, try the `2.x` branch/version range (note: 2.x branch is primarily targeted at Node.js, not browsers).
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import {EventSource} from 'eventsource'
|
|
44
|
+
|
|
45
|
+
const es = new EventSource('https://my-server.com/sse')
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* This will listen for events with the field `event: notice`.
|
|
49
|
+
*/
|
|
50
|
+
es.addEventListener('notice', (event) => {
|
|
51
|
+
console.log(event.data)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* This will listen for events with the field `event: update`.
|
|
56
|
+
*/
|
|
57
|
+
es.addEventListener('update', (event) => {
|
|
58
|
+
console.log(event.data)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* The event "message" is a special case, as it will capture events _without_ an
|
|
63
|
+
* event field, as well as events that have the specific type `event: message`.
|
|
64
|
+
* It will not trigger on any other event type.
|
|
65
|
+
*/
|
|
66
|
+
es.addEventListener('message', (event) => {
|
|
67
|
+
console.log(event.data)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* To explicitly close the connection, call the `close` method.
|
|
72
|
+
* This will prevent any reconnection from happening.
|
|
73
|
+
*/
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
es.close()
|
|
76
|
+
}, 10_000)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### TypeScript
|
|
80
|
+
|
|
81
|
+
Make sure you have configured your TSConfig so it matches the environment you are targetting. If you are targetting browsers, this would be `dom`:
|
|
82
|
+
|
|
83
|
+
```jsonc
|
|
84
|
+
{
|
|
85
|
+
"compilerOptions": {
|
|
86
|
+
"lib": ["dom"],
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If you're using Node.js, ensure you have `@types/node` installed (and it is version 22 or higher). Cloudflare workers have `@cloudflare/workers-types` etc.
|
|
92
|
+
|
|
93
|
+
The following errors are caused by targetting an environment that does not have the necessary types available:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
error TS2304: Cannot find name 'Event'.
|
|
97
|
+
error TS2304: Cannot find name 'EventTarget'.
|
|
98
|
+
error TS2304: Cannot find name 'MessageEvent'.
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Safari and WebKit
|
|
102
|
+
|
|
103
|
+
Safari/WebKit encodes non-ASCII `Last-Event-ID` header values as UTF-8 a second time, so the server receives a different ID on reconnect. This affects accented characters, currency symbols and emoji. Event data and `MessageEvent.lastEventId` retain their original Unicode values.
|
|
104
|
+
|
|
105
|
+
For the widest client compatibility, we recommend that servers use ASCII-only values in the event stream's `id` field. See [WebKit's header encoding](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h#L76-L85) for the underlying behavior.
|
|
106
|
+
|
|
107
|
+
### Cloudflare Workers
|
|
108
|
+
|
|
109
|
+
Cloudflare Workers require `compatibilityDate: '2024-11-11'` or later, and `addEventListener()` instead of the `onmessage`, `onopen` and `onerror` properties.
|
|
110
|
+
|
|
111
|
+
workerd's `EventTarget` dispatches `on<type>` handler properties itself, on top of the listener this module registers, so a handler assigned that way is called twice per event - and assigning `null` only removes one of the two registrations, so it does not unsubscribe ([workerd#6022](https://github.com/cloudflare/workerd/issues/6022)).
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// Called twice per message on Cloudflare Workers
|
|
115
|
+
eventSource.onmessage = (event) => console.log(event.data)
|
|
116
|
+
|
|
117
|
+
// Use this instead
|
|
118
|
+
eventSource.addEventListener('message', (event) => console.log(event.data))
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
workerd also drops `origin` and `lastEventId` from the `MessageEvent` constructor. This module assigns them itself, so both are correct on Workers today; the workaround goes away once [workerd#6995](https://github.com/cloudflare/workerd/pull/6995) lands.
|
|
122
|
+
|
|
123
|
+
Workers' native `fetch` encodes header values as UTF-8 itself. This module passes it the original event ID to avoid encoding twice. Custom `fetch` implementations receive a UTF-8 byte string; wrappers that forward to Workers' native `fetch` must decode `Last-Event-ID` back to Unicode first.
|
|
124
|
+
|
|
125
|
+
## Migrating from v1 / v2
|
|
126
|
+
|
|
127
|
+
See [MIGRATION.md](MIGRATION.md#v2-to-v3) for a detailed migration guide.
|
|
128
|
+
|
|
129
|
+
## Extensions to the WhatWG/W3C API
|
|
130
|
+
|
|
131
|
+
### Message and code properties on errors
|
|
132
|
+
|
|
133
|
+
The `error` event has a `message` and `code` property that can be used to get more information about the error. In the specification, the Event
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
es.addEventListener('error', (err) => {
|
|
137
|
+
if (err.code === 401 || err.code === 403) {
|
|
138
|
+
console.log('not authorized')
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Limit parser buffer size
|
|
144
|
+
|
|
145
|
+
The parser buffers up to 100 MB while waiting for a complete EventSource line. To change that limit, pass `maxBufferSize` in the constructor options:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const es = new EventSource('https://my-server.com/sse', {
|
|
149
|
+
maxBufferSize: 10 * 1024 * 1024, // 10 MB
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
If the limit is exceeded, the connection fails and emits an `error` event, and will not reconnect. Prefer servers that emit smaller chunks or newlines more frequently over increasing this limit.
|
|
154
|
+
|
|
155
|
+
### Specify `fetch` implementation
|
|
156
|
+
|
|
157
|
+
The `EventSource` constructor accepts an optional `fetch` property in the second argument that can be used to specify the `fetch` implementation to use.
|
|
158
|
+
|
|
159
|
+
This can be useful in environments where the global `fetch` function is not available - but it can also be used to alter the request/response behaviour.
|
|
160
|
+
|
|
161
|
+
#### Setting HTTP request headers
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const es = new EventSource('https://my-server.com/sse', {
|
|
165
|
+
fetch: (input, init) =>
|
|
166
|
+
fetch(input, {
|
|
167
|
+
...init,
|
|
168
|
+
headers: {
|
|
169
|
+
...init.headers,
|
|
170
|
+
Authorization: 'Bearer myToken',
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### HTTP/HTTPS proxy
|
|
177
|
+
|
|
178
|
+
Use a package like [`undici`](https://github.com/nodejs/undici) to add proxy support, either through environment variables or explicit configuration.
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
// npm install undici --save
|
|
182
|
+
import {fetch, EnvHttpProxyAgent} from 'undici'
|
|
183
|
+
|
|
184
|
+
const proxyAgent = new EnvHttpProxyAgent()
|
|
185
|
+
|
|
186
|
+
const es = new EventSource('https://my-server.com/sse', {
|
|
187
|
+
fetch: (input, init) => fetch(input, {...init, dispatcher: proxyAgent}),
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Using HTTP2
|
|
192
|
+
|
|
193
|
+
Use a package like [`undici`](https://github.com/nodejs/undici) that supports HTTP2.
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
// npm install undici --save
|
|
197
|
+
import {Agent, fetch} from 'undici'
|
|
198
|
+
|
|
199
|
+
const http2Dispatcher = new Agent({allowH2: true})
|
|
200
|
+
|
|
201
|
+
const es = new EventSource('https://my-server.com/sse', {
|
|
202
|
+
fetch: (url, init) => fetch(url, {...init, dispatcher: http2Dispatcher}),
|
|
203
|
+
})
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### Allow unauthorized HTTPS requests
|
|
207
|
+
|
|
208
|
+
Use a package like [`undici`](https://github.com/nodejs/undici) for more control of fetch options through the use of an [`Agent`](https://undici.nodejs.org/#/docs/api/Agent.md).
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
// npm install undici --save
|
|
212
|
+
import {fetch, Agent} from 'undici'
|
|
213
|
+
|
|
214
|
+
const unsafeAgent = new Agent({
|
|
215
|
+
connect: {
|
|
216
|
+
rejectUnauthorized: false,
|
|
217
|
+
},
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
await fetch('https://my-server.com/sse', {
|
|
221
|
+
dispatcher: unsafeAgent,
|
|
222
|
+
})
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### Feature checking
|
|
226
|
+
|
|
227
|
+
For library authors, you may want to feature-check if an EventSource implementation supports passing a custom `fetch` implementation (such as this library does). We declare (from [v4.1.0](https://github.com/EventSource/eventsource/releases/tag/v4.1.0) and onwards) a non-enumerable symbol on the EventSource class to indicate this, named `eventsource.supports-fetch-override`. It can be used downstream such as:
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
function yourLibrary(options) {
|
|
231
|
+
const OurEventSource = options.polyfills.EventSource || globalThis.EventSource
|
|
232
|
+
|
|
233
|
+
if (OurEventSource && Symbol.for('eventsource.supports-fetch-override') in OurEventSource) {
|
|
234
|
+
// We can safely assume this supports overriding/specifying `fetch`!
|
|
235
|
+
const es = new OurEventSource('https://some.url', {
|
|
236
|
+
fetch: (input, init) =>
|
|
237
|
+
fetch(input, {
|
|
238
|
+
...init,
|
|
239
|
+
headers: {
|
|
240
|
+
...(init.headers || {}),
|
|
241
|
+
'x-some-header': 'foo',
|
|
242
|
+
},
|
|
243
|
+
}),
|
|
244
|
+
})
|
|
245
|
+
// …
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
MIT-licensed. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ErrorEvent } from './errors.ts';
|
|
2
|
+
import type { AddEventListenerOptions, EventListenerOptions, EventListenerOrEventListenerObject, EventSourceEventMap, EventSourceInit } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* An `EventSource` instance opens a persistent connection to an HTTP server, which sends events
|
|
5
|
+
* in `text/event-stream` format. The connection remains open until closed by calling `.close()`.
|
|
6
|
+
*
|
|
7
|
+
* Deliberately an `interface` and not a `class`: it lets consumers pass the native `EventSource`,
|
|
8
|
+
* a mock, or any other implementation wherever this type is expected.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* const eventSource = new EventSource('https://example.com/stream')
|
|
14
|
+
* eventSource.addEventListener('error', (error) => {
|
|
15
|
+
* console.error(error)
|
|
16
|
+
* })
|
|
17
|
+
* eventSource.addEventListener('message', (event) => {
|
|
18
|
+
* console.log('Received message:', event.data)
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export interface EventSource extends EventTarget {
|
|
23
|
+
/**
|
|
24
|
+
* ReadyState representing an EventSource currently trying to connect
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
readonly CONNECTING: 0;
|
|
29
|
+
/**
|
|
30
|
+
* ReadyState representing an EventSource connection that is open (eg connected)
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
readonly OPEN: 1;
|
|
35
|
+
/**
|
|
36
|
+
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
readonly CLOSED: 2;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the state of this EventSource object's connection. It can have the values described below.
|
|
43
|
+
*
|
|
44
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
45
|
+
*
|
|
46
|
+
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
|
47
|
+
* defined in the TypeScript `dom` library.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
readonly readyState: number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the URL providing the event stream.
|
|
54
|
+
*
|
|
55
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
readonly url: string;
|
|
60
|
+
/**
|
|
61
|
+
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
|
62
|
+
*
|
|
63
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
readonly withCredentials: boolean;
|
|
68
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
69
|
+
onerror: ((this: EventSource, ev: ErrorEvent) => unknown) | null;
|
|
70
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
71
|
+
onmessage: ((this: EventSource, ev: MessageEvent) => unknown) | null;
|
|
72
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
73
|
+
onopen: ((this: EventSource, ev: Event) => unknown) | null;
|
|
74
|
+
addEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
75
|
+
addEventListener(type: string, listener: (this: EventSource, event: MessageEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
76
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
77
|
+
removeEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: EventSource, ev: EventSourceEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
78
|
+
removeEventListener(type: string, listener: (this: EventSource, event: MessageEvent) => unknown, options?: boolean | EventListenerOptions): void;
|
|
79
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
80
|
+
/**
|
|
81
|
+
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
82
|
+
*
|
|
83
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
close(): void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The `EventSource` constructor. Mirrors the shape of the native one, so the two can be used
|
|
91
|
+
* interchangeably - eg for functions that take an implementation to construct.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export interface EventSourceConstructor {
|
|
96
|
+
readonly prototype: EventSource;
|
|
97
|
+
/**
|
|
98
|
+
* Constructs a new `EventSource` instance, which immediately starts connecting.
|
|
99
|
+
*
|
|
100
|
+
* @param url - The URL to connect to
|
|
101
|
+
* @param eventSourceInitDict - Options for the connection
|
|
102
|
+
*/
|
|
103
|
+
new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
|
|
104
|
+
/** ReadyState representing an EventSource currently trying to connect */
|
|
105
|
+
readonly CONNECTING: 0;
|
|
106
|
+
/** ReadyState representing an EventSource connection that is open (eg connected) */
|
|
107
|
+
readonly OPEN: 1;
|
|
108
|
+
/** ReadyState representing an EventSource connection that is closed (eg disconnected) */
|
|
109
|
+
readonly CLOSED: 2;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* An `EventSource` instance opens a persistent connection to an HTTP server, which sends events
|
|
113
|
+
* in `text/event-stream` format. The connection remains open until closed by calling `.close()`.
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
* @example
|
|
117
|
+
* ```js
|
|
118
|
+
* const eventSource = new EventSource('https://example.com/stream')
|
|
119
|
+
* eventSource.addEventListener('error', (error) => {
|
|
120
|
+
* console.error(error)
|
|
121
|
+
* })
|
|
122
|
+
* eventSource.addEventListener('message', (event) => {
|
|
123
|
+
* console.log('Received message:', event.data)
|
|
124
|
+
* })
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare const EventSource: EventSourceConstructor;
|
|
128
|
+
//# sourceMappingURL=EventSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventSource.d.ts","sourceRoot":"","sources":["../src/EventSource.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,UAAU,EAA4B,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,kCAAkC,EAClC,mBAAmB,EAEnB,eAAe,EAGhB,MAAM,YAAY,CAAA;AAInB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAEhB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAElB;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE3B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IAEjC,0FAA0F;IAC1F,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,KAAK,OAAO,CAAC,GAAG,IAAI,CAAA;IAEhE,4FAA4F;IAC5F,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,IAAI,CAAA;IAEpE,yFAAyF;IACzF,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,KAAK,OAAO,CAAC,GAAG,IAAI,CAAA;IAE1D,gBAAgB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAClD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,OAAO,EACpE,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;IACP,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,EAC7D,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;IACP,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,kCAAkC,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;IAEP,mBAAmB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACrD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,OAAO,EACpE,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI,CAAA;IACP,mBAAmB,CACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,KAAK,OAAO,EAC7D,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI,CAAA;IACP,mBAAmB,CACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,kCAAkC,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI,CAAA;IAEP;;;;;;OAMG;IACH,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAA;IAE/B;;;;;OAKG;IACH,KAAK,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,mBAAmB,CAAC,EAAE,eAAe,GAAG,WAAW,CAAA;IAE3E,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IAEtB,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAEhB,yFAAyF;IACzF,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CACnB;AAmlBD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,EAAE,sBAAwC,CAAA"}
|