@symbiotejs/symbiote 3.4.4 → 3.4.6
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/CHANGELOG.md +7 -0
- package/core/PubSub.js +30 -4
- package/core/Symbiote.js +12 -3
- package/package.json +1 -1
- package/types/core/PubSub.d.ts +1 -0
- package/types/core/PubSub.d.ts.map +1 -1
- package/types/core/Symbiote.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.4.6
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **PubSub: computed properties with cross-context deps no longer depend on import order.** When a computed property declared `deps: ['CTX/prop']` and the target context wasn't registered yet, the subscription was silently skipped. Now deferred deps are stored in `PubSub.pendingDeps` and automatically resolved when `registerCtx()` is called.
|
|
8
|
+
- **Symbiote: named context access no longer crashes when context is not yet registered.** The `$` proxy, `sub()`, `notify()`, `has()`, and `add()` now handle missing named contexts gracefully (return `undefined`/no-op instead of throwing).
|
|
9
|
+
|
|
3
10
|
## 3.4.4
|
|
4
11
|
|
|
5
12
|
### Fixed
|
package/core/PubSub.js
CHANGED
|
@@ -120,10 +120,24 @@ export class PubSub {
|
|
|
120
120
|
let extCtx = PubSub.getCtx(ctxName, false);
|
|
121
121
|
|
|
122
122
|
if (!extCtx) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
// Defer: will resolve when the context is registered
|
|
124
|
+
if (!PubSub.pendingDeps.has(ctxName)) {
|
|
125
|
+
PubSub.pendingDeps.set(ctxName, []);
|
|
126
|
+
}
|
|
127
|
+
PubSub.pendingDeps.get(ctxName).push(() => {
|
|
128
|
+
let resolvedCtx = PubSub.getCtx(ctxName, false);
|
|
129
|
+
if (!resolvedCtx) return;
|
|
130
|
+
let sub = resolvedCtx.sub(propName, () => {
|
|
131
|
+
this.#recalcComputed(compProp);
|
|
132
|
+
}, false);
|
|
133
|
+
if (sub) {
|
|
134
|
+
if (!this.#externalSubs[compProp]) {
|
|
135
|
+
this.#externalSubs[compProp] = [];
|
|
136
|
+
}
|
|
137
|
+
this.#externalSubs[compProp].push(sub);
|
|
138
|
+
}
|
|
139
|
+
this.#recalcComputed(compProp);
|
|
140
|
+
});
|
|
127
141
|
continue;
|
|
128
142
|
}
|
|
129
143
|
|
|
@@ -366,6 +380,15 @@ export class PubSub {
|
|
|
366
380
|
data = new PubSub(schema);
|
|
367
381
|
data.uid = uid;
|
|
368
382
|
PubSub.globalStore.set(uid, data);
|
|
383
|
+
|
|
384
|
+
// Resolve deferred external deps waiting for this context:
|
|
385
|
+
let pending = PubSub.pendingDeps.get(uid);
|
|
386
|
+
if (pending) {
|
|
387
|
+
PubSub.pendingDeps.delete(uid);
|
|
388
|
+
for (let resolve of pending) {
|
|
389
|
+
resolve();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
369
392
|
}
|
|
370
393
|
return data;
|
|
371
394
|
}
|
|
@@ -391,6 +414,9 @@ export class PubSub {
|
|
|
391
414
|
/** @type {Map<String | Symbol, PubSub>} */
|
|
392
415
|
PubSub.globalStore = globalThis.__SYMBIOTE_PUBSUB_STORE || (globalThis.__SYMBIOTE_PUBSUB_STORE = new Map());
|
|
393
416
|
|
|
417
|
+
/** @type {Map<String | Symbol, Array<Function>>} */
|
|
418
|
+
PubSub.pendingDeps = new Map();
|
|
419
|
+
|
|
394
420
|
/** @type {Boolean} */
|
|
395
421
|
PubSub.devMode = false;
|
|
396
422
|
|
package/core/Symbiote.js
CHANGED
|
@@ -247,7 +247,10 @@ export class Symbiote extends HTMLElement {
|
|
|
247
247
|
ctx = found?.localCtx || fnCtx.localCtx;
|
|
248
248
|
} else if (prop.includes('/')) {
|
|
249
249
|
let slashIdx = prop.indexOf('/');
|
|
250
|
-
ctx = PubSub.getCtx(prop.slice(0, slashIdx));
|
|
250
|
+
ctx = PubSub.getCtx(prop.slice(0, slashIdx), false);
|
|
251
|
+
if (!ctx) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
251
254
|
name = prop.slice(slashIdx + 1);
|
|
252
255
|
} else if (first === 45 && prop.charCodeAt(1) === 45) {
|
|
253
256
|
ctx = fnCtx.localCtx;
|
|
@@ -276,6 +279,7 @@ export class Symbiote extends HTMLElement {
|
|
|
276
279
|
handler(val);
|
|
277
280
|
};
|
|
278
281
|
let parsed = Symbiote.#parseProp(/** @type {string} */ (prop), this);
|
|
282
|
+
if (!parsed) return;
|
|
279
283
|
if (!parsed.ctx.has(parsed.name)) {
|
|
280
284
|
// Avoid *prop binding race:
|
|
281
285
|
window.queueMicrotask(() => {
|
|
@@ -289,12 +293,14 @@ export class Symbiote extends HTMLElement {
|
|
|
289
293
|
/** @param {String} prop */
|
|
290
294
|
notify(prop) {
|
|
291
295
|
let parsed = Symbiote.#parseProp(prop, this);
|
|
296
|
+
if (!parsed) return;
|
|
292
297
|
parsed.ctx.notify(parsed.name);
|
|
293
298
|
}
|
|
294
299
|
|
|
295
300
|
/** @param {String} prop */
|
|
296
301
|
has(prop) {
|
|
297
302
|
let parsed = Symbiote.#parseProp(prop, this);
|
|
303
|
+
if (!parsed) return false;
|
|
298
304
|
return parsed.ctx.has(parsed.name);
|
|
299
305
|
}
|
|
300
306
|
|
|
@@ -306,6 +312,7 @@ export class Symbiote extends HTMLElement {
|
|
|
306
312
|
*/
|
|
307
313
|
add(prop, val, rewrite = false) {
|
|
308
314
|
let parsed = Symbiote.#parseProp(prop, this);
|
|
315
|
+
if (!parsed) return;
|
|
309
316
|
parsed.ctx.add(parsed.name, val, rewrite);
|
|
310
317
|
}
|
|
311
318
|
|
|
@@ -330,8 +337,9 @@ export class Symbiote extends HTMLElement {
|
|
|
330
337
|
if (first !== 42 && first !== 94 && first !== 64 && first !== 43 && first !== 45 && !prop.includes('/')) {
|
|
331
338
|
this.localCtx.pub(prop, val);
|
|
332
339
|
} else {
|
|
333
|
-
|
|
334
|
-
|
|
340
|
+
let parsed = Symbiote.#parseProp(prop, this);
|
|
341
|
+
if (!parsed) return true;
|
|
342
|
+
parsed.ctx.pub(parsed.name, val);
|
|
335
343
|
}
|
|
336
344
|
return true;
|
|
337
345
|
},
|
|
@@ -341,6 +349,7 @@ export class Symbiote extends HTMLElement {
|
|
|
341
349
|
return this.localCtx.read(prop);
|
|
342
350
|
}
|
|
343
351
|
let parsed = Symbiote.#parseProp(prop, this);
|
|
352
|
+
if (!parsed) return undefined;
|
|
344
353
|
return parsed.ctx.read(parsed.name);
|
|
345
354
|
},
|
|
346
355
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@symbiotejs/symbiote",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.6",
|
|
5
5
|
"description": "Symbiote.js - zero-dependency close-to-platform frontend library to build super-powered web components",
|
|
6
6
|
"author": "team@rnd-pro.com",
|
|
7
7
|
"license": "MIT",
|
package/types/core/PubSub.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSub.d.ts","sourceRoot":"","sources":["../../core/PubSub.js"],"names":[],"mappings":"AAgBA,oBADwC,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE;IA2DrC,oDAFW,GAAC,kBAKX;
|
|
1
|
+
{"version":3,"file":"PubSub.d.ts","sourceRoot":"","sources":["../../core/PubSub.js"],"names":[],"mappings":"AAgBA,oBADwC,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE;IA2DrC,oDAFW,GAAC,kBAKX;IAwSD,mBALuC,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,UAC3B,CAAC,QACD,SAAS,MAAM,GACb,MAAM,CAAC,CAAC,CAAC,CAsBrB;IAGD,sBADY,SAAS,MAAM,QAG1B;IAOD,mBAJW,SAAS,MAAM,iCASzB;IAhWD,oBADY,CAAC,EAWZ;IARG,WAA6B;IAO/B,aADW,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAChB;IAsIxC,WADY,MAAM,CAAC,OAqClB;IAzBK,sBAAuB;IA4B7B,uBAEC;IAOD,uBAHW,OAAO,2BASjB;IAMD,UAHW,MAAM,CAAC,OACP,OAAO,QAqBjB;IAGD,aADc,CAAC,CAed;IAGD,iBADY,CAAC,QAKZ;IAGD,aADY,MAAM,CAAC,kBAoBlB;IAOD,UAJW,MAAM,CAAC,YACP,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI;;wBAAhB,OAAO,KAAK,IAAI;MAwBhC;IAKD,aAFW,SAAS,MAAM,EAIzB;IAED,WANW,SAAS,MAAM,CAQzB;;CA8CF;;qBAEU,GAAG,CAAC,SAAS,MAAM,cAAS;qBAG5B,GAAG,CAAC,SAAS,MAAM,EAAE,KAAK,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Symbiote.d.ts","sourceRoot":"","sources":["../../core/Symbiote.js"],"names":[],"mappings":";;AAmBA,sBADc,CAAC;IAuBb,cADW,mBAAmB,CACjB;IAGb,sCAAwB;IAExB,iCAGC;IAED,8BAEC;IAkBD,wBAAgB;IA0JhB,+BAJwB,CAAC,SAAZ,aAAU,uBAEZ,CAAC;;;
|
|
1
|
+
{"version":3,"file":"Symbiote.d.ts","sourceRoot":"","sources":["../../core/Symbiote.js"],"names":[],"mappings":";;AAmBA,sBADc,CAAC;IAuBb,cADW,mBAAmB,CACjB;IAGb,sCAAwB;IAExB,iCAGC;IAED,8BAEC;IAkBD,wBAAgB;IA0JhB,+BAJwB,CAAC,SAAZ,aAAU,uBAEZ,CAAC;;;MA0CX;IAyPD,qCAA+B;IAoC/B,iDAFa,OAAO,QAAQ,CAqB3B;IAED,wBAKC;IAGD;;aAOC;IAsHD,6BADY,SAA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