Comparing version 0.8.3 to 0.9.0
@@ -94,3 +94,3 @@ 'use strict'; | ||
store.config.logger = __spreadValues({}, console); | ||
LOG_LEVELS.forEach((logLevel) => { | ||
for (const logLevel of LOG_LEVELS) { | ||
if (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) { | ||
@@ -101,3 +101,3 @@ store.config.logger[logLevel] = NO_OP; | ||
} | ||
}); | ||
} | ||
} | ||
@@ -104,0 +104,0 @@ }; |
@@ -121,19 +121,18 @@ import type { | ||
} | ||
for (const [, atom] of store.atoms) { | ||
atom.install(this) | ||
} | ||
for (const [, selector] of store.readonlySelectors) { | ||
selector.install(this) | ||
} | ||
for (const [, selector] of store.selectors) { | ||
selector.install(this) | ||
} | ||
for (const [, tx] of store.transactions) { | ||
tx.install(this) | ||
} | ||
for (const [, timeline] of store.timelines) { | ||
timeline.install(this) | ||
} | ||
} | ||
store?.atoms.forEach((atom) => { | ||
atom.install(this) | ||
}) | ||
store?.readonlySelectors.forEach((selector) => { | ||
selector.install(this) | ||
}) | ||
store?.selectors.forEach((selector) => { | ||
selector.install(this) | ||
}) | ||
store?.transactions.forEach((tx) => { | ||
tx.install(this) | ||
}) | ||
store?.timelines.forEach((timeline) => { | ||
timeline.install(this) | ||
}) | ||
} | ||
@@ -140,0 +139,0 @@ } |
{ | ||
"name": "atom.io", | ||
"version": "0.8.3", | ||
"description": "Reactive state graph for React, Preact, and vanilla", | ||
"version": "0.9.0", | ||
"description": "Composable and testable reactive data library.", | ||
"homepage": "https://atom.io.fyi", | ||
"sideEffects": false, | ||
"license": "MIT", | ||
"author": "Jeremy Banka", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jeremybanka/wayforge.git", | ||
"directory": "packages/atom.io" | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
@@ -40,14 +53,16 @@ "@floating-ui/react": ">=0.25.0", | ||
"@testing-library/react": "14.0.0", | ||
"@types/mock-fs": "4.13.2", | ||
"@types/react": "18.2.28", | ||
"@types/tmp": "0.2.4", | ||
"@types/mock-fs": "4.13.3", | ||
"@types/npmlog": "4.1.5", | ||
"@types/react": "18.2.31", | ||
"@types/tmp": "0.2.5", | ||
"@vitest/coverage-v8": "0.34.6", | ||
"concurrently": "8.2.1", | ||
"eslint": "8.51.0", | ||
"concurrently": "8.2.2", | ||
"eslint": "8.52.0", | ||
"framer-motion": "10.16.4", | ||
"happy-dom": "12.9.1", | ||
"npmlog": "7.0.1", | ||
"preact": "10.18.1", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"react-router-dom": "6.16.0", | ||
"react-router-dom": "6.17.0", | ||
"socket.io": "4.7.2", | ||
@@ -68,2 +83,5 @@ "socket.io-client": "4.7.2", | ||
"src", | ||
"data/dist", | ||
"data/package.json", | ||
"data/src", | ||
"internal/dist", | ||
@@ -108,2 +126,9 @@ "internal/package.json", | ||
}, | ||
"./data/package.json": "./data/package.json", | ||
"./data": { | ||
"types": "./data/dist/index.d.ts", | ||
"browser": "./data/dist/index.mjs", | ||
"import": "./data/dist/index.mjs", | ||
"require": "./data/dist/index.js" | ||
}, | ||
"./internal/package.json": "./internal/package.json", | ||
@@ -180,15 +205,7 @@ "./internal": { | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jeremybanka/wayforge.git" | ||
}, | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"author": "Jeremy Banka", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"integrity": "tsx __scripts__/integrity-build.node", | ||
"build": "concurrently \"npm:build:*\"", | ||
"build:main": "tsup", | ||
"build:data": "cd data && tsup", | ||
"build:internal": "cd internal && tsup", | ||
@@ -208,4 +225,5 @@ "build:introspection": "cd introspection && tsup", | ||
"test": "vitest", | ||
"test:once": "cross-env IMPORT=dist vitest run" | ||
"test:once": "npm run test:integrity && cross-env IMPORT=dist vitest run", | ||
"test:integrity": "tsx __scripts__/integrity-test.node" | ||
} | ||
} |
@@ -274,11 +274,11 @@ import * as atom_io from 'atom.io'; | ||
leafDiffers: { | ||
[K in keyof Leaf]: Diff<Supported<Leaf[K]>>; | ||
[KL in keyof Leaf]: Diff<Supported<Leaf[KL]>>; | ||
}; | ||
treeDiffers: { | ||
[K in keyof Tree]: DiffTree<Supported<Tree[K]>>; | ||
[KT in keyof Tree]: DiffTree<Supported<Tree[KT]>>; | ||
}; | ||
constructor(leafRefinery: Refinery<Leaf>, treeRefinery: Refinery<Tree>, diffFunctions: { | ||
[K in keyof Tree]: DiffTree<Supported<Tree[K]>>; | ||
[KT in keyof Tree]: DiffTree<Supported<Tree[KT]>>; | ||
} & { | ||
[K in keyof Leaf]: Diff<Supported<Leaf[K]>>; | ||
[KL in keyof Leaf]: Diff<Supported<Leaf[KL]>>; | ||
}); | ||
@@ -285,0 +285,0 @@ diff(a: unknown, b: unknown): Delta; |
@@ -1,9 +0,39 @@ | ||
<hr> | ||
<div align="center"> | ||
<img alt="corners logo" src="https://raw.githubusercontent.com/jeremybanka/wayforge/main/packages/atom.io/assets/logo.png"/> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jeremybanka/wayforge/main/packages/atom.io/__assets__/logo-dark-mode.png"> | ||
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/jeremybanka/wayforge/main/packages/atom.io/__assets__/logo-light-mode.png"> | ||
<img alt="Banner text reading 'atom.io'" src="https://raw.githubusercontent.com/jeremybanka/wayforge/main/packages/atom.io/__assets__/logo-light-mode.png" style="max-width: 100%;"> | ||
</picture> | ||
</div> | ||
<br> | ||
<h1 align="center"> | ||
atom.io | ||
</h1> | ||
<h3 align="center"> | ||
Composable, high-performance reactivity for ECMAScript inspired by <a href="https://recoiljs.org/">Recoil</a> 💙 | ||
</h3> | ||
<h3 align="center"> | ||
<a href="https://atom.io.fyi">📖 Read the docs at atom.io.fyi</a> | ||
</h3> | ||
```shell | ||
npm i atom.io | ||
``` | ||
```shell | ||
pnpm i atom.io | ||
``` | ||
```shell | ||
bun i atom.io | ||
``` | ||
<p align="center"> | ||
@@ -24,29 +54,4 @@ <a href="https://bundlephobia.com/result?p=atom.io"> | ||
```shell | ||
npm i atom.io | ||
``` | ||
```shell | ||
pnpm i atom.io | ||
``` | ||
```shell | ||
bun i atom.io | ||
``` | ||
<hr> | ||
Fine-grained reactivity for JavaScript environments. | ||
💙 Inspired by [Recoil](https://recoiljs.org/). | ||
# Usage | ||
```typescript | ||
import { atom } from 'atom.io' | ||
const countState = atom({ | ||
key: 'count', | ||
default: 0 | ||
}) | ||
// { key: 'count', type: 'atom' } | ||
``` |
@@ -64,3 +64,5 @@ 'use strict'; | ||
const fillFamilyUnsubRequest = () => { | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()); | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub(); | ||
} | ||
unsubFamilyCallbacksByKey.clear(); | ||
@@ -78,6 +80,6 @@ socket.off(`unsub:${family.key}`, fillFamilyUnsubRequest); | ||
const fillSubRequest = (subKey) => { | ||
var _a; | ||
if (subKey === void 0) { | ||
const keys = AtomIO4__namespace.getState(index, store); | ||
keys.forEach((key) => { | ||
var _a; | ||
for (const key of keys) { | ||
const token = family(key); | ||
@@ -89,3 +91,3 @@ socket.emit( | ||
); | ||
}); | ||
} | ||
const unsubscribeFromTokenCreation = subscribeToTokenCreation( | ||
@@ -98,6 +100,6 @@ family, | ||
({ newValue }) => { | ||
var _a; | ||
var _a2; | ||
socket.emit( | ||
`serve:${family.key}`, | ||
json.parseJson(((_a = token.family) == null ? void 0 : _a.subKey) || `null`), | ||
json.parseJson(((_a2 = token.family) == null ? void 0 : _a2.subKey) || `null`), | ||
newValue | ||
@@ -134,4 +136,8 @@ ); | ||
socket.off(`sub:${family.key}`, fillSubRequest); | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()); | ||
unsubSingleCallbacksByKey.forEach((unsub) => unsub()); | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub(); | ||
} | ||
for (const [, unsub] of unsubSingleCallbacksByKey) { | ||
unsub(); | ||
} | ||
unsubFamilyCallbacksByKey.clear(); | ||
@@ -176,3 +182,5 @@ unsubSingleCallbacksByKey.clear(); | ||
const fillFamilyUnsubRequest = () => { | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()); | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub(); | ||
} | ||
unsubFamilyCallbacksByKey.clear(); | ||
@@ -190,6 +198,6 @@ socket.off(`unsub:${family.key}`, fillFamilyUnsubRequest); | ||
const fillSubRequest = (subKey) => { | ||
var _a; | ||
if (subKey === void 0) { | ||
const keys = AtomIO4__namespace.getState(index, store); | ||
keys.forEach((key) => { | ||
var _a; | ||
for (const key of keys) { | ||
const token = family(key); | ||
@@ -217,7 +225,7 @@ const jsonToken = internal.getJsonToken(token); | ||
unsubFamilyCallbacksByKey.set(token.key, unsubFromUpdates); | ||
}); | ||
} | ||
const unsubscribeFromTokenCreation = family.subject.subscribe( | ||
`expose-family:${socket.id}`, | ||
(token) => { | ||
var _a; | ||
var _a2; | ||
const jsonToken = internal.getJsonToken(token); | ||
@@ -227,3 +235,3 @@ const trackerToken = internal.getUpdateToken(token); | ||
`init:${family.key}`, | ||
json.parseJson(((_a = jsonToken.family) == null ? void 0 : _a.subKey) || `null`), | ||
json.parseJson(((_a2 = jsonToken.family) == null ? void 0 : _a2.subKey) || `null`), | ||
AtomIO4__namespace.getState(jsonToken, store) | ||
@@ -234,6 +242,6 @@ ); | ||
({ newValue }) => { | ||
var _a2; | ||
var _a3; | ||
socket.emit( | ||
`next:${token.key}`, | ||
json.parseJson(((_a2 = jsonToken.family) == null ? void 0 : _a2.subKey) || `null`), | ||
json.parseJson(((_a3 = jsonToken.family) == null ? void 0 : _a3.subKey) || `null`), | ||
newValue | ||
@@ -272,4 +280,8 @@ ); | ||
socket.off(`sub:${family.key}`, fillSubRequest); | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()); | ||
unsubSingleCallbacksByKey.forEach((unsub) => unsub()); | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub(); | ||
} | ||
for (const [, unsub] of unsubSingleCallbacksByKey) { | ||
unsub(); | ||
} | ||
unsubFamilyCallbacksByKey.clear(); | ||
@@ -276,0 +288,0 @@ unsubSingleCallbacksByKey.clear(); |
@@ -29,3 +29,5 @@ import * as AtomIO from "atom.io" | ||
const fillFamilyUnsubRequest = () => { | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()) | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub() | ||
} | ||
unsubFamilyCallbacksByKey.clear() | ||
@@ -47,3 +49,3 @@ socket.off(`unsub:${family.key}`, fillFamilyUnsubRequest) | ||
const keys = AtomIO.getState(index, store) | ||
keys.forEach((key) => { | ||
for (const key of keys) { | ||
const token = family(key) | ||
@@ -55,3 +57,3 @@ socket.emit( | ||
) | ||
}) | ||
} | ||
@@ -102,4 +104,8 @@ const unsubscribeFromTokenCreation = subscribeToTokenCreation( | ||
socket.off(`sub:${family.key}`, fillSubRequest) | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()) | ||
unsubSingleCallbacksByKey.forEach((unsub) => unsub()) | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub() | ||
} | ||
for (const [, unsub] of unsubSingleCallbacksByKey) { | ||
unsub() | ||
} | ||
unsubFamilyCallbacksByKey.clear() | ||
@@ -106,0 +112,0 @@ unsubSingleCallbacksByKey.clear() |
@@ -29,3 +29,5 @@ import * as AtomIO from "atom.io" | ||
const fillFamilyUnsubRequest = () => { | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()) | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub() | ||
} | ||
unsubFamilyCallbacksByKey.clear() | ||
@@ -47,3 +49,3 @@ socket.off(`unsub:${family.key}`, fillFamilyUnsubRequest) | ||
const keys = AtomIO.getState(index, store) | ||
keys.forEach((key) => { | ||
for (const key of keys) { | ||
const token = family(key) | ||
@@ -70,3 +72,3 @@ const jsonToken = getJsonToken(token) | ||
unsubFamilyCallbacksByKey.set(token.key, unsubFromUpdates) | ||
}) | ||
} | ||
const unsubscribeFromTokenCreation = family.subject.subscribe( | ||
@@ -124,4 +126,8 @@ `expose-family:${socket.id}`, | ||
socket.off(`sub:${family.key}`, fillSubRequest) | ||
unsubFamilyCallbacksByKey.forEach((unsub) => unsub()) | ||
unsubSingleCallbacksByKey.forEach((unsub) => unsub()) | ||
for (const [, unsub] of unsubFamilyCallbacksByKey) { | ||
unsub() | ||
} | ||
for (const [, unsub] of unsubSingleCallbacksByKey) { | ||
unsub() | ||
} | ||
unsubFamilyCallbacksByKey.clear() | ||
@@ -128,0 +134,0 @@ unsubSingleCallbacksByKey.clear() |
@@ -127,5 +127,10 @@ 'use strict'; | ||
const clients = recordToEntries(options.clients).reduce( | ||
(clients2, [name, client]) => __spreadProps(__spreadValues({}, clients2), { | ||
[name]: setupRealtimeTestClient(__spreadProps(__spreadValues({}, options), { client }), name, server.port) | ||
}), | ||
(clients2, [name, client]) => { | ||
clients2[name] = setupRealtimeTestClient( | ||
__spreadProps(__spreadValues({}, options), { client }), | ||
name, | ||
server.port | ||
); | ||
return clients2; | ||
}, | ||
{} | ||
@@ -137,3 +142,5 @@ ); | ||
teardown: () => { | ||
recordToEntries(clients).forEach(([, client]) => client.dispose()); | ||
for (const [, client] of recordToEntries(clients)) { | ||
client.dispose(); | ||
} | ||
server.dispose(); | ||
@@ -140,0 +147,0 @@ } |
@@ -22,3 +22,3 @@ import { IMPLICIT } from "atom.io/internal" | ||
store.config.logger = { ...console } | ||
LOG_LEVELS.forEach((logLevel) => { | ||
for (const logLevel of LOG_LEVELS) { | ||
if (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) { | ||
@@ -31,3 +31,3 @@ // biome-ignore lint/style/noNonNullAssertion: we just set it | ||
} | ||
}) | ||
} | ||
} | ||
@@ -34,0 +34,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1709083
214
18893
1
57
24