@everystate/core 1.0.3 → 1.0.4

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 CHANGED
@@ -37,6 +37,59 @@ store.subscribe('user.*', ({ path, value }) => {
37
37
  unsub();
38
38
  ```
39
39
 
40
+ ## Self-test (CLI, opt-in)
41
+
42
+ Run the bundled **zero-dependency** self-test locally to verify core behavior.
43
+ It is **opt-in** and never runs automatically on install:
44
+
45
+ ```bash
46
+ # via npx (no install needed)
47
+ npx everystate-self-test
48
+
49
+ # if installed locally
50
+ everystate-self-test
51
+
52
+ # or directly
53
+ node node_modules/@everystate/core/self-test.js
54
+ ```
55
+
56
+ You can also run the npm script from the package folder:
57
+
58
+ ```bash
59
+ npm --prefix node_modules/@everystate/core run self-test
60
+ ```
61
+
62
+ ### Integration tests (@everystate/test)
63
+
64
+ The `tests/` folder contains a separate integration suite that uses
65
+ `@everystate/test` (not zero-dep). This is an intentional tradeoff:
66
+ the **self-test** stays lightweight, while integration tests remain available
67
+ for deeper validation.
68
+
69
+ Run the integration suite (opt-in):
70
+
71
+ ```bash
72
+ npm install @everystate/test
73
+ node node_modules/@everystate/core/tests/core.test.js
74
+ ```
75
+
76
+ Short form (from the package folder):
77
+
78
+ ```bash
79
+ cd node_modules/@everystate/core
80
+ npm run test:integration
81
+ # or short alias
82
+ npm run test:i
83
+ ```
84
+
85
+ Or, from your project root:
86
+
87
+ ```bash
88
+ npm --prefix node_modules/@everystate/core run test:integration
89
+ # or short alias
90
+ npm --prefix node_modules/@everystate/core run test:i
91
+ ```
92
+
40
93
  ## What is EveryState?
41
94
 
42
95
  EveryState is a reactive state management library where:
@@ -64,15 +117,6 @@ EveryState makes state **addressable, observable, and testable** without special
64
117
 
65
118
  ## Ecosystem
66
119
 
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
120
  | Package | Description | License |
77
121
  |---|---|---|
78
122
  | [@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",
3
+ "version": "1.0.4",
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,7 @@
37
43
  "*.d.ts",
38
44
  "*.md",
39
45
  "*.html",
46
+ "cli.js",
40
47
  "tests/"
41
48
  ]
42
49
  }
@@ -1,17 +1,17 @@
1
1
  /**
2
- * @everystate/core eventTest-based integration tests
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/event-test';
9
+ import { createEventTest, runTests } from '@everystate/test';
10
10
  import { createEveryState } from '@everystate/core';
11
11
 
12
12
  const results = runTests({
13
13
 
14
- // ── batch ─────────────────────────────────────────────────────────
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
- // ── setMany ───────────────────────────────────────────────────────
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
- // ── setAsync ──────────────────────────────────────────────────────
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
- // ── destroy ───────────────────────────────────────────────────────
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
- // ── core regression ───────────────────────────────────────────────
197
+ // -- core regression -----------------------------------------------
198
198
 
199
199
  'core: basic get/set/subscribe': () => {
200
200
  const t = createEventTest({ name: 'Alice' });