@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,31 @@
|
|
|
1
|
+
import type { Patches, ApplyImmutableOptions, ApplyMutableOptions, ApplyOptions, ApplyResult } from './interface';
|
|
2
|
+
/**
|
|
3
|
+
* `apply(state, patches)` to apply patches to state
|
|
4
|
+
*
|
|
5
|
+
* ## Example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { create, apply } from 'mutative';
|
|
9
|
+
*
|
|
10
|
+
* const baseState = { foo: { bar: 'str' }, arr: [] };
|
|
11
|
+
* const [state, patches] = create(
|
|
12
|
+
* baseState,
|
|
13
|
+
* (draft) => {
|
|
14
|
+
* draft.foo.bar = 'str2';
|
|
15
|
+
* },
|
|
16
|
+
* { enablePatches: true }
|
|
17
|
+
* );
|
|
18
|
+
* expect(state).toEqual({ foo: { bar: 'str2' }, arr: [] });
|
|
19
|
+
* expect(patches).toEqual([{ op: 'replace', path: ['foo', 'bar'], value: 'str2' }]);
|
|
20
|
+
* expect(state).toEqual(apply(baseState, patches));
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function apply<T extends object, F extends boolean = false, _A extends ApplyOptions<boolean> | undefined = ApplyImmutableOptions<F>>(state: T, patches: Patches, applyOptions?: undefined): ApplyResult<T, F, undefined>;
|
|
24
|
+
export declare function apply<T extends object, F extends boolean = false, A extends ApplyOptions<boolean> | undefined = ApplyImmutableOptions<F>>(state: T, patches: Patches, applyOptions: A): ApplyResult<T, F, A>;
|
|
25
|
+
export declare function apply<T extends object, F extends boolean = false, A extends ApplyOptions<boolean> | undefined = ApplyImmutableOptions<F>>(state: T, patches: Patches, applyOptions?: A): ApplyResult<T, F, A | undefined>;
|
|
26
|
+
export declare function apply<T extends object, F extends boolean = false>(state: T, patches: Patches, applyOptions: {
|
|
27
|
+
mutable: true;
|
|
28
|
+
}): ApplyResult<T, F, {
|
|
29
|
+
mutable: true;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function apply<T extends object, F extends boolean = false>(state: T, patches: Patches, applyOptions: ApplyMutableOptions | undefined): ApplyResult<T, F, ApplyMutableOptions | undefined>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ProxyDraft } from './interface';
|
|
2
|
+
/**
|
|
3
|
+
* Records that the get trap handed out an optimized method of `target`. Only
|
|
4
|
+
* a switch between arrays of a live producer adds a weak-collection entry, so
|
|
5
|
+
* the common case of one array per producer allocates nothing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function trackArrayMethod(target: ProxyDraft): void;
|
|
8
|
+
/**
|
|
9
|
+
* Called by `create` whenever a producer ends, normally or by an error, so
|
|
10
|
+
* this module keeps no reference to its drafts. Another producer's entry, such
|
|
11
|
+
* as an outer producer's, is left in place.
|
|
12
|
+
*/
|
|
13
|
+
export declare function releaseArrayMethods(revoke: unknown[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* The original index under which a read of `value` at `index` drafts it, or
|
|
16
|
+
* -1 when the read hands it out as is: an element at its original index, or,
|
|
17
|
+
* once native operations moved elements, any element of the original array
|
|
18
|
+
* except a value the recipe assigned at `index`, whose record moves along
|
|
19
|
+
* with it. Reads, searches and removals all decide by it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function baseIndex(target: ProxyDraft, value: any, index: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* After the proxy lengthened an array draft, by its length or by an assignment
|
|
24
|
+
* past its end, holes follow. An index that the array exposes again below the
|
|
25
|
+
* original length lost its element to a shorter length earlier; no assignment
|
|
26
|
+
* records such an index, and a native move may have dropped one, so patches
|
|
27
|
+
* compare it. Marking the range as moved leaves reads as they are: an exposed
|
|
28
|
+
* index holds a hole, and an assigned value is handed out as it is.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resized(target: ProxyDraft, previous: number): void;
|
|
31
|
+
type Native = (...args: any[]) => any;
|
|
32
|
+
/**
|
|
33
|
+
* Whether `value`, which the array already holds at `index`, is an element of
|
|
34
|
+
* the base state that native methods moved there. The proxy path moves
|
|
35
|
+
* elements by reading them, so it holds a draft there, and assigning the raw
|
|
36
|
+
* element replaces the draft and records an assignment; the set trap records
|
|
37
|
+
* one as well instead of ignoring the assignment.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isMovedElement(target: ProxyDraft, value: any, index: any): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Array methods without callbacks run natively on the draft's copy instead
|
|
42
|
+
* of moving every element through the proxy traps.
|
|
43
|
+
*/
|
|
44
|
+
export declare const arrayMethods: Record<PropertyKey, Native>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PROXY_DRAFT: unique symbol;
|
|
2
|
+
export declare const RAW_RETURN_SYMBOL: unique symbol;
|
|
3
|
+
export declare const iteratorSymbol: typeof Symbol.iterator;
|
|
4
|
+
export declare const iteratorPrototype: any;
|
|
5
|
+
export declare const dataTypes: {
|
|
6
|
+
readonly mutable: "mutable";
|
|
7
|
+
readonly immutable: "immutable";
|
|
8
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `create(baseState, callback, options)` to create the next state
|
|
3
|
+
*
|
|
4
|
+
* ## Example
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { create } from 'mutative';
|
|
8
|
+
*
|
|
9
|
+
* const baseState = { foo: { bar: 'str' }, arr: [] };
|
|
10
|
+
* const state = create(
|
|
11
|
+
* baseState,
|
|
12
|
+
* (draft) => {
|
|
13
|
+
* draft.foo.bar = 'str2';
|
|
14
|
+
* },
|
|
15
|
+
* );
|
|
16
|
+
*
|
|
17
|
+
* expect(state).toEqual({ foo: { bar: 'str2' }, arr: [] });
|
|
18
|
+
* expect(state).not.toBe(baseState);
|
|
19
|
+
* expect(state.foo).not.toBe(baseState.foo);
|
|
20
|
+
* expect(state.arr).toBe(baseState.arr);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const create: {
|
|
24
|
+
<T = never, F extends boolean = false, O extends import("./interface").PatchesOptions = false>(base: [T][T extends any ? 0 : never], mutate: [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>) => ([[T][T extends any ? 0 : never]] extends [string | number | bigint | boolean | symbol | null | undefined] ? true : false) extends true ? Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>> & {
|
|
25
|
+
readonly __mutativeAsyncContext: never;
|
|
26
|
+
} : (Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>> & {
|
|
27
|
+
readonly __mutativeAsyncContext: never;
|
|
28
|
+
}) | (void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>), options?: import("./interface").ExternalOptions<O, F> | undefined): import("./interface").Result<[T][T extends any ? 0 : never], O, F>;
|
|
29
|
+
<T = never, F extends boolean = false, O extends import("./interface").PatchesOptions = false>(base: [T][T extends any ? 0 : never], mutate: [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>) => Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>>, options?: import("./interface").ExternalOptions<O, F> | undefined): Promise<import("./interface").Result<[T][T extends any ? 0 : never], O, F>>;
|
|
30
|
+
<T = never, F extends boolean = false, O extends import("./interface").PatchesOptions = false>(base: [T][T extends any ? 0 : never], mutate: ([[T][T extends any ? 0 : never]] extends [string | number | bigint | boolean | symbol | null | undefined] ? true : false) extends true ? [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>) => void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]> : never, options?: import("./interface").ExternalOptions<O, F> | undefined): import("./interface").Result<[T][T extends any ? 0 : never], O, F>;
|
|
31
|
+
<T = never, F extends boolean = false, O extends import("./interface").PatchesOptions = false>(base: [T][T extends any ? 0 : never], mutate: [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>) => (void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>) | Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>>, options?: import("./interface").ExternalOptions<O, F> | undefined): import("./interface").Result<[T][T extends any ? 0 : never], O, F> | Promise<import("./interface").Result<[T][T extends any ? 0 : never], O, F>>;
|
|
32
|
+
<T extends unknown, F extends boolean = false, O extends import("./interface").PatchesOptions = false, R extends void | Promise<void> | T | Promise<T> = void>(base: T, mutate: (draft: import("./interface").Draft<T>) => R, options?: import("./interface").ExternalOptions<O, F> | undefined): import("./interface").CreateResult<T, O, F, R>;
|
|
33
|
+
<T extends unknown, F extends boolean = false, O extends import("./interface").PatchesOptions = false, R extends void | Promise<void> = void>(base: T, mutate: (draft: T) => R, options?: import("./interface").ExternalOptions<O, F> | undefined): import("./interface").CreateResult<T, O, F, R>;
|
|
34
|
+
<T = never, P extends any[] = [], F extends boolean = false, O extends import("./interface").PatchesOptions = false>(mutate: [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>, ...args: P) => ([[T][T extends any ? 0 : never]] extends [string | number | bigint | boolean | symbol | null | undefined] ? true : false) extends true ? Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>> & {
|
|
35
|
+
readonly __mutativeAsyncContext: never;
|
|
36
|
+
} : (Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>> & {
|
|
37
|
+
readonly __mutativeAsyncContext: never;
|
|
38
|
+
}) | (void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>), options?: import("./interface").ExternalOptions<O, F> | undefined): (base: [T][T extends any ? 0 : never], ...args: P) => import("./interface").Result<[T][T extends any ? 0 : never], O, F>;
|
|
39
|
+
<T = never, P extends any[] = [], F extends boolean = false, O extends import("./interface").PatchesOptions = false>(mutate: [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>, ...args: P) => Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>>, options?: import("./interface").ExternalOptions<O, F> | undefined): (base: [T][T extends any ? 0 : never], ...args: P) => Promise<import("./interface").Result<[T][T extends any ? 0 : never], O, F>>;
|
|
40
|
+
<T = never, P extends any[] = [], F extends boolean = false, O extends import("./interface").PatchesOptions = false>(mutate: ([[T][T extends any ? 0 : never]] extends [string | number | bigint | boolean | symbol | null | undefined] ? true : false) extends true ? [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>, ...args: P) => void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]> : never, options?: import("./interface").ExternalOptions<O, F> | undefined): (base: [T][T extends any ? 0 : never], ...args: P) => import("./interface").Result<[T][T extends any ? 0 : never], O, F>;
|
|
41
|
+
<T = never, P extends any[] = [], F extends boolean = false, O extends import("./interface").PatchesOptions = false>(mutate: [T] extends [never] ? never : (draft: import("./interface").Draft<[T][T extends any ? 0 : never]>, ...args: P) => (void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>) | Promise<void | [T][T extends any ? 0 : never] | import("./interface").Draft<[T][T extends any ? 0 : never]>>, options?: import("./interface").ExternalOptions<O, F> | undefined): (base: [T][T extends any ? 0 : never], ...args: P) => import("./interface").Result<[T][T extends any ? 0 : never], O, F> | Promise<import("./interface").Result<[T][T extends any ? 0 : never], O, F>>;
|
|
42
|
+
<T extends unknown, P extends any[] = [], F extends boolean = false, O extends import("./interface").PatchesOptions = false, R extends void | Promise<void> | T | Promise<T> = void>(mutate: (draft: import("./interface").Draft<T>, ...args: P) => R, options?: import("./interface").ExternalOptions<O, F> | undefined): (base: T, ...args: P) => import("./interface").CreateResult<T, O, F, R>;
|
|
43
|
+
<T extends unknown, P extends any[] = [], F extends boolean = false, O extends import("./interface").PatchesOptions = false, R extends void | Promise<void> | T | Promise<T> = void>(mutate: (draft: T, ...args: P) => R, options?: import("./interface").ExternalOptions<O, F> | undefined): (base: T, ...args: P) => import("./interface").CreateResult<T, O, F, R>;
|
|
44
|
+
<T extends unknown, O extends import("./interface").PatchesOptions = false, F extends boolean = false>(base: T, options?: import("./interface").ExternalOptions<O, F> | undefined): [import("./interface").Draft<T>, () => import("./interface").Result<T, O, F>];
|
|
45
|
+
};
|
|
46
|
+
export { create };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Draft, type ProxyDraft } from './interface';
|
|
2
|
+
export declare function handleReturnValue(rootDraft: ProxyDraft<any> | undefined, value: object, useRawReturn?: boolean): void;
|
|
3
|
+
/**
|
|
4
|
+
* `current(draft)` to get current state in the draft mutation function.
|
|
5
|
+
*
|
|
6
|
+
* ## Example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { create, current } from 'mutative';
|
|
10
|
+
*
|
|
11
|
+
* const baseState = { foo: { bar: 'str' }, arr: [] };
|
|
12
|
+
* const state = create(
|
|
13
|
+
* baseState,
|
|
14
|
+
* (draft) => {
|
|
15
|
+
* draft.foo.bar = 'str2';
|
|
16
|
+
* expect(current(draft.foo)).toEqual({ bar: 'str2' });
|
|
17
|
+
* },
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function current<T extends object>(target: Draft<T>): T;
|
|
22
|
+
/** @deprecated You should call current only on `Draft<T>` types. */
|
|
23
|
+
export declare function current<T extends object>(target: T): T;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Finalities, Patches, ProxyDraft, Options } from './interface';
|
|
2
|
+
export declare function createDraft<T extends object>(original: T, parentDraft: ProxyDraft | null, key: string | number | symbol | undefined, finalities: Finalities, options: Options<any, any>): T;
|
|
3
|
+
export declare function finalizeDraft<T>(result: T, returnedValue: [T] | [], patches?: Patches, inversePatches?: Patches, enableAutoFreeze?: boolean): [T, Patches | undefined, Patches | undefined];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Finalities, Options, PatchesOptions, Result } from './interface';
|
|
2
|
+
export declare function draftify<T extends object, O extends PatchesOptions = false, F extends boolean = false>(baseState: T, options: Options<O, F>): [T, (returnedValue: [T] | []) => Result<T, O, F>, Finalities];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes are kept as a const enum so production builds can inline them.
|
|
3
|
+
* Verify that production bundles contain neither an `ErrorCode` object nor
|
|
4
|
+
* the member names when changing the build toolchain.
|
|
5
|
+
* Keep numeric codes stable; retired codes must not be reassigned.
|
|
6
|
+
*/
|
|
7
|
+
export declare const enum ErrorCode {
|
|
8
|
+
InvalidBaseState = 0,
|
|
9
|
+
CannotAssignToMapOrSet = 1,
|
|
10
|
+
InvalidArrayIndex = 2,
|
|
11
|
+
CannotSetPrototypeOfDraft = 3,
|
|
12
|
+
CannotDefinePropertyOnDraft = 4,
|
|
13
|
+
MutateAndReturn = 5,
|
|
14
|
+
CannotReturnModifiedChildDraft = 6,
|
|
15
|
+
CurrentOnNonDraft = 7,
|
|
16
|
+
StrictModeAccess = 8,
|
|
17
|
+
UnsupportedMarkResult = 9,
|
|
18
|
+
InvalidMark = 10,
|
|
19
|
+
CannotModifyFrozenObject = 11,
|
|
20
|
+
ReservedPatchAttribute = 13,
|
|
21
|
+
CannotApplyPatch = 14,
|
|
22
|
+
ReplacePatchOnSet = 15,
|
|
23
|
+
UnsupportedPatchOperation = 16,
|
|
24
|
+
ApplyOptionsToDraft = 17,
|
|
25
|
+
OriginalOnNonDraft = 18,
|
|
26
|
+
RawReturnWithoutValue = 19,
|
|
27
|
+
RawReturnWithExtraArguments = 20,
|
|
28
|
+
ReplaceMutableRoot = 21
|
|
29
|
+
}
|
|
30
|
+
type ErrorArguments = {
|
|
31
|
+
[ErrorCode.InvalidBaseState]: [];
|
|
32
|
+
[ErrorCode.CannotAssignToMapOrSet]: [];
|
|
33
|
+
[ErrorCode.InvalidArrayIndex]: [];
|
|
34
|
+
[ErrorCode.CannotSetPrototypeOfDraft]: [];
|
|
35
|
+
[ErrorCode.CannotDefinePropertyOnDraft]: [];
|
|
36
|
+
[ErrorCode.MutateAndReturn]: [];
|
|
37
|
+
[ErrorCode.CannotReturnModifiedChildDraft]: [];
|
|
38
|
+
[ErrorCode.CurrentOnNonDraft]: [target: any];
|
|
39
|
+
[ErrorCode.StrictModeAccess]: [];
|
|
40
|
+
[ErrorCode.UnsupportedMarkResult]: [markResult: any];
|
|
41
|
+
[ErrorCode.InvalidMark]: [];
|
|
42
|
+
[ErrorCode.CannotModifyFrozenObject]: [];
|
|
43
|
+
[ErrorCode.ReservedPatchAttribute]: [];
|
|
44
|
+
[ErrorCode.CannotApplyPatch]: [path: (string | number)[]];
|
|
45
|
+
[ErrorCode.ReplacePatchOnSet]: [];
|
|
46
|
+
[ErrorCode.UnsupportedPatchOperation]: [op: string];
|
|
47
|
+
[ErrorCode.ApplyOptionsToDraft]: [];
|
|
48
|
+
[ErrorCode.OriginalOnNonDraft]: [target: any];
|
|
49
|
+
[ErrorCode.RawReturnWithoutValue]: [];
|
|
50
|
+
[ErrorCode.RawReturnWithExtraArguments]: [];
|
|
51
|
+
[ErrorCode.ReplaceMutableRoot]: [];
|
|
52
|
+
};
|
|
53
|
+
export declare function die<Code extends ErrorCode>(error: Code, ...args: ErrorArguments[Code]): never;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { makeCreator } from './makeCreator';
|
|
2
|
+
export { create } from './create';
|
|
3
|
+
export { apply } from './apply';
|
|
4
|
+
export { original } from './original';
|
|
5
|
+
export { current } from './current';
|
|
6
|
+
export { unsafe } from './unsafe';
|
|
7
|
+
export { rawReturn } from './rawReturn';
|
|
8
|
+
export { isDraft } from './utils/draft';
|
|
9
|
+
export { isDraftable } from './utils/draft';
|
|
10
|
+
export { markSimpleObject } from './utils/marker';
|
|
11
|
+
export { castDraft, castImmutable, castMutable } from './utils/cast';
|
|
12
|
+
export type { Immutable, Draft, Patches, Patch, ExternalOptions as Options, PatchesOptions, DraftedObject, } from './interface';
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { dataTypes } from './constant';
|
|
2
|
+
export declare const enum DraftType {
|
|
3
|
+
Object = 0,
|
|
4
|
+
Array = 1,
|
|
5
|
+
Map = 2,
|
|
6
|
+
Set = 3
|
|
7
|
+
}
|
|
8
|
+
export declare const Operation: {
|
|
9
|
+
readonly Remove: "remove";
|
|
10
|
+
readonly Replace: "replace";
|
|
11
|
+
readonly Add: "add";
|
|
12
|
+
};
|
|
13
|
+
export type DataType = keyof typeof dataTypes;
|
|
14
|
+
/**
|
|
15
|
+
* The `enablePatches` option: `true` or an object generates patches, `false`
|
|
16
|
+
* does not.
|
|
17
|
+
*/
|
|
18
|
+
export type PatchesOptions = boolean | {
|
|
19
|
+
/**
|
|
20
|
+
* Whether a patch path is an array of keys, as by default, or a JSON
|
|
21
|
+
* Pointer string, such as `/list/0`.
|
|
22
|
+
*/
|
|
23
|
+
pathAsArray?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether an array that gets shorter gets a `replace` patch of its
|
|
26
|
+
* `length`, as by default, or a `remove` patch for each index that it
|
|
27
|
+
* loses, as JSON Patch requires.
|
|
28
|
+
* Recreating holes in a sparse array still uses length patches;
|
|
29
|
+
* JSON cannot represent holes.
|
|
30
|
+
*/
|
|
31
|
+
arrayLengthAssignment?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type FinalizeCallback = (patches?: Patches, inversePatches?: Patches) => void;
|
|
34
|
+
export interface Finalities {
|
|
35
|
+
draft: (ProxyDraft | FinalizeCallback)[];
|
|
36
|
+
revoke: (() => void)[];
|
|
37
|
+
handledSet: WeakSet<any>;
|
|
38
|
+
scoped: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ProxyDraft<T = any> {
|
|
41
|
+
type: DraftType;
|
|
42
|
+
operated: boolean;
|
|
43
|
+
finalized: boolean;
|
|
44
|
+
original: T;
|
|
45
|
+
copy: T | null;
|
|
46
|
+
proxy: T | null;
|
|
47
|
+
finalities: Finalities;
|
|
48
|
+
options: Options<any, any>;
|
|
49
|
+
parent: ProxyDraft | null;
|
|
50
|
+
key: string | number | symbol | undefined;
|
|
51
|
+
setMap: (Map<any, any> & {
|
|
52
|
+
items?: any[];
|
|
53
|
+
}) | undefined;
|
|
54
|
+
assignedMap: Map<any, boolean> | undefined;
|
|
55
|
+
callbacks: FinalizeCallback[] | undefined;
|
|
56
|
+
children: any;
|
|
57
|
+
child: any;
|
|
58
|
+
childKey: any;
|
|
59
|
+
arrayState: ArrayState | null;
|
|
60
|
+
}
|
|
61
|
+
export interface ArrayState {
|
|
62
|
+
relocated: boolean;
|
|
63
|
+
diffStart: number;
|
|
64
|
+
diffEnd: number;
|
|
65
|
+
baseRefs: Map<any, number> | null;
|
|
66
|
+
delta: number | undefined;
|
|
67
|
+
lookups: number;
|
|
68
|
+
inert: boolean | null;
|
|
69
|
+
dense: boolean | null;
|
|
70
|
+
}
|
|
71
|
+
export interface IPatch {
|
|
72
|
+
op: (typeof Operation)[keyof typeof Operation];
|
|
73
|
+
value?: any;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* An `add`, `remove` or `replace` operation at a path, as `create()` generates
|
|
77
|
+
* it with `enablePatches` and `apply()` applies it. The path is an array of
|
|
78
|
+
* keys, or a JSON Pointer string with `pathAsArray: false`.
|
|
79
|
+
*/
|
|
80
|
+
export type Patch<P extends PatchesOptions = any> = P extends {
|
|
81
|
+
pathAsArray: false;
|
|
82
|
+
} ? IPatch & {
|
|
83
|
+
path: string;
|
|
84
|
+
} : P extends true | object ? IPatch & {
|
|
85
|
+
path: (string | number)[];
|
|
86
|
+
} : IPatch & {
|
|
87
|
+
path: string | (string | number)[];
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Patches in the order in which `apply()` applies them.
|
|
91
|
+
*/
|
|
92
|
+
export type Patches<P extends PatchesOptions = any> = Patch<P>[];
|
|
93
|
+
export type Result<T extends any, O extends PatchesOptions, F extends boolean> = O extends true | object ? [F extends true ? Immutable<T> : T, Patches<O>, Patches<O>] : F extends true ? Immutable<T> : T;
|
|
94
|
+
export type CreateResult<T extends any, O extends PatchesOptions, F extends boolean, R extends void | Promise<void> | T | Promise<T>> = R extends Promise<void> | Promise<T> ? Promise<Result<T, O, F>> : Result<T, O, F>;
|
|
95
|
+
type BaseMark = null | undefined | DataType;
|
|
96
|
+
type MarkWithCopy = BaseMark | (() => any);
|
|
97
|
+
export type Mark<O extends PatchesOptions, F extends boolean> = (target: any, types: typeof dataTypes) => O extends true | object ? BaseMark : F extends true ? BaseMark : MarkWithCopy;
|
|
98
|
+
export interface ApplyMutableOptions {
|
|
99
|
+
/**
|
|
100
|
+
* If it's `true`, the state will be mutated directly.
|
|
101
|
+
*/
|
|
102
|
+
mutable?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface Options<O extends PatchesOptions, F extends boolean> {
|
|
105
|
+
/**
|
|
106
|
+
* In strict mode, reading an object that cannot be drafted from a draft,
|
|
107
|
+
* such as a class instance that no mark makes draftable, or a value that
|
|
108
|
+
* `mark` makes mutable, throws unless the read happens inside `unsafe()`.
|
|
109
|
+
* A value returned with `rawReturn()` is still searched for drafts, which
|
|
110
|
+
* development builds report with a warning. Development builds also warn
|
|
111
|
+
* once when a recipe leaves 1,000 or more drafts unchanged.
|
|
112
|
+
*/
|
|
113
|
+
strict?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Generate patches: the result is then
|
|
116
|
+
* `[state, patches, inversePatches]`.
|
|
117
|
+
*/
|
|
118
|
+
enablePatches?: O;
|
|
119
|
+
/**
|
|
120
|
+
* Freeze the next state deeply, also the parts that it shares with the base
|
|
121
|
+
* state. Development builds also throw for an object that holds itself.
|
|
122
|
+
*/
|
|
123
|
+
enableAutoFreeze?: F;
|
|
124
|
+
/**
|
|
125
|
+
* Decide how values are drafted: a mark returns `immutable` to make a value
|
|
126
|
+
* draftable, such as a class instance, `mutable` to keep it out of drafts so
|
|
127
|
+
* that the recipe changes it in place, or a function that returns a shallow
|
|
128
|
+
* copy of the value, which needs patches and auto-freeze off. With several
|
|
129
|
+
* marks, the first one that returns a value decides.
|
|
130
|
+
*/
|
|
131
|
+
mark?: Mark<O, F>;
|
|
132
|
+
}
|
|
133
|
+
export interface ExternalOptions<O extends PatchesOptions, F extends boolean> {
|
|
134
|
+
/**
|
|
135
|
+
* In strict mode, reading an object that cannot be drafted from a draft,
|
|
136
|
+
* such as a class instance that no mark makes draftable, or a value that
|
|
137
|
+
* `mark` makes mutable, throws unless the read happens inside `unsafe()`.
|
|
138
|
+
* A value returned with `rawReturn()` is still searched for drafts, which
|
|
139
|
+
* development builds report with a warning. Development builds also warn
|
|
140
|
+
* once when a recipe leaves 1,000 or more drafts unchanged.
|
|
141
|
+
*/
|
|
142
|
+
strict?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Generate patches: the result is then
|
|
145
|
+
* `[state, patches, inversePatches]`.
|
|
146
|
+
*/
|
|
147
|
+
enablePatches?: O;
|
|
148
|
+
/**
|
|
149
|
+
* Freeze the next state deeply, also the parts that it shares with the base
|
|
150
|
+
* state. Development builds also throw for an object that holds itself.
|
|
151
|
+
*/
|
|
152
|
+
enableAutoFreeze?: F;
|
|
153
|
+
/**
|
|
154
|
+
* Decide how values are drafted: a mark returns `immutable` to make a value
|
|
155
|
+
* draftable, such as a class instance, `mutable` to keep it out of drafts so
|
|
156
|
+
* that the recipe changes it in place, or a function that returns a shallow
|
|
157
|
+
* copy of the value, which needs patches and auto-freeze off. With several
|
|
158
|
+
* marks, the first one that returns a value decides.
|
|
159
|
+
*/
|
|
160
|
+
mark?: Mark<O, F>[] | Mark<O, F>;
|
|
161
|
+
}
|
|
162
|
+
type Primitive = string | number | bigint | boolean | null | undefined;
|
|
163
|
+
type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
164
|
+
type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
165
|
+
type ImmutableObject<T> = {
|
|
166
|
+
readonly [K in keyof T]: Immutable<T[K]>;
|
|
167
|
+
};
|
|
168
|
+
export type IfAvailable<T, Fallback = void> = true | false extends (T extends never ? true : false) ? Fallback : keyof T extends never ? Fallback : T;
|
|
169
|
+
type WeakReferences = IfAvailable<WeakMap<any, any>> | IfAvailable<WeakSet<any>>;
|
|
170
|
+
type AtomicObject = Function | Promise<any> | Date | RegExp;
|
|
171
|
+
/**
|
|
172
|
+
* A deeply readonly `T`, the type of a state that `enableAutoFreeze` freezes:
|
|
173
|
+
* Maps and Sets become `ReadonlyMap` and `ReadonlySet`, and functions,
|
|
174
|
+
* Promises, dates and regular expressions keep their types.
|
|
175
|
+
*/
|
|
176
|
+
export type Immutable<T> = T extends Primitive | AtomicObject ? T : T extends IfAvailable<ReadonlyMap<infer K, infer V>> ? ImmutableMap<K, V> : T extends IfAvailable<ReadonlySet<infer V>> ? ImmutableSet<V> : T extends WeakReferences ? T : T extends object ? ImmutableObject<T> : T;
|
|
177
|
+
type DraftedMap<K, V> = Map<K, Draft<V>>;
|
|
178
|
+
type DraftedSet<T> = Set<Draft<T>>;
|
|
179
|
+
/**
|
|
180
|
+
* The draft of an object type: writable properties whose values are drafts.
|
|
181
|
+
*/
|
|
182
|
+
export type DraftedObject<T> = {
|
|
183
|
+
-readonly [K in keyof T]: Draft<T[K]>;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* The type of a draft of `T`: its objects, arrays, Maps and Sets without
|
|
187
|
+
* `readonly`, deeply, so that a recipe can change them. Functions, Promises,
|
|
188
|
+
* dates and regular expressions keep their types.
|
|
189
|
+
*/
|
|
190
|
+
export type Draft<T> = T extends Primitive | AtomicObject ? T : T extends IfAvailable<ReadonlyMap<infer K, infer V>> ? DraftedMap<K, V> : T extends IfAvailable<ReadonlySet<infer V>> ? DraftedSet<V> : T extends WeakReferences ? T : T extends object ? DraftedObject<T> : T;
|
|
191
|
+
export type ApplyImmutableOptions<F extends boolean> = Pick<Options<boolean, F>, Exclude<keyof Options<boolean, F>, 'enablePatches'>> & {
|
|
192
|
+
mutable?: false;
|
|
193
|
+
};
|
|
194
|
+
export type ApplyOptions<F extends boolean> = ApplyImmutableOptions<F> | ApplyMutableOptions;
|
|
195
|
+
type ApplyFrozenState<T, F> = F extends true ? Immutable<T> : T;
|
|
196
|
+
type ApplyState<T, F extends boolean, A> = F extends true ? Immutable<T> : 'enableAutoFreeze' extends keyof A ? ApplyFrozenState<T, A['enableAutoFreeze']> : T;
|
|
197
|
+
export type ApplyResult<T extends object, F extends boolean = false, A extends ApplyOptions<boolean> | undefined = ApplyImmutableOptions<F>> = A extends {
|
|
198
|
+
mutable: true;
|
|
199
|
+
} ? void : 'mutable' extends keyof A ? true extends A['mutable'] ? ApplyState<T, F, A> | void : ApplyState<T, F, A> : ApplyState<T, F, A>;
|
|
200
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CreateResult, Draft, ExternalOptions, PatchesOptions, Result } from './interface';
|
|
2
|
+
type ExplicitState<T> = [T][T extends any ? 0 : never];
|
|
3
|
+
type ExplicitReturn<T> = void | ExplicitState<T> | Draft<ExplicitState<T>>;
|
|
4
|
+
type AsyncRecipeContext<T> = Promise<ExplicitReturn<T>> & {
|
|
5
|
+
readonly __mutativeAsyncContext: never;
|
|
6
|
+
};
|
|
7
|
+
type IsExplicitPrimitive<T> = [ExplicitState<T>] extends [
|
|
8
|
+
string | number | bigint | boolean | symbol | null | undefined
|
|
9
|
+
] ? true : false;
|
|
10
|
+
type ExplicitSyncReturn<T> = IsExplicitPrimitive<T> extends true ? AsyncRecipeContext<T> : ExplicitReturn<T> | AsyncRecipeContext<T>;
|
|
11
|
+
type ExplicitRecipe<T, P extends any[], R> = [T] extends [never] ? never : (draft: Draft<ExplicitState<T>>, ...args: P) => R;
|
|
12
|
+
type ExplicitPrimitiveRecipe<T, P extends any[]> = IsExplicitPrimitive<T> extends true ? ExplicitRecipe<T, P, ExplicitReturn<T>> : never;
|
|
13
|
+
/** @inline */ type MakeCreator = <_F extends boolean = false, _O extends PatchesOptions = false>(options?: ExternalOptions<_O, _F>) => {
|
|
14
|
+
<T = never, F extends boolean = _F, O extends PatchesOptions = _O>(base: ExplicitState<T>, mutate: ExplicitRecipe<T, [], ExplicitSyncReturn<T>>, options?: ExternalOptions<O, F>): Result<ExplicitState<T>, O, F>;
|
|
15
|
+
<T = never, F extends boolean = _F, O extends PatchesOptions = _O>(base: ExplicitState<T>, mutate: ExplicitRecipe<T, [], Promise<ExplicitReturn<T>>>, options?: ExternalOptions<O, F>): Promise<Result<ExplicitState<T>, O, F>>;
|
|
16
|
+
<T = never, F extends boolean = _F, O extends PatchesOptions = _O>(base: ExplicitState<T>, mutate: ExplicitPrimitiveRecipe<T, []>, options?: ExternalOptions<O, F>): Result<ExplicitState<T>, O, F>;
|
|
17
|
+
<T = never, F extends boolean = _F, O extends PatchesOptions = _O>(base: ExplicitState<T>, mutate: ExplicitRecipe<T, [
|
|
18
|
+
], ExplicitReturn<T> | Promise<ExplicitReturn<T>>>, options?: ExternalOptions<O, F>): Result<ExplicitState<T>, O, F> | Promise<Result<ExplicitState<T>, O, F>>;
|
|
19
|
+
<T extends any, F extends boolean = _F, O extends PatchesOptions = _O, R extends void | Promise<void> | T | Promise<T> = void>(base: T, mutate: (draft: Draft<T>) => R, options?: ExternalOptions<O, F>): CreateResult<T, O, F, R>;
|
|
20
|
+
<T extends any, F extends boolean = _F, O extends PatchesOptions = _O, R extends void | Promise<void> = void>(base: T, mutate: (draft: T) => R, options?: ExternalOptions<O, F>): CreateResult<T, O, F, R>;
|
|
21
|
+
<T = never, P extends any[] = [], F extends boolean = _F, O extends PatchesOptions = _O>(mutate: ExplicitRecipe<T, P, ExplicitSyncReturn<T>>, options?: ExternalOptions<O, F>): (base: ExplicitState<T>, ...args: P) => Result<ExplicitState<T>, O, F>;
|
|
22
|
+
<T = never, P extends any[] = [], F extends boolean = _F, O extends PatchesOptions = _O>(mutate: ExplicitRecipe<T, P, Promise<ExplicitReturn<T>>>, options?: ExternalOptions<O, F>): (base: ExplicitState<T>, ...args: P) => Promise<Result<ExplicitState<T>, O, F>>;
|
|
23
|
+
<T = never, P extends any[] = [], F extends boolean = _F, O extends PatchesOptions = _O>(mutate: ExplicitPrimitiveRecipe<T, P>, options?: ExternalOptions<O, F>): (base: ExplicitState<T>, ...args: P) => Result<ExplicitState<T>, O, F>;
|
|
24
|
+
<T = never, P extends any[] = [], F extends boolean = _F, O extends PatchesOptions = _O>(mutate: ExplicitRecipe<T, P, ExplicitReturn<T> | Promise<ExplicitReturn<T>>>, options?: ExternalOptions<O, F>): (base: ExplicitState<T>, ...args: P) => Result<ExplicitState<T>, O, F> | Promise<Result<ExplicitState<T>, O, F>>;
|
|
25
|
+
<T extends any, P extends any[] = [], F extends boolean = _F, O extends PatchesOptions = _O, R extends void | Promise<void> | T | Promise<T> = void>(mutate: (draft: Draft<T>, ...args: P) => R, options?: ExternalOptions<O, F>): (base: T, ...args: P) => CreateResult<T, O, F, R>;
|
|
26
|
+
<T extends any, P extends any[] = [], F extends boolean = _F, O extends PatchesOptions = _O, R extends void | Promise<void> | T | Promise<T> = void>(mutate: (draft: T, ...args: P) => R, options?: ExternalOptions<O, F>): (base: T, ...args: P) => CreateResult<T, O, F, R>;
|
|
27
|
+
<T extends any, O extends PatchesOptions = _O, F extends boolean = _F>(base: T, options?: ExternalOptions<O, F>): [Draft<T>, () => Result<T, O, F>];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* `makeCreator(options)` to make a creator function.
|
|
31
|
+
*
|
|
32
|
+
* ## Example
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { makeCreator } from 'mutative';
|
|
36
|
+
*
|
|
37
|
+
* const baseState = { foo: { bar: 'str' }, arr: [] };
|
|
38
|
+
* const create = makeCreator({ enableAutoFreeze: true });
|
|
39
|
+
* const state = create(
|
|
40
|
+
* baseState,
|
|
41
|
+
* (draft) => {
|
|
42
|
+
* draft.foo.bar = 'str2';
|
|
43
|
+
* },
|
|
44
|
+
* );
|
|
45
|
+
*
|
|
46
|
+
* expect(state).toEqual({ foo: { bar: 'str2' }, arr: [] });
|
|
47
|
+
* expect(state).not.toBe(baseState);
|
|
48
|
+
* expect(state.foo).not.toBe(baseState.foo);
|
|
49
|
+
* expect(state.arr).toBe(baseState.arr);
|
|
50
|
+
* expect(Object.isFrozen(state)).toBeTruthy();
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const makeCreator: MakeCreator;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { iteratorSymbol } from './constant';
|
|
2
|
+
export declare const mapHandler: {
|
|
3
|
+
readonly size: number;
|
|
4
|
+
has(key: any): boolean;
|
|
5
|
+
set(key: any, value: any): /*elided*/ any;
|
|
6
|
+
delete(key: any): boolean;
|
|
7
|
+
clear(): void;
|
|
8
|
+
forEach(callback: (value: any, key: any, self: any) => void, thisArg?: any): void;
|
|
9
|
+
get(key: any): any;
|
|
10
|
+
keys(): IterableIterator<any>;
|
|
11
|
+
values(): IterableIterator<any>;
|
|
12
|
+
entries(): IterableIterator<[any, any]>;
|
|
13
|
+
[Symbol.iterator](): IterableIterator<[any, any]>;
|
|
14
|
+
};
|
|
15
|
+
export declare const mapHandlerKeys: (string | symbol)[];
|