genesys-spark 4.26.0 → 4.26.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Genesys Cloud Services, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,50 @@
1
+ declare function dateTimeFormat(localeOrOptions: string | Intl.DateTimeFormatOptions, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
2
+ /**
3
+ * Provides an [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
4
+ * object for formatting dates and times. Unlike the native version, `locale` is
5
+ * an optional argument. If not provided, the function will try to determine the
6
+ * locale from the DOM, where it should be set for a11y reasons.
7
+ * @param locale optional locale to use for formatting
8
+ * @param options options to pass to the Intl.RelativeTimeFormat constructor
9
+ * @returns a new RelativeTimeFormat
10
+ */
11
+ declare function relativeTimeFormat(localeOrOptions: string | Intl.RelativeTimeFormatOptions, options?: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
12
+ /**
13
+ * Makes a best effort to return the locale that should be used for a given element
14
+ * by checking language tags on ancestors. If no element is provided, it will
15
+ * start with the document's <body> tag. If no locale can be found, it will use
16
+ * the browser's locale preference. It will also try to add a region to regionless
17
+ * locales when there is a partial match with the browser's locale.
18
+ * @returns a locale string (e.g. 'en-US', 'en', 'de-DE', etc)
19
+ */
20
+ declare function determineDisplayLocale(element?: HTMLElement): string;
21
+ declare function getFormat(locale: string): string;
22
+
23
+ declare const intl_dateTimeFormat: typeof dateTimeFormat;
24
+ declare const intl_determineDisplayLocale: typeof determineDisplayLocale;
25
+ declare const intl_getFormat: typeof getFormat;
26
+ declare const intl_relativeTimeFormat: typeof relativeTimeFormat;
27
+ declare namespace intl {
28
+ export { intl_dateTimeFormat as dateTimeFormat, intl_determineDisplayLocale as determineDisplayLocale, intl_getFormat as getFormat, intl_relativeTimeFormat as relativeTimeFormat };
29
+ }
30
+
31
+ /**
32
+ * TODO
33
+ */
34
+ declare function loadSparkFonts(): Promise<void>;
35
+ /**
36
+ * Loads the spark web components, as well as required CSS and fonts from a
37
+ * shared CDN. Performance can be optimized by pre-loading fonts in static HTML.
38
+ *
39
+ * @returns a promise that succeeds if the component script and styles
40
+ * load successfully. It is not recommended to wait on this promise or to stop
41
+ * application bootstrap if it rejects. Its primary use should be for logging
42
+ * unexpected failures.
43
+ */
44
+ declare function registerSparkComponents(): Promise<void>;
45
+ /**
46
+ * TODO
47
+ */
48
+ declare function registerSparkChartComponents(): Promise<void>;
49
+
50
+ export { intl as Intl, loadSparkFonts, registerSparkChartComponents, registerSparkComponents };
package/dist/index.js CHANGED
@@ -1,348 +1,236 @@
1
- // Default domain to load assets from
2
- var DEFAULT_DOMAIN = 'mypurecloud.com';
3
- // List of Genesys UI domains that do not follow the ${region}.pure.cloud format
4
- var NON_STANDARD_DOMAINS = [
5
- 'inindca.com',
6
- 'inintca.com',
7
- 'mypurecloud.com.au',
8
- 'mypurecloud.com',
9
- 'mypurecloud.de',
10
- 'mypurecloud.ie',
11
- 'mypurecloud.jp'
12
- // 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP. It should fall back to the default domain.
1
+ const DEFAULT_DOMAIN = "mypurecloud.com";
2
+ const NON_STANDARD_DOMAINS = [
3
+ "inindca.com",
4
+ "inintca.com",
5
+ "mypurecloud.com.au",
6
+ "mypurecloud.com",
7
+ "mypurecloud.de",
8
+ "mypurecloud.ie",
9
+ "mypurecloud.jp"
10
+ // 'use2.us-gov-pure.cloud', Assets are not currently deployed to FedRAMP. It should fall back to the default domain.
13
11
  ];
14
- /**
15
- * Returns the origin that web component assets should be loaded from.
16
- * Will use the domain of the current window if it matches a Genesys domain.
17
- */
18
12
  function getComponentAssetsOrigin() {
19
- return getAssetsOrigin();
13
+ return getAssetsOrigin();
20
14
  }
21
15
  function getChartComponentAssetsOrigin() {
22
- return getAssetsOrigin();
16
+ return getAssetsOrigin();
23
17
  }
24
18
  function getAssetsOrigin() {
25
- var matchedDomain = getRegionDomain();
26
- return "https://app.".concat(matchedDomain || DEFAULT_DOMAIN);
19
+ const matchedDomain = getRegionDomain();
20
+ return `https://app.${matchedDomain || DEFAULT_DOMAIN}`;
27
21
  }
28
22
  function getFontOrigin() {
29
- return getComponentAssetsOrigin();
23
+ return getComponentAssetsOrigin();
30
24
  }
31
25
  function getRegionDomain() {
32
- var pageHost = window.location.hostname;
33
- // We can automatically handle the standard domain format: ${region}.pure.cloud
34
- if (pageHost.endsWith('.pure.cloud')) {
35
- return pageHost.split('.').slice(-3).join('.');
36
- }
37
- // For older domains, we have to do a lookup
38
- return NON_STANDARD_DOMAINS.find(function (regionDomain) {
39
- return pageHost.endsWith(regionDomain);
40
- });
26
+ const pageHost = window.location.hostname;
27
+ if (pageHost.endsWith(".pure.cloud")) {
28
+ return pageHost.split(".").slice(-3).join(".");
29
+ }
30
+ return NON_STANDARD_DOMAINS.find(
31
+ (regionDomain) => pageHost.endsWith(regionDomain)
32
+ );
41
33
  }
42
34
 
43
- /******************************************************************************
44
- Copyright (c) Microsoft Corporation.
45
-
46
- Permission to use, copy, modify, and/or distribute this software for any
47
- purpose with or without fee is hereby granted.
48
-
49
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
50
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
51
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
52
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
53
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
54
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
55
- PERFORMANCE OF THIS SOFTWARE.
56
- ***************************************************************************** */
57
- /* global Reflect, Promise, SuppressedError, Symbol */
58
-
59
-
60
- var __assign = function() {
61
- __assign = Object.assign || function __assign(t) {
62
- for (var s, i = 1, n = arguments.length; i < n; i++) {
63
- s = arguments[i];
64
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
65
- }
66
- return t;
67
- };
68
- return __assign.apply(this, arguments);
69
- };
70
-
71
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
72
- var e = new Error(message);
73
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
35
+ var __defProp = Object.defineProperty;
36
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
37
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
38
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
39
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
40
+ var __spreadValues = (a, b) => {
41
+ for (var prop in b || (b = {}))
42
+ if (__hasOwnProp.call(b, prop))
43
+ __defNormalProp(a, prop, b[prop]);
44
+ if (__getOwnPropSymbols)
45
+ for (var prop of __getOwnPropSymbols(b)) {
46
+ if (__propIsEnum.call(b, prop))
47
+ __defNormalProp(a, prop, b[prop]);
48
+ }
49
+ return a;
74
50
  };
75
-
76
- /**
77
- * Add a script tag to the document if it is not already present.
78
- * @param scriptSrc The src attribute of the script
79
- * @returns a promise that resolves if the script loads or is already present
80
- */
81
51
  function checkAndLoadScript(scriptSrc) {
82
- var existingTag = document.querySelector("script[src=\"".concat(scriptSrc, "\"]"));
83
- if (existingTag) {
84
- return Promise.resolve();
85
- }
86
- else {
87
- var scriptTag_1 = document.createElement('script');
88
- scriptTag_1.setAttribute('type', 'module');
89
- scriptTag_1.setAttribute('src', scriptSrc);
90
- var result = new Promise(function (resolve, reject) {
91
- scriptTag_1.addEventListener('load', function () {
92
- resolve();
93
- });
94
- scriptTag_1.addEventListener('error', function () {
95
- reject("Spark script failed to load: ".concat(scriptSrc));
96
- });
97
- });
98
- document.head.appendChild(scriptTag_1);
99
- return result;
100
- }
52
+ const existingTag = document.querySelector(`script[src="${scriptSrc}"]`);
53
+ if (existingTag) {
54
+ return Promise.resolve();
55
+ } else {
56
+ const scriptTag = document.createElement("script");
57
+ scriptTag.setAttribute("type", "module");
58
+ scriptTag.setAttribute("src", scriptSrc);
59
+ const result = new Promise((resolve, reject) => {
60
+ scriptTag.addEventListener("load", () => {
61
+ resolve();
62
+ });
63
+ scriptTag.addEventListener("error", () => {
64
+ reject(`Spark script failed to load: ${scriptSrc}`);
65
+ });
66
+ });
67
+ document.head.appendChild(scriptTag);
68
+ return result;
69
+ }
101
70
  }
102
- /**
103
- * Add a stylesheet link tag to the document if it is not already present.
104
- * @param styleHref The href attribute of the stylesheet
105
- * @returns a promise that resolves if the style loads or is already present
106
- */
107
71
  function checkAndLoadStyle(styleHref) {
108
- var existingTag = document.querySelector("link[href=\"".concat(styleHref, "\"]"));
109
- if (existingTag) {
110
- return Promise.resolve();
111
- }
112
- else {
113
- var styleTag_1 = document.createElement('link');
114
- styleTag_1.setAttribute('href', styleHref);
115
- styleTag_1.setAttribute('rel', 'stylesheet');
116
- var result = new Promise(function (resolve, reject) {
117
- styleTag_1.addEventListener('load', function () {
118
- resolve();
119
- });
120
- styleTag_1.addEventListener('error', function () {
121
- reject("Spark styles failed to load: ".concat(styleHref));
122
- });
123
- });
124
- document.head.appendChild(styleTag_1);
125
- return result;
126
- }
72
+ const existingTag = document.querySelector(`link[href="${styleHref}"]`);
73
+ if (existingTag) {
74
+ return Promise.resolve();
75
+ } else {
76
+ const styleTag = document.createElement("link");
77
+ styleTag.setAttribute("href", styleHref);
78
+ styleTag.setAttribute("rel", "stylesheet");
79
+ const result = new Promise((resolve, reject) => {
80
+ styleTag.addEventListener("load", () => {
81
+ resolve();
82
+ });
83
+ styleTag.addEventListener("error", () => {
84
+ reject(`Spark styles failed to load: ${styleHref}`);
85
+ });
86
+ });
87
+ document.head.appendChild(styleTag);
88
+ return result;
89
+ }
127
90
  }
128
- /**
129
- * Given an object that maps font-family identifiers to CSS urls e.g:
130
- * {
131
- * "Urbanist": "/urbanist.css",
132
- * "Noto Sans": "/noto-sans.css"
133
- * }
134
- * This function checks for loaded fonts with those identifiers. If a font is
135
- * not found, the corresponding stylesheet is added to the document.
136
- * @param fonts An object mapping font-family identifiers to CSS file urls
137
- * @returns A promise that resolves once the script tags has finished loading.
138
- * It does not fail if the script tags fail to load because we don't want to fail
139
- * the whole component loading process in that situation.
140
- */
141
91
  function checkAndLoadFonts(fonts) {
142
- var fontsToLoad = __assign({}, fonts); //clone our input so we can safely mutate it.
143
- document.fonts.forEach(function (fontFace) {
144
- // If the family is defined with quotes in CSS (e.g. `font-family: "Noto Sans"),
145
- // those quotes may be preserved JS, depending on the browser.
146
- var normalizedFamily = fontFace.family.replace(/"/g, '');
147
- if (fontsToLoad[normalizedFamily]) {
148
- // remove the font from the set to load
149
- delete fontsToLoad[normalizedFamily];
150
- }
151
- });
152
- return Promise.all(Object.values(fontsToLoad).map(function (href) {
153
- return checkAndLoadStyle(href)["catch"](function () {
154
- // Don't fail loading process for fonts, since the components
155
- // should still be reasonably usable.
156
- console.info("genesys-spark: couldn't load font style ".concat(href));
157
- });
158
- })).then(function () { }); // flatten the promise array
92
+ const fontsToLoad = __spreadValues({}, fonts);
93
+ document.fonts.forEach((fontFace) => {
94
+ const normalizedFamily = fontFace.family.replace(/"/g, "");
95
+ if (fontsToLoad[normalizedFamily]) {
96
+ delete fontsToLoad[normalizedFamily];
97
+ }
98
+ });
99
+ return Promise.all(
100
+ Object.values(fontsToLoad).map((href) => {
101
+ return checkAndLoadStyle(href).catch(() => {
102
+ console.info(`genesys-spark: couldn't load font style ${href}`);
103
+ });
104
+ })
105
+ ).then(() => {
106
+ });
159
107
  }
160
108
 
161
- //https://inindca.atlassian.net/browse/COMUI-2673
162
- // utility to get the closest element passing shadow dom boundaries
163
109
  function getClosestElement(node, selector) {
164
- if (!node) {
165
- return null;
166
- }
167
- if (node instanceof ShadowRoot) {
168
- return getClosestElement(node.host, selector);
169
- }
170
- if (node instanceof HTMLElement) {
171
- if (node.matches(selector)) {
172
- return node;
173
- }
174
- else {
175
- return getClosestElement(node.parentNode, selector);
176
- }
177
- }
178
- return getClosestElement(node.parentNode, selector);
110
+ if (!node) {
111
+ return null;
112
+ }
113
+ if (node instanceof ShadowRoot) {
114
+ return getClosestElement(node.host, selector);
115
+ }
116
+ if (node instanceof HTMLElement) {
117
+ if (node.matches(selector)) {
118
+ return node;
119
+ } else {
120
+ return getClosestElement(node.parentNode, selector);
121
+ }
122
+ }
123
+ return getClosestElement(node.parentNode, selector);
179
124
  }
180
125
 
181
- /**
182
- * Provides an [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)
183
- * object for formatting dates and times. Unlike the native version, `locale` is
184
- * an optional argument. If not provided, the function will try to determine the
185
- * locale from the DOM, where it should be set for a11y reasons.
186
- * @param locale optional locale to use for formatting
187
- * @param options options to pass to the Intl.DateTimeFormat constructor
188
- * @returns a new DateTimeFormat
189
- */
190
126
  function dateTimeFormat(localeOrOptions, options) {
191
- var locale = undefined;
192
- if (typeof localeOrOptions === 'string') {
193
- locale = localeOrOptions;
194
- }
195
- else {
196
- options = localeOrOptions;
197
- }
198
- if (locale != undefined) {
199
- return new Intl.DateTimeFormat(locale, options);
200
- }
201
- else {
202
- var userLocale = determineDisplayLocale();
203
- return new Intl.DateTimeFormat(userLocale, options);
204
- }
127
+ let locale = void 0;
128
+ if (typeof localeOrOptions === "string") {
129
+ locale = localeOrOptions;
130
+ } else {
131
+ options = localeOrOptions;
132
+ }
133
+ if (locale != void 0) {
134
+ return new Intl.DateTimeFormat(locale, options);
135
+ } else {
136
+ const userLocale = determineDisplayLocale();
137
+ return new Intl.DateTimeFormat(userLocale, options);
138
+ }
205
139
  }
206
- /**
207
- * Provides an [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
208
- * object for formatting dates and times. Unlike the native version, `locale` is
209
- * an optional argument. If not provided, the function will try to determine the
210
- * locale from the DOM, where it should be set for a11y reasons.
211
- * @param locale optional locale to use for formatting
212
- * @param options options to pass to the Intl.RelativeTimeFormat constructor
213
- * @returns a new RelativeTimeFormat
214
- */
215
140
  function relativeTimeFormat(localeOrOptions, options) {
216
- var locale = undefined;
217
- if (typeof localeOrOptions === 'string') {
218
- locale = localeOrOptions;
219
- }
220
- else {
221
- options = localeOrOptions;
222
- }
223
- if (locale != undefined) {
224
- return new Intl.RelativeTimeFormat(locale, options);
225
- }
226
- else {
227
- var userLocale = determineDisplayLocale();
228
- return new Intl.RelativeTimeFormat(userLocale, options);
229
- }
230
- }
231
- /**
232
- * Makes a best effort to return the locale that should be used for a given element
233
- * by checking language tags on ancestors. If no element is provided, it will
234
- * start with the document's <body> tag. If no locale can be found, it will use
235
- * the browser's locale preference. It will also try to add a region to regionless
236
- * locales when there is a partial match with the browser's locale.
237
- * @returns a locale string (e.g. 'en-US', 'en', 'de-DE', etc)
238
- */
239
- function determineDisplayLocale(element) {
240
- var _a;
241
- if (element === void 0) { element = document.body; }
242
- var domLocale = (_a = getClosestElement(element, '*[lang]')) === null || _a === void 0 ? void 0 : _a.lang;
243
- if (!domLocale || browserHasRegionData(domLocale)) {
244
- // If we can't find a locale in the DOM, or we find a locale without a region that matches the
245
- // users's browser locale, use the browser locale.
246
- return navigator.language;
247
- }
248
- else {
249
- return domLocale;
250
- }
141
+ let locale = void 0;
142
+ if (typeof localeOrOptions === "string") {
143
+ locale = localeOrOptions;
144
+ } else {
145
+ options = localeOrOptions;
146
+ }
147
+ if (locale != void 0) {
148
+ return new Intl.RelativeTimeFormat(locale, options);
149
+ } else {
150
+ const userLocale = determineDisplayLocale();
151
+ return new Intl.RelativeTimeFormat(userLocale, options);
152
+ }
153
+ }
154
+ function determineDisplayLocale(element = document.body) {
155
+ var _a;
156
+ const domLocale = (_a = getClosestElement(element, "*[lang]")) == null ? void 0 : _a.lang;
157
+ if (!domLocale || browserHasRegionData(domLocale)) {
158
+ return navigator.language;
159
+ } else {
160
+ return domLocale;
161
+ }
251
162
  }
252
- /**
253
- * Returns true if the provided locale only has a language, but the user's
254
- * browser settings have the same language with a locale.
255
- * @param localeString The locale to check
256
- * @returns true if the region can be guessed from the browser settings.
257
- */
258
163
  function browserHasRegionData(localeString) {
259
- return (localeString.length == 2 &&
260
- navigator.language.startsWith("".concat(localeString, "-")));
164
+ return localeString.length == 2 && navigator.language.startsWith(`${localeString}-`);
261
165
  }
262
166
  function getFormat(locale) {
263
- var date = new Date('July 5, 2000 15:00:00 UTC+00:00');
264
- var options = {
265
- year: 'numeric',
266
- month: 'numeric',
267
- day: 'numeric'
268
- };
269
- var dateTimeFormat = new Intl.DateTimeFormat(locale, options);
270
- var parts = dateTimeFormat.formatToParts(date);
271
- var dateString = parts
272
- .map(function (_a) {
273
- var type = _a.type, value = _a.value;
274
- switch (type) {
275
- case 'day':
276
- return "dd";
277
- case 'month':
278
- return "mm";
279
- case 'year':
280
- return "yyyy";
281
- default:
282
- return value;
283
- }
284
- })
285
- .join('');
286
- // review locales with two character date delimiters https://inindca.atlassian.net/browse/COMUI-2679
287
- return dateString.replace(/\s/g, '').replace(/‏/g, '');
167
+ const date = /* @__PURE__ */ new Date("July 5, 2000 15:00:00 UTC+00:00");
168
+ const options = {
169
+ year: "numeric",
170
+ month: "numeric",
171
+ day: "numeric"
172
+ };
173
+ const dateTimeFormat2 = new Intl.DateTimeFormat(
174
+ locale,
175
+ options
176
+ );
177
+ const parts = dateTimeFormat2.formatToParts(date);
178
+ const dateString = parts.map(({ type, value }) => {
179
+ switch (type) {
180
+ case "day":
181
+ return `dd`;
182
+ case "month":
183
+ return `mm`;
184
+ case "year":
185
+ return `yyyy`;
186
+ default:
187
+ return value;
188
+ }
189
+ }).join("");
190
+ return dateString.replace(/\s/g, "").replace(/‏/g, "");
288
191
  }
289
192
 
290
193
  var intl = /*#__PURE__*/Object.freeze({
291
- __proto__: null,
292
- dateTimeFormat: dateTimeFormat,
293
- determineDisplayLocale: determineDisplayLocale,
294
- getFormat: getFormat,
295
- relativeTimeFormat: relativeTimeFormat
194
+ __proto__: null,
195
+ dateTimeFormat: dateTimeFormat,
196
+ determineDisplayLocale: determineDisplayLocale,
197
+ getFormat: getFormat,
198
+ relativeTimeFormat: relativeTimeFormat
296
199
  });
297
200
 
298
- var COMPONENT_ASSET_PREFIX = '/spark-components/build-assets/4.26.0-133/genesys-webcomponents/';
299
- var CHART_COMPONENT_ASSET_PREFIX = '/spark-components/build-assets/4.26.0-133/genesys-chart-webcomponents/';
300
- /**
301
- * TODO
302
- */
201
+ const COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.26.1-135/genesys-webcomponents/";
202
+ const CHART_COMPONENT_ASSET_PREFIX = "/spark-components/build-assets/4.26.1-135/genesys-chart-webcomponents/";
303
203
  function loadSparkFonts() {
304
- var fontOrigin = getFontOrigin();
305
- var FONTS = {
306
- Urbanist: "".concat(fontOrigin, "/webfonts/urbanist.css"),
307
- 'Noto Sans': "".concat(fontOrigin, "/webfonts/noto-sans.css")
308
- };
309
- return checkAndLoadFonts(FONTS);
204
+ const fontOrigin = getFontOrigin();
205
+ const FONTS = {
206
+ Urbanist: `${fontOrigin}/webfonts/urbanist.css`,
207
+ "Noto Sans": `${fontOrigin}/webfonts/noto-sans.css`
208
+ };
209
+ return checkAndLoadFonts(FONTS);
310
210
  }
311
- /**
312
- * Loads the spark web components, as well as required CSS and fonts from a
313
- * shared CDN. Performance can be optimized by pre-loading fonts in static HTML.
314
- *
315
- * @returns a promise that succeeds if the component script and styles
316
- * load successfully. It is not recommended to wait on this promise or to stop
317
- * application bootstrap if it rejects. Its primary use should be for logging
318
- * unexpected failures.
319
- */
320
211
  function registerSparkComponents() {
321
- var SCRIPT_PATH = 'genesys-webcomponents.esm.js';
322
- var STYLE_PATH = 'genesys-webcomponents.css';
323
- var assetsOrigin = getComponentAssetsOrigin();
324
- var SCRIPT_SRC = "".concat(assetsOrigin).concat(COMPONENT_ASSET_PREFIX).concat(SCRIPT_PATH);
325
- var STYLE_HREF = "".concat(assetsOrigin).concat(COMPONENT_ASSET_PREFIX).concat(STYLE_PATH);
326
- return Promise.all([
327
- checkAndLoadScript(SCRIPT_SRC),
328
- checkAndLoadStyle(STYLE_HREF),
329
- loadSparkFonts()
330
- ]).then();
212
+ const SCRIPT_PATH = "genesys-webcomponents.esm.js";
213
+ const STYLE_PATH = "genesys-webcomponents.css";
214
+ const assetsOrigin = getComponentAssetsOrigin();
215
+ const SCRIPT_SRC = `${assetsOrigin}${COMPONENT_ASSET_PREFIX}${SCRIPT_PATH}`;
216
+ const STYLE_HREF = `${assetsOrigin}${COMPONENT_ASSET_PREFIX}${STYLE_PATH}`;
217
+ return Promise.all([
218
+ checkAndLoadScript(SCRIPT_SRC),
219
+ checkAndLoadStyle(STYLE_HREF),
220
+ loadSparkFonts()
221
+ ]).then();
331
222
  }
332
- /**
333
- * TODO
334
- */
335
223
  function registerSparkChartComponents() {
336
- var SCRIPT_PATH = 'genesys-chart-webcomponents.esm.js';
337
- var STYLE_PATH = 'genesys-chart-webcomponents.css';
338
- var assetsOrigin = getChartComponentAssetsOrigin();
339
- var SCRIPT_SRC = "".concat(assetsOrigin).concat(CHART_COMPONENT_ASSET_PREFIX).concat(SCRIPT_PATH);
340
- var STYLE_HREF = "".concat(assetsOrigin).concat(CHART_COMPONENT_ASSET_PREFIX).concat(STYLE_PATH);
341
- return Promise.all([
342
- checkAndLoadScript(SCRIPT_SRC),
343
- checkAndLoadStyle(STYLE_HREF),
344
- loadSparkFonts()
345
- ]).then();
224
+ const SCRIPT_PATH = "genesys-chart-webcomponents.esm.js";
225
+ const STYLE_PATH = "genesys-chart-webcomponents.css";
226
+ const assetsOrigin = getChartComponentAssetsOrigin();
227
+ const SCRIPT_SRC = `${assetsOrigin}${CHART_COMPONENT_ASSET_PREFIX}${SCRIPT_PATH}`;
228
+ const STYLE_HREF = `${assetsOrigin}${CHART_COMPONENT_ASSET_PREFIX}${STYLE_PATH}`;
229
+ return Promise.all([
230
+ checkAndLoadScript(SCRIPT_SRC),
231
+ checkAndLoadStyle(STYLE_HREF),
232
+ loadSparkFonts()
233
+ ]).then();
346
234
  }
347
235
 
348
236
  export { intl as Intl, loadSparkFonts, registerSparkChartComponents, registerSparkComponents };
package/package.json CHANGED
@@ -1,28 +1,30 @@
1
1
  {
2
2
  "name": "genesys-spark",
3
- "version": "4.26.0",
3
+ "version": "4.26.1",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "files": [
10
- "dist/src/*.d.ts"
10
+ "dist"
11
11
  ],
12
12
  "scripts": {
13
+ "prebuild": "npm run clean",
13
14
  "build": "rollup -c",
15
+ "clean": "rm -r ./dist || true",
14
16
  "dev": "rollup -c --watch",
15
17
  "eslint": "eslint --fix './**/*.ts'",
16
18
  "lint-staged": "lint-staged --concurrent false",
17
19
  "prettier": "prettier --log-level silent --ignore-path .gitignore --ignore-unknown --write .",
18
20
  "test": "jest",
21
+ "test.ci": "npm run test",
19
22
  "test.watch": "jest --watch",
20
23
  "version-sync": "npm version --no-git-tag-version --allow-same-version"
21
24
  },
22
25
  "types": "dist/src/index.d.ts",
23
26
  "devDependencies": {
24
27
  "@rollup/plugin-replace": "^5.0.5",
25
- "@rollup/plugin-typescript": "^11.1.6",
26
28
  "@tsconfig/strictest": "^2.0.3",
27
29
  "@typescript-eslint/eslint-plugin": "^7.1.0",
28
30
  "@typescript-eslint/parser": "^7.1.0",
@@ -30,6 +32,8 @@
30
32
  "jest": "^29.7.0",
31
33
  "jest-environment-jsdom": "^29.7.0",
32
34
  "rollup": "^4.12.1",
35
+ "rollup-plugin-dts": "^6.1.0",
36
+ "rollup-plugin-esbuild": "^6.1.1",
33
37
  "ts-jest": "^29.1.2"
34
38
  }
35
39
  }
@@ -1,11 +0,0 @@
1
- declare global {
2
- var IS_DEV_MODE: boolean;
3
- }
4
- /**
5
- * Returns the origin that web component assets should be loaded from.
6
- * Will use the domain of the current window if it matches a Genesys domain.
7
- */
8
- export declare function getComponentAssetsOrigin(): string;
9
- export declare function getChartComponentAssetsOrigin(): string;
10
- export declare function getAssetsOrigin(): string;
11
- export declare function getFontOrigin(): string;
@@ -1,19 +0,0 @@
1
- /**
2
- * TODO
3
- */
4
- export declare function loadSparkFonts(): Promise<void>;
5
- /**
6
- * Loads the spark web components, as well as required CSS and fonts from a
7
- * shared CDN. Performance can be optimized by pre-loading fonts in static HTML.
8
- *
9
- * @returns a promise that succeeds if the component script and styles
10
- * load successfully. It is not recommended to wait on this promise or to stop
11
- * application bootstrap if it rejects. Its primary use should be for logging
12
- * unexpected failures.
13
- */
14
- export declare function registerSparkComponents(): Promise<void>;
15
- /**
16
- * TODO
17
- */
18
- export declare function registerSparkChartComponents(): Promise<void>;
19
- export * as Intl from './utils/intl';
@@ -1,28 +0,0 @@
1
- /**
2
- * Add a script tag to the document if it is not already present.
3
- * @param scriptSrc The src attribute of the script
4
- * @returns a promise that resolves if the script loads or is already present
5
- */
6
- export declare function checkAndLoadScript(scriptSrc: string): Promise<void>;
7
- /**
8
- * Add a stylesheet link tag to the document if it is not already present.
9
- * @param styleHref The href attribute of the stylesheet
10
- * @returns a promise that resolves if the style loads or is already present
11
- */
12
- export declare function checkAndLoadStyle(styleHref: string): Promise<void>;
13
- /**
14
- * Given an object that maps font-family identifiers to CSS urls e.g:
15
- * {
16
- * "Urbanist": "/urbanist.css",
17
- * "Noto Sans": "/noto-sans.css"
18
- * }
19
- * This function checks for loaded fonts with those identifiers. If a font is
20
- * not found, the corresponding stylesheet is added to the document.
21
- * @param fonts An object mapping font-family identifiers to CSS file urls
22
- * @returns A promise that resolves once the script tags has finished loading.
23
- * It does not fail if the script tags fail to load because we don't want to fail
24
- * the whole component loading process in that situation.
25
- */
26
- export declare function checkAndLoadFonts(fonts: {
27
- [key: string]: string;
28
- }): Promise<void>;