@symbiotejs/symbiote 3.3.3 → 3.3.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/CHANGELOG.md +25 -0
- package/core/AppRouter.js +23 -7
- 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,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.3.5
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **AppRouter: SSR context populated with default route.**
|
|
8
|
+
`initRoutingCtx()` in SSR now populates the PubSub context with the default route's `route`, `title`, and `options` instead of leaving them as `null`. Components can access `this.$['R/route']` during server rendering.
|
|
9
|
+
|
|
10
|
+
## 3.3.4
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **PubSub context isolation with importmaps.**
|
|
15
|
+
`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.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`@symbiotejs/symbiote/full` entry point.**
|
|
20
|
+
Re-exports everything from the main entry point plus `AppRouter`, guaranteeing a single PubSub module:
|
|
21
|
+
```js
|
|
22
|
+
import Symbiote, { html, css, AppRouter } from '@symbiotejs/symbiote/full';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- **AppRouter SSR support.**
|
|
26
|
+
`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.
|
|
27
|
+
|
|
3
28
|
## 3.3.0
|
|
4
29
|
|
|
5
30
|
### 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,24 @@ export class AppRouter {
|
|
|
344
350
|
},
|
|
345
351
|
ctxName
|
|
346
352
|
);
|
|
347
|
-
|
|
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
|
+
});
|
|
360
|
+
});
|
|
361
|
+
AppRouter.notify();
|
|
362
|
+
this.#initPopstateListener();
|
|
363
|
+
} else if (this.defaultRoute) {
|
|
364
|
+
let defaultDesc = this.appMap[this.defaultRoute];
|
|
348
365
|
routingCtx.multiPub({
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
366
|
+
route: this.defaultRoute,
|
|
367
|
+
options: {},
|
|
368
|
+
title: defaultDesc?.title || this.defaultTitle || '',
|
|
352
369
|
});
|
|
353
|
-
}
|
|
354
|
-
AppRouter.notify();
|
|
355
|
-
this.#initPopstateListener();
|
|
370
|
+
}
|
|
356
371
|
return routingCtx;
|
|
357
372
|
}
|
|
358
373
|
|
|
@@ -367,6 +382,7 @@ export class AppRouter {
|
|
|
367
382
|
}
|
|
368
383
|
|
|
369
384
|
static removePopstateListener() {
|
|
385
|
+
if (!this.#isBrowser) return;
|
|
370
386
|
window.removeEventListener('popstate', this.#onPopstate);
|
|
371
387
|
this.#onPopstate = null;
|
|
372
388
|
}
|
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.5",
|
|
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;;;oBAyW3B;IAED,kDAQC;IAED,sCAIC;CACF;;mBApYkB,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"full.d.ts","sourceRoot":"","sources":["../../core/full.js"],"names":[],"mappings":""}
|