genesys-spark 4.264.2 → 4.265.0

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/README.md CHANGED
@@ -50,6 +50,55 @@ that you link stylesheets to load the Urbanist and Noto Sans fonts in your docum
50
50
  prior to starting your app. This will improve loading performance and prevent a
51
51
  jarring font transition when the required fonts load.
52
52
 
53
+ ### Unit testing with Jest and jsdom
54
+
55
+ If you render Spark components in a jsdom test environment, add
56
+ `genesys-spark/dist/testing.cjs` to your Jest `setupFiles`:
57
+
58
+ ```js
59
+ // jest.config.js
60
+ module.exports = {
61
+ testEnvironment: 'jsdom',
62
+ setupFiles: ['genesys-spark/dist/testing.cjs']
63
+ };
64
+ ```
65
+
66
+ Without it, your suites use far more memory than they need to, and large suites
67
+ can exhaust Node's heap.
68
+
69
+ Spark shares a single ~400KB global stylesheet across every shadow root, using one
70
+ constructable `CSSStyleSheet`. jsdom does not implement `adoptedStyleSheets`, so
71
+ Stencil cannot detect support for that API and falls back to injecting a `<style>`
72
+ element into every shadow root. jsdom then re-parses those 400KB once per Spark
73
+ element. This entry point fills in the missing APIs so Spark stays on the shared
74
+ stylesheet path.
75
+
76
+ Use `setupFiles` rather than `setupFilesAfterEnv`. Stencil runs its detection when
77
+ its runtime is first evaluated, so the shim has to be in place before your
78
+ components are imported.
79
+
80
+ If you use a custom Jest environment, import the function and apply it to that
81
+ environment's global instead:
82
+
83
+ ```js
84
+ const {
85
+ shimConstructableStyleSheets
86
+ } = require('genesys-spark/dist/testing.cjs');
87
+
88
+ class MyEnvironment extends JSDOMEnvironment {
89
+ constructor(config, context) {
90
+ super(config, context);
91
+ shimConstructableStyleSheets(this.global);
92
+ }
93
+ }
94
+ ```
95
+
96
+ The shim fills in each API only when it is missing, so it does nothing in a real
97
+ browser and will retire itself if jsdom implements `adoptedStyleSheets`. The
98
+ stylesheet text is never applied, because jsdom does not implement the shadow DOM
99
+ cascade. That is equally true of the `<style>` element it replaces, so this costs
100
+ no style fidelity.
101
+
53
102
  ## Asset loading details
54
103
 
55
104
  By adding a script tag to the document, we ensure that the components are always
package/dist/index.js CHANGED
@@ -230,8 +230,8 @@ var sparkIntl = /*#__PURE__*/Object.freeze({
230
230
  relativeTimeFormat: relativeTimeFormat
231
231
  });
232
232
 
