@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,189 @@
|
|
|
1
|
+
import { DraftType, Finalities, Mark, ProxyDraft } from '../interface';
|
|
2
|
+
import { dataTypes, PROXY_DRAFT } from '../constant';
|
|
3
|
+
|
|
4
|
+
export function latest<T = any>(proxyDraft: ProxyDraft): T {
|
|
5
|
+
return proxyDraft.copy ?? proxyDraft.original;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// The drafts of a Set draft's items and the objects it added; see `src/set.ts`.
|
|
9
|
+
export function getSetMap(target: ProxyDraft): Map<any, any> {
|
|
10
|
+
return target.setMap || (target.setMap = new Map());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// The value that an item of a Set draft stands for; `setMap` holds no
|
|
14
|
+
// `undefined` value.
|
|
15
|
+
export function setItemValue(target: ProxyDraft, item: any) {
|
|
16
|
+
const value = target.setMap && target.setMap.get(item);
|
|
17
|
+
return value === undefined ? item : value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const setValues = Set.prototype.values;
|
|
21
|
+
|
|
22
|
+
// The items of a Set in the order in which it holds them, also for a subclass
|
|
23
|
+
// that iterates them otherwise, so that the positions in patch paths are those
|
|
24
|
+
// that the draft iterates. A draft of an outer producer iterates them so
|
|
25
|
+
// itself.
|
|
26
|
+
export function iterateSet(set: Set<any>): IterableIterator<any> {
|
|
27
|
+
return isDraft(set) ? set.values() : setValues.call(set);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Check if the value is a draft
|
|
32
|
+
*/
|
|
33
|
+
export function isDraft(target: any) {
|
|
34
|
+
return !!getProxyDraft(target);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getProxyDraft<T extends any>(value: T): ProxyDraft | null {
|
|
38
|
+
if (typeof value !== 'object') return null;
|
|
39
|
+
return (value as { [PROXY_DRAFT]: any })?.[PROXY_DRAFT];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Iterators retain draft state instead of reading through the proxy. Once
|
|
43
|
+
// its scope has been revoked, use the proxy to throw the same native error.
|
|
44
|
+
export function assertDraftActive(target: ProxyDraft) {
|
|
45
|
+
if (target.finalities.revoke.length === 0) getProxyDraft(target.proxy);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getValue<T extends object>(value: T): T {
|
|
49
|
+
const proxyDraft = getProxyDraft(value);
|
|
50
|
+
if (!proxyDraft) return value;
|
|
51
|
+
// A copy also exists once a child has merely been read; an unchanged draft
|
|
52
|
+
// still stands for its original, as every other finalization path decides.
|
|
53
|
+
return proxyDraft.operated ? proxyDraft.copy! : proxyDraft.original;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Check if a value is draftable
|
|
58
|
+
*/
|
|
59
|
+
export function isDraftable(value: any, options?: { mark?: Mark<any, any> }) {
|
|
60
|
+
if (!value || typeof value !== 'object') return false;
|
|
61
|
+
let markResult: any;
|
|
62
|
+
return (
|
|
63
|
+
Object.getPrototypeOf(value) === Object.prototype ||
|
|
64
|
+
Array.isArray(value) ||
|
|
65
|
+
value instanceof Map ||
|
|
66
|
+
value instanceof Set ||
|
|
67
|
+
(!!options?.mark &&
|
|
68
|
+
((markResult = options.mark(value, dataTypes)) === dataTypes.immutable ||
|
|
69
|
+
typeof markResult === 'function'))
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// A string path holds only strings, so a Map key of another type or a symbol
|
|
74
|
+
// key would name a different key when the patch is applied. Development
|
|
75
|
+
// builds check the keys of the patch paths they generate.
|
|
76
|
+
export function checkPathKey(
|
|
77
|
+
type: DraftType,
|
|
78
|
+
key: unknown,
|
|
79
|
+
pathAsArray: boolean | undefined
|
|
80
|
+
) {
|
|
81
|
+
if (
|
|
82
|
+
pathAsArray === false &&
|
|
83
|
+
typeof key !== 'string' &&
|
|
84
|
+
(type === DraftType.Map || typeof key === 'symbol')
|
|
85
|
+
) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Patches with string paths only support string Map keys and no symbol keys, got a key of type '${typeof key}'. Set 'pathAsArray' to true to keep keys of other types.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function getPath(
|
|
93
|
+
target: ProxyDraft,
|
|
94
|
+
path: any[] = []
|
|
95
|
+
): (string | number | object)[] | null {
|
|
96
|
+
const parent = target.parent;
|
|
97
|
+
if (parent) {
|
|
98
|
+
const parentCopy = parent.copy;
|
|
99
|
+
let key: any = target.key;
|
|
100
|
+
if (parent.type === DraftType.Set) {
|
|
101
|
+
// Set items are keyed by their original value; paths use positions,
|
|
102
|
+
// which patches can follow only while the Set itself is unchanged.
|
|
103
|
+
// Once the recipe added or removed items, the Set's own patches carry
|
|
104
|
+
// every changed item by value, so patches under this path would be
|
|
105
|
+
// applied to whatever sits at the position in the base Set. An
|
|
106
|
+
// unchanged Set holds its items in their original order.
|
|
107
|
+
if (parent.assignedMap!.size > 0) return null;
|
|
108
|
+
// Counted without copying the Set, as each changed item searches it.
|
|
109
|
+
let index = 0;
|
|
110
|
+
for (const item of iterateSet(parent.original)) {
|
|
111
|
+
if (item === key) break;
|
|
112
|
+
index += 1;
|
|
113
|
+
}
|
|
114
|
+
key = index;
|
|
115
|
+
} else if (get(parentCopy, key) !== target.proxy) {
|
|
116
|
+
// The child left its key: it was moved, deleted or replaced, possibly
|
|
117
|
+
// by another draft of a shared object. The parent's patches carry its
|
|
118
|
+
// value wherever it is now, so patches under this path would be stale.
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
path.push(key);
|
|
122
|
+
const resolved = getPath(parent, path);
|
|
123
|
+
// Checked once the path resolves, as a stale path emits no patches.
|
|
124
|
+
if (__DEV__ && resolved) {
|
|
125
|
+
checkPathKey(parent.type, key, parent.options.enablePatches.pathAsArray);
|
|
126
|
+
}
|
|
127
|
+
return resolved;
|
|
128
|
+
}
|
|
129
|
+
// `target` is the root draft. Every level above found its child at its
|
|
130
|
+
// key, so the path resolves in the root's copy.
|
|
131
|
+
path.reverse();
|
|
132
|
+
return path;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function getType(target: any) {
|
|
136
|
+
if (Array.isArray(target)) return DraftType.Array;
|
|
137
|
+
if (target instanceof Map) return DraftType.Map;
|
|
138
|
+
if (target instanceof Set) return DraftType.Set;
|
|
139
|
+
return DraftType.Object;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function get(target: any, key: PropertyKey) {
|
|
143
|
+
return getType(target) === DraftType.Map ? target.get(key) : target[key];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function set(target: any, key: PropertyKey, value: any) {
|
|
147
|
+
const type = getType(target);
|
|
148
|
+
if (type === DraftType.Map) {
|
|
149
|
+
target.set(key, value);
|
|
150
|
+
} else {
|
|
151
|
+
target[key] = value;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function isEqual(x: any, y: any) {
|
|
156
|
+
if (x === y) {
|
|
157
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
158
|
+
} else {
|
|
159
|
+
return x !== x && y !== y;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Revokes every draft of a producer without reading any of them.
|
|
164
|
+
export function revokeProxy(finalities: Finalities) {
|
|
165
|
+
const revoke = finalities.revoke;
|
|
166
|
+
while (revoke.length > 0) revoke.pop()!();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// handle JSON Pointer path with spec https://www.rfc-editor.org/rfc/rfc6901
|
|
170
|
+
export function escapePath(path: string[], pathAsArray: boolean) {
|
|
171
|
+
return pathAsArray
|
|
172
|
+
? path
|
|
173
|
+
: ['']
|
|
174
|
+
.concat(path)
|
|
175
|
+
.map((_item) => {
|
|
176
|
+
const item = `${_item}`;
|
|
177
|
+
if (item.indexOf('/') === -1 && item.indexOf('~') === -1) return item;
|
|
178
|
+
return item.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
179
|
+
})
|
|
180
|
+
.join('/');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function unescapePath(path: string | (string | number)[]) {
|
|
184
|
+
if (Array.isArray(path)) return path;
|
|
185
|
+
return path
|
|
186
|
+
.split('/')
|
|
187
|
+
.map((_item) => _item.replace(/~1/g, '/').replace(/~0/g, '~'))
|
|
188
|
+
.slice(1);
|
|
189
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { DraftType, Patches, ProxyDraft } from '../interface';
|
|
2
|
+
import {
|
|
3
|
+
get,
|
|
4
|
+
getPath,
|
|
5
|
+
getProxyDraft,
|
|
6
|
+
getValue,
|
|
7
|
+
isDraft,
|
|
8
|
+
isDraftable,
|
|
9
|
+
isEqual,
|
|
10
|
+
iterateSet,
|
|
11
|
+
set,
|
|
12
|
+
} from './draft';
|
|
13
|
+
import { forEach } from './forEach';
|
|
14
|
+
|
|
15
|
+
export function handleValue(
|
|
16
|
+
target: any,
|
|
17
|
+
handledSet: WeakSet<any>,
|
|
18
|
+
options?: ProxyDraft['options']
|
|
19
|
+
) {
|
|
20
|
+
if (
|
|
21
|
+
isDraft(target) ||
|
|
22
|
+
!isDraftable(target, options) ||
|
|
23
|
+
handledSet.has(target) ||
|
|
24
|
+
Object.isFrozen(target)
|
|
25
|
+
)
|
|
26
|
+
return;
|
|
27
|
+
const isSet = target instanceof Set;
|
|
28
|
+
const setMap: Map<any, any> | undefined = isSet ? new Map() : undefined;
|
|
29
|
+
handledSet.add(target);
|
|
30
|
+
forEach(target, (key, value) => {
|
|
31
|
+
if (isDraft(value)) {
|
|
32
|
+
const proxyDraft = getProxyDraft(value)!;
|
|
33
|
+
// A draft where a child node has been changed, or assigned a value
|
|
34
|
+
const updatedValue =
|
|
35
|
+
proxyDraft.assignedMap?.size || proxyDraft.operated
|
|
36
|
+
? proxyDraft.copy
|
|
37
|
+
: proxyDraft.original;
|
|
38
|
+
// final update value
|
|
39
|
+
set(isSet ? setMap! : target, key, updatedValue);
|
|
40
|
+
} else {
|
|
41
|
+
handleValue(value, handledSet, options);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (setMap) {
|
|
45
|
+
const set = target as Set<any>;
|
|
46
|
+
const values = Array.from(set);
|
|
47
|
+
set.clear();
|
|
48
|
+
values.forEach((value) => {
|
|
49
|
+
set.add(setMap!.has(value) ? setMap!.get(value) : value);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function finalizeAssigned(proxyDraft: ProxyDraft, key: PropertyKey) {
|
|
55
|
+
// handle the draftable assigned values, and the value is not a draft
|
|
56
|
+
const copy =
|
|
57
|
+
proxyDraft.type === DraftType.Set ? proxyDraft.setMap : proxyDraft.copy;
|
|
58
|
+
if (
|
|
59
|
+
proxyDraft.finalities.revoke.length > 1 &&
|
|
60
|
+
proxyDraft.assignedMap!.get(key) &&
|
|
61
|
+
copy
|
|
62
|
+
) {
|
|
63
|
+
handleValue(
|
|
64
|
+
get(copy, key),
|
|
65
|
+
proxyDraft.finalities.handledSet,
|
|
66
|
+
proxyDraft.options
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type GeneratePatches = (
|
|
72
|
+
proxyState: ProxyDraft,
|
|
73
|
+
basePath: any[],
|
|
74
|
+
patches: Patches,
|
|
75
|
+
inversePatches: Patches
|
|
76
|
+
) => void;
|
|
77
|
+
|
|
78
|
+
// The copy of a Set draft holds its items in order, so only items that a draft
|
|
79
|
+
// stands for may need their final value: the Set is rebuilt in order once one
|
|
80
|
+
// of them differs from the item itself. The first rebuild keeps the items on
|
|
81
|
+
// `setMap`. With `again`, only a Set rebuilt before is rebuilt, for a draft of
|
|
82
|
+
// an outer producer that a nested producer's Set holds; other Sets may still
|
|
83
|
+
// be changing, and are rebuilt when their own producer finalizes them.
|
|
84
|
+
export function finalizeSetValue(target: ProxyDraft, again?: boolean) {
|
|
85
|
+
// Only Set drafts have `setMap`, and an unchanged draft stands for its
|
|
86
|
+
// original.
|
|
87
|
+
const setMap = target.setMap;
|
|
88
|
+
if (!setMap || !target.operated) return;
|
|
89
|
+
let items = setMap.items;
|
|
90
|
+
if (!items) {
|
|
91
|
+
if (again) return;
|
|
92
|
+
// Without added or deleted items, an item that the Set drafted changed,
|
|
93
|
+
// unless the recipe added and deleted a draft; rebuilding then changes
|
|
94
|
+
// nothing.
|
|
95
|
+
let differs = target.assignedMap!.size === 0;
|
|
96
|
+
if (!differs) {
|
|
97
|
+
for (const [item, value] of setMap) {
|
|
98
|
+
if (getValue(value) !== item) {
|
|
99
|
+
differs = true;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!differs) return;
|
|
105
|
+
items = setMap.items = Array.from(iterateSet(target.copy));
|
|
106
|
+
}
|
|
107
|
+
const copy: Set<any> = target.copy;
|
|
108
|
+
copy.clear();
|
|
109
|
+
items.forEach((item) => {
|
|
110
|
+
const value = setMap.get(item);
|
|
111
|
+
copy.add(value === undefined ? item : getValue(value));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function finalizePatches(
|
|
116
|
+
target: ProxyDraft,
|
|
117
|
+
generatePatches: GeneratePatches,
|
|
118
|
+
patches?: Patches,
|
|
119
|
+
inversePatches?: Patches
|
|
120
|
+
) {
|
|
121
|
+
const shouldFinalize =
|
|
122
|
+
target.operated &&
|
|
123
|
+
((target.arrayState !== null && target.arrayState.relocated) ||
|
|
124
|
+
(target.assignedMap !== undefined && target.assignedMap.size > 0)) &&
|
|
125
|
+
!target.finalized;
|
|
126
|
+
if (shouldFinalize) {
|
|
127
|
+
if (patches && inversePatches) {
|
|
128
|
+
const basePath = getPath(target);
|
|
129
|
+
if (basePath) {
|
|
130
|
+
generatePatches(target, basePath, patches, inversePatches);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
target.finalized = true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Finalize one draft node: write the final value back into the parent's copy,
|
|
139
|
+
* generate its patches and run callbacks registered for it, for example
|
|
140
|
+
* because it was assigned to another location.
|
|
141
|
+
*/
|
|
142
|
+
export function finalizeNode(
|
|
143
|
+
node: ProxyDraft,
|
|
144
|
+
generatePatches: GeneratePatches,
|
|
145
|
+
patches?: Patches,
|
|
146
|
+
inversePatches?: Patches
|
|
147
|
+
) {
|
|
148
|
+
const parent = node.parent;
|
|
149
|
+
if (parent) {
|
|
150
|
+
const parentType = parent.type;
|
|
151
|
+
// if the parent is a Set draft, `setMap` is the real Set copies proxy mapping.
|
|
152
|
+
const copy = parentType === DraftType.Set ? parent.setMap : parent.copy;
|
|
153
|
+
const key = node.key!;
|
|
154
|
+
const isMapLike =
|
|
155
|
+
parentType === DraftType.Set || parentType === DraftType.Map;
|
|
156
|
+
const draft = isMapLike ? copy.get(key) : copy[key];
|
|
157
|
+
// Fast path: the node is still at its own key. Otherwise another draft
|
|
158
|
+
// may have been moved here, e.g. by `reverse()`, and is finalized instead.
|
|
159
|
+
const proxyDraft = draft === node.proxy ? node : getProxyDraft(draft);
|
|
160
|
+
// A draft that left its key reaches its new place as a value, through a
|
|
161
|
+
// callback or a value assigned there, so a Set finalizes its items here.
|
|
162
|
+
if (proxyDraft !== node) finalizeSetValue(node);
|
|
163
|
+
if (proxyDraft) {
|
|
164
|
+
// assign the updated value to the copy object
|
|
165
|
+
const updatedValue = proxyDraft.operated
|
|
166
|
+
? proxyDraft.copy
|
|
167
|
+
: proxyDraft.original;
|
|
168
|
+
// A draft of another producer, which a recipe placed here, is
|
|
169
|
+
// finalized by that producer.
|
|
170
|
+
if (proxyDraft.finalities === node.finalities)
|
|
171
|
+
finalizeSetValue(proxyDraft);
|
|
172
|
+
finalizePatches(proxyDraft, generatePatches, patches, inversePatches);
|
|
173
|
+
// final update value
|
|
174
|
+
if (isMapLike) {
|
|
175
|
+
copy.set(key, updatedValue);
|
|
176
|
+
} else {
|
|
177
|
+
copy[key] = updatedValue;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
// !case: handle the root draft
|
|
182
|
+
finalizeSetValue(node);
|
|
183
|
+
finalizePatches(node, generatePatches, patches, inversePatches);
|
|
184
|
+
}
|
|
185
|
+
// !case: handle the deleted key
|
|
186
|
+
const callbacks = node.callbacks;
|
|
187
|
+
if (callbacks) {
|
|
188
|
+
for (let index = 0; index < callbacks.length; index += 1) {
|
|
189
|
+
callbacks[index](patches, inversePatches);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function markFinalization(target: ProxyDraft, key: any, value: any) {
|
|
195
|
+
const proxyDraft = getProxyDraft(value);
|
|
196
|
+
if (proxyDraft) {
|
|
197
|
+
// !case: assign the draft value
|
|
198
|
+
if (!proxyDraft.callbacks) {
|
|
199
|
+
proxyDraft.callbacks = [];
|
|
200
|
+
}
|
|
201
|
+
proxyDraft.callbacks.push(() => {
|
|
202
|
+
const copy = target.type === DraftType.Set ? target.setMap : target.copy;
|
|
203
|
+
if (isEqual(get(copy, key), value)) {
|
|
204
|
+
// The target generates its own patches once all drafts it holds have
|
|
205
|
+
// been finalized, so its patch values never need deep cloning.
|
|
206
|
+
const updatedValue = proxyDraft.operated
|
|
207
|
+
? proxyDraft.copy
|
|
208
|
+
: proxyDraft.original;
|
|
209
|
+
// The drafts of a Set's own producer are done changing when it rebuilds
|
|
210
|
+
// the Set; a draft of another producer may change after that.
|
|
211
|
+
if (proxyDraft.finalities !== target.finalities)
|
|
212
|
+
finalizeSetValue(target, true);
|
|
213
|
+
// final update value
|
|
214
|
+
set(copy, key, updatedValue);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
if (target.options.enableAutoFreeze) {
|
|
218
|
+
// !case: assign the draft value in cross draft tree
|
|
219
|
+
if (proxyDraft.finalities !== target.finalities) {
|
|
220
|
+
target.options.enableAutoFreeze = false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} else if (isDraftable(value, target.options)) {
|
|
224
|
+
// !case: assign the non-draft value
|
|
225
|
+
target.finalities.draft.push(() => {
|
|
226
|
+
const copy = target.type === DraftType.Set ? target.setMap : target.copy;
|
|
227
|
+
if (isEqual(get(copy, key), value)) {
|
|
228
|
+
finalizeAssigned(target, key);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DraftType } from '../interface';
|
|
2
|
+
import { getType } from './draft';
|
|
3
|
+
|
|
4
|
+
export function forEach<T extends object>(
|
|
5
|
+
target: T,
|
|
6
|
+
iter: (key: string | number | symbol, value: any, source: T) => void
|
|
7
|
+
) {
|
|
8
|
+
const type = getType(target);
|
|
9
|
+
if (type === DraftType.Object) {
|
|
10
|
+
Reflect.ownKeys(target).forEach((key) => {
|
|
11
|
+
iter(key, (target as any)[key], target);
|
|
12
|
+
});
|
|
13
|
+
} else if (type === DraftType.Array) {
|
|
14
|
+
let index = 0;
|
|
15
|
+
for (const entry of target as any[]) {
|
|
16
|
+
iter(index, entry, target);
|
|
17
|
+
index += 1;
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
(target as Map<any, any> | Set<any>).forEach((entry: any, index: any) =>
|
|
21
|
+
iter(index, entry, target)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProxyDraft } from '../interface';
|
|
2
|
+
|
|
3
|
+
export function markChanged(proxyDraft: ProxyDraft) {
|
|
4
|
+
proxyDraft.assignedMap = proxyDraft.assignedMap ?? new Map();
|
|
5
|
+
if (!proxyDraft.operated) {
|
|
6
|
+
proxyDraft.operated = true;
|
|
7
|
+
if (proxyDraft.parent) {
|
|
8
|
+
markChanged(proxyDraft.parent);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { dataTypes } from '../constant';
|
|
2
|
+
|
|
3
|
+
const constructorString = Object.prototype.constructor.toString();
|
|
4
|
+
// Whether a value is a plain object, an object without a prototype, or a plain
|
|
5
|
+
// object of another realm, such as a same-origin iframe, whose constructor is
|
|
6
|
+
// that realm's `Object`.
|
|
7
|
+
const isSimpleObject = (value: unknown) => {
|
|
8
|
+
if (!value || typeof value !== 'object') return false;
|
|
9
|
+
const prototype = Object.getPrototypeOf(value);
|
|
10
|
+
if (prototype === null) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const constructor =
|
|
14
|
+
Object.hasOwnProperty.call(prototype, 'constructor') &&
|
|
15
|
+
prototype.constructor;
|
|
16
|
+
|
|
17
|
+
if (constructor === Object) return true;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
typeof constructor === 'function' &&
|
|
21
|
+
Function.toString.call(constructor) === constructorString
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A `mark` that drafts plain objects, objects without a prototype and plain
|
|
27
|
+
* objects of other realms, such as same-origin iframes.
|
|
28
|
+
*/
|
|
29
|
+
export const markSimpleObject = (value: unknown) => {
|
|
30
|
+
if (isSimpleObject(value)) {
|
|
31
|
+
return dataTypes.immutable;
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function has(target: object, key: PropertyKey) {
|
|
2
|
+
return target instanceof Map
|
|
3
|
+
? target.has(key)
|
|
4
|
+
: Object.prototype.hasOwnProperty.call(target, key);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getDescriptor(target: object, key: PropertyKey) {
|
|
8
|
+
if (key in target) {
|
|
9
|
+
let prototype = Reflect.getPrototypeOf(target);
|
|
10
|
+
while (prototype) {
|
|
11
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(prototype, key);
|
|
12
|
+
if (descriptor) return descriptor;
|
|
13
|
+
prototype = Reflect.getPrototypeOf(prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Whether `concat` and the array methods treat `array` like any array: no
|
|
21
|
+
* subclass, and no own `constructor` or `Symbol.isConcatSpreadable` that
|
|
22
|
+
* changes what `concat` creates.
|
|
23
|
+
*/
|
|
24
|
+
export function isPlainArray(array: any[]) {
|
|
25
|
+
return (
|
|
26
|
+
!Object.prototype.hasOwnProperty.call(array, 'constructor') &&
|
|
27
|
+
!Object.prototype.hasOwnProperty.call(array, Symbol.isConcatSpreadable) &&
|
|
28
|
+
Object.getPrototypeOf(array) === Array.prototype
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isBaseSetInstance(obj: any) {
|
|
33
|
+
return Object.getPrototypeOf(obj) === Set.prototype;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isBaseMapInstance(obj: any) {
|
|
37
|
+
return Object.getPrototypeOf(obj) === Map.prototype;
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|