@uniweb/core 0.14.0 → 0.14.1

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/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": "./src/index.js",
8
8
  "./base-path": "./src/base-path.js",
9
- "./collection-address": "./src/collection-address.js",
9
+ "./collection-address": "./src/query-address.js",
10
+ "./query-address": "./src/query-address.js",
10
11
  "./data-paths": "./src/data-paths.js",
11
12
  "./detail-url": "./src/detail-url.js",
12
13
  "./fetch-config": "./src/fetch-config.js",
@@ -41,8 +42,8 @@
41
42
  "vitest": "^4.1.7"
42
43
  },
43
44
  "dependencies": {
44
- "@uniweb/semantic-parser": "^1.3.1",
45
- "@uniweb/theming": "^0.1.15"
45
+ "@uniweb/theming": "^0.1.15",
46
+ "@uniweb/semantic-parser": "^1.3.1"
46
47
  },
47
48
  "scripts": {
48
49
  "test": "vitest run"
package/src/datastore.js CHANGED
@@ -62,7 +62,7 @@ export default class DataStore {
62
62
  *
63
63
  * Two forms:
64
64
  * - `subscribe(fn)` — fires after every successful `set()` (all keys).
65
- * - `subscribe(key, fn)` — fires only when `set(key, ...)` is called.
65
+ * - `subscribe(key, fn)` — fires only when `set(key, ...)` or `delete(key)` is called.
66
66
  *
67
67
  * The global form is useful for debugging / blanket observers. The keyed
68
68
  * form is what Layer-3 kit hooks (`useFetched`, `useCacheEntry`) use so
@@ -131,6 +131,29 @@ export default class DataStore {
131
131
  }
132
132
  }
133
133
 
134
+ /**
135
+ * Drop one entry, and any in-flight record for the same key.
136
+ *
137
+ * Fires the key's subscribers (and the global ones) so an observer re-reads
138
+ * and sees the absence, exactly as it would see a write. Exists for the case
139
+ * `clear()` is too blunt for: one consumer's entries must leave memory — a
140
+ * viewer's records at sign-out — while everything else stays warm.
141
+ *
142
+ * @param {string} key
143
+ * @returns {boolean} true if an entry was removed
144
+ */
145
+ delete(key) {
146
+ const had = this._cache.delete(key)
147
+ this._inflight.delete(key)
148
+ if (!had) return false
149
+ for (const fn of this._listeners) fn()
150
+ const keyed = this._keyedListeners.get(key)
151
+ if (keyed) {
152
+ for (const fn of keyed) fn()
153
+ }
154
+ return true
155
+ }
156
+
134
157
  /**
135
158
  * In-flight fetch registry — used by the dispatcher to dedup concurrent
136
159
  * requests and collect abort signals so the underlying fetch is cancelled
package/src/uniweb.js CHANGED
@@ -88,6 +88,15 @@ export default class Uniweb {
88
88
  // `defaultInsets` above.
89
89
  this.tracking = new Tracker()
90
90
 
91
+ // Reserved for `@uniweb/api` — the one client instance per page. That
92
+ // package is bundled into each foundation, so a page with a primary
93
+ // foundation and extensions holds several copies of its code; the first to
94
+ // need a client creates one and parks it here, and every other copy adopts
95
+ // it instead of creating another. Core implements nothing on it: declared
96
+ // null so the seal permits the assignment, nothing more. Same pattern as
97
+ // `defaultInsets` above.
98
+ this.api = null
99
+
91
100
  Object.seal(this)
92
101
  }
93
102