@everystate/core 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -10
- package/cli.js +40 -0
- package/package.json +13 -3
- package/tests/core.test.js +7 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @everystate/core
|
|
1
|
+
# @everystate/core v1.0.5
|
|
2
2
|
|
|
3
3
|
**EveryState: Observable state management with dot-path addressing**
|
|
4
4
|
|
|
@@ -10,6 +10,8 @@ Every piece of state has a name. Every name is subscribable. Every operation is
|
|
|
10
10
|
npm install @everystate/core
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
> **Zero external dependencies** - Pure state management with no third-party packages required.
|
|
14
|
+
|
|
13
15
|
## Quick Start
|
|
14
16
|
|
|
15
17
|
```js
|
|
@@ -37,6 +39,66 @@ store.subscribe('user.*', ({ path, value }) => {
|
|
|
37
39
|
unsub();
|
|
38
40
|
```
|
|
39
41
|
|
|
42
|
+
## Self-test (CLI, opt-in)
|
|
43
|
+
|
|
44
|
+
Run the bundled **zero-dependency** self-test locally to verify core behavior.
|
|
45
|
+
It is **opt-in** and never runs automatically on install:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# via npx (no install needed)
|
|
49
|
+
npx everystate-self-test
|
|
50
|
+
|
|
51
|
+
# if installed locally
|
|
52
|
+
everystate-self-test
|
|
53
|
+
|
|
54
|
+
# or directly
|
|
55
|
+
node node_modules/@everystate/core/self-test.js
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You can also run the npm script from the package folder:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm --prefix node_modules/@everystate/core run self-test
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Integration tests (@everystate/test)
|
|
65
|
+
|
|
66
|
+
The `tests/` folder contains a separate integration suite that uses
|
|
67
|
+
`@everystate/test` (declared as `devDependency`). This is an intentional
|
|
68
|
+
tradeoff: the **self-test** stays lightweight, while integration tests
|
|
69
|
+
remain available for deeper validation.
|
|
70
|
+
|
|
71
|
+
**For end users** (after installing the package):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Install test dependency
|
|
75
|
+
npm install @everystate/test
|
|
76
|
+
|
|
77
|
+
# Run from package folder
|
|
78
|
+
cd node_modules/@everystate/core
|
|
79
|
+
npm run test:integration
|
|
80
|
+
# or short alias
|
|
81
|
+
npm run test:i
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or, from your project root:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm --prefix node_modules/@everystate/core run test:integration
|
|
88
|
+
# or short alias
|
|
89
|
+
npm --prefix node_modules/@everystate/core run test:i
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**For package developers** (working in the source repo):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Install dev dependencies first
|
|
96
|
+
npm install
|
|
97
|
+
|
|
98
|
+
# Run integration tests
|
|
99
|
+
npm run test:integration
|
|
100
|
+
```
|
|
101
|
+
|
|
40
102
|
## What is EveryState?
|
|
41
103
|
|
|
42
104
|
EveryState is a reactive state management library where:
|
|
@@ -64,15 +126,6 @@ EveryState makes state **addressable, observable, and testable** without special
|
|
|
64
126
|
|
|
65
127
|
## Ecosystem
|
|
66
128
|
|
|
67
|
-
- `@everystate/core`: Core state engine (you are here)
|
|
68
|
-
- `@everystate/css`: Reactive styling and design tokens
|
|
69
|
-
- `@everystate/perf`: Performance monitoring overlay
|
|
70
|
-
- `@everystate/react`: React hooks adapter
|
|
71
|
-
- `@everystate/router`: SPA routing as state
|
|
72
|
-
- `@everystate/test`: Zero-dependency testing
|
|
73
|
-
- `@everystate/view`: DOM-as-state with surgical updates
|
|
74
|
-
|
|
75
|
-
|
|
76
129
|
| Package | Description | License |
|
|
77
130
|
|---|---|---|
|
|
78
131
|
| [@everystate/aliases](https://www.npmjs.com/package/@everystate/aliases) | Ergonomic single-character and short-name DOM aliases for vanilla JS | MIT |
|
package/cli.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @everystate/core CLI (opt-in)
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npx everystate-self-test
|
|
8
|
+
* everystate-self-test
|
|
9
|
+
* everystate-self-test --self-test
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
const wantsHelp = args.includes('-h') || args.includes('--help');
|
|
14
|
+
const wantsSelfTest =
|
|
15
|
+
args.length === 0 ||
|
|
16
|
+
args.includes('self-test') ||
|
|
17
|
+
args.includes('--self-test') ||
|
|
18
|
+
args.includes('test') ||
|
|
19
|
+
args.includes('--test');
|
|
20
|
+
|
|
21
|
+
if (wantsHelp) {
|
|
22
|
+
console.log(`@everystate/core self-test (opt-in)\n\nUsage:\n everystate-self-test [--self-test]\n\nNotes:\n - This command is opt-in and never runs automatically.\n - It runs a zero-dependency self-test bundled with the package.\n\nFlags:\n --self-test Run the bundled self-test (default)\n -h, --help Show this help message\n`);
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!wantsSelfTest) {
|
|
27
|
+
console.error('Unknown arguments. Run with --help for usage.');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
(async () => {
|
|
32
|
+
try {
|
|
33
|
+
console.log('@everystate/core: running opt-in self-test...');
|
|
34
|
+
await import('./self-test.js');
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Self-test failed to run.');
|
|
37
|
+
console.error(error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everystate/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "EveryState: Lightweight event-driven state management with path-based subscriptions, wildcards, and async support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"everystate-self-test": "cli.js"
|
|
10
|
+
},
|
|
8
11
|
"scripts": {
|
|
9
|
-
"test": "node self-test.js"
|
|
12
|
+
"test": "node self-test.js",
|
|
13
|
+
"self-test": "node self-test.js",
|
|
14
|
+
"test:integration": "node tests/core.test.js",
|
|
15
|
+
"test:i": "node tests/core.test.js"
|
|
10
16
|
},
|
|
11
17
|
"keywords": [
|
|
12
18
|
"everystate",
|
|
@@ -37,6 +43,10 @@
|
|
|
37
43
|
"*.d.ts",
|
|
38
44
|
"*.md",
|
|
39
45
|
"*.html",
|
|
46
|
+
"cli.js",
|
|
40
47
|
"tests/"
|
|
41
|
-
]
|
|
48
|
+
],
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@everystate/test": "^1.0.0"
|
|
51
|
+
}
|
|
42
52
|
}
|
package/tests/core.test.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @everystate/core
|
|
2
|
+
* @everystate/core - eventTest-based integration tests
|
|
3
3
|
*
|
|
4
4
|
* Merged from test-batch.js and test-batch-dogfood.js.
|
|
5
5
|
* Tests batch, setMany, setAsync, destroy, and core regression tests
|
|
6
6
|
* using @everystate/event-test.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { createEventTest, runTests } from '@everystate/
|
|
9
|
+
import { createEventTest, runTests } from '@everystate/test';
|
|
10
10
|
import { createEveryState } from '@everystate/core';
|
|
11
11
|
|
|
12
12
|
const results = runTests({
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// -- batch ---------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
'batch: coalesces — same-path deduplication': () => {
|
|
17
17
|
const t = createEventTest({ count: 0 });
|
|
@@ -80,7 +80,7 @@ const results = runTests({
|
|
|
80
80
|
store.destroy();
|
|
81
81
|
},
|
|
82
82
|
|
|
83
|
-
//
|
|
83
|
+
// -- setMany -------------------------------------------------------
|
|
84
84
|
|
|
85
85
|
'setMany: plain object': () => {
|
|
86
86
|
const t = createEventTest({});
|
|
@@ -116,7 +116,7 @@ const results = runTests({
|
|
|
116
116
|
t.assertPath('x.z', 'world');
|
|
117
117
|
},
|
|
118
118
|
|
|
119
|
-
//
|
|
119
|
+
// -- setAsync ------------------------------------------------------
|
|
120
120
|
|
|
121
121
|
'setAsync: batches loading phase writes': () => {
|
|
122
122
|
const store = createEveryState({});
|
|
@@ -176,7 +176,7 @@ const results = runTests({
|
|
|
176
176
|
store.destroy();
|
|
177
177
|
},
|
|
178
178
|
|
|
179
|
-
//
|
|
179
|
+
// -- destroy -------------------------------------------------------
|
|
180
180
|
|
|
181
181
|
'destroy: batch throws after destroy': () => {
|
|
182
182
|
const store = createEveryState({ z: 0 });
|
|
@@ -194,7 +194,7 @@ const results = runTests({
|
|
|
194
194
|
if (!threw) throw new Error('setMany() should throw after destroy');
|
|
195
195
|
},
|
|
196
196
|
|
|
197
|
-
//
|
|
197
|
+
// -- core regression -----------------------------------------------
|
|
198
198
|
|
|
199
199
|
'core: basic get/set/subscribe': () => {
|
|
200
200
|
const t = createEventTest({ name: 'Alice' });
|