@flipdish/ui-library 0.18.0 → 0.20.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 +6 -7
- package/dist/components/atoms/AppStoreButton/components/app-store-buttons-outline.cjs +5 -12
- package/dist/components/atoms/AppStoreButton/components/app-store-buttons-outline.cjs.map +1 -1
- package/dist/components/atoms/AppStoreButton/components/app-store-buttons-outline.d.ts.map +1 -1
- package/dist/components/atoms/AppStoreButton/components/app-store-buttons-outline.js +5 -12
- package/dist/components/atoms/AppStoreButton/components/app-store-buttons-outline.js.map +1 -1
- package/dist/components/atoms/AppStoreButton/index.cjs +6 -15
- package/dist/components/atoms/AppStoreButton/index.cjs.map +1 -1
- package/dist/components/atoms/AppStoreButton/index.d.ts.map +1 -1
- package/dist/components/atoms/AppStoreButton/index.js +6 -15
- package/dist/components/atoms/AppStoreButton/index.js.map +1 -1
- package/dist/components/atoms/Avatar/components/avatar-base.cjs +60 -0
- package/dist/components/atoms/Avatar/components/avatar-base.cjs.map +1 -0
- package/dist/components/atoms/Avatar/components/avatar-base.d.ts +77 -0
- package/dist/components/atoms/Avatar/components/avatar-base.d.ts.map +1 -0
- package/dist/components/atoms/Avatar/components/avatar-base.js +58 -0
- package/dist/components/atoms/Avatar/components/avatar-base.js.map +1 -0
- package/dist/components/atoms/Avatar/components/avatar-label-group.cjs +2 -2
- package/dist/components/atoms/Avatar/components/avatar-label-group.cjs.map +1 -1
- package/dist/components/atoms/Avatar/components/avatar-label-group.d.ts +1 -1
- package/dist/components/atoms/Avatar/components/avatar-label-group.d.ts.map +1 -1
- package/dist/components/atoms/Avatar/components/avatar-label-group.js +1 -1
- package/dist/components/atoms/Avatar/index.cjs +3 -55
- package/dist/components/atoms/Avatar/index.cjs.map +1 -1
- package/dist/components/atoms/Avatar/index.d.ts +2 -70
- package/dist/components/atoms/Avatar/index.d.ts.map +1 -1
- package/dist/components/atoms/Avatar/index.js +1 -57
- package/dist/components/atoms/Avatar/index.js.map +1 -1
- package/dist/components/atoms/Badge/index.cjs +0 -1
- package/dist/components/atoms/Badge/index.cjs.map +1 -1
- package/dist/components/atoms/Badge/index.d.ts +0 -5
- package/dist/components/atoms/Badge/index.d.ts.map +1 -1
- package/dist/components/atoms/Badge/index.js +1 -1
- package/dist/components/atoms/Badge/index.js.map +1 -1
- package/dist/components/atoms/Button/index.cjs +3 -3
- package/dist/components/atoms/Button/index.cjs.map +1 -1
- package/dist/components/atoms/Button/index.d.ts.map +1 -1
- package/dist/components/atoms/Button/index.js +1 -1
- package/dist/components/atoms/FeaturedIcon/index.cjs +2 -2
- package/dist/components/atoms/FeaturedIcon/index.cjs.map +1 -1
- package/dist/components/atoms/FeaturedIcon/index.d.ts.map +1 -1
- package/dist/components/atoms/FeaturedIcon/index.js +1 -1
- package/dist/components/atoms/UtilityButton/index.cjs +2 -2
- package/dist/components/atoms/UtilityButton/index.cjs.map +1 -1
- package/dist/components/atoms/UtilityButton/index.d.ts.map +1 -1
- package/dist/components/atoms/UtilityButton/index.js +1 -1
- package/dist/components/molecules/BadgeGroup/index.cjs +3 -3
- package/dist/components/molecules/BadgeGroup/index.cjs.map +1 -1
- package/dist/components/molecules/BadgeGroup/index.d.ts.map +1 -1
- package/dist/components/molecules/BadgeGroup/index.js +1 -1
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-account-item.cjs +2 -2
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-account-item.cjs.map +1 -1
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-account-item.js +1 -1
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-item.cjs +9 -6
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-item.cjs.map +1 -1
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-item.d.ts +1 -1
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-item.d.ts.map +1 -1
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-item.js +7 -4
- package/dist/components/molecules/Breadcrumbs/components/breadcrumb-item.js.map +1 -1
- package/dist/components/molecules/Breadcrumbs/index.cjs +3 -6
- package/dist/components/molecules/Breadcrumbs/index.cjs.map +1 -1
- package/dist/components/molecules/Breadcrumbs/index.d.ts +2 -6
- package/dist/components/molecules/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/components/molecules/Breadcrumbs/index.js +2 -5
- package/dist/components/molecules/Breadcrumbs/index.js.map +1 -1
- package/dist/components/molecules/Breadcrumbs/providers/breadcrumbs-context.cjs +17 -0
- package/dist/components/molecules/Breadcrumbs/providers/breadcrumbs-context.cjs.map +1 -0
- package/dist/components/molecules/Breadcrumbs/providers/breadcrumbs-context.d.ts +13 -0
- package/dist/components/molecules/Breadcrumbs/providers/breadcrumbs-context.d.ts.map +1 -0
- package/dist/components/molecules/Breadcrumbs/providers/breadcrumbs-context.js +15 -0
- package/dist/components/molecules/Breadcrumbs/providers/breadcrumbs-context.js.map +1 -0
- package/dist/components/molecules/ButtonGroup/index.cjs +2 -2
- package/dist/components/molecules/ButtonGroup/index.cjs.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.d.ts.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.js +1 -1
- package/dist/components/molecules/Carousel/index.cjs +0 -1
- package/dist/components/molecules/Carousel/index.cjs.map +1 -1
- package/dist/components/molecules/Carousel/index.d.ts +0 -1
- package/dist/components/molecules/Carousel/index.d.ts.map +1 -1
- package/dist/components/molecules/Carousel/index.js +1 -1
- package/dist/components/molecules/Carousel/index.js.map +1 -1
- package/dist/components/molecules/Select/components/combobox.cjs +2 -2
- package/dist/components/molecules/Select/components/combobox.cjs.map +1 -1
- package/dist/components/molecules/Select/components/combobox.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/combobox.js +1 -1
- package/dist/components/molecules/Select/components/select-item.cjs +2 -2
- package/dist/components/molecules/Select/components/select-item.cjs.map +1 -1
- package/dist/components/molecules/Select/components/select-item.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/select-item.js +1 -1
- package/dist/components/molecules/Select/index.cjs +2 -2
- package/dist/components/molecules/Select/index.cjs.map +1 -1
- package/dist/components/molecules/Select/index.d.ts.map +1 -1
- package/dist/components/molecules/Select/index.js +1 -1
- package/dist/components/molecules/Tabs/index.cjs +2 -2
- package/dist/components/molecules/Tabs/index.cjs.map +1 -1
- package/dist/components/molecules/Tabs/index.d.ts.map +1 -1
- package/dist/components/molecules/Tabs/index.js +1 -1
- package/dist/components/organisms/ActivityFeed/index.cjs +5 -1
- package/dist/components/organisms/ActivityFeed/index.cjs.map +1 -1
- package/dist/components/organisms/ActivityFeed/index.d.ts.map +1 -1
- package/dist/components/organisms/ActivityFeed/index.js +5 -1
- package/dist/components/organisms/ActivityFeed/index.js.map +1 -1
- package/dist/components/organisms/Charts/index.d.ts +22 -6
- package/dist/components/organisms/Charts/index.d.ts.map +1 -1
- package/dist/components/organisms/FileUpload/index.cjs +1 -4
- package/dist/components/organisms/FileUpload/index.cjs.map +1 -1
- package/dist/components/organisms/FileUpload/index.d.ts +1 -9
- package/dist/components/organisms/FileUpload/index.d.ts.map +1 -1
- package/dist/components/organisms/FileUpload/index.js +3 -3
- package/dist/components/organisms/FileUpload/index.js.map +1 -1
- package/dist/components/organisms/GradientPicker/index.cjs +0 -6
- package/dist/components/organisms/GradientPicker/index.cjs.map +1 -1
- package/dist/components/organisms/GradientPicker/index.d.ts +0 -28
- package/dist/components/organisms/GradientPicker/index.d.ts.map +1 -1
- package/dist/components/organisms/GradientPicker/index.js +1 -1
- package/dist/components/organisms/GradientPicker/index.js.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.cjs +2 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.d.ts.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.js +2 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-account-card.js.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-item.cjs +4 -3
- package/dist/components/organisms/HeaderNavigation/components/nav-item.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-item.d.ts.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/nav-item.js +4 -3
- package/dist/components/organisms/HeaderNavigation/components/nav-item.js.map +1 -1
- package/dist/components/organisms/ImagePicker/index.cjs +0 -3
- package/dist/components/organisms/ImagePicker/index.cjs.map +1 -1
- package/dist/components/organisms/ImagePicker/index.d.ts +0 -6
- package/dist/components/organisms/ImagePicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ImagePicker/index.js +1 -1
- package/dist/components/organisms/ImagePicker/index.js.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-button.cjs +5 -2
- package/dist/components/organisms/SidebarNavigation/components/nav-button.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-button.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-button.js +5 -2
- package/dist/components/organisms/SidebarNavigation/components/nav-button.js.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-item.cjs +5 -4
- package/dist/components/organisms/SidebarNavigation/components/nav-item.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-item.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/components/nav-item.js +5 -4
- package/dist/components/organisms/SidebarNavigation/components/nav-item.js.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-extensions.cjs +13 -13
- package/dist/components/organisms/TextEditor/components/text-editor-extensions.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-extensions.js +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-tooltip.cjs +2 -2
- package/dist/components/organisms/TextEditor/components/text-editor-tooltip.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/components/text-editor-tooltip.js +1 -1
- package/dist/components/organisms/TextEditor/index.cjs +6 -13
- package/dist/components/organisms/TextEditor/index.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/index.d.ts +2 -10
- package/dist/components/organisms/TextEditor/index.d.ts.map +1 -1
- package/dist/components/organisms/TextEditor/index.js +2 -9
- package/dist/components/organisms/TextEditor/index.js.map +1 -1
- package/dist/components/organisms/TextEditor/providers/text-editor-context.cjs +21 -0
- package/dist/components/organisms/TextEditor/providers/text-editor-context.cjs.map +1 -0
- package/dist/components/organisms/TextEditor/providers/text-editor-context.d.ts +17 -0
- package/dist/components/organisms/TextEditor/providers/text-editor-context.d.ts.map +1 -0
- package/dist/components/organisms/TextEditor/providers/text-editor-context.js +18 -0
- package/dist/components/organisms/TextEditor/providers/text-editor-context.js.map +1 -0
- package/dist/components/organisms/TreeView/index.cjs +2 -2
- package/dist/components/organisms/TreeView/index.cjs.map +1 -1
- package/dist/components/organisms/TreeView/index.d.ts.map +1 -1
- package/dist/components/organisms/TreeView/index.js +1 -1
- package/dist/hooks/{useAriaDisclosureAttrs/index.cjs → __internal__/useAriaDisclosureAttrs/useAriaDisclosureAttrs.cjs} +1 -1
- package/dist/hooks/__internal__/useAriaDisclosureAttrs/useAriaDisclosureAttrs.cjs.map +1 -0
- package/dist/hooks/{useAriaDisclosureAttrs/index.d.ts → __internal__/useAriaDisclosureAttrs/useAriaDisclosureAttrs.d.ts} +1 -1
- package/dist/hooks/__internal__/useAriaDisclosureAttrs/useAriaDisclosureAttrs.d.ts.map +1 -0
- package/dist/hooks/{useAriaDisclosureAttrs/index.js → __internal__/useAriaDisclosureAttrs/useAriaDisclosureAttrs.js} +1 -1
- package/dist/hooks/__internal__/useAriaDisclosureAttrs/useAriaDisclosureAttrs.js.map +1 -0
- package/dist/native/components/atoms/Button/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Button/index.js +1 -1
- package/dist/{utilities/isReactComponent/index.d.ts → native/utilities/__internal__/componentGuardUtils/componentGuard.utils.d.ts} +3 -3
- package/dist/native/utilities/__internal__/componentGuardUtils/componentGuard.utils.d.ts.map +1 -0
- package/dist/{utilities/isReactComponent/index.js → native/utilities/__internal__/componentGuardUtils/componentGuard.utils.js} +3 -3
- package/dist/native/utilities/__internal__/componentGuardUtils/componentGuard.utils.js.map +1 -0
- package/dist/native/utilities/cx/index.d.ts +2 -2
- package/dist/native/utilities/cx/index.js +2 -2
- package/dist/native/{hooks/useAriaDisclosureAttrs → utilities/hrefUtils}/index.d.ts +3 -3
- package/dist/utilities/{isReactComponent/index.cjs → __internal__/componentGuardUtils/componentGuard.utils.cjs} +3 -3
- package/dist/utilities/__internal__/componentGuardUtils/componentGuard.utils.cjs.map +1 -0
- package/dist/{native/utilities/isReactComponent/index.d.ts → utilities/__internal__/componentGuardUtils/componentGuard.utils.d.ts} +3 -3
- package/dist/utilities/__internal__/componentGuardUtils/componentGuard.utils.d.ts.map +1 -0
- package/dist/{native/utilities/isReactComponent/index.js → utilities/__internal__/componentGuardUtils/componentGuard.utils.js} +3 -3
- package/dist/utilities/__internal__/componentGuardUtils/componentGuard.utils.js.map +1 -0
- package/dist/utilities/__internal__/logUtils/log.utils.cjs +32 -0
- package/dist/utilities/__internal__/logUtils/log.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/logUtils/log.utils.d.ts +23 -0
- package/dist/utilities/__internal__/logUtils/log.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/logUtils/log.utils.js +30 -0
- package/dist/utilities/__internal__/logUtils/log.utils.js.map +1 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs +102 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts +41 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js +98 -0
- package/dist/utilities/__internal__/webStorageUtils/webStorage.utils.js.map +1 -0
- package/dist/utilities/cx/index.cjs +2 -2
- package/dist/utilities/cx/index.d.ts +2 -2
- package/dist/utilities/cx/index.js +2 -2
- package/dist/utilities/hrefUtils/index.cjs +50 -0
- package/dist/utilities/hrefUtils/index.cjs.map +1 -0
- package/dist/utilities/hrefUtils/index.d.ts +19 -0
- package/dist/utilities/hrefUtils/index.d.ts.map +1 -0
- package/dist/utilities/hrefUtils/index.js +47 -0
- package/dist/utilities/hrefUtils/index.js.map +1 -0
- package/dist/utilities/localStorageUtils/index.cjs +9 -102
- package/dist/utilities/localStorageUtils/index.cjs.map +1 -1
- package/dist/utilities/localStorageUtils/index.d.ts +5 -5
- package/dist/utilities/localStorageUtils/index.d.ts.map +1 -1
- package/dist/utilities/localStorageUtils/index.js +7 -100
- package/dist/utilities/localStorageUtils/index.js.map +1 -1
- package/dist/utilities/renderUtils/index.cjs +7 -12
- package/dist/utilities/renderUtils/index.cjs.map +1 -1
- package/dist/utilities/renderUtils/index.d.ts.map +1 -1
- package/dist/utilities/renderUtils/index.js +7 -12
- package/dist/utilities/renderUtils/index.js.map +1 -1
- package/dist/utilities/sessionStorageUtils/index.cjs +9 -103
- package/dist/utilities/sessionStorageUtils/index.cjs.map +1 -1
- package/dist/utilities/sessionStorageUtils/index.d.ts +5 -6
- package/dist/utilities/sessionStorageUtils/index.d.ts.map +1 -1
- package/dist/utilities/sessionStorageUtils/index.js +7 -101
- package/dist/utilities/sessionStorageUtils/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/hooks/useAriaDisclosureAttrs/index.cjs.map +0 -1
- package/dist/hooks/useAriaDisclosureAttrs/index.d.ts.map +0 -1
- package/dist/hooks/useAriaDisclosureAttrs/index.js.map +0 -1
- package/dist/native/utilities/isReactComponent/index.d.ts.map +0 -1
- package/dist/native/utilities/isReactComponent/index.js.map +0 -1
- package/dist/utilities/isReactComponent/index.cjs.map +0 -1
- package/dist/utilities/isReactComponent/index.d.ts.map +0 -1
- package/dist/utilities/isReactComponent/index.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var log_utils = require('../__internal__/logUtils/log.utils.cjs');
|
|
4
|
+
|
|
5
|
+
const ALLOWED_PROTOCOLS = ['http:', 'https:', 'mailto:', 'tel:'];
|
|
6
|
+
// The only scheme names that may appear in warnings — never consumer input.
|
|
7
|
+
const KNOWN_BLOCKED_SCHEMES = ['javascript:', 'data:', 'vbscript:', 'file:', 'blob:', 'ftp:'];
|
|
8
|
+
// Browsers strip tab/newline (and tolerate other C0 controls) when parsing URLs, so
|
|
9
|
+
// `java\nscript:alert(1)` executes as javascript: — remove them before scheme-checking.
|
|
10
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: removing control characters is the point
|
|
11
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001F\u007F]/g;
|
|
12
|
+
/**
|
|
13
|
+
* Validates a consumer-supplied `href` for safe use on an anchor.
|
|
14
|
+
*
|
|
15
|
+
* Strips ASCII control characters, then rejects any explicit scheme outside
|
|
16
|
+
* http/https/mailto/tel — blocking `javascript:`, `data:` and friends. Scheme-less
|
|
17
|
+
* values (relative paths, fragments, bare domains) are allowed.
|
|
18
|
+
*
|
|
19
|
+
* @returns the cleaned href, or `undefined` when the href is not allowed (rendering
|
|
20
|
+
* an anchor with no `href` rather than an executable one).
|
|
21
|
+
*/
|
|
22
|
+
const safeHref = (href) => {
|
|
23
|
+
if (href === undefined) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const cleaned = href.replace(CONTROL_CHARACTERS, '');
|
|
27
|
+
const scheme = /^[a-z][a-z0-9+.-]*:/i.exec(cleaned.trim())?.[0].toLowerCase();
|
|
28
|
+
if (scheme && !ALLOWED_PROTOCOLS.includes(scheme)) {
|
|
29
|
+
// Kept in production builds on purpose: the dangerous input is data-dependent
|
|
30
|
+
// (CMS content, user profiles) and usually only exists in production. The warning
|
|
31
|
+
// text and dedupe key only ever use values from the fixed list below — a raw
|
|
32
|
+
// scheme is consumer input that can embed identifiers (`customer-123:`) and would
|
|
33
|
+
// grow the dedupe set without bound.
|
|
34
|
+
const known = KNOWN_BLOCKED_SCHEMES.includes(scheme);
|
|
35
|
+
log_utils.warnOnce(`safeHref:${known ? scheme : 'other-scheme'}`, `safeHref blocked an href with ${known ? `disallowed scheme "${scheme}"` : 'a non-allowlisted scheme'}. Allowed: http, https, mailto, tel, and relative URLs. The element renders without an href.`);
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return cleaned;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Whether an href points at an external site (http/https), for `target="_blank"`
|
|
42
|
+
* decisions. Unlike a bare `startsWith('http')`, this requires a real scheme match on
|
|
43
|
+
* the control-character-stripped value, so `javascript:` never classifies as internal
|
|
44
|
+
* by falling through, and `httpfoo` never classifies as external.
|
|
45
|
+
*/
|
|
46
|
+
const isExternalHref = (href) => /^https?:/i.test((href ?? '').replace(CONTROL_CHARACTERS, '').trim());
|
|
47
|
+
|
|
48
|
+
exports.isExternalHref = isExternalHref;
|
|
49
|
+
exports.safeHref = safeHref;
|
|
50
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/hrefUtils/index.ts"],"sourcesContent":[null],"names":["warnOnce"],"mappings":";;;;AAEA,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;AAEhE;AACA,MAAM,qBAAqB,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC;AAE7F;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,wBAAwB;AAEnD;;;;;;;;;AASG;AACI,MAAM,QAAQ,GAAG,CAAC,IAAwB,KAAwB;AACvE,IAAA,IAAI,IAAI,KAAK,SAAS,EAAE;AACtB,QAAA,OAAO,SAAS;IAClB;IACA,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;AACpD,IAAA,MAAM,MAAM,GAAG,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE;IAC7E,IAAI,MAAM,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;;;;;;QAMjD,MAAM,KAAK,GAAG,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC;QACpDA,kBAAQ,CACN,CAAA,SAAA,EAAY,KAAK,GAAG,MAAM,GAAG,cAAc,CAAA,CAAE,EAC7C,CAAA,8BAAA,EAAiC,KAAK,GAAG,CAAA,mBAAA,EAAsB,MAAM,CAAA,CAAA,CAAG,GAAG,0BAA0B,CAAA,4FAAA,CAA8F,CACpM;AACD,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,OAAO,OAAO;AAChB;AAEA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAC,IAAwB,KAAc,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,EAAE,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a consumer-supplied `href` for safe use on an anchor.
|
|
3
|
+
*
|
|
4
|
+
* Strips ASCII control characters, then rejects any explicit scheme outside
|
|
5
|
+
* http/https/mailto/tel — blocking `javascript:`, `data:` and friends. Scheme-less
|
|
6
|
+
* values (relative paths, fragments, bare domains) are allowed.
|
|
7
|
+
*
|
|
8
|
+
* @returns the cleaned href, or `undefined` when the href is not allowed (rendering
|
|
9
|
+
* an anchor with no `href` rather than an executable one).
|
|
10
|
+
*/
|
|
11
|
+
export declare const safeHref: (href: string | undefined) => string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Whether an href points at an external site (http/https), for `target="_blank"`
|
|
14
|
+
* decisions. Unlike a bare `startsWith('http')`, this requires a real scheme match on
|
|
15
|
+
* the control-character-stripped value, so `javascript:` never classifies as internal
|
|
16
|
+
* by falling through, and `httpfoo` never classifies as external.
|
|
17
|
+
*/
|
|
18
|
+
export declare const isExternalHref: (href: string | undefined) => boolean;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/hrefUtils/index.ts"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAoB5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,OAAgF,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { warnOnce } from '../__internal__/logUtils/log.utils.js';
|
|
2
|
+
|
|
3
|
+
const ALLOWED_PROTOCOLS = ['http:', 'https:', 'mailto:', 'tel:'];
|
|
4
|
+
// The only scheme names that may appear in warnings — never consumer input.
|
|
5
|
+
const KNOWN_BLOCKED_SCHEMES = ['javascript:', 'data:', 'vbscript:', 'file:', 'blob:', 'ftp:'];
|
|
6
|
+
// Browsers strip tab/newline (and tolerate other C0 controls) when parsing URLs, so
|
|
7
|
+
// `java\nscript:alert(1)` executes as javascript: — remove them before scheme-checking.
|
|
8
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: removing control characters is the point
|
|
9
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001F\u007F]/g;
|
|
10
|
+
/**
|
|
11
|
+
* Validates a consumer-supplied `href` for safe use on an anchor.
|
|
12
|
+
*
|
|
13
|
+
* Strips ASCII control characters, then rejects any explicit scheme outside
|
|
14
|
+
* http/https/mailto/tel — blocking `javascript:`, `data:` and friends. Scheme-less
|
|
15
|
+
* values (relative paths, fragments, bare domains) are allowed.
|
|
16
|
+
*
|
|
17
|
+
* @returns the cleaned href, or `undefined` when the href is not allowed (rendering
|
|
18
|
+
* an anchor with no `href` rather than an executable one).
|
|
19
|
+
*/
|
|
20
|
+
const safeHref = (href) => {
|
|
21
|
+
if (href === undefined) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const cleaned = href.replace(CONTROL_CHARACTERS, '');
|
|
25
|
+
const scheme = /^[a-z][a-z0-9+.-]*:/i.exec(cleaned.trim())?.[0].toLowerCase();
|
|
26
|
+
if (scheme && !ALLOWED_PROTOCOLS.includes(scheme)) {
|
|
27
|
+
// Kept in production builds on purpose: the dangerous input is data-dependent
|
|
28
|
+
// (CMS content, user profiles) and usually only exists in production. The warning
|
|
29
|
+
// text and dedupe key only ever use values from the fixed list below — a raw
|
|
30
|
+
// scheme is consumer input that can embed identifiers (`customer-123:`) and would
|
|
31
|
+
// grow the dedupe set without bound.
|
|
32
|
+
const known = KNOWN_BLOCKED_SCHEMES.includes(scheme);
|
|
33
|
+
warnOnce(`safeHref:${known ? scheme : 'other-scheme'}`, `safeHref blocked an href with ${known ? `disallowed scheme "${scheme}"` : 'a non-allowlisted scheme'}. Allowed: http, https, mailto, tel, and relative URLs. The element renders without an href.`);
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return cleaned;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Whether an href points at an external site (http/https), for `target="_blank"`
|
|
40
|
+
* decisions. Unlike a bare `startsWith('http')`, this requires a real scheme match on
|
|
41
|
+
* the control-character-stripped value, so `javascript:` never classifies as internal
|
|
42
|
+
* by falling through, and `httpfoo` never classifies as external.
|
|
43
|
+
*/
|
|
44
|
+
const isExternalHref = (href) => /^https?:/i.test((href ?? '').replace(CONTROL_CHARACTERS, '').trim());
|
|
45
|
+
|
|
46
|
+
export { isExternalHref, safeHref };
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/hrefUtils/index.ts"],"sourcesContent":[null],"names":[],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|
3
|
+
var webStorage_utils = require('../__internal__/webStorageUtils/webStorage.utils.cjs');
|
|
3
4
|
var localStorageUtils_constants = require('./localStorageUtils.constants.cjs');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* Web-only, typed `localStorage` persistence.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Web-only, typed `localStorage` persistence. Thin wrapper over the shared
|
|
8
|
+
* `#internal/utilities/webStorageUtils` factory (which `sessionStorageUtils`
|
|
9
|
+
* also uses — the two modules were byte-identical twins before the factory).
|
|
10
|
+
* Every helper no-ops / returns `null` when `localStorage` is unavailable
|
|
11
|
+
* (SSR, React Native, private mode, quota errors).
|
|
11
12
|
*
|
|
12
13
|
* Every key this package persists is registered in `localStorageUtils.constants.ts`
|
|
13
14
|
* — check there for the full list before adding a new one.
|
|
14
15
|
*/
|
|
15
|
-
const isBrowser = typeof window !== 'undefined';
|
|
16
|
-
/**
|
|
17
|
-
* Internal `localStorage` primitives backing `createLocalStorageItem`. Not
|
|
18
|
-
* exported — everything a consumer needs goes through `createLocalStorageItem`,
|
|
19
|
-
* which adds typed serialization/validation on top. Add a raw string export
|
|
20
|
-
* here only once a real caller needs plain-string storage without JSON typing.
|
|
21
|
-
*/
|
|
22
|
-
/** Read a raw string value, or `null` when unset/unavailable. */
|
|
23
|
-
const safeLocalGet = (key) => {
|
|
24
|
-
if (!isBrowser)
|
|
25
|
-
return null;
|
|
26
|
-
try {
|
|
27
|
-
return window.localStorage.getItem(key);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
/** Persist a raw string value; returns whether the write succeeded. */
|
|
34
|
-
const safeLocalSet = (key, value) => {
|
|
35
|
-
if (!isBrowser)
|
|
36
|
-
return false;
|
|
37
|
-
try {
|
|
38
|
-
window.localStorage.setItem(key, value);
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
/** Remove a value; returns whether the removal succeeded. */
|
|
46
|
-
const safeLocalRemove = (key) => {
|
|
47
|
-
if (!isBrowser)
|
|
48
|
-
return false;
|
|
49
|
-
try {
|
|
50
|
-
window.localStorage.removeItem(key);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Reusable `validate` guard for a `createLocalStorageItem<boolean>` item.
|
|
59
|
-
*/
|
|
60
|
-
const isBoolean = (value) => typeof value === 'boolean';
|
|
61
|
-
/**
|
|
62
|
-
* Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
|
|
63
|
-
* `errorMessage` for anything else so `createLocalStorageItem.get()` treats it
|
|
64
|
-
* as invalid data and returns `null`.
|
|
65
|
-
*/
|
|
66
|
-
const parseBooleanString = (raw, errorMessage) => {
|
|
67
|
-
if (raw === 'true')
|
|
68
|
-
return true;
|
|
69
|
-
if (raw === 'false')
|
|
70
|
-
return false;
|
|
71
|
-
throw new Error(errorMessage);
|
|
72
|
-
};
|
|
73
16
|
/**
|
|
74
17
|
* Build a typed, failure-safe accessor for a single `localStorage` key.
|
|
75
18
|
*
|
|
@@ -78,51 +21,15 @@ const parseBooleanString = (raw, errorMessage) => {
|
|
|
78
21
|
* draft.set({ title: 'Hi' });
|
|
79
22
|
* const value = draft.get(); // Draft | null
|
|
80
23
|
*/
|
|
81
|
-
const createLocalStorageItem = (key, options = {}) =>
|
|
82
|
-
const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
|
|
83
|
-
return {
|
|
84
|
-
get() {
|
|
85
|
-
const raw = safeLocalGet(key);
|
|
86
|
-
if (raw == null)
|
|
87
|
-
return null;
|
|
88
|
-
try {
|
|
89
|
-
const value = deserialize(raw);
|
|
90
|
-
if (validate && !validate(value))
|
|
91
|
-
return null;
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
set(value) {
|
|
99
|
-
try {
|
|
100
|
-
const serialized = serialize(value);
|
|
101
|
-
// JSON.stringify (and a custom serializer) can return `undefined` for a
|
|
102
|
-
// top-level `undefined`, function, or symbol — treat that as a failed
|
|
103
|
-
// serialization rather than writing the literal string "undefined".
|
|
104
|
-
if (typeof serialized !== 'string')
|
|
105
|
-
return;
|
|
106
|
-
safeLocalSet(key, serialized);
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
// serialize() can throw (e.g. circular refs); matches the documented
|
|
110
|
-
// failure-safe contract — silently ignore, same as a write failure.
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
clear() {
|
|
114
|
-
safeLocalRemove(key);
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
};
|
|
24
|
+
const createLocalStorageItem = (key, options = {}) => webStorage_utils.createWebStorageItem(() => window.localStorage, key, options);
|
|
118
25
|
/**
|
|
119
26
|
* Persistence for the `SidebarNavigation` collapsed preference. Stored as the
|
|
120
27
|
* plain strings `'true'` / `'false'` to preserve the original on-disk format.
|
|
121
28
|
*/
|
|
122
29
|
const sidebarCollapsedStorage = createLocalStorageItem(localStorageUtils_constants.LOCAL_STORAGE_KEYS.sidebarCollapsed, {
|
|
123
30
|
serialize: String,
|
|
124
|
-
deserialize: (raw) => parseBooleanString(raw, 'Invalid sidebar collapsed value'),
|
|
125
|
-
validate: isBoolean,
|
|
31
|
+
deserialize: (raw) => webStorage_utils.parseBooleanString(raw, 'Invalid sidebar collapsed value'),
|
|
32
|
+
validate: webStorage_utils.isBoolean,
|
|
126
33
|
});
|
|
127
34
|
|
|
128
35
|
exports.LOCAL_STORAGE_KEYS = localStorageUtils_constants.LOCAL_STORAGE_KEYS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":["LOCAL_STORAGE_KEYS"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":["createWebStorageItem","LOCAL_STORAGE_KEYS","parseBooleanString","isBoolean"],"mappings":";;;;;AAAA;;;;;;;;;AASG;AA2BH;;;;;;;AAOG;AACI,MAAM,sBAAsB,GAAG,CAAI,GAAW,EAAE,OAAA,GAAsC,EAAE,KAC7FA,qCAAoB,CAAC,MAAM,MAAM,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO;AAE9D;;;AAGG;MACU,uBAAuB,GAAG,sBAAsB,CAAUC,8CAAkB,CAAC,gBAAgB,EAAE;AAC1G,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAKC,mCAAkB,CAAC,GAAG,EAAE,iCAAiC,CAAC;AAChF,IAAA,QAAQ,EAAEC,0BAAS;AACpB,CAAA;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Web-only, typed `localStorage` persistence.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Web-only, typed `localStorage` persistence. Thin wrapper over the shared
|
|
3
|
+
* `#internal/utilities/webStorageUtils` factory (which `sessionStorageUtils`
|
|
4
|
+
* also uses — the two modules were byte-identical twins before the factory).
|
|
5
|
+
* Every helper no-ops / returns `null` when `localStorage` is unavailable
|
|
6
|
+
* (SSR, React Native, private mode, quota errors).
|
|
7
7
|
*
|
|
8
8
|
* Every key this package persists is registered in `localStorageUtils.constants.ts`
|
|
9
9
|
* — check there for the full list before adding a new one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/localStorageUtils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAI9B,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,gFAAgF;IAChF,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChB,wEAAwE;IACxE,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,CAAC;IACjC,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,UAAS,uBAAuB,CAAC,CAAC,CAAM,KAAG,gBAAgB,CAAC,CAAC,CACrD,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,2BAIlC,CAAC"}
|
|
@@ -1,73 +1,16 @@
|
|
|
1
|
+
import { createWebStorageItem, isBoolean, parseBooleanString } from '../__internal__/webStorageUtils/webStorage.utils.js';
|
|
1
2
|
import { LOCAL_STORAGE_KEYS } from './localStorageUtils.constants.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
* Web-only, typed `localStorage` persistence.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Web-only, typed `localStorage` persistence. Thin wrapper over the shared
|
|
6
|
+
* `#internal/utilities/webStorageUtils` factory (which `sessionStorageUtils`
|
|
7
|
+
* also uses — the two modules were byte-identical twins before the factory).
|
|
8
|
+
* Every helper no-ops / returns `null` when `localStorage` is unavailable
|
|
9
|
+
* (SSR, React Native, private mode, quota errors).
|
|
9
10
|
*
|
|
10
11
|
* Every key this package persists is registered in `localStorageUtils.constants.ts`
|
|
11
12
|
* — check there for the full list before adding a new one.
|
|
12
13
|
*/
|
|
13
|
-
const isBrowser = typeof window !== 'undefined';
|
|
14
|
-
/**
|
|
15
|
-
* Internal `localStorage` primitives backing `createLocalStorageItem`. Not
|
|
16
|
-
* exported — everything a consumer needs goes through `createLocalStorageItem`,
|
|
17
|
-
* which adds typed serialization/validation on top. Add a raw string export
|
|
18
|
-
* here only once a real caller needs plain-string storage without JSON typing.
|
|
19
|
-
*/
|
|
20
|
-
/** Read a raw string value, or `null` when unset/unavailable. */
|
|
21
|
-
const safeLocalGet = (key) => {
|
|
22
|
-
if (!isBrowser)
|
|
23
|
-
return null;
|
|
24
|
-
try {
|
|
25
|
-
return window.localStorage.getItem(key);
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
/** Persist a raw string value; returns whether the write succeeded. */
|
|
32
|
-
const safeLocalSet = (key, value) => {
|
|
33
|
-
if (!isBrowser)
|
|
34
|
-
return false;
|
|
35
|
-
try {
|
|
36
|
-
window.localStorage.setItem(key, value);
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
/** Remove a value; returns whether the removal succeeded. */
|
|
44
|
-
const safeLocalRemove = (key) => {
|
|
45
|
-
if (!isBrowser)
|
|
46
|
-
return false;
|
|
47
|
-
try {
|
|
48
|
-
window.localStorage.removeItem(key);
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Reusable `validate` guard for a `createLocalStorageItem<boolean>` item.
|
|
57
|
-
*/
|
|
58
|
-
const isBoolean = (value) => typeof value === 'boolean';
|
|
59
|
-
/**
|
|
60
|
-
* Parse a plain `'true'`/`'false'` string (not JSON) into a boolean; throws
|
|
61
|
-
* `errorMessage` for anything else so `createLocalStorageItem.get()` treats it
|
|
62
|
-
* as invalid data and returns `null`.
|
|
63
|
-
*/
|
|
64
|
-
const parseBooleanString = (raw, errorMessage) => {
|
|
65
|
-
if (raw === 'true')
|
|
66
|
-
return true;
|
|
67
|
-
if (raw === 'false')
|
|
68
|
-
return false;
|
|
69
|
-
throw new Error(errorMessage);
|
|
70
|
-
};
|
|
71
14
|
/**
|
|
72
15
|
* Build a typed, failure-safe accessor for a single `localStorage` key.
|
|
73
16
|
*
|
|
@@ -76,43 +19,7 @@ const parseBooleanString = (raw, errorMessage) => {
|
|
|
76
19
|
* draft.set({ title: 'Hi' });
|
|
77
20
|
* const value = draft.get(); // Draft | null
|
|
78
21
|
*/
|
|
79
|
-
const createLocalStorageItem = (key, options = {}) =>
|
|
80
|
-
const { serialize = JSON.stringify, deserialize = JSON.parse, validate } = options;
|
|
81
|
-
return {
|
|
82
|
-
get() {
|
|
83
|
-
const raw = safeLocalGet(key);
|
|
84
|
-
if (raw == null)
|
|
85
|
-
return null;
|
|
86
|
-
try {
|
|
87
|
-
const value = deserialize(raw);
|
|
88
|
-
if (validate && !validate(value))
|
|
89
|
-
return null;
|
|
90
|
-
return value;
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
set(value) {
|
|
97
|
-
try {
|
|
98
|
-
const serialized = serialize(value);
|
|
99
|
-
// JSON.stringify (and a custom serializer) can return `undefined` for a
|
|
100
|
-
// top-level `undefined`, function, or symbol — treat that as a failed
|
|
101
|
-
// serialization rather than writing the literal string "undefined".
|
|
102
|
-
if (typeof serialized !== 'string')
|
|
103
|
-
return;
|
|
104
|
-
safeLocalSet(key, serialized);
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
// serialize() can throw (e.g. circular refs); matches the documented
|
|
108
|
-
// failure-safe contract — silently ignore, same as a write failure.
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
clear() {
|
|
112
|
-
safeLocalRemove(key);
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
};
|
|
22
|
+
const createLocalStorageItem = (key, options = {}) => createWebStorageItem(() => window.localStorage, key, options);
|
|
116
23
|
/**
|
|
117
24
|
* Persistence for the `SidebarNavigation` collapsed preference. Stored as the
|
|
118
25
|
* plain strings `'true'` / `'false'` to preserve the original on-disk format.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/localStorageUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;AASG;AA2BH;;;;;;;AAOG;AACI,MAAM,sBAAsB,GAAG,CAAI,GAAW,EAAE,OAAA,GAAsC,EAAE,KAC7F,oBAAoB,CAAC,MAAM,MAAM,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO;AAE9D;;;AAGG;MACU,uBAAuB,GAAG,sBAAsB,CAAU,kBAAkB,CAAC,gBAAgB,EAAE;AAC1G,IAAA,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,GAAG,KAAK,kBAAkB,CAAC,GAAG,EAAE,iCAAiC,CAAC;AAChF,IAAA,QAAQ,EAAE,SAAS;AACpB,CAAA;;;;"}
|
|
@@ -14,18 +14,13 @@ const getEnvironmentVariable = (key) => {
|
|
|
14
14
|
if (typeof process !== 'undefined' && process.env && typeof process.env[key] === 'string') {
|
|
15
15
|
return process.env[key];
|
|
16
16
|
}
|
|
17
|
-
// Fallback to Vite env when available
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return viteEnv?.[key] ?? '';
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return '';
|
|
28
|
-
}
|
|
17
|
+
// Fallback to Vite env when available. Written as bare `import.meta.env` — legal in
|
|
18
|
+
// the ESM build and in Vite/Vitest — and rewritten to `undefined` in the CJS output
|
|
19
|
+
// by the `import-meta-env-cjs-safe` plugin in rollup.config.js, where `import.meta`
|
|
20
|
+
// would be a parse error. No eval: strict-CSP consumers (no `unsafe-eval`) previously
|
|
21
|
+
// lost this path silently.
|
|
22
|
+
const viteEnv = undefined;
|
|
23
|
+
return viteEnv?.[key] ?? '';
|
|
29
24
|
};
|
|
30
25
|
/**
|
|
31
26
|
* Retrieves a micro-frontend attribute.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":["lazy","importWithRetry"],"mappings":";;;;;AAIA;;;;;AAKG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAW,KAAY;;AAE5D,IAAA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;AACzF,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW;IACnC
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":["lazy","importWithRetry"],"mappings":";;;;;AAIA;;;;;AAKG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAW,KAAY;;AAE5D,IAAA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,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,MAAM,aAAa,GAAG,CAAC,eAA0B,KAAKA,UAAI,CAAC,MAAMC,qCAAe,CAAC,eAAe,CAAC;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/renderUtils/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/renderUtils/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,MAYpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,KAAK,MAAM,KAAG,MAMvD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAAO,MAE3B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAAO,MAE3B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,QAAO,OAMrC,CAAC;AAGF,eAAO,MAAM,aAAa,GAAI,iBAAiB,MAAM,GAAG,4EAAiD,CAAC"}
|
|
@@ -12,18 +12,13 @@ const getEnvironmentVariable = (key) => {
|
|
|
12
12
|
if (typeof process !== 'undefined' && process.env && typeof process.env[key] === 'string') {
|
|
13
13
|
return process.env[key];
|
|
14
14
|
}
|
|
15
|
-
// Fallback to Vite env when available
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return viteEnv?.[key] ?? '';
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return '';
|
|
26
|
-
}
|
|
15
|
+
// Fallback to Vite env when available. Written as bare `import.meta.env` — legal in
|
|
16
|
+
// the ESM build and in Vite/Vitest — and rewritten to `undefined` in the CJS output
|
|
17
|
+
// by the `import-meta-env-cjs-safe` plugin in rollup.config.js, where `import.meta`
|
|
18
|
+
// would be a parse error. No eval: strict-CSP consumers (no `unsafe-eval`) previously
|
|
19
|
+
// lost this path silently.
|
|
20
|
+
const viteEnv = import.meta.env;
|
|
21
|
+
return viteEnv?.[key] ?? '';
|
|
27
22
|
};
|
|
28
23
|
/**
|
|
29
24
|
* Retrieves a micro-frontend attribute.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;;;AAKG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAW,KAAY;;AAE5D,IAAA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;AACzF,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW;IACnC
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utilities/renderUtils/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;;;AAKG;AACI,MAAM,sBAAsB,GAAG,CAAC,GAAW,KAAY;;AAE5D,IAAA,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;AACzF,QAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW;IACnC;;;;;;AAMA,IAAA,MAAM,OAAO,GAAI,MAAM,CAAC,IAAkE,CAAC,GAAG;AAC9F,IAAA,OAAO,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE;AAC7B;AAEA;;;;;AAKG;AACI,MAAM,yBAAyB,GAAG,CAAC,GAAW,KAAY;AAC/D,IAAA,IA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