@symbiotejs/symbiote 3.3.2 → 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 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
- window.addEventListener(this.routingEventName, (/** @type {CustomEvent} */ e) => {
348
- routingCtx.multiPub({
349
- options: e.detail.options,
350
- title: e.detail.options?.title || this.defaultTitle || '',
351
- route: e.detail.route,
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
- AppRouter.notify();
355
- this.#initPopstateListener();
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/Symbiote.js CHANGED
@@ -146,7 +146,9 @@ export class Symbiote extends HTMLElement {
146
146
 
147
147
  if (this.#super.shadowStyleSheets) {
148
148
  shadow = true; // is needed for cases when Shadow DOM was created manually for some other purposes
149
- this.shadowRoot.adoptedStyleSheets = [...this.#super.shadowStyleSheets];
149
+ if (!clientSSR) {
150
+ this.shadowRoot.adoptedStyleSheets = [...this.#super.shadowStyleSheets];
151
+ }
150
152
  }
151
153
  addFr();
152
154
  }
@@ -466,14 +468,18 @@ export class Symbiote extends HTMLElement {
466
468
  this.#initCallback();
467
469
  } else {
468
470
  if (this.#super.rootStyleSheets) {
469
- /** @type {Document | ShadowRoot} */
470
- // @ts-expect-error
471
- let root = this.getRootNode();
472
- if (!root) {
473
- return;
471
+ // Skip adopted sheets when hydrating SSR (inline <style> tags already present):
472
+ let hydrating = this.ssrMode || (this.isoMode && this.childNodes.length > 0);
473
+ if (!hydrating) {
474
+ /** @type {Document | ShadowRoot} */
475
+ // @ts-expect-error
476
+ let root = this.getRootNode();
477
+ if (!root) {
478
+ return;
479
+ }
480
+ let styleSet = new Set([...root.adoptedStyleSheets, ...this.#super.rootStyleSheets]);
481
+ root.adoptedStyleSheets = [...styleSet];
474
482
  }
475
- let styleSet = new Set([...root.adoptedStyleSheets, ...this.#super.rootStyleSheets]);
476
- root.adoptedStyleSheets = [...styleSet];
477
483
  }
478
484
  this.render();
479
485
  }
package/core/full.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default, Symbiote, html, css, PubSub, DICT, animateOut } from './index.js';
2
+ export { AppRouter } from './AppRouter.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@symbiotejs/symbiote",
4
- "version": "3.3.2",
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"
@@ -29,6 +29,10 @@ async function run() {
29
29
  './utils': {
30
30
  default: './utils/index.js',
31
31
  },
32
+ './full': {
33
+ types: './types/core/full.d.ts',
34
+ default: './core/full.js',
35
+ },
32
36
  './node': {
33
37
  default: './node/index.js',
34
38
  },
@@ -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,+BAqEC;IAMD;;aAuCC;IAMD;;aAGC;IAQD;;;;;aA7RW;;;;;QAAa,IAAI,KACf,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,GA0R1D,MAAM,IAAI,CAUtB;IAGD,wCAGC;IAGD,+BAEC;IAOD;;;;;;mBAtUY,MAAM,OAAO,CAAC,GAAC,CAAC;;;oBA0V3B;IAED,kDAQC;IAED,sCAGC;CACF;;mBApXkB,aAAa"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"Symbiote.d.ts","sourceRoot":"","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AAI,wBAmB/B;IAGD,2BAGC;IAGD,uBAGC;IAQD,IALuB,CAAC,SAAX,MAAO,CAAE,qBAEX,CAAC,CAAC,CAAC,CAAC,2BAMd;IAMD,UAHW,OAAO,CAAC,CAAC,CAAC,2BAOpB;IAGD,SADc,CAAC,CA2Bd;IAMD,YAHW,OAAO,CAAC,CAAC,CAAC,mCAcpB;IAED,8BAgBC;IAdG,4CASE;IAwFF,0BAAwC;IAwB1C,uBAAyB;IAG3B,0BAEC;IAED,wBAAoB;IAUpB,yBAAuB;IACvB,6BA0BC;IA6CD,oEAeC;IAMD,yDAiBC;IAYD,0BAME;IAMF,0CAFW,GAAG,QAab;IAED,yBAGC;IAOD,8EAmBC;;CA+BF;;mBAtsBkB,aAAa;qBACX,iBAAiB;2BACX,iBAAiB"}
@@ -0,0 +1,3 @@
1
+ export { AppRouter } from "./AppRouter.js";
2
+ export { default, Symbiote, html, css, PubSub, DICT, animateOut } from "./index.js";
3
+ //# sourceMappingURL=full.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"full.d.ts","sourceRoot":"","sources":["../../core/full.js"],"names":[],"mappings":""}