create-atom.io 0.0.0 → 0.0.2
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/dist/{create-atom-BV6WVRvY.js → create-atom-DOkiQlT8.js} +27 -11
- package/dist/create-atom-DOkiQlT8.js.map +1 -0
- package/dist/create-atom.d.ts +5 -2
- package/dist/create-atom.d.ts.map +1 -1
- package/dist/create-atom.js +1 -1
- package/dist/create-atom.x.js +27 -31
- package/dist/create-atom.x.js.map +1 -1
- package/package.json +53 -55
- package/src/create-atom.ts +28 -5
- package/src/create-atom.x.ts +16 -19
- package/templates/{base → preact-svg-editor}/eslint.config.ts +4 -3
- package/templates/preact-svg-editor/eslint.d.ts +31 -0
- package/templates/preact-svg-editor/node_modules/.bin/vite +21 -0
- package/templates/{base → preact-svg-editor}/package.json +1 -1
- package/templates/{base → preact-svg-editor}/src/BezierPlayground.tsx +157 -147
- package/templates/{base → preact-svg-editor}/src/index.tsx +6 -4
- package/templates/{base → preact-svg-editor}/vite.config.ts +2 -1
- package/templates/react-node-backend/.turbo/turbo-build.log +12 -0
- package/templates/react-node-backend/README.md +75 -0
- package/templates/react-node-backend/_gitignore +24 -0
- package/templates/react-node-backend/dist/assets/index-6PkP9syN.js +9 -0
- package/templates/react-node-backend/dist/assets/index-By2j7w9s.css +1 -0
- package/templates/react-node-backend/dist/index.html +14 -0
- package/templates/react-node-backend/dist/react.svg +1 -0
- package/templates/react-node-backend/dist/vite.svg +1 -0
- package/templates/react-node-backend/eslint.config.ts +176 -0
- package/templates/react-node-backend/index.html +13 -0
- package/templates/react-node-backend/node/authenticator.ts +47 -0
- package/templates/react-node-backend/node/server.ts +103 -0
- package/templates/react-node-backend/node_modules/.bin/conc +21 -0
- package/templates/react-node-backend/node_modules/.bin/concurrently +21 -0
- package/templates/react-node-backend/node_modules/.bin/eslint +21 -0
- package/templates/react-node-backend/node_modules/.bin/tsc +21 -0
- package/templates/react-node-backend/node_modules/.bin/tsserver +21 -0
- package/templates/react-node-backend/node_modules/.bin/vite +21 -0
- package/templates/react-node-backend/package.json +33 -0
- package/templates/react-node-backend/public/react.svg +1 -0
- package/templates/react-node-backend/public/vite.svg +1 -0
- package/templates/react-node-backend/src/App.tsx +69 -0
- package/templates/react-node-backend/src/index.css +145 -0
- package/templates/react-node-backend/src/main.tsx +12 -0
- package/templates/react-node-backend/tsconfig.app.json +28 -0
- package/templates/react-node-backend/tsconfig.json +7 -0
- package/templates/react-node-backend/tsconfig.node.json +26 -0
- package/templates/react-node-backend/vite.config.ts +13 -0
- package/dist/create-atom-BV6WVRvY.js.map +0 -1
- package/templates/base/node_modules/.bin/browserslist +0 -21
- package/templates/base/node_modules/.bin/eslint +0 -21
- package/templates/base/node_modules/.bin/jiti +0 -21
- package/templates/base/node_modules/.bin/sass +0 -21
- package/templates/base/node_modules/.bin/terser +0 -21
- package/templates/base/node_modules/.bin/tsc +0 -21
- package/templates/base/node_modules/.bin/tsserver +0 -21
- package/templates/base/node_modules/.bin/vite +0 -21
- package/templates/base/node_modules/.bin/yaml +0 -21
- package/templates/base/node_modules/.vite/deps/_metadata.json +0 -82
- package/templates/base/node_modules/.vite/deps/atom__io.js +0 -72
- package/templates/base/node_modules/.vite/deps/atom__io.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/atom__io_react.js +0 -170
- package/templates/base/node_modules/.vite/deps/atom__io_react.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/chunk-2PJG54YB.js +0 -364
- package/templates/base/node_modules/.vite/deps/chunk-2PJG54YB.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/chunk-6VZTUEOV.js +0 -3777
- package/templates/base/node_modules/.vite/deps/chunk-6VZTUEOV.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/chunk-IHAFLL3M.js +0 -204
- package/templates/base/node_modules/.vite/deps/chunk-IHAFLL3M.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/chunk-LZJKCPXG.js +0 -84
- package/templates/base/node_modules/.vite/deps/chunk-LZJKCPXG.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/chunk-PJQAIOAR.js +0 -311
- package/templates/base/node_modules/.vite/deps/chunk-PJQAIOAR.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/chunk-XRJUZPUF.js +0 -17
- package/templates/base/node_modules/.vite/deps/chunk-XRJUZPUF.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/package.json +0 -3
- package/templates/base/node_modules/.vite/deps/preact.js +0 -27
- package/templates/base/node_modules/.vite/deps/preact.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/preact_compat.js +0 -100
- package/templates/base/node_modules/.vite/deps/preact_compat.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/preact_debug.js +0 -240
- package/templates/base/node_modules/.vite/deps/preact_debug.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/preact_devtools.js +0 -7
- package/templates/base/node_modules/.vite/deps/preact_devtools.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/preact_hooks.js +0 -29
- package/templates/base/node_modules/.vite/deps/preact_hooks.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/preact_jsx-dev-runtime.js +0 -18
- package/templates/base/node_modules/.vite/deps/preact_jsx-dev-runtime.js.map +0 -7
- package/templates/base/node_modules/.vite/deps/preact_jsx-runtime.js +0 -18
- package/templates/base/node_modules/.vite/deps/preact_jsx-runtime.js.map +0 -7
- /package/templates/{base → preact-svg-editor}/_gitignore +0 -0
- /package/templates/{base → preact-svg-editor}/index.html +0 -0
- /package/templates/{base → preact-svg-editor}/public/preact.svg +0 -0
- /package/templates/{base → preact-svg-editor}/src/msg.md +0 -0
- /package/templates/{base → preact-svg-editor}/src/style.css +0 -0
- /package/templates/{base → preact-svg-editor}/tsconfig.json +0 -0
- /package/templates/{base → react-node-backend}/eslint.d.ts +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/json/entries.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/json/index.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/struct/micro.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/transceivers/u-list/u-list.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/transceivers/u-list/u-list-disposed-key-cleanup-effect.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/arbitrary.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/lineage.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/is-fn.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/become.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/future.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/subject.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/store/circular-buffer.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/store/deposit.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/overlays/map-overlay.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/overlays/set-overlay.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/overlays/relations-overlay.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/junction.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/reserved-keys.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/abort-transaction.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/act-upon-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/events/ingest-atom-update.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/get-trace.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/molecule.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/events/ingest-creation-disposal.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/events/ingest-selector-update.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/events/ingest-transaction-update.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/is-root-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/get-epoch-number.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/set-epoch-number.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/apply-transaction.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/assign-transaction-to-continuity.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/get-environment-data.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/build-transaction.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/create-transaction.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/transaction/transaction-meta-progress.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/store/store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/not-found-error.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/store/withdraw.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/get-state/get-fallback.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/safe-compute.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/get-state/read-or-compute-value.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/get-family-of-token.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/mint-in-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/get-state/reduce-reference.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/get-state/get-from-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/seek-in-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/find-in-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/create-readonly-pure-selector-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/create-regular-atom-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/create-readonly-held-selector-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/create-writable-held-selector-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/create-writable-pure-selector-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/create-selector-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/families/dispose-from-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/operation.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/dispatch-state-update.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/set-atom.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/reset-atom-or-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/set-into-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/reset-in-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/set-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/set-atom-or-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/operate-on-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/keys.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/get-selector-dependency-keys.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/trace-selector-atoms.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/update-selector-atoms.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/register-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/create-readonly-held-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/create-readonly-pure-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/create-writable-held-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/create-writable-pure-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/create-standalone-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/selector/dispose-selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/subscribe/recall-state.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/subscribe/subscribe-to-root-atoms.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/subscribe/subscribe-to-state.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/subscribe/subscribe-to-timeline.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/subscribe/subscribe-to-transaction.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/subscribe/subscribe-in-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/tracker.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/create-mutable-atom.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/tracker-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/create-mutable-atom-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/get-json-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/get-json-token.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/get-update-family.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/get-update-token.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/mutable/transceiver.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/caching.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/set-state/evict-downstream.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/atom/create-regular-atom.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/atom/has-role.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/atom/dispose-atom.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/capitalize.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/install-into-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/join/join-internal.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/join/create-join.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/join/get-join.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/join/edit-relations-in-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/join/find-relations-in-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/join/get-internal-relations-from-store.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/timeline/create-timeline.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/internal/timeline/time-travel.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/atom.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/dispose-state.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/find-state.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/get-state.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/join.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/logger.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/realm.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/reset-state.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/selector.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/set-state.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/silo.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/subscribe.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/timeline.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/transaction.ts", "../../../../../../../node_modules/.pnpm/atom.io@0.44.0_@floating-ui+react-dom@2.1.6_@preact+compat@18.3.1_preact@10.27.2__@prea_a385030eab0fd5c9f5ef9e758818d457/node_modules/atom.io/src/main/validators.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Count, Flat } from \"atom.io/internal\"\n\n/** Tuples of `[key, value]` pairs, as returned from `Object.entries` */\nexport type Entries<K extends PropertyKey = PropertyKey, V = any> = [K, V][]\n\n/** The collective or \"union\" type of the keys in a set of entries */\nexport type KeyOfEntries<E extends Entries> = E extends [infer K, any][]\n\t? K\n\t: never\n\n/** The type of the value of entry `K` in a set of entries `E` */\nexport type ValueOfEntry<E extends Entries, K extends KeyOfEntries<E>> = {\n\t[P in Count<E[`length`]>]: E[P] extends [K, infer V] ? V : never\n}[Count<E[`length`]>]\n\n/** The type of a set of entries `E` in object form */\nexport type FromEntries<E extends Entries> = Flat<{\n\t[K in KeyOfEntries<E>]: ValueOfEntry<E, K>\n}>\n\n/** Typed form of `Object.fromEntries` */\nexport function fromEntries<E extends Entries>(entries: E): FromEntries<E> {\n\treturn Object.fromEntries(entries) as FromEntries<E>\n}\n\n/** The type of an object T in {@link Entries} form */\nexport type ToEntries<T extends object> = Entries<keyof T, T[keyof T]>\n\n/** Typed form of `Object.entries` */\nexport function toEntries<T extends object>(obj: T): ToEntries<T> {\n\treturn Object.entries(obj) as Entries<keyof T, T[keyof T]>\n}\n", "import type { ViewOf } from \"atom.io\"\n\nexport * from \"./entries\"\n\nexport type primitive = boolean | number | string | null\n\nexport namespace Json {\n\texport namespace Tree {\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\texport type Array<Element = unknown> = ReadonlyArray<Element>\n\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\texport type Object<K extends string = string, V = unknown> = Record<K, V>\n\t\texport type Fork = Array | Object\n\t\texport type Leaf = primitive\n\t\texport type Node = Fork | Leaf\n\t}\n\n\t/** A value can survive being {@link JSON.stringify}-ed and {@link JSON.parse}-d fully intact */\n\texport type Serializable =\n\t\t| primitive\n\t\t| Readonly<{ [key: string]: Serializable }>\n\t\t| ReadonlyArray<Serializable>\n\n\texport type Object<\n\t\tKey extends string = string,\n\t\tValue extends Serializable = Serializable,\n\t> = Record<Key, Value>\n\n\texport type Array<Element extends Serializable = Serializable> =\n\t\tReadonlyArray<Element>\n}\n\n/** A generic that retains the type information of a {@link Json.Serializable} value while in string form */\n// biome-ignore format: long silly ternary\nexport type stringified<J extends Json.Serializable> = (\n J extends string\n ? `\"${J}\"`\n : J extends number\n ? `${J}`\n : J extends true\n ? `true`\n : J extends false\n ? `false`\n : J extends boolean\n ? `false` | `true`\n : J extends null\n ? `null`\n : J extends []\n ? `[]`\n : J extends [infer Element extends Json.Serializable]\n ? `[${stringified<Element>}]`\n : J extends [\n\t\t\t\t\tinfer Element1 extends Json.Serializable,\n\t\t\t\t\tinfer Element2 extends Json.Serializable,\n\t\t\t\t]\n ? `[${stringified<Element1>}, ${stringified<Element2>}]`\n : J extends [\n\t\t\t\t\tinfer Element1 extends Json.Serializable,\n\t\t\t\t\tinfer Element2 extends Json.Serializable,\n\t\t\t\t\tinfer Element3 extends Json.Serializable,\n\t\t\t\t]\n ? `[${stringified<Element1>}, ${stringified<Element2>}, ${stringified<Element3>}]`\n : J extends any[]\n ? `[${string}]` & { __json?: J }\n : string & { __json?: J }\n )\n\n/** Type-safe wrapper for {@link JSON.parse} */\nexport function parseJson<J extends Json.Serializable>(str: stringified<J>): J\n/** Type-safe wrapper for {@link JSON.parse} */\nexport function parseJson(str: string): Json.Serializable\nexport function parseJson(str: string): Json.Serializable {\n\treturn JSON.parse(str)\n}\n\n/** Type-safe wrapper for {@link JSON.stringify} */\nexport const stringifyJson = <J extends Json.Serializable>(\n\tjson: J,\n): stringified<J> => JSON.stringify(json) as stringified<J>\n\n/** Only Canonical values should be used for keys because they always serialize to the same string */\nexport type Canonical = primitive | ReadonlyArray<Canonical>\n\n/** A function whose parameters and return value are {@link Json.Serializable} */\nexport type JsonIO = (...params: Json.Serializable[]) => Json.Serializable | void\n\nexport type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {\n\ttoJson: (t: ViewOf<T>) => J\n\tfromJson: (json: J) => T\n}\n\nconst JSON_PROTOTYPES = [\n\tArray.prototype,\n\tBoolean.prototype,\n\tNumber.prototype,\n\tObject.prototype,\n\tString.prototype,\n] as const\nexport const isJson = (input: unknown): input is Json.Tree.Node => {\n\tif (input === null) return true\n\tif (input === undefined) return false\n\tconst prototype = Object.getPrototypeOf(input)\n\treturn JSON_PROTOTYPES.includes(prototype)\n}\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {\n\tarray: Json.Array\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: Json.Object\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n", "import type { primitive } from \"atom.io/json\"\n\nimport type { Flat } from \"../internal/utility-types\"\n\nexport type IndexOf<\n\tT extends readonly unknown[],\n\tE,\n\tA extends unknown[] = [],\n> = T extends readonly [infer Head, ...infer Tail]\n\t? (<U>() => U extends Head ? 1 : 2) extends <U>() => U extends E ? 1 : 2\n\t\t? A[`length`]\n\t\t: IndexOf<Tail, E, [...A, unknown]>\n\t: never\n\nexport type Flip<T extends Record<string, number | string>> = {\n\t[K in keyof T as T[K]]: K\n}\n\nexport type TwoWay<T extends Record<string, number | string>> = Flip<T> & T\n\nexport type Enumeration<T extends readonly string[]> = Flat<\n\tTwoWay<{\n\t\t[K in T[number]]: IndexOf<T, K>\n\t}>\n>\n\nexport function enumeration<T extends readonly string[]>(\n\tvalues: T,\n): Enumeration<T> {\n\tconst result: Record<any, any> = {}\n\tlet i = 0\n\tfor (const value of values) {\n\t\tresult[value] = i\n\t\tresult[i] = value\n\t\t++i\n\t}\n\treturn result as Enumeration<T>\n}\n\nconst BOOL = `\\u0001`\nconst NULL = `\\u0002`\nconst STRING = `\\u0003`\nconst NUMBER = `\\u0004`\nexport const packValue = (value: primitive): string => {\n\tconst type = typeof value as `boolean` | `number` | `object` | `string`\n\tswitch (type) {\n\t\tcase `string`:\n\t\t\treturn STRING + value\n\t\tcase `number`:\n\t\t\treturn NUMBER + value\n\t\tcase `boolean`:\n\t\t\treturn BOOL + +(value as boolean)\n\t\tcase `object`:\n\t\t\treturn NULL\n\t}\n}\nexport const unpackValue = (value: string): primitive => {\n\tconst type = value[0] as `\\u0001` | `\\u0002` | `\\u0003` | `\\u0004`\n\tswitch (type) {\n\t\tcase STRING:\n\t\t\treturn value.slice(1)\n\t\tcase NUMBER:\n\t\t\treturn +value.slice(1)\n\t\tcase BOOL:\n\t\t\treturn value.slice(1) === `1`\n\t\tcase NULL:\n\t\t\treturn null\n\t}\n}\n", "import type { Fn, Transceiver, TransceiverMode } from \"atom.io/internal\"\nimport { Subject } from \"atom.io/internal\"\nimport type { primitive } from \"atom.io/json\"\nimport type { Enumeration } from \"atom.io/struct\"\nimport { enumeration, packValue, unpackValue } from \"atom.io/struct\"\n\nexport type SetMutations = Exclude<\n\tkeyof Set<any>,\n\tsymbol | keyof ReadonlySet<any>\n>\nexport type SetUpdate<P extends primitive> =\n\t| {\n\t\t\ttype: `add` | `delete`\n\t\t\tvalue: P\n\t }\n\t| {\n\t\t\ttype: `clear`\n\t\t\tvalues: P[]\n\t }\nexport type UListUpdateType = SetUpdate<any>[`type`]\ntrue satisfies SetMutations extends UListUpdateType\n\t? true\n\t: Exclude<SetMutations, UListUpdateType>\n\nexport type PackedSetUpdate<P extends primitive> = string & {\n\tupdate?: SetUpdate<P>\n}\n\nexport const SET_UPDATE_ENUM: Enumeration<[`add`, `delete`, `clear`]> =\n\tenumeration([`add`, `delete`, `clear`] as const)\n\nexport type SetMutationHandler = { [K in UListUpdateType]: Fn }\n\nexport type UListView<P extends primitive> = ReadonlySet<P> & {\n\tsubscribe: (\n\t\tkey: string,\n\t\tfn: (update: PackedSetUpdate<P>) => void,\n\t) => () => void\n}\n\nexport class UList<P extends primitive>\n\textends Set<P>\n\timplements\n\t\tTransceiver<UListView<P>, PackedSetUpdate<P>, ReadonlyArray<P>>,\n\t\tSetMutationHandler\n{\n\tpublic mode: TransceiverMode = `record`\n\tpublic readonly subject: Subject<PackedSetUpdate<P>> = new Subject()\n\n\tpublic constructor(values?: Iterable<P>) {\n\t\tsuper(values)\n\t\tif (values instanceof UList) {\n\t\t}\n\t}\n\n\tpublic readonly READONLY_VIEW: UListView<P> = this\n\n\tpublic toJSON(): ReadonlyArray<P> {\n\t\treturn [...this]\n\t}\n\n\tpublic static fromJSON<P extends primitive>(json: ReadonlyArray<P>): UList<P> {\n\t\treturn new UList<P>(json)\n\t}\n\n\tpublic add(value: P): this {\n\t\tconst result = super.add(value)\n\t\tif (this.mode === `record`) {\n\t\t\tthis.emit({ type: `add`, value })\n\t\t}\n\t\treturn result\n\t}\n\n\tpublic clear(): void {\n\t\tconst capturedContents = this.mode === `record` ? [...this] : null\n\t\tsuper.clear()\n\t\tif (capturedContents) {\n\t\t\tthis.emit({ type: `clear`, values: capturedContents })\n\t\t}\n\t}\n\n\tpublic delete(value: P): boolean {\n\t\tconst result = super.delete(value)\n\t\tif (this.mode === `record`) {\n\t\t\tthis.emit({ type: `delete`, value })\n\t\t}\n\t\treturn result\n\t}\n\n\tpublic subscribe(\n\t\tkey: string,\n\t\tfn: (update: PackedSetUpdate<P>) => void,\n\t): () => void {\n\t\treturn this.subject.subscribe(key, fn)\n\t}\n\n\tpublic emit(update: SetUpdate<P>): void {\n\t\tthis.subject.next(UList.packUpdate(update))\n\t}\n\n\tpublic do(packed: PackedSetUpdate<P>): null {\n\t\tthis.mode = `playback`\n\t\tconst update = UList.unpackUpdate(packed)\n\t\tswitch (update.type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.add(update.value)\n\t\t\t\tbreak\n\t\t\tcase `delete`:\n\t\t\t\tthis.delete(update.value)\n\t\t\t\tbreak\n\t\t\tcase `clear`:\n\t\t\t\tthis.clear()\n\t\t}\n\t\tthis.mode = `record`\n\t\treturn null\n\t}\n\n\tpublic undo(packed: PackedSetUpdate<P>): number | null {\n\t\tconst update = UList.unpackUpdate(packed)\n\t\tthis.mode = `playback`\n\t\tswitch (update.type) {\n\t\t\tcase `add`:\n\t\t\t\tthis.delete(update.value)\n\t\t\t\tbreak\n\t\t\tcase `delete`:\n\t\t\t\tthis.add(update.value)\n\t\t\t\tbreak\n\t\t\tcase `clear`: {\n\t\t\t\tconst values = update.values\n\t\t\t\tfor (const v of values) this.add(v)\n\t\t\t}\n\t\t}\n\t\tthis.mode = `record`\n\t\treturn null\n\t}\n\n\tpublic static packUpdate<P extends primitive>(\n\t\tupdate: SetUpdate<P>,\n\t): PackedSetUpdate<P> {\n\t\tconst head = SET_UPDATE_ENUM[update.type] + `\\u001F`\n\t\tif (update.type === `clear`) {\n\t\t\treturn head + update.values.map(packValue).join(`\\u001E`)\n\t\t}\n\t\treturn head + packValue(update.value)\n\t}\n\tpublic static unpackUpdate<P extends primitive>(\n\t\tpacked: PackedSetUpdate<P>,\n\t): SetUpdate<P> {\n\t\tconst [type, tail] = packed.split(`\\u001F`) as [0 | 1 | 2, string]\n\t\tconst head = SET_UPDATE_ENUM[type]\n\t\tif (head === `clear`) {\n\t\t\tconst values = tail.split(`\\u001E`).map(unpackValue) as P[]\n\t\t\treturn { type: `clear`, values }\n\t\t}\n\t\treturn { type: head, value: unpackValue(tail) as P }\n\t}\n}\n", "import type { AtomEffect } from \"atom.io\"\nimport { getUpdateToken, subscribeInStore } from \"atom.io/internal\"\nimport { type primitive, stringifyJson } from \"atom.io/json\"\n\nimport { UList } from \"./u-list\"\n\nexport const uListDisposedKeyCleanupEffect: AtomEffect<UList<primitive>> = ({\n\ttoken,\n\tsetSelf,\n\tstore,\n}) => {\n\tconst disposalSubscriptions = new Map<primitive, () => void>()\n\tconst updateToken = getUpdateToken(token)\n\tsubscribeInStore(\n\t\tstore,\n\t\tupdateToken,\n\t\tfunction setAutoDeletionTriggers({ newValue }) {\n\t\t\tconst unpacked = UList.unpackUpdate(newValue)\n\t\t\tswitch (unpacked.type) {\n\t\t\t\tcase `add`:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst molecule = store.molecules.get(stringifyJson(unpacked.value))\n\t\t\t\t\t\tif (molecule) {\n\t\t\t\t\t\t\tdisposalSubscriptions.set(\n\t\t\t\t\t\t\t\tunpacked.value,\n\t\t\t\t\t\t\t\tmolecule.subject.subscribe(token.key, () => {\n\t\t\t\t\t\t\t\t\tsetSelf((self) => {\n\t\t\t\t\t\t\t\t\t\tself.delete(unpacked.value)\n\t\t\t\t\t\t\t\t\t\treturn self\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\tcase `delete`:\n\t\t\t\t\tdisposalSubscriptions.get(unpacked.value)?.()\n\t\t\t\t\tdisposalSubscriptions.delete(unpacked.value)\n\t\t\t\t\tbreak\n\t\t\t\tcase `clear`:\n\t\t\t\t\tfor (const unsub of disposalSubscriptions.values()) unsub()\n\t\t\t\t\tdisposalSubscriptions.clear()\n\t\t\t}\n\t\t},\n\t\t`set-auto-deletion-triggers`,\n\t)\n}\n", "export function arbitrary(random: () => number = Math.random): string {\n\treturn random().toString(36).slice(2)\n}\n", "/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\nexport interface Lineage {\n\tparent: typeof this | null\n\tchild: typeof this | null\n}\n\nexport function newest<T extends Lineage>(\n\tscion: T,\n): Exclude<T[`child`], null> | T {\n\twhile (scion.child !== null) {\n\t\tscion = scion.child\n\t}\n\treturn scion\n}\n\nexport function eldest<T extends Lineage>(\n\tscion: T,\n): Exclude<T[`parent`], T[`child`] | null> {\n\twhile (scion.parent !== null) {\n\t\tscion = scion.parent\n\t}\n\treturn scion as Exclude<T[`parent`], T[`child`] | null>\n}\n", "import type { Fn } from \"./utility-types\"\n\nconst NON_CTOR_FN_REGEX =\n\t/^\\[object (?:Async|Generator|AsyncGenerator)?Function\\]$/\n\nexport function isFn(input: unknown): input is Fn {\n\tconst protoString = Object.prototype.toString.call(input)\n\treturn NON_CTOR_FN_REGEX.test(protoString)\n}\n", "import { isFn } from \"../is-fn\"\n\nexport function become<T>(\n\tnextVersionOfThing: T | ((prev: T) => T),\n\toriginalThing: T,\n): T {\n\tif (isFn(nextVersionOfThing)) {\n\t\treturn nextVersionOfThing(originalThing)\n\t}\n\treturn nextVersionOfThing\n}\n", "/**\n * A Promise whose incoming value can be hot swapped.\n * @internal\n * @private\n * @typeParam T The type of the value that the promise will resolve to.\n *\n * @remarks\n * Can be constructed like a Promise, or from an existing Promise.\n */\nexport class Future<T> extends Promise<T> {\n\tprivate fate: Promise<T> | undefined\n\tprivate resolve: (value: T) => void\n\tprivate reject: (reason?: any) => void\n\n\tpublic done = false\n\n\tpublic constructor(\n\t\texecutor:\n\t\t\t| Promise<T>\n\t\t\t| ((resolve: (value: T) => void, reject: (reason?: any) => void) => void),\n\t) {\n\t\tlet superResolve: ((value: T) => void) | undefined\n\t\tlet superReject: ((reason?: any) => void) | undefined\n\t\tsuper((resolve, reject) => {\n\t\t\tsuperResolve = resolve\n\t\t\tsuperReject = reject\n\t\t})\n\t\tthis.resolve = superResolve as (value: T) => void\n\t\tthis.reject = superReject as (reason?: any) => void\n\t\tthis.use(executor instanceof Promise ? executor : new Promise(executor))\n\t}\n\n\tprivate pass(promise: Promise<T>, value: T) {\n\t\tif (promise === this.fate) {\n\t\t\tthis.resolve(value)\n\t\t\tthis.done = true\n\t\t}\n\t}\n\tprivate fail(promise: Promise<T>, reason: any) {\n\t\tif (promise === this.fate) {\n\t\t\tthis.reject(reason)\n\t\t\tthis.done = true\n\t\t}\n\t}\n\n\tpublic use(value: Promise<T> | T): void {\n\t\tif (this === value) {\n\t\t\treturn\n\t\t}\n\t\tif (value instanceof Promise) {\n\t\t\tconst promise = value\n\t\t\tthis.fate = promise\n\t\t\tpromise.then(\n\t\t\t\t(resolved) => {\n\t\t\t\t\tthis.pass(promise, resolved)\n\t\t\t\t},\n\t\t\t\t(reason) => {\n\t\t\t\t\tthis.fail(promise, reason)\n\t\t\t\t},\n\t\t\t)\n\t\t} else {\n\t\t\tthis.resolve(value)\n\t\t\tthis.fate = undefined\n\t\t}\n\t}\n}\n", "export class Subject<T> {\n\tpublic Subscriber!: (value: T) => void\n\n\tpublic subscribers: Map<string, this[`Subscriber`]> = new Map()\n\n\tpublic subscribe(key: string, subscriber: this[`Subscriber`]): () => void {\n\t\tthis.subscribers.set(key, subscriber)\n\t\tconst unsubscribe = () => {\n\t\t\tthis.unsubscribe(key)\n\t\t}\n\t\treturn unsubscribe\n\t}\n\n\tprivate unsubscribe(key: string) {\n\t\tthis.subscribers.delete(key)\n\t}\n\n\tpublic next(value: T): void {\n\t\tconst subscribers = this.subscribers.values()\n\t\tfor (const subscriber of subscribers) {\n\t\t\tsubscriber(value)\n\t\t}\n\t}\n}\n\nexport class StatefulSubject<T> extends Subject<T> {\n\tpublic state: T\n\n\tpublic constructor(initialState: T) {\n\t\tsuper()\n\t\tthis.state = initialState\n\t}\n\n\tpublic next(value: T): void {\n\t\tthis.state = value\n\t\tsuper.next(value)\n\t}\n}\n", "export class CircularBuffer<T> {\n\tprotected _buffer: T[]\n\tprotected _index = 0\n\tpublic constructor(array: T[])\n\tpublic constructor(length: number)\n\tpublic constructor(lengthOrArray: T[] | number) {\n\t\tlet length: number\n\t\tif (typeof lengthOrArray === `number`) {\n\t\t\tlength = lengthOrArray\n\t\t} else {\n\t\t\tlength = lengthOrArray.length\n\t\t}\n\t\tthis._buffer = Array.from({ length })\n\t}\n\n\tpublic get buffer(): ReadonlyArray<T | undefined> {\n\t\treturn this._buffer\n\t}\n\n\tpublic get index(): number {\n\t\treturn this._index\n\t}\n\n\tpublic add(item: T): void {\n\t\tthis._buffer[this._index] = item\n\t\tthis._index = (this._index + 1) % this._buffer.length\n\t}\n\n\tpublic copy(): CircularBuffer<T> {\n\t\tconst copy = new CircularBuffer<T>([...this._buffer])\n\t\tcopy._index = this._index\n\t\treturn copy\n\t}\n}\n", "import type {\n\tAtomFamilyToken,\n\tAtomIOToken,\n\tAtomToken,\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tReadonlyPureSelectorFamilyToken,\n\tReadonlyPureSelectorToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSelectorFamilyToken,\n\tSelectorToken,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tWritableFamilyToken,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { Transceiver } from \"../mutable\"\nimport type {\n\tAtom,\n\tAtomFamily,\n\tAtomIOInternalResource,\n\tMutableAtom,\n\tMutableAtomFamily,\n\tReadableFamily,\n\tReadableState,\n\tReadonlyPureSelector,\n\tReadonlyPureSelectorFamily,\n\tRegularAtom,\n\tRegularAtomFamily,\n\tSelector,\n\tSelectorFamily,\n\tWritableFamily,\n\tWritablePureSelector,\n\tWritablePureSelectorFamily,\n\tWritableState,\n} from \"../state-types\"\nimport type { Timeline } from \"../timeline\"\nimport type { Transaction } from \"../transaction\"\nimport type { Fn } from \"../utility-types\"\n\nexport function deposit<T, E>(\n\tstate: RegularAtom<T, E>,\n): RegularAtomToken<T, Canonical, E>\nexport function deposit<T extends Transceiver<any, any, any>>(\n\tstate: MutableAtom<T>,\n): MutableAtomToken<T>\nexport function deposit<T, E>(state: Atom<T, E>): AtomToken<T, Canonical, E>\nexport function deposit<T, E>(\n\tstate: WritablePureSelector<T, E>,\n): WritablePureSelectorToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: ReadonlyPureSelector<T, E>,\n): ReadonlyPureSelectorToken<T, any, E>\nexport function deposit<T, E>(state: Selector<T, E>): SelectorToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: WritableState<T, E>,\n): WritableToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: ReadableState<T, E>,\n): ReadableToken<T, any, E>\n\nexport function deposit<T, K extends Canonical, E>(\n\tstate: RegularAtomFamily<T, K, E>,\n): RegularAtomFamilyToken<T, K, E>\nexport function deposit<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(state: MutableAtomFamily<T, K>): MutableAtomFamilyToken<T, K>\nexport function deposit<T, E>(\n\tstate: AtomFamily<T, any, E>,\n): AtomFamilyToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: WritablePureSelectorFamily<T, any, E>,\n): WritablePureSelectorFamilyToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: ReadonlyPureSelectorFamily<T, any, E>,\n): ReadonlyPureSelectorFamilyToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: SelectorFamily<T, any, E>,\n): SelectorFamilyToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: WritableFamily<T, any, E>,\n): WritableFamilyToken<T, any, E>\nexport function deposit<T, E>(\n\tstate: ReadableFamily<T, any, E>,\n): ReadableFamilyToken<T, any, E>\n\nexport function deposit<T extends Fn>(state: Transaction<T>): TransactionToken<T>\nexport function deposit<M extends TimelineManageable>(\n\tstate: Timeline<M>,\n): TimelineToken<M>\n\nexport function deposit(resource: AtomIOInternalResource): AtomIOToken\n\nexport function deposit(state: AtomIOInternalResource): AtomIOToken {\n\tconst token = {\n\t\tkey: state.key,\n\t\ttype: state.type,\n\t} as any\n\tif (`family` in state) {\n\t\ttoken.family = state.family\n\t}\n\treturn token\n}\n", "export class MapOverlay<K, V> extends Map<K, V> {\n\tpublic deleted: Set<K> = new Set()\n\tpublic changed: Set<K> = new Set()\n\tprotected readonly source: Map<K, V>\n\n\tpublic constructor(source: Map<K, V>) {\n\t\tsuper()\n\t\tthis.source = source\n\t}\n\n\tpublic get(key: K): V | undefined {\n\t\tconst has = super.has(key)\n\t\tif (has) {\n\t\t\treturn super.get(key)\n\t\t}\n\t\tif (!this.deleted.has(key) && this.source.has(key)) {\n\t\t\tconst value = this.source.get(key)\n\t\t\treturn value\n\t\t}\n\t\treturn undefined\n\t}\n\n\tpublic set(key: K, value: V): this {\n\t\tthis.deleted.delete(key)\n\t\tif (this.source.has(key)) {\n\t\t\tthis.changed.add(key)\n\t\t}\n\t\treturn super.set(key, value)\n\t}\n\n\tpublic hasOwn(key: K): boolean {\n\t\treturn super.has(key)\n\t}\n\n\tpublic has(key: K): boolean {\n\t\treturn !this.deleted.has(key) && (super.has(key) || this.source.has(key))\n\t}\n\n\tpublic delete(key: K): boolean {\n\t\tif (this.source.has(key)) {\n\t\t\tthis.deleted.add(key)\n\t\t\tthis.changed.delete(key)\n\t\t}\n\t\treturn super.delete(key)\n\t}\n\n\tpublic clear(): void {\n\t\tthis.deleted = new Set(this.source.keys())\n\t\tthis.changed.clear()\n\t\tsuper.clear()\n\t}\n\n\tpublic *[Symbol.iterator](): MapIterator<[K, V]> {\n\t\tyield* super[Symbol.iterator]()\n\t\tfor (const [key, value] of this.source) {\n\t\t\tif (!this.deleted.has(key) && !this.changed.has(key)) {\n\t\t\t\tyield [key, value]\n\t\t\t}\n\t\t}\n\t}\n\tpublic *entries(): MapIterator<[K, V]> {\n\t\tyield* this[Symbol.iterator]()\n\t}\n\tpublic *keys(): MapIterator<K> {\n\t\tyield* super.keys()\n\t\tfor (const key of this.source.keys()) {\n\t\t\tif (!this.deleted.has(key) && !this.changed.has(key)) {\n\t\t\t\tyield key\n\t\t\t}\n\t\t}\n\t}\n\tpublic *values(): MapIterator<V> {\n\t\tfor (const [, value] of this[Symbol.iterator]()) {\n\t\t\tyield value\n\t\t}\n\t}\n\tpublic forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void): void {\n\t\tfor (const [key, value] of this[Symbol.iterator]()) {\n\t\t\tcallbackfn(value, key, this)\n\t\t}\n\t}\n\n\tpublic get size(): number {\n\t\treturn super.size + this.source.size - this.changed.size - this.deleted.size\n\t}\n}\n", "export class SetOverlay<T> extends Set<T> {\n\tpublic deleted: Set<T> = new Set()\n\tpublic source: Set<T>\n\n\tpublic constructor(source: Set<T>) {\n\t\tsuper()\n\t\tthis.source = source\n\t}\n\n\tpublic add(value: T): this {\n\t\tif (this.source.has(value)) {\n\t\t\tthis.deleted.delete(value)\n\t\t\treturn this\n\t\t}\n\t\treturn super.add(value)\n\t}\n\n\tpublic hasOwn(member: T): boolean {\n\t\treturn super.has(member)\n\t}\n\n\tpublic has(key: T): boolean {\n\t\treturn !this.deleted.has(key) && (super.has(key) || this.source.has(key))\n\t}\n\n\tpublic delete(key: T): boolean {\n\t\tif (this.source.has(key)) {\n\t\t\tthis.deleted.add(key)\n\t\t\treturn true\n\t\t}\n\t\treturn super.delete(key)\n\t}\n\n\tpublic clear(): void {\n\t\tthis.deleted = new Set(this.source)\n\t\tsuper.clear()\n\t}\n\n\tpublic *[Symbol.iterator](): SetIterator<T> {\n\t\tyield* super[Symbol.iterator]()\n\t\tfor (const value of this.source) {\n\t\t\tif (!this.deleted.has(value)) {\n\t\t\t\tyield value\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic *iterateOwn(): SetIterator<T> {\n\t\tyield* super[Symbol.iterator]()\n\t}\n\n\tpublic get size(): number {\n\t\treturn super.size + this.source.size - this.deleted.size\n\t}\n}\n", "import { SetOverlay } from \"./set-overlay\"\n\nexport class RelationsOverlay<K, V extends Set<any>> extends Map<K, V> {\n\tpublic deleted: Set<K> = new Set()\n\tprotected readonly source: Map<K, V>\n\n\tpublic constructor(source: Map<K, V>) {\n\t\tsuper()\n\t\tthis.source = source\n\t}\n\n\tpublic get(key: K): V | undefined {\n\t\tconst has = super.has(key)\n\t\tif (has) {\n\t\t\treturn super.get(key)\n\t\t}\n\t\tif (!this.deleted.has(key) && this.source.has(key)) {\n\t\t\tconst value = this.source.get(key)\n\t\t\tconst valueOverlay = new SetOverlay(value as V) as unknown as V\n\t\t\tsuper.set(key, valueOverlay)\n\t\t\treturn valueOverlay\n\t\t}\n\t\treturn undefined\n\t}\n\n\tpublic set(key: K, value: V): this {\n\t\tthis.deleted.delete(key)\n\t\treturn super.set(key, value)\n\t}\n\n\tpublic has(key: K): boolean {\n\t\treturn !this.deleted.has(key) && (super.has(key) || this.source.has(key))\n\t}\n\n\tpublic delete(key: K): boolean {\n\t\tthis.deleted.add(key)\n\t\treturn super.delete(key)\n\t}\n}\n", "import type { Json } from \"atom.io/json\"\n\nimport { MapOverlay, RelationsOverlay, SetOverlay } from \"./overlays\"\nimport type { Refinement } from \"./utility-types\"\n\nexport type JunctionEntriesBase<\n\tA extends string,\n\tB extends string,\n\tContent extends Json.Object | null,\n> = {\n\treadonly relations: ([A, B[]] | [B, A[]])[]\n\treadonly contents: [string, Content][]\n}\nexport interface JunctionEntries<\n\tA extends string,\n\tB extends string,\n\tContent extends Json.Object | null,\n> extends Json.Object,\n\t\tJunctionEntriesBase<A, B, Content> {}\n\nexport type JunctionSchemaBase<AName extends string, BName extends string> = {\n\t/** Description of the relationship between the two sides */\n\treadonly between: [a: AName, b: BName]\n\t/** How many relations are allowed in each direction? */\n\treadonly cardinality: `1:1` | `1:n` | `n:n`\n}\nexport interface JunctionSchema<ASide extends string, BSide extends string>\n\textends Json.Object,\n\t\tJunctionSchemaBase<ASide, BSide> {}\n\nexport type BaseExternalStoreConfiguration = {\n\taddRelation: (a: string, b: string) => void\n\tdeleteRelation: (a: string, b: string) => void\n\treplaceRelationsSafely: (a: string, bs: string[]) => void\n\treplaceRelationsUnsafely: (a: string, bs: string[]) => void\n\tgetRelatedKeys(key: string): Set<string> | undefined\n\thas: (a: string, b?: string) => boolean\n}\n\nexport type ExternalStoreWithContentConfiguration<Content extends Json.Object> =\n\t{\n\t\tgetContent: (contentKey: string) => Content | undefined\n\t\tsetContent: (contentKey: string, content: Content) => void\n\t\tdeleteContent: (contentKey: string) => void\n\t}\n\nexport type Empty<Obj extends object> = {\n\t[Key in keyof Obj]?: undefined\n}\n\nexport type ExternalStoreConfiguration<Content extends Json.Object | null> =\n\tContent extends Json.Object\n\t\t? BaseExternalStoreConfiguration &\n\t\t\t\tExternalStoreWithContentConfiguration<Content>\n\t\t: BaseExternalStoreConfiguration &\n\t\t\t\tEmpty<ExternalStoreWithContentConfiguration<Json.Object>>\n\nexport type JunctionAdvancedConfiguration<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tContent extends Json.Object | null,\n> = {\n\twarn?: (...args: any[]) => void\n\texternalStore?: ExternalStoreConfiguration<Content>\n\tisAType?: Refinement<string, A>\n\tisBType?: Refinement<string, B>\n\tisContent?: Refinement<unknown, Content>\n\tmakeContentKey?: (a: A, b: B) => string\n\tsource?: Junction<AName, A, BName, B, Content>\n}\n\nexport type JunctionJSON<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tContent extends Json.Object | null,\n> = JunctionEntries<A, B, Content> & JunctionSchema<AName, BName>\n\nexport class Junction<\n\tconst AName extends string,\n\tconst A extends string,\n\tconst BName extends string,\n\tconst B extends string,\n\tconst Content extends Json.Object | null = null,\n> {\n\tpublic readonly a: AName\n\tpublic readonly b: BName\n\tpublic readonly cardinality: `1:1` | `1:n` | `n:n`\n\tpublic readonly relations: Map<A | B, Set<A> | Set<B>> = new Map()\n\tpublic readonly contents: Map<string, Content> = new Map()\n\n\tpublic isAType?: Refinement<string, A> | null\n\tpublic isBType?: Refinement<string, B> | null\n\tpublic isContent: Refinement<unknown, Content> | null\n\tpublic makeContentKey = (a: A, b: B): string => `${a}:${b}`\n\n\tpublic warn?: (...args: any[]) => void\n\n\tpublic getRelatedKeys(key: A): Set<B> | undefined\n\tpublic getRelatedKeys(key: B): Set<A> | undefined\n\tpublic getRelatedKeys(key: A | B): Set<A> | Set<B> | undefined\n\tpublic getRelatedKeys(key: A | B): Set<A> | Set<B> | undefined {\n\t\treturn this.relations.get(key)\n\t}\n\tprotected addRelation(a: A, b: B): void {\n\t\tlet aRelations = this.relations.get(a) as Set<B> | undefined\n\t\tlet bRelations = this.relations.get(b) as Set<A> | undefined\n\t\tif (aRelations) {\n\t\t\taRelations.add(b)\n\t\t} else {\n\t\t\taRelations = new Set([b])\n\t\t\tthis.relations.set(a, aRelations)\n\t\t}\n\t\tif (bRelations) {\n\t\t\tbRelations.add(a)\n\t\t} else {\n\t\t\tbRelations = new Set([a])\n\t\t\tthis.relations.set(b, bRelations)\n\t\t}\n\t}\n\tprotected deleteRelation(a: A, b: B): void {\n\t\tconst aRelations = this.relations.get(a) as Set<B> | undefined\n\t\tif (aRelations) {\n\t\t\taRelations.delete(b)\n\t\t\tif (aRelations.size === 0) {\n\t\t\t\tthis.relations.delete(a)\n\t\t\t}\n\t\t\tconst bRelations = this.relations.get(b) as Set<A> | undefined\n\t\t\tif (bRelations) {\n\t\t\t\tbRelations.delete(a)\n\t\t\t\tif (bRelations.size === 0) {\n\t\t\t\t\tthis.relations.delete(b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected replaceRelationsUnsafely(a: A, bs: B[]): void\n\tprotected replaceRelationsUnsafely(b: B, as: A[]): void\n\tprotected replaceRelationsUnsafely(x: A | B, ys: A[] | B[]): void {\n\t\tthis.relations.set(x as A, new Set(ys as B[]))\n\t\tfor (const y of ys) {\n\t\t\tconst yRelations = new Set<A>().add(x as A)\n\t\t\tthis.relations.set(y, yRelations)\n\t\t}\n\t}\n\tprotected replaceRelationsSafely(a: A, bs: B[]): void\n\tprotected replaceRelationsSafely(b: B, as: A[]): void\n\tprotected replaceRelationsSafely<\n\t\tXType extends A | B,\n\t\tYType extends XType extends A ? B : A,\n\t>(x: XType, ys: YType[]): void {\n\t\tconst xRelationsPrev = this.relations.get(x)\n\t\tlet a: A | undefined = this.isAType?.(x) ? x : undefined\n\t\tlet b: B | undefined = a === undefined ? (x as B) : undefined\n\t\tif (xRelationsPrev) {\n\t\t\tfor (const y of xRelationsPrev) {\n\t\t\t\ta ??= y as A\n\t\t\t\tb ??= y as B\n\t\t\t\tconst yRelations = this.relations.get(y) as Set<XType> | undefined\n\t\t\t\tif (yRelations) {\n\t\t\t\t\tif (yRelations.size === 1) {\n\t\t\t\t\t\tthis.relations.delete(y)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tyRelations.delete(x)\n\t\t\t\t\t}\n\t\t\t\t\tthis.contents.delete(this.makeContentKey(a, b))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.relations.set(x, new Set(ys) as any)\n\t\tfor (const y of ys) {\n\t\t\tlet yRelations = this.relations.get(y) as Set<XType> | undefined\n\t\t\tif (yRelations) {\n\t\t\t\tyRelations.add(x)\n\t\t\t} else {\n\t\t\t\tyRelations = new Set<XType>().add(x)\n\t\t\t\tthis.relations.set(y, yRelations as any)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected getContentInternal(contentKey: string): Content | undefined {\n\t\treturn this.contents.get(contentKey)\n\t}\n\tprotected setContent(contentKey: string, content: Content): void {\n\t\tthis.contents.set(contentKey, content)\n\t}\n\tprotected deleteContent(contentKey: string): void {\n\t\tthis.contents.delete(contentKey)\n\t}\n\n\tpublic constructor(\n\t\tdata: JunctionSchema<AName, BName> &\n\t\t\tPartial<JunctionEntries<NoInfer<A>, NoInfer<B>, Content>>,\n\t\tconfig?: JunctionAdvancedConfiguration<AName, A, BName, B, Content>,\n\t) {\n\t\tthis.a = data.between[0]\n\t\tthis.b = data.between[1]\n\n\t\tthis.cardinality = data.cardinality\n\n\t\tthis.isAType = config?.isAType ?? null\n\t\tthis.isBType = config?.isBType ?? null\n\t\tthis.isContent = config?.isContent ?? null\n\t\tif (config?.makeContentKey) {\n\t\t\tthis.makeContentKey = config.makeContentKey\n\t\t}\n\t\tif (!config?.externalStore) {\n\t\t\tconst source = config?.source\n\t\t\tif (source === undefined) {\n\t\t\t\tthis.relations = new Map(\n\t\t\t\t\tdata.relations?.map(([x, ys]) => [x, new Set(ys as A[])]),\n\t\t\t\t)\n\t\t\t\tthis.contents = new Map(data.contents)\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tthis.relations = new RelationsOverlay(source.relations)\n\t\t\t\tthis.contents = new MapOverlay(source.contents)\n\t\t\t}\n\t\t}\n\t\tif (config?.externalStore) {\n\t\t\tconst externalStore = config.externalStore\n\t\t\tthis.has = (a, b) => externalStore.has(a, b)\n\t\t\tthis.addRelation = (a, b) => {\n\t\t\t\texternalStore.addRelation(a, b)\n\t\t\t}\n\t\t\tthis.deleteRelation = (a, b) => {\n\t\t\t\texternalStore.deleteRelation(a, b)\n\t\t\t}\n\t\t\tthis.replaceRelationsSafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsSafely(a, bs)\n\t\t\t}\n\t\t\tthis.replaceRelationsUnsafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsUnsafely(a, bs)\n\t\t\t}\n\t\t\tthis.getRelatedKeys = ((key) =>\n\t\t\t\texternalStore.getRelatedKeys(\n\t\t\t\t\tkey,\n\t\t\t\t)) as typeof Junction.prototype.getRelatedKeys\n\t\t\tif (externalStore.getContent) {\n\t\t\t\tthis.getContentInternal = (contentKey) => {\n\t\t\t\t\treturn externalStore.getContent(contentKey) as any\n\t\t\t\t}\n\t\t\t\tthis.setContent = (contentKey, content) => {\n\t\t\t\t\texternalStore.setContent(contentKey, content as any)\n\t\t\t\t}\n\t\t\t\tthis.deleteContent = (contentKey) => {\n\t\t\t\t\texternalStore.deleteContent(contentKey)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [x, ys] of data.relations ?? []) {\n\t\t\t\tlet a = this.isAType?.(x) ? x : undefined\n\t\t\t\tlet b = a === undefined ? (x as B) : undefined\n\t\t\t\tfor (const y of ys) {\n\t\t\t\t\ta ??= y as A\n\t\t\t\t\tb ??= y as B\n\t\t\t\t\tthis.addRelation(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [contentKey, content] of data.contents ?? []) {\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t\tif (config?.warn) {\n\t\t\tthis.warn = config.warn\n\t\t}\n\t}\n\tpublic toJSON(): JunctionJSON<AName, A, BName, B, Content> {\n\t\treturn {\n\t\t\tbetween: [this.a, this.b],\n\t\t\tcardinality: this.cardinality,\n\t\t\trelations: [...this.relations.entries()].map(\n\t\t\t\t([a, b]) => [a, [...b]] as [A, B[]],\n\t\t\t),\n\t\t\tcontents: [...this.contents.entries()],\n\t\t}\n\t}\n\n\tpublic set(\n\t\ta: A,\n\t\t...rest: Content extends null ? [b: B] : [b: B, content: Content]\n\t): this\n\tpublic set(\n\t\trelation: { [Key in AName]: A } & { [Key in BName]: B },\n\t\t...rest: Content extends null ? [] | [void?: undefined] : [content: Content]\n\t): this\n\tpublic set(\n\t\t...params:\n\t\t\t| [\n\t\t\t\t\trelation: { [Key in AName]: A } & { [Key in BName]: B },\n\t\t\t\t\t...rest: Content extends null\n\t\t\t\t\t\t? [] | [void?: undefined]\n\t\t\t\t\t\t: [content: Content],\n\t\t\t ]\n\t\t\t| [a: A, ...rest: Content extends null ? [b: B] : [b: B, content: Content]]\n\t): this {\n\t\tlet a: A\n\t\tlet b: B\n\t\tlet content: Content | undefined\n\t\tswitch (params.length) {\n\t\t\tcase 1: {\n\t\t\t\tconst relation = params[0] as Record<AName, A> & Record<BName, B>\n\t\t\t\ta = relation[this.a]\n\t\t\t\tb = relation[this.b]\n\t\t\t\tcontent = undefined\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 2: {\n\t\t\t\tconst zeroth = params[0]\n\t\t\t\tif (typeof zeroth === `string`) {\n\t\t\t\t\t;[a, b] = params as unknown as [A, B]\n\t\t\t\t} else {\n\t\t\t\t\ta = zeroth[this.a]\n\t\t\t\t\tb = zeroth[this.b]\n\t\t\t\t\tcontent = params[1] as Content\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\ta = params[0] as A\n\t\t\t\tb = params[1] as B\n\t\t\t\tcontent = params[2] as Content\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tswitch (this.cardinality) {\n\t\t\t// biome-ignore lint/suspicious/noFallthroughSwitchClause: perfect here\n\t\t\tcase `1:1`: {\n\t\t\t\tconst bPrev = this.getRelatedKey(a)\n\t\t\t\tif (bPrev && bPrev !== b) this.delete(a, bPrev)\n\t\t\t}\n\t\t\tcase `1:n`:\n\t\t\t\t{\n\t\t\t\t\tconst aPrev = this.getRelatedKey(b)\n\t\t\t\t\tif (aPrev && aPrev !== a) this.delete(aPrev, b)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase `n:n`: // do nothing\n\t\t}\n\t\tif (content) {\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.setContent(contentKey, content)\n\t\t}\n\t\tthis.addRelation(a, b)\n\t\treturn this\n\t}\n\n\tpublic delete(a: A, b?: B): this\n\tpublic delete(b: B, a?: A): this\n\tpublic delete(\n\t\trelation:\n\t\t\t| { [Key in AName]: A }\n\t\t\t| { [Key in BName]: B }\n\t\t\t| ({ [Key in AName]: A } & { [Key in BName]: B }),\n\t\tb?: undefined,\n\t): this\n\tpublic delete(\n\t\tx:\n\t\t\t| A\n\t\t\t| B\n\t\t\t| Record<AName | BName, string>\n\t\t\t| Record<AName, string>\n\t\t\t| Record<BName, string>,\n\t\tb?: A | B,\n\t): this {\n\t\t// @ts-expect-error we deduce that this.b may index x\n\t\tb = typeof b === `string` ? (b as B) : (x[this.b] as B | undefined)\n\t\tconst a =\n\t\t\t// @ts-expect-error we deduce that this.a may index x\n\t\t\ttypeof x === `string` ? (x as A) : (x[this.a] as A | undefined)\n\n\t\tif (a === undefined && typeof b === `string`) {\n\t\t\tconst bRelations = this.getRelatedKeys(b) as Set<A>\n\t\t\tif (bRelations) {\n\t\t\t\tfor (const bRelation of bRelations) {\n\t\t\t\t\tthis.delete(bRelation, b)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeof a === `string` && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\tfor (const aRelation of aRelations) {\n\t\t\t\t\tthis.delete(a, aRelation)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (typeof a === `string` && typeof b === `string`) {\n\t\t\tthis.deleteRelation(a, b)\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.deleteContent(contentKey)\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRelatedKey(key: A): B | undefined\n\tpublic getRelatedKey(key: B): A | undefined\n\tpublic getRelatedKey(key: A | B): A | B | undefined {\n\t\tconst relations = this.getRelatedKeys(key)\n\t\tif (relations) {\n\t\t\tif (relations.size > 1) {\n\t\t\t\tthis.warn?.(\n\t\t\t\t\t`${relations.size} related keys were found for key \"${key}\": (${[\n\t\t\t\t\t\t...relations,\n\t\t\t\t\t]\n\t\t\t\t\t\t.map((k) => `\"${k}\"`)\n\t\t\t\t\t\t.join(`, `)}). Only one related key was expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tlet singleRelation: A | B | undefined\n\t\t\tfor (const relation of relations) {\n\t\t\t\tsingleRelation = relation\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn singleRelation\n\t\t}\n\t}\n\n\tpublic replaceRelations(\n\t\ta: A,\n\t\trelations: Content extends null ? B[] : Record<B, Content>,\n\t\tconfig?: { reckless: boolean },\n\t): this\n\tpublic replaceRelations(\n\t\tb: B,\n\t\trelations: Content extends null ? A[] : Record<A, Content>,\n\t\tconfig?: { reckless: boolean },\n\t): this\n\tpublic replaceRelations<\n\t\tXType extends A | B,\n\t\tYType extends XType extends A ? B : A,\n\t>(\n\t\tx: XType,\n\t\trelations: Content extends null ? YType[] : Record<YType, Content>,\n\t\tconfig?: { reckless: boolean },\n\t): this {\n\t\tconst hasContent = !Array.isArray(relations)\n\t\tconst ys = (hasContent ? Object.keys(relations) : relations) as YType[]\n\t\tif (config?.reckless) {\n\t\t\tthis.replaceRelationsUnsafely(x as any, ys as any)\n\t\t} else {\n\t\t\tthis.replaceRelationsSafely(x as any, ys as any)\n\t\t}\n\t\tif (hasContent) {\n\t\t\tfor (const y of ys) {\n\t\t\t\tconst contentKey = this.makeContentKey(x as any, y as any) // sort XY to AB ❗\n\t\t\t\tconst content = (relations as Record<YType, Content>)[y]\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getContent(a: A, b: B): Content | undefined {\n\t\tconst contentKey = this.makeContentKey(a, b)\n\t\treturn this.getContentInternal(contentKey)\n\t}\n\n\tpublic getRelationEntries(input: Record<AName, A>): [B, Content][]\n\tpublic getRelationEntries(input: Record<BName, B>): [A, Content][]\n\tpublic getRelationEntries(\n\t\tinput: Record<AName, A> | Record<BName, B>,\n\t): [A | B, Content][] {\n\t\tconst a: A | undefined = (input as any)[this.a]\n\t\tconst b: B | undefined = (input as any)[this.b]\n\t\tif (a !== undefined && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\treturn [...aRelations].map((aRelation) => {\n\t\t\t\t\treturn [aRelation, this.getContent(a, aRelation) as Content]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (a === undefined && b !== undefined) {\n\t\t\tconst bRelations = this.getRelatedKeys(b)\n\t\t\tif (bRelations) {\n\t\t\t\treturn [...bRelations].map((bRelation) => {\n\t\t\t\t\treturn [bRelation, this.getContent(bRelation, b) as Content]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn []\n\t}\n\n\tpublic has(a: A, b?: B): boolean\n\tpublic has(b: B, a?: A): boolean\n\tpublic has(a: A | B, b?: A | B): boolean {\n\t\tif (b) {\n\t\t\tconst setA = this.getRelatedKeys(a)\n\t\t\treturn setA?.has(b as any) ?? false\n\t\t}\n\t\treturn this.relations.has(a)\n\t}\n\tpublic overlay(): JunctionOverlay<AName, A, BName, B, Content> {\n\t\tconst config: JunctionAdvancedConfiguration<AName, A, BName, B, Content> = {\n\t\t\tsource: this,\n\t\t\tmakeContentKey: this.makeContentKey,\n\t\t}\n\t\tif (this.isAType) config.isAType = this.isAType\n\t\tif (this.isBType) config.isBType = this.isBType\n\t\tif (this.isContent) config.isContent = this.isContent\n\t\tif (this.warn) config.warn = this.warn\n\n\t\treturn new Junction(\n\t\t\t{\n\t\t\t\tbetween: [this.a, this.b],\n\t\t\t\tcardinality: this.cardinality,\n\t\t\t},\n\t\t\tconfig,\n\t\t) as JunctionOverlay<AName, A, BName, B, Content>\n\t}\n\tpublic incorporate(\n\t\toverlay: JunctionOverlay<AName, A, BName, B, Content>,\n\t): void {\n\t\tconst { relations, contents } = overlay\n\t\tfor (const [key, value] of relations) {\n\t\t\tif (value instanceof SetOverlay) {\n\t\t\t\tconst { source } = value\n\t\t\t\tfor (const keyAdded of value.iterateOwn()) {\n\t\t\t\t\tsource.add(keyAdded)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.relations.set(key, value)\n\t\t\t}\n\t\t}\n\t\tfor (const key of relations.deleted) {\n\t\t\tthis.relations.delete(key)\n\t\t}\n\t\tfor (const [key, value] of contents) {\n\t\t\tthis.contents.set(key, value)\n\t\t}\n\t\tfor (const key of contents.deleted) {\n\t\t\tthis.contents.delete(key)\n\t\t}\n\t}\n}\n\nexport type JunctionOverlay<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tContent extends Json.Object | null = null,\n> = Junction<AName, A, BName, B, Content> & {\n\trelations: MapOverlay<A | B, Set<A> | Set<B>>\n\tcontents: MapOverlay<string, Content>\n}\n", "export type ReservedIntrospectionKey = `🔍 ${string}`\n\nexport function isReservedIntrospectionKey(\n\tvalue: string,\n): value is ReservedIntrospectionKey {\n\treturn value.startsWith(`🔍 `)\n}\n", "import type { ChildStore } from \"./is-root-store\"\n\nexport const abortTransaction = (target: ChildStore): void => {\n\ttarget.logger.info(\n\t\t`🪂`,\n\t\t`transaction`,\n\t\ttarget.transactionMeta.update.token.key,\n\t\t`Aborting transaction`,\n\t)\n\ttarget.parent.child = null\n}\n", "import type { TransactionToken } from \"atom.io\"\n\nimport type { Store } from \"../store\"\nimport { withdraw } from \"../store\"\nimport type { Fn } from \"../utility-types\"\n\nexport function actUponStore<F extends Fn>(\n\tstore: Store,\n\ttoken: TransactionToken<F>,\n\tid: string,\n): (...parameters: Parameters<F>) => ReturnType<F> {\n\treturn (...parameters: Parameters<F>): ReturnType<F> => {\n\t\tconst tx = withdraw(store, token)\n\t\treturn tx.run(parameters, id)\n\t}\n}\n", "import type { AtomUpdateEvent } from \"atom.io\"\n\nimport { setIntoStore } from \"../set-state\"\nimport type { Store } from \"../store\"\n\nexport function ingestAtomUpdateEvent(\n\tstore: Store,\n\tevent: AtomUpdateEvent<any>,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tconst {\n\t\ttoken,\n\t\tupdate: { newValue, oldValue },\n\t} = event\n\tconst value = applying === `newValue` ? newValue : oldValue\n\tsetIntoStore(store, token, value)\n}\n", "export function getTrace(error: Error): string {\n\tconst { stack } = error\n\tif (stack) {\n\t\treturn `\\n` + stack.split(`\\n`)?.slice(1)?.join(`\\n`)\n\t}\n\treturn ``\n}\n", "import {\n\ttype Above,\n\ttype CompoundFrom,\n\ttype CompoundTypedKey,\n\tdecomposeCompound,\n\ttype Hierarchy,\n\ttype MoleculeCreationEvent,\n\ttype MoleculeDisposalEvent,\n\ttype MoleculeTransferEvent,\n\tsimpleCompound,\n\ttype SingularTypedKey,\n\ttype TransactionToken,\n\ttype ValidKey,\n\ttype Vassal,\n} from \"atom.io\"\nimport type { Canonical, stringified } from \"atom.io/json\"\nimport { parseJson, stringifyJson } from \"atom.io/json\"\n\nimport { disposeFromStore } from \"./families\"\nimport { getFromStore } from \"./get-state\"\nimport { getTrace } from \"./get-trace\"\nimport { newest } from \"./lineage\"\nimport type { Store } from \"./store\"\nimport { Subject } from \"./subject\"\nimport type { RootStore } from \"./transaction\"\nimport { createTransaction, isChildStore } from \"./transaction\"\n\nexport type Molecule<K extends Canonical> = {\n\treadonly key: K\n\treadonly stringKey: stringified<K>\n\treadonly dependsOn: `all` | `any`\n\treadonly subject: Subject<void>\n}\n\nexport function makeRootMoleculeInStore<S extends string>(\n\tstore: Store,\n\tkey: S,\n): S {\n\tconst molecule = {\n\t\tkey,\n\t\tstringKey: stringifyJson(key),\n\t\tdependsOn: `any`,\n\t\tsubject: new Subject(),\n\t} satisfies Molecule<S>\n\tstore.molecules.set(stringifyJson(key), molecule)\n\treturn key\n}\n\nexport function allocateIntoStore<\n\tH extends Hierarchy,\n\tV extends Vassal<H>,\n\tA extends Above<V, H>,\n>(\n\tstore: Store,\n\tprovenance: A,\n\tkey: V,\n\tdependsOn: `all` | `any` = `any`,\n): ValidKey<V> {\n\tconst origin = provenance as Canonical | [Canonical, Canonical]\n\tconst stringKey = stringifyJson(key)\n\tconst invalidKeys: stringified<Canonical>[] = []\n\tconst target = newest(store)\n\n\tif (Array.isArray(origin)) {\n\t\tfor (const formerClaim of origin) {\n\t\t\tconst claimString = stringifyJson(formerClaim)\n\t\t\tconst claim = target.molecules.get(claimString)\n\t\t\tif (claim) {\n\t\t\t\tstore.moleculeGraph.set(claimString, stringKey, { source: claimString })\n\t\t\t} else {\n\t\t\t\tinvalidKeys.push(claimString)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst claimString = stringifyJson(origin)\n\t\tconst claim = target.molecules.get(claimString)\n\t\tif (claim) {\n\t\t\tstore.moleculeGraph.set(claimString, stringKey, { source: claimString })\n\t\t} else {\n\t\t\tinvalidKeys.push(claimString)\n\t\t}\n\t}\n\tconst subject = new Subject<void>()\n\tif (invalidKeys.length === 0) {\n\t\ttarget.molecules.set(stringKey, { key, stringKey, dependsOn, subject })\n\t}\n\n\tconst creationEvent: MoleculeCreationEvent = {\n\t\ttype: `molecule_creation`,\n\t\tkey,\n\t\tprovenance: origin,\n\t\ttimestamp: Date.now(),\n\t}\n\tconst isTransaction =\n\t\tisChildStore(target) && target.transactionMeta.phase === `building`\n\tif (isTransaction) {\n\t\ttarget.transactionMeta.update.subEvents.push(creationEvent)\n\t} else {\n\t\ttarget.on.moleculeCreation.next(creationEvent)\n\t}\n\n\tfor (const claim of invalidKeys) {\n\t\tconst disposal = store.disposalTraces.buffer.find(\n\t\t\t(item) => item?.key === claim,\n\t\t)\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\t`key`,\n\t\t\tkey,\n\t\t\t`allocation failed:`,\n\t\t\t`Could not allocate to ${claim} in store \"${store.config.name}\".`,\n\t\t\tdisposal\n\t\t\t\t? `\\n ${claim} was most recently disposed\\n${disposal.trace}`\n\t\t\t\t: `No previous disposal trace for ${claim} was found.`,\n\t\t)\n\t}\n\n\treturn key as ValidKey<V>\n}\n\nexport function fuseWithinStore<\n\tH extends Hierarchy,\n\tC extends CompoundFrom<H>,\n\tT extends C extends CompoundTypedKey<infer t, any, any> ? t : never,\n\tA extends C extends CompoundTypedKey<any, infer a, any> ? a : never,\n\tB extends C extends CompoundTypedKey<any, any, infer b> ? b : never,\n>(\n\tstore: Store,\n\ttype: T,\n\tsideA: SingularTypedKey<A>,\n\tsideB: SingularTypedKey<B>,\n): ValidKey<CompoundTypedKey<T, A, B>> {\n\tconst compoundKey: CompoundTypedKey<T, A, B> =\n\t\t`T$--${type}==${sideA}++${sideB}`\n\tconst above = [sideA, sideB] as Above<Vassal<H>, H>\n\tallocateIntoStore<H, Vassal<H>, Above<Vassal<H>, H>>(\n\t\tstore,\n\t\tabove,\n\t\tcompoundKey as Vassal<H>,\n\t\t`all`,\n\t)\n\treturn compoundKey\n}\n\nexport function createDeallocateTX<\n\tH extends Hierarchy,\n\tV extends Exclude<Vassal<H>, CompoundTypedKey>,\n>(store: RootStore): TransactionToken<(claim: ValidKey<V>) => void> {\n\treturn createTransaction(store, {\n\t\tkey: `[Internal] deallocate`,\n\t\tdo: (_, claim: ValidKey<V>): void => {\n\t\t\tdeallocateFromStore<H, V>(newest(store), claim)\n\t\t},\n\t})\n}\n\nexport function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>>(\n\ttarget: Store,\n\tclaim: ValidKey<V>,\n): void {\n\tconst stringKey = stringifyJson(claim)\n\n\tconst molecule = target.molecules.get(stringKey)\n\tif (!molecule) {\n\t\tconst disposal = target.disposalTraces.buffer.find(\n\t\t\t(item) => item?.key === stringKey,\n\t\t)\n\t\ttarget.logger.error(\n\t\t\t`❌`,\n\t\t\t`key`,\n\t\t\tclaim,\n\t\t\t`deallocation failed:`,\n\t\t\t`Could not find allocation for ${stringKey} in store \"${target.config.name}\".`,\n\t\t\tdisposal\n\t\t\t\t? `\\n This state was most recently deallocated\\n${disposal.trace}`\n\t\t\t\t: `No previous disposal trace for ${stringKey} was found.`,\n\t\t)\n\t\treturn\n\t}\n\tmolecule.subject.next()\n\n\tconst joinKeys = target.keyRefsInJoins.getRelatedKeys(stringKey)\n\tif (joinKeys) {\n\t\tfor (const joinKey of joinKeys) {\n\t\t\tconst join = target.joins.get(joinKey)\n\t\t\tif (join) {\n\t\t\t\tjoin.relations.delete(claim)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst compound = decomposeCompound(claim)\n\t\tif (compound) {\n\t\t\tconst [, a, b] = compound\n\t\t\tconst joinKey = target.keyRefsInJoins.getRelatedKey(simpleCompound(a, b))\n\t\t\tif (joinKey) {\n\t\t\t\tconst join = target.joins.get(joinKey)\n\t\t\t\tif (join) {\n\t\t\t\t\tjoin.relations.delete(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\ttarget.keyRefsInJoins.delete(stringKey)\n\n\tconst provenance: stringified<Canonical>[] = []\n\n\tconst values: [string, any][] = []\n\n\tconst relatedMolecules = target.moleculeGraph.getRelationEntries({\n\t\tdownstreamMoleculeKey: stringKey,\n\t})\n\tif (relatedMolecules) {\n\t\tfor (const [relatedStringKey, { source }] of relatedMolecules) {\n\t\t\tif (source === stringKey) {\n\t\t\t\tconst relatedKey = parseJson(relatedStringKey)\n\t\t\t\tdeallocateFromStore<any, any>(target, relatedKey)\n\t\t\t} else {\n\t\t\t\tprovenance.push(source)\n\t\t\t}\n\t\t}\n\t}\n\tconst familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey)\n\tif (familyKeys) {\n\t\tfor (const familyKey of familyKeys) {\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: tokens of molecules must have a family\n\t\t\tconst family = target.families.get(familyKey)!\n\t\t\tconst value = getFromStore(target, family, claim)\n\t\t\tvalues.push([family.key, value])\n\t\t\tdisposeFromStore(target, family, claim)\n\t\t}\n\t}\n\tconst disposalEvent: MoleculeDisposalEvent = {\n\t\ttype: `molecule_disposal`,\n\t\tkey: molecule.key,\n\t\tvalues,\n\t\tprovenance,\n\t\ttimestamp: Date.now(),\n\t}\n\ttarget.molecules.delete(stringKey)\n\tconst isTransaction =\n\t\tisChildStore(target) && target.transactionMeta.phase === `building`\n\tif (isTransaction) {\n\t\ttarget.transactionMeta.update.subEvents.push(disposalEvent)\n\t}\n\n\ttarget.moleculeGraph.delete(molecule.stringKey)\n\ttarget.keyRefsInJoins.delete(molecule.stringKey)\n\ttarget.moleculeData.delete(molecule.stringKey)\n\n\tif (!isTransaction) {\n\t\ttarget.on.moleculeDisposal.next(disposalEvent)\n\t}\n\ttarget.molecules.delete(molecule.stringKey)\n\n\tconst trace = getTrace(new Error())\n\ttarget.disposalTraces.add({ key: stringKey, trace })\n}\n\nexport function createClaimTX<\n\tH extends Hierarchy,\n\tV extends Exclude<Vassal<H>, CompoundTypedKey>,\n\tA extends Above<V, H>,\n>(\n\tstore: RootStore,\n): TransactionToken<\n\t(newProvenance: A, claim: ValidKey<V>, exclusive?: `exclusive`) => void\n> {\n\treturn createTransaction(store, {\n\t\tkey: `[Internal] claim`,\n\t\tdo: (_, newProvenance, claim, exclusive) => {\n\t\t\tclaimWithinStore<H, V, A>(store, newProvenance, claim, exclusive)\n\t\t},\n\t})\n}\n\nexport function claimWithinStore<\n\tH extends Hierarchy,\n\tV extends Exclude<Vassal<H>, CompoundTypedKey>,\n\tA extends Above<V, H>,\n>(\n\tstore: Store,\n\tnewProvenance: A,\n\tclaim: ValidKey<V>,\n\texclusive?: `exclusive`,\n): ValidKey<V> {\n\tconst stringKey = stringifyJson(claim)\n\tconst target = newest(store)\n\tconst molecule = target.molecules.get(stringKey)\n\tif (!molecule) {\n\t\tconst disposal = store.disposalTraces.buffer.find(\n\t\t\t(item) => item?.key === stringKey,\n\t\t)\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\t`key`,\n\t\t\tstringKey,\n\t\t\t`claim failed:`,\n\t\t\t`Could not allocate to ${stringKey} in store \"${store.config.name}\".`,\n\t\t\tdisposal\n\t\t\t\t? `\\n ${stringKey} was most recently disposed\\n${disposal.trace}`\n\t\t\t\t: `No previous disposal trace for ${stringKey} was found.`,\n\t\t)\n\t\treturn claim\n\t}\n\n\tconst newProvenanceKey = stringifyJson(newProvenance as Canonical)\n\tconst newProvenanceMolecule = target.molecules.get(newProvenanceKey)\n\tif (!newProvenanceMolecule) {\n\t\tconst disposal = store.disposalTraces.buffer.find(\n\t\t\t(item) => item?.key === newProvenanceKey,\n\t\t)\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\t`key`,\n\t\t\tclaim,\n\t\t\t`claim failed:`,\n\t\t\t`Could not allocate to ${newProvenanceKey} in store \"${store.config.name}\".`,\n\t\t\tdisposal\n\t\t\t\t? `\\n ${newProvenanceKey} was most recently disposed\\n${disposal.trace}`\n\t\t\t\t: `No previous disposal trace for ${newProvenanceKey} was found.`,\n\t\t)\n\t\treturn claim\n\t}\n\n\tconst priorProvenance = store.moleculeGraph\n\t\t.getRelationEntries({\n\t\t\tdownstreamMoleculeKey: molecule.stringKey,\n\t\t})\n\t\t.filter(([, { source }]) => source !== stringKey)\n\t\t.map(([key]) => parseJson(key))\n\tif (exclusive) {\n\t\ttarget.moleculeGraph.delete(stringKey)\n\t}\n\ttarget.moleculeGraph.set(\n\t\t{\n\t\t\tupstreamMoleculeKey: newProvenanceMolecule.stringKey,\n\t\t\tdownstreamMoleculeKey: molecule.stringKey,\n\t\t},\n\t\t{\n\t\t\tsource: newProvenanceMolecule.stringKey,\n\t\t},\n\t)\n\tconst transferEvent: MoleculeTransferEvent = {\n\t\ttype: `molecule_transfer`,\n\t\tkey: molecule.key,\n\t\texclusive: Boolean(exclusive),\n\t\tfrom: priorProvenance,\n\t\tto: [newProvenanceMolecule.key],\n\t\ttimestamp: Date.now(),\n\t}\n\tconst isTransaction =\n\t\tisChildStore(target) && target.transactionMeta.phase === `building`\n\tif (isTransaction) {\n\t\ttarget.transactionMeta.update.subEvents.push(transferEvent)\n\t}\n\n\treturn claim\n}\n", "import type {\n\tMoleculeCreationEvent,\n\tMoleculeDisposalEvent,\n\tMoleculeTransferEvent,\n\tReadableToken,\n\tStateCreationEvent,\n\tStateDisposalEvent,\n} from \"atom.io\"\nimport { parseJson, stringifyJson } from \"atom.io/json\"\n\nimport { disposeFromStore } from \"../families\"\nimport { getFromStore } from \"../get-state\"\nimport {\n\tallocateIntoStore,\n\tclaimWithinStore,\n\tdeallocateFromStore,\n} from \"../molecule\"\nimport { setIntoStore } from \"../set-state\"\nimport type { Store } from \"../store\"\n\nexport function ingestCreationEvent(\n\tstore: Store,\n\tevent: StateCreationEvent<any>,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tswitch (applying) {\n\t\tcase `newValue`: {\n\t\t\tcreateInStore(store, event)\n\t\t\tbreak\n\t\t}\n\t\tcase `oldValue`: {\n\t\t\tdisposeFromStore(store, event.token)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nexport function ingestDisposalEvent(\n\tstore: Store,\n\tevent: StateDisposalEvent<ReadableToken<any, any, any>>,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tswitch (applying) {\n\t\tcase `newValue`: {\n\t\t\tdisposeFromStore(store, event.token)\n\t\t\tbreak\n\t\t}\n\t\tcase `oldValue`: {\n\t\t\tcreateInStore(store, event)\n\t\t\tif (event.subType === `atom`) {\n\t\t\t\tstore.valueMap.set(event.token.key, event.value)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n}\n\nfunction createInStore(\n\tstore: Store,\n\tevent: StateCreationEvent<any> | StateDisposalEvent<any>,\n): void {\n\tconst { token } = event\n\tif (event.subType === `writable` && event.value) {\n\t\tsetIntoStore(store, token, event.value)\n\t} else {\n\t\tgetFromStore(store, token)\n\t}\n}\n\nexport function ingestMoleculeCreationEvent(\n\tstore: Store,\n\tevent: MoleculeCreationEvent,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tswitch (applying) {\n\t\tcase `newValue`:\n\t\t\tallocateIntoStore<any, any, any>(store, event.provenance, event.key)\n\t\t\tbreak\n\n\t\tcase `oldValue`:\n\t\t\tdeallocateFromStore<any, any>(store, event.key)\n\t\t\tbreak\n\t}\n}\nexport function ingestMoleculeDisposalEvent(\n\tstore: Store,\n\tevent: MoleculeDisposalEvent,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tswitch (applying) {\n\t\tcase `newValue`:\n\t\t\tdeallocateFromStore<any, any>(store, event.key)\n\t\t\tbreak\n\n\t\tcase `oldValue`:\n\t\t\t{\n\t\t\t\tconst provenanceJson = event.provenance.map(parseJson)\n\t\t\t\tallocateIntoStore<any, any, any>(store, provenanceJson, event.key)\n\t\t\t\tfor (const [familyKey, value] of event.values) {\n\t\t\t\t\tconst family = store.families.get(familyKey)\n\t\t\t\t\tif (family) {\n\t\t\t\t\t\tgetFromStore(store, family, event.key)\n\t\t\t\t\t\tconst memberKey = `${familyKey}(${stringifyJson(event.key)})`\n\t\t\t\t\t\tstore.valueMap.set(memberKey, value)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t}\n}\nexport function ingestMoleculeTransferEvent(\n\tstore: Store,\n\tevent: MoleculeTransferEvent,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tswitch (applying) {\n\t\tcase `newValue`:\n\t\t\t{\n\t\t\t\tfor (const newOwner of event.to) {\n\t\t\t\t\tclaimWithinStore<any, any, any>(\n\t\t\t\t\t\tstore,\n\t\t\t\t\t\tnewOwner,\n\t\t\t\t\t\tevent.key,\n\t\t\t\t\t\tevent.exclusive ? `exclusive` : undefined,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\tcase `oldValue`:\n\t\t\t{\n\t\t\t\tlet exclusivity: `exclusive` | undefined = `exclusive`\n\t\t\t\tfor (const previousOwner of event.from) {\n\t\t\t\t\tclaimWithinStore<any, any, any>(\n\t\t\t\t\t\tstore,\n\t\t\t\t\t\tpreviousOwner,\n\t\t\t\t\t\tevent.key,\n\t\t\t\t\t\texclusivity,\n\t\t\t\t\t)\n\t\t\t\t\texclusivity = undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t}\n}\n", "import type {\n\tAtomOnly,\n\tAtomUpdateEvent,\n\tStateCreationEvent,\n\tTimelineManageable,\n\tTimelineSelectorUpdateEvent,\n} from \"atom.io\"\n\nimport type { Store } from \"../store\"\nimport { ingestAtomUpdateEvent } from \"./ingest-atom-update\"\nimport { ingestCreationEvent } from \"./ingest-creation-disposal\"\n\nexport function ingestSelectorUpdateEvent(\n\tstore: Store,\n\tselectorUpdate: TimelineSelectorUpdateEvent<any>,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tlet updates: (\n\t\t| AtomUpdateEvent<AtomOnly<TimelineManageable>>\n\t\t| StateCreationEvent<any>\n\t)[]\n\tif (applying === `newValue`) {\n\t\tupdates = selectorUpdate.subEvents\n\t} else {\n\t\tupdates = selectorUpdate.subEvents.toReversed()\n\t}\n\tfor (const atomUpdate of updates) {\n\t\tif (atomUpdate.type === `state_creation`) {\n\t\t\tingestCreationEvent(store, atomUpdate, applying)\n\t\t} else {\n\t\t\tingestAtomUpdateEvent(store, atomUpdate, applying)\n\t\t}\n\t}\n}\n", "import type { TransactionOutcomeEvent } from \"atom.io\"\n\nimport type { Store } from \"../store\"\nimport { ingestAtomUpdateEvent } from \"./ingest-atom-update\"\nimport {\n\tingestCreationEvent,\n\tingestDisposalEvent,\n\tingestMoleculeCreationEvent,\n\tingestMoleculeDisposalEvent,\n\tingestMoleculeTransferEvent,\n} from \"./ingest-creation-disposal\"\n\nexport function ingestTransactionOutcomeEvent(\n\tstore: Store,\n\tevent: TransactionOutcomeEvent<any>,\n\tapplying: `newValue` | `oldValue`,\n): void {\n\tconst subEvents =\n\t\tapplying === `newValue` ? event.subEvents : [...event.subEvents].reverse()\n\tfor (const subEvent of subEvents) {\n\t\tswitch (subEvent.type) {\n\t\t\tcase `atom_update`:\n\t\t\t\tingestAtomUpdateEvent(store, subEvent, applying)\n\t\t\t\tbreak\n\t\t\tcase `state_creation`:\n\t\t\t\tingestCreationEvent(store, subEvent, applying)\n\t\t\t\tbreak\n\t\t\tcase `state_disposal`:\n\t\t\t\tingestDisposalEvent(store, subEvent, applying)\n\t\t\t\tbreak\n\t\t\tcase `molecule_creation`:\n\t\t\t\tingestMoleculeCreationEvent(store, subEvent, applying)\n\t\t\t\tbreak\n\t\t\tcase `molecule_disposal`:\n\t\t\t\tingestMoleculeDisposalEvent(store, subEvent, applying)\n\t\t\t\tbreak\n\t\t\tcase `molecule_transfer`:\n\t\t\t\tingestMoleculeTransferEvent(store, subEvent, applying)\n\t\t\t\tbreak\n\t\t\tcase `transaction_outcome`:\n\t\t\t\tingestTransactionOutcomeEvent(store, subEvent, applying)\n\t\t\t\tbreak\n\t\t}\n\t}\n}\n", "import type { MapOverlay } from \"../overlays/map-overlay\"\nimport type { Store } from \"../store\"\nimport type { Fn } from \"../utility-types\"\nimport type {\n\tTransactionEpoch,\n\tTransactionProgress,\n} from \"./transaction-meta-progress\"\n\nexport interface RootStore extends Store {\n\ttransactionMeta: TransactionEpoch\n\tparent: null\n\tchild: ChildStore | null\n}\nexport interface ChildStore extends Store {\n\ttransactionMeta: TransactionProgress<Fn>\n\tparent: ChildStore | RootStore\n\tchild: ChildStore | null\n\tvalueMap: MapOverlay<string, any>\n}\n\nexport function isRootStore(store: Store): store is RootStore {\n\treturn `epoch` in store.transactionMeta\n}\n\nexport function isChildStore(store: Store): store is ChildStore {\n\treturn `phase` in store.transactionMeta\n}\n", "import type { RootStore } from \"./is-root-store\"\n\nexport function getContinuityKey(\n\tstore: RootStore,\n\ttransactionKey: string,\n): string | undefined {\n\tconst continuity =\n\t\tstore.transactionMeta.actionContinuities.getRelatedKey(transactionKey)\n\n\treturn continuity\n}\n\nexport function getEpochNumberOfContinuity(\n\tstore: RootStore,\n\tcontinuityKey: string,\n): number | undefined {\n\tconst epoch = store.transactionMeta.epoch.get(continuityKey)\n\treturn epoch\n}\n\nexport function getEpochNumberOfAction(\n\tstore: RootStore,\n\ttransactionKey: string,\n): number | undefined {\n\tconst continuityKey = getContinuityKey(store, transactionKey)\n\tif (continuityKey === undefined) {\n\t\treturn undefined\n\t}\n\treturn getEpochNumberOfContinuity(store, continuityKey)\n}\n", "import { getContinuityKey } from \"./get-epoch-number\"\nimport type { RootStore } from \"./is-root-store\"\n\nexport function setEpochNumberOfContinuity(\n\tstore: RootStore,\n\tcontinuityKey: string,\n\tnewEpoch: number,\n): void {\n\tstore.transactionMeta.epoch.set(continuityKey, newEpoch)\n}\n\nexport function setEpochNumberOfAction(\n\tstore: RootStore,\n\ttransactionKey: string,\n\tnewEpoch: number,\n): void {\n\tconst continuityKey = getContinuityKey(store, transactionKey)\n\n\tif (continuityKey !== undefined) {\n\t\tstore.transactionMeta.epoch.set(continuityKey, newEpoch)\n\t}\n}\n", "import { ingestTransactionOutcomeEvent } from \"../events\"\nimport { newest } from \"../lineage\"\nimport { withdraw } from \"../store\"\nimport type { Fn } from \"../utility-types\"\nimport type { ChildStore } from \"./is-root-store\"\nimport { isChildStore, isRootStore } from \"./is-root-store\"\nimport { setEpochNumberOfAction } from \"./set-epoch-number\"\n\nexport function applyTransaction<F extends Fn>(\n\tstore: ChildStore,\n\toutput: ReturnType<F>,\n): void {\n\tconst child = newest(store)\n\tconst { parent } = child\n\n\tchild.transactionMeta.phase = `applying`\n\tchild.transactionMeta.update.output = output\n\tparent.child = null\n\tparent.on.transactionApplying.next(child.transactionMeta)\n\tconst { subEvents: updates } = child.transactionMeta.update\n\tstore.logger.info(\n\t\t`🛄`,\n\t\t`transaction`,\n\t\tchild.transactionMeta.update.token.key,\n\t\t`applying ${updates.length} subEvents:`,\n\t\tupdates,\n\t)\n\n\tingestTransactionOutcomeEvent(parent, child.transactionMeta.update, `newValue`)\n\n\tif (isRootStore(parent)) {\n\t\tsetEpochNumberOfAction(\n\t\t\tparent,\n\t\t\tchild.transactionMeta.update.token.key,\n\t\t\tchild.transactionMeta.update.epoch,\n\t\t)\n\t\tconst myTransaction = withdraw<Fn>(store, {\n\t\t\tkey: child.transactionMeta.update.token.key,\n\t\t\ttype: `transaction`,\n\t\t})\n\t\tmyTransaction?.subject.next(child.transactionMeta.update)\n\t\tstore.logger.info(\n\t\t\t`🛬`,\n\t\t\t`transaction`,\n\t\t\tchild.transactionMeta.update.token.key,\n\t\t\t`applied`,\n\t\t)\n\t} else if (isChildStore(parent)) {\n\t\tparent.transactionMeta.update.subEvents.push(child.transactionMeta.update)\n\t}\n\tparent.on.transactionApplying.next(null)\n}\n", "import type { RootStore } from \"./is-root-store\"\n\nexport function assignTransactionToContinuity(\n\tstore: RootStore,\n\tcontinuityKey: string,\n\ttransactionKey: string,\n): void {\n\tconst { epoch, actionContinuities } = store.transactionMeta\n\tactionContinuities.set(continuityKey, transactionKey)\n\tif (!epoch.has(continuityKey)) {\n\t\tepoch.set(continuityKey, -1)\n\t}\n}\n", "import type { Store } from \"./store\"\n\nexport type EnvironmentData = {\n\tstore: Store\n}\n\nexport function getEnvironmentData(store: Store): EnvironmentData {\n\treturn {\n\t\tstore,\n\t}\n}\n", "import type {\n\tdisposeState,\n\tfindState,\n\tgetState,\n\tresetState,\n\tsetState,\n\tTransactionToken,\n} from \"atom.io\"\n\nimport { arbitrary } from \"../arbitrary\"\nimport { disposeFromStore, findInStore } from \"../families\"\nimport { getEnvironmentData } from \"../get-environment-data\"\nimport { getFromStore } from \"../get-state\"\nimport { newest } from \"../lineage\"\nimport { getJsonToken } from \"../mutable\"\nimport { MapOverlay } from \"../overlays/map-overlay\"\nimport { resetInStore, setIntoStore } from \"../set-state\"\nimport type { Fn } from \"../utility-types\"\nimport { actUponStore } from \"./act-upon-store\"\nimport { getEpochNumberOfAction } from \"./get-epoch-number\"\nimport type { ChildStore, RootStore } from \"./is-root-store\"\nimport type { TransactionProgress } from \"./transaction-meta-progress\"\n\nexport const buildTransaction = (\n\tstore: RootStore,\n\ttoken: TransactionToken<any>,\n\tparams: any[],\n\tid: string,\n): ChildStore => {\n\tconst parent = newest(store)\n\tconst childBase: Omit<ChildStore, `transactionMeta`> = {\n\t\tparent,\n\t\tchild: null,\n\t\ton: parent.on,\n\t\tloggers: parent.loggers,\n\t\tlogger: parent.logger,\n\t\tconfig: parent.config,\n\t\tatoms: new MapOverlay(parent.atoms),\n\t\tatomsThatAreDefault: new Set(parent.atomsThatAreDefault),\n\t\tfamilies: new MapOverlay(parent.families),\n\t\tjoins: new MapOverlay(parent.joins),\n\t\toperation: { open: false },\n\t\treadonlySelectors: new MapOverlay(parent.readonlySelectors),\n\t\ttimelines: new MapOverlay(parent.timelines),\n\t\ttimelineTopics: parent.timelineTopics.overlay(),\n\t\ttrackers: new Map(),\n\t\ttransactions: new MapOverlay(parent.transactions),\n\t\tselectorAtoms: parent.selectorAtoms.overlay(),\n\t\tselectorGraph: parent.selectorGraph.overlay(),\n\t\twritableSelectors: new MapOverlay(parent.writableSelectors),\n\t\tvalueMap: new MapOverlay(parent.valueMap),\n\t\tdefaults: parent.defaults,\n\t\tdisposalTraces: store.disposalTraces.copy(),\n\t\tmolecules: new MapOverlay(parent.molecules),\n\t\tmoleculeGraph: parent.moleculeGraph.overlay(),\n\t\tmoleculeData: parent.moleculeData.overlay(),\n\t\tkeyRefsInJoins: parent.keyRefsInJoins.overlay(),\n\t\tmiscResources: new MapOverlay(parent.miscResources),\n\t}\n\tconst epoch = getEpochNumberOfAction(store, token.key)\n\tconst transactionMeta: TransactionProgress<Fn> = {\n\t\tphase: `building`,\n\t\tupdate: {\n\t\t\ttype: `transaction_outcome`,\n\t\t\ttoken,\n\t\t\tid,\n\t\t\tepoch: epoch === undefined ? Number.NaN : epoch + 1,\n\t\t\ttimestamp: Date.now(),\n\t\t\tsubEvents: [],\n\t\t\tparams,\n\t\t\toutput: undefined,\n\t\t},\n\t\ttoolkit: {\n\t\t\tget: ((...ps: Parameters<typeof getState>) =>\n\t\t\t\tgetFromStore(child, ...ps)) as typeof getState,\n\t\t\tset: ((...ps: Parameters<typeof setState>) => {\n\t\t\t\tsetIntoStore(child, ...ps)\n\t\t\t}) as typeof setState,\n\t\t\treset: ((...ps: Parameters<typeof resetState>) => {\n\t\t\t\tresetInStore(child, ...ps)\n\t\t\t}) as typeof resetState,\n\t\t\trun: (t, identifier = arbitrary()) => actUponStore(child, t, identifier),\n\t\t\tfind: ((...ps: Parameters<typeof findState>) =>\n\t\t\t\tfindInStore(store, ...ps)) as typeof findState,\n\t\t\tjson: (t) => getJsonToken(child, t),\n\t\t\tdispose: ((...ps: Parameters<typeof disposeState>) => {\n\t\t\t\tdisposeFromStore(child, ...ps)\n\t\t\t}) as typeof disposeState,\n\t\t\tenv: () => getEnvironmentData(child),\n\t\t},\n\t}\n\tconst child: ChildStore = Object.assign(childBase, {\n\t\ttransactionMeta,\n\t})\n\tparent.child = child\n\tstore.logger.info(\n\t\t`🛫`,\n\t\t`transaction`,\n\t\ttoken.key,\n\t\t`building with params:`,\n\t\tparams,\n\t)\n\treturn child\n}\n", "import type {\n\tTransactionOptions,\n\tTransactionOutcomeEvent,\n\tTransactionToken,\n} from \"atom.io\"\n\nimport { newest } from \"../lineage\"\nimport { deposit } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { Fn } from \"../utility-types\"\nimport { abortTransaction } from \"./abort-transaction\"\nimport { applyTransaction } from \"./apply-transaction\"\nimport { buildTransaction } from \"./build-transaction\"\nimport type { RootStore } from \"./is-root-store\"\n\nexport type Transaction<F extends Fn> = {\n\tkey: string\n\ttype: `transaction`\n\tinstall: (store: RootStore) => void\n\tsubject: Subject<TransactionOutcomeEvent<TransactionToken<F>>>\n\trun: (parameters: Parameters<F>, id?: string) => ReturnType<F>\n}\n\nexport function createTransaction<F extends Fn>(\n\tstore: RootStore,\n\toptions: TransactionOptions<F>,\n): TransactionToken<F> {\n\tconst { key } = options\n\tconst transactionAlreadyExists = store.transactions.has(key)\n\tconst newTransaction: Transaction<F> = {\n\t\tkey,\n\t\ttype: `transaction`,\n\t\trun: (params: Parameters<F>, id: string) => {\n\t\t\tconst token = deposit(newTransaction)\n\t\t\tconst target = buildTransaction(store, token, params, id)\n\t\t\ttry {\n\t\t\t\tconst { toolkit } = target.transactionMeta\n\t\t\t\tconst output = options.do(toolkit, ...params)\n\t\t\t\tapplyTransaction<F>(target, output)\n\t\t\t\treturn output\n\t\t\t} catch (thrown) {\n\t\t\t\tabortTransaction(target)\n\t\t\t\tstore.logger.warn(`💥`, `transaction`, key, `caught:`, thrown)\n\t\t\t\tthrow thrown\n\t\t\t}\n\t\t},\n\t\tinstall: (s) => createTransaction(s, options),\n\t\tsubject: new Subject(),\n\t}\n\tconst target = newest(store)\n\ttarget.transactions.set(key, newTransaction)\n\tconst token = deposit(newTransaction)\n\tif (!transactionAlreadyExists) {\n\t\tstore.on.transactionCreation.next(token)\n\t}\n\treturn token\n}\n", "import type {\n\tActorToolkit,\n\tTransactionOutcomeEvent,\n\tTransactionToken,\n} from \"atom.io\"\n\nimport type { Junction } from \"../junction\"\nimport type { Fn } from \"../utility-types\"\n\nexport const TRANSACTION_PHASES = [`idle`, `building`, `applying`] as const\nexport type TransactionPhase = (typeof TRANSACTION_PHASES)[number]\n\nexport type TransactionProgress<F extends Fn> = {\n\tphase: `applying` | `building`\n\tupdate: TransactionOutcomeEvent<TransactionToken<F>>\n\ttoolkit: ActorToolkit\n}\n\nexport type TransactionEpoch = {\n\tepoch: Map<string, number>\n\tactionContinuities: Junction<`continuity`, string, `action`, string>\n}\n", "import type {\n\tAtomToken,\n\tLogger,\n\tMoleculeCreationEvent,\n\tMoleculeDisposalEvent,\n\tSelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n} from \"atom.io\"\nimport { AtomIOLogger } from \"atom.io\"\nimport type { Canonical, stringified } from \"atom.io/json\"\n\nimport type { Join } from \"../join\"\nimport { Junction } from \"../junction\"\nimport type { Lineage } from \"../lineage\"\nimport type { Molecule } from \"../molecule\"\nimport type { Tracker, Transceiver } from \"../mutable\"\nimport { getJsonToken, getUpdateToken } from \"../mutable\"\nimport type { OperationProgress } from \"../operation\"\nimport { isReservedIntrospectionKey } from \"../reserved-keys\"\nimport type {\n\tAtom,\n\tHeldSelectorFamily,\n\tMutableAtomFamily,\n\tPureSelectorFamily,\n\tReadonlySelector,\n\tRegularAtomFamily,\n\tWritableSelector,\n} from \"../state-types\"\nimport { StatefulSubject, Subject } from \"../subject\"\nimport type { Timeline } from \"../timeline\"\nimport type {\n\tChildStore,\n\tRootStore,\n\tTransaction,\n\tTransactionEpoch,\n\tTransactionProgress,\n} from \"../transaction\"\nimport { isRootStore } from \"../transaction\"\nimport type { Fn } from \"../utility-types\"\nimport { CircularBuffer } from \"./circular-buffer\"\n\nexport class Store implements Lineage {\n\tpublic parent: ChildStore | RootStore | null = null\n\tpublic child: ChildStore | null = null\n\n\tpublic valueMap: Map<string, any> = new Map()\n\tpublic defaults: Map<string, any> = new Map()\n\n\tpublic atoms: Map<string, Atom<any, any>> = new Map()\n\tpublic writableSelectors: Map<string, WritableSelector<any, any>> = new Map()\n\tpublic readonlySelectors: Map<string, ReadonlySelector<any, any>> = new Map()\n\n\tpublic atomsThatAreDefault: Set<string> = new Set()\n\tpublic selectorAtoms: Junction<`selectorKey`, string, `atomKey`, string> =\n\t\tnew Junction({\n\t\t\tbetween: [`selectorKey`, `atomKey`],\n\t\t\tcardinality: `n:n`,\n\t\t})\n\tpublic selectorGraph: Junction<\n\t\t`upstreamSelectorKey`,\n\t\tstring,\n\t\t`downstreamSelectorKey`,\n\t\tstring,\n\t\t{ source: string }\n\t> = new Junction(\n\t\t{\n\t\t\tbetween: [`upstreamSelectorKey`, `downstreamSelectorKey`],\n\t\t\tcardinality: `n:n`,\n\t\t},\n\t\t{\n\t\t\tmakeContentKey: (...keys) => keys.sort().join(`:`),\n\t\t},\n\t)\n\tpublic trackers: Map<string, Tracker<Transceiver<any, any, any>>> = new Map()\n\tpublic families: Map<\n\t\tstring,\n\t\t| HeldSelectorFamily<any, any>\n\t\t| MutableAtomFamily<any, any>\n\t\t| PureSelectorFamily<any, any, any>\n\t\t| RegularAtomFamily<any, any, any>\n\t> = new Map()\n\tpublic joins: Map<string, Join<any, any, any, any, any>> = new Map()\n\n\tpublic transactions: Map<string, Transaction<Fn>> = new Map()\n\tpublic transactionMeta: TransactionEpoch | TransactionProgress<Fn> = {\n\t\tepoch: new Map<string, number>(),\n\t\tactionContinuities: new Junction({\n\t\t\tbetween: [`continuity`, `action`],\n\t\t\tcardinality: `1:n`,\n\t\t}),\n\t}\n\n\tpublic timelines: Map<string, Timeline<any>> = new Map()\n\tpublic timelineTopics: Junction<\n\t\t`timelineKey`,\n\t\tstring,\n\t\t`topicKey`,\n\t\tstring,\n\t\t{ topicType: `atom_family` | `atom` | `molecule_family` | `molecule` }\n\t> = new Junction({\n\t\tbetween: [`timelineKey`, `topicKey`],\n\t\tcardinality: `1:n`,\n\t})\n\n\tpublic disposalTraces: CircularBuffer<{ key: string; trace: string }> =\n\t\tnew CircularBuffer(100)\n\n\tpublic molecules: Map<string, Molecule<Canonical>> = new Map()\n\n\tpublic moleculeGraph: Junction<\n\t\t`upstreamMoleculeKey`,\n\t\tstringified<Canonical> | `\"root\"`,\n\t\t`downstreamMoleculeKey`,\n\t\tstringified<Canonical>,\n\t\t{ source: stringified<Canonical> }\n\t> = new Junction(\n\t\t{\n\t\t\tbetween: [`upstreamMoleculeKey`, `downstreamMoleculeKey`],\n\t\t\tcardinality: `n:n`,\n\t\t},\n\t\t{\n\t\t\tmakeContentKey: (...keys) => keys.sort().join(`:`),\n\t\t},\n\t)\n\tpublic moleculeData: Junction<\n\t\t`moleculeKey`,\n\t\tstringified<Canonical>,\n\t\t`stateFamilyKey`,\n\t\tstring\n\t> = new Junction(\n\t\t{\n\t\t\tbetween: [`moleculeKey`, `stateFamilyKey`],\n\t\t\tcardinality: `n:n`,\n\t\t},\n\t\t{\n\t\t\tmakeContentKey: (...keys) => keys.sort().join(`:`),\n\t\t},\n\t)\n\tpublic keyRefsInJoins: Junction<\n\t\t`moleculeKey`,\n\t\tstringified<Canonical>,\n\t\t`joinKey`,\n\t\tstring\n\t> = new Junction(\n\t\t{\n\t\t\tbetween: [`moleculeKey`, `joinKey`],\n\t\t\tcardinality: `n:n`,\n\t\t},\n\t\t{\n\t\t\tmakeContentKey: (...keys) => keys.sort().join(`:`),\n\t\t},\n\t)\n\tpublic miscResources: Map<string, Disposable> = new Map()\n\n\tpublic on: StoreEventCarrier = {\n\t\tatomCreation: new Subject(),\n\t\tatomDisposal: new Subject(),\n\t\tselectorCreation: new Subject(),\n\t\tselectorDisposal: new Subject(),\n\t\ttimelineCreation: new Subject(),\n\t\ttransactionCreation: new Subject(),\n\t\ttransactionApplying: new StatefulSubject(null),\n\t\toperationClose: new Subject(),\n\t\tmoleculeCreation: new Subject(),\n\t\tmoleculeDisposal: new Subject(),\n\t}\n\tpublic operation: OperationProgress = { open: false }\n\n\tpublic config: {\n\t\tname: string\n\t\tlifespan: `ephemeral` | `immortal`\n\t\tisProduction: boolean\n\t} = {\n\t\tname: `IMPLICIT_STORE`,\n\t\tlifespan: `ephemeral`,\n\t\tisProduction: globalThis.process?.env?.[`NODE_ENV`] === `production`,\n\t}\n\n\tpublic loggers: AtomIOLogger[] = [\n\t\tnew AtomIOLogger(`warn`, (_, __, key) => !isReservedIntrospectionKey(key)),\n\t]\n\tpublic logger: Logger = {\n\t\terror: (...messages) => {\n\t\t\tfor (const logger of this.loggers) logger.error(...messages)\n\t\t},\n\t\tinfo: (...messages) => {\n\t\t\tfor (const logger of this.loggers) logger.info(...messages)\n\t\t},\n\t\twarn: (...messages) => {\n\t\t\tfor (const logger of this.loggers) logger.warn(...messages)\n\t\t},\n\t}\n\n\tpublic constructor(config: Store[`config`], store: Store | null = null) {\n\t\tthis.config = {\n\t\t\t...store?.config,\n\t\t\t...config,\n\t\t}\n\t\tif (store !== null) {\n\t\t\tthis.operation = { ...store?.operation }\n\t\t\tif (isRootStore(store)) {\n\t\t\t\tthis.transactionMeta = {\n\t\t\t\t\tepoch: new Map(store?.transactionMeta.epoch),\n\t\t\t\t\tactionContinuities: new Junction(\n\t\t\t\t\t\tstore?.transactionMeta.actionContinuities.toJSON(),\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const [, family] of store.families) {\n\t\t\t\tif (\n\t\t\t\t\tfamily.internalRoles?.includes(`mutable`) ||\n\t\t\t\t\tfamily.internalRoles?.includes(`join`)\n\t\t\t\t) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfamily.install(this as RootStore)\n\t\t\t}\n\t\t\tconst mutableHelpers = new Set<string>()\n\t\t\tfor (const [, atom] of store.atoms) {\n\t\t\t\tif (mutableHelpers.has(atom.key)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tatom.install(this as RootStore)\n\t\t\t\tif (atom.type === `mutable_atom`) {\n\t\t\t\t\tconst originalJsonToken = getJsonToken(store, atom)\n\t\t\t\t\tconst originalUpdateToken = getUpdateToken(atom)\n\t\t\t\t\tmutableHelpers.add(originalJsonToken.key)\n\t\t\t\t\tmutableHelpers.add(originalUpdateToken.key)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [, selector] of store.readonlySelectors) {\n\t\t\t\tselector.install(this as RootStore)\n\t\t\t}\n\t\t\tfor (const [, selector] of store.writableSelectors) {\n\t\t\t\tif (mutableHelpers.has(selector.key)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tselector.install(this as RootStore)\n\t\t\t}\n\t\t\tfor (const [, tx] of store.transactions) {\n\t\t\t\ttx.install(this as RootStore)\n\t\t\t}\n\t\t\tfor (const [, timeline] of store.timelines) {\n\t\t\t\ttimeline.install(this as RootStore)\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type StoreEventCarrier = {\n\tatomCreation: Subject<AtomToken<unknown, any, any>>\n\tatomDisposal: Subject<AtomToken<unknown, any, any>>\n\tselectorCreation: Subject<SelectorToken<unknown, any, any>>\n\tselectorDisposal: Subject<SelectorToken<unknown, any, any>>\n\ttimelineCreation: Subject<TimelineToken<unknown>>\n\ttransactionCreation: Subject<TransactionToken<Fn>>\n\ttransactionApplying: StatefulSubject<TransactionProgress<Fn> | null>\n\toperationClose: Subject<OperationProgress>\n\tmoleculeCreation: Subject<MoleculeCreationEvent>\n\tmoleculeDisposal: Subject<MoleculeDisposalEvent>\n}\n\ndeclare global {\n\tvar ATOM_IO_IMPLICIT_STORE: RootStore | undefined\n}\n\nexport const IMPLICIT: { readonly STORE: RootStore } = {\n\tget STORE(): RootStore {\n\t\tglobalThis.ATOM_IO_IMPLICIT_STORE ??= new Store({\n\t\t\tname: `IMPLICIT_STORE`,\n\t\t\tlifespan: `ephemeral`,\n\t\t\tisProduction: globalThis.process?.env?.[`NODE_ENV`] === `production`,\n\t\t}) as RootStore\n\t\treturn globalThis.ATOM_IO_IMPLICIT_STORE\n\t},\n}\n\nexport const clearStore = (store: Store): void => {\n\tconst { config } = store\n\tfor (const disposable of store.miscResources.values()) {\n\t\tdisposable[Symbol.dispose]()\n\t}\n\tObject.assign(store, new Store(config))\n\tstore.config = config\n}\n", "import { type AtomIOToken, PRETTY_TOKEN_TYPES } from \"atom.io\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport type { Store } from \"./store\"\n\nexport class NotFoundError extends Error {\n\tpublic constructor(token: AtomIOToken, store: Store) {\n\t\tsuper(\n\t\t\t`${PRETTY_TOKEN_TYPES[token.type]} ${stringifyJson(token.key)} not found in store \"${\n\t\t\t\tstore.config.name\n\t\t\t}\".`,\n\t\t)\n\t}\n}\n", "import type {\n\tAtomFamilyToken,\n\tAtomIOToken,\n\tAtomToken,\n\tHeldSelectorFamilyToken,\n\tHeldSelectorToken,\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tPureSelectorFamilyToken,\n\tPureSelectorToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tReadonlyHeldSelectorFamilyToken,\n\tReadonlyHeldSelectorToken,\n\tReadonlyPureSelectorFamilyToken,\n\tReadonlyPureSelectorToken,\n\tReadonlySelectorFamilyToken,\n\tReadonlySelectorToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSelectorFamilyToken,\n\tSelectorToken,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tWritableFamilyToken,\n\tWritableHeldSelectorFamilyToken,\n\tWritableHeldSelectorToken,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorToken,\n\tWritableSelectorFamilyToken,\n\tWritableSelectorToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { Transceiver } from \"../mutable\"\nimport { NotFoundError } from \"../not-found-error\"\nimport type {\n\tAtom,\n\tAtomFamily,\n\tAtomIOInternalResource,\n\tHeldSelector,\n\tHeldSelectorFamily,\n\tMutableAtom,\n\tMutableAtomFamily,\n\tPureSelector,\n\tPureSelectorFamily,\n\tReadableFamily,\n\tReadableState,\n\tReadonlyHeldSelector,\n\tReadonlyHeldSelectorFamily,\n\tReadonlyPureSelector,\n\tReadonlyPureSelectorFamily,\n\tReadonlySelector,\n\tReadonlySelectorFamily,\n\tRegularAtom,\n\tRegularAtomFamily,\n\tSelector,\n\tSelectorFamily,\n\tWritableFamily,\n\tWritableHeldSelector,\n\tWritableHeldSelectorFamily,\n\tWritablePureSelector,\n\tWritablePureSelectorFamily,\n\tWritableSelector,\n\tWritableSelectorFamily,\n\tWritableState,\n} from \"../state-types\"\nimport type { Timeline } from \"../timeline\"\nimport type { Transaction } from \"../transaction\"\nimport type { Fn } from \"../utility-types\"\nimport type { Store } from \"./store\"\n\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: RegularAtomToken<T, any, E>,\n): RegularAtom<T, E>\nexport function withdraw<T extends Transceiver<any, any, any>>(\n\tstore: Store,\n\ttoken: MutableAtomToken<T, any>,\n): MutableAtom<T>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: AtomToken<T, any, E>,\n): Atom<T, E>\nexport function withdraw<T>(\n\tstore: Store,\n\ttoken: WritableHeldSelectorToken<T>,\n): WritableHeldSelector<T>\nexport function withdraw<T>(\n\tstore: Store,\n\ttoken: ReadonlyHeldSelectorToken<T>,\n): ReadonlyHeldSelector<T>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: WritablePureSelectorToken<T, any, E>,\n): WritablePureSelector<T, E>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: ReadonlyPureSelectorToken<T, any, E>,\n): ReadonlyPureSelector<T, E>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: ReadonlySelectorToken<T, any, E>,\n): ReadonlySelector<T, E>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: WritableSelectorToken<T, any, E>,\n): WritableSelector<T, E>\nexport function withdraw<T>(\n\tstore: Store,\n\ttoken: HeldSelectorToken<T>,\n): HeldSelector<T>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: PureSelectorToken<T, any, E>,\n): PureSelector<T, E>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: SelectorToken<T, any, E>,\n): Selector<T, E>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: WritableToken<T, any, E>,\n): WritableState<T, E>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: ReadableToken<T, any, E>,\n): ReadableState<T, E>\n\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: RegularAtomFamilyToken<T, K, E>,\n): RegularAtomFamily<T, K, E>\nexport function withdraw<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(store: Store, token: MutableAtomFamilyToken<T, K>): MutableAtomFamily<T, K>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: AtomFamilyToken<T, K, E>,\n): AtomFamily<T, K, E>\nexport function withdraw<T, K extends Canonical>(\n\tstore: Store,\n\ttoken: ReadonlyHeldSelectorFamilyToken<T, K>,\n): ReadonlyHeldSelectorFamily<T, K>\nexport function withdraw<T, K extends Canonical>(\n\tstore: Store,\n\ttoken: WritableHeldSelectorFamilyToken<T, K>,\n): WritableHeldSelectorFamily<T, K>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: ReadonlyPureSelectorFamilyToken<T, K, E>,\n): ReadonlyPureSelectorFamily<T, K, E>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: WritablePureSelectorFamilyToken<T, K, E>,\n): WritablePureSelectorFamily<T, K, E>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: ReadonlySelectorFamilyToken<T, K, E>,\n): ReadonlySelectorFamily<T, K, E>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: WritableSelectorFamilyToken<T, K, E>,\n): WritableSelectorFamily<T, K, E>\nexport function withdraw<T, K extends Canonical>(\n\tstore: Store,\n\ttoken: HeldSelectorFamilyToken<T, K>,\n): HeldSelectorFamily<T, K>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: PureSelectorFamilyToken<T, K, E>,\n): PureSelectorFamily<T, K, E>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: SelectorFamilyToken<T, K, E>,\n): SelectorFamily<T, K, E>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: WritableFamilyToken<T, K, E>,\n): WritableFamily<T, K, E>\nexport function withdraw<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: ReadableFamilyToken<T, K, E>,\n): ReadableFamily<T, K, E>\n\nexport function withdraw<T extends Fn>(\n\tstore: Store,\n\ttoken: TransactionToken<T>,\n): Transaction<T extends Fn ? T : never>\nexport function withdraw<T>(\n\tstore: Store,\n\ttoken: TimelineToken<T>,\n): Timeline<T extends TimelineManageable ? T : never>\n\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: WritableToken<T, any, E>,\n): WritableState<T, E>\nexport function withdraw<T, E>(\n\tstore: Store,\n\ttoken: ReadableToken<T, any, E>,\n): ReadableState<T, E>\n\nexport function withdraw(\n\tstore: Store,\n\ttoken: AtomIOToken,\n): AtomIOInternalResource\n\nexport function withdraw(\n\tstore: Store,\n\ttoken: AtomIOToken,\n): AtomIOInternalResource {\n\tlet withdrawn: AtomIOInternalResource | undefined\n\tlet target: Store | null = store\n\twhile (target !== null) {\n\t\tswitch (token.type) {\n\t\t\tcase `atom`:\n\t\t\tcase `mutable_atom`:\n\t\t\t\twithdrawn = target.atoms.get(token.key)\n\t\t\t\tbreak\n\t\t\tcase `writable_pure_selector`:\n\t\t\tcase `writable_held_selector`:\n\t\t\t\twithdrawn = target.writableSelectors.get(token.key)\n\t\t\t\tbreak\n\t\t\tcase `readonly_pure_selector`:\n\t\t\tcase `readonly_held_selector`:\n\t\t\t\twithdrawn = target.readonlySelectors.get(token.key)\n\t\t\t\tbreak\n\t\t\tcase `atom_family`:\n\t\t\tcase `mutable_atom_family`:\n\t\t\tcase `writable_pure_selector_family`:\n\t\t\tcase `readonly_pure_selector_family`:\n\t\t\tcase `writable_held_selector_family`:\n\t\t\tcase `readonly_held_selector_family`:\n\t\t\t\twithdrawn = target.families.get(token.key)\n\t\t\t\tbreak\n\t\t\tcase `timeline`:\n\t\t\t\twithdrawn = target.timelines.get(token.key)\n\t\t\t\tbreak\n\t\t\tcase `transaction`:\n\t\t\t\twithdrawn = target.transactions.get(token.key)\n\t\t\t\tbreak\n\t\t}\n\t\tif (withdrawn) {\n\t\t\treturn withdrawn\n\t\t}\n\t\ttarget = target.child\n\t}\n\tthrow new NotFoundError(token, store)\n}\n", "import type { ReadableToken, ViewOf } from \"atom.io\"\nimport { type Canonical, stringifyJson } from \"atom.io/json\"\n\nimport type { ReadableFamily } from \"../state-types\"\nimport type { Store } from \"../store\"\n\nexport function getFallback<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: ReadableToken<T, K, E>,\n\tfamily: ReadableFamily<T, K, E>,\n\tsubKey: NoInfer<K>,\n): ViewOf<E | T> {\n\tconst disposal = store.disposalTraces.buffer.find(\n\t\t(item) => item?.key === stringifyJson(subKey),\n\t)\n\tstore.logger.error(\n\t\t`❌`,\n\t\ttoken.type,\n\t\ttoken.key,\n\t\t`gets a fallback value because key`,\n\t\tsubKey,\n\t\t`is not allocated`,\n\t\tdisposal\n\t\t\t? `This key was previously disposed:\\n${disposal.trace}`\n\t\t\t: `(no previous disposal trace found)`,\n\t)\n\tswitch (family.type) {\n\t\tcase `mutable_atom_family`: {\n\t\t\tif (store.defaults.has(family.key)) {\n\t\t\t\treturn store.defaults.get(family.key)\n\t\t\t}\n\t\t\tconst defaultValue = new family.class()\n\t\t\tstore.defaults.set(family.key, defaultValue)\n\t\t\treturn defaultValue.READONLY_VIEW\n\t\t}\n\t\tcase `atom_family`: {\n\t\t\tif (store.defaults.has(family.key)) {\n\t\t\t\treturn store.defaults.get(family.key)\n\t\t\t}\n\t\t\tconst def = family.default as (key: K) => T\n\t\t\tconst defaultValue = def(subKey)\n\t\t\tstore.defaults.set(family.key, defaultValue)\n\t\t\treturn defaultValue as ViewOf<T>\n\t\t}\n\t\tcase `readonly_pure_selector_family`:\n\t\tcase `writable_pure_selector_family`:\n\t\tcase `readonly_held_selector_family`:\n\t\tcase `writable_held_selector_family`: {\n\t\t\tif (store.defaults.has(family.key)) {\n\t\t\t\treturn store.defaults.get(family.key)\n\t\t\t}\n\t\t\tconst defaultValue = family.default(subKey)\n\t\t\tstore.defaults.set(family.key, defaultValue)\n\t\t\treturn defaultValue as ViewOf<T>\n\t\t}\n\t}\n}\n", "import { writeToCache } from \"./caching\"\nimport { isFn } from \"./is-fn\"\nimport type { PureSelector, RegularAtom } from \"./state-types\"\nimport type { Store } from \"./store\"\n\nexport function safeCompute<T, E>(\n\ttarget: Store,\n\tstate: PureSelector<T, E> | RegularAtom<T, E>,\n): E | T {\n\tconst { type, key, catch: canCatch } = state\n\tswitch (type) {\n\t\tcase `readonly_pure_selector`:\n\t\tcase `writable_pure_selector`: {\n\t\t\tlet val: E | T\n\t\t\ttarget.logger.info(`🧮`, type, key, `computing value`)\n\t\t\ttry {\n\t\t\t\tval = state.getFrom(target)\n\t\t\t\tif (val instanceof Promise) {\n\t\t\t\t\treturn (val as Promise<E & T>).catch((thrown) => {\n\t\t\t\t\t\ttarget.logger.error(`💥`, type, key, `rejected:`, thrown)\n\t\t\t\t\t\tif (canCatch) {\n\t\t\t\t\t\t\tfor (const Class of canCatch) {\n\t\t\t\t\t\t\t\tif (thrown instanceof Class) {\n\t\t\t\t\t\t\t\t\treturn thrown\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow thrown\n\t\t\t\t\t}) as E | T\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\ttarget.logger.error(`💥`, type, key, `rejected:`, e)\n\t\t\t\tif (canCatch) {\n\t\t\t\t\tfor (const Class of canCatch) {\n\t\t\t\t\t\tif (e instanceof Class) {\n\t\t\t\t\t\t\treturn writeToCache(target, state, e)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow e\n\t\t\t}\n\t\t\tconst cachedValue = writeToCache(target, state, val)\n\t\t\treturn cachedValue\n\t\t}\n\t\tcase `atom`: {\n\t\t\tlet def: E | T\n\t\t\tif (isFn(state.default)) {\n\t\t\t\ttry {\n\t\t\t\t\tdef = state.default()\n\t\t\t\t\tif (def instanceof Promise) {\n\t\t\t\t\t\tdef = (def as Promise<T> & T).catch<E | T>((thrown) => {\n\t\t\t\t\t\t\ttarget.logger.error(`💥`, type, key, `rejected:`, thrown)\n\t\t\t\t\t\t\tif (canCatch) {\n\t\t\t\t\t\t\t\tfor (const Class of canCatch) {\n\t\t\t\t\t\t\t\t\tif (thrown instanceof Class) {\n\t\t\t\t\t\t\t\t\t\treturn thrown\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow thrown\n\t\t\t\t\t\t}) as E | T\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\ttarget.logger.error(`💥`, type, key, `rejected:`, e)\n\t\t\t\t\tif (canCatch) {\n\t\t\t\t\t\tfor (const Class of canCatch) {\n\t\t\t\t\t\t\tif (e instanceof Class) {\n\t\t\t\t\t\t\t\tdef = writeToCache(target, state, e)\n\t\t\t\t\t\t\t\ttarget.logger.info(\n\t\t\t\t\t\t\t\t\t`✨`,\n\t\t\t\t\t\t\t\t\tstate.type,\n\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\t`computed default`,\n\t\t\t\t\t\t\t\t\tdef,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn def\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow e\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdef = state.default\n\t\t\t\ttarget.logger.info(`✨`, state.type, key, `using static default`, def)\n\t\t\t}\n\t\t\tconst cachedValue = writeToCache(target, state, def)\n\t\t\treturn cachedValue\n\t\t}\n\t}\n}\n", "import type { ViewOf } from \"atom.io\"\n\nimport { readFromCache, writeToCache } from \"../caching\"\nimport { safeCompute } from \"../safe-compute\"\nimport type { ReadableState } from \"../state-types\"\nimport type { Store } from \"../store\"\n\nexport function readOrComputeValue<T, E>(\n\ttarget: Store,\n\tstate: ReadableState<T, E>,\n\tmut?: undefined,\n): ViewOf<E | T>\nexport function readOrComputeValue<T, E>(\n\ttarget: Store,\n\tstate: ReadableState<T, E>,\n\tmut: `mut`,\n): E | T\nexport function readOrComputeValue<T, E>(\n\ttarget: Store,\n\tstate: ReadableState<T, E>,\n\tmut: `mut` | undefined,\n): E | T {\n\tif (target.valueMap.has(state.key)) {\n\t\treturn readFromCache(target, state, mut)\n\t}\n\ttarget.logger.info(`❔`, state.type, state.key, `value not found in cache`)\n\tconst { key } = state\n\tswitch (state.type) {\n\t\tcase `readonly_held_selector`:\n\t\tcase `writable_held_selector`:\n\t\t\ttarget.logger.info(`🧮`, state.type, key, `computing value`)\n\t\t\treturn state.getFrom(target)\n\t\tcase `writable_pure_selector`:\n\t\tcase `readonly_pure_selector`:\n\t\tcase `atom`:\n\t\t\treturn safeCompute(target, state)\n\t\tcase `mutable_atom`: {\n\t\t\tconst instance = new state.class()\n\t\t\ttarget.logger.info(`✨`, state.type, key, `created new instance`, instance)\n\t\t\tconst cachedValue = writeToCache(target, state, instance)\n\t\t\treturn cachedValue\n\t\t}\n\t}\n}\n", "import type {\n\tMutableAtomToken,\n\tReadableToken,\n\tReadonlyPureSelectorToken,\n\tRegularAtomToken,\n\tWritablePureSelectorToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { Transceiver } from \"../mutable\"\nimport type {\n\tMutableAtomFamily,\n\tReadableFamily,\n\tReadonlyPureSelectorFamily,\n\tRegularAtomFamily,\n\tWritableFamily,\n\tWritablePureSelectorFamily,\n} from \"../state-types\"\nimport { type Store, withdraw } from \"../store\"\n\nexport function getFamilyOfToken<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(store: Store, token: MutableAtomToken<T, K>): MutableAtomFamily<T, K>\n\nexport function getFamilyOfToken<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: RegularAtomToken<T, K, E>,\n): RegularAtomFamily<T, K, E>\n\nexport function getFamilyOfToken<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: WritablePureSelectorToken<T, K, E>,\n): WritablePureSelectorFamily<T, K, E>\n\nexport function getFamilyOfToken<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: ReadonlyPureSelectorToken<T, K, E>,\n): ReadonlyPureSelectorFamily<T, K, E>\n\nexport function getFamilyOfToken<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: WritableToken<T, K, E>,\n): WritableFamily<T, K, E>\n\nexport function getFamilyOfToken<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: ReadableToken<T, K, E>,\n): ReadableFamily<T, K, E>\n\nexport function getFamilyOfToken(\n\tstore: Store,\n\ttoken: ReadableToken<any, any, any>,\n): ReadableFamily<any, any, any> {\n\treturn withdraw(store, {\n\t\t// biome-ignore lint/style/noNonNullAssertion: family is required\n\t\tkey: token.family!.key,\n\t\ttype: `${token.type}_family`,\n\t})\n}\n", "import type { ReadableToken, WritableToken } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport type { ReadableFamily } from \"../state-types\"\nimport type { Store } from \"../store\"\n\nexport const FAMILY_MEMBER_TOKEN_TYPES = {\n\tatom_family: `atom`,\n\tmolecule_family: `molecule`,\n\tmutable_atom_family: `mutable_atom`,\n\treadonly_held_selector_family: `readonly_held_selector`,\n\treadonly_pure_selector_family: `readonly_pure_selector`,\n\twritable_held_selector_family: `writable_held_selector`,\n\twritable_pure_selector_family: `writable_pure_selector`,\n} as const\n\nexport const MUST_CREATE: unique symbol = Symbol(`MUST_CREATE`)\nexport const DO_NOT_CREATE: unique symbol = Symbol(`DO_NOT_CREATE`)\n\nexport function mintInStore<T, K extends Canonical, KK extends K, E>(\n\tmustCreate: typeof DO_NOT_CREATE | typeof MUST_CREATE,\n\tstore: Store,\n\tfamily: ReadableFamily<T, K, E>,\n\tkey: KK,\n): WritableToken<T, KK, E>\nexport function mintInStore<T, K extends Canonical, KK extends K, E>(\n\tmustCreate: typeof DO_NOT_CREATE | typeof MUST_CREATE,\n\tstore: Store,\n\tfamily: ReadableFamily<T, K, E>,\n\tkey: KK,\n): ReadableToken<T, KK, E>\nexport function mintInStore<T, K extends Canonical, KK extends K, E>(\n\tmustCreate: typeof DO_NOT_CREATE | typeof MUST_CREATE,\n\tstore: Store,\n\tfamily: ReadableFamily<T, K, E>,\n\tkey: KK,\n): ReadableToken<T, KK, E> {\n\tconst stringKey = stringifyJson(key)\n\tconst molecule = store.molecules.get(stringKey)\n\n\tconst cannotCreate = !molecule && store.config.lifespan === `immortal`\n\n\tif (cannotCreate) {\n\t\tconst { type: familyType, key: familyKey } = family\n\t\tstore.logger.warn(\n\t\t\t`💣`,\n\t\t\t`key`,\n\t\t\tstringKey,\n\t\t\t`was used to mint a counterfeit token for`,\n\t\t\tfamilyType,\n\t\t\t`\"${familyKey}\"`,\n\t\t)\n\t\tconst fullKey = `${familyKey}(${stringKey})`\n\t\tconst type = FAMILY_MEMBER_TOKEN_TYPES[familyType]\n\t\tconst stateToken: ReadableToken<T, KK, E> & { counterfeit: true } = {\n\t\t\tcounterfeit: true,\n\t\t\tkey: fullKey,\n\t\t\ttype,\n\t\t\tfamily: {\n\t\t\t\tkey: familyKey,\n\t\t\t\tsubKey: stringKey,\n\t\t\t},\n\t\t}\n\n\t\treturn stateToken\n\t}\n\n\tlet token: ReadableToken<T, KK, E>\n\tif (mustCreate === MUST_CREATE) {\n\t\tstore.logger.info(\n\t\t\t`👪`,\n\t\t\tfamily.type,\n\t\t\tfamily.key,\n\t\t\t`adds member`,\n\t\t\ttypeof key === `string` ? `\\`${key}\\`` : key,\n\t\t)\n\t\ttoken = family.create(key)\n\t\tif (molecule) {\n\t\t\tstore.moleculeData.set(stringKey, family.key)\n\t\t}\n\t} else {\n\t\tconst { type: familyType, key: familyKey } = family\n\t\tconst fullKey = `${familyKey}(${stringKey})`\n\t\tconst type = FAMILY_MEMBER_TOKEN_TYPES[familyType]\n\t\tconst stateToken: ReadableToken<T, KK, E> = {\n\t\t\tkey: fullKey,\n\t\t\ttype,\n\t\t\tfamily: {\n\t\t\t\tkey: familyKey,\n\t\t\t\tsubKey: stringKey,\n\t\t\t},\n\t\t}\n\n\t\treturn stateToken\n\t}\n\n\treturn token\n}\n", "import type {\n\tReadableFamilyToken,\n\tReadableToken,\n\tStateCreationEvent,\n} from \"atom.io\"\nimport { type Canonical, parseJson } from \"atom.io/json\"\n\nimport { seekInStore } from \"../families\"\nimport { getFamilyOfToken } from \"../families/get-family-of-token\"\nimport { mintInStore, MUST_CREATE } from \"../families/mint-in-store\"\nimport { newest } from \"../lineage\"\nimport type { ReadableFamily } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { withdraw } from \"../store\"\nimport type { Subject } from \"../subject\"\nimport { isChildStore, isRootStore } from \"../transaction\"\n\nexport function reduceReference<T, K extends Canonical, E>(\n\tstore: Store,\n\t...params:\n\t\t| [token: ReadableFamilyToken<T, K, E>, key: NoInfer<K>]\n\t\t| [token: ReadableToken<T, K, E>]\n): {\n\ttoken: ReadableToken<T, K, E>\n\tfamily: ReadableFamily<T, K, E> | undefined\n\tsubKey: NoInfer<K> | undefined\n\tisNew: boolean\n} {\n\tlet existingToken: ReadableToken<T, K, E> | undefined\n\tlet brandNewToken: ReadableToken<T, K, E> | undefined\n\tlet family: ReadableFamily<T, K, E> | undefined\n\tlet subKey: K | undefined\n\tlet token: ReadableToken<T, K, E>\n\tif (params.length === 1) {\n\t\ttoken = params[0]\n\t\tif (`family` in token) {\n\t\t\tconst familyToken = getFamilyOfToken(store, token)\n\t\t\tfamily = withdraw(store, familyToken) as ReadableFamily<T, K, E>\n\t\t\tsubKey = parseJson(token.family.subKey)\n\t\t\texistingToken = seekInStore(store, familyToken, subKey)\n\t\t\tif (`counterfeit` in token) {\n\t\t\t\treturn {\n\t\t\t\t\ttoken,\n\t\t\t\t\tfamily,\n\t\t\t\t\tsubKey,\n\t\t\t\t\tisNew: false,\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!existingToken) {\n\t\t\t\tbrandNewToken = mintInStore(MUST_CREATE, store, familyToken, subKey)\n\t\t\t\ttoken = brandNewToken\n\t\t\t} else {\n\t\t\t\ttoken = existingToken\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfamily = withdraw(store, params[0])\n\t\tsubKey = params[1]\n\t\texistingToken = seekInStore(store, family, subKey)\n\t\tif (!existingToken) {\n\t\t\tbrandNewToken = mintInStore(MUST_CREATE, store, family, subKey)\n\t\t\ttoken = brandNewToken\n\t\t} else {\n\t\t\ttoken = existingToken\n\t\t}\n\t}\n\n\tconst isCounterfeit = `counterfeit` in token\n\tconst isNewlyCreated = Boolean(brandNewToken) && isCounterfeit === false\n\tif (isNewlyCreated && family) {\n\t\tlet subType: `readable` | `writable`\n\t\tswitch (token.type) {\n\t\t\tcase `readonly_pure_selector`:\n\t\t\tcase `readonly_held_selector`:\n\t\t\t\tsubType = `readable`\n\t\t\t\tbreak\n\t\t\tcase `atom`:\n\t\t\tcase `mutable_atom`:\n\t\t\tcase `writable_pure_selector`:\n\t\t\tcase `writable_held_selector`:\n\t\t\t\tsubType = `writable`\n\t\t\t\tbreak\n\t\t}\n\t\tconst stateCreationEvent: StateCreationEvent<any> = {\n\t\t\ttype: `state_creation`,\n\t\t\tsubType,\n\t\t\ttoken,\n\t\t\ttimestamp: Date.now(),\n\t\t}\n\t\tconst familySubject = family.subject as Subject<StateCreationEvent<any>>\n\t\tfamilySubject.next(stateCreationEvent)\n\t\tconst target = newest(store)\n\t\tif (token.family) {\n\t\t\tif (isRootStore(target)) {\n\t\t\t\tswitch (token.type) {\n\t\t\t\t\tcase `atom`:\n\t\t\t\t\tcase `mutable_atom`:\n\t\t\t\t\t\tstore.on.atomCreation.next(token)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase `writable_pure_selector`:\n\t\t\t\t\tcase `readonly_pure_selector`:\n\t\t\t\t\tcase `writable_held_selector`:\n\t\t\t\t\tcase `readonly_held_selector`:\n\t\t\t\t\t\tstore.on.selectorCreation.next(token)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisChildStore(target) &&\n\t\t\t\ttarget.on.transactionApplying.state === null\n\t\t\t) {\n\t\t\t\ttarget.transactionMeta.update.subEvents.push(stateCreationEvent)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\ttoken,\n\t\tfamily,\n\t\tsubKey,\n\t\tisNew: Boolean(brandNewToken),\n\t}\n}\n", "import type { ReadableFamilyToken, ReadableToken, ViewOf } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport { type Store, withdraw } from \"../store\"\nimport { getFallback } from \"./get-fallback\"\nimport { readOrComputeValue } from \"./read-or-compute-value\"\nimport { reduceReference } from \"./reduce-reference\"\n\nexport function getFromStore<T>(store: Store, token: ReadableToken<T>): T\n\nexport function getFromStore<T, E>(\n\tstore: Store,\n\ttoken: ReadableToken<T, any, E>,\n): E | T\n\nexport function getFromStore<T, K extends Canonical, E>(\n\tstore: Store,\n\ttoken: ReadableFamilyToken<T, K, E>,\n\tkey: NoInfer<K>,\n): ViewOf<E | T>\n\nexport function getFromStore<T, K extends Canonical, E>(\n\tstore: Store,\n\t...params:\n\t\t| [token: ReadableFamilyToken<T, K, E>, key: NoInfer<K>]\n\t\t| [token: ReadableToken<T, any, E>]\n): ViewOf<E | T>\n\nexport function getFromStore<T, K extends Canonical, E>(\n\tstore: Store,\n\t...params:\n\t\t| [token: ReadableFamilyToken<T, K, E>, key: NoInfer<K>]\n\t\t| [token: ReadableToken<T, any, E>]\n): ViewOf<E | T> {\n\tconst { token, family, subKey } = reduceReference(store, ...params)\n\n\tif (`counterfeit` in token && family && subKey) {\n\t\treturn getFallback(store, token, family, subKey)\n\t}\n\tconst state = withdraw(store, token)\n\n\treturn readOrComputeValue(store, state)\n}\n", "import type {\n\tAtomFamilyToken,\n\tAtomToken,\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tReadonlyPureSelectorFamilyToken,\n\tReadonlyPureSelectorToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSelectorFamilyToken,\n\tSelectorToken,\n\tWritableFamilyToken,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { newest } from \"../lineage\"\nimport type { Transceiver } from \"../mutable\"\nimport type { ReadableState } from \"../state-types\"\nimport { deposit, type Store } from \"../store\"\n\nexport function seekInStore<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n\tKey extends K,\n>(\n\tstore: Store,\n\ttoken: MutableAtomFamilyToken<T, K>,\n\tkey: Key,\n): MutableAtomToken<T, Key> | undefined\n\nexport function seekInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\ttoken: RegularAtomFamilyToken<T, K, E>,\n\tkey: Key,\n): RegularAtomToken<T, Key, E> | undefined\n\nexport function seekInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\ttoken: AtomFamilyToken<T, K, E>,\n\tkey: Key,\n): AtomToken<T, Key, E> | undefined\n\nexport function seekInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\ttoken: WritablePureSelectorFamilyToken<T, K, E>,\n\tkey: Key,\n): WritablePureSelectorToken<T, Key, E> | undefined\n\nexport function seekInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\ttoken: ReadonlyPureSelectorFamilyToken<T, K, E>,\n\tkey: Key,\n): ReadonlyPureSelectorToken<T, Key, E> | undefined\n\nexport function seekInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\ttoken: SelectorFamilyToken<T, K, E>,\n\tkey: Key,\n): SelectorToken<T, Key, E> | undefined\n\nexport function seekInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\ttoken: WritableFamilyToken<T, K, E>,\n\tkey: Key,\n): WritableToken<T, Key, E> | undefined\n\nexport function seekInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\ttoken: ReadableFamilyToken<T, K, E>,\n\tkey: Key,\n): ReadableToken<T, Key, E> | undefined\n\nexport function seekInStore(\n\tstore: Store,\n\ttoken: ReadableFamilyToken<any, any, any>,\n\tkey: Canonical,\n): ReadableToken<any, any, any> | undefined {\n\tconst subKey = stringifyJson(key)\n\tconst fullKey = `${token.key}(${subKey})`\n\tconst target = newest(store)\n\tlet state: ReadableState<any, any> | undefined\n\tswitch (token.type) {\n\t\tcase `atom_family`:\n\t\tcase `mutable_atom_family`:\n\t\t\tstate = target.atoms.get(fullKey)\n\t\t\tbreak\n\t\tcase `writable_held_selector_family`:\n\t\tcase `writable_pure_selector_family`:\n\t\t\tstate = target.writableSelectors.get(fullKey)\n\t\t\tbreak\n\t\tcase `readonly_held_selector_family`:\n\t\tcase `readonly_pure_selector_family`:\n\t\t\tstate = target.readonlySelectors.get(fullKey)\n\t\t\tbreak\n\t}\n\tif (state) {\n\t\treturn deposit(state)\n\t}\n\treturn state\n}\n", "import type {\n\tAtomFamilyToken,\n\tAtomToken,\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tReadonlyPureSelectorFamilyToken,\n\tReadonlyPureSelectorToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSelectorFamilyToken,\n\tSelectorToken,\n\tWritableFamilyToken,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { Transceiver } from \"../mutable\"\nimport { type Store, withdraw } from \"../store\"\nimport { DO_NOT_CREATE, mintInStore } from \"./mint-in-store\"\nimport { seekInStore } from \"./seek-in-store\"\n\n// seek [token 🟧] [inits ⬛]\n// find [token ✅] [inits ⬛]\n// mint [token ✅] [inits 🟧]\n// init [token ✅] [inits ✅]\n\nexport function findInStore<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n\tKey extends K,\n>(\n\tstore: Store,\n\tfamilyToken: MutableAtomFamilyToken<T, K>,\n\tkey: Key,\n): MutableAtomToken<T, Key>\n\nexport function findInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\tfamilyToken: RegularAtomFamilyToken<T, K, E>,\n\tkey: Key,\n): RegularAtomToken<T, Key, E>\n\nexport function findInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\tfamilyToken: AtomFamilyToken<T, K, E>,\n\tkey: Key,\n): AtomToken<T, Key, E>\n\nexport function findInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\tfamilyToken: WritablePureSelectorFamilyToken<T, K, E>,\n\tkey: Key,\n): WritablePureSelectorToken<T, Key, E>\n\nexport function findInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\tfamilyToken: ReadonlyPureSelectorFamilyToken<T, K, E>,\n\tkey: Key,\n): ReadonlyPureSelectorToken<T, Key, E>\n\nexport function findInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\tfamilyToken: SelectorFamilyToken<T, K, E>,\n\tkey: Key,\n): SelectorToken<T, Key, E>\n\nexport function findInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\tfamilyToken: WritableFamilyToken<T, K, E>,\n\tkey: Key,\n): WritableToken<T, Key, E>\n\nexport function findInStore<T, K extends Canonical, Key extends K, E>(\n\tstore: Store,\n\tfamilyToken: ReadableFamilyToken<T, K, E>,\n\tkey: Key,\n): ReadableToken<T, Key, E>\n\nexport function findInStore(\n\tstore: Store,\n\tfamilyToken: ReadableFamilyToken<any, any, any>,\n\tkey: Canonical,\n): ReadableToken<any, any, any> {\n\tconst family = withdraw(store, familyToken)\n\tconst existingStateToken = seekInStore(store, familyToken, key)\n\tif (existingStateToken) {\n\t\treturn existingStateToken\n\t}\n\tconst newStateToken = mintInStore(DO_NOT_CREATE, store, family, key)\n\treturn newStateToken\n}\n", "import type {\n\tFamilyMetadata,\n\tfindState,\n\tgetState,\n\tReadonlyPureSelectorFamilyOptions,\n\tReadonlyPureSelectorFamilyToken,\n\tReadonlyPureSelectorOptions,\n\tReadonlyPureSelectorToken,\n\tStateLifecycleEvent,\n} from \"atom.io\"\nimport { PRETTY_TOKEN_TYPES } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { getFromStore } from \"../get-state\"\nimport { newest } from \"../lineage\"\nimport { getJsonToken } from \"../mutable\"\nimport { createReadonlyPureSelector } from \"../selector\"\nimport type { ReadonlyPureSelectorFamily } from \"../state-types\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { findInStore } from \"./find-in-store\"\n\nexport function createReadonlyPureSelectorFamily<T, K extends Canonical, E>(\n\tstore: RootStore,\n\toptions: ReadonlyPureSelectorFamilyOptions<T, K, E>,\n\tinternalRoles?: string[],\n): ReadonlyPureSelectorFamilyToken<T, K, E> {\n\tconst familyKey = options.key\n\tconst type = `readonly_pure_selector_family`\n\n\tconst familyToken = {\n\t\tkey: familyKey,\n\t\ttype,\n\t} as const satisfies ReadonlyPureSelectorFamilyToken<T, K, E>\n\n\tconst existing = store.families.get(familyKey)\n\tif (existing && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❗`,\n\t\t\ttype,\n\t\t\tfamilyKey,\n\t\t\t`Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} \"${existing.key}\" in store \"${store.config.name}\". You can safely ignore this warning if it is due to hot module replacement.`,\n\t\t)\n\t}\n\n\tconst subject = new Subject<\n\t\tStateLifecycleEvent<ReadonlyPureSelectorToken<T, K, E>>\n\t>()\n\n\tconst create = <Key extends K>(\n\t\tkey: Key,\n\t): ReadonlyPureSelectorToken<T, Key, E> => {\n\t\tconst subKey = stringifyJson(key)\n\t\tconst family: FamilyMetadata<Key> = { key: familyKey, subKey }\n\t\tconst fullKey = `${familyKey}(${subKey})`\n\t\tconst target = newest(store)\n\t\tconst individualOptions: ReadonlyPureSelectorOptions<T, E> = {\n\t\t\tkey: fullKey,\n\t\t\tget: options.get(key),\n\t\t}\n\t\tif (options.catch) {\n\t\t\tindividualOptions.catch = options.catch\n\t\t}\n\n\t\treturn createReadonlyPureSelector<T, Key, E>(\n\t\t\ttarget,\n\t\t\tindividualOptions,\n\t\t\tfamily,\n\t\t)\n\t}\n\n\tconst readonlySelectorFamily: ReadonlyPureSelectorFamily<T, K, E> = {\n\t\t...familyToken,\n\t\tcreate,\n\t\tinternalRoles,\n\t\tsubject,\n\t\tinstall: (s: RootStore) => createReadonlyPureSelectorFamily(s, options),\n\t\tdefault: (key: K) => {\n\t\t\tconst getFn = options.get(key)\n\t\t\treturn getFn({\n\t\t\t\tget: ((...args: Parameters<typeof getState>) =>\n\t\t\t\t\tgetFromStore(store, ...args)) as typeof getState,\n\t\t\t\tfind: ((...args: Parameters<typeof findState>) =>\n\t\t\t\t\tfindInStore(store, ...args)) as typeof findState,\n\t\t\t\tjson: (token) => getJsonToken(store, token),\n\t\t\t})\n\t\t},\n\t}\n\n\tstore.families.set(familyKey, readonlySelectorFamily)\n\treturn familyToken\n}\n", "import type {\n\tFamilyMetadata,\n\tRegularAtomFamilyOptions,\n\tRegularAtomFamilyToken,\n\tRegularAtomOptions,\n\tRegularAtomToken,\n\tStateLifecycleEvent,\n} from \"atom.io\"\nimport { PRETTY_TOKEN_TYPES } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { createRegularAtom } from \"../atom\"\nimport { isFn } from \"../is-fn\"\nimport { newest } from \"../lineage\"\nimport type { RegularAtomFamily } from \"../state-types\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\n\nexport function createRegularAtomFamily<T, K extends Canonical, E>(\n\tstore: RootStore,\n\toptions: RegularAtomFamilyOptions<T, K, E>,\n\tinternalRoles?: string[],\n): RegularAtomFamilyToken<T, K, E> {\n\tconst familyToken: RegularAtomFamilyToken<T, K, E> = {\n\t\tkey: options.key,\n\t\ttype: `atom_family`,\n\t}\n\n\tconst existing = store.families.get(options.key)\n\tif (existing && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❗`,\n\t\t\t`atom_family`,\n\t\t\toptions.key,\n\t\t\t`Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} \"${existing.key}\" in store \"${store.config.name}\". You can safely ignore this warning if it is due to hot module replacement.`,\n\t\t)\n\t}\n\n\tconst subject = new Subject<StateLifecycleEvent<RegularAtomToken<T, K, E>>>()\n\n\tconst create = <Key extends K>(key: Key): RegularAtomToken<T, Key, E> => {\n\t\tconst subKey = stringifyJson(key)\n\t\tconst family: FamilyMetadata<Key> = { key: options.key, subKey }\n\t\tconst fullKey = `${options.key}(${subKey})`\n\t\tconst target = newest(store)\n\n\t\tconst def = options.default\n\t\tconst individualOptions: RegularAtomOptions<T, E> = {\n\t\t\tkey: fullKey,\n\t\t\tdefault: isFn(def) ? () => def(key) : def,\n\t\t}\n\t\tif (options.effects) {\n\t\t\tindividualOptions.effects = options.effects(key)\n\t\t}\n\t\tif (options.catch) {\n\t\t\tindividualOptions.catch = options.catch\n\t\t}\n\n\t\treturn createRegularAtom(target, individualOptions, family)\n\t}\n\n\tconst atomFamily: RegularAtomFamily<T, K, E> = {\n\t\t...familyToken,\n\t\tcreate,\n\t\tdefault: options.default,\n\t\tsubject,\n\t\tinstall: (s: RootStore) => createRegularAtomFamily(s, options),\n\t\tinternalRoles,\n\t}\n\n\tstore.families.set(options.key, atomFamily)\n\tif (isFn(options.default) === false) {\n\t\tstore.defaults.set(options.key, options.default)\n\t}\n\treturn familyToken\n}\n", "import type {\n\tFamilyMetadata,\n\tReadonlyHeldSelectorFamilyOptions,\n\tReadonlyHeldSelectorFamilyToken,\n\tReadonlyHeldSelectorToken,\n\tStateLifecycleEvent,\n} from \"atom.io\"\nimport { PRETTY_TOKEN_TYPES } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { newest } from \"../lineage\"\nimport { createReadonlyHeldSelector } from \"../selector\"\nimport type { ReadonlyHeldSelectorFamily } from \"../state-types\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\n\nexport function createReadonlyHeldSelectorFamily<\n\tT extends object,\n\tK extends Canonical,\n>(\n\tstore: RootStore,\n\toptions: ReadonlyHeldSelectorFamilyOptions<T, K>,\n\tinternalRoles?: string[],\n): ReadonlyHeldSelectorFamilyToken<T, K> {\n\tconst familyKey = options.key\n\tconst type = `readonly_held_selector_family`\n\n\tconst familyToken = {\n\t\tkey: familyKey,\n\t\ttype,\n\t} as const satisfies ReadonlyHeldSelectorFamilyToken<T, K>\n\n\tconst existing = store.families.get(familyKey)\n\tif (existing && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❗`,\n\t\t\ttype,\n\t\t\tfamilyKey,\n\t\t\t`Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} \"${existing.key}\" in store \"${store.config.name}\". You can safely ignore this warning if it is due to hot module replacement.`,\n\t\t)\n\t}\n\n\tconst subject = new Subject<\n\t\tStateLifecycleEvent<ReadonlyHeldSelectorToken<T>>\n\t>()\n\n\tconst create = (key: K): ReadonlyHeldSelectorToken<T> => {\n\t\tconst subKey = stringifyJson(key)\n\t\tconst family: FamilyMetadata = { key: familyKey, subKey }\n\t\tconst fullKey = `${familyKey}(${subKey})`\n\t\tconst target = newest(store)\n\n\t\treturn createReadonlyHeldSelector(\n\t\t\ttarget,\n\t\t\t{\n\t\t\t\tkey: fullKey,\n\t\t\t\tconst: options.const(key),\n\t\t\t\tget: options.get(key),\n\t\t\t},\n\t\t\tfamily,\n\t\t)\n\t}\n\n\tconst readonlySelectorFamily: ReadonlyHeldSelectorFamily<T, K> = {\n\t\t...familyToken,\n\t\tcreate,\n\t\tinternalRoles,\n\t\tsubject,\n\t\tinstall: (s: RootStore) => createReadonlyHeldSelectorFamily(s, options),\n\t\tdefault: options.const,\n\t}\n\n\tstore.families.set(familyKey, readonlySelectorFamily)\n\treturn familyToken\n}\n", "import type {\n\tFamilyMetadata,\n\tStateLifecycleEvent,\n\tWritableHeldSelectorFamilyOptions,\n\tWritableHeldSelectorFamilyToken,\n\tWritableHeldSelectorToken,\n} from \"atom.io\"\nimport { PRETTY_TOKEN_TYPES } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { newest } from \"../lineage\"\nimport { createWritableHeldSelector } from \"../selector\"\nimport type { WritableHeldSelectorFamily } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\n\nexport function createWritableHeldSelectorFamily<\n\tT extends object,\n\tK extends Canonical,\n>(\n\tstore: Store,\n\toptions: WritableHeldSelectorFamilyOptions<T, K>,\n\tinternalRoles?: string[],\n): WritableHeldSelectorFamilyToken<T, K> {\n\tconst familyKey = options.key\n\tconst type = `writable_held_selector_family`\n\n\tconst familyToken = {\n\t\tkey: familyKey,\n\t\ttype,\n\t} as const satisfies WritableHeldSelectorFamilyToken<T, K>\n\n\tconst existing = store.families.get(familyKey)\n\tif (existing && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❗`,\n\t\t\ttype,\n\t\t\tfamilyKey,\n\t\t\t`Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} \"${existing.key}\" in store \"${store.config.name}\". You can safely ignore this warning if it is due to hot module replacement.`,\n\t\t)\n\t}\n\tconst subject = new Subject<\n\t\tStateLifecycleEvent<WritableHeldSelectorToken<T>>\n\t>()\n\n\tconst create = (key: K): WritableHeldSelectorToken<T> => {\n\t\tconst subKey = stringifyJson(key)\n\t\tconst family: FamilyMetadata = { key: familyKey, subKey }\n\t\tconst fullKey = `${familyKey}(${subKey})`\n\t\tconst target = newest(store)\n\n\t\treturn createWritableHeldSelector(\n\t\t\ttarget,\n\t\t\t{\n\t\t\t\tkey: fullKey,\n\t\t\t\tconst: options.const(key),\n\t\t\t\tget: options.get(key),\n\t\t\t\tset: options.set(key),\n\t\t\t},\n\t\t\tfamily,\n\t\t)\n\t}\n\n\tconst selectorFamily: WritableHeldSelectorFamily<T, K> = {\n\t\t...familyToken,\n\t\tcreate,\n\t\tinternalRoles,\n\t\tsubject,\n\t\tinstall: (s: RootStore) => createWritableHeldSelectorFamily(s, options),\n\t\tdefault: options.const,\n\t}\n\n\tstore.families.set(familyKey, selectorFamily)\n\treturn familyToken\n}\n", "import type {\n\tFamilyMetadata,\n\tfindState,\n\tgetState,\n\tStateLifecycleEvent,\n\tWritablePureSelectorFamilyOptions,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorOptions,\n\tWritablePureSelectorToken,\n} from \"atom.io\"\nimport { PRETTY_TOKEN_TYPES } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { getFromStore } from \"../get-state\"\nimport { newest } from \"../lineage\"\nimport { getJsonToken } from \"../mutable\"\nimport { createWritablePureSelector } from \"../selector\"\nimport type { WritablePureSelectorFamily } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { findInStore } from \"./find-in-store\"\n\nexport function createWritablePureSelectorFamily<T, K extends Canonical, E>(\n\tstore: Store,\n\toptions: WritablePureSelectorFamilyOptions<T, K, E>,\n\tinternalRoles?: string[],\n): WritablePureSelectorFamilyToken<T, K, E> {\n\tconst familyKey = options.key\n\tconst type = `writable_pure_selector_family`\n\n\tconst familyToken = {\n\t\tkey: familyKey,\n\t\ttype,\n\t} as const satisfies WritablePureSelectorFamilyToken<T, K, E>\n\n\tconst existing = store.families.get(familyKey)\n\tif (existing && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❗`,\n\t\t\ttype,\n\t\t\tfamilyKey,\n\t\t\t`Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} \"${existing.key}\" in store \"${store.config.name}\". You can safely ignore this warning if it is due to hot module replacement.`,\n\t\t)\n\t}\n\tconst subject = new Subject<\n\t\tStateLifecycleEvent<WritablePureSelectorToken<T, K, E>>\n\t>()\n\n\tconst create = <Key extends K>(\n\t\tkey: Key,\n\t): WritablePureSelectorToken<T, Key, E> => {\n\t\tconst subKey = stringifyJson(key)\n\t\tconst family: FamilyMetadata<Key> = { key: familyKey, subKey }\n\t\tconst fullKey = `${familyKey}(${subKey})`\n\t\tconst target = newest(store)\n\t\tconst individualOptions: WritablePureSelectorOptions<T, E> = {\n\t\t\tkey: fullKey,\n\t\t\tget: options.get(key),\n\t\t\tset: options.set(key),\n\t\t}\n\t\tif (options.catch) {\n\t\t\tindividualOptions.catch = options.catch\n\t\t}\n\n\t\treturn createWritablePureSelector<T, Key, E>(\n\t\t\ttarget,\n\t\t\tindividualOptions,\n\t\t\tfamily,\n\t\t)\n\t}\n\n\tconst selectorFamily: WritablePureSelectorFamily<T, K, E> = {\n\t\t...familyToken,\n\t\tcreate,\n\t\tinternalRoles,\n\t\tsubject,\n\t\tinstall: (s: RootStore) => createWritablePureSelectorFamily(s, options),\n\t\tdefault: (key: K) => {\n\t\t\tconst getFn = options.get(key)\n\t\t\treturn getFn({\n\t\t\t\tget: ((...args: Parameters<typeof getState>) =>\n\t\t\t\t\tgetFromStore(store, ...args)) as typeof getState,\n\t\t\t\tfind: ((...args: Parameters<typeof findState>) =>\n\t\t\t\t\tfindInStore(store, ...args)) as typeof findState,\n\t\t\t\tjson: (token) => getJsonToken(store, token),\n\t\t\t})\n\t\t},\n\t}\n\n\tstore.families.set(familyKey, selectorFamily)\n\treturn familyToken\n}\n", "import type {\n\tReadonlyHeldSelectorFamilyOptions,\n\tReadonlyHeldSelectorFamilyToken,\n\tReadonlyPureSelectorFamilyOptions,\n\tReadonlyPureSelectorFamilyToken,\n\tSelectorFamilyToken,\n\tWritableHeldSelectorFamilyOptions,\n\tWritableHeldSelectorFamilyToken,\n\tWritablePureSelectorFamilyOptions,\n\tWritablePureSelectorFamilyToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { RootStore } from \"../transaction\"\nimport { createReadonlyHeldSelectorFamily } from \"./create-readonly-held-selector-family\"\nimport { createReadonlyPureSelectorFamily } from \"./create-readonly-pure-selector-family\"\nimport { createWritableHeldSelectorFamily } from \"./create-writable-held-selector-family\"\nimport { createWritablePureSelectorFamily } from \"./create-writable-pure-selector-family\"\n\nexport function createSelectorFamily<T extends object, K extends Canonical>(\n\tstore: RootStore,\n\toptions: WritableHeldSelectorFamilyOptions<T, K>,\n): WritableHeldSelectorFamilyToken<T, K>\nexport function createSelectorFamily<T extends object, K extends Canonical>(\n\tstore: RootStore,\n\toptions: ReadonlyHeldSelectorFamilyOptions<T, K>,\n): ReadonlyHeldSelectorFamilyToken<T, K>\nexport function createSelectorFamily<T, K extends Canonical, E>(\n\tstore: RootStore,\n\toptions: WritablePureSelectorFamilyOptions<T, K, E>,\n): WritablePureSelectorFamilyToken<T, K, E>\nexport function createSelectorFamily<T, K extends Canonical, E>(\n\tstore: RootStore,\n\toptions: ReadonlyPureSelectorFamilyOptions<T, K, E>,\n): ReadonlyPureSelectorFamilyToken<T, K, E>\nexport function createSelectorFamily(\n\tstore: RootStore,\n\toptions:\n\t\t| ReadonlyHeldSelectorFamilyOptions<any, any>\n\t\t| ReadonlyPureSelectorFamilyOptions<any, any, any>\n\t\t| WritableHeldSelectorFamilyOptions<any, any>\n\t\t| WritablePureSelectorFamilyOptions<any, any, any>,\n): SelectorFamilyToken<any, any, any> {\n\tconst isWritable = `set` in options\n\tconst isHeld = `const` in options\n\n\tif (isHeld && isWritable) {\n\t\treturn createWritableHeldSelectorFamily(store, options, undefined)\n\t}\n\tif (isHeld) {\n\t\treturn createReadonlyHeldSelectorFamily(store, options, undefined)\n\t}\n\tif (isWritable) {\n\t\treturn createWritablePureSelectorFamily(store, options)\n\t}\n\treturn createReadonlyPureSelectorFamily(store, options)\n}\n", "import type { ReadableFamilyToken, ReadableToken } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport { disposeAtom } from \"../atom\"\nimport { disposeSelector } from \"../selector\"\nimport { type Store, withdraw } from \"../store\"\nimport { findInStore } from \"./find-in-store\"\n\nexport function disposeFromStore(\n\tstore: Store,\n\ttoken: ReadableToken<any, any, any>,\n): void\n\nexport function disposeFromStore<K extends Canonical>(\n\tstore: Store,\n\ttoken: ReadableFamilyToken<any, K, any>,\n\tkey: NoInfer<K>,\n): void\n\nexport function disposeFromStore<K extends Canonical>(\n\tstore: Store,\n\t...params:\n\t\t| [token: ReadableFamilyToken<any, K, any>, key: NoInfer<K>]\n\t\t| [token: ReadableToken<any, any, any>]\n): void\n\nexport function disposeFromStore(\n\tstore: Store,\n\t...params:\n\t\t| [token: ReadableFamilyToken<any, any, any>, key: Canonical]\n\t\t| [token: ReadableToken<any, any, any>]\n): void {\n\tlet token: ReadableToken<any, any, any>\n\tif (params.length === 1) {\n\t\ttoken = params[0]\n\t} else {\n\t\tconst family = params[0]\n\t\tconst key = params[1]\n\t\tconst maybeToken = findInStore(store, family, key)\n\t\ttoken = maybeToken\n\t}\n\ttry {\n\t\twithdraw(store, token)\n\t} catch (_) {\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\ttoken.type,\n\t\t\ttoken.key,\n\t\t\t`could not be disposed because it was not found in the store \"${store.config.name}\".`,\n\t\t)\n\t\treturn\n\t}\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\tcase `mutable_atom`:\n\t\t\tdisposeAtom(store, token)\n\t\t\tbreak\n\t\tcase `writable_pure_selector`:\n\t\tcase `readonly_pure_selector`:\n\t\tcase `writable_held_selector`:\n\t\tcase `readonly_held_selector`:\n\t\t\tdisposeSelector(store, token)\n\t\t\tbreak\n\t}\n}\n", "import type { AtomUpdateEvent, ReadableToken, StateCreationEvent } from \"atom.io\"\n\nimport type { Store } from \"./store\"\nimport { isChildStore } from \"./transaction/is-root-store\"\n\nexport type OperationProgress =\n\t| OpenOperation<any>\n\t| {\n\t\t\topen: false\n\t }\nexport type OpenOperation<\n\tR extends ReadableToken<any, any> = ReadableToken<any, any>,\n> = {\n\topen: true\n\ttoken: R\n\tdone: Set<string>\n\tprev: Map<string, any>\n\ttimestamp: number\n\tsubEvents: (AtomUpdateEvent<any> | StateCreationEvent<any>)[]\n}\n\nexport function openOperation(\n\tstore: Store,\n\ttoken: ReadableToken<any, any, any>,\n): number | (Store & { operation: OpenOperation }) {\n\tif (store.operation.open) {\n\t\tconst rejectionTime = performance.now()\n\t\tstore.logger.info(\n\t\t\t`🚫`,\n\t\t\ttoken.type,\n\t\t\ttoken.key,\n\t\t\t`deferring setState at T-${rejectionTime} until setState for \"${store.operation.token.key}\" is done`,\n\t\t)\n\t\treturn rejectionTime\n\t}\n\tstore.operation = {\n\t\topen: true,\n\t\tdone: new Set(),\n\t\tprev: new Map(),\n\t\ttimestamp: Date.now(),\n\t\ttoken,\n\t\tsubEvents: [],\n\t}\n\tstore.logger.info(\n\t\t`⭕`,\n\t\ttoken.type,\n\t\ttoken.key,\n\t\t`operation start in store \"${store.config.name}\"${\n\t\t\tisChildStore(store)\n\t\t\t\t? ` ${store.transactionMeta.phase} \"${store.transactionMeta.update.token.key}\"`\n\t\t\t\t: ``\n\t\t}`,\n\t)\n\treturn store as Store & { operation: OpenOperation }\n}\n\nexport function closeOperation(store: Store): void {\n\tif (store.operation.open) {\n\t\tstore.logger.info(\n\t\t\t`🔴`,\n\t\t\tstore.operation.token.type,\n\t\t\tstore.operation.token.key,\n\t\t\t`operation done in store \"${store.config.name}\"`,\n\t\t)\n\t}\n\tstore.operation = { open: false }\n\tstore.on.operationClose.next(store.operation)\n}\n\nexport const isDone = (store: Store, key: string): boolean => {\n\tif (!store.operation.open) {\n\t\tstore.logger.error(\n\t\t\t`🐞`,\n\t\t\t`unknown`,\n\t\t\tkey,\n\t\t\t`isDone called outside of an operation. This is probably a bug in AtomIO.`,\n\t\t)\n\t\treturn true\n\t}\n\treturn store.operation.done.has(key)\n}\nexport const markDone = (store: Store, key: string): void => {\n\tif (!store.operation.open) {\n\t\tstore.logger.error(\n\t\t\t`🐞`,\n\t\t\t`unknown`,\n\t\t\tkey,\n\t\t\t`markDone called outside of an operation. This is probably a bug in AtomIO.`,\n\t\t)\n\t\treturn\n\t}\n\tstore.operation.done.add(key)\n}\n", "import type {\n\tAtomUpdateEvent,\n\tStateCreationEvent,\n\tStateUpdate,\n\tTimelineEvent,\n} from \"atom.io\"\n\nimport { hasRole } from \"../atom\"\nimport { readOrComputeValue } from \"../get-state\"\nimport { newest } from \"../lineage\"\nimport type { Transceiver } from \"../mutable\"\nimport { isTransceiver } from \"../mutable\"\nimport type { OpenOperation } from \"../operation\"\nimport type { MutableAtom, WritableFamily, WritableState } from \"../state-types\"\nimport { deposit, type Store } from \"../store\"\nimport type { Subject } from \"../subject\"\nimport { isChildStore, isRootStore } from \"../transaction\"\nimport { evictDownstreamFromAtom } from \"./evict-downstream\"\nimport type { ProtoUpdate } from \"./operate-on-store\"\n\nexport function dispatchOrDeferStateUpdate<T, E>(\n\ttarget: Store & { operation: OpenOperation<any> },\n\tstate: WritableState<T, E>,\n\t{ oldValue, newValue }: ProtoUpdate<E | T>,\n\tstateIsNewlyCreated: boolean,\n\tfamily?: WritableFamily<T, any, E>,\n): void {\n\tconst token = deposit(state)\n\tif (stateIsNewlyCreated && family) {\n\t\tstate.subject.next({ newValue })\n\t\tconst stateCreationEvent: StateCreationEvent<any> & TimelineEvent<any> = {\n\t\t\tcheckpoint: true,\n\t\t\ttype: `state_creation`,\n\t\t\tsubType: `writable`,\n\t\t\ttoken,\n\t\t\ttimestamp: Date.now(),\n\t\t\tvalue: newValue,\n\t\t}\n\t\ttarget.operation.subEvents.push(stateCreationEvent)\n\t\tconst familySubject = family.subject as Subject<StateCreationEvent<any>>\n\t\tfamilySubject.next(stateCreationEvent)\n\t\tconst innerTarget = newest(target)\n\t\tif (token.family) {\n\t\t\tif (isRootStore(innerTarget)) {\n\t\t\t\tswitch (token.type) {\n\t\t\t\t\tcase `atom`:\n\t\t\t\t\tcase `mutable_atom`:\n\t\t\t\t\t\ttarget.on.atomCreation.next(token)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase `writable_pure_selector`:\n\t\t\t\t\tcase `writable_held_selector`:\n\t\t\t\t\t\ttarget.on.selectorCreation.next(token)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisChildStore(innerTarget) &&\n\t\t\t\tinnerTarget.on.transactionApplying.state === null\n\t\t\t) {\n\t\t\t\tinnerTarget.transactionMeta.update.subEvents.push(stateCreationEvent)\n\t\t\t}\n\t\t}\n\t\treturn /* bailing early here to avoid redundant update */\n\t}\n\tconst { key, subject, type } = state\n\n\tconst update: StateUpdate<T> = {\n\t\toldValue: isTransceiver(oldValue) ? oldValue.READONLY_VIEW : oldValue,\n\t\tnewValue: isTransceiver(newValue) ? newValue.READONLY_VIEW : newValue,\n\t}\n\n\tif (isRootStore(target)) {\n\t\tswitch (type) {\n\t\t\tcase `mutable_atom`:\n\t\t\t\ttarget.logger.info(\n\t\t\t\t\t`📢`,\n\t\t\t\t\ttype,\n\t\t\t\t\tkey,\n\t\t\t\t\t`is now (`,\n\t\t\t\t\tnewValue,\n\t\t\t\t\t`) subscribers:`,\n\t\t\t\t\tsubject.subscribers.keys(),\n\t\t\t\t)\n\t\t\t\tbreak\n\t\t\tcase `atom`:\n\t\t\tcase `writable_pure_selector`:\n\t\t\tcase `writable_held_selector`:\n\t\t\t\ttarget.logger.info(\n\t\t\t\t\t`📢`,\n\t\t\t\t\ttype,\n\t\t\t\t\tkey,\n\t\t\t\t\t`went (`,\n\t\t\t\t\toldValue,\n\t\t\t\t\t`->`,\n\t\t\t\t\tnewValue,\n\t\t\t\t\t`) subscribers:`,\n\t\t\t\t\tsubject.subscribers.keys(),\n\t\t\t\t)\n\t\t}\n\t\tsubject.next(update)\n\t}\n\n\tif (isChildStore(target) && (type === `mutable_atom` || type === `atom`)) {\n\t\tif (target.on.transactionApplying.state === null) {\n\t\t\tif (isTransceiver(newValue)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst { timestamp } = target.operation\n\t\t\tconst atomUpdate: AtomUpdateEvent<any> = {\n\t\t\t\ttype: `atom_update`,\n\t\t\t\ttoken,\n\t\t\t\ttimestamp,\n\t\t\t\tupdate,\n\t\t\t}\n\t\t\ttarget.transactionMeta.update.subEvents.push(atomUpdate)\n\t\t\ttarget.logger.info(\n\t\t\t\t`📁`,\n\t\t\t\t`atom`,\n\t\t\t\tkey,\n\t\t\t\t`stowed (`,\n\t\t\t\toldValue,\n\t\t\t\t`->`,\n\t\t\t\tnewValue,\n\t\t\t\t`)`,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tif (hasRole(state, `tracker:signal`)) {\n\t\t\tconst keyOfMutable = key.slice(1)\n\t\t\tconst mutable = target.atoms.get(keyOfMutable) as MutableAtom<\n\t\t\t\tTransceiver<any, any, any>\n\t\t\t>\n\t\t\tconst transceiver = readOrComputeValue<Transceiver<any, any, any>, never>(\n\t\t\t\ttarget,\n\t\t\t\tmutable,\n\t\t\t\t`mut`,\n\t\t\t)\n\t\t\tconst accepted = transceiver.do(update.newValue) === null\n\t\t\tif (accepted === true) {\n\t\t\t\tevictDownstreamFromAtom(target, mutable)\n\t\t\t}\n\t\t}\n\t}\n}\n", "import { writeToCache } from \"../caching\"\nimport { readOrComputeValue } from \"../get-state/read-or-compute-value\"\nimport type { OpenOperation } from \"../operation\"\nimport { markDone } from \"../operation\"\nimport type { Atom } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { become } from \"./become\"\nimport { evictDownstreamFromAtom } from \"./evict-downstream\"\nimport type { ProtoUpdate } from \"./operate-on-store\"\n\nexport const setAtom = <T>(\n\ttarget: Store & { operation: OpenOperation<any> },\n\tatom: Atom<T, any>,\n\tnext: NoInfer<T> | ((oldValue: T) => NoInfer<T>),\n): ProtoUpdate<T> => {\n\tconst oldValue = readOrComputeValue(target, atom, `mut`)\n\tlet newValue = become(next, oldValue)\n\ttarget.logger.info(`⭐`, `atom`, atom.key, `setting value`, newValue)\n\tnewValue = writeToCache(target, atom, newValue)\n\tmarkDone(target, atom.key)\n\tevictDownstreamFromAtom(target, atom)\n\treturn { oldValue, newValue }\n}\n", "import { isFn } from \"../is-fn\"\nimport type { OpenOperation } from \"../operation\"\nimport { safeCompute } from \"../safe-compute\"\nimport { traceRootSelectorAtoms } from \"../selector\"\nimport type { Atom, WritableState } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { dispatchOrDeferStateUpdate } from \"./dispatch-state-update\"\nimport type { ProtoUpdate } from \"./operate-on-store\"\nimport { setAtom } from \"./set-atom\"\n\nfunction resetAtom<T, E>(\n\ttarget: Store & { operation: OpenOperation },\n\tatom: Atom<T, E>,\n): ProtoUpdate<E | T> {\n\tswitch (atom.type) {\n\t\tcase `mutable_atom`:\n\t\t\treturn setAtom(target, atom, new atom.class())\n\t\tcase `atom`: {\n\t\t\tlet def: E | T\n\t\t\tif (isFn(atom.default)) def = safeCompute(target, atom)\n\t\t\telse def = atom.default\n\t\t\treturn setAtom<E | T>(target, atom, def)\n\t\t}\n\t}\n}\n\nexport function resetAtomOrSelector<T, E>(\n\ttarget: Store & { operation: OpenOperation },\n\tstate: WritableState<T, E>,\n): ProtoUpdate<E | T> {\n\tlet protoUpdate: ProtoUpdate<E | T>\n\tswitch (state.type) {\n\t\tcase `atom`:\n\t\tcase `mutable_atom`:\n\t\t\tprotoUpdate = resetAtom(target, state)\n\t\t\tbreak\n\t\tcase `writable_held_selector`:\n\t\t\t{\n\t\t\t\tconst atoms = traceRootSelectorAtoms(target, state.key)\n\t\t\t\tfor (const atom of atoms.values()) {\n\t\t\t\t\tconst rootProtoUpdate = resetAtom(target, atom)\n\t\t\t\t\tdispatchOrDeferStateUpdate(target, state, rootProtoUpdate, false)\n\t\t\t\t}\n\t\t\t\tconst value = state.getFrom(target)\n\t\t\t\tprotoUpdate = { oldValue: value, newValue: value }\n\t\t\t}\n\t\t\tbreak\n\t\tcase `writable_pure_selector`:\n\t\t\t{\n\t\t\t\tconst oldValue = safeCompute(target, state)\n\t\t\t\tconst atoms = traceRootSelectorAtoms(target, state.key)\n\t\t\t\tfor (const atom of atoms.values()) {\n\t\t\t\t\tconst rootProtoUpdate = resetAtom(target, atom)\n\t\t\t\t\tdispatchOrDeferStateUpdate(target, state, rootProtoUpdate, false)\n\t\t\t\t}\n\t\t\t\tconst newValue = safeCompute(target, state)\n\t\t\t\tprotoUpdate = { oldValue, newValue }\n\t\t\t}\n\t\t\tbreak\n\t}\n\n\treturn protoUpdate\n}\n", "import type { Setter, WritableFamilyToken, WritableToken } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { Store } from \"../store\"\nimport { operateOnStore, OWN_OP } from \"./operate-on-store\"\nimport type { RESET_STATE } from \"./reset-in-store\"\n\nexport function setIntoStore<T, TT extends T>(\n\tstore: Store,\n\ttoken: WritableToken<T, any, any>,\n\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n): void\n\nexport function setIntoStore<T, TT extends T, K extends Canonical>(\n\tstore: Store,\n\ttoken: WritableFamilyToken<T, K, any>,\n\tkey: NoInfer<K>,\n\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n): void\n\nexport function setIntoStore<T, TT extends T, K extends Canonical>(\n\tstore: Store,\n\t...params:\n\t\t| [\n\t\t\t\ttoken: WritableFamilyToken<T, K, any>,\n\t\t\t\tkey: NoInfer<K>,\n\t\t\t\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n\t\t ]\n\t\t| [\n\t\t\t\ttoken: WritableToken<T, any, any>,\n\t\t\t\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n\t\t ]\n): void\n\nexport function setIntoStore<T, TT extends T, K extends Canonical>(\n\tstore: Store,\n\t...params:\n\t\t| [\n\t\t\t\ttoken: WritableFamilyToken<T, K, any>,\n\t\t\t\tkey: NoInfer<K>,\n\t\t\t\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n\t\t ]\n\t\t| [\n\t\t\t\ttoken: WritableToken<T, any, any>,\n\t\t\t\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n\t\t ]\n): void {\n\toperateOnStore(OWN_OP, store, ...params)\n}\n", "import type { WritableFamilyToken, WritableToken } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { Store } from \"../store\"\nimport { setIntoStore } from \"./set-into-store\"\n\nexport const RESET_STATE: unique symbol = Symbol(`RESET`)\n\nexport function resetInStore(\n\tstore: Store,\n\ttoken: WritableToken<any, any, any>,\n): void\n\nexport function resetInStore<K extends Canonical>(\n\tstore: Store,\n\ttoken: WritableFamilyToken<any, K, any>,\n\tkey: NoInfer<K>,\n): void\n\nexport function resetInStore<T, K extends Canonical>(\n\tstore: Store,\n\t...params:\n\t\t| [token: WritableFamilyToken<T, K, any>, key: NoInfer<K>]\n\t\t| [token: WritableToken<T, any, any>]\n): void\n\nexport function resetInStore<T, K extends Canonical>(\n\tstore: Store,\n\t...params:\n\t\t| [token: WritableFamilyToken<T, K, any>, key: NoInfer<K>]\n\t\t| [token: WritableToken<T, any, any>]\n): void {\n\tconst subParams = [...params, RESET_STATE] as const\n\tsetIntoStore(store, ...subParams)\n}\n", "import { writeToCache } from \"../caching\"\nimport { readOrComputeValue } from \"../get-state\"\nimport { markDone, type OpenOperation } from \"../operation\"\nimport type { WritableSelector } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { become } from \"./become\"\nimport type { ProtoUpdate } from \"./operate-on-store\"\n\nexport function setSelector<T>(\n\ttarget: Store & { operation: OpenOperation<any> },\n\tselector: WritableSelector<T, any>,\n\tnext: NoInfer<T> | ((oldValue: T) => NoInfer<T>),\n): ProtoUpdate<T> {\n\tlet oldValue: T\n\tlet newValue: T\n\tlet constant: T\n\n\tconst { type, key } = selector\n\n\tswitch (selector.type) {\n\t\tcase `writable_pure_selector`:\n\t\t\toldValue = readOrComputeValue(target, selector, `mut`)\n\t\t\tnewValue = become(next, oldValue)\n\t\t\tnewValue = writeToCache(target, selector, newValue)\n\t\t\tbreak\n\t\tcase `writable_held_selector`:\n\t\t\tconstant = selector.const\n\t\t\tbecome(next, constant)\n\t\t\toldValue = constant\n\t\t\tnewValue = constant\n\t}\n\n\ttarget.logger.info(`⭐`, type, key, `setting to`, newValue)\n\tmarkDone(target, key)\n\tselector.setSelf(newValue)\n\treturn { oldValue, newValue }\n}\n", "import type { OpenOperation } from \"../operation\"\nimport type { WritableState } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport type { ProtoUpdate } from \"./operate-on-store\"\nimport { setAtom } from \"./set-atom\"\nimport { setSelector } from \"./set-selector\"\n\nexport const setAtomOrSelector = <T>(\n\ttarget: Store & { operation: OpenOperation },\n\tstate: WritableState<T, any>,\n\tvalue: NoInfer<T> | ((oldValue: T) => NoInfer<T>),\n): ProtoUpdate<T> => {\n\tlet protoUpdate: ProtoUpdate<T>\n\tswitch (state.type) {\n\t\tcase `atom`:\n\t\tcase `mutable_atom`:\n\t\t\tprotoUpdate = setAtom(target, state, value)\n\t\t\tbreak\n\t\tcase `writable_pure_selector`:\n\t\tcase `writable_held_selector`:\n\t\t\tprotoUpdate = setSelector(target, state, value)\n\t\t\tbreak\n\t}\n\n\treturn protoUpdate\n}\n", "import type { Setter, WritableFamilyToken, WritableToken } from \"atom.io\"\nimport { type Canonical, parseJson } from \"atom.io/json\"\n\nimport { seekInStore } from \"../families\"\nimport { getFamilyOfToken } from \"../families/get-family-of-token\"\nimport { mintInStore, MUST_CREATE } from \"../families/mint-in-store\"\nimport type { OpenOperation } from \"../operation\"\nimport { closeOperation, openOperation } from \"../operation\"\nimport type { WritableFamily } from \"../state-types\"\nimport { type Store, withdraw } from \"../store\"\nimport { dispatchOrDeferStateUpdate } from \"./dispatch-state-update\"\nimport { resetAtomOrSelector } from \"./reset-atom-or-selector\"\nimport { RESET_STATE } from \"./reset-in-store\"\nimport { setAtomOrSelector } from \"./set-atom-or-selector\"\n\nexport type ProtoUpdate<T> = { oldValue: T; newValue: T }\n\nexport const OWN_OP: unique symbol = Symbol(`OWN_OP`)\nexport const JOIN_OP: unique symbol = Symbol(`JOIN_OP`)\n\nexport function operateOnStore<T, TT extends T, K extends Canonical, E>(\n\topMode: typeof JOIN_OP | typeof OWN_OP,\n\tstore: Store,\n\t...params:\n\t\t| [\n\t\t\t\ttoken: WritableFamilyToken<T, K, E>,\n\t\t\t\tkey: NoInfer<K>,\n\t\t\t\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n\t\t ]\n\t\t| [\n\t\t\t\ttoken: WritableToken<T, any, E>,\n\t\t\t\tvalue: Setter<TT> | TT | typeof RESET_STATE,\n\t\t ]\n): void {\n\tlet existingToken: WritableToken<T, K, E> | undefined\n\tlet brandNewToken: WritableToken<T, K, E> | undefined\n\tlet token: WritableToken<T, K, E>\n\tlet family: WritableFamily<T, K, E> | undefined\n\tlet key: K | null\n\tlet value: Setter<TT> | TT | typeof RESET_STATE\n\tif (params.length === 2) {\n\t\ttoken = params[0]\n\t\tvalue = params[1]\n\t\tif (`family` in token) {\n\t\t\tfamily = getFamilyOfToken(store, token)\n\t\t\tkey = parseJson(token.family.subKey)\n\t\t\texistingToken = seekInStore(store, family, key)\n\t\t\tif (!existingToken) {\n\t\t\t\ttoken = brandNewToken = mintInStore(MUST_CREATE, store, family, key)\n\t\t\t} else {\n\t\t\t\ttoken = existingToken\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfamily = withdraw(store, params[0])\n\t\tkey = params[1]\n\t\tvalue = params[2]\n\t\texistingToken = seekInStore(store, family, key)\n\t\tif (!existingToken) {\n\t\t\ttoken = brandNewToken = mintInStore(MUST_CREATE, store, family, key)\n\t\t} else {\n\t\t\ttoken = existingToken\n\t\t}\n\t}\n\n\tconst action = value === RESET_STATE ? `reset` : `set`\n\n\tlet target: Store & { operation: OpenOperation }\n\n\tif (opMode === OWN_OP) {\n\t\tconst result = openOperation(store, token)\n\t\tconst rejected = typeof result === `number`\n\t\tif (rejected) {\n\t\t\tconst rejectionTime = result\n\t\t\tconst unsubscribe = store.on.operationClose.subscribe(\n\t\t\t\t`waiting to ${action} \"${token.key}\" at T-${rejectionTime}`,\n\t\t\t\tfunction waitUntilOperationCloseToSetState() {\n\t\t\t\t\tunsubscribe()\n\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t`🟢`,\n\t\t\t\t\t\ttoken.type,\n\t\t\t\t\t\ttoken.key,\n\t\t\t\t\t\t`resuming deferred`,\n\t\t\t\t\t\taction,\n\t\t\t\t\t\t`from T-${rejectionTime}`,\n\t\t\t\t\t)\n\t\t\t\t\toperateOnStore(opMode, store, token, value)\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\ttarget = result\n\t} else {\n\t\ttarget = store as Store & { operation: OpenOperation }\n\t}\n\n\tif (`counterfeit` in token && `family` in token) {\n\t\tconst subKey = token.family.subKey\n\t\tconst disposal = store.disposalTraces.buffer.find(\n\t\t\t(item) => item?.key === subKey,\n\t\t)\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\ttoken.type,\n\t\t\ttoken.key,\n\t\t\t`could not be`,\n\t\t\taction,\n\t\t\t`because key`,\n\t\t\tsubKey,\n\t\t\t`is not allocated.`,\n\t\t\tdisposal\n\t\t\t\t? `this key was previously disposed:${disposal.trace}`\n\t\t\t\t: `(no previous disposal trace found)`,\n\t\t)\n\t\treturn\n\t}\n\n\tconst state = withdraw(target, token)\n\tlet protoUpdate: ProtoUpdate<E | T>\n\tif (value === RESET_STATE) {\n\t\tprotoUpdate = resetAtomOrSelector(target, state)\n\t} else {\n\t\tprotoUpdate = setAtomOrSelector(target, state, value)\n\t}\n\n\tconst isNewlyCreated = Boolean(brandNewToken)\n\tdispatchOrDeferStateUpdate(target, state, protoUpdate, isNewlyCreated, family)\n\n\tif (opMode === OWN_OP) {\n\t\tcloseOperation(target)\n\t}\n}\n", "import { newest } from \"./lineage\"\nimport type { Store } from \"./store\"\n\nexport type AtomKey<T> = string & { __atomKey?: never; __brand?: T }\nexport type SelectorKey<T> = string & { __selectorKey?: never; __brand?: T }\nexport type ReadonlySelectorKey<T> = string & {\n\t__readonlySelectorKey?: never\n\t__brand?: T\n}\n\nexport const isAtomKey = (store: Store, key: string): key is AtomKey<unknown> =>\n\tnewest(store).atoms.has(key)\nexport const isSelectorKey = (\n\tstore: Store,\n\tkey: string,\n): key is SelectorKey<unknown> => newest(store).writableSelectors.has(key)\nexport const isReadonlySelectorKey = (\n\tstore: Store,\n\tkey: string,\n): key is ReadonlySelectorKey<unknown> =>\n\tnewest(store).readonlySelectors.has(key)\n\nexport type StateKey<T> = AtomKey<T> | ReadonlySelectorKey<T> | SelectorKey<T>\nexport const isStateKey = (\n\tstore: Store,\n\tkey: string,\n): key is StateKey<unknown> =>\n\tisAtomKey(store, key) ||\n\tisSelectorKey(store, key) ||\n\tisReadonlySelectorKey(store, key)\n", "import type { AtomKey, ReadonlySelectorKey, SelectorKey } from \"../keys\"\nimport { isStateKey } from \"../keys\"\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\n\nexport function getSelectorDependencyKeys(\n\tstore: Store,\n\tkey: string,\n): (AtomKey<unknown> | ReadonlySelectorKey<unknown> | SelectorKey<unknown>)[] {\n\tconst sources = newest(store)\n\t\t.selectorGraph.getRelationEntries({ downstreamSelectorKey: key })\n\t\t.filter(([_, { source }]) => source !== key)\n\t\t.map(([_, { source }]) => source)\n\t\t.filter((source) => isStateKey(store, source))\n\treturn sources\n}\n", "import { isAtomKey } from \"../keys\"\nimport type { Atom } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { getSelectorDependencyKeys } from \"./get-selector-dependency-keys\"\n\nexport function traceRootSelectorAtoms(\n\tstore: Store,\n\tselectorKey: string,\n\tcovered: Set<string> = new Set<string>(),\n): Map<string, Atom<any, any>> {\n\tconst dependencies = getSelectorDependencyKeys(store, selectorKey)\n\n\tconst roots = new Map<string, Atom<unknown, unknown>>()\n\n\twhile (dependencies.length > 0) {\n\t\t// biome-ignore lint/style/noNonNullAssertion: just checked length ^^^\n\t\tconst dependencyKey = dependencies.pop()!\n\t\tif (covered.has(dependencyKey)) {\n\t\t\tcontinue\n\t\t}\n\t\tcovered.add(dependencyKey)\n\t\tif (isAtomKey(store, dependencyKey)) {\n\t\t\tconst atom = store.atoms.get(dependencyKey) as Atom<unknown, unknown>\n\t\t\troots.set(atom.key, atom)\n\t\t} else {\n\t\t\tdependencies.push(...getSelectorDependencyKeys(store, dependencyKey))\n\t\t}\n\t}\n\treturn roots\n}\n", "import type { ReadableToken } from \"atom.io\"\n\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\nimport { traceRootSelectorAtoms } from \"./trace-selector-atoms\"\n\nexport function updateSelectorAtoms(\n\tstore: Store,\n\tselectorType:\n\t\t| `readonly_held_selector`\n\t\t| `readonly_pure_selector`\n\t\t| `writable_held_selector`\n\t\t| `writable_pure_selector`,\n\tselectorKey: string,\n\tdependency: ReadableToken<unknown, any, unknown>,\n\tcovered: Set<string>,\n): void {\n\tconst target = newest(store)\n\tconst { type: dependencyType, key: dependencyKey } = dependency\n\tif (dependencyType === `atom` || dependencyType === `mutable_atom`) {\n\t\ttarget.selectorAtoms.set({\n\t\t\tselectorKey,\n\t\t\tatomKey: dependencyKey,\n\t\t})\n\t\tstore.logger.info(\n\t\t\t`🔍`,\n\t\t\tselectorType,\n\t\t\tselectorKey,\n\t\t\t`discovers root atom \"${dependencyKey}\"`,\n\t\t)\n\t} else {\n\t\tconst rootKeys = traceRootSelectorAtoms(store, dependencyKey, covered)\n\t\tstore.logger.info(\n\t\t\t`🔍`,\n\t\t\tselectorType,\n\t\t\tselectorKey,\n\t\t\t`discovers root atoms: [ ${[...rootKeys.values()]\n\t\t\t\t.map((root) => `\"${root.key}\"`)\n\t\t\t\t.join(`, `)} ]`,\n\t\t)\n\t\tfor (const { key: atomKey } of rootKeys.values()) {\n\t\t\ttarget.selectorAtoms = target.selectorAtoms.set({\n\t\t\t\tselectorKey,\n\t\t\t\tatomKey,\n\t\t\t})\n\t\t}\n\t}\n\tcovered.add(dependencyKey)\n}\n", "import type {\n\tfindState,\n\tReadableFamilyToken,\n\tReadableToken,\n\tsetState,\n\tWritableFamilyToken,\n\tWritableToken,\n\tWriterToolkit,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport { findInStore } from \"../families\"\nimport { getFallback } from \"../get-state/get-fallback\"\nimport { readOrComputeValue } from \"../get-state/read-or-compute-value\"\nimport { reduceReference } from \"../get-state/reduce-reference\"\nimport { newest } from \"../lineage\"\nimport { getJsonToken } from \"../mutable\"\nimport { JOIN_OP, operateOnStore } from \"../set-state/operate-on-store\"\nimport type { Store } from \"../store\"\nimport { withdraw } from \"../store\"\nimport { updateSelectorAtoms } from \"./update-selector-atoms\"\n\nexport function registerSelector(\n\tstore: Store,\n\tselectorType:\n\t\t| `readonly_held_selector`\n\t\t| `readonly_pure_selector`\n\t\t| `writable_held_selector`\n\t\t| `writable_pure_selector`,\n\tselectorKey: string,\n\tcovered: Set<string>,\n): WriterToolkit {\n\treturn {\n\t\tget: (\n\t\t\t...params:\n\t\t\t\t| [ReadableFamilyToken<any, any, any>, Canonical]\n\t\t\t\t| [ReadableToken<any, any, any>]\n\t\t) => {\n\t\t\tconst target = newest(store)\n\t\t\tconst { token, family, subKey } = reduceReference(store, ...params)\n\t\t\tlet dependencyValue: unknown\n\t\t\tif (`counterfeit` in token && family && subKey) {\n\t\t\t\tdependencyValue = getFallback(store, token, family, subKey)\n\t\t\t} else {\n\t\t\t\tconst dependency = withdraw(store, token)\n\t\t\t\tdependencyValue = readOrComputeValue(store, dependency)\n\t\t\t}\n\n\t\t\tstore.logger.info(\n\t\t\t\t`🔌`,\n\t\t\t\tselectorType,\n\t\t\t\tselectorKey,\n\t\t\t\t`registers dependency ( \"${token.key}\" =`,\n\t\t\t\tdependencyValue,\n\t\t\t\t`)`,\n\t\t\t)\n\n\t\t\ttarget.selectorGraph.set(\n\t\t\t\t{\n\t\t\t\t\tupstreamSelectorKey: token.key,\n\t\t\t\t\tdownstreamSelectorKey: selectorKey,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tsource: token.key,\n\t\t\t\t},\n\t\t\t)\n\t\t\tupdateSelectorAtoms(store, selectorType, selectorKey, token, covered)\n\t\t\treturn dependencyValue\n\t\t},\n\t\tset: (<T, K extends Canonical>(\n\t\t\t...params:\n\t\t\t\t| [\n\t\t\t\t\t\ttoken: WritableFamilyToken<T, K>,\n\t\t\t\t\t\tkey: NoInfer<K>,\n\t\t\t\t\t\tvalue: NoInfer<T> | ((oldValue: T) => NoInfer<T>),\n\t\t\t\t ]\n\t\t\t\t| [\n\t\t\t\t\t\ttoken: WritableToken<T>,\n\t\t\t\t\t\tvalue: NoInfer<T> | ((oldValue: T) => NoInfer<T>),\n\t\t\t\t ]\n\t\t) => {\n\t\t\tconst target = newest(store)\n\t\t\toperateOnStore(JOIN_OP, target, ...params)\n\t\t}) as typeof setState,\n\t\tfind: ((...args: Parameters<typeof findState>) =>\n\t\t\tfindInStore(store, ...args)) as typeof findState,\n\t\tjson: (token) => getJsonToken(store, token),\n\t}\n}\n", "import type {\n\tFamilyMetadata,\n\tReadonlyHeldSelectorOptions,\n\tReadonlyHeldSelectorToken,\n} from \"atom.io\"\n\nimport { writeToCache } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport type { ReadonlyHeldSelector } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { registerSelector } from \"./register-selector\"\n\nexport function createReadonlyHeldSelector<T extends object>(\n\tstore: Store,\n\toptions: ReadonlyHeldSelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n): ReadonlyHeldSelectorToken<T> {\n\tconst target = newest(store)\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\tconst covered = new Set<string>()\n\tconst { key, const: constant } = options\n\tconst type = `readonly_held_selector` as const\n\tstore.logger.info(`🔨`, type, key, `is being created`)\n\n\tconst { get, find, json } = registerSelector(target, type, key, covered)\n\n\tconst getFrom = (innerTarget: Store) => {\n\t\tconst upstreamStates = innerTarget.selectorGraph.getRelationEntries({\n\t\t\tdownstreamSelectorKey: key,\n\t\t})\n\t\tfor (const [downstreamSelectorKey, { source }] of upstreamStates) {\n\t\t\tif (source !== key) {\n\t\t\t\tinnerTarget.selectorGraph.delete(downstreamSelectorKey, key)\n\t\t\t}\n\t\t}\n\t\tinnerTarget.selectorAtoms.delete(key)\n\t\toptions.get({ get, find, json }, constant)\n\t\twriteToCache(innerTarget, readonlySelector, constant)\n\t\tstore.logger.info(`✨`, type, key, `=`, constant)\n\t\tcovered.clear()\n\t\treturn constant\n\t}\n\n\tconst readonlySelector: ReadonlyHeldSelector<T> = {\n\t\t...options,\n\t\ttype,\n\t\tsubject,\n\t\tgetFrom,\n\t\tinstall: (s: RootStore) => createReadonlyHeldSelector(s, options, family),\n\t}\n\tif (family) readonlySelector.family = family\n\n\ttarget.readonlySelectors.set(key, readonlySelector)\n\tconst token: ReadonlyHeldSelectorToken<T> = { key, type }\n\tif (family) token.family = family\n\n\treturn token\n}\n", "import type {\n\tFamilyMetadata,\n\tReadonlyPureSelectorOptions,\n\tReadonlyPureSelectorToken,\n\tStateUpdate,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport { writeToCache } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport type { ReadonlyPureSelector } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { registerSelector } from \"./register-selector\"\n\nexport function createReadonlyPureSelector<T, K extends Canonical, E>(\n\tstore: Store,\n\toptions: ReadonlyPureSelectorOptions<T, E>,\n\tfamily: FamilyMetadata<K> | undefined,\n): ReadonlyPureSelectorToken<T, K, E> {\n\tconst target = newest(store)\n\tconst subject = new Subject<StateUpdate<E | T>>()\n\tconst covered = new Set<string>()\n\tconst key = options.key\n\tconst type = `readonly_pure_selector` as const\n\tstore.logger.info(`🔨`, type, key, `is being created`)\n\n\tconst { get, find, json } = registerSelector(target, type, key, covered)\n\n\tconst getFrom = () => {\n\t\tconst innerTarget = newest(store)\n\t\tconst upstreamStates = innerTarget.selectorGraph.getRelationEntries({\n\t\t\tdownstreamSelectorKey: key,\n\t\t})\n\t\tfor (const [downstreamSelectorKey, { source }] of upstreamStates) {\n\t\t\tif (source !== key) {\n\t\t\t\tinnerTarget.selectorGraph.delete(downstreamSelectorKey, key)\n\t\t\t}\n\t\t}\n\t\tinnerTarget.selectorAtoms.delete(key)\n\t\tconst value = options.get({ get, find, json })\n\t\tconst cached = writeToCache(innerTarget, readonlySelector, value)\n\t\tstore.logger.info(`✨`, type, key, `=`, cached)\n\t\tcovered.clear()\n\t\treturn cached\n\t}\n\n\tconst readonlySelector: ReadonlyPureSelector<T, E> = {\n\t\t...options,\n\t\ttype,\n\t\tsubject,\n\t\tgetFrom,\n\t\tinstall: (s: RootStore) => createReadonlyPureSelector(s, options, family),\n\t}\n\tif (family) readonlySelector.family = family\n\n\ttarget.readonlySelectors.set(key, readonlySelector)\n\n\tconst token: ReadonlyPureSelectorToken<T> = { key, type }\n\tif (family) token.family = family\n\n\treturn token\n}\n", "import type {\n\tFamilyMetadata,\n\tWritableHeldSelectorOptions,\n\tWritableHeldSelectorToken,\n} from \"atom.io\"\n\nimport { writeToCache } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport type { WritableHeldSelector } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { registerSelector } from \"./register-selector\"\n\nexport function createWritableHeldSelector<T extends object>(\n\tstore: Store,\n\toptions: WritableHeldSelectorOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n): WritableHeldSelectorToken<T> {\n\tconst target = newest(store)\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\tconst covered = new Set<string>()\n\tconst { key, const: constant } = options\n\tconst type = `writable_held_selector` as const\n\tstore.logger.info(`🔨`, type, key, `is being created`)\n\n\tconst setterToolkit = registerSelector(target, type, key, covered)\n\tconst { find, get, json } = setterToolkit\n\tconst getterToolkit = { find, get, json }\n\n\tconst getFrom = (innerTarget: Store): T => {\n\t\tconst upstreamStates = innerTarget.selectorGraph.getRelationEntries({\n\t\t\tdownstreamSelectorKey: key,\n\t\t})\n\t\tfor (const [downstreamSelectorKey, { source }] of upstreamStates) {\n\t\t\tif (source !== key) {\n\t\t\t\tinnerTarget.selectorGraph.delete(downstreamSelectorKey, key)\n\t\t\t}\n\t\t}\n\t\tinnerTarget.selectorAtoms.delete(key)\n\t\toptions.get(getterToolkit, constant)\n\t\twriteToCache(innerTarget, mySelector, constant)\n\t\tstore.logger.info(`✨`, type, key, `=`, constant)\n\t\tcovered.clear()\n\t\treturn constant\n\t}\n\n\tconst setSelf = (): void => {\n\t\toptions.set(setterToolkit, constant)\n\t}\n\n\tconst mySelector: WritableHeldSelector<T> = {\n\t\t...options,\n\t\ttype,\n\t\tsubject,\n\t\tgetFrom,\n\t\tsetSelf,\n\t\tinstall: (s: RootStore) => createWritableHeldSelector(s, options, family),\n\t}\n\tif (family) mySelector.family = family\n\n\ttarget.writableSelectors.set(key, mySelector)\n\n\tconst token: WritableHeldSelectorToken<T> = { key, type }\n\tif (family) token.family = family\n\n\treturn token\n}\n", "import type {\n\tFamilyMetadata,\n\tStateUpdate,\n\tWritablePureSelectorOptions,\n\tWritablePureSelectorToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport { writeToCache } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport type { WritablePureSelector } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { registerSelector } from \"./register-selector\"\n\nexport function createWritablePureSelector<T, K extends Canonical, E>(\n\tstore: Store,\n\toptions: WritablePureSelectorOptions<T, E>,\n\tfamily: FamilyMetadata<K> | undefined,\n): WritablePureSelectorToken<T, K, E> {\n\tconst target = newest(store)\n\tconst subject = new Subject<StateUpdate<E | T>>()\n\tconst covered = new Set<string>()\n\tconst key = options.key\n\tconst type = `writable_pure_selector` as const\n\tstore.logger.info(`🔨`, type, key, `is being created`)\n\n\tconst setterToolkit = registerSelector(target, type, key, covered)\n\tconst { find, get, json } = setterToolkit\n\tconst getterToolkit = { find, get, json }\n\n\tconst getFrom = (innerTarget: Store): E | T => {\n\t\tconst upstreamStates = innerTarget.selectorGraph.getRelationEntries({\n\t\t\tdownstreamSelectorKey: key,\n\t\t})\n\t\tfor (const [downstreamSelectorKey, { source }] of upstreamStates) {\n\t\t\tif (source !== key) {\n\t\t\t\tinnerTarget.selectorGraph.delete(downstreamSelectorKey, key)\n\t\t\t}\n\t\t}\n\t\tinnerTarget.selectorAtoms.delete(key)\n\t\tconst value = options.get(getterToolkit)\n\t\tconst cached = writeToCache(innerTarget, mySelector, value)\n\t\tstore.logger.info(`✨`, type, key, `=`, cached)\n\t\tcovered.clear()\n\t\treturn cached\n\t}\n\n\tconst setSelf = (newValue: T): void => {\n\t\toptions.set(setterToolkit, newValue)\n\t}\n\n\tconst mySelector: WritablePureSelector<T, E> = {\n\t\t...options,\n\t\ttype,\n\t\tsubject,\n\t\tgetFrom,\n\t\tsetSelf,\n\t\tinstall: (s: RootStore) => createWritablePureSelector(s, options, family),\n\t}\n\tif (family) mySelector.family = family\n\n\ttarget.writableSelectors.set(key, mySelector)\n\n\tconst token: WritablePureSelectorToken<T> = { key, type }\n\tif (family) token.family = family\n\n\treturn token\n}\n", "import type {\n\tReadonlyHeldSelectorOptions,\n\tReadonlyHeldSelectorToken,\n\tReadonlyPureSelectorOptions,\n\tReadonlyPureSelectorToken,\n\tWritableHeldSelectorOptions,\n\tWritableHeldSelectorToken,\n\tWritablePureSelectorOptions,\n\tWritablePureSelectorToken,\n} from \"atom.io\"\n\nimport type { Store } from \"../store\"\nimport { createReadonlyHeldSelector } from \"./create-readonly-held-selector\"\nimport { createReadonlyPureSelector } from \"./create-readonly-pure-selector\"\nimport { createWritableHeldSelector } from \"./create-writable-held-selector\"\nimport { createWritablePureSelector } from \"./create-writable-pure-selector\"\n\nexport function createStandaloneSelector<T extends object>(\n\tstore: Store,\n\toptions: WritableHeldSelectorOptions<T>,\n): WritableHeldSelectorToken<T>\nexport function createStandaloneSelector<T extends object>(\n\tstore: Store,\n\toptions: ReadonlyHeldSelectorOptions<T>,\n): ReadonlyHeldSelectorToken<T>\nexport function createStandaloneSelector<T, E>(\n\tstore: Store,\n\toptions: WritablePureSelectorOptions<T, E>,\n): WritablePureSelectorToken<T, any, E>\nexport function createStandaloneSelector<T, E>(\n\tstore: Store,\n\toptions: ReadonlyPureSelectorOptions<T, E>,\n): ReadonlyPureSelectorToken<T, any, E>\nexport function createStandaloneSelector(\n\tstore: Store,\n\toptions:\n\t\t| ReadonlyHeldSelectorOptions<any>\n\t\t| ReadonlyPureSelectorOptions<any, any>\n\t\t| WritableHeldSelectorOptions<any>\n\t\t| WritablePureSelectorOptions<any, any>,\n):\n\t| ReadonlyHeldSelectorToken<any>\n\t| ReadonlyPureSelectorToken<any, any, any>\n\t| WritableHeldSelectorToken<any>\n\t| WritablePureSelectorToken<any, any, any> {\n\tconst isWritable = `set` in options\n\tconst isHeld = `const` in options\n\n\tif (isHeld && isWritable) {\n\t\tconst state = createWritableHeldSelector(store, options, undefined)\n\t\tstore.on.selectorCreation.next(state)\n\t\treturn state\n\t}\n\tif (isHeld) {\n\t\tconst state = createReadonlyHeldSelector(store, options, undefined)\n\t\tstore.on.selectorCreation.next(state)\n\t\treturn state\n\t}\n\tif (isWritable) {\n\t\tconst state = createWritablePureSelector(store, options, undefined)\n\t\tstore.on.selectorCreation.next(state)\n\t\treturn state\n\t}\n\tconst state = createReadonlyPureSelector(store, options, undefined)\n\tstore.on.selectorCreation.next(state)\n\treturn state\n}\n", "import type { SelectorFamilyToken, SelectorToken } from \"atom.io\"\n\nimport { newest } from \"../lineage\"\nimport { type Store, withdraw } from \"../store\"\nimport { isChildStore } from \"../transaction\"\n\nexport function disposeSelector(\n\tstore: Store,\n\tselectorToken: SelectorToken<unknown, any, any>,\n): void {\n\tconst target = newest(store)\n\tconst { key, type, family: familyMeta } = selectorToken\n\tif (!familyMeta) {\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\ttype,\n\t\t\tkey,\n\t\t\t`Standalone selectors cannot be disposed.`,\n\t\t)\n\t} else {\n\t\tconst molecule = target.molecules.get(familyMeta.subKey)\n\t\tif (molecule) {\n\t\t\ttarget.moleculeData.delete(familyMeta.subKey, familyMeta.key)\n\t\t}\n\t\tlet familyToken: SelectorFamilyToken<any, any, any>\n\t\tswitch (selectorToken.type) {\n\t\t\tcase `writable_held_selector`:\n\t\t\t\t{\n\t\t\t\t\ttarget.writableSelectors.delete(key)\n\t\t\t\t\tfamilyToken = {\n\t\t\t\t\t\tkey: familyMeta.key,\n\t\t\t\t\t\ttype: `writable_held_selector_family`,\n\t\t\t\t\t}\n\t\t\t\t\tconst family = withdraw(store, familyToken)\n\t\t\t\t\tfamily.subject.next({\n\t\t\t\t\t\ttype: `state_disposal`,\n\t\t\t\t\t\tsubType: `selector`,\n\t\t\t\t\t\ttoken: selectorToken,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase `writable_pure_selector`:\n\t\t\t\t{\n\t\t\t\t\ttarget.writableSelectors.delete(key)\n\t\t\t\t\tfamilyToken = {\n\t\t\t\t\t\tkey: familyMeta.key,\n\t\t\t\t\t\ttype: `writable_pure_selector_family`,\n\t\t\t\t\t}\n\t\t\t\t\tconst family = withdraw(store, familyToken)\n\t\t\t\t\tfamily.subject.next({\n\t\t\t\t\t\ttype: `state_disposal`,\n\t\t\t\t\t\tsubType: `selector`,\n\t\t\t\t\t\ttoken: selectorToken,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase `readonly_held_selector`:\n\t\t\t\t{\n\t\t\t\t\ttarget.readonlySelectors.delete(key)\n\t\t\t\t\tfamilyToken = {\n\t\t\t\t\t\tkey: familyMeta.key,\n\t\t\t\t\t\ttype: `readonly_held_selector_family`,\n\t\t\t\t\t}\n\t\t\t\t\tconst family = withdraw(store, familyToken)\n\t\t\t\t\tfamily.subject.next({\n\t\t\t\t\t\ttype: `state_disposal`,\n\t\t\t\t\t\tsubType: `selector`,\n\t\t\t\t\t\ttoken: selectorToken,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase `readonly_pure_selector`:\n\t\t\t\t{\n\t\t\t\t\ttarget.readonlySelectors.delete(key)\n\t\t\t\t\tfamilyToken = {\n\t\t\t\t\t\tkey: familyMeta.key,\n\t\t\t\t\t\ttype: `readonly_pure_selector_family`,\n\t\t\t\t\t}\n\t\t\t\t\tconst family = withdraw(store, familyToken)\n\t\t\t\t\tfamily.subject.next({\n\t\t\t\t\t\ttype: `state_disposal`,\n\t\t\t\t\t\tsubType: `selector`,\n\t\t\t\t\t\ttoken: selectorToken,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\n\t\ttarget.valueMap.delete(key)\n\t\ttarget.selectorAtoms.delete(key)\n\t\ttarget.selectorGraph.delete(key)\n\t\ttarget.moleculeData.delete(familyMeta.key, familyMeta.subKey)\n\t\tstore.logger.info(`🔥`, selectorToken.type, key, `deleted`)\n\t\tif (isChildStore(target) && target.transactionMeta.phase === `building`) {\n\t\t\ttarget.transactionMeta.update.subEvents.push({\n\t\t\t\ttype: `state_disposal`,\n\t\t\t\tsubType: `selector`,\n\t\t\t\ttoken: selectorToken,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t})\n\t\t} else {\n\t\t\tstore.on.selectorDisposal.next(selectorToken)\n\t\t}\n\t}\n}\n", "import { newest } from \"../lineage\"\nimport type { ReadableState } from \"../state-types\"\nimport type { Store } from \"../store\"\n\nexport const recallState = <T, E>(\n\tstore: Store,\n\tstate: ReadableState<T, E>,\n): T => {\n\tconst target = newest(store)\n\tif (target.operation.open) {\n\t\treturn target.operation.prev.get(state.key)\n\t}\n\treturn target.valueMap.get(state.key)\n}\n", "import { readOrComputeValue } from \"../get-state/read-or-compute-value\"\nimport type { Atom, Selector } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { recallState } from \"./recall-state\"\n\nexport const subscribeToRootDependency = (\n\ttarget: Store,\n\tselector: Selector<any, any>,\n\tatom: Atom<any, any>,\n): (() => void) => {\n\treturn atom.subject.subscribe(\n\t\t`${selector.type}:${selector.key}`,\n\t\t(atomChange) => {\n\t\t\ttarget.logger.info(\n\t\t\t\t`📢`,\n\t\t\t\tselector.type,\n\t\t\t\tselector.key,\n\t\t\t\t`root`,\n\t\t\t\tatom.key,\n\t\t\t\t`went`,\n\t\t\t\tatomChange.oldValue,\n\t\t\t\t`->`,\n\t\t\t\tatomChange.newValue,\n\t\t\t)\n\t\t\tconst oldValue = recallState(target, selector)\n\t\t\tconst newValue = readOrComputeValue(target, selector)\n\t\t\ttarget.logger.info(\n\t\t\t\t`✨`,\n\t\t\t\tselector.type,\n\t\t\t\tselector.key,\n\t\t\t\t`went`,\n\t\t\t\toldValue,\n\t\t\t\t`->`,\n\t\t\t\tnewValue,\n\t\t\t)\n\t\t\tselector.subject.next({ newValue, oldValue })\n\t\t},\n\t)\n}\n", "import type { ReadableToken, StateUpdate, UpdateHandler } from \"atom.io\"\n\nimport { hasRole } from \"../atom\"\nimport { readOrComputeValue } from \"../get-state\"\nimport { reduceReference } from \"../get-state/reduce-reference\"\nimport { traceRootSelectorAtoms } from \"../selector\"\nimport type { Store } from \"../store\"\nimport { withdraw } from \"../store\"\nimport { subscribeToRootDependency } from \"./subscribe-to-root-atoms\"\n\nexport function subscribeToState<T, E>(\n\tstore: Store,\n\ttoken: ReadableToken<T, any, E>,\n\tkey: string,\n\thandleUpdate: UpdateHandler<E | T>,\n): () => void {\n\tfunction safelyHandleUpdate(update: StateUpdate<any>): void {\n\t\tif (store.operation.open) {\n\t\t\tif (\n\t\t\t\tstate?.type === `atom` &&\n\t\t\t\thasRole(state, `tracker:signal`) &&\n\t\t\t\t`*` + store.operation.token.key === token.key &&\n\t\t\t\t`inboundTracker` in handleUpdate\n\t\t\t) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst unsubscribe = store.on.operationClose.subscribe(\n\t\t\t\t`state subscription ${key}`,\n\t\t\t\t() => {\n\t\t\t\t\tunsubscribe()\n\t\t\t\t\thandleUpdate(update)\n\t\t\t\t},\n\t\t\t)\n\t\t} else {\n\t\t\thandleUpdate(update)\n\t\t}\n\t}\n\treduceReference(store, token)\n\tconst state = withdraw(store, token)\n\tstore.logger.info(`👀`, state.type, state.key, `Adding subscription \"${key}\"`)\n\tconst isSelector =\n\t\tstate.type === `writable_pure_selector` ||\n\t\tstate.type === `readonly_pure_selector`\n\tconst rootSubs = new Map<string, () => void>()\n\tlet updateHandler: UpdateHandler<E | T> = safelyHandleUpdate\n\tif (isSelector) {\n\t\treadOrComputeValue(store, state)\n\t\tfor (const [atomKey, atom] of traceRootSelectorAtoms(store, state.key)) {\n\t\t\trootSubs.set(atomKey, subscribeToRootDependency(store, state, atom))\n\t\t}\n\t\tupdateHandler = function updateRootsBeforeHandlingUpdate(update) {\n\t\t\tconst dependencies = traceRootSelectorAtoms(store, state.key)\n\t\t\tfor (const [previousRootKey, unsub] of rootSubs) {\n\t\t\t\tconst currentRoot = dependencies.get(previousRootKey)\n\t\t\t\tif (currentRoot) {\n\t\t\t\t\tdependencies.delete(previousRootKey)\n\t\t\t\t} else {\n\t\t\t\t\tunsub()\n\t\t\t\t\trootSubs.delete(previousRootKey)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [atomKey, atom] of dependencies) {\n\t\t\t\trootSubs.set(atomKey, subscribeToRootDependency(store, state, atom))\n\t\t\t}\n\t\t\tsafelyHandleUpdate(update)\n\t\t}\n\t}\n\tconst mainUnsubFunction = state.subject.subscribe(key, updateHandler)\n\tconst unsubscribe = () => {\n\t\tstore.logger.info(\n\t\t\t`🙈`,\n\t\t\tstate.type,\n\t\t\tstate.key,\n\t\t\t`Removing subscription \"${key}\"`,\n\t\t)\n\t\tmainUnsubFunction()\n\t\tfor (const unsubFromDependency of rootSubs.values()) {\n\t\t\tunsubFromDependency()\n\t\t}\n\t}\n\n\treturn unsubscribe\n}\n", "import type { TimelineEvent, TimelineManageable, TimelineToken } from \"atom.io\"\n\nimport type { Store } from \"../store/store\"\nimport { withdraw } from \"../store/withdraw\"\n\nexport const subscribeToTimeline = <ManagedAtom extends TimelineManageable>(\n\tstore: Store,\n\ttoken: TimelineToken<ManagedAtom>,\n\tkey: string,\n\thandleUpdate: (update: TimelineEvent<any> | `redo` | `undo`) => void,\n): (() => void) => {\n\tconst tl = withdraw(store, token)\n\tstore.logger.info(`👀`, `timeline`, token.key, `Adding subscription \"${key}\"`)\n\tconst unsubscribe = tl.subject.subscribe(key, handleUpdate)\n\treturn () => {\n\t\tstore.logger.info(\n\t\t\t`🙈`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Removing subscription \"${key}\" from timeline`,\n\t\t)\n\t\tunsubscribe()\n\t}\n}\n", "import type { TransactionToken, TransactionUpdateHandler } from \"atom.io\"\n\nimport type { Store } from \"../store\"\nimport { withdraw } from \"../store\"\nimport type { Fn } from \"../utility-types\"\n\nexport const subscribeToTransaction = <F extends Fn>(\n\tstore: Store,\n\ttoken: TransactionToken<F>,\n\tkey: string,\n\thandleUpdate: TransactionUpdateHandler<F>,\n): (() => void) => {\n\tconst tx = withdraw(store, token)\n\tstore.logger.info(\n\t\t`👀`,\n\t\t`transaction`,\n\t\ttoken.key,\n\t\t`Adding subscription \"${key}\"`,\n\t)\n\tconst unsubscribe = tx.subject.subscribe(key, handleUpdate)\n\treturn () => {\n\t\tstore.logger.info(\n\t\t\t`🙈`,\n\t\t\t`transaction`,\n\t\t\ttoken.key,\n\t\t\t`Removing subscription \"${key}\"`,\n\t\t)\n\t\tunsubscribe()\n\t}\n}\n", "import type {\n\tReadableToken,\n\tTimelineEvent,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tTransactionUpdateHandler,\n\tUpdateHandler,\n} from \"atom.io\"\n\nimport { arbitrary } from \"../arbitrary\"\nimport type { Store } from \"../store\"\nimport type { Fn } from \"../utility-types\"\nimport { subscribeToState } from \"./subscribe-to-state\"\nimport { subscribeToTimeline } from \"./subscribe-to-timeline\"\nimport { subscribeToTransaction } from \"./subscribe-to-transaction\"\n\nexport function subscribeInStore<T>(\n\tstore: Store,\n\ttoken: ReadableToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tkey?: string,\n): () => void\nexport function subscribeInStore<F extends Fn>(\n\tstore: Store,\n\ttoken: TransactionToken<F>,\n\thandleUpdate: TransactionUpdateHandler<F>,\n\tkey?: string,\n): () => void\nexport function subscribeInStore<M extends TimelineManageable>(\n\tstore: Store,\n\ttoken: TimelineToken<M>,\n\thandleUpdate: (update: TimelineEvent<M> | `redo` | `undo`) => void,\n\tkey?: string,\n): () => void\nexport function subscribeInStore<M extends TimelineManageable>(\n\tstore: Store,\n\ttoken: ReadableToken<any> | TimelineToken<M> | TransactionToken<any>,\n\thandleUpdate:\n\t\t| TransactionUpdateHandler<any>\n\t\t| UpdateHandler<any>\n\t\t| ((update: TimelineEvent<M> | `redo` | `undo`) => void),\n\tkey?: string,\n): () => void\nexport function subscribeInStore(\n\tstore: Store,\n\ttoken: ReadableToken<any> | TimelineToken<any> | TransactionToken<any>,\n\thandleUpdate: (update: any) => void,\n\tkey: string = arbitrary(),\n): () => void {\n\tswitch (token.type) {\n\t\tcase `atom`:\n\t\tcase `mutable_atom`:\n\t\tcase `readonly_pure_selector`:\n\t\tcase `readonly_held_selector`:\n\t\tcase `writable_pure_selector`:\n\t\tcase `writable_held_selector`:\n\t\t\treturn subscribeToState(store, token, key, handleUpdate)\n\t\tcase `transaction`:\n\t\t\treturn subscribeToTransaction(store, token, key, handleUpdate)\n\t\tcase `timeline`:\n\t\t\treturn subscribeToTimeline(store, token, key, handleUpdate)\n\t}\n}\n", "import type {\n\tFamilyMetadata,\n\tMutableAtomToken,\n\tRegularAtomToken,\n\tStateUpdate,\n} from \"atom.io\"\n\nimport { createRegularAtom } from \"../atom\"\nimport { getFromStore } from \"../get-state\"\nimport { newest } from \"../lineage\"\nimport { setIntoStore } from \"../set-state\"\nimport { JOIN_OP, operateOnStore } from \"../set-state/operate-on-store\"\nimport type { Store } from \"../store\"\nimport { subscribeToState, subscribeToTimeline } from \"../subscribe\"\nimport { isChildStore } from \"../transaction/is-root-store\"\nimport type { SignalFrom, Transceiver } from \"./transceiver\"\n\n/**\n * @internal Give the tracker a transceiver state and a store, and it will\n * subscribe to the transceiver's inner value. When the inner value changes,\n * the tracker will update its own state to reflect the change.\n */\nexport class Tracker<T extends Transceiver<any, any, any>> {\n\tprivate initializeSignalAtom(\n\t\tmutableState: MutableAtomToken<T>,\n\t\tstore: Store,\n\t): RegularAtomToken<SignalFrom<T> | null> {\n\t\tconst latestSignalStateKey = `*${mutableState.key}`\n\t\tstore.atoms.delete(latestSignalStateKey)\n\t\tstore.valueMap.delete(latestSignalStateKey)\n\t\tconst familyMetaData: FamilyMetadata | undefined = mutableState.family\n\t\t\t? {\n\t\t\t\t\tkey: `*${mutableState.family.key}`,\n\t\t\t\t\tsubKey: mutableState.family.subKey,\n\t\t\t\t}\n\t\t\t: undefined\n\t\tconst latestSignalState = createRegularAtom<\n\t\t\tSignalFrom<T> | null,\n\t\t\tany,\n\t\t\tnever\n\t\t>(\n\t\t\tstore,\n\t\t\t{\n\t\t\t\tkey: latestSignalStateKey,\n\t\t\t\tdefault: null,\n\t\t\t},\n\t\t\tfamilyMetaData,\n\t\t\t[`tracker:signal`],\n\t\t)\n\t\tif (store.parent?.valueMap.has(latestSignalStateKey)) {\n\t\t\tconst parentValue = store.parent.valueMap.get(latestSignalStateKey)\n\t\t\tstore.valueMap.set(latestSignalStateKey, parentValue)\n\t\t}\n\n\t\treturn latestSignalState\n\t}\n\n\tprivate unsubscribeFromInnerValue!: () => void\n\tprivate unsubscribeFromState!: () => void\n\tprivate captureSignalsFromCore(\n\t\tmutableState: MutableAtomToken<T, any>,\n\t\tlatestSignalState: RegularAtomToken<SignalFrom<T> | null>,\n\t\ttarget: Store,\n\t): void {\n\t\tconst stateKey = mutableState.key\n\t\tconst storeName = target.config.name\n\t\tconst storeStatus = isChildStore(target)\n\t\t\t? target.transactionMeta.update.token.key\n\t\t\t: `main`\n\t\tconst subscriptionKey = `tracker-from-core:${storeName}:${storeStatus}:${stateKey}`\n\t\tconst trackerCapturesOutboundSignal = (update: SignalFrom<T>) => {\n\t\t\toperateOnStore(JOIN_OP, target, latestSignalState, update)\n\t\t}\n\t\tconst originalInnerValue = getFromStore(target, mutableState)\n\t\tthis.unsubscribeFromInnerValue = originalInnerValue.subscribe(\n\t\t\tsubscriptionKey,\n\t\t\ttrackerCapturesOutboundSignal,\n\t\t)\n\t\tthis.unsubscribeFromState = subscribeToState(\n\t\t\ttarget,\n\t\t\tmutableState,\n\t\t\tsubscriptionKey,\n\t\t\tfunction trackerLooksForNewReference(update: SignalFrom<T>) {\n\t\t\t\tif (update.newValue !== update.oldValue) {\n\t\t\t\t\tthis.unsubscribeFromInnerValue()\n\t\t\t\t\tthis.unsubscribeFromInnerValue = update.newValue.subscribe(\n\t\t\t\t\t\tsubscriptionKey,\n\t\t\t\t\t\ttrackerCapturesOutboundSignal,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}.bind(this),\n\t\t)\n\t}\n\n\tprivate supplySignalsToCore(\n\t\tmutableState: MutableAtomToken<T>,\n\t\tlatestSignalState: RegularAtomToken<SignalFrom<T> | null>,\n\t\ttarget: Store,\n\t): void {\n\t\tconst stateKey = mutableState.key\n\t\tconst storeName = target.config.name\n\t\tconst storeStatus = isChildStore(target)\n\t\t\t? target.transactionMeta.update.token.key\n\t\t\t: `main`\n\t\tconst subscriptionKey = `tracker-to-core:${storeName}:${storeStatus}:${stateKey}`\n\t\tsubscribeToState(\n\t\t\ttarget,\n\t\t\tlatestSignalState,\n\t\t\tsubscriptionKey,\n\t\t\tObject.assign(\n\t\t\t\tfunction trackerCapturesInboundSignal({\n\t\t\t\t\tnewValue,\n\t\t\t\t\toldValue,\n\t\t\t\t}: StateUpdate<SignalFrom<T> | null>) {\n\t\t\t\t\tconst timelineId = target.timelineTopics.getRelatedKey(\n\t\t\t\t\t\tlatestSignalState.key,\n\t\t\t\t\t)\n\n\t\t\t\t\tif (timelineId && target.timelines.get(timelineId)?.timeTraveling) {\n\t\t\t\t\t\tconst unsubscribe = subscribeToTimeline(\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\t{ key: timelineId, type: `timeline` },\n\t\t\t\t\t\t\tsubscriptionKey,\n\t\t\t\t\t\t\tfunction trackerWaitsForTimeTravelToFinish(update) {\n\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\tsetIntoStore(target, mutableState, (transceiver) => {\n\t\t\t\t\t\t\t\t\tif (update === `redo` && newValue) {\n\t\t\t\t\t\t\t\t\t\ttransceiver.do(newValue)\n\t\t\t\t\t\t\t\t\t} else if (update === `undo` && oldValue) {\n\t\t\t\t\t\t\t\t\t\ttransceiver.undo(oldValue)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn transceiver\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// const mutable = getFromStore(target, mutableState)\n\t\t\t\t\t// const updateNumber = mutable.getUpdateNumber(newValue)\n\t\t\t\t\t// const eventOffset = updateNumber - mutable.cacheUpdateNumber\n\t\t\t\t\t// if (newValue && eventOffset === 1) {\n\t\t\t\t\tsetIntoStore(\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\tmutableState,\n\t\t\t\t\t\t(transceiver) => (transceiver.do(newValue), transceiver),\n\t\t\t\t\t)\n\t\t\t\t\t// } else {\n\t\t\t\t\t// \tconst expected = mutable.cacheUpdateNumber + 1\n\t\t\t\t\t// \ttarget.logger.info(\n\t\t\t\t\t// \t\t`❌`,\n\t\t\t\t\t// \t\t`mutable_atom`,\n\t\t\t\t\t// \t\tmutableState.key,\n\t\t\t\t\t// \t\t`could not be updated. Expected update number`,\n\t\t\t\t\t// \t\texpected,\n\t\t\t\t\t// \t\t`but got`,\n\t\t\t\t\t// \t\tupdateNumber,\n\t\t\t\t\t// \t)\n\t\t\t\t\t// }\n\t\t\t\t},\n\t\t\t\t{ inboundTracker: true },\n\t\t\t),\n\t\t)\n\t}\n\n\tpublic mutableAtomToken: MutableAtomToken<T>\n\tpublic latestSignalToken: RegularAtomToken<SignalFrom<T> | null>\n\n\tpublic [Symbol.dispose]!: () => void\n\n\tpublic constructor(mutableAtomToken: MutableAtomToken<T>, store: Store) {\n\t\tconst target = newest(store)\n\t\tconst latestSignalToken = this.initializeSignalAtom(mutableAtomToken, target)\n\t\tthis.mutableAtomToken = mutableAtomToken\n\t\tthis.latestSignalToken = latestSignalToken\n\t\tthis.captureSignalsFromCore(mutableAtomToken, latestSignalToken, target)\n\t\tthis.supplySignalsToCore(mutableAtomToken, latestSignalToken, target)\n\t\ttarget.trackers.set(mutableAtomToken.key, this)\n\t\tthis[Symbol.dispose] = () => {\n\t\t\tthis.unsubscribeFromInnerValue()\n\t\t\tthis.unsubscribeFromState()\n\t\t\ttarget.trackers.delete(mutableAtomToken.key)\n\t\t}\n\t}\n}\n", "import type {\n\tFamilyMetadata,\n\tMutableAtomOptions,\n\tMutableAtomToken,\n\tUpdateHandler,\n} from \"atom.io\"\n\nimport { eldest, newest } from \"../lineage\"\nimport { createStandaloneSelector } from \"../selector\"\nimport { resetInStore, setIntoStore } from \"../set-state\"\nimport type { MutableAtom } from \"../state-types\"\nimport { deposit, type Store } from \"../store\"\nimport { Subject } from \"../subject\"\nimport { subscribeToState } from \"../subscribe\"\nimport type { RootStore } from \"../transaction\"\nimport { Tracker } from \"./tracker\"\nimport type { Transceiver } from \"./transceiver\"\n\nexport function createMutableAtom<T extends Transceiver<any, any, any>>(\n\tstore: Store,\n\toptions: MutableAtomOptions<T>,\n\tfamily: FamilyMetadata | undefined,\n): MutableAtomToken<T> {\n\tstore.logger.info(\n\t\t`🔨`,\n\t\t`atom`,\n\t\toptions.key,\n\t\t`creating in store \"${store.config.name}\"`,\n\t)\n\tconst target = newest(store)\n\tconst { key } = options\n\tconst existing = target.atoms.get(key)\n\tconst type = `mutable_atom`\n\tif (existing?.type === type && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\ttype,\n\t\t\tkey,\n\t\t\t`Tried to create atom, but it already exists in the store.`,\n\t\t)\n\t\treturn deposit(existing)\n\t}\n\tconst subject = new Subject<{\n\t\tnewValue: T\n\t\toldValue: T\n\t}>()\n\tconst newAtom: MutableAtom<T> = {\n\t\t...options,\n\t\ttype,\n\t\tinstall: (s: RootStore) => {\n\t\t\ts.logger.info(`🛠️`, `atom`, key, `installing in store \"${s.config.name}\"`)\n\t\t\treturn createMutableAtom(s, options, family)\n\t\t},\n\t\tsubject,\n\t} as const\n\tif (family) {\n\t\tnewAtom.family = family\n\t}\n\ttarget.atoms.set(newAtom.key, newAtom)\n\tconst token = deposit(newAtom)\n\n\tnew Tracker(token, store)\n\tif (!family) {\n\t\tcreateStandaloneSelector(store, {\n\t\t\tkey: `${key}:JSON`,\n\t\t\tget: ({ get }) => get(token).toJSON(),\n\t\t\tset: ({ set }, newValue) => {\n\t\t\t\tset(token, options.class.fromJSON(newValue))\n\t\t\t},\n\t\t})\n\t}\n\n\tif (options.effects) {\n\t\tlet effectIndex = 0\n\t\tconst cleanupFunctions: (() => void)[] = []\n\t\tfor (const effect of options.effects) {\n\t\t\tconst cleanup = effect({\n\t\t\t\tresetSelf: () => {\n\t\t\t\t\tresetInStore(store, token)\n\t\t\t\t},\n\t\t\t\tsetSelf: (next) => {\n\t\t\t\t\tsetIntoStore(store, token, next)\n\t\t\t\t},\n\t\t\t\tonSet: (handle: UpdateHandler<T>) =>\n\t\t\t\t\tsubscribeToState(store, token, `effect[${effectIndex}]`, handle),\n\t\t\t\ttoken: token as any,\n\t\t\t\tstore: eldest(store),\n\t\t\t})\n\t\t\tif (cleanup) {\n\t\t\t\tcleanupFunctions.push(cleanup)\n\t\t\t}\n\t\t\t++effectIndex\n\t\t}\n\t\tnewAtom.cleanup = () => {\n\t\t\tfor (const cleanup of cleanupFunctions) {\n\t\t\t\tcleanup()\n\t\t\t}\n\t\t}\n\t}\n\n\tstore.on.atomCreation.next(token)\n\treturn token\n}\n", "import type { MutableAtomToken, StateLifecycleEvent } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { parseJson } from \"atom.io/json\"\n\nimport { createRegularAtomFamily } from \"../families\"\nimport type { MutableAtomFamily, RegularAtomFamily } from \"../state-types\"\nimport { withdraw } from \"../store\"\nimport type { RootStore } from \"../transaction\"\nimport { Tracker } from \"./tracker\"\nimport type { SignalFrom, Transceiver } from \"./transceiver\"\n\nexport class FamilyTracker<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n> {\n\tprivate trackers: Map<K, Tracker<T>> = new Map()\n\n\tpublic readonly latestSignalAtoms: RegularAtomFamily<SignalFrom<T> | null, K>\n\tpublic readonly mutableAtoms: MutableAtomFamily<T, K>\n\n\tpublic constructor(mutableAtoms: MutableAtomFamily<T, K>, store: RootStore) {\n\t\tconst latestSignalAtoms = createRegularAtomFamily<\n\t\t\tSignalFrom<T> | null,\n\t\t\tK,\n\t\t\tnever\n\t\t>(\n\t\t\tstore,\n\t\t\t{\n\t\t\t\tkey: `*${mutableAtoms.key}`,\n\t\t\t\tdefault: null,\n\t\t\t},\n\t\t\t[`mutable`, `updates`],\n\t\t)\n\t\tthis.latestSignalAtoms = withdraw(store, latestSignalAtoms)\n\t\tthis.mutableAtoms = mutableAtoms\n\t\tconst trackerFamilyWatchesForCreationAndDisposalEvents = (\n\t\t\tevent: StateLifecycleEvent<MutableAtomToken<T>>,\n\t\t) => {\n\t\t\tconst { type, token } = event\n\t\t\tif (token.family) {\n\t\t\t\tconst key = parseJson(token.family.subKey)\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase `state_creation`:\n\t\t\t\t\t\tthis.trackers.set(key, new Tracker<T>(token, store))\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase `state_disposal`: {\n\t\t\t\t\t\tconst tracker = this.trackers.get(key)\n\t\t\t\t\t\tif (tracker) {\n\t\t\t\t\t\t\ttracker[Symbol.dispose]()\n\t\t\t\t\t\t\tthis.trackers.delete(key)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.mutableAtoms.subject.subscribe(\n\t\t\t`store=${store.config.name}::tracker-atom-family`,\n\t\t\ttrackerFamilyWatchesForCreationAndDisposalEvents,\n\t\t)\n\t}\n}\n", "import type {\n\tFamilyMetadata,\n\tMutableAtomFamilyOptions,\n\tMutableAtomFamilyToken,\n\tMutableAtomOptions,\n\tMutableAtomToken,\n\tStateLifecycleEvent,\n} from \"atom.io\"\nimport { PRETTY_TOKEN_TYPES } from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\nimport { stringifyJson } from \"atom.io/json\"\n\nimport { createWritablePureSelectorFamily } from \"../families\"\nimport { newest } from \"../lineage\"\nimport { createMutableAtom } from \"../mutable\"\nimport type { MutableAtomFamily } from \"../state-types\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { FamilyTracker } from \"./tracker-family\"\nimport type { AsJSON, Transceiver } from \"./transceiver\"\n\nexport function createMutableAtomFamily<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(\n\tstore: RootStore,\n\toptions: MutableAtomFamilyOptions<T, K>,\n\tinternalRoles?: string[],\n): MutableAtomFamilyToken<T, K> {\n\tconst familyToken: MutableAtomFamilyToken<T & Transceiver<any, any, any>, K> =\n\t\t{\n\t\t\tkey: options.key,\n\t\t\ttype: `mutable_atom_family`,\n\t\t}\n\n\tconst existing = store.families.get(options.key)\n\tif (existing && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❗`,\n\t\t\t`mutable_atom_family`,\n\t\t\toptions.key,\n\t\t\t`Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} \"${existing.key}\" in store \"${store.config.name}\". You can safely ignore this warning if it is due to hot module replacement.`,\n\t\t)\n\t}\n\n\tconst subject = new Subject<StateLifecycleEvent<MutableAtomToken<T>>>()\n\n\tconst create = (key: K): MutableAtomToken<T> => {\n\t\tconst subKey = stringifyJson(key)\n\t\tconst family: FamilyMetadata = { key: options.key, subKey }\n\t\tconst fullKey = `${options.key}(${subKey})`\n\t\tconst target = newest(store)\n\n\t\tconst individualOptions: MutableAtomOptions<T> = {\n\t\t\tkey: fullKey,\n\t\t\tclass: options.class,\n\t\t}\n\t\tif (options.effects) {\n\t\t\tindividualOptions.effects = options.effects(key)\n\t\t}\n\n\t\treturn createMutableAtom(target, individualOptions, family)\n\t}\n\n\tconst atomFamily: MutableAtomFamily<T, K> = {\n\t\t...familyToken,\n\t\tcreate,\n\t\tclass: options.class,\n\t\tsubject,\n\t\tinstall: (s: RootStore) => createMutableAtomFamily(s, options),\n\t\tinternalRoles,\n\t}\n\n\tstore.families.set(options.key, atomFamily)\n\n\tcreateWritablePureSelectorFamily<AsJSON<T>, K, never>(\n\t\tstore,\n\t\t{\n\t\t\tkey: `${options.key}:JSON`,\n\t\t\tget:\n\t\t\t\t(key) =>\n\t\t\t\t({ get }) =>\n\t\t\t\t\tget(familyToken, key).toJSON(),\n\t\t\tset:\n\t\t\t\t(key) =>\n\t\t\t\t({ set }, newValue) => {\n\t\t\t\t\tset(familyToken, key, options.class.fromJSON(newValue))\n\t\t\t\t},\n\t\t},\n\t\t[`mutable`, `json`],\n\t)\n\n\tnew FamilyTracker(atomFamily, store)\n\n\treturn familyToken\n}\n", "import type { MutableAtomFamilyToken } from \"atom.io\"\nimport type { Canonical, Json } from \"atom.io/json\"\n\nimport { newest } from \"../lineage\"\nimport type { WritablePureSelectorFamily } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport type { Transceiver } from \"./transceiver\"\n\nexport const getJsonFamily = <\n\tCore extends Transceiver<any, Json.Serializable, Json.Serializable>,\n\tKey extends Canonical,\n>(\n\tmutableAtomFamily: MutableAtomFamilyToken<Core, Key>,\n\tstore: Store,\n): WritablePureSelectorFamily<ReturnType<Core[`toJSON`]>, Key, never> => {\n\tconst target = newest(store)\n\tconst key = `${mutableAtomFamily.key}:JSON`\n\tconst jsonFamily = target.families.get(key) as WritablePureSelectorFamily<\n\t\tReturnType<Core[`toJSON`]>,\n\t\tKey,\n\t\tnever\n\t>\n\treturn jsonFamily\n}\n", "import type {\n\tMutableAtomToken,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorToken,\n} from \"atom.io\"\nimport { parseJson } from \"atom.io/json\"\n\nimport { findInStore } from \"../families\"\nimport { newest } from \"../lineage\"\nimport { type Store, withdraw } from \"../store\"\nimport type { AsJSON, Transceiver } from \"./transceiver\"\n\nexport const getJsonToken = <T extends Transceiver<any, any, any>>(\n\tstore: Store,\n\tmutableAtomToken: MutableAtomToken<T>,\n): WritablePureSelectorToken<AsJSON<T>> => {\n\tif (mutableAtomToken.family) {\n\t\tconst target = newest(store)\n\t\tconst jsonFamilyKey = `${mutableAtomToken.family.key}:JSON`\n\t\tconst jsonFamilyToken: WritablePureSelectorFamilyToken<AsJSON<T>, string> = {\n\t\t\tkey: jsonFamilyKey,\n\t\t\ttype: `writable_pure_selector_family`,\n\t\t}\n\t\tconst family = withdraw(target, jsonFamilyToken)\n\t\tconst subKey = parseJson(mutableAtomToken.family.subKey)\n\t\tconst jsonToken = findInStore(store, family, subKey)\n\t\treturn jsonToken\n\t}\n\tconst token: WritablePureSelectorToken<AsJSON<T>> = {\n\t\ttype: `writable_pure_selector`,\n\t\tkey: `${mutableAtomToken.key}:JSON`,\n\t}\n\treturn token\n}\n", "import type { MutableAtomFamilyToken } from \"atom.io\"\nimport type { Json } from \"atom.io/json\"\n\nimport { newest } from \"../lineage\"\nimport type { RegularAtomFamily } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport type { SignalFrom, Transceiver } from \"./transceiver\"\n\nexport const getUpdateFamily = <\n\tT extends Transceiver<any, Json.Serializable, Json.Serializable>,\n\tK extends string,\n>(\n\tmutableAtomFamily: MutableAtomFamilyToken<T, K>,\n\tstore: Store,\n): RegularAtomFamily<SignalFrom<T>, K, never> => {\n\tconst target = newest(store)\n\tconst key = `*${mutableAtomFamily.key}`\n\tconst updateFamily = target.families.get(key) as RegularAtomFamily<\n\t\tSignalFrom<T>,\n\t\tK,\n\t\tnever\n\t>\n\treturn updateFamily\n}\n", "import type { MutableAtomToken, RegularAtomToken } from \"atom.io\"\n\nimport type { SignalFrom, Transceiver } from \"./transceiver\"\n\nexport const getUpdateToken = <T extends Transceiver<any, any, any>>(\n\tmutableAtomToken: MutableAtomToken<T>,\n): RegularAtomToken<SignalFrom<T>> => {\n\tconst key = `*${mutableAtomToken.key}`\n\tconst updateToken: RegularAtomToken<SignalFrom<T>> = { type: `atom`, key }\n\tif (mutableAtomToken.family) {\n\t\tupdateToken.family = {\n\t\t\tkey: `*${mutableAtomToken.family.key}`,\n\t\t\tsubKey: mutableAtomToken.family.subKey,\n\t\t}\n\t}\n\treturn updateToken\n}\n", "import type { Json } from \"atom.io/json\"\n\nexport interface Transceiver<\n\tV extends { subscribe: (key: string, fn: (update: S) => void) => () => void },\n\tS extends Json.Serializable,\n\tJ extends Json.Serializable,\n> {\n\tREADONLY_VIEW: V\n\tdo: (update: S) => number | `OUT_OF_RANGE` | null\n\tundo: (update: S) => void\n\tsubscribe: (key: string, fn: (update: S) => void) => () => void\n\ttoJSON: () => J\n}\n\n// biome-ignore format: intersection\nexport type TransceiverConstructor<\n J extends Json.Serializable,\n T extends Transceiver<any, any, J>\n> =\n\t& ( new () => T )\n\t& { fromJSON: (json: J) => T }\n\nexport function isTransceiver(\n\tvalue: unknown,\n): value is Transceiver<any, Json.Serializable, Json.Serializable> {\n\treturn (\n\t\ttypeof value === `object` &&\n\t\tvalue !== null &&\n\t\t`do` in value &&\n\t\t`undo` in value &&\n\t\t`subscribe` in value &&\n\t\t`READONLY_VIEW` in value &&\n\t\t`toJSON` in value\n\t)\n}\n\nexport type TransceiverMode = `playback` | `record` | `transaction`\n\nexport type SignalFrom<T extends Transceiver<any, any, any>> =\n\tT extends Transceiver<any, infer S, any> ? S : never\n\nexport type AsJSON<T extends Transceiver<any, any, any>> = T extends Transceiver<\n\tany,\n\tany,\n\tinfer J\n>\n\t? J\n\t: never\n\nexport type ConstructorOf<T extends Transceiver<any, any, any>> =\n\tTransceiverConstructor<AsJSON<T>, T>\n\n/*\nA transceiver may also keep a list of updates that have been applied to it.\nThis is useful for undo/redo functionality, especially in the context of\nrevising history. It is a good idea to accept a cache limit in your\nconstructor, and overwrite old updates. Here's an example of how we\nmight set that up:\n\nmyTransceiver = Transceiver {\n\tcacheUpdateNumber: number = 27\n\tcacheIdx: number = 1\n\tcacheLimit: number = 3\n\tcache: Array<Update> = [\n\t\t26=add:\"x\"\n\t\t27=del:\"x\" (current)\n\t\t25=add:\"y\"\n\t]\n}\n\nCONFIRM/NO-OP\nUpdate `27=del:\"x\"` is passed to myTransceiver.do:\n- [updateNumber = 27, update = `del:\"x\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // 0\n- eventOffset < 1 // true (we're validating the past)\n- |eventOffset| < cacheLimit // true (we remember this update)\n- eventIdx = cacheIdx + updateOffset // 1\n- update === cache.get(eventIdx) // true\n- return null // 👍\n\nEXPECTED UPDATE\nUpdate `28=add:\"x\"` is passed to myTransceiver.do:\n- [updateNumber = 28, update = `add:\"x\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // 1\n- eventOffset < 1 // false (we're in the future)\n- eventOffset === 1 // true (we're ready to apply this update)\n- cacheIdx += eventOffset // 2\n- cacheIdx %= cacheLimit // 2\n- cache[cacheIdx] = update // cache = <{ 0 => add:\"x\" }>\n- return null // 👍\n\nUNEXPECTED UPDATE\nUpdate `29=del:\"x\"` is passed to myTransceiver.do:\n- [updateNumber = 29, update = `del:\"x\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // 2\n- eventOffset < 1 // false (we're in the future)\n- eventOffset === 1 // false (we're NOT ready to apply this update)\n- updateIdx := cacheIdx + updateOffset // 3\n- updateIdx %= cacheLimit // 0\n- cache[updateIdx] = update // cache = <{ 0 => del:\"x\" }>\n- expectedUpdateNumber = cacheUpdateNumber + 1 // 28\n- return expectedUpdateNumber // 🤨👂\n\nSUCCESSFUL ROLLBACK UPDATE\nUpdate `25=add:\"z\"` is passed to myTransceiver.do:\n- [updateNumber = 25, update = `add:\"z\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // -2\n- eventOffset < 1 // true (we're validating the past)\n- |eventOffset| < cacheLimit // true (we remember this update)\n- eventIdx = cacheIdx + updateOffset // -1\n- eventIdx %= cacheLimit // 2\n- update === cache[eventIdx] // false (we're rolling back)\n- done := false\n- update := cache[cacheIdx] // update = `del:\"x\"`\n- undo(update) // myTransceiver.undo(`del:\"x\"`)\n- while (!done) {\n- \tcacheIdx -= 1 // 0, -1\n- \tcacheIdx %= cacheLimit // 0, 2\n- \tupdate = cache[cacheIdx] // update = `add:\"y\"`, `add:\"x\"`\n- \tundo(update) // myTransceiver.undo(`add:\"y\"`), myTransceiver.undo(`add:\"x\"`)\n- \tdone = cacheIdx === eventIdx // false, true\n- }\n- do(update) // myTransceiver.do(`add:\"z\"`)\n- return null // 👍\n\nUNSUCCESSFUL ROLLBACK UPDATE\nUpdate `24=add:\"z\"` is passed to myTransceiver.do:\n- [updateNumber = 24, update = `add:\"z\"`]\n- updateOffset = updateNumber - cacheUpdateNumber // -3\n- eventOffset < 1 // true (we're validating the past)\n- |eventOffset| < cacheLimit // 3 < 3 // false (we don't remember this update)\n- return `OUT_OF_RANGE` // 😵💫👂\n\n*/\n\n// The function wants a constructor C\n// - that has a static fromJSON(json) returning an instance of C\n// - and whose instances have toJSON() whose return type matches fromJSON's param\n", "import { Future } from \"./future\"\nimport { Tracker, type Transceiver } from \"./mutable\"\nimport { closeOperation, openOperation } from \"./operation\"\nimport {\n\tevictDownstreamFromAtom,\n\tevictDownstreamFromSelector,\n} from \"./set-state/evict-downstream\"\nimport type { ReadableState } from \"./state-types\"\nimport type { Store } from \"./store\"\nimport { isChildStore } from \"./transaction\"\n\nexport function writeToCache<T, E>(\n\ttarget: Store,\n\tstate: ReadableState<T, E>,\n\tvalue: E | T,\n): E | T\nexport function writeToCache<T extends Promise<any>, E>(\n\ttarget: Store,\n\tstate: ReadableState<T, E>,\n\tvalue: T,\n): Future<Awaited<E | T>>\nexport function writeToCache<T, E>(\n\ttarget: Store,\n\tstate: ReadableState<T, E>,\n\tvalue: E | T,\n): E | Future<E | T> | T {\n\tconst { key, subject, type } = state\n\tconst currentValue = target.valueMap.get(key)\n\tif (currentValue instanceof Future && !currentValue.done) {\n\t\tconst future = currentValue\n\t\tif (value instanceof Promise) {\n\t\t\tfuture.use(value)\n\t\t\treturn future\n\t\t}\n\t\ttarget.valueMap.set(key, value)\n\t\treturn value\n\t}\n\tif (value instanceof Promise) {\n\t\tconst future = new Future<T>(value)\n\t\ttarget.valueMap.set(key, future)\n\t\tfuture\n\t\t\t.then(function handleResolvedFuture(resolved) {\n\t\t\t\tconst current = target.valueMap.get(key)\n\t\t\t\tif (current === future) {\n\t\t\t\t\topenOperation(target, state)\n\t\t\t\t\twriteToCache(target, state, resolved)\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n\t\t\t\t\tswitch (type) {\n\t\t\t\t\t\tcase `atom`:\n\t\t\t\t\t\t\tevictDownstreamFromAtom(target, state)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase `readonly_pure_selector`:\n\t\t\t\t\t\tcase `writable_pure_selector`:\n\t\t\t\t\t\t\tevictDownstreamFromSelector(target, key)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t// held selectors, by definition, don't become promises\n\t\t\t\t\t}\n\t\t\t\t\tcloseOperation(target)\n\t\t\t\t\tsubject.next({ newValue: resolved, oldValue: future })\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch((thrown) => {\n\t\t\t\ttarget.logger.error(`💥`, state.type, key, `rejected:`, thrown)\n\t\t\t})\n\t\treturn future\n\t}\n\ttarget.logger.info(`📝`, state.type, state.key, `writing to cache`, value)\n\ttarget.valueMap.set(key, value)\n\treturn value\n}\n\n/**\n * @param target - the newest layer of the store\n * @param state - the state to read from cache\n * @param mut - whether the value is intended to be mutable\n * @returns the state's current value\n */\nexport function readFromCache<T, E>(\n\ttarget: Store,\n\tstate: ReadableState<T, E>,\n\tmut: `mut` | undefined,\n): E | T {\n\ttarget.logger.info(`📖`, state.type, state.key, `reading cached value`)\n\tlet value = target.valueMap.get(state.key) as E | T\n\n\tconst mayNeedToBeCopied =\n\t\tmut === `mut` && state.type === `mutable_atom` && isChildStore(target)\n\tif (mayNeedToBeCopied) {\n\t\tconst mutableAtom = state\n\t\tconst { parent } = target\n\n\t\tif (target.valueMap.hasOwn(mutableAtom.key)) {\n\t\t\treturn value\n\t\t}\n\n\t\tconst parentValue = parent.valueMap.get(mutableAtom.key) as T &\n\t\t\tTransceiver<any, any, any>\n\n\t\ttarget.logger.info(`📃`, `atom`, mutableAtom.key, `copying`)\n\t\tconst jsonValue = parentValue.toJSON()\n\t\tconst copiedValue = mutableAtom.class.fromJSON(jsonValue)\n\t\ttarget.valueMap.set(mutableAtom.key, copiedValue)\n\t\tnew Tracker(mutableAtom, parent)\n\t\tvalue = copiedValue\n\t}\n\treturn value\n}\n\nexport function evictCachedValue(target: Store, key: string): void {\n\tconst currentValue = target.valueMap.get(key)\n\tif (currentValue instanceof Future) {\n\t\tconst selector =\n\t\t\ttarget.writableSelectors.get(key) ?? target.readonlySelectors.get(key)\n\t\tif (selector) {\n\t\t\tselector.getFrom(target)\n\t\t}\n\t\treturn\n\t}\n\tif (target.operation.open) {\n\t\ttarget.operation.prev.set(key, currentValue)\n\t}\n\ttarget.valueMap.delete(key)\n\ttarget.logger.info(`🗑`, `state`, key, `evicted`)\n}\n", "import { evictCachedValue } from \"../caching\"\nimport { newest } from \"../lineage\"\nimport { isDone, markDone } from \"../operation\"\nimport type { Atom } from \"../state-types\"\nimport type { Store } from \"../store\"\n\nexport function evictDownstreamFromAtom(\n\tstore: Store,\n\tatom: Atom<any, any>,\n): void {\n\tconst target = newest(store)\n\tconst { key, type } = atom\n\tconst downstreamKeys = target.selectorAtoms.getRelatedKeys(key)\n\ttarget.logger.info(\n\t\t`🧹`,\n\t\ttype,\n\t\tkey,\n\t\tdownstreamKeys\n\t\t\t? `evicting ${downstreamKeys.size} states downstream:`\n\t\t\t: `no downstream states`,\n\t\tdownstreamKeys ?? `to evict`,\n\t)\n\tif (downstreamKeys) {\n\t\tif (target.operation.open) {\n\t\t\ttarget.logger.info(\n\t\t\t\t`🧹`,\n\t\t\t\ttype,\n\t\t\t\tkey,\n\t\t\t\t`[ ${[...target.operation.done].join(`, `)} ] already done`,\n\t\t\t)\n\t\t}\n\t\tfor (const downstreamKey of downstreamKeys) {\n\t\t\tif (isDone(target, downstreamKey)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tevictCachedValue(target, downstreamKey)\n\t\t\tmarkDone(target, downstreamKey)\n\t\t}\n\t}\n}\n\nexport function evictDownstreamFromSelector(\n\tstore: Store,\n\tselectorKey: string,\n): void {\n\tconst target = newest(store)\n\tconst relationEntries = target.selectorGraph\n\t\t.getRelationEntries({\n\t\t\tupstreamSelectorKey: selectorKey,\n\t\t})\n\t\t.filter(([_, { source }]) => source === selectorKey)\n\tfor (const [downstreamSelectorKey] of relationEntries) {\n\t\tif (isDone(target, downstreamSelectorKey)) {\n\t\t\tcontinue\n\t\t}\n\t\tevictCachedValue(target, downstreamSelectorKey)\n\t\tmarkDone(target, downstreamSelectorKey)\n\t\tevictDownstreamFromSelector(store, downstreamSelectorKey)\n\t}\n}\n", "import type {\n\tFamilyMetadata,\n\tRegularAtomOptions,\n\tRegularAtomToken,\n\tUpdateHandler,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport { eldest, newest } from \"../lineage\"\nimport { resetInStore, setIntoStore } from \"../set-state\"\nimport type { RegularAtom } from \"../state-types\"\nimport type { Store } from \"../store\"\nimport { deposit } from \"../store\"\nimport { Subject } from \"../subject\"\nimport { subscribeToState } from \"../subscribe\"\nimport type { RootStore } from \"../transaction\"\nimport type { InternalRole } from \"./has-role\"\n\nexport function createRegularAtom<T, K extends Canonical, E>(\n\tstore: Store,\n\toptions: RegularAtomOptions<T, E>,\n\tfamily: FamilyMetadata<K> | undefined,\n\tinternalRoles?: InternalRole[],\n): RegularAtomToken<T, K, E> {\n\tconst type = `atom`\n\tconst { key } = options\n\tstore.logger.info(`🔨`, type, key, `is being created`)\n\n\tconst target = newest(store)\n\tconst existing = target.atoms.get(key)\n\tif (existing?.type === type && store.config.isProduction === true) {\n\t\tstore.logger.error(\n\t\t\t`❌`,\n\t\t\t`atom`,\n\t\t\tkey,\n\t\t\t`Tried to create atom, but it already exists in the store.`,\n\t\t)\n\t\treturn deposit(existing) as RegularAtomToken<T, K, E>\n\t}\n\tconst subject = new Subject<{ newValue: T; oldValue: T }>()\n\tconst newAtom: RegularAtom<T, E> = {\n\t\t...options,\n\t\ttype,\n\t\tinstall: (s: RootStore) => {\n\t\t\ts.logger.info(`🛠️`, type, key, `installing in store \"${s.config.name}\"`)\n\t\t\treturn createRegularAtom(s, options, family)\n\t\t},\n\t\tsubject,\n\t} as const\n\tif (family) {\n\t\tnewAtom.family = family\n\t}\n\tif (internalRoles) {\n\t\tnewAtom.internalRoles = internalRoles\n\t}\n\ttarget.atoms.set(key, newAtom)\n\tconst token = deposit(newAtom) as RegularAtomToken<T, K, E>\n\tif (options.effects) {\n\t\tlet effectIndex = 0\n\t\tconst cleanupFunctions: (() => void)[] = []\n\t\tfor (const effect of options.effects) {\n\t\t\tconst cleanup = effect({\n\t\t\t\tresetSelf: () => {\n\t\t\t\t\tresetInStore(store, token)\n\t\t\t\t},\n\t\t\t\tsetSelf: (next) => {\n\t\t\t\t\tsetIntoStore(store, token, next)\n\t\t\t\t},\n\t\t\t\tonSet: (handle: UpdateHandler<T>) =>\n\t\t\t\t\tsubscribeToState(store, token, `effect[${effectIndex}]`, handle),\n\t\t\t\ttoken: token as any,\n\t\t\t\tstore: eldest(store),\n\t\t\t})\n\t\t\tif (cleanup) {\n\t\t\t\tcleanupFunctions.push(cleanup)\n\t\t\t}\n\t\t\t++effectIndex\n\t\t}\n\t\tnewAtom.cleanup = () => {\n\t\t\tfor (const cleanup of cleanupFunctions) {\n\t\t\t\tcleanup()\n\t\t\t}\n\t\t}\n\t}\n\tstore.on.atomCreation.next(token)\n\treturn token\n}\n", "import type { Atom } from \"../state-types\"\n\nexport const INTERNAL_ROLES = [`tracker:signal`] as const\nexport type InternalRole = (typeof INTERNAL_ROLES)[number]\n\nexport function hasRole(atom: Atom<any, any>, role: InternalRole): boolean {\n\tif (`internalRoles` in atom === false) {\n\t\treturn false\n\t}\n\n\treturn atom.internalRoles.includes(role)\n}\n", "import type { AtomDisposalEvent, AtomToken, StateLifecycleEvent } from \"atom.io\"\n\nimport { getFamilyOfToken } from \"../families/get-family-of-token\"\nimport { newest } from \"../lineage\"\nimport { getUpdateToken } from \"../mutable\"\nimport type { Store } from \"../store\"\nimport { withdraw } from \"../store\"\nimport type { Subject } from \"../subject\"\nimport { isChildStore } from \"../transaction\"\nimport { hasRole } from \"./has-role\"\n\nexport function disposeAtom(\n\tstore: Store,\n\tatomToken: AtomToken<any, any, any>,\n): void {\n\tconst target = newest(store)\n\tconst { key, family } = atomToken\n\tconst atom = withdraw(target, atomToken)\n\tif (!family) {\n\t\tstore.logger.error(`❌`, `atom`, key, `Standalone atoms cannot be disposed.`)\n\t} else {\n\t\tatom.cleanup?.()\n\t\tconst lastValue = store.valueMap.get(atom.key)\n\t\tconst familyToken = getFamilyOfToken(store, atomToken)\n\t\tconst atomFamily = withdraw(store, familyToken)\n\t\tconst subject = atomFamily.subject as Subject<\n\t\t\tStateLifecycleEvent<AtomToken<any, any, any>>\n\t\t>\n\n\t\tconst disposalEvent: AtomDisposalEvent<AtomToken<any, any, any>> = {\n\t\t\ttype: `state_disposal`,\n\t\t\tsubType: `atom`,\n\t\t\ttoken: atomToken,\n\t\t\tvalue: lastValue,\n\t\t\ttimestamp: Date.now(),\n\t\t}\n\n\t\tsubject.next(disposalEvent)\n\n\t\tconst isChild = isChildStore(target)\n\n\t\ttarget.atoms.delete(key)\n\t\ttarget.valueMap.delete(key)\n\t\ttarget.selectorAtoms.delete(key)\n\t\ttarget.atomsThatAreDefault.delete(key)\n\t\ttarget.moleculeData.delete(family.key, family.subKey)\n\t\tstore.timelineTopics.delete(key)\n\n\t\tif (atomToken.type === `mutable_atom`) {\n\t\t\tconst updateToken = getUpdateToken(atomToken)\n\t\t\tdisposeAtom(store, updateToken)\n\t\t\tstore.trackers.delete(key)\n\t\t}\n\t\tstore.logger.info(`🔥`, `atom`, key, `deleted`)\n\t\tif (isChild && target.transactionMeta.phase === `building`) {\n\t\t\tconst mostRecentUpdate = target.transactionMeta.update.subEvents.at(-1)\n\t\t\tconst wasMoleculeDisposal = mostRecentUpdate?.type === `molecule_disposal`\n\t\t\tconst updateAlreadyCaptured =\n\t\t\t\twasMoleculeDisposal &&\n\t\t\t\tmostRecentUpdate.values.some(([k]) => k === atom.family?.key)\n\t\t\tconst isTracker = hasRole(atom, `tracker:signal`)\n\t\t\tif (!updateAlreadyCaptured && !isTracker) {\n\t\t\t\ttarget.transactionMeta.update.subEvents.push(disposalEvent)\n\t\t\t}\n\t\t} else {\n\t\t\tstore.on.atomDisposal.next(atomToken)\n\t\t}\n\t}\n}\n", "export function capitalize<S extends string>(string: S): Capitalize<S> {\n\treturn (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>\n}\n", "import type { AtomIOToken } from \"atom.io\"\n\nimport { newest } from \"./lineage\"\nimport { type Store, withdraw } from \"./store\"\nimport type { RootStore } from \"./transaction\"\nimport { isChildStore } from \"./transaction\"\n\n/**\n * @public\n * Install the given tokens into the target store\n * @param tokens - States, families, transactions, and timelines to install into the target store\n * @param target - The store to install the tokens into\n * @param source - The store to install the tokens from\n *\n */\nexport function installIntoStore(\n\ttokens: AtomIOToken[],\n\ttarget: RootStore,\n\tsource: Store,\n): void {\n\tconst sourceNewest = newest(source)\n\tif (isChildStore(sourceNewest)) {\n\t\tsource.logger.error(\n\t\t\t`❌`,\n\t\t\t`transaction`,\n\t\t\tsourceNewest.transactionMeta.update.token.key,\n\t\t\t`could not install the following tokens into store \"${target.config.name} from \"${source.config.name}\":`,\n\t\t\ttokens,\n\t\t\t`${sourceNewest.config.name} is undergoing a transaction.`,\n\t\t)\n\t\treturn\n\t}\n\tconst targetNewest = newest(target)\n\tif (isChildStore(targetNewest)) {\n\t\ttarget.logger.error(\n\t\t\t`❌`,\n\t\t\t`transaction`,\n\t\t\ttargetNewest.transactionMeta.update.token.key,\n\t\t\t`could not install the following tokens into store \"${target.config.name} from \"${source.config.name}\":`,\n\t\t\ttokens,\n\t\t\t`${targetNewest.config.name} is undergoing a transaction.`,\n\t\t)\n\t\treturn\n\t}\n\tfor (const token of tokens) {\n\t\tconst resource = withdraw(source, token)\n\t\tresource.install(target)\n\t}\n}\n", "import {\n\ttype findState,\n\ttype getState,\n\ttype JoinOptions,\n\ttype MutableAtomFamilyToken,\n\ttype ReadonlyPureSelectorFamilyToken,\n\ttype setState,\n\tsimpleCompound,\n\ttype Write,\n\ttype WriterToolkit,\n} from \"atom.io\"\nimport { UList } from \"atom.io/transceivers/u-list\"\n\nimport { capitalize } from \"../capitalize\"\nimport { createReadonlyPureSelectorFamily, findInStore } from \"../families\"\nimport { getFromStore } from \"../get-state\"\nimport type { BaseExternalStoreConfiguration } from \"../junction\"\nimport { Junction } from \"../junction\"\nimport { createMutableAtomFamily, getJsonFamily, getJsonToken } from \"../mutable\"\nimport { JOIN_OP, operateOnStore, setIntoStore } from \"../set-state\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\nimport type { RootStore } from \"../transaction\"\n\nexport type JoinStateFamilies<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n> = Cardinality extends `1:1`\n\t? {\n\t\t\treadonly [N in AName as `${N}KeyOf${Capitalize<BName>}`]: ReadonlyPureSelectorFamilyToken<\n\t\t\t\tA | null,\n\t\t\t\tB\n\t\t\t>\n\t\t} & {\n\t\t\treadonly [N in BName as `${N}KeyOf${Capitalize<AName>}`]: ReadonlyPureSelectorFamilyToken<\n\t\t\t\tB | null,\n\t\t\t\tA\n\t\t\t>\n\t\t}\n\t: Cardinality extends `1:n`\n\t\t? {\n\t\t\t\treadonly [N in BName as `${N}KeysOf${Capitalize<AName>}`]: ReadonlyPureSelectorFamilyToken<\n\t\t\t\t\tB[],\n\t\t\t\t\tA\n\t\t\t\t>\n\t\t\t}\n\t\t: Cardinality extends `n:n`\n\t\t\t? {\n\t\t\t\t\treadonly [N in AName as `${N}KeysOf${Capitalize<BName>}`]: ReadonlyPureSelectorFamilyToken<\n\t\t\t\t\t\tA[],\n\t\t\t\t\t\tB\n\t\t\t\t\t>\n\t\t\t\t} & {\n\t\t\t\t\treadonly [N in BName as `${N}KeysOf${Capitalize<AName>}`]: ReadonlyPureSelectorFamilyToken<\n\t\t\t\t\t\tB[],\n\t\t\t\t\t\tA\n\t\t\t\t\t>\n\t\t\t\t}\n\t\t\t: never\n\nexport class Join<\n\tconst AName extends string,\n\tconst A extends string,\n\tconst BName extends string,\n\tconst B extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n> {\n\tprivate toolkit: WriterToolkit\n\tpublic options: JoinOptions<AName, A, BName, B, Cardinality>\n\tpublic relations: Junction<AName, A, BName, B>\n\tpublic states: JoinStateFamilies<AName, A, BName, B, Cardinality>\n\tpublic relatedKeysAtoms: MutableAtomFamilyToken<UList<string>, string>\n\n\tpublic transact(\n\t\ttoolkit: WriterToolkit,\n\t\trun: (join: Join<AName, A, BName, B, Cardinality>) => void,\n\t): void {\n\t\tconst originalToolkit = this.toolkit\n\t\tthis.toolkit = toolkit\n\t\trun(this)\n\t\tthis.toolkit = originalToolkit\n\t}\n\n\tpublic store: Store\n\n\tpublic [Symbol.dispose](): void {}\n\n\tpublic constructor(\n\t\toptions: JoinOptions<AName, A, BName, B, Cardinality>,\n\t\tstore: RootStore = IMPLICIT.STORE,\n\t) {\n\t\ttype AB = A & B\n\n\t\tthis.store = store\n\t\tthis.options = options\n\n\t\tthis.store.miscResources.set(`join:${options.key}`, this)\n\n\t\tthis.toolkit = {\n\t\t\tget: ((...ps: Parameters<typeof getState>) =>\n\t\t\t\tgetFromStore(store, ...ps)) as typeof getState,\n\t\t\tset: ((...ps: Parameters<typeof setState>) => {\n\t\t\t\tsetIntoStore(store, ...ps)\n\t\t\t}) as typeof setState,\n\t\t\tfind: ((...ps: Parameters<typeof findState>) =>\n\t\t\t\tfindInStore(store, ...ps)) as typeof findState,\n\t\t\tjson: (token) => getJsonToken(store, token),\n\t\t}\n\n\t\tconst aSide: AName = options.between[0]\n\t\tconst bSide: BName = options.between[1]\n\t\tconst relatedKeysAtoms = createMutableAtomFamily<UList<string>, string>(\n\t\t\tstore,\n\t\t\t{\n\t\t\t\tkey: `${options.key}/relatedKeys`,\n\t\t\t\tclass: UList,\n\t\t\t},\n\t\t\t[`join`, `relations`],\n\t\t)\n\t\tthis.relatedKeysAtoms = relatedKeysAtoms\n\n\t\tconst replaceRelationsSafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t> = (toolkit, a, newRelationsOfA) => {\n\t\t\tconst { find, get, set } = toolkit\n\t\t\tconst relationsOfAState = find(relatedKeysAtoms, a)\n\t\t\tconst currentRelationsOfA = get(relationsOfAState)\n\t\t\tfor (const currentRelationB of currentRelationsOfA) {\n\t\t\t\tconst remainsRelated = newRelationsOfA.includes(currentRelationB)\n\t\t\t\tif (remainsRelated) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tset(relatedKeysAtoms, currentRelationB, (relationsOfB) => {\n\t\t\t\t\trelationsOfB.delete(a)\n\t\t\t\t\treturn relationsOfB\n\t\t\t\t})\n\t\t\t}\n\t\t\tset(relationsOfAState, (relationsOfA) => {\n\t\t\t\t// relationsOfA.transaction((nextRelationsOfA) => {\n\t\t\t\trelationsOfA.clear()\n\t\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\t\tconst relationsOfBAtom = find(relatedKeysAtoms, newRelationB)\n\t\t\t\t\tconst relationsOfB = get(relationsOfBAtom)\n\t\t\t\t\tconst newRelationBIsAlreadyRelated = relationsOfB.has(a as AB)\n\t\t\t\t\tif (this.relations.cardinality === `1:n`) {\n\t\t\t\t\t\tconst previousOwnersToDispose: string[] = []\n\t\t\t\t\t\tfor (const previousOwner of relationsOfB) {\n\t\t\t\t\t\t\tif (previousOwner === a) {\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet previousOwnerSize: number | undefined\n\t\t\t\t\t\t\toperateOnStore(\n\t\t\t\t\t\t\t\tJOIN_OP,\n\t\t\t\t\t\t\t\tthis.store,\n\t\t\t\t\t\t\t\trelatedKeysAtoms,\n\t\t\t\t\t\t\t\tpreviousOwner,\n\t\t\t\t\t\t\t\t(relations) => {\n\t\t\t\t\t\t\t\t\trelations.delete(newRelationB as AB)\n\t\t\t\t\t\t\t\t\tpreviousOwnerSize = relations.size\n\t\t\t\t\t\t\t\t\treturn relations\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tif (previousOwnerSize === 0) {\n\t\t\t\t\t\t\t\tpreviousOwnersToDispose.push(previousOwner)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) {\n\t\t\t\t\t\t\tset(relationsOfBAtom, (relations) => {\n\t\t\t\t\t\t\t\trelations.clear()\n\t\t\t\t\t\t\t\treturn relations\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const previousOwner of previousOwnersToDispose) {\n\t\t\t\t\t\t\tstore.keyRefsInJoins.delete(\n\t\t\t\t\t\t\t\tsimpleCompound(newRelationB, previousOwner),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!newRelationBIsAlreadyRelated) {\n\t\t\t\t\t\tset(relationsOfBAtom, (relations) => {\n\t\t\t\t\t\t\trelations.add(a as AB)\n\t\t\t\t\t\t\treturn relations\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\trelationsOfA.add(newRelationB)\n\t\t\t\t}\n\t\t\t\t// return true\n\t\t\t\t// })\n\t\t\t\treturn relationsOfA\n\t\t\t})\n\t\t}\n\t\tconst replaceRelationsUnsafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t> = (toolkit, a, newRelationsOfA) => {\n\t\t\tconst { set } = toolkit\n\t\t\tset(relatedKeysAtoms, a, (relationsOfA) => {\n\t\t\t\t// relationsOfA.transaction((nextRelationsOfA) => {\n\t\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\t\trelationsOfA.add(newRelationB)\n\t\t\t\t}\n\t\t\t\t// return true\n\t\t\t\t// })\n\t\t\t\treturn relationsOfA\n\t\t\t})\n\t\t\tfor (const newRelationB of newRelationsOfA) {\n\t\t\t\tset(relatedKeysAtoms, newRelationB, (newRelationsB) => {\n\t\t\t\t\tnewRelationsB.add(a)\n\t\t\t\t\treturn newRelationsB\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\tconst baseExternalStoreConfiguration: BaseExternalStoreConfiguration = {\n\t\t\tgetRelatedKeys: (key) =>\n\t\t\t\tthis.toolkit.get(relatedKeysAtoms, key) as UList<A> | UList<B>,\n\t\t\taddRelation: (a, b) => {\n\t\t\t\tthis.store.keyRefsInJoins.set(`\"${a}\"`, options.key)\n\t\t\t\tthis.store.keyRefsInJoins.set(`\"${b}\"`, options.key)\n\t\t\t\tthis.store.keyRefsInJoins.set(simpleCompound(a, b), options.key)\n\t\t\t\tthis.toolkit.set(relatedKeysAtoms, a, (aKeys) => aKeys.add(b))\n\t\t\t\tthis.toolkit.set(relatedKeysAtoms, b, (bKeys) => bKeys.add(a))\n\t\t\t},\n\t\t\tdeleteRelation: (a, b) => {\n\t\t\t\tthis.toolkit.set(relatedKeysAtoms, a, (aKeys) => {\n\t\t\t\t\taKeys.delete(b)\n\t\t\t\t\treturn aKeys\n\t\t\t\t})\n\t\t\t\tthis.toolkit.set(relatedKeysAtoms, b, (bKeys) => {\n\t\t\t\t\tbKeys.delete(a)\n\t\t\t\t\treturn bKeys\n\t\t\t\t})\n\t\t\t\tconst compositeKey = simpleCompound(a, b)\n\t\t\t\tthis.store.keyRefsInJoins.delete(compositeKey)\n\t\t\t},\n\t\t\treplaceRelationsSafely: (a, bs) => {\n\t\t\t\treplaceRelationsSafely(this.toolkit, a, bs)\n\t\t\t},\n\t\t\treplaceRelationsUnsafely: (a, bs) => {\n\t\t\t\treplaceRelationsUnsafely(this.toolkit, a, bs)\n\t\t\t},\n\t\t\thas: (a, b) => {\n\t\t\t\tconst aKeys = this.toolkit.get(relatedKeysAtoms, a)\n\t\t\t\treturn b ? aKeys.has(b as AB) : aKeys.size > 0\n\t\t\t},\n\t\t}\n\t\tconst externalStore = baseExternalStoreConfiguration\n\t\tconst relations = new Junction<AName, A, BName, B>(options as any, {\n\t\t\texternalStore,\n\t\t\tisAType: options.isAType,\n\t\t\tisBType: options.isBType,\n\t\t})\n\n\t\tconst createSingleKeySelectorFamily = () =>\n\t\t\tcreateReadonlyPureSelectorFamily<string | null, string, never>(\n\t\t\t\tstore,\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/singleRelatedKey`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\t\tconst relatedKeys = get(relatedKeysAtoms, key)\n\t\t\t\t\t\t\tfor (const relatedKey of relatedKeys) {\n\t\t\t\t\t\t\t\treturn relatedKey\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn null\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t[`join`, `keys`],\n\t\t\t)\n\t\tconst getMultipleKeySelectorFamily = () => {\n\t\t\treturn createReadonlyPureSelectorFamily<readonly string[], string, never>(\n\t\t\t\tstore,\n\t\t\t\t{\n\t\t\t\t\tkey: `${options.key}/multipleRelatedKeys`,\n\t\t\t\t\tget:\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t({ get }) => {\n\t\t\t\t\t\t\tconst jsonFamily = getJsonFamily(relatedKeysAtoms, store)\n\t\t\t\t\t\t\tconst json = get(jsonFamily, key)\n\t\t\t\t\t\t\treturn json\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t[`join`, `keys`],\n\t\t\t)\n\t\t}\n\n\t\tswitch (options.cardinality) {\n\t\t\tcase `1:1`: {\n\t\t\t\tconst singleRelatedKeySelectors = createSingleKeySelectorFamily()\n\t\t\t\tconst stateKeyA = `${aSide}KeyOf${capitalize(bSide)}` as const\n\t\t\t\tconst stateKeyB = `${bSide}KeyOf${capitalize(aSide)}` as const\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = {\n\t\t\t\t\t[stateKeyA]: singleRelatedKeySelectors,\n\t\t\t\t\t[stateKeyB]: singleRelatedKeySelectors,\n\t\t\t\t} as JoinStateFamilies<AName, A, BName, B, Cardinality>\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `1:n`: {\n\t\t\t\tconst singleRelatedKeySelectors = createSingleKeySelectorFamily()\n\t\t\t\tconst multipleRelatedKeysSelectors = getMultipleKeySelectorFamily()\n\t\t\t\tconst stateKeyA = `${aSide}KeyOf${capitalize(bSide)}` as const\n\t\t\t\tconst stateKeyB = `${bSide}KeysOf${capitalize(aSide)}` as const\n\t\t\t\tconst baseStates = {\n\t\t\t\t\t[stateKeyA]: singleRelatedKeySelectors,\n\t\t\t\t\t[stateKeyB]: multipleRelatedKeysSelectors,\n\t\t\t\t} as JoinStateFamilies<AName, A, BName, B, Cardinality>\n\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = baseStates\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `n:n`: {\n\t\t\t\tconst multipleRelatedKeysSelectors = getMultipleKeySelectorFamily()\n\t\t\t\tconst stateKeyA = `${aSide}KeysOf${capitalize(bSide)}` as const\n\t\t\t\tconst stateKeyB = `${bSide}KeysOf${capitalize(aSide)}` as const\n\t\t\t\tthis.relations = relations\n\t\t\t\tthis.states = {\n\t\t\t\t\t[stateKeyA]: multipleRelatedKeysSelectors,\n\t\t\t\t\t[stateKeyB]: multipleRelatedKeysSelectors,\n\t\t\t\t} as JoinStateFamilies<AName, A, BName, B, Cardinality>\n\t\t\t}\n\t\t}\n\t}\n}\n", "import type { JoinOptions, JoinToken } from \"atom.io\"\n\nimport type { RootStore } from \"../transaction\"\nimport { Join } from \"./join-internal\"\n\nexport function createJoin<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\tstore: RootStore,\n\toptions: JoinOptions<AName, A, BName, B, Cardinality>,\n): JoinToken<AName, A, BName, B, Cardinality> {\n\tstore.joins.set(options.key, new Join(options))\n\tconst token: JoinToken<AName, A, BName, B, Cardinality> = {\n\t\tkey: options.key,\n\t\ttype: `join`,\n\t\ta: options.between[0],\n\t\tb: options.between[1],\n\t\tcardinality: options.cardinality,\n\t}\n\treturn token\n}\n", "import type { JoinToken } from \"atom.io\"\n\nimport { eldest } from \"../lineage\"\nimport type { Store } from \"../store\"\nimport { IMPLICIT } from \"../store\"\nimport { Join } from \"./join-internal\"\n\nexport function getJoin<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\ttoken: JoinToken<AName, A, BName, B, Cardinality>,\n\tstore: Store,\n): Join<AName, A, BName, B, Cardinality> {\n\tlet myJoin = store.joins.get(token.key)\n\tif (myJoin === undefined) {\n\t\tconst rootJoinMap = IMPLICIT.STORE.joins\n\t\tconst rootJoin = rootJoinMap.get(token.key)\n\t\tif (rootJoin === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Join \"${token.key}\" not found in store \"${store.config.name}\"`,\n\t\t\t)\n\t\t}\n\t\tconst root = eldest(store)\n\t\tmyJoin = new Join(rootJoin.options, root)\n\t\tstore.joins.set(token.key, myJoin)\n\t}\n\treturn myJoin\n}\n", "import type { JoinToken } from \"atom.io\"\n\nimport type { Junction } from \"../junction\"\nimport { newest } from \"../lineage\"\nimport type { Store } from \"../store\"\nimport { isChildStore } from \"../transaction\"\nimport { getJoin } from \"./get-join\"\n\nexport function editRelationsInStore<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\ttoken: JoinToken<AName, A, BName, B, Cardinality>,\n\tchange: (relations: Junction<AName, A, BName, B>) => void,\n\tstore: Store,\n): void {\n\tconst myJoin = getJoin(token, store)\n\tconst target = newest(store)\n\tif (isChildStore(target)) {\n\t\tconst { toolkit } = target.transactionMeta\n\t\tmyJoin.transact(toolkit, ({ relations }) => {\n\t\t\tchange(relations)\n\t\t})\n\t} else {\n\t\tchange(myJoin.relations)\n\t}\n}\n", "import type { JoinStates, JoinToken } from \"atom.io\"\n\nimport { capitalize } from \"../capitalize\"\nimport { findInStore } from \"../families\"\nimport type { RootStore } from \"../transaction\"\nimport { getJoin } from \"./get-join\"\n\nexport function findRelationsInStore<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\ttoken: JoinToken<AName, A, BName, B, Cardinality>,\n\tkey: A | B,\n\tstore: RootStore,\n): JoinStates<AName, A, BName, B, Cardinality> {\n\tconst myJoin = getJoin(token, store)\n\tlet relations: JoinStates<AName, A, BName, B, Cardinality>\n\tswitch (token.cardinality satisfies `1:1` | `1:n` | `n:n`) {\n\t\tcase `1:1`: {\n\t\t\tconst keyAB = `${token.a}KeyOf${capitalize(token.b)}`\n\t\t\tconst keyBA = `${token.b}KeyOf${capitalize(token.a)}`\n\t\t\trelations = {\n\t\t\t\tget [keyAB]() {\n\t\t\t\t\t// @ts-expect-error way too complicated to represent\n\t\t\t\t\tconst familyAB = myJoin.states[keyAB as any]\n\t\t\t\t\tconst state = findInStore(store, familyAB, key)\n\t\t\t\t\treturn state\n\t\t\t\t},\n\t\t\t\tget [keyBA]() {\n\t\t\t\t\t// @ts-expect-error way too complicated to represent\n\t\t\t\t\tconst familyBA = myJoin.states[keyBA as any]\n\t\t\t\t\tconst state = findInStore(store, familyBA, key)\n\t\t\t\t\treturn state\n\t\t\t\t},\n\t\t\t} as JoinStates<AName, A, BName, B, Cardinality>\n\t\t\tbreak\n\t\t}\n\t\tcase `1:n`: {\n\t\t\tconst keyAB = `${token.a}KeyOf${capitalize(token.b)}`\n\t\t\tconst keysBA = `${token.b}KeysOf${capitalize(token.a)}`\n\t\t\trelations = {\n\t\t\t\tget [keyAB]() {\n\t\t\t\t\t// @ts-expect-error way too complicated to represent\n\t\t\t\t\tconst familyAB = myJoin.states[keyAB as any]\n\t\t\t\t\tconst state = findInStore(store, familyAB, key)\n\t\t\t\t\treturn state\n\t\t\t\t},\n\t\t\t\tget [keysBA]() {\n\t\t\t\t\t// @ts-expect-error way too complicated to represent\n\t\t\t\t\tconst familyBA = myJoin.states[keysBA as any]\n\t\t\t\t\tconst state = findInStore(store, familyBA, key)\n\t\t\t\t\treturn state\n\t\t\t\t},\n\t\t\t} as JoinStates<AName, A, BName, B, Cardinality>\n\t\t\tbreak\n\t\t}\n\t\tcase `n:n`: {\n\t\t\tconst keysAB = `${token.a}KeysOf${capitalize(token.b)}`\n\t\t\tconst keysBA = `${token.b}KeysOf${capitalize(token.a)}`\n\t\t\trelations = {\n\t\t\t\tget [keysAB]() {\n\t\t\t\t\t// @ts-expect-error way too complicated to represent\n\t\t\t\t\tconst familyAB = myJoin.states[keysAB as any]\n\t\t\t\t\tconst state = findInStore(store, familyAB, key)\n\t\t\t\t\treturn state\n\t\t\t\t},\n\t\t\t\tget [keysBA]() {\n\t\t\t\t\t// @ts-expect-error way too complicated to represent\n\t\t\t\t\tconst familyBA = myJoin.states[keysBA as any]\n\t\t\t\t\tconst state = findInStore(store, familyBA, key)\n\t\t\t\t\treturn state\n\t\t\t\t},\n\t\t\t} as JoinStates<AName, A, BName, B, Cardinality>\n\t\t}\n\t}\n\treturn relations\n}\n", "import type { JoinToken, MutableAtomFamilyToken } from \"atom.io\"\nimport type { UList } from \"atom.io/transceivers/u-list\"\n\nimport type { RootStore } from \"../transaction\"\nimport { getJoin } from \"./get-join\"\n\nexport function getInternalRelationsFromStore<\n\tAName extends string,\n\tBName extends string,\n>(\n\ttoken: JoinToken<any, AName, any, BName, any>,\n\tstore: RootStore,\n): MutableAtomFamilyToken<UList<AName> | UList<BName>, string> {\n\tconst myJoin = getJoin(token, store)\n\tconst family = myJoin.relatedKeysAtoms as MutableAtomFamilyToken<\n\t\tUList<AName> | UList<BName>,\n\t\tstring\n\t>\n\treturn family\n}\n", "import type {\n\tAtomFamilyToken,\n\tAtomToken,\n\tAtomUpdateEvent,\n\tStateCreationEvent,\n\tStateDisposalEvent,\n\tStateUpdate,\n\tTimelineEvent,\n\tTimelineManageable,\n\tTimelineOptions,\n\tTimelineSelectorUpdateEvent,\n\tTimelineToken,\n\tTransactionOutcomeEvent,\n\tTransactionSubEvent,\n\tTransactionToken,\n\tWritablePureSelectorToken,\n} from \"atom.io\"\n\nimport { reduceReference } from \"../get-state/reduce-reference\"\nimport { newest } from \"../lineage\"\nimport { getUpdateToken } from \"../mutable\"\nimport { deposit, type Store, withdraw } from \"../store\"\nimport { Subject } from \"../subject\"\nimport type { RootStore } from \"../transaction\"\nimport { isChildStore } from \"../transaction\"\n\nexport type Timeline<ManagedAtom extends TimelineManageable> = {\n\ttype: `timeline`\n\tkey: string\n\tat: number\n\ttimeTraveling: `into_future` | `into_past` | null\n\thistory: TimelineEvent<ManagedAtom>[]\n\tselectorTime: number | null\n\ttransactionKey: string | null\n\tinstall: (store: RootStore) => void\n\tsubject: Subject<TimelineEvent<ManagedAtom> | `redo` | `undo`>\n\tsubscriptions: Map<string, () => void>\n}\n\nexport function createTimeline<ManagedAtom extends TimelineManageable>(\n\tstore: RootStore,\n\toptions: TimelineOptions<ManagedAtom>,\n\tdata?: Timeline<ManagedAtom>,\n): TimelineToken<ManagedAtom> {\n\tconst tl: Timeline<ManagedAtom> = {\n\t\ttype: `timeline`,\n\t\tkey: options.key,\n\t\tat: 0,\n\t\ttimeTraveling: null,\n\t\tselectorTime: null,\n\t\ttransactionKey: null,\n\t\t...data,\n\t\thistory: data?.history.map((update) => ({ ...update })) ?? [],\n\t\tinstall: (s) => createTimeline(s, options, tl),\n\t\tsubject: new Subject(),\n\t\tsubscriptions: new Map(),\n\t}\n\n\tconst timelineKey = options.key\n\tconst target = newest(store)\n\tfor (const initialTopic of options.scope) {\n\t\tswitch (initialTopic.type) {\n\t\t\tcase `atom`:\n\t\t\tcase `mutable_atom`:\n\t\t\t\t{\n\t\t\t\t\tconst atomToken: AtomToken<any, any, any> = initialTopic\n\t\t\t\t\tconst atomKey = atomToken.key\n\t\t\t\t\tlet existingTimelineKey = target.timelineTopics.getRelatedKey(atomKey)\n\t\t\t\t\tif (`family` in atomToken) {\n\t\t\t\t\t\tconst familyKey = atomToken.family.key\n\t\t\t\t\t\texistingTimelineKey = target.timelineTopics.getRelatedKey(familyKey)\n\t\t\t\t\t\tif (existingTimelineKey) {\n\t\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t\t`timeline`,\n\t\t\t\t\t\t\t\toptions.key,\n\t\t\t\t\t\t\t\t`Failed to add atom \"${atomKey}\" because its family \"${familyKey}\" already belongs to timeline \"${existingTimelineKey}\"`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (existingTimelineKey) {\n\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t`timeline`,\n\t\t\t\t\t\t\toptions.key,\n\t\t\t\t\t\t\t`Failed to add atom \"${atomKey}\" because it already belongs to timeline \"${existingTimelineKey}\"`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\taddAtomToTimeline(store, atomToken, tl)\n\t\t\t\t}\n\t\t\t\tbreak\n\n\t\t\tcase `atom_family`:\n\t\t\tcase `mutable_atom_family`:\n\t\t\t\t{\n\t\t\t\t\tconst familyToken: AtomFamilyToken<any, any, any> = initialTopic\n\t\t\t\t\tconst familyKey = familyToken.key\n\t\t\t\t\tconst existingTimelineKey =\n\t\t\t\t\t\ttarget.timelineTopics.getRelatedKey(familyKey)\n\t\t\t\t\tif (existingTimelineKey) {\n\t\t\t\t\t\tstore.logger.error(\n\t\t\t\t\t\t\t`❌`,\n\t\t\t\t\t\t\t`timeline`,\n\t\t\t\t\t\t\toptions.key,\n\t\t\t\t\t\t\t`Failed to add atom family \"${familyKey}\" because it already belongs to timeline \"${existingTimelineKey}\"`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\taddAtomFamilyToTimeline(store, familyToken, tl)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\tstore.timelines.set(options.key, tl)\n\tconst token: TimelineToken<ManagedAtom> = {\n\t\tkey: timelineKey,\n\t\ttype: `timeline`,\n\t}\n\tstore.on.timelineCreation.next(token)\n\treturn token\n}\n\nfunction addAtomToTimeline(\n\tstore: Store,\n\tatomToken: AtomToken<any, any, any>,\n\ttl: Timeline<any>,\n): void {\n\treduceReference(store, atomToken)\n\tlet maybeAtom = withdraw(store, atomToken)\n\tif (maybeAtom.type === `mutable_atom`) {\n\t\tconst updateToken = getUpdateToken(maybeAtom)\n\t\tmaybeAtom = withdraw(store, updateToken)\n\t}\n\tconst atom = maybeAtom\n\tstore.timelineTopics.set(\n\t\t{ topicKey: atom.key, timelineKey: tl.key },\n\t\t{ topicType: `atom` },\n\t)\n\n\ttl.subscriptions.set(\n\t\tatom.key,\n\t\tatom.subject.subscribe(\n\t\t\t`timeline`,\n\t\t\tfunction timelineCapturesAtomUpdate(update) {\n\t\t\t\tconst target = newest(store)\n\t\t\t\tconst currentSelectorToken =\n\t\t\t\t\tstore.operation.open &&\n\t\t\t\t\tstore.operation.token.type === `writable_pure_selector`\n\t\t\t\t\t\t? store.operation.token\n\t\t\t\t\t\t: null\n\t\t\t\tconst currentSelectorTime =\n\t\t\t\t\tstore.operation.open &&\n\t\t\t\t\tstore.operation.token.type === `writable_pure_selector`\n\t\t\t\t\t\t? store.operation.timestamp\n\t\t\t\t\t\t: null\n\n\t\t\t\tconst txUpdateInProgress = target.on.transactionApplying.state?.update\n\n\t\t\t\tstore.logger.info(\n\t\t\t\t\t`⏳`,\n\t\t\t\t\t`timeline`,\n\t\t\t\t\ttl.key,\n\t\t\t\t\t`atom`,\n\t\t\t\t\tatomToken.key,\n\t\t\t\t\t`went`,\n\t\t\t\t\tupdate.oldValue,\n\t\t\t\t\t`->`,\n\t\t\t\t\tupdate.newValue,\n\t\t\t\t\ttxUpdateInProgress\n\t\t\t\t\t\t? `in transaction \"${txUpdateInProgress.token.key}\"`\n\t\t\t\t\t\t: currentSelectorToken\n\t\t\t\t\t\t\t? `in selector \"${currentSelectorToken.key}\"`\n\t\t\t\t\t\t\t: ``,\n\t\t\t\t)\n\t\t\t\tif (tl.timeTraveling === null) {\n\t\t\t\t\tif (txUpdateInProgress) {\n\t\t\t\t\t\tjoinTransaction(store, tl, txUpdateInProgress)\n\t\t\t\t\t} else if (currentSelectorToken && currentSelectorTime) {\n\t\t\t\t\t\tbuildSelectorUpdate(\n\t\t\t\t\t\t\tstore,\n\t\t\t\t\t\t\ttl,\n\t\t\t\t\t\t\tatomToken,\n\t\t\t\t\t\t\tupdate,\n\t\t\t\t\t\t\tcurrentSelectorToken,\n\t\t\t\t\t\t\tcurrentSelectorTime,\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst timestamp = Date.now()\n\t\t\t\t\t\ttl.selectorTime = null\n\n\t\t\t\t\t\tconst atomUpdate: AtomUpdateEvent<any> & TimelineEvent<any> = {\n\t\t\t\t\t\t\tcheckpoint: true,\n\t\t\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\t\t\ttoken: deposit(atom),\n\t\t\t\t\t\t\tupdate,\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstore.logger.info(\n\t\t\t\t\t\t\t`⌛`,\n\t\t\t\t\t\t\t`timeline`,\n\t\t\t\t\t\t\ttl.key,\n\t\t\t\t\t\t\t`got an atom_update to \"${atom.key}\"`,\n\t\t\t\t\t\t)\n\t\t\t\t\t\taddToHistory(tl, atomUpdate)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t),\n\t)\n}\n\nfunction addAtomFamilyToTimeline(\n\tstore: Store,\n\tatomFamilyToken: AtomFamilyToken<any, any, any>,\n\ttl: Timeline<any>,\n): void {\n\tconst family = withdraw(store, atomFamilyToken)\n\tstore.timelineTopics.set(\n\t\t{ topicKey: family.key, timelineKey: tl.key },\n\t\t{ topicType: `atom_family` },\n\t)\n\ttl.subscriptions.set(\n\t\tfamily.key,\n\t\tfamily.subject.subscribe(\n\t\t\t`timeline`,\n\t\t\tfunction timelineCapturesStateLifecycleEvent(creationOrDisposal) {\n\t\t\t\thandleStateLifecycleEvent(store, creationOrDisposal, tl)\n\t\t\t},\n\t\t),\n\t)\n\tfor (const atom of store.atoms.values()) {\n\t\tif (atom.family?.key === family.key) {\n\t\t\taddAtomToTimeline(store, atom, tl)\n\t\t}\n\t}\n}\n\nfunction joinTransaction(\n\tstore: Store,\n\ttl: Timeline<any>,\n\ttxUpdateInProgress: TransactionOutcomeEvent<TransactionToken<any>>,\n) {\n\tconst currentTxKey = txUpdateInProgress.token.key\n\tconst currentTxInstanceId = txUpdateInProgress.id\n\tconst currentTxToken: TransactionToken<any> = {\n\t\tkey: currentTxKey,\n\t\ttype: `transaction`,\n\t}\n\tconst currentTransaction = withdraw(store, currentTxToken)\n\tif (currentTxKey && tl.transactionKey === null) {\n\t\ttl.transactionKey = currentTxKey\n\t\tconst unsubscribe = currentTransaction.subject.subscribe(\n\t\t\t`timeline:${tl.key}`,\n\t\t\t(transactionUpdate) => {\n\t\t\t\tunsubscribe()\n\t\t\t\ttl.transactionKey = null\n\t\t\t\tif (tl.timeTraveling === null && currentTxInstanceId) {\n\t\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: we are in the context of this timeline\n\t\t\t\t\tconst timelineTopics = store.timelineTopics.getRelatedKeys(tl.key)!\n\n\t\t\t\t\tconst subEventsFiltered = filterTransactionSubEvents(\n\t\t\t\t\t\ttransactionUpdate.subEvents,\n\t\t\t\t\t\ttimelineTopics,\n\t\t\t\t\t)\n\n\t\t\t\t\tconst timelineTransactionUpdate: TimelineEvent<any> &\n\t\t\t\t\t\tTransactionOutcomeEvent<TransactionToken<any>> = {\n\t\t\t\t\t\tcheckpoint: true,\n\t\t\t\t\t\t...transactionUpdate,\n\t\t\t\t\t\tsubEvents: subEventsFiltered,\n\t\t\t\t\t}\n\n\t\t\t\t\taddToHistory(tl, timelineTransactionUpdate)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t}\n}\n\nfunction buildSelectorUpdate(\n\tstore: Store,\n\ttl: Timeline<any>,\n\tatomToken: AtomToken<any, any, any>,\n\teventOrUpdate: StateCreationEvent<any> | StateUpdate<any>,\n\tcurrentSelectorToken: WritablePureSelectorToken<any>,\n\tcurrentSelectorTime: number,\n) {\n\tlet latestUpdate: TimelineEvent<any> | undefined = tl.history.at(-1)\n\tif (currentSelectorTime !== tl.selectorTime) {\n\t\tconst selectorUpdate: TimelineEvent<any> & TimelineSelectorUpdateEvent<any> =\n\t\t\t(latestUpdate = {\n\t\t\t\tcheckpoint: true,\n\t\t\t\ttype: `selector_update`,\n\t\t\t\ttimestamp: currentSelectorTime,\n\t\t\t\ttoken: currentSelectorToken,\n\t\t\t\tsubEvents: [],\n\t\t\t})\n\t\tif (`type` in eventOrUpdate) {\n\t\t\tlatestUpdate.subEvents.push(eventOrUpdate)\n\t\t} else {\n\t\t\tlatestUpdate.subEvents.push({\n\t\t\t\ttype: `atom_update`,\n\t\t\t\ttoken: atomToken,\n\t\t\t\tupdate: eventOrUpdate,\n\t\t\t\ttimestamp: Date.now(), // 👺 use store operation\n\t\t\t})\n\t\t}\n\n\t\taddToHistory(tl, latestUpdate)\n\t\ttl.selectorTime = currentSelectorTime\n\n\t\tstore.logger.info(\n\t\t\t`⌛`,\n\t\t\t`timeline`,\n\t\t\ttl.key,\n\t\t\t`got a selector_update \"${currentSelectorToken.key}\" with`,\n\t\t\tlatestUpdate.subEvents.map((event) => event.token.key),\n\t\t)\n\n\t\tconst operation = store.operation\n\t\tconst unsub = store.on.operationClose.subscribe(\n\t\t\t`timeline:${tl.key} (needs to gather nested selector creations)`,\n\t\t\t() => {\n\t\t\t\tunsub()\n\t\t\t\tif (operation.open) {\n\t\t\t\t\tselectorUpdate.subEvents = [\n\t\t\t\t\t\t...operation.subEvents,\n\t\t\t\t\t\t...selectorUpdate.subEvents,\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t} else {\n\t\tif (latestUpdate?.type === `selector_update`) {\n\t\t\tif (`type` in eventOrUpdate) {\n\t\t\t\tlatestUpdate.subEvents.push(eventOrUpdate)\n\t\t\t} else {\n\t\t\t\tlatestUpdate.subEvents.push({\n\t\t\t\t\ttype: `atom_update`,\n\t\t\t\t\ttoken: atomToken,\n\t\t\t\t\tupdate: eventOrUpdate,\n\t\t\t\t\ttimestamp: Date.now(), // 👺 use store operation\n\t\t\t\t})\n\t\t\t}\n\t\t\tstore.logger.info(\n\t\t\t\t`⌛`,\n\t\t\t\t`timeline`,\n\t\t\t\ttl.key,\n\t\t\t\t`set selector_update \"${currentSelectorToken.key}\" to`,\n\t\t\t\tlatestUpdate?.subEvents.map((event) => event.token.key),\n\t\t\t)\n\t\t}\n\t}\n\tif (latestUpdate) {\n\t\ttl.subject.next(latestUpdate)\n\t}\n}\n\nfunction filterTransactionSubEvents(\n\tupdates: TransactionSubEvent[],\n\ttimelineTopics: Set<string>,\n): TransactionSubEvent[] {\n\treturn updates\n\t\t.filter((updateFromTx) => {\n\t\t\tif (updateFromTx.type === `transaction_outcome`) {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tlet key: string\n\t\t\tlet familyKey: string | undefined\n\t\t\tswitch (updateFromTx.type) {\n\t\t\t\tcase `atom_update`:\n\t\t\t\tcase `state_creation`:\n\t\t\t\tcase `state_disposal`:\n\t\t\t\t\tkey = updateFromTx.token.key\n\t\t\t\t\tfamilyKey = updateFromTx.token.family?.key\n\t\t\t\t\tbreak\n\t\t\t\tcase `molecule_creation`:\n\t\t\t\tcase `molecule_disposal`:\n\t\t\t\tcase `molecule_transfer`:\n\t\t\t\t\treturn true // always include\n\t\t\t}\n\t\t\ttimelineTopics.has(key)\n\t\t\tif (familyKey && timelineTopics.has(familyKey)) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn timelineTopics.has(key)\n\t\t})\n\t\t.map((updateFromTx): TransactionSubEvent => {\n\t\t\tif (`subEvents` in updateFromTx) {\n\t\t\t\treturn {\n\t\t\t\t\t...updateFromTx,\n\t\t\t\t\tsubEvents: filterTransactionSubEvents(\n\t\t\t\t\t\tupdateFromTx.subEvents,\n\t\t\t\t\t\ttimelineTopics,\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn updateFromTx\n\t\t})\n}\n\nfunction handleStateLifecycleEvent(\n\tstore: Store,\n\tevent: StateCreationEvent<any> | StateDisposalEvent<any>,\n\ttl: Timeline<any>,\n): void {\n\tconst currentSelectorToken =\n\t\tstore.operation.open &&\n\t\tstore.operation.token.type === `writable_pure_selector`\n\t\t\t? store.operation.token\n\t\t\t: null\n\tconst currentSelectorTime =\n\t\tstore.operation.open &&\n\t\tstore.operation.token.type === `writable_pure_selector`\n\t\t\t? store.operation.timestamp\n\t\t\t: null\n\tif (!tl.timeTraveling) {\n\t\tconst target = newest(store)\n\t\tif (isChildStore(target)) {\n\t\t\t// we don't want to update the true timeline while we are in a transaction\n\t\t} else {\n\t\t\tconst txUpdateInProgress = target.on.transactionApplying.state\n\t\t\tif (txUpdateInProgress) {\n\t\t\t\tjoinTransaction(store, tl, txUpdateInProgress.update)\n\t\t\t} else if (\n\t\t\t\tcurrentSelectorToken &&\n\t\t\t\tcurrentSelectorTime &&\n\t\t\t\tevent.type === `state_creation`\n\t\t\t) {\n\t\t\t\tbuildSelectorUpdate(\n\t\t\t\t\tstore,\n\t\t\t\t\ttl,\n\t\t\t\t\tevent.token,\n\t\t\t\t\tevent,\n\t\t\t\t\tcurrentSelectorToken,\n\t\t\t\t\tcurrentSelectorTime,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\taddToHistory(tl, event)\n\t\t\t}\n\t\t}\n\t}\n\tswitch (event.type) {\n\t\tcase `state_creation`:\n\t\t\taddAtomToTimeline(store, event.token, tl)\n\t\t\tbreak\n\t\tcase `state_disposal`:\n\t\t\ttl.subscriptions.get(event.token.key)?.()\n\t\t\ttl.subscriptions.delete(event.token.key)\n\t\t\tbreak\n\t}\n}\n\nfunction addToHistory(tl: Timeline<any>, event: TimelineEvent<any>): void {\n\tif (tl.at !== tl.history.length) {\n\t\ttl.history.splice(tl.at)\n\t}\n\ttl.history.push(event)\n\ttl.at = tl.history.length\n\ttl.subject.next(event)\n}\n", "import type { TimelineEvent, TimelineToken } from \"atom.io\"\n\nimport {\n\tingestAtomUpdateEvent,\n\tingestCreationEvent,\n\tingestDisposalEvent,\n\tingestSelectorUpdateEvent,\n\tingestTransactionOutcomeEvent,\n} from \"../events\"\nimport type { Store } from \"../store\"\n\nexport const timeTravel = (\n\tstore: Store,\n\taction: `redo` | `undo`,\n\ttoken: TimelineToken<any>,\n): void => {\n\tstore.logger.info(\n\t\taction === `redo` ? `⏩` : `⏪`,\n\t\t`timeline`,\n\t\ttoken.key,\n\t\taction,\n\t)\n\tconst timelineData = store.timelines.get(token.key)\n\tif (!timelineData) {\n\t\tstore.logger.error(\n\t\t\t`🐞`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Failed to ${action}. This timeline has not been initialized.`,\n\t\t)\n\t\treturn\n\t}\n\n\tif (\n\t\t(action === `redo` && timelineData.at === timelineData.history.length) ||\n\t\t(action === `undo` && timelineData.at === 0)\n\t) {\n\t\tstore.logger.warn(\n\t\t\t`💁`,\n\t\t\t`timeline`,\n\t\t\ttoken.key,\n\t\t\t`Failed to ${action} at the ${\n\t\t\t\taction === `redo` ? `end` : `beginning`\n\t\t\t} of timeline \"${token.key}\". There is nothing to ${action}.`,\n\t\t)\n\t\treturn\n\t}\n\n\ttimelineData.timeTraveling = action === `redo` ? `into_future` : `into_past`\n\tlet nextIndex = timelineData.at\n\tlet events: TimelineEvent<any>[]\n\tswitch (action) {\n\t\tcase `undo`:\n\t\t\t--nextIndex\n\t\t\twhile (\n\t\t\t\tnextIndex !== 0 &&\n\t\t\t\ttimelineData.history[nextIndex].checkpoint !== true\n\t\t\t) {\n\t\t\t\t--nextIndex\n\t\t\t}\n\t\t\tevents = timelineData.history.slice(nextIndex, timelineData.at).reverse()\n\n\t\t\tbreak\n\t\tcase `redo`:\n\t\t\t++nextIndex\n\t\t\tevents = timelineData.history.slice(timelineData.at, nextIndex)\n\t}\n\ttimelineData.at = nextIndex\n\n\tconst applying = action === `redo` ? `newValue` : `oldValue`\n\n\tfor (const event of events) {\n\t\tswitch (event.type) {\n\t\t\tcase `atom_update`: {\n\t\t\t\tingestAtomUpdateEvent(store, event, applying)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `selector_update`: {\n\t\t\t\tingestSelectorUpdateEvent(store, event, applying)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `transaction_outcome`: {\n\t\t\t\tingestTransactionOutcomeEvent(store, event, applying)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `state_creation`: {\n\t\t\t\tingestCreationEvent(store, event, applying)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase `state_disposal`: {\n\t\t\t\tingestDisposalEvent(store, event, applying)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\ttimelineData.subject.next(action)\n\ttimelineData.timeTraveling = null\n\tstore.logger.info(\n\t\t`⏸️`,\n\t\t`timeline`,\n\t\ttoken.key,\n\t\t`\"${token.key}\" is now at ${timelineData.at} / ${timelineData.history.length}`,\n\t)\n}\n", "import type { ConstructorOf, Ctor, Store, Transceiver } from \"atom.io/internal\"\nimport {\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateRegularAtom,\n\tcreateRegularAtomFamily,\n\tIMPLICIT,\n} from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { StateUpdate } from \"./events\"\nimport type {\n\tAtomToken,\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n} from \"./tokens\"\n\nexport type RegularAtomOptions<T, E = never> = {\n\t/** The unique identifier of the atom */\n\tkey: string\n\t/** The starting value of the atom */\n\tdefault: T | (() => T)\n\t/** Hooks used to run side effects when the atom is set */\n\teffects?: readonly AtomEffect<T, E>[]\n\t/** The classes of errors that might be thrown when deriving the atom's default value */\n\tcatch?: readonly Ctor<E>[]\n}\n/**\n * Create a regular atom, a global reactive variable in the implicit store\n * @param options - {@link RegularAtomOptions}.\n * @returns\n * A reference to the atom created: a {@link RegularAtomToken}\n */\nexport function atom<T, E = never>(\n\toptions: RegularAtomOptions<T, E>,\n): RegularAtomToken<T, any, E> {\n\treturn createRegularAtom(IMPLICIT.STORE, options, undefined)\n}\n\nexport type MutableAtomOptions<T extends Transceiver<any, any, any>> = {\n\t/** The unique identifier of the atom */\n\tkey: string\n\t/** A constructor for the atom's value */\n\tclass: ConstructorOf<T>\n\t/** Hooks used to run side effects when the atom is set */\n\teffects?: readonly AtomEffect<T>[]\n}\n/**\n * Create a mutable atom, a global reactive variable in the implicit store\n *\n * The value of a mutable atom must be some kind of {@link Transceiver}.\n *\n * @param options - {@link MutableAtomOptions}.\n * @returns\n * A reference to the atom created: a {@link MutableAtomToken}\n */\nexport function mutableAtom<T extends Transceiver<any, any, any>>(\n\toptions: MutableAtomOptions<T>,\n): MutableAtomToken<T> {\n\treturn createMutableAtom(IMPLICIT.STORE, options, undefined)\n}\n\n/**\n * A function that runs side effects when the atom is set\n * @param tools - {@link Effectors} that can be used to run side effects\n * @returns\n * Optionally, a cleanup function that will be called when the atom is disposed\n */\nexport type AtomEffect<T, E = never> = (\n\ttools: Effectors<T, E>,\n) => (() => void) | void\nexport type Effectors<T, E = never> = {\n\t/**\n\t * Reset the value of the atom to its default\n\t */\n\tresetSelf: () => void\n\t/**\n\t * Set the value of the atom\n\t * @param next - The new value of the atom, or a setter function\n\t */\n\tsetSelf: <New extends T>(next: New | ((old: T) => New)) => void\n\t/** Subscribe to changes to the atom */\n\tonSet: (callback: (options: StateUpdate<E | T>) => void) => void\n\t/** The token of the atom */\n\ttoken: T extends Transceiver<any, any, any>\n\t\t? MutableAtomToken<T>\n\t\t: AtomToken<T, any, E>\n\t/** The store in which the atom exists */\n\tstore: Store\n}\n\nexport type RegularAtomFamilyOptions<T, K extends Canonical, E = never> = {\n\t/** The unique identifier of the atom family */\n\tkey: string\n\t/** The starting value of the atom family */\n\tdefault: T | ((key: K) => T)\n\t/** Hooks used to run side effects when an atom in the family is set */\n\teffects?: (key: K) => AtomEffect<T, E>[]\n\t/** The classes of errors that might be thrown when deriving the atom's default value */\n\tcatch?: readonly Ctor<E>[]\n}\n/**\n * Create a family of regular atoms, allowing for the dynamic creation and disposal of atoms.\n * @param options - {@link RegularAtomFamilyOptions}\n * @returns\n * A reference to the atom family created: a {@link RegularAtomFamilyToken}\n */\nexport function atomFamily<T, K extends Canonical, E = never>(\n\toptions: RegularAtomFamilyOptions<T, K, E>,\n): RegularAtomFamilyToken<T, K, E> {\n\treturn createRegularAtomFamily(IMPLICIT.STORE, options)\n}\n\nexport type MutableAtomFamilyOptions<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n> = {\n\t/** The unique identifier of the atom family */\n\tkey: string\n\t/** The class of the transceiver to be created */\n\tclass: ConstructorOf<T>\n\t/** Hooks used to run side effects when an atom in the family is set */\n\teffects?: (key: K) => AtomEffect<T>[]\n}\n/**\n * Create a family of mutable atoms, allowing for the dynamic creation and disposal of atoms.\n *\n * The value of a mutable atom must be some kind of {@link Transceiver}.\n *\n * @param options - {@link MutableAtomFamilyOptions}\n * @returns\n * A reference to the atom family created: a {@link MutableAtomFamilyToken}\n */\nexport function mutableAtomFamily<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n>(options: MutableAtomFamilyOptions<T, K>): MutableAtomFamilyToken<T, K> {\n\treturn createMutableAtomFamily(IMPLICIT.STORE, options)\n}\n", "import { disposeFromStore, IMPLICIT } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { ReadableFamilyToken, ReadableToken } from \".\"\n\n/**\n * Disposes of a state in the implicit store.\n *\n * Only family members can be disposed of.\n *\n * @param token - The token of the state to dispose\n * @overload Default\n */\nexport function disposeState(token: ReadableToken<any>): void\n/**\n * Disposes of a state in the implicit store.\n *\n * Only family members can be disposed of.\n *\n * @param token - The token of the state family to dispose\n * @param key - The unique key of the state to dispose\n * @overload Streamlined\n */\nexport function disposeState<K extends Canonical>(\n\ttoken: ReadableFamilyToken<any, K>,\n\tkey: K,\n): void\nexport function disposeState(\n\t...params:\n\t\t| [token: ReadableFamilyToken<any, any>, key: Canonical]\n\t\t| [token: ReadableToken<any>]\n): void {\n\tdisposeFromStore(IMPLICIT.STORE, ...params)\n}\n", "import type {\n\tMutableAtomToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tReadonlySelectorFamilyToken,\n\tReadonlySelectorToken,\n\tRegularAtomToken,\n\tWritableFamilyToken,\n\tWritableSelectorFamilyToken,\n\tWritableSelectorToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Transceiver } from \"atom.io/internal\"\nimport { findInStore, IMPLICIT } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { MutableAtomFamilyToken, RegularAtomFamilyToken } from \"./tokens\"\n\n/**\n * Finds a {@link MutableAtomToken} in the store, without accessing its value.\n *\n * In an ephemeral store, this will create a new atom if one does not exist with the given key.\n *\n * In an immortal store, a \"counterfeit\" atom token will be returned in this case and a warning will be logged.\n *\n * @param token - A {@link MutableAtomFamilyToken}\n * @param key - The key of the state\n * @returns\n * The current value of the state\n * @overload Mutable Atom\n */\nexport function findState<\n\tT extends Transceiver<any, any, any>,\n\tK extends Canonical,\n\tKey extends K,\n>(token: MutableAtomFamilyToken<T, K>, key: Key): MutableAtomToken<T, K>\n/**\n * Finds a {@link RegularAtomToken} in the store, without accessing its value.\n *\n * In an ephemeral store, this will create a new atom if one does not exist with the given key.\n *\n * In an immortal store, a \"counterfeit\" atom token will be returned in this case and a warning will be logged.\n *\n * @param token - The token of the state family\n * @param key - The key of the state\n * @returns\n * The current value of the state\n * @overload Regular Atom\n */\nexport function findState<T, K extends Canonical, Key extends K>(\n\ttoken: RegularAtomFamilyToken<T, K>,\n\tkey: Key,\n): RegularAtomToken<T, Key>\n/**\n * Finds a {@link WritableSelectorToken} in the store, without accessing its value.\n *\n * In an ephemeral store, this will create a new selector if one does not exist with the given key.\n *\n * In an immortal store, a \"counterfeit\" selector token will be returned in this case and a warning will be logged.\n *\n * @param token - The token of the state family\n * @param key - The key of the state\n * @returns\n * The current value of the state\n * @overload Writable Selector\n */\nexport function findState<T, K extends Canonical, Key extends K>(\n\ttoken: WritableSelectorFamilyToken<T, K>,\n\tkey: Key,\n): WritableSelectorToken<T, Key>\n/**\n * Finds a {@link ReadonlySelectorToken} in the store, without accessing its value.\n *\n * In an ephemeral store, this will create a new selector if one does not exist with the given key.\n *\n * In an immortal store, a \"counterfeit\" selector token will be returned in this case and a warning will be logged.\n *\n * @param token - The token of the state family\n * @param key - The key of the state\n * @returns\n * The current value of the state\n * @overload Readonly Selector\n */\nexport function findState<T, K extends Canonical, Key extends K>(\n\ttoken: ReadonlySelectorFamilyToken<T, K>,\n\tkey: Key,\n): ReadonlySelectorToken<T, Key>\n/**\n * Finds a {@link WritableToken} in the store, without accessing its value.\n *\n * In an ephemeral store, this will create a new atom or selector if one does not exist with the given key.\n *\n * In an immortal store, a \"counterfeit\" token will be returned in this case and a warning will be logged.\n *\n * @param token - The token of the state family\n * @param key - The key of the state\n * @returns\n * The current value of the state\n * @overload Writable State\n */\nexport function findState<T, K extends Canonical, Key extends K>(\n\ttoken: WritableFamilyToken<T, K>,\n\tkey: Key,\n): WritableToken<T, Key>\n/**\n * Finds a {@link MutableAtomToken} in the store, without accessing its value.\n *\n * In an ephemeral store, this will create a new atom or selector if one does not exist with the given key.\n *\n * In an immortal store, a \"counterfeit\" token will be returned in this case and a warning will be logged.\n *\n * @param token - A {@link ReadableFamilyToken}\n * @param key - The key of the state\n * @returns\n * The current value of the state\n * @overload Unknown\n * @default\n */\nexport function findState<T, K extends Canonical, Key extends K>(\n\ttoken: ReadableFamilyToken<T, K>,\n\tkey: Key,\n): ReadableToken<T, Key>\n\nexport function findState(\n\ttoken: ReadableFamilyToken<any, any>,\n\tkey: Canonical,\n): ReadableToken<any> {\n\tconst state = findInStore(IMPLICIT.STORE, token, key)\n\treturn state\n}\n", "import type { ViewOf } from \"atom.io\"\nimport { getFromStore, IMPLICIT } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { ReadableFamilyToken, ReadableToken } from \".\"\n\n/**\n * Read or compute the current value of a state\n * @param token - The token of the state to get\n * @return The current value of the state\n * @overload Default\n * @default\n */\nexport function getState<T, E = never>(\n\ttoken: ReadableToken<T, any, E>,\n): ViewOf<E | T>\n\n/**\n * Read or compute the current value of a state\n * @param token - The token of a state family\n * @param key - The unique key of the state to get\n * @return The current value of the state\n * @overload Streamlined\n */\nexport function getState<T, K extends Canonical, E = never>(\n\ttoken: ReadableFamilyToken<T, K, E>,\n\tkey: NoInfer<K>,\n): ViewOf<E | T>\n\nexport function getState<T, K extends Canonical, E = never>(\n\t...params:\n\t\t| [token: ReadableFamilyToken<T, K, E>, key: NoInfer<K>]\n\t\t| [token: ReadableToken<T, any, E>]\n): ViewOf<E | T> {\n\treturn getFromStore(IMPLICIT.STORE, ...params)\n}\n", "import type { MutableAtomFamilyToken, ReadonlyPureSelectorToken } from \"atom.io\"\nimport type {\n\tFlat,\n\tJunction,\n\tJunctionEntriesBase,\n\tJunctionSchemaBase,\n\tRefinement,\n} from \"atom.io/internal\"\nimport {\n\tcreateJoin,\n\teditRelationsInStore,\n\tfindRelationsInStore,\n\tgetInternalRelationsFromStore,\n\tIMPLICIT,\n} from \"atom.io/internal\"\nimport type { UList } from \"atom.io/transceivers/u-list\"\n\n// biome-ignore format: intersection\nexport type JoinOptions<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n> =\n\tFlat<\n\t\t& JunctionSchemaBase<AName, BName>\n\t\t& {\n\t\t\t/** Unique identifier of the join */\n\t\t\treadonly key: string\n\t\t\t/** How many relations are allowed in each direction? */\n\t\t\treadonly cardinality: Cardinality\n\t\t\t/** Type guard for the type of the left side */\n\t\t\treadonly isAType: Refinement<string, A>\n\t\t\t/** Type guard for the type of the right side */\n\t\t\treadonly isBType: Refinement<string, B>\n\t\t}\n\t> & Partial<JunctionEntriesBase<A, B, null>>\n\nexport type JoinToken<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n> = {\n\t/** Unique identifier of the join */\n\tkey: string\n\t/** Discriminator */\n\ttype: `join`\n\t/** How many relations are allowed in each direction? */\n\tcardinality: Cardinality\n\t/** Name of the join's left side */\n\ta: AName\n\t/** Name of the join's right side */\n\tb: BName\n\t/** Never present. This is a marker that preserves the type of the left side's keys */\n\t__aType?: A\n\t/** Never present. This is a marker that preserves the type of the right side's keys */\n\t__bType?: B\n}\n\n/**\n * Create a join, an interface for managing relations between two sets of keys.\n *\n * Use joins when it is important to view relationships from either side.\n *\n * Under the hood, joins coordinate changes of multiple atoms to support that the desired relationships stay consistent.\n *\n * @param options - {@link JoinOptions}\n * @returns\n * A reference to the join created: a {@link JoinToken}\n */\nexport function join<\n\tconst AName extends string,\n\tconst A extends string,\n\tconst BName extends string,\n\tconst B extends string,\n\tconst Cardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\toptions: JoinOptions<AName, A, BName, B, Cardinality>,\n): JoinToken<AName, A, BName, B, Cardinality> {\n\treturn createJoin(IMPLICIT.STORE, options)\n}\n\nexport type JoinStates<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n> = Cardinality extends `1:1`\n\t? {\n\t\t\treadonly [N in AName as `${N}KeyOf${Capitalize<BName>}`]: ReadonlyPureSelectorToken<\n\t\t\t\tA | null,\n\t\t\t\tB\n\t\t\t>\n\t\t} & {\n\t\t\treadonly [N in BName as `${N}KeyOf${Capitalize<AName>}`]: ReadonlyPureSelectorToken<\n\t\t\t\tB | null,\n\t\t\t\tA\n\t\t\t>\n\t\t}\n\t: Cardinality extends `1:n`\n\t\t? {\n\t\t\t\treadonly [N in AName as `${N}KeyOf${Capitalize<BName>}`]: ReadonlyPureSelectorToken<\n\t\t\t\t\tA | null,\n\t\t\t\t\tB\n\t\t\t\t>\n\t\t\t} & {\n\t\t\t\treadonly [N in BName as `${N}KeysOf${Capitalize<AName>}`]: ReadonlyPureSelectorToken<\n\t\t\t\t\tB[],\n\t\t\t\t\tA\n\t\t\t\t>\n\t\t\t}\n\t\t: Cardinality extends `n:n`\n\t\t\t? {\n\t\t\t\t\treadonly [N in AName as `${N}KeysOf${Capitalize<BName>}`]: ReadonlyPureSelectorToken<\n\t\t\t\t\t\tA[],\n\t\t\t\t\t\tB\n\t\t\t\t\t>\n\t\t\t\t} & {\n\t\t\t\t\treadonly [N in BName as `${N}KeysOf${Capitalize<AName>}`]: ReadonlyPureSelectorToken<\n\t\t\t\t\t\tB[],\n\t\t\t\t\t\tA\n\t\t\t\t\t>\n\t\t\t\t}\n\t\t\t: never\n\n/**\n * Find the current value of a relation owned by a {@link join}\n * @param token - The token of the join\n * @param key - The key of the relation to find\n * @returns\n * A {@link JoinStates} interface to access the relation\n * @overload Default\n */\nexport function findRelations<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\ttoken: JoinToken<AName, A, BName, B, Cardinality>,\n\tkey: A | B,\n): JoinStates<AName, A, BName, B, Cardinality> {\n\treturn findRelationsInStore(token, key, IMPLICIT.STORE)\n}\n\n/**\n * Change one or multiple relations owned by a {@link join}\n * @param token - The token of the join\n * @param change - A function that takes a {@link Junction} interface to edit the relations\n */\nexport function editRelations<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\ttoken: JoinToken<AName, A, BName, B, Cardinality>,\n\tchange: (relations: Junction<AName, A, BName, B>) => void,\n): void {\n\teditRelationsInStore(token, change, IMPLICIT.STORE)\n}\n\n/**\n * @param token - The token of the join\n * @returns\n * A {@link MutableAtomFamilyToken} to access the internal relations\n */\nexport function getInternalRelations<\n\tAName extends string,\n\tA extends string,\n\tBName extends string,\n\tB extends string,\n\tCardinality extends `1:1` | `1:n` | `n:n`,\n>(\n\ttoken: JoinToken<AName, A, BName, B, Cardinality>,\n): MutableAtomFamilyToken<UList<A> | UList<B>, string> {\n\treturn getInternalRelationsFromStore(token, IMPLICIT.STORE)\n}\n", "const LOGGER_ICON_DICTIONARY = {\n\t// Lifecycle\n\t\"🔨\": `Create state`,\n\t\"🛠️\": `Install state into store`,\n\t// Families\n\t\"👪\": `Family member added`,\n\t\"🔥\": `Family member deleted`,\n\t// Cache\n\t\"📃\": `Copy mutable`,\n\t\"📖\": `Read from cache`,\n\t\"📝\": `Write to cache`,\n\t\"❔\": `Cache miss`,\n\t\"✨\": `Value derived`,\n\t\"⭐\": `Value set`,\n\t// Operations\n\t\"⭕\": `Operation start`,\n\t\"🔴\": `Operation complete`,\n\t\"🚫\": `Operation blocked`,\n\t\"🟢\": `Operation unblocked`,\n\t// Selectors\n\t\"🗑\": `Evict cached value`,\n\t\"🧹\": `Prepare to evict`,\n\t\"🧮\": `Computing selector`,\n\t\"🔌\": `Register direct dependency`,\n\t\"🔍\": `Discover root`,\n\t// Transactions\n\t\"📁\": `Stow update`,\n\t\"🛫\": `Begin transaction`,\n\t\"🛄\": `Apply transaction`,\n\t\"🛬\": `Complete transaction`,\n\t\"💥\": `Transaction caught error`,\n\t\"🪂\": `Abort transaction`,\n\t// Timelines\n\t\"⌛\": `Timeline event fully captured`,\n\t\"⏩\": `Timeline redo`,\n\t\"⏪\": `Timeline undo`,\n\t\"⏭️\": `Transaction redo`,\n\t\"⏮️\": `Transaction undo`,\n\t\"⏳\": `Timeline event partially captured`,\n\t\"⏸️\": `Time-travel complete`,\n\t// Problems\n\t\"💣\": `Dangerous action likely to cause bad errors down the line`,\n\t\"❗\": `Dangerous action unless in development mode`,\n\t\"❌\": `Conflict prevents attempted action`,\n\t\"🐞\": `Possible bug in AtomIO`,\n\t\"💁\": `Advice and guidance to the developer`,\n\t// Subscriptions\n\t\"👀\": `Subscription added`,\n\t\"🙈\": `Subscription canceled`,\n\t\"📢\": `Notify subscribers`,\n\n\t// Realtime\n\t\"🚀\": `Performance measure`,\n\t\"✅\": `Realtime transaction success`,\n\t\"🔄\": `Realtime transaction synchronized`,\n\t\"🤞\": `Realtime optimistic update enqueued`,\n\t\"👈\": `Realtime confirmed update enqueued`,\n\t\"🧑⚖️\": `Realtime update beginning reconciliation`,\n\t\"🛎️\": `Realtime transaction received`,\n\t\"👁\": `Determining perspective`,\n\t\"🔭\": `Determining realtime perspective`,\n\t\"🖌\": `Redacting realtime update`,\n\t\"👋\": `Realtime greeting`,\n\t\"👍\": `Realtime acknowledgment`,\n} as const\nexport type LoggerIcon = keyof typeof LOGGER_ICON_DICTIONARY\nexport type TokenDenomination =\n\t| `atom_family`\n\t| `atom`\n\t| `continuity`\n\t| `key`\n\t| `mutable_atom_family`\n\t| `mutable_atom`\n\t| `readonly_held_selector_family`\n\t| `readonly_held_selector`\n\t| `readonly_pure_selector_family`\n\t| `readonly_pure_selector`\n\t| `state`\n\t| `timeline`\n\t| `transaction`\n\t| `unknown`\n\t| `writable_held_selector_family`\n\t| `writable_held_selector`\n\t| `writable_pure_selector_family`\n\t| `writable_pure_selector`\n\nexport const PRETTY_TOKEN_TYPES: Record<TokenDenomination, string> = {\n\tatom_family: `atom family`,\n\tatom: `atom`,\n\tcontinuity: `continuity`,\n\tkey: `key`,\n\tmutable_atom_family: `atom family [m]`,\n\tmutable_atom: `atom [m]`,\n\treadonly_held_selector_family: `selector family [h]`,\n\treadonly_held_selector: `selector [h]`,\n\treadonly_pure_selector_family: `selector family`,\n\treadonly_pure_selector: `selector`,\n\tstate: `state`,\n\ttimeline: `timeline`,\n\ttransaction: `transaction`,\n\tunknown: `unknown`,\n\twritable_held_selector_family: `selector family [wh]`,\n\twritable_held_selector: `selector [wh]`,\n\twritable_pure_selector_family: `selector family [w]`,\n\twritable_pure_selector: `selector [w]`,\n}\n\nexport const LOG_LEVELS = [`info`, `warn`, `error`] as const\nexport type LogLevel = (typeof LOG_LEVELS)[number]\n\nexport type LogFn = (\n\ticon: LoggerIcon,\n\tdenomination: TokenDenomination,\n\ttokenKey: string,\n\tmessage: string,\n\t...rest: unknown[]\n) => void\nexport type LogFilter = (\n\t...params: Parameters<LogFn>\n) => Parameters<LogFn> | boolean\n\nexport type Logger = Record<LogLevel, LogFn>\n\nexport const simpleLog =\n\t(logLevel: keyof Logger): LogFn =>\n\t(icon, denomination, tokenKey, message, ...rest) => {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole[logLevel](\n\t\t\t`${icon} ${PRETTY_TOKEN_TYPES[denomination]} \\`${tokenKey}\\` ${message}`,\n\t\t\t...rest,\n\t\t)\n\t}\nexport const simpleLogger: Logger = {\n\terror: simpleLog(`error`),\n\tinfo: simpleLog(`info`),\n\twarn: simpleLog(`warn`),\n}\n\nexport class AtomIOLogger implements Logger {\n\tpublic logLevel: `error` | `info` | `warn` | null\n\tpublic filter: LogFilter | undefined\n\tprivate readonly logger: Logger\n\n\tpublic constructor(\n\t\tlogLevel: `error` | `info` | `warn` | null,\n\t\tfilter?: LogFilter,\n\t\tlogger: Logger = simpleLogger,\n\t) {\n\t\tthis.logLevel = logLevel\n\t\tthis.filter = filter\n\t\tthis.logger = logger\n\t}\n\n\tpublic error: LogFn = (...args) => {\n\t\tif (this.logLevel !== null) {\n\t\t\tconst filterResult = this.filter?.(...args) ?? true\n\t\t\tif (filterResult === true) {\n\t\t\t\tthis.logger.error(...args)\n\t\t\t} else if (filterResult) {\n\t\t\t\tthis.logger.error(...filterResult)\n\t\t\t}\n\t\t}\n\t}\n\tpublic info: LogFn = (...args) => {\n\t\tif (this.logLevel === `info`) {\n\t\t\tconst filterResult = this.filter?.(...args) ?? true\n\t\t\tif (filterResult === true) {\n\t\t\t\tthis.logger.info(...args)\n\t\t\t} else if (filterResult) {\n\t\t\t\tthis.logger.info(...filterResult)\n\t\t\t}\n\t\t}\n\t}\n\tpublic warn: LogFn = (...args) => {\n\t\tif (this.logLevel !== `error` && this.logLevel !== null) {\n\t\t\tconst filterResult = this.filter?.(...args) ?? true\n\t\t\tif (filterResult === true) {\n\t\t\t\tthis.logger.warn(...args)\n\t\t\t} else if (filterResult) {\n\t\t\t\tthis.logger.warn(...filterResult)\n\t\t\t}\n\t\t}\n\t}\n}\n", "import type { Each, RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tallocateIntoStore,\n\tarbitrary,\n\tclaimWithinStore,\n\tcreateClaimTX,\n\tcreateDeallocateTX,\n\tfuseWithinStore,\n\tIMPLICIT,\n\tmakeRootMoleculeInStore,\n} from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { TransactionToken } from \"./tokens\"\n\nexport const $validatedKey: unique symbol = Symbol.for(`claim`)\nexport type ValidKey<K extends Canonical> = K & { [$validatedKey]?: true }\n\nexport function simpleCompound(a: string, b: string): string {\n\treturn [a, b].sort().join(`\\u001F`)\n}\n\nexport class Realm<H extends Hierarchy> {\n\tpublic store: RootStore\n\tpublic deallocateTX: TransactionToken<(claim: ValidKey<Vassal<H>>) => void>\n\tpublic claimTX: TransactionToken<\n\t\t<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(\n\t\t\tnewProvenance: A,\n\t\t\tclaim: ValidKey<V>,\n\t\t\texclusive?: `exclusive`,\n\t\t) => void\n\t>\n\t/**\n\t * @param store - The store to which the realm will be attached\n\t */\n\tpublic constructor(store: RootStore = IMPLICIT.STORE) {\n\t\tthis.store = store\n\t\tthis.deallocateTX = createDeallocateTX(store)\n\t\tthis.claimTX = createClaimTX(store)\n\t\tmakeRootMoleculeInStore(store, `root`)\n\t}\n\t/**\n\t * Make space for a new subject of the realm\n\t * @param provenance - A key for an owner {@link Above} the new subject in the realm's {@link Hierarchy}\n\t * @param key - A unique identifier for the new subject\n\t * @param attachmentStyle - The attachment style of new subject to its owner(s). `any` means that if any owners remain, the subject will be retained. `all` means that the subject be retained only if all owners remain .\n\t * @returns\n\t * The subject's key, given status as a true {@link ValidKey}\n\t */\n\tpublic allocate<V extends Vassal<H>, A extends Above<V, H>>(\n\t\tprovenance: A,\n\t\tkey: V,\n\t\tattachmentStyle?: `all` | `any`,\n\t): ValidKey<V> {\n\t\treturn allocateIntoStore<H, V, A>(\n\t\t\tthis.store,\n\t\t\tprovenance,\n\t\t\tkey,\n\t\t\tattachmentStyle,\n\t\t)\n\t}\n\t/**\n\t * Fuse two reagents into a compound\n\t * @param type - the name of the compound that is being fused\n\t * @param reagentA - the left reagent of the compound\n\t * @param reagentB - the right reagent of the compound\n\t * @returns\n\t * The compound's key, given status as a {@link ValidKey}\n\t */\n\tpublic fuse<\n\t\tC extends CompoundFrom<H>,\n\t\tT extends C extends CompoundTypedKey<infer t, any, any> ? t : never,\n\t\tA extends C extends CompoundTypedKey<any, infer v, any> ? v : never,\n\t\tB extends C extends CompoundTypedKey<any, any, infer m> ? m : never,\n\t>(\n\t\ttype: T,\n\t\treagentA: SingularTypedKey<A>,\n\t\treagentB: SingularTypedKey<B>,\n\t): ValidKey<CompoundTypedKey<T, A, B>> {\n\t\treturn fuseWithinStore<H, C, T, A, B>(this.store, type, reagentA, reagentB)\n\t}\n\t/**\n\t * Remove a subject from the realm\n\t * @param claim - The subject to be deallocated\n\t */\n\tpublic deallocate<V extends Vassal<H>>(claim: ValidKey<V>): void {\n\t\tactUponStore(this.store, this.deallocateTX, arbitrary())(claim)\n\t}\n\t/**\n\t * Transfer a subject of the realm from one owner to another\n\t * @param newProvenance - A key for an owner {@link Above} the new subject in the realm's {@link Hierarchy}\n\t * @param claim - The subject to be claimed\n\t * @param exclusive - Whether the subjects previous owners should be detached from it\n\t * @returns\n\t * The subject's key, given status as a true {@link ValidKey}\n\t */\n\tpublic claim<\n\t\tV extends Exclude<Vassal<H>, CompoundTypedKey>,\n\t\tA extends Above<V, H>,\n\t>(newProvenance: A, claim: ValidKey<V>, exclusive?: `exclusive`): void {\n\t\tactUponStore(this.store, this.claimTX, arbitrary())(\n\t\t\tnewProvenance,\n\t\t\tclaim,\n\t\t\texclusive,\n\t\t)\n\t}\n}\n\nexport class Anarchy {\n\tpublic store: RootStore\n\tpublic deallocateTX: TransactionToken<(key: Canonical) => void>\n\tpublic claimTX: TransactionToken<\n\t\t(newProvenance: Canonical, key: Canonical, exclusive?: `exclusive`) => void\n\t>\n\n\t/**\n\t * @param store - The store to which the anarchy-realm will be attached\n\t */\n\tpublic constructor(store: RootStore = IMPLICIT.STORE) {\n\t\tthis.store = store\n\t\tthis.deallocateTX = createDeallocateTX(store)\n\t\tthis.claimTX = createClaimTX(store)\n\t\tmakeRootMoleculeInStore(store, `root`)\n\t}\n\t/**\n\t * Declare a new entity\n\t * @param provenance - A key for an owner of the entity\n\t * @param key - A unique identifier for the new entity\n\t * @param attachmentStyle - The attachment style of new entity to its owner(s). `any` means that if any owners remain, the subject will be retained. `all` means that the subject be retained only if all owners remain .\n\t */\n\tpublic allocate(\n\t\tprovenance: Canonical,\n\t\tkey: Canonical,\n\t\tattachmentStyle?: `all` | `any`,\n\t): void {\n\t\tallocateIntoStore<any, any, any>(\n\t\t\tthis.store,\n\t\t\tprovenance,\n\t\t\tkey,\n\t\t\tattachmentStyle,\n\t\t)\n\t}\n\t/**\n\t * Remove an entity\n\t * @param key - The entity to be deallocated\n\t */\n\tpublic deallocate(key: Canonical): void {\n\t\tactUponStore(this.store, this.deallocateTX, arbitrary())(key)\n\t}\n\t/**\n\t * Transfer an entity from one owner to another\n\t * @param newProvenance - A key for an owner of the entity\n\t * @param key - The entity to be claimed\n\t * @param exclusive - Whether the entity's previous owners should be detached from it\n\t */\n\tpublic claim(\n\t\tnewProvenance: Canonical,\n\t\tkey: Canonical,\n\t\texclusive?: `exclusive`,\n\t): void {\n\t\tclaimWithinStore<any, any, any>(this.store, newProvenance, key, exclusive)\n\t}\n\t/**\n\t * Fuse two reagents into a compound\n\t * @param type - the name of the compound that is being fused\n\t * @param reagentA - the left reagent of the compound\n\t * @param reagentB - the right reagent of the compound\n\t * @returns\n\t * The compound's key, given status as a {@link ValidKey}\n\t */\n\tpublic fuse<T extends string, A extends string, B extends string>(\n\t\ttype: T,\n\t\treagentA: SingularTypedKey<A>,\n\t\treagentB: SingularTypedKey<B>,\n\t): ValidKey<CompoundTypedKey<T, A, B>> {\n\t\treturn fuseWithinStore<any, any, T, A, B>(\n\t\t\tthis.store,\n\t\t\ttype,\n\t\t\treagentA,\n\t\t\treagentB,\n\t\t)\n\t}\n}\n\nexport function decomposeCompound(\n\tcompound: Canonical,\n): [type: string, a: string, b: string] | null {\n\tif ((typeof compound === `string`) === false) {\n\t\treturn null\n\t}\n\tconst [typeTag, components] = compound.split(`==`)\n\tif (!components) {\n\t\treturn null\n\t}\n\tconst type = typeTag.slice(4)\n\tconst [a, b] = components.split(`++`)\n\tif (type && a && b) {\n\t\treturn [type, a, b]\n\t}\n\treturn null\n}\n\nexport type T$ = `T$`\nexport type TypeTag<T extends string> = `${T$}--${T}`\nexport type SingularTypedKey<T extends string = string> = `${T}::${string}`\nexport type CompoundTypedKey<\n\tT extends string = string,\n\tA extends string = string,\n\tB extends string = string,\n> = `${TypeTag<T>}==${SingularTypedKey<A>}++${SingularTypedKey<B>}`\nexport type TypedKey<\n\tT extends string = string,\n\tA extends string = string,\n\tB extends string = string,\n> = CompoundTypedKey<T, A, B> | SingularTypedKey<T>\ntype Scope = SingularTypedKey[]\ntype MutualFealty = {\n\tabove: Scope\n\tbelow: CompoundTypedKey\n}\ntype ExclusiveFealty = {\n\tabove: TypedKey | `root`\n\tbelow: Scope\n}\ntype Fealty = ExclusiveFealty | MutualFealty\n\nexport type Hierarchy<F extends Fealty[] = Fealty[]> = Each<F>\n\nexport type Vassal<H extends Hierarchy> = {\n\t[K in keyof H]: H[K] extends MutualFealty\n\t\t? H[K][`below`]\n\t\t: H[K] extends { below: Array<infer V> }\n\t\t\t? V extends TypedKey\n\t\t\t\t? V\n\t\t\t\t: never\n\t\t\t: never\n}[keyof H]\n\nexport type Above<TK extends TypedKey, H extends Hierarchy> = {\n\t[K in keyof H]: H[K] extends MutualFealty\n\t\t? TK extends H[K][`below`]\n\t\t\t? H[K][`above`]\n\t\t\t: never\n\t\t: H[K] extends { below: Array<infer V> }\n\t\t\t? TK extends V\n\t\t\t\t? H[K] extends ExclusiveFealty\n\t\t\t\t\t? H[K][`above`]\n\t\t\t\t\t: never\n\t\t\t\t: never\n\t\t\t: never\n}[keyof H]\n\nexport type Below<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {\n\t[K in keyof H]: H[K] extends MutualFealty\n\t\t? TK extends H[K][`above`]\n\t\t\t? H[K][`below`]\n\t\t\t: TK extends H[K][`above`][number]\n\t\t\t\t? H[K][`below`]\n\t\t\t\t: never\n\t\t: H[K] extends { above: infer V }\n\t\t\t? TK extends V\n\t\t\t\t? H[K] extends ExclusiveFealty\n\t\t\t\t\t? H[K][`below`][number]\n\t\t\t\t\t: never\n\t\t\t\t: never\n\t\t\t: never\n}[keyof H]\n\nexport type Mutuals<TK extends TypedKey | TypedKey[], H extends Hierarchy> = {\n\t[K in keyof H]: H[K] extends MutualFealty\n\t\t? TK extends H[K][`above`][number]\n\t\t\t? [mutual: Exclude<H[K][`above`][number], TK>, below: H[K][`below`]]\n\t\t\t: never\n\t\t: never\n}[keyof H]\n\nexport type CompoundFrom<H extends Hierarchy> = {\n\t[K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : never\n}[keyof H]\n", "import { IMPLICIT, resetInStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { WritableFamilyToken, WritableToken } from \".\"\n\n/**\n * Set the value of a state into the implicit store back to its default value.\n * @param token - An atom or writable selector token.\n * @overload Default\n * @default\n */\nexport function resetState(token: WritableToken<any, any, any>): void\n/**\n * Set the value of a state into the implicit store back to its default value.\n * @param token - An atom family or writable selector family token.\n * @param key - The unique key of the state to set.\n * @overload Streamlined\n */\nexport function resetState<K extends Canonical>(\n\ttoken: WritableFamilyToken<any, K, any>,\n\tkey: K,\n): void\nexport function resetState(\n\t...params:\n\t\t| [token: WritableFamilyToken<any, Canonical, any>, key: Canonical]\n\t\t| [token: WritableToken<any, any, any>]\n): void {\n\tresetInStore(IMPLICIT.STORE, ...params)\n}\n", "import type { Ctor } from \"atom.io/internal\"\nimport {\n\tcreateSelectorFamily,\n\tcreateStandaloneSelector,\n\tIMPLICIT,\n} from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type {\n\tReadonlyHeldSelectorFamilyToken,\n\tReadonlyHeldSelectorToken,\n\tReadonlyPureSelectorFamilyToken,\n\tReadonlyPureSelectorToken,\n\tWritableHeldSelectorFamilyToken,\n\tWritableHeldSelectorToken,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorToken,\n} from \"./tokens\"\nimport type { Read, Write } from \"./transaction\"\n\nexport type WritablePureSelectorOptions<T, E = never> = {\n\t/** The unique identifier of the selector */\n\tkey: string\n\t/** For each instantiated selector, a function that computes its value */\n\tget: Read<() => T>\n\t/** For each instantiated selector, a function that sets its value */\n\tset: Write<(newValue: T) => void>\n\t/** The classes of errors that might be thrown when deriving the atom's default value */\n\tcatch?: readonly Ctor<E>[]\n}\nexport type ReadonlyPureSelectorOptions<T, E = never> = {\n\t/** The unique identifier of the selector */\n\tkey: string\n\t/** For each instantiated selector, a function that computes its value */\n\tget: Read<() => T>\n\t/** The classes of errors that might be thrown when deriving the atom's default value */\n\tcatch?: readonly Ctor<E>[]\n}\nexport type ReadonlyHeldSelectorOptions<T extends object> = {\n\t/** The unique identifier of the selector */\n\tkey: string\n\t/** For each instantiated selector, a constant reference to a value that will not be replaced */\n\tconst: T\n\t/** For each instantiated selector, a function that computes its value */\n\tget: Read<(permanent: T) => void>\n}\nexport type WritableHeldSelectorOptions<T extends object> = {\n\t/** The unique identifier of the selector */\n\tkey: string\n\t/** For each instantiated selector, a constant reference to a value that will not be replaced */\n\tconst: T\n\t/** For each instantiated selector, a function that computes its value */\n\tget: Read<(permanent: T) => void>\n\t/** For each instantiated selector, a function that sets its value */\n\tset: Write<(newValue: T) => void>\n}\n\n/**\n * Declare a selector. The value of a selector should depend\n * on the value of atoms or other selectors in the store, and\n * should be recycled when a root atom of the selector is set.\n *\n * A held selector's value must be some object.\n * The reference to that object is permanent and will not be replaced.\n *\n * A writable selector can be \"set\" to a new value.\n * It is strongly advised to set its dependencies to values\n * that would produce the new value of the selector.\n *\n * @param options - {@link WritableHeldSelectorOptions}.\n * @returns\n * The token for your selector.\n * @overload WritableHeld\n */\nexport function selector<T extends object>(\n\toptions: WritableHeldSelectorOptions<T>,\n): WritableHeldSelectorToken<T>\n/**\n * Declare a selector. The value of a selector should depend\n * on the value of atoms or other selectors in the store,\n * and should be recycled when a root atom of the selector is set.\n *\n * A held selector's value must be some object.\n * The reference to that object is permanent and will not be replaced.\n *\n * A readonly selector can be \"gotten\" but not \"set\".\n *\n * @param options - {@link ReadonlyHeldSelectorOptions}.\n * @returns\n * The token for your selector.\n * @overload ReadonlyHeld\n */\nexport function selector<T extends object>(\n\toptions: ReadonlyHeldSelectorOptions<T>,\n): ReadonlyHeldSelectorToken<T>\n/**\n * Declare a selector. The value of a selector should depend\n * on the value of atoms or other selectors in the store.\n *\n * A pure selector's current value is evicted from the store\n * in order to be garbage collected when a root atom of the selector is set.\n *\n * A writable selector can be \"set\" to a new value.\n * It is strongly advised to set its dependencies to values\n * that would produce the new value of the selector.\n *\n * @param options - {@link TransientWritableSelectorOptions}.\n * @returns\n * The token for your selector.\n * @overload WritablePure\n */\nexport function selector<T, E = never>(\n\toptions: WritablePureSelectorOptions<T, E>,\n): WritablePureSelectorToken<T, any, E>\n/**\n * Declare a selector. The value of a selector should depend\n * on the value of atoms or other selectors in the store.\n *\n * A pure selector's current value is evicted from the store\n * in order to be garbage collected when a root atom of the selector is set.\n *\n * A readonly selector can be \"gotten\" but not \"set\".\n *\n * @param options - {@link ReadonlyPureSelectorOptions}.\n * @returns\n * The token for your selector.\n * @overload ReadonlyPure\n */\nexport function selector<T, E = never>(\n\toptions: ReadonlyPureSelectorOptions<T, E>,\n): ReadonlyPureSelectorToken<T, any, E>\nexport function selector(\n\toptions:\n\t\t| ReadonlyHeldSelectorOptions<any>\n\t\t| ReadonlyPureSelectorOptions<any, any>\n\t\t| WritableHeldSelectorOptions<any>\n\t\t| WritablePureSelectorOptions<any, any>,\n):\n\t| ReadonlyHeldSelectorToken<any>\n\t| ReadonlyPureSelectorToken<any, any, any>\n\t| WritableHeldSelectorToken<any>\n\t| WritablePureSelectorToken<any, any, any> {\n\treturn createStandaloneSelector(IMPLICIT.STORE, options)\n}\n\nexport type WritablePureSelectorFamilyOptions<\n\tT,\n\tK extends Canonical,\n\tE = never,\n> = {\n\t/** The unique identifier of the family */\n\tkey: string\n\t/** For each instantiated family member, a function that computes its value */\n\tget: (key: K) => Read<() => T>\n\t/** For each instantiated family member, a function that sets its value */\n\tset: (key: K) => Write<(newValue: T) => void>\n\t/** The classes of errors that might be thrown when deriving the atom's default value */\n\tcatch?: readonly Ctor<E>[]\n}\nexport type ReadonlyPureSelectorFamilyOptions<\n\tT,\n\tK extends Canonical,\n\tE = never,\n> = {\n\t/** The unique identifier of the family */\n\tkey: string\n\t/** For each instantiated family member, a function that computes its value */\n\tget: (key: K) => Read<() => T>\n\t/** The classes of errors that might be thrown when deriving the atom's default value */\n\tcatch?: readonly Ctor<E>[]\n}\nexport type WritableHeldSelectorFamilyOptions<\n\tT extends object,\n\tK extends Canonical,\n> = {\n\t/** The unique identifier of the family */\n\tkey: string\n\t/** For each instantiated family member, a constant reference to a value that will not be replaced */\n\tconst: (key: K) => T\n\t/** For each instantiated family member, a function that computes its value */\n\tget: (key: K) => Read<(permanent: T) => void>\n\t/** For each instantiated family member, a function that sets its value */\n\tset: (key: K) => Write<(newValue: T) => void>\n}\nexport type ReadonlyHeldSelectorFamilyOptions<\n\tT extends object,\n\tK extends Canonical,\n> = {\n\t/** The unique identifier of the family */\n\tkey: string\n\t/** For each instantiated family member, a constant reference to a value that will not be replaced */\n\tconst: (key: K) => T\n\t/** For each instantiated family member, a function that computes its value */\n\tget: (key: K) => Read<(permanent: T) => void>\n}\n\n/**\n * Create a family of selectors, allowing for the dynamic creation and disposal of selectors.\n *\n * The value of a held selector should depend on the value of atoms or other selectors in the store,\n * and should be recycled when a root atom of the selector is set.\n *\n * A held selector's value must be some object.\n * The reference to that object is permanent and will not be replaced.\n *\n * A writable selector can be \"set\" to a new value.\n * It is advised to set its dependencies to values\n * that would produce the new value of the selector.\n *\n * @param options - {@link WritableHeldSelectorFamilyOptions}.\n * @returns\n * A reference to the selector family created: a {@link WritableHeldSelectorFamilyToken}\n * @overload WritableHeld\n */\nexport function selectorFamily<T extends object, K extends Canonical>(\n\toptions: WritableHeldSelectorFamilyOptions<T, K>,\n): WritableHeldSelectorFamilyToken<T, K>\n/**\n * Create a family of selectors, allowing for the dynamic creation and disposal of selectors.\n *\n * The value of a held selector should depend on the value of atoms or other selectors in the store,\n * and should be recycled when a root atom of the selector is set.\n *\n * A held selector's value must be some object.\n * The reference to that object is permanent and will not be replaced.\n *\n * A readonly selector can be \"gotten\" but not \"set\".\n *\n * @param options - {@link ReadonlyHeldSelectorFamilyOptions}.\n * @returns\n * A reference to the selector family created: a {@link ReadonlyHeldSelectorFamilyToken}\n * @overload ReadonlyHeld\n */\nexport function selectorFamily<T extends object, K extends Canonical>(\n\toptions: ReadonlyHeldSelectorFamilyOptions<T, K>,\n): ReadonlyHeldSelectorFamilyToken<T, K>\n/**\n * Create a family of selectors, allowing for the dynamic creation and disposal of selectors.\n *\n * The value of a selector should depend on the value of atoms or other selectors in the store.\n *\n * A pure selector's current value is evicted from the store\n * in order to be garbage collected when a root atom of the selector is set.\n *\n * A writable selector can be \"set\" to a new value.\n * It is advised to set its dependencies to values\n * that would produce the new value of the selector.\n *\n * @param options - {@link TransientWritableSelectorFamilyOptions}.\n * @returns\n * A reference to the selector family created: a {@link TransientWritableSelectorFamilyToken}\n * @overload WritablePure\n */\nexport function selectorFamily<T, K extends Canonical, E = never>(\n\toptions: WritablePureSelectorFamilyOptions<T, K, E>,\n): WritablePureSelectorFamilyToken<T, K, E>\n/**\n * Create a family of selectors, allowing for the dynamic creation and disposal of selectors.\n *\n * The value of a selector should depend on the value of atoms or other selectors in the store.\n *\n * A pure selector's current value is evicted from the store\n * in order to be garbage collected when a root atom of the selector is set.\n *\n * A readonly selector can be \"gotten\" but not \"set\".\n *\n * @param options - {@link ReadonlyPureSelectorFamilyOptions}.\n * @returns\n * A reference to the selector family created: a {@link ReadonlyPureSelectorFamilyToken}\n * @overload ReadonlyPure\n */\nexport function selectorFamily<T, K extends Canonical, E = never>(\n\toptions: ReadonlyPureSelectorFamilyOptions<T, K, E>,\n): ReadonlyPureSelectorFamilyToken<T, K, E>\nexport function selectorFamily(\n\toptions:\n\t\t| ReadonlyHeldSelectorFamilyOptions<any, any>\n\t\t| ReadonlyPureSelectorFamilyOptions<any, any, any>\n\t\t| WritableHeldSelectorFamilyOptions<any, any>\n\t\t| WritablePureSelectorFamilyOptions<any, any, any>,\n):\n\t| ReadonlyHeldSelectorFamilyToken<any, any>\n\t| ReadonlyPureSelectorFamilyToken<any, any, any>\n\t| WritableHeldSelectorFamilyToken<any, any>\n\t| WritablePureSelectorFamilyToken<any, any, any> {\n\treturn createSelectorFamily(IMPLICIT.STORE, options)\n}\n", "import { IMPLICIT, setIntoStore } from \"atom.io/internal\"\nimport type { Canonical } from \"atom.io/json\"\n\nimport type { WritableFamilyToken, WritableToken } from \"./tokens\"\n\n/**\n * A function that sets the value of a state.\n * @param oldValue - The current value of the state.\n * @returns\n * The new value of the state.\n */\nexport type Setter<T> = (oldValue: T) => T\n\n/**\n * Set the value of a state into the implicit store.\n * @param token - An atom or writable selector token.\n * @param value - The new value of the state.\n * @overload Default\n * @default\n */\nexport function setState<T, TT extends T>(\n\ttoken: WritableToken<T, any, any>,\n\tvalue: Setter<TT> | TT,\n): void\n\n/**\n * Set the value of a state into the implicit store.\n * @param token - An atom family or writable selector family token.\n * @param key - The unique key of the state to set.\n * @param value - The new value of the state.\n * @overload Streamlined\n */\nexport function setState<T, TT extends T, K extends Canonical>(\n\ttoken: WritableFamilyToken<T, K, any>,\n\tkey: NoInfer<K>,\n\tvalue: Setter<TT> | TT,\n): void\n\nexport function setState<T, TT extends T, K extends Canonical>(\n\t...params:\n\t\t| [\n\t\t\t\ttoken: WritableFamilyToken<T, K, any>,\n\t\t\t\tkey: NoInfer<K>,\n\t\t\t\tvalue: Setter<TT> | TT,\n\t\t ]\n\t\t| [token: WritableToken<T, any, any>, value: Setter<TT> | TT]\n): void {\n\tsetIntoStore(IMPLICIT.STORE, ...params)\n}\n", "import type { findState } from \"atom.io\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tarbitrary,\n\tcreateMutableAtom,\n\tcreateMutableAtomFamily,\n\tcreateRegularAtom,\n\tcreateRegularAtomFamily,\n\tcreateSelectorFamily,\n\tcreateStandaloneSelector,\n\tcreateTimeline,\n\tcreateTransaction,\n\tdisposeFromStore,\n\tfindInStore,\n\tgetFromStore,\n\tIMPLICIT,\n\tinstallIntoStore,\n\tresetInStore,\n\tsetIntoStore,\n\tStore,\n\tsubscribeInStore,\n\ttimeTravel,\n} from \"atom.io/internal\"\n\nimport type {\n\tAtomIOToken,\n\tdisposeState,\n\tgetState,\n\tredo,\n\tsetState,\n\tsubscribe,\n\ttimeline,\n\tundo,\n} from \".\"\nimport type { atom, atomFamily, mutableAtom, mutableAtomFamily } from \"./atom\"\nimport type { resetState } from \"./reset-state\"\nimport type { selector, selectorFamily } from \"./selector\"\nimport type { runTransaction, transaction } from \"./transaction\"\n\nexport class Silo {\n\tpublic store: RootStore\n\tpublic atom: typeof atom\n\tpublic mutableAtom: typeof mutableAtom\n\tpublic atomFamily: typeof atomFamily\n\tpublic mutableAtomFamily: typeof mutableAtomFamily\n\tpublic selector: typeof selector\n\tpublic selectorFamily: typeof selectorFamily\n\tpublic transaction: typeof transaction\n\tpublic timeline: typeof timeline\n\tpublic findState: typeof findState\n\tpublic getState: typeof getState\n\tpublic setState: typeof setState\n\tpublic resetState: typeof resetState\n\tpublic disposeState: typeof disposeState\n\tpublic subscribe: typeof subscribe\n\tpublic undo: typeof undo\n\tpublic redo: typeof redo\n\tpublic runTransaction: typeof runTransaction\n\tpublic install: (tokens: AtomIOToken[], store?: RootStore) => void\n\n\tpublic constructor(config: Store[`config`], fromStore: Store | null = null) {\n\t\tconst s = (this.store = new Store(config, fromStore) as RootStore)\n\t\tthis.atom = ((options: Parameters<typeof atom>[0]) =>\n\t\t\tcreateRegularAtom(s, options, undefined)) as typeof atom\n\t\tthis.mutableAtom = ((options: Parameters<typeof mutableAtom>[0]) =>\n\t\t\tcreateMutableAtom(s, options, undefined)) as typeof mutableAtom\n\t\tthis.atomFamily = ((options: Parameters<typeof atomFamily>[0]) =>\n\t\t\tcreateRegularAtomFamily(s, options)) as typeof atomFamily\n\t\tthis.mutableAtomFamily = ((\n\t\t\toptions: Parameters<typeof mutableAtomFamily>[0],\n\t\t) => createMutableAtomFamily(s, options)) as typeof mutableAtomFamily\n\t\tthis.selector = ((options: Parameters<typeof selector>[0]) =>\n\t\t\tcreateStandaloneSelector(s, options)) as typeof selector\n\t\tthis.selectorFamily = ((options: Parameters<typeof selectorFamily>[0]) =>\n\t\t\tcreateSelectorFamily(s, options)) as typeof selectorFamily\n\t\tthis.transaction = (options) => createTransaction(s, options)\n\t\tthis.timeline = (options) => createTimeline(s, options)\n\t\tthis.findState = ((...params: Parameters<typeof findState>) =>\n\t\t\tfindInStore(s, ...params)) as typeof findState\n\t\tthis.getState = ((...params: Parameters<typeof getState>) =>\n\t\t\tgetFromStore(s, ...params)) as typeof getState\n\t\tthis.setState = ((...params: Parameters<typeof setState>) => {\n\t\t\tsetIntoStore(s, ...params)\n\t\t}) as typeof setState\n\t\tthis.resetState = ((...params: Parameters<typeof resetState>) => {\n\t\t\tresetInStore(s, ...params)\n\t\t}) as typeof resetState\n\t\tthis.disposeState = ((...params: Parameters<typeof disposeState>) => {\n\t\t\tdisposeFromStore(s, ...params)\n\t\t}) as typeof disposeState\n\t\tthis.subscribe = ((...params: Parameters<typeof subscribe>) =>\n\t\t\tsubscribeInStore(s, ...params)) as typeof subscribe\n\t\tthis.undo = (token) => {\n\t\t\ttimeTravel(s, `undo`, token)\n\t\t}\n\t\tthis.redo = (token) => {\n\t\t\ttimeTravel(s, `redo`, token)\n\t\t}\n\t\tthis.runTransaction = (token, id = arbitrary()) => actUponStore(s, token, id)\n\t\tthis.install = (tokens, source = IMPLICIT.STORE) => {\n\t\t\tinstallIntoStore(tokens, s, source)\n\t\t}\n\t}\n}\n", "import type { Fn } from \"atom.io/internal\"\nimport { arbitrary, IMPLICIT, subscribeInStore } from \"atom.io/internal\"\n\nimport type {\n\tStateUpdate,\n\tTimelineEvent,\n\tTransactionOutcomeEvent,\n} from \"./events\"\nimport type { TimelineManageable } from \"./timeline\"\nimport type { ReadableToken, TimelineToken, TransactionToken } from \"./tokens\"\n\nexport type UpdateHandler<T> = (update: StateUpdate<T>) => void\nexport type TransactionUpdateHandler<F extends Fn> = (\n\tdata: TransactionOutcomeEvent<TransactionToken<F>>,\n) => void\n\n/**\n * Subscribe to a state in the implicit store\n * @param token - The token of the state to subscribe to\n * @param handleUpdate - A function that will be called when the state is updated\n * @param key - A unique key for the subscription. If not provided, a random key will be generated.\n * @returns A function that can be called to unsubscribe from the state\n * @overload State\n */\nexport function subscribe<T>(\n\ttoken: ReadableToken<T>,\n\thandleUpdate: UpdateHandler<T>,\n\tkey?: string,\n): () => void\n/**\n * Subscribe to a transaction in the implicit store\n * @param token - The token of the transaction to subscribe to\n * @param handleUpdate - A function that will be called when the transaction succeeds\n * @param key - A unique key for the subscription. If not provided, a random key will be generated.\n * @returns A function that can be called to unsubscribe from the transaction\n * @overload Transaction\n */\nexport function subscribe<F extends Fn>(\n\ttoken: TransactionToken<F>,\n\thandleUpdate: TransactionUpdateHandler<F>,\n\tkey?: string,\n): () => void\n/**\n * Subscribe to a timeline in the implicit store\n * @param token - The token of the timeline to subscribe to\n * @param handleUpdate - A function that will be called when a new update is available\n * @param key - A unique key for the subscription. If not provided, a random key will be generated.\n * @returns A function that can be called to unsubscribe from the timeline\n * @overload Timeline\n */\nexport function subscribe<M extends TimelineManageable>(\n\ttoken: TimelineToken<M>,\n\thandleUpdate: (update: TimelineEvent<M> | `redo` | `undo`) => void,\n\tkey?: string,\n): () => void\nexport function subscribe(\n\ttoken: ReadableToken<any> | TimelineToken<any> | TransactionToken<any>,\n\thandleUpdate: (update: any) => void,\n\tkey: string = arbitrary(),\n): () => void {\n\treturn subscribeInStore(IMPLICIT.STORE, token, handleUpdate, key)\n}\n", "import { createTimeline, IMPLICIT, timeTravel } from \"atom.io/internal\"\n\nimport type { AtomFamilyToken, AtomToken, TimelineToken } from \".\"\n\nexport type TimelineManageable =\n\t| AtomFamilyToken<any, any, any>\n\t| AtomToken<any, any, any>\nexport type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<\n\tany,\n\tany\n>\n\t? AtomToken<any, any, any>\n\t: M extends AtomToken<any, any, any>\n\t\t? M\n\t\t: never\n\n/**\n * If there is an update ahead of the cursor (in the future of this {@link timeline}), apply it and move the cursor to the next update\n * @param timeline - A {@link TimelineToken}\n */\nexport const redo = (timeline: TimelineToken<any>): void => {\n\ttimeTravel(IMPLICIT.STORE, `redo`, timeline)\n}\n/**\n * Reverse the last update on the {@link timeline} and move the cursor to the previous update\n * @param timeline - A {@link TimelineToken}\n */\nexport const undo = (timeline: TimelineToken<any>): void => {\n\ttimeTravel(IMPLICIT.STORE, `undo`, timeline)\n}\n\nexport type TimelineOptions<ManagedAtom extends TimelineManageable> = {\n\t/** The unique identifier of the timeline */\n\tkey: string\n\t/** The managed atoms (and families of atoms) to record */\n\tscope: ManagedAtom[]\n}\n\n/**\n * Create a timeline, a mechanism for recording, undoing, and replaying changes to groups of atoms\n * @param options - {@link TimelineOptions}\n * @returns A reference to the timeline created: a {@link TimelineToken}\n */\nexport const timeline = <ManagedAtom extends TimelineManageable>(\n\toptions: TimelineOptions<ManagedAtom>,\n): TimelineToken<ManagedAtom> => {\n\treturn createTimeline(IMPLICIT.STORE, options)\n}\n", "import type { AsJSON, EnvironmentData, Fn, Transceiver } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tarbitrary,\n\tcreateTransaction,\n\tIMPLICIT,\n} from \"atom.io/internal\"\n\nimport type { disposeState } from \"./dispose-state\"\nimport type { findState } from \"./find-state\"\nimport type { getState } from \"./get-state\"\nimport type { resetState } from \"./reset-state\"\nimport type { setState } from \"./set-state\"\nimport type {\n\tMutableAtomToken,\n\tTransactionToken,\n\tWritablePureSelectorToken,\n} from \"./tokens\"\n\nexport type ReaderToolkit = Pick<ActorToolkit, `find` | `get` | `json`>\nexport type WriterToolkit = Pick<ActorToolkit, `find` | `get` | `json` | `set`>\nexport type ActorToolkit = Readonly<{\n\tget: typeof getState\n\tset: typeof setState\n\treset: typeof resetState\n\tfind: typeof findState\n\tjson: <T extends Transceiver<any, any, any>>(\n\t\tstate: MutableAtomToken<T>,\n\t) => WritablePureSelectorToken<AsJSON<T>>\n\tdispose: typeof disposeState\n\trun: typeof runTransaction\n\tenv: () => EnvironmentData\n}>\n\nexport type Read<F extends Fn> = (\n\ttoolkit: ReaderToolkit,\n\t...parameters: Parameters<F>\n) => ReturnType<F>\nexport type Write<F extends Fn> = (\n\ttoolkit: WriterToolkit,\n\t...parameters: Parameters<F>\n) => ReturnType<F>\nexport type Transact<F extends Fn> = (\n\ttoolkit: ActorToolkit,\n\t...parameters: Parameters<F>\n) => ReturnType<F>\nexport type TransactionIO<Token extends TransactionToken<any>> =\n\tToken extends TransactionToken<infer F> ? F : never\nexport type TransactionOptions<F extends Fn> = {\n\t/** The unique identifier of the transaction */\n\tkey: string\n\t/** The operation to perform */\n\tdo: Transact<F>\n}\n\n/**\n * Create a transaction, a mechanism for batching updates multiple states in a single, all-or-nothing operation\n * @param options - {@link TransactionOptions}\n * @returns A reference to the transaction created: a {@link TransactionToken}\n */\nexport function transaction<F extends Fn>(\n\toptions: TransactionOptions<F>,\n): TransactionToken<F> {\n\treturn createTransaction(IMPLICIT.STORE, options)\n}\n\n/**\n * Execute a {@link transaction}\n * @param token - A {@link TransactionToken}\n * @param id - A unique identifier for the transaction. If not provided, a random identifier will be generated\n * @returns A function that can be called to run the transaction with its {@link TransactionIO} parameters\n */\nexport function runTransaction<F extends Fn>(\n\ttoken: TransactionToken<F>,\n\tid: string = arbitrary(),\n): (...parameters: Parameters<F>) => ReturnType<F> {\n\treturn actUponStore(IMPLICIT.STORE, token, id)\n}\n", "import type {\n\tMutableAtomFamilyToken,\n\tMutableAtomToken,\n\tReadableFamilyToken,\n\tReadableToken,\n\tReadonlyPureSelectorFamilyToken,\n\tReadonlyPureSelectorToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tTransactionToken,\n\tWritableFamilyToken,\n\tWritablePureSelectorFamilyToken,\n\tWritablePureSelectorToken,\n\tWritableToken,\n} from \"./tokens\"\n\nexport type TokenType<\n\tComparison extends\n\t\t| ReadableFamilyToken<any, any, any>\n\t\t| ReadableToken<any, any, any>\n\t\t| TransactionToken<any>,\n> = Comparison extends ReadableToken<infer RepresentedValue>\n\t? RepresentedValue\n\t: Comparison extends ReadableFamilyToken<infer RepresentedValue, any>\n\t\t? RepresentedValue\n\t\t: Comparison extends TransactionToken<infer Fn>\n\t\t\t? Fn\n\t\t\t: never\n\nexport function isToken<KnownToken extends RegularAtomToken<any, any, any>>(\n\tknownToken: KnownToken,\n\tunknownToken: ReadableToken<any, any, any>,\n): unknownToken is RegularAtomToken<TokenType<KnownToken>>\nexport function isToken<KnownToken extends MutableAtomToken<any, any>>(\n\tknownToken: KnownToken,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is MutableAtomToken<TokenType<KnownToken>, any>\nexport function isToken<KnownToken extends WritablePureSelectorToken<any>>(\n\tknownToken: KnownToken,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is WritablePureSelectorToken<TokenType<KnownToken>>\nexport function isToken<KnownToken extends ReadonlyPureSelectorToken<any>>(\n\tknownToken: KnownToken,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is ReadonlyPureSelectorToken<TokenType<KnownToken>>\nexport function isToken<KnownToken extends WritableToken<any>>(\n\tknownToken: KnownToken,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is WritableToken<TokenType<KnownToken>>\nexport function isToken<KnownToken extends ReadableToken<any>>(\n\tknownToken: KnownToken,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is ReadableToken<TokenType<KnownToken>>\nexport function isToken<KnownToken extends ReadableToken<any>>(\n\tknownToken: KnownToken,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is ReadableToken<TokenType<KnownToken>> {\n\treturn knownToken.key === unknownToken.key\n}\n\nexport function belongsTo<Family extends RegularAtomFamilyToken<any, any>>(\n\tfamily: Family,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is RegularAtomToken<TokenType<Family>>\nexport function belongsTo<Family extends MutableAtomFamilyToken<any, any>>(\n\tfamily: Family,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is MutableAtomToken<TokenType<Family>, any>\nexport function belongsTo<\n\tFamily extends WritablePureSelectorFamilyToken<any, any>,\n>(\n\tfamily: Family,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is WritablePureSelectorToken<TokenType<Family>>\nexport function belongsTo<\n\tFamily extends ReadonlyPureSelectorFamilyToken<any, any>,\n>(\n\tfamily: Family,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is ReadonlyPureSelectorToken<TokenType<Family>>\nexport function belongsTo<Family extends WritableFamilyToken<any, any>>(\n\tfamily: Family,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is WritableToken<TokenType<Family>>\nexport function belongsTo<Family extends ReadableFamilyToken<any, any>>(\n\tfamily: Family,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is ReadableToken<TokenType<Family>>\nexport function belongsTo<Family extends ReadableFamilyToken<any, any>>(\n\tfamily: Family,\n\tunknownToken: ReadableToken<any>,\n): unknownToken is ReadableToken<TokenType<Family>> {\n\treturn family.key === unknownToken.family?.key\n}\n"],
|
|
5
|
-
"mappings": ";ACuEA,SAAgB,UAAU,KAAgC;AACzD,SAAO,KAAK,MAAM,GAAA;;AAInB,IAAa,gBAAA,CACZ,SACoB,KAAK,UAAU,IAAA;AAapC,IAAM,kBAAkB;EACvB,MAAM;EACN,QAAQ;EACR,OAAO;EACP,OAAO;EACP,OAAO;;;;ACtER,SAAgB,YACf,QACiB;AACjB,QAAMA,SAA2B,CAAA;AACjC,MAAI,IAAI;AACR,aAAW,SAAS,QAAQ;AAC3B,WAAO,KAAA,IAAS;AACh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C3D,aAAW,SAAS,OAAO,QAAQC,UAAAA;;AAMpC,IAAa,OAAA,CAAQ,eAAuC;AAC3D,aAAW,SAAS,OAAO,QAAQA,UAAAA;;AAepC,IAAa,WAAA,CACZ,YACgC;AAChC,SAAO,eAAe,SAAS,OAAO,OAAA;;ACcvC,SAAgB,YACf,SACsB;AACtB,SAAO,kBAAkB,SAAS,OAAO,OAAA;;AAS1C,SAAgB,eACf,OACA,KAAa,UAAA,GACqC;AAClD,SAAO,aAAa,SAAS,OAAO,OAAO,EAAA;;ACvB5C,SAAgB,QACf,YACA,cACuD;AACvD,SAAO,WAAW,QAAQ,aAAa;;AA+BxC,SAAgB,UACf,QACA,cACmD;AACnD,SAAO,OAAO,QAAQ,aAAa,QAAQ;;",
|
|
6
|
-
"names": ["result: Record<any, any>", "SET_UPDATE_ENUM: Enumeration<[`add`, `delete`, `clear`]>", "UList", "superResolve: ((value: T) => void) | undefined", "superReject: ((reason?: any) => void) | undefined", "CircularBuffer", "length: number", "Junction", "a: A | undefined", "b: B | undefined", "a: A", "b: B", "content: Content | undefined", "singleRelation: A | B | undefined", "config: JunctionAdvancedConfiguration<AName, A, BName, B, Content>", "invalidKeys: stringified<Canonical>[]", "creationEvent: MoleculeCreationEvent", "compoundKey: CompoundTypedKey<T, A, B>", "join", "provenance: stringified<Canonical>[]", "values: [string, any][]", "disposalEvent: MoleculeDisposalEvent", "transferEvent: MoleculeTransferEvent", "exclusivity: `exclusive` | undefined", "updates: (\n\t\t| AtomUpdateEvent<AtomOnly<TimelineManageable>>\n\t\t| StateCreationEvent<any>\n\t)[]", "childBase: Omit<ChildStore, `transactionMeta`>", "transactionMeta: TransactionProgress<Fn>", "child: ChildStore", "newTransaction: Transaction<F>", "atom", "selector", "timeline", "IMPLICIT: { readonly STORE: RootStore }", "withdrawn: AtomIOInternalResource | undefined", "target: Store | null", "val: E | T", "def: E | T", "MUST_CREATE: unique symbol", "DO_NOT_CREATE: unique symbol", "token: ReadableToken<T, KK, E>", "existingToken: ReadableToken<T, K, E> | undefined", "brandNewToken: ReadableToken<T, K, E> | undefined", "family: ReadableFamily<T, K, E> | undefined", "subKey: K | undefined", "token: ReadableToken<T, K, E>", "subType: `readable` | `writable`", "stateCreationEvent: StateCreationEvent<any>", "state: ReadableState<any, any> | undefined", "family: FamilyMetadata<Key>", "individualOptions: ReadonlyPureSelectorOptions<T, E>", "readonlySelectorFamily: ReadonlyPureSelectorFamily<T, K, E>", "familyToken: RegularAtomFamilyToken<T, K, E>", "individualOptions: RegularAtomOptions<T, E>", "atomFamily: RegularAtomFamily<T, K, E>", "atomFamily", "family: FamilyMetadata", "readonlySelectorFamily: ReadonlyHeldSelectorFamily<T, K>", "selectorFamily: WritableHeldSelectorFamily<T, K>", "selectorFamily", "individualOptions: WritablePureSelectorOptions<T, E>", "selectorFamily: WritablePureSelectorFamily<T, K, E>", "token: ReadableToken<any, any, any>", "stateCreationEvent: StateCreationEvent<any> & TimelineEvent<any>", "update: StateUpdate<T>", "atomUpdate: AtomUpdateEvent<any>", "atom", "protoUpdate: ProtoUpdate<E | T>", "RESET_STATE: unique symbol", "selector", "oldValue: T", "newValue: T", "constant: T", "protoUpdate: ProtoUpdate<T>", "OWN_OP: unique symbol", "JOIN_OP: unique symbol", "existingToken: WritableToken<T, K, E> | undefined", "brandNewToken: WritableToken<T, K, E> | undefined", "token: WritableToken<T, K, E>", "family: WritableFamily<T, K, E> | undefined", "key: K | null", "value: Setter<TT> | TT | typeof RESET_STATE", "target: Store & { operation: OpenOperation }", "dependencyValue: unknown", "readonlySelector: ReadonlyHeldSelector<T>", "token: ReadonlyHeldSelectorToken<T>", "readonlySelector: ReadonlyPureSelector<T, E>", "token: ReadonlyPureSelectorToken<T>", "mySelector: WritableHeldSelector<T>", "token: WritableHeldSelectorToken<T>", "mySelector: WritablePureSelector<T, E>", "token: WritablePureSelectorToken<T>", "state", "familyToken: SelectorFamilyToken<any, any, any>", "unsubscribe", "updateHandler: UpdateHandler<E | T>", "familyMetaData: FamilyMetadata | undefined", "newAtom: MutableAtom<T>", "cleanupFunctions: (() => void)[]", "familyToken: MutableAtomFamilyToken<T & Transceiver<any, any, any>, K>", "individualOptions: MutableAtomOptions<T>", "atomFamily: MutableAtomFamily<T, K>", "mutableAtomFamily", "updateToken: RegularAtomToken<SignalFrom<T>>", "mutableAtom", "selector", "atom", "newAtom: RegularAtom<T, E>", "cleanupFunctions: (() => void)[]", "atom", "disposalEvent: AtomDisposalEvent<AtomToken<any, any, any>>", "aSide: AName", "bSide: BName", "replaceRelationsSafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t>", "previousOwnersToDispose: string[]", "previousOwnerSize: number | undefined", "relations", "replaceRelationsUnsafely: Write<\n\t\t\t(a: string, newRelationsOfA: string[]) => void\n\t\t>", "relations: JoinStates<AName, A, BName, B, Cardinality>", "tl: Timeline<ManagedAtom>", "atomToken: AtomToken<any, any, any>", "familyToken: AtomFamilyToken<any, any, any>", "token: TimelineToken<ManagedAtom>", "atomUpdate: AtomUpdateEvent<any> & TimelineEvent<any>", "latestUpdate: TimelineEvent<any> | undefined", "selectorUpdate: TimelineEvent<any> & TimelineSelectorUpdateEvent<any>", "key: string", "familyKey: string | undefined", "events: TimelineEvent<any>[]", "PRETTY_TOKEN_TYPES: Record<TokenDenomination, string>", "simpleLogger: Logger", "$validatedKey: unique symbol", "timeline"]
|
|
7
|
-
}
|