@symbiotejs/symbiote 3.3.3 → 3.3.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/CHANGELOG.md +18 -0
- package/core/AppRouter.js +17 -8
- package/core/PubSub.js +1 -1
- package/core/full.js +2 -0
- package/package.json +9 -1
- package/scripts/update-exports.js +4 -0
- package/types/core/AppRouter.d.ts.map +1 -1
- package/types/core/full.d.ts +3 -0
- package/types/core/full.d.ts.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.3.4
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **PubSub context isolation with importmaps.**
|
|
8
|
+
`PubSub.globalStore` now uses `globalThis.__SYMBIOTE_PUBSUB_STORE`, so multiple copies of PubSub loaded from different URLs (e.g. via importmap) share the same context registry. Fixes `Router/title` and similar named context bindings not working when AppRouter is resolved separately.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`@symbiotejs/symbiote/full` entry point.**
|
|
13
|
+
Re-exports everything from the main entry point plus `AppRouter`, guaranteeing a single PubSub module:
|
|
14
|
+
```js
|
|
15
|
+
import Symbiote, { html, css, AppRouter } from '@symbiotejs/symbiote/full';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **AppRouter SSR support.**
|
|
19
|
+
`AppRouter.initRoutingCtx()` now works in Node.js and linkedom SSR environments — creates the PubSub context without errors, skipping browser-only APIs (`window`, `history`, events). Enables isomorphic code that uses AppRouter on both server and client.
|
|
20
|
+
|
|
3
21
|
## 3.3.0
|
|
4
22
|
|
|
5
23
|
### Added
|
package/core/AppRouter.js
CHANGED
|
@@ -44,6 +44,10 @@ export class AppRouter {
|
|
|
44
44
|
/** @type {Array<{regex: RegExp, keys: string[], route: string}>} */
|
|
45
45
|
static #compiledPatterns = [];
|
|
46
46
|
|
|
47
|
+
static get #isBrowser() {
|
|
48
|
+
return typeof window !== 'undefined' && !globalThis.__SYMBIOTE_SSR;
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
static #print(msg) {
|
|
48
52
|
console.warn(`[Symbiote > AppRouter] ${msg}`);
|
|
49
53
|
}
|
|
@@ -178,6 +182,7 @@ export class AppRouter {
|
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
static async notify() {
|
|
185
|
+
if (!this.#isBrowser) return;
|
|
181
186
|
let routeBase = this.readAddressBar();
|
|
182
187
|
let routeScheme = this.appMap[routeBase.route];
|
|
183
188
|
|
|
@@ -253,6 +258,7 @@ export class AppRouter {
|
|
|
253
258
|
* @param {Object<string, any>} [options]
|
|
254
259
|
*/
|
|
255
260
|
static reflect(route, options = {}) {
|
|
261
|
+
if (!this.#isBrowser) return;
|
|
256
262
|
let routeScheme = this.appMap[route];
|
|
257
263
|
if (!routeScheme) {
|
|
258
264
|
this.#print('Wrong route: ' + route);
|
|
@@ -344,15 +350,17 @@ export class AppRouter {
|
|
|
344
350
|
},
|
|
345
351
|
ctxName
|
|
346
352
|
);
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
353
|
+
if (this.#isBrowser) {
|
|
354
|
+
window.addEventListener(this.routingEventName, (/** @type {CustomEvent} */ e) => {
|
|
355
|
+
routingCtx.multiPub({
|
|
356
|
+
options: e.detail.options,
|
|
357
|
+
title: e.detail.options?.title || this.defaultTitle || '',
|
|
358
|
+
route: e.detail.route,
|
|
359
|
+
});
|
|
352
360
|
});
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
361
|
+
AppRouter.notify();
|
|
362
|
+
this.#initPopstateListener();
|
|
363
|
+
}
|
|
356
364
|
return routingCtx;
|
|
357
365
|
}
|
|
358
366
|
|
|
@@ -367,6 +375,7 @@ export class AppRouter {
|
|
|
367
375
|
}
|
|
368
376
|
|
|
369
377
|
static removePopstateListener() {
|
|
378
|
+
if (!this.#isBrowser) return;
|
|
370
379
|
window.removeEventListener('popstate', this.#onPopstate);
|
|
371
380
|
this.#onPopstate = null;
|
|
372
381
|
}
|
package/core/PubSub.js
CHANGED
|
@@ -389,7 +389,7 @@ export class PubSub {
|
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
/** @type {Map<String | Symbol, PubSub>} */
|
|
392
|
-
PubSub.globalStore = new Map();
|
|
392
|
+
PubSub.globalStore = globalThis.__SYMBIOTE_PUBSUB_STORE || (globalThis.__SYMBIOTE_PUBSUB_STORE = new Map());
|
|
393
393
|
|
|
394
394
|
/** @type {Boolean} */
|
|
395
395
|
PubSub.devMode = false;
|
package/core/full.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@symbiotejs/symbiote",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.4",
|
|
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",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"./utils": {
|
|
37
37
|
"default": "./utils/index.js"
|
|
38
38
|
},
|
|
39
|
+
"./full": {
|
|
40
|
+
"types": "./types/core/full.d.ts",
|
|
41
|
+
"default": "./core/full.js"
|
|
42
|
+
},
|
|
39
43
|
"./node": {
|
|
40
44
|
"default": "./node/index.js"
|
|
41
45
|
},
|
|
@@ -63,6 +67,10 @@
|
|
|
63
67
|
"types": "./types/core/dictionary.d.ts",
|
|
64
68
|
"default": "./core/dictionary.js"
|
|
65
69
|
},
|
|
70
|
+
"./core/full.js": {
|
|
71
|
+
"types": "./types/core/full.d.ts",
|
|
72
|
+
"default": "./core/full.js"
|
|
73
|
+
},
|
|
66
74
|
"./core/html.js": {
|
|
67
75
|
"types": "./types/core/html.d.ts",
|
|
68
76
|
"default": "./core/html.js"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouter.d.ts","sourceRoot":"","sources":["../../core/AppRouter.js"],"names":[],"mappings":"AAEA;IA4BE,iCADW,MAAM,IAAI,CACF;IAEnB,uCAAkB;IAElB,8CAAyB;IAEzB;;;;;;mBA1BY,MAAM,OAAO,CAAC,GAAC,CAAC;;;MA0BQ;IAEpC,6BADW;;;;;aAZA;;;;;QAAa,IAAI,KACf,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,GAWhD,CACH;IAEpB,mCADW;;;;;QAAa,IAAI,CACA;IAE5B,kCADW,OAAO,CACU;IAE5B,uCADW,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,CAClC;IAE9B,2CAEC;IAGD,4CAEC;IAGD;;aAgBC;IAMD,6CAuBC;IAGD,0CAGC;IAGD,sCAEC;IAED;;;MAKC;IAED;;;MAiBC;IAED;;;MAwBC;IAMD;;;;;QAFa,OAAO,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAS5C;IAED,+
|
|
1
|
+
{"version":3,"file":"AppRouter.d.ts","sourceRoot":"","sources":["../../core/AppRouter.js"],"names":[],"mappings":"AAEA;IA4BE,iCADW,MAAM,IAAI,CACF;IAEnB,uCAAkB;IAElB,8CAAyB;IAEzB;;;;;;mBA1BY,MAAM,OAAO,CAAC,GAAC,CAAC;;;MA0BQ;IAEpC,6BADW;;;;;aAZA;;;;;QAAa,IAAI,KACf,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,GAWhD,CACH;IAEpB,mCADW;;;;;QAAa,IAAI,CACA;IAE5B,kCADW,OAAO,CACU;IAE5B,uCADW,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,CAClC;IAE9B,8CAEC;IAED,2CAEC;IAGD,4CAEC;IAGD;;aAgBC;IAMD,6CAuBC;IAGD,0CAGC;IAGD,sCAEC;IAED;;;MAKC;IAED;;;MAiBC;IAED;;;MAwBC;IAMD;;;;;QAFa,OAAO,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAS5C;IAED,+BAsEC;IAMD;;aAwCC;IAMD;;aAGC;IAQD;;;;;aAnSW;;;;;QAAa,IAAI,KACf,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,GAgS1D,MAAM,IAAI,CAUtB;IAGD,wCAGC;IAGD,+BAEC;IAOD;;;;;;mBA5UY,MAAM,OAAO,CAAC,GAAC,CAAC;;;oBAkW3B;IAED,kDAQC;IAED,sCAIC;CACF;;mBA7XkB,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"full.d.ts","sourceRoot":"","sources":["../../core/full.js"],"names":[],"mappings":""}
|