233
- const COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.264.2-1115/genesys-webcomponents/";
234
- const CHART_COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.264.2-1115/chart/genesys-chart-webcomponents/";
233
+ const COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.265.0-1116/genesys-webcomponents/";
234
+ const CHART_COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.265.0-1116/chart/genesys-chart-webcomponents/";
235
235
  function loadSparkFonts(opts) {
236
236
  const fontOrigin = getFontOrigin();
237
237
  const flareFonts = {
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ const adoptedStyleSheetsByHost = /* @__PURE__ */ new WeakMap();
4
+ function getAdoptedStyleSheets(host) {
5
+ let sheets = adoptedStyleSheetsByHost.get(host);
6
+ if (!sheets) {
7
+ sheets = [];
8
+ adoptedStyleSheetsByHost.set(host, sheets);
9
+ }
10
+ return sheets;
11
+ }
12
+ const adoptedStyleSheetsDescriptor = {
13
+ configurable: true,
14
+ get() {
15
+ return getAdoptedStyleSheets(this);
16
+ },
17
+ set(sheets) {
18
+ adoptedStyleSheetsByHost.set(this, Array.from(sheets));
19
+ }
20
+ };
21
+ function shimConstructableStyleSheets(globalObject) {
22
+ if (!globalObject) {
23
+ return false;
24
+ }
25
+ const { CSSStyleSheet, ShadowRoot, document } = globalObject;
26
+ if (!CSSStyleSheet || !ShadowRoot || !document) {
27
+ return false;
28
+ }
29
+ if (typeof CSSStyleSheet.prototype.replaceSync !== "function") {
30
+ CSSStyleSheet.prototype.replaceSync = function replaceSync() {
31
+ };
32
+ }
33
+ if (!ShadowRoot.prototype.adoptedStyleSheets) {
34
+ Object.defineProperty(
35
+ ShadowRoot.prototype,
36
+ "adoptedStyleSheets",
37
+ adoptedStyleSheetsDescriptor
38
+ );
39
+ }
40
+ if (!document.adoptedStyleSheets) {
41
+ Object.defineProperty(
42
+ document,
43
+ "adoptedStyleSheets",
44
+ adoptedStyleSheetsDescriptor
45
+ );
46
+ }
47
+ return true;
48
+ }
49
+ shimConstructableStyleSheets(globalThis);
50
+
51
+ exports.shimConstructableStyleSheets = shimConstructableStyleSheets;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Test-environment shim that lets Stencil detect constructable stylesheet
3
+ * support under jsdom.
4
+ *
5
+ * Spark shares one ~400KB global stylesheet across every shadow root through a
6
+ * single constructable `CSSStyleSheet`. When Stencil cannot detect support for
7
+ * that API it falls back to injecting a `<style>` element into *every* shadow
8
+ * root, so jsdom re-parses those 400KB once per Spark element. That is enough to
9
+ * take a moderate test suite past Node's 4GB heap limit.
10
+ *
11
+ * Stencil's detection needs two things: a truthy `document.adoptedStyleSheets`,
12
+ * and a `CSSStyleSheet` that is constructable and has `replaceSync`. Once it
13
+ * detects support it also reads and writes `adoptedStyleSheets` on each shadow
14
+ * root, so that needs to exist too. jsdom supplies only the bare `CSSStyleSheet`
15
+ * constructor, so Stencil takes the fallback. Supplying all three missing pieces
16
+ * keeps Spark on the shared-stylesheet path.
17
+ *
18
+ * Neither upgrading Spark nor upgrading jsdom removes the need for this. jsdom
19
+ * has never shipped `adoptedStyleSheets` (see
20
+ * https://github.com/jsdom/jsdom/issues/3998, which recommends this same
21
+ * approach). Each piece is filled in only when it is missing, so the shim
22
+ * retires itself if jsdom ever implements the API.
23
+ *
24
+ * The stylesheet text is never applied, because jsdom does not implement the
25
+ * shadow DOM cascade. That is equally true of the `<style>` element the fallback
26
+ * injects, so this costs no style fidelity.
27
+ *
28
+ * See COMUI-5120.
29
+ */
30
+ /**
31
+ * Fills in the constructable stylesheet APIs that jsdom is missing.
32
+ *
33
+ * Importing this module applies the shim to `globalThis`, which is all a Jest
34
+ * `setupFiles` entry needs. Call this directly only if you patch a different
35
+ * global, for example from a custom Jest environment.
36
+ *
37
+ * @param globalObject the environment to patch, normally `globalThis`
38
+ * @returns true when the environment is a DOM the shim can support
39
+ */
40
+ declare function shimConstructableStyleSheets(globalObject: unknown): boolean;
41
+
42
+ export { shimConstructableStyleSheets };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genesys-spark",
3
- "version": "4.264.2",
3
+ "version": "4.265.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -45,24 +45,24 @@
45
45
  "@tsconfig/strictest": "^2.0.8",
46
46
  "dir-compare": "^5.0.0",
47
47
  "esbuild": "^0.28.2",
48
- "eslint": "^10.8.1",
48
+ "eslint": "^10.10.0",
49
49
  "glob": "^13.0.6",
50
- "globals": "^17.11.0",
51
- "jest": "^30.4.2",
52
- "jest-environment-jsdom": "^30.4.1",
50
+ "globals": "^17.12.0",
51
+ "jest": "^30.5.1",
52
+ "jest-environment-jsdom": "^30.5.1",
53
53
  "npm-run-all": "^4.1.5",
54
54
  "prettier-package-json": "^2.8.0",
55
- "rollup": "^4.62.4",
55
+ "rollup": "^4.63.3",
56
56
  "rollup-plugin-dts": "^6.5.1",
57
57
  "rollup-plugin-esbuild": "^6.2.1",
58
58
  "sass": "^1.101.0",
59
59
  "smob": "^1.6.2",
60
- "stylelint": "^17.14.1",
60
+ "stylelint": "^17.15.0",
61
61
  "stylelint-config-html": "^2.0.0",
62
62
  "stylelint-config-recess-order": "^7.8.0",
63
63
  "stylelint-config-standard": "^40.0.0",
64
64
  "stylelint-order": "^8.1.1",
65
- "stylelint-scss": "^7.2.0",
65
+ "stylelint-scss": "^7.3.0",
66
66
  "ts-jest": "^29.4.12"
67
67
  }
68
68
  }