@lmvz-ds/components 0.18.2 → 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/CHANGELOG.md +16 -0
- package/README.md +45 -100
- package/assets/icons/checkmark.svg +4 -0
- package/cjs/{aria-loader-CfFuAbJn.js → aria-loader-Cec1zR2g.js} +1 -1
- package/cjs/ds.constants-DSnxZ3ia.js +16 -0
- package/cjs/icons-BQASWgk-.js +80 -0
- package/cjs/{index--7IqZZqn.js → index-3g9Z9sfF.js} +765 -2854
- package/cjs/index.cjs.js +12 -12
- package/cjs/lmvz-button.cjs.entry.js +4 -4
- package/cjs/lmvz-card.cjs.entry.js +1 -1
- package/cjs/lmvz-checkbox.cjs.entry.js +113 -0
- package/cjs/lmvz-chip.cjs.entry.js +68 -4
- package/cjs/lmvz-components.cjs.js +1 -1
- package/cjs/lmvz-header_2.cjs.entry.js +3 -3
- package/cjs/lmvz-icon.cjs.entry.js +10 -8
- package/cjs/lmvz-input.cjs.entry.js +4 -4
- package/cjs/lmvz-menuitem.cjs.entry.js +4 -4
- package/cjs/lmvz-select.cjs.entry.js +3 -3
- package/cjs/loader.cjs.js +1 -1
- package/cjs/{logger-Bn2yoZGP.js → logger-DsM6xg6V.js} +3063 -833
- package/cjs/{reactive-controller-host-CtaVAiYJ.js → reactive-controller-host-BA4ZhjKA.js} +10 -10
- package/cjs/svg-BMBduILB.js +125 -0
- package/collection/api/ds.constants.js +2 -0
- package/collection/assets/icons/checkmark.svg +4 -0
- package/collection/collection-manifest.json +1 -0
- package/collection/components/lmvz-button/lmvz-button.css +1 -2
- package/collection/components/lmvz-button/lmvz-button.js +6 -3
- package/collection/components/lmvz-card/lmvz-card.css +1 -2
- package/collection/components/lmvz-checkbox/lmvz-checkbox.css +207 -0
- package/collection/components/lmvz-checkbox/lmvz-checkbox.js +424 -0
- package/collection/components/lmvz-chip/lmvz-chip.css +84 -1
- package/collection/components/lmvz-chip/lmvz-chip.js +110 -13
- package/collection/components/lmvz-header/lmvz-header.js +2 -2
- package/collection/components/lmvz-icon/lmvz-icon.css +11 -10
- package/collection/components/lmvz-icon/lmvz-icon.js +8 -7
- package/collection/components/lmvz-input/lmvz-input.js +4 -4
- package/collection/components/lmvz-menuitem/lmvz-menuitem.css +1 -1
- package/collection/components/lmvz-menuitem/lmvz-menuitem.js +11 -5
- package/collection/components/lmvz-select/lmvz-select.js +1 -1
- package/collection/index.js +1 -1
- package/collection/integration/header-integration/header-integration.js +1 -1
- package/collection/utils/aria/aria-validation-controller.js +1 -0
- package/collection/utils/icons/icons.js +2 -13
- package/collection/utils/icons/icons.unit.js +3 -15
- package/collection/utils/reactive-controller-host.js +9 -9
- package/components/index.d.ts +2 -0
- package/components/index.d.ts.bak +2 -0
- package/components/index.js +1 -1
- package/components/lmvz-button.js +1 -1
- package/components/lmvz-card.js +1 -1
- package/components/lmvz-checkbox.d.ts +11 -0
- package/components/lmvz-checkbox.d.ts.bak +11 -0
- package/components/lmvz-checkbox.js +1 -0
- package/components/lmvz-chip.js +1 -1
- package/components/lmvz-header.js +1 -1
- package/components/lmvz-icon.js +1 -1
- package/components/lmvz-input.js +1 -1
- package/components/lmvz-menuitem.js +1 -1
- package/components/lmvz-select.js +1 -1
- package/components/p-0s99QfRy.js +12 -0
- package/components/{p-CBLAeife.js → p-BuFx0tTm.js} +1 -1
- package/components/p-CGmJG63p.js +1 -0
- package/components/p-CcxjkCOx.js +1 -0
- package/components/{p-DQEkWkMh.js → p-DIrAQ4IB.js} +1 -1
- package/esm/{aria-loader-BF_AYtbb.js → aria-loader-BVolm0lC.js} +1 -1
- package/esm/ds.constants-Bmi89ll1.js +9 -0
- package/esm/icons-CmuFKDRz.js +75 -0
- package/esm/{index-7Ru1khgk.js → index-Dh_9sN0q.js} +389 -2478
- package/esm/index.js +5 -11
- package/esm/lmvz-button.entry.js +4 -4
- package/esm/lmvz-card.entry.js +1 -1
- package/esm/lmvz-checkbox.entry.js +111 -0
- package/esm/lmvz-chip.entry.js +69 -5
- package/esm/lmvz-components.js +1 -1
- package/esm/lmvz-header_2.entry.js +3 -3
- package/esm/lmvz-icon.entry.js +10 -8
- package/esm/lmvz-input.entry.js +4 -4
- package/esm/lmvz-menuitem.entry.js +4 -4
- package/esm/lmvz-select.entry.js +3 -3
- package/esm/loader.js +1 -1
- package/esm/{logger-fiRXhuXK.js → logger-CGmJG63p.js} +2870 -765
- package/esm/{reactive-controller-host-sR2jJxNG.js → reactive-controller-host-DHcPpJW7.js} +10 -10
- package/esm/svg-B2YoIRuh.js +121 -0
- package/hydrate/index.js +2383 -42
- package/hydrate/index.mjs +2383 -42
- package/lmvz-components/index.esm.js +1 -1
- package/lmvz-components/lmvz-components.esm.js +1 -1
- package/lmvz-components/{p-5aa17cd2.entry.js → p-0f7a4236.entry.js} +1 -1
- package/lmvz-components/p-0s99QfRy.js +12 -0
- package/lmvz-components/{p-30b99f11.entry.js → p-2f83d7a2.entry.js} +1 -1
- package/lmvz-components/{p-6dbb3f13.entry.js → p-32171f4f.entry.js} +1 -1
- package/lmvz-components/{p-59383f3a.entry.js → p-400b2318.entry.js} +1 -1
- package/lmvz-components/p-851969bd.entry.js +1 -0
- package/lmvz-components/p-9f9d845d.entry.js +1 -0
- package/lmvz-components/p-Bmi89ll1.js +1 -0
- package/lmvz-components/p-CFsC37ww.js +1 -0
- package/lmvz-components/p-CGmJG63p.js +1 -0
- package/lmvz-components/p-CcxjkCOx.js +1 -0
- package/lmvz-components/{p-Bkfdgg0T.js → p-GdMr6Qlp.js} +1 -1
- package/lmvz-components/p-a12f95da.entry.js +1 -0
- package/lmvz-components/{p-84267405.entry.js → p-ab4437dc.entry.js} +1 -1
- package/lmvz-components/{p-7a6bec13.entry.js → p-d0a0e206.entry.js} +1 -1
- package/lmvz-components/{p-B3dnXEPG.js → p-dhVSUYqd.js} +1 -1
- package/manifest.json +544 -28
- package/package.json +5 -1
- package/types/api/ds.constants.d.ts +6 -1
- package/types/components/lmvz-action/lmvz-action.d.ts +0 -1
- package/types/components/lmvz-button/lmvz-button.d.ts +0 -1
- package/types/components/lmvz-card/lmvz-card.d.ts +0 -1
- package/types/components/lmvz-checkbox/lmvz-checkbox.d.ts +39 -0
- package/types/components/lmvz-chip/lmvz-chip.d.ts +18 -3
- package/types/components/lmvz-header/lmvz-header.d.ts +0 -1
- package/types/components/lmvz-icon/lmvz-icon.d.ts +0 -1
- package/types/components/lmvz-input/lmvz-input.d.ts +0 -1
- package/types/components/lmvz-menuitem/lmvz-menuitem.d.ts +0 -1
- package/types/components/lmvz-select/lmvz-select.d.ts +0 -1
- package/types/components.d.ts +221 -12
- package/types/index.d.ts +1 -2
- package/types/utils/aria/aria-validation-controller.d.ts +1 -2
- package/types/utils/aria/element-activation-controller.d.ts +0 -1
- package/types/utils/aria/list-keyboard-controller.d.ts +0 -1
- package/types/utils/assets.d.ts +0 -1
- package/types/utils/component.d.ts +0 -1
- package/types/utils/environment.d.ts +0 -1
- package/types/utils/http.d.ts +0 -1
- package/types/utils/http.unit.d.ts +0 -1
- package/types/utils/icons/icons-registry.d.ts +0 -1
- package/types/utils/icons/icons.d.ts +0 -2
- package/types/utils/icons/icons.unit.d.ts +0 -1
- package/types/utils/icons/public.d.ts +0 -1
- package/types/utils/public.d.ts +0 -1
- package/types/utils/reactive-controller-host.d.ts +0 -1
- package/cjs/icons-swqMn6s2.js +0 -163
- package/components/p-DXOTa5VF.js +0 -12
- package/components/p-fiRXhuXK.js +0 -1
- package/esm/icons-Ca8oMiRa.js +0 -157
- package/lmvz-components/p-0a41cc24.entry.js +0 -1
- package/lmvz-components/p-5f150890.entry.js +0 -1
- package/lmvz-components/p-Bh2Epkwf.js +0 -1
- package/lmvz-components/p-DXOTa5VF.js +0 -12
- package/lmvz-components/p-fiRXhuXK.js +0 -1
package/hydrate/index.js
CHANGED
|
@@ -4153,7 +4153,7 @@ var braceExpand = (pattern, options = {}) => {
|
|
|
4153
4153
|
minimatch.braceExpand = braceExpand;
|
|
4154
4154
|
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
4155
4155
|
minimatch.makeRe = makeRe;
|
|
4156
|
-
var match = (list, pattern, options = {}) => {
|
|
4156
|
+
var match$1 = (list, pattern, options = {}) => {
|
|
4157
4157
|
const mm = new Minimatch(pattern, options);
|
|
4158
4158
|
list = list.filter((f) => mm.match(f));
|
|
4159
4159
|
if (mm.options.nonull && !list.length) {
|
|
@@ -4161,7 +4161,7 @@ var match = (list, pattern, options = {}) => {
|
|
|
4161
4161
|
}
|
|
4162
4162
|
return list;
|
|
4163
4163
|
};
|
|
4164
|
-
minimatch.match = match;
|
|
4164
|
+
minimatch.match = match$1;
|
|
4165
4165
|
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
4166
4166
|
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
4167
4167
|
var _Minimatch_instances, matchGlobstar_fn, matchGlobStarBodySections_fn, matchOne_fn;
|
|
@@ -5483,9 +5483,6 @@ function resolvePossiblyAsyncFunction(func, args = []) {
|
|
|
5483
5483
|
return Promise.resolve(res);
|
|
5484
5484
|
}
|
|
5485
5485
|
|
|
5486
|
-
const hasProcessStdout = typeof process === "object" && process !== null && typeof process.stdout === "object" && process.stdout !== null;
|
|
5487
|
-
hasProcessStdout && process.stdout.isTTY === true;
|
|
5488
|
-
|
|
5489
5486
|
const GLOBAL_STATE_KEY = Symbol('LMVZ__ariaValidationRuntimeState');
|
|
5490
5487
|
const ARIA_VALIDATION_RUNTIME_CHANGED_EVENT = 'lmvz:aria-validation-runtime-changed';
|
|
5491
5488
|
function getRuntimeState() {
|
|
@@ -5820,38 +5817,38 @@ class ReactiveControllerHost {
|
|
|
5820
5817
|
this.controllers.delete(controller);
|
|
5821
5818
|
}
|
|
5822
5819
|
get activeControllers() {
|
|
5823
|
-
return Array.from(this.controllers).filter(controller => !controller.disabled);
|
|
5820
|
+
return Array.from(this.controllers).filter((controller) => !controller.disabled);
|
|
5824
5821
|
}
|
|
5825
5822
|
connectedCallback() {
|
|
5826
5823
|
if (!this.controllers.size) {
|
|
5827
5824
|
console.warn('ReactiveControllerHost connected with no controllers registered.', this);
|
|
5828
5825
|
}
|
|
5829
|
-
this.activeControllers.forEach(controller => controller.hostConnected?.());
|
|
5826
|
+
this.activeControllers.forEach((controller) => controller.hostConnected?.());
|
|
5830
5827
|
}
|
|
5831
5828
|
disconnectedCallback() {
|
|
5832
|
-
this.activeControllers.forEach(controller => controller.hostDisconnected?.());
|
|
5829
|
+
this.activeControllers.forEach((controller) => controller.hostDisconnected?.());
|
|
5833
5830
|
}
|
|
5834
5831
|
componentWillLoad() {
|
|
5835
|
-
this.activeControllers.forEach(controller => controller.hostWillLoad?.());
|
|
5832
|
+
this.activeControllers.forEach((controller) => controller.hostWillLoad?.());
|
|
5836
5833
|
}
|
|
5837
5834
|
componentDidLoad() {
|
|
5838
|
-
this.activeControllers.forEach(controller => controller.hostDidLoad?.());
|
|
5835
|
+
this.activeControllers.forEach((controller) => controller.hostDidLoad?.());
|
|
5839
5836
|
}
|
|
5840
5837
|
componentWillRender() {
|
|
5841
|
-
this.activeControllers.forEach(controller => controller.hostWillRender?.());
|
|
5838
|
+
this.activeControllers.forEach((controller) => controller.hostWillRender?.());
|
|
5842
5839
|
}
|
|
5843
5840
|
componentDidRender() {
|
|
5844
|
-
this.activeControllers.forEach(controller => controller.hostDidRender?.());
|
|
5841
|
+
this.activeControllers.forEach((controller) => controller.hostDidRender?.());
|
|
5845
5842
|
}
|
|
5846
5843
|
componentWillUpdate() {
|
|
5847
|
-
this.activeControllers.forEach(controller => controller.hostWillUpdate?.());
|
|
5844
|
+
this.activeControllers.forEach((controller) => controller.hostWillUpdate?.());
|
|
5848
5845
|
}
|
|
5849
5846
|
componentDidUpdate() {
|
|
5850
|
-
this.activeControllers.forEach(controller => controller.hostDidUpdate?.());
|
|
5847
|
+
this.activeControllers.forEach((controller) => controller.hostDidUpdate?.());
|
|
5851
5848
|
}
|
|
5852
5849
|
}
|
|
5853
5850
|
|
|
5854
|
-
const lmvzButtonCss = () => ` @layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } @layer lmvz-ds.reset { body { margin: 0; } h1, h2, h3, h4, h5, h6 { margin: 0; } } :host { button { --lmvz-button-color: var(--lmvz-component-color, var(--lmvz-semantic-color-int-on-primary, #ffffff)); --lmvz-button-padding-inline: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-padding-block: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); --lmvz-button-radius: var(--lmvz-component-input-radius-default, 999px); --lmvz-button-border-width: 0; --lmvz-button-border-color: transparent; --lmvz-button-background: var(--lmvz-semantic-color-int-primary, #000000); display: inline-flex; align-items: center; justify-content: center; gap: var(--lmvz-button-gap); padding-block: var(--lmvz-button-padding-block); padding-inline: var(--lmvz-button-padding-inline); border-radius: var(--lmvz-button-radius); border: var(--lmvz-button-border-width) solid var(--lmvz-button-border-color); background-color: var(--lmvz-button-background); color: var(--lmvz-button-color); cursor: pointer; font: var(--lmvz-button-font); text-align: center; text-decoration: none; white-space: nowrap; transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; } button > * { font: inherit; color: inherit; } button:focus-visible {
|
|
5851
|
+
const lmvzButtonCss = () => ` @layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } @layer lmvz-ds.reset { body { margin: 0; } h1, h2, h3, h4, h5, h6 { margin: 0; } } :host { button { --lmvz-button-color: var(--lmvz-component-color, var(--lmvz-semantic-color-int-on-primary, #ffffff)); --lmvz-button-padding-inline: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-padding-block: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); --lmvz-button-radius: var(--lmvz-component-input-radius-default, 999px); --lmvz-button-border-width: 0; --lmvz-button-border-color: transparent; --lmvz-button-background: var(--lmvz-semantic-color-int-primary, #000000); display: inline-flex; align-items: center; justify-content: center; gap: var(--lmvz-button-gap); padding-block: var(--lmvz-button-padding-block); padding-inline: var(--lmvz-button-padding-inline); border-radius: var(--lmvz-button-radius); border: var(--lmvz-button-border-width) solid var(--lmvz-button-border-color); background-color: var(--lmvz-button-background); color: var(--lmvz-button-color); cursor: pointer; font: var(--lmvz-button-font); text-align: center; text-decoration: none; white-space: nowrap; transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; } button > * { font: inherit; color: inherit; } button:focus-visible { outline: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-status-on-active, #0e7ab4); outline-offset: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); } button:is([disabled], .disabled) { cursor: not-allowed; pointer-events: none; opacity: var(--lmvz-component-input-disabled-opacity, 40%); } button:not([disabled]):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-primary-hover, #2e2e2e); } button:not([disabled]):active { --lmvz-button-background: var(--lmvz-semantic-color-int-primary-active, #545454); } button.secondary { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary, #f0f0f0); --lmvz-button-color: var(--lmvz-semantic-color-int-on-secondary, #000000); --lmvz-button-border-width: var(--lmvz-semantic-border-width-default, 1px); --lmvz-button-border-color: var(--lmvz-semantic-color-border-default, #e0e0e0); } button.secondary:not([disabled], .disabled):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-hover, #e0e0e0); --lmvz-button-border-color: var(--lmvz-semantic-color-border-hover, #c7c7c7); } button.secondary:not([disabled], .disabled):active { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-active, #d4d4d4); --lmvz-button-border-color: var(--lmvz-semantic-color-border-active, #0f8acc); } button.tertiary { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary, #ffffff); --lmvz-button-color: var(--lmvz-semantic-color-int-on-tertiary, #545454); } button.tertiary:not([disabled], .disabled):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0); } button.tertiary:not([disabled], .disabled):active { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-active, #e0e0e0); } button.small { --lmvz-button-padding-inline: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); --lmvz-button-padding-block: var(--lmvz-component-input-sm-padding-y, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); --lmvz-button-gap: var(--lmvz-component-input-sm-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); } button.large { --lmvz-button-padding-inline: var(--lmvz-component-input-lg-padding-x, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem)); --lmvz-button-padding-block: var(--lmvz-component-input-lg-padding-y, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem)); --lmvz-button-gap: var(--lmvz-component-input-lg-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); } display: contents; } ::slotted(*) { --lmvz-component-color: var(--lmvz-button-color); } `;
|
|
5855
5852
|
|
|
5856
5853
|
class LmvzButton extends ReactiveControllerHost {
|
|
5857
5854
|
get el() { return getElement(this); }
|
|
@@ -5908,7 +5905,7 @@ class LmvzButton extends ReactiveControllerHost {
|
|
|
5908
5905
|
};
|
|
5909
5906
|
render() {
|
|
5910
5907
|
this.renderHiddenButton();
|
|
5911
|
-
return (hAsync(Host, { key: '
|
|
5908
|
+
return (hAsync(Host, { key: 'ce82e749ffb9172a9421d303e0d7cc02de58dff9', "aria-disabled": this.disabled ? 'true' : null }, hAsync("button", { key: 'acd0773f72e76139ec5495eb15fc3a5949029e40', ref: (e) => (this.validationEl = e), disabled: this.disabled, class: classNames(this.variant, { [this.scale ?? '']: !!this.scale, disabled: this.disabled }), ...this.inheritedAttributes }, hAsync("slot", { key: 'f519e0f82e68811a8831214e83e609bd9501fed0' }))));
|
|
5912
5909
|
}
|
|
5913
5910
|
static get delegatesFocus() { return true; }
|
|
5914
5911
|
static get style() { return lmvzButtonCss(); }
|
|
@@ -5949,7 +5946,7 @@ function joinPath(...parts) {
|
|
|
5949
5946
|
return parts.filter(Boolean).join('/').replace('//', '/').replace('/./', '/');
|
|
5950
5947
|
}
|
|
5951
5948
|
|
|
5952
|
-
const lmvzCardCss = () => `@layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } @layer lmvz-ds.reset { body { margin: 0; } h1, h2, h3, h4, h5, h6 { margin: 0; } } .sc-lmvz-card-h { button { --lmvz-button-color: var(--lmvz-component-color, var(--lmvz-semantic-color-int-on-primary, #ffffff)); --lmvz-button-padding-inline: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-padding-block: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); --lmvz-button-radius: var(--lmvz-component-input-radius-default, 999px); --lmvz-button-border-width: 0; --lmvz-button-border-color: transparent; --lmvz-button-background: var(--lmvz-semantic-color-int-primary, #000000); display: inline-flex; align-items: center; justify-content: center; gap: var(--lmvz-button-gap); padding-block: var(--lmvz-button-padding-block); padding-inline: var(--lmvz-button-padding-inline); border-radius: var(--lmvz-button-radius); border: var(--lmvz-button-border-width) solid var(--lmvz-button-border-color); background-color: var(--lmvz-button-background); color: var(--lmvz-button-color); cursor: pointer; font: var(--lmvz-button-font); text-align: center; text-decoration: none; white-space: nowrap; transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; } button > * { font: inherit; color: inherit; } button:focus-visible {
|
|
5949
|
+
const lmvzCardCss = () => `@layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } @layer lmvz-ds.reset { body { margin: 0; } h1, h2, h3, h4, h5, h6 { margin: 0; } } .sc-lmvz-card-h { button { --lmvz-button-color: var(--lmvz-component-color, var(--lmvz-semantic-color-int-on-primary, #ffffff)); --lmvz-button-padding-inline: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-padding-block: var(--lmvz-button-padding, var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))); --lmvz-button-gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); --lmvz-button-radius: var(--lmvz-component-input-radius-default, 999px); --lmvz-button-border-width: 0; --lmvz-button-border-color: transparent; --lmvz-button-background: var(--lmvz-semantic-color-int-primary, #000000); display: inline-flex; align-items: center; justify-content: center; gap: var(--lmvz-button-gap); padding-block: var(--lmvz-button-padding-block); padding-inline: var(--lmvz-button-padding-inline); border-radius: var(--lmvz-button-radius); border: var(--lmvz-button-border-width) solid var(--lmvz-button-border-color); background-color: var(--lmvz-button-background); color: var(--lmvz-button-color); cursor: pointer; font: var(--lmvz-button-font); text-align: center; text-decoration: none; white-space: nowrap; transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; } button > * { font: inherit; color: inherit; } button:focus-visible { outline: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-status-on-active, #0e7ab4); outline-offset: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); } button:is([disabled], .disabled) { cursor: not-allowed; pointer-events: none; opacity: var(--lmvz-component-input-disabled-opacity, 40%); } button:not([disabled]):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-primary-hover, #2e2e2e); } button:not([disabled]):active { --lmvz-button-background: var(--lmvz-semantic-color-int-primary-active, #545454); } button.secondary { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary, #f0f0f0); --lmvz-button-color: var(--lmvz-semantic-color-int-on-secondary, #000000); --lmvz-button-border-width: var(--lmvz-semantic-border-width-default, 1px); --lmvz-button-border-color: var(--lmvz-semantic-color-border-default, #e0e0e0); } button.secondary:not([disabled], .disabled):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-hover, #e0e0e0); --lmvz-button-border-color: var(--lmvz-semantic-color-border-hover, #c7c7c7); } button.secondary:not([disabled], .disabled):active { --lmvz-button-background: var(--lmvz-semantic-color-int-secondary-active, #d4d4d4); --lmvz-button-border-color: var(--lmvz-semantic-color-border-active, #0f8acc); } button.tertiary { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary, #ffffff); --lmvz-button-color: var(--lmvz-semantic-color-int-on-tertiary, #545454); } button.tertiary:not([disabled], .disabled):hover { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0); } button.tertiary:not([disabled], .disabled):active { --lmvz-button-background: var(--lmvz-semantic-color-int-tertiary-active, #e0e0e0); } button.small { --lmvz-button-padding-inline: var(--lmvz-component-input-sm-padding-x, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); --lmvz-button-padding-block: var(--lmvz-component-input-sm-padding-y, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); --lmvz-button-gap: var(--lmvz-component-input-sm-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); } button.large { --lmvz-button-padding-inline: var(--lmvz-component-input-lg-padding-x, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem)); --lmvz-button-padding-block: var(--lmvz-component-input-lg-padding-y, clamp(0.88rem, 0.78rem + 0.39vw, 1.25rem)); --lmvz-button-gap: var(--lmvz-component-input-lg-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); --lmvz-button-font: var(--lmvz-typography-body-lg, 400 clamp(1rem, 0.97rem + 0.13vw, 1.13rem) / 1.4 Router); } display: flex; min-width: var(--lmvz-card-component-card-minwidth, 20.4375rem); max-width: var(--lmvz-card-component-card-maxwidth, 21.6875rem); flex-direction: column; align-items: flex-start; border-radius: var(--lmvz-semantic-border-radius-lg, 14px); border: var(--lmvz-semantic-border-width-default, 1px) solid var(--lmvz-semantic-color-border-default, #e0e0e0); background: var(--lmvz-semantic-color-surface-primary, #ffffff); } *.sc-lmvz-card { color: var(--lmvz-semantic-color-on-surface-primary, #000000); font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); } .top.sc-lmvz-card { display: flex; padding: var(--lmvz-dimension-8-12, clamp(0.5rem, 0.44rem + 0.26vw, 0.75rem)); flex-direction: column; justify-content: center; align-items: center; align-self: stretch; } .bottom.sc-lmvz-card { display: flex; min-width: 150px; padding: var(--lmvz-dimension-4-6, clamp(0.25rem, 0.22rem + 0.13vw, 0.38rem)) var(--lmvz-dimension-10-14, clamp(0.63rem, 0.56rem + 0.26vw, 0.88rem)) var(--lmvz-dimension-10-14, clamp(0.63rem, 0.56rem + 0.26vw, 0.88rem)) var(--lmvz-dimension-10-14, clamp(0.63rem, 0.56rem + 0.26vw, 0.88rem)); flex-direction: column; align-items: flex-start; align-self: stretch; } .title.sc-lmvz-card { margin: 0; display: flex; justify-content: center; align-items: center; align-self: stretch; padding-bottom: var(--lmvz-global-s4, 4px); overflow-wrap: break-word; font: var(--lmvz-typography-heading-2xl, 500 clamp(2.25rem, 2.13rem + 0.52vw, 2.75rem) / 1.2 Router); } .description.sc-lmvz-card { display: flex; margin: 0; padding-bottom: var(--lmvz-component-body-sm-padding-bottom, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); align-items: flex-start; align-self: stretch; white-space: pre-line; font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); } .image-wrapper.sc-lmvz-card { aspect-ratio: 4 / 3; width: 100%; background-size: cover; background-position: center; flex: 1 0 0; align-self: stretch; border-radius: var(--lmvz-semantic-border-radius-md, 6px); } .actions.sc-lmvz-card { margin-top: var(--lmvz-component-form-wrapper-gap-y, clamp(1.13rem, 0.97rem + 0.65vw, 1.75rem)); display: flex; align-items: center; gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); align-self: stretch; } button.primary.sc-lmvz-card, lmvz-button.primary.sc-lmvz-card { display: flex; justify-content: center; align-items: center; gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); flex: 1 0 0; }`;
|
|
5953
5950
|
|
|
5954
5951
|
class LmvzCard {
|
|
5955
5952
|
constructor(hostRef) {
|
|
@@ -5993,26 +5990,2369 @@ class LmvzCard {
|
|
|
5993
5990
|
}; }
|
|
5994
5991
|
}
|
|
5995
5992
|
|
|
5996
|
-
|
|
5993
|
+
/**
|
|
5994
|
+
* Tests if a value is a `function`.
|
|
5995
|
+
*
|
|
5996
|
+
* @example
|
|
5997
|
+
* ```ts
|
|
5998
|
+
* import * as assert from "node:assert"
|
|
5999
|
+
* import { isFunction } from "effect/Predicate"
|
|
6000
|
+
*
|
|
6001
|
+
* assert.deepStrictEqual(isFunction(isFunction), true)
|
|
6002
|
+
* assert.deepStrictEqual(isFunction("function"), false)
|
|
6003
|
+
* ```
|
|
6004
|
+
*
|
|
6005
|
+
* @category guards
|
|
6006
|
+
* @since 2.0.0
|
|
6007
|
+
*/
|
|
6008
|
+
const isFunction$1 = input => typeof input === "function";
|
|
6009
|
+
/**
|
|
6010
|
+
* Creates a function that can be used in a data-last (aka `pipe`able) or
|
|
6011
|
+
* data-first style.
|
|
6012
|
+
*
|
|
6013
|
+
* The first parameter to `dual` is either the arity of the uncurried function
|
|
6014
|
+
* or a predicate that determines if the function is being used in a data-first
|
|
6015
|
+
* or data-last style.
|
|
6016
|
+
*
|
|
6017
|
+
* Using the arity is the most common use case, but there are some cases where
|
|
6018
|
+
* you may want to use a predicate. For example, if you have a function that
|
|
6019
|
+
* takes an optional argument, you can use a predicate to determine if the
|
|
6020
|
+
* function is being used in a data-first or data-last style.
|
|
6021
|
+
*
|
|
6022
|
+
* You can pass either the arity of the uncurried function or a predicate
|
|
6023
|
+
* which determines if the function is being used in a data-first or
|
|
6024
|
+
* data-last style.
|
|
6025
|
+
*
|
|
6026
|
+
* **Example** (Using arity to determine data-first or data-last style)
|
|
6027
|
+
*
|
|
6028
|
+
* ```ts
|
|
6029
|
+
* import { dual, pipe } from "effect/Function"
|
|
6030
|
+
*
|
|
6031
|
+
* const sum = dual<
|
|
6032
|
+
* (that: number) => (self: number) => number,
|
|
6033
|
+
* (self: number, that: number) => number
|
|
6034
|
+
* >(2, (self, that) => self + that)
|
|
6035
|
+
*
|
|
6036
|
+
* console.log(sum(2, 3)) // 5
|
|
6037
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
6038
|
+
* ```
|
|
6039
|
+
*
|
|
6040
|
+
* **Example** (Using call signatures to define the overloads)
|
|
6041
|
+
*
|
|
6042
|
+
* ```ts
|
|
6043
|
+
* import { dual, pipe } from "effect/Function"
|
|
6044
|
+
*
|
|
6045
|
+
* const sum: {
|
|
6046
|
+
* (that: number): (self: number) => number
|
|
6047
|
+
* (self: number, that: number): number
|
|
6048
|
+
* } = dual(2, (self: number, that: number): number => self + that)
|
|
6049
|
+
*
|
|
6050
|
+
* console.log(sum(2, 3)) // 5
|
|
6051
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
6052
|
+
* ```
|
|
6053
|
+
*
|
|
6054
|
+
* **Example** (Using a predicate to determine data-first or data-last style)
|
|
6055
|
+
*
|
|
6056
|
+
* ```ts
|
|
6057
|
+
* import { dual, pipe } from "effect/Function"
|
|
6058
|
+
*
|
|
6059
|
+
* const sum = dual<
|
|
6060
|
+
* (that: number) => (self: number) => number,
|
|
6061
|
+
* (self: number, that: number) => number
|
|
6062
|
+
* >(
|
|
6063
|
+
* (args) => args.length === 2,
|
|
6064
|
+
* (self, that) => self + that
|
|
6065
|
+
* )
|
|
6066
|
+
*
|
|
6067
|
+
* console.log(sum(2, 3)) // 5
|
|
6068
|
+
* console.log(pipe(2, sum(3))) // 5
|
|
6069
|
+
* ```
|
|
6070
|
+
*
|
|
6071
|
+
* @since 2.0.0
|
|
6072
|
+
*/
|
|
6073
|
+
const dual = function (arity, body) {
|
|
6074
|
+
if (typeof arity === "function") {
|
|
6075
|
+
return function () {
|
|
6076
|
+
if (arity(arguments)) {
|
|
6077
|
+
// @ts-expect-error
|
|
6078
|
+
return body.apply(this, arguments);
|
|
6079
|
+
}
|
|
6080
|
+
return self => body(self, ...arguments);
|
|
6081
|
+
};
|
|
6082
|
+
}
|
|
6083
|
+
switch (arity) {
|
|
6084
|
+
case 0:
|
|
6085
|
+
case 1:
|
|
6086
|
+
throw new RangeError(`Invalid arity ${arity}`);
|
|
6087
|
+
case 2:
|
|
6088
|
+
return function (a, b) {
|
|
6089
|
+
if (arguments.length >= 2) {
|
|
6090
|
+
return body(a, b);
|
|
6091
|
+
}
|
|
6092
|
+
return function (self) {
|
|
6093
|
+
return body(self, a);
|
|
6094
|
+
};
|
|
6095
|
+
};
|
|
6096
|
+
case 3:
|
|
6097
|
+
return function (a, b, c) {
|
|
6098
|
+
if (arguments.length >= 3) {
|
|
6099
|
+
return body(a, b, c);
|
|
6100
|
+
}
|
|
6101
|
+
return function (self) {
|
|
6102
|
+
return body(self, a, b);
|
|
6103
|
+
};
|
|
6104
|
+
};
|
|
6105
|
+
case 4:
|
|
6106
|
+
return function (a, b, c, d) {
|
|
6107
|
+
if (arguments.length >= 4) {
|
|
6108
|
+
return body(a, b, c, d);
|
|
6109
|
+
}
|
|
6110
|
+
return function (self) {
|
|
6111
|
+
return body(self, a, b, c);
|
|
6112
|
+
};
|
|
6113
|
+
};
|
|
6114
|
+
case 5:
|
|
6115
|
+
return function (a, b, c, d, e) {
|
|
6116
|
+
if (arguments.length >= 5) {
|
|
6117
|
+
return body(a, b, c, d, e);
|
|
6118
|
+
}
|
|
6119
|
+
return function (self) {
|
|
6120
|
+
return body(self, a, b, c, d);
|
|
6121
|
+
};
|
|
6122
|
+
};
|
|
6123
|
+
default:
|
|
6124
|
+
return function () {
|
|
6125
|
+
if (arguments.length >= arity) {
|
|
6126
|
+
// @ts-expect-error
|
|
6127
|
+
return body.apply(this, arguments);
|
|
6128
|
+
}
|
|
6129
|
+
const args = arguments;
|
|
6130
|
+
return function (self) {
|
|
6131
|
+
return body(self, ...args);
|
|
6132
|
+
};
|
|
6133
|
+
};
|
|
6134
|
+
}
|
|
6135
|
+
};
|
|
6136
|
+
/**
|
|
6137
|
+
* The identity function, i.e. A function that returns its input argument.
|
|
6138
|
+
*
|
|
6139
|
+
* @example
|
|
6140
|
+
* ```ts
|
|
6141
|
+
* import * as assert from "node:assert"
|
|
6142
|
+
* import { identity } from "effect/Function"
|
|
6143
|
+
*
|
|
6144
|
+
* assert.deepStrictEqual(identity(5), 5)
|
|
6145
|
+
* ```
|
|
6146
|
+
*
|
|
6147
|
+
* @since 2.0.0
|
|
6148
|
+
*/
|
|
6149
|
+
const identity = a => a;
|
|
6150
|
+
/**
|
|
6151
|
+
* Creates a constant value that never changes.
|
|
6152
|
+
*
|
|
6153
|
+
* This is useful when you want to pass a value to a higher-order function (a function that takes another function as its argument)
|
|
6154
|
+
* and want that inner function to always use the same value, no matter how many times it is called.
|
|
6155
|
+
*
|
|
6156
|
+
* @example
|
|
6157
|
+
* ```ts
|
|
6158
|
+
* import * as assert from "node:assert"
|
|
6159
|
+
* import { constant } from "effect/Function"
|
|
6160
|
+
*
|
|
6161
|
+
* const constNull = constant(null)
|
|
6162
|
+
*
|
|
6163
|
+
* assert.deepStrictEqual(constNull(), null)
|
|
6164
|
+
* assert.deepStrictEqual(constNull(), null)
|
|
6165
|
+
* ```
|
|
6166
|
+
*
|
|
6167
|
+
* @since 2.0.0
|
|
6168
|
+
*/
|
|
6169
|
+
const constant = value => () => value;
|
|
6170
|
+
/**
|
|
6171
|
+
* A thunk that returns always `undefined`.
|
|
6172
|
+
*
|
|
6173
|
+
* @example
|
|
6174
|
+
* ```ts
|
|
6175
|
+
* import * as assert from "node:assert"
|
|
6176
|
+
* import { constUndefined } from "effect/Function"
|
|
6177
|
+
*
|
|
6178
|
+
* assert.deepStrictEqual(constUndefined(), undefined)
|
|
6179
|
+
* ```
|
|
6180
|
+
*
|
|
6181
|
+
* @since 2.0.0
|
|
6182
|
+
*/
|
|
6183
|
+
const constUndefined = /*#__PURE__*/constant(undefined);
|
|
6184
|
+
/**
|
|
6185
|
+
* A thunk that returns always `void`.
|
|
6186
|
+
*
|
|
6187
|
+
* @example
|
|
6188
|
+
* ```ts
|
|
6189
|
+
* import * as assert from "node:assert"
|
|
6190
|
+
* import { constVoid } from "effect/Function"
|
|
6191
|
+
*
|
|
6192
|
+
* assert.deepStrictEqual(constVoid(), undefined)
|
|
6193
|
+
* ```
|
|
6194
|
+
*
|
|
6195
|
+
* @since 2.0.0
|
|
6196
|
+
*/
|
|
6197
|
+
const constVoid = constUndefined;
|
|
6198
|
+
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
6199
|
+
switch (arguments.length) {
|
|
6200
|
+
case 1:
|
|
6201
|
+
return a;
|
|
6202
|
+
case 2:
|
|
6203
|
+
return ab(a);
|
|
6204
|
+
case 3:
|
|
6205
|
+
return bc(ab(a));
|
|
6206
|
+
case 4:
|
|
6207
|
+
return cd(bc(ab(a)));
|
|
6208
|
+
case 5:
|
|
6209
|
+
return de(cd(bc(ab(a))));
|
|
6210
|
+
case 6:
|
|
6211
|
+
return ef(de(cd(bc(ab(a)))));
|
|
6212
|
+
case 7:
|
|
6213
|
+
return fg(ef(de(cd(bc(ab(a))))));
|
|
6214
|
+
case 8:
|
|
6215
|
+
return gh(fg(ef(de(cd(bc(ab(a)))))));
|
|
6216
|
+
case 9:
|
|
6217
|
+
return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
|
|
6218
|
+
default:
|
|
6219
|
+
{
|
|
6220
|
+
let ret = arguments[0];
|
|
6221
|
+
for (let i = 1; i < arguments.length; i++) {
|
|
6222
|
+
ret = arguments[i](ret);
|
|
6223
|
+
}
|
|
6224
|
+
return ret;
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
}
|
|
6228
|
+
|
|
6229
|
+
/**
|
|
6230
|
+
* The `GlobalValue` module ensures that a single instance of a value is created globally,
|
|
6231
|
+
* even when modules are imported multiple times (e.g., due to mixing CommonJS and ESM builds)
|
|
6232
|
+
* or during hot-reloading in development environments like Next.js or Remix.
|
|
6233
|
+
*
|
|
6234
|
+
* It achieves this by using a versioned global store, identified by a unique `Symbol` tied to
|
|
6235
|
+
* the current version of the `effect` library. The store holds values that are keyed by an identifier,
|
|
6236
|
+
* allowing the reuse of previously computed instances across imports or reloads.
|
|
6237
|
+
*
|
|
6238
|
+
* This pattern is particularly useful in scenarios where frequent reloading can cause services or
|
|
6239
|
+
* single-instance objects to be recreated unnecessarily, such as in development environments with hot-reloading.
|
|
6240
|
+
*
|
|
6241
|
+
* @since 2.0.0
|
|
6242
|
+
*/
|
|
6243
|
+
const globalStoreId = `effect/GlobalValue`;
|
|
6244
|
+
let globalStore;
|
|
6245
|
+
/**
|
|
6246
|
+
* Retrieves or computes a global value associated with the given `id`. If the value for this `id`
|
|
6247
|
+
* has already been computed, it will be returned from the global store. If it does not exist yet,
|
|
6248
|
+
* the provided `compute` function will be executed to compute the value, store it, and then return it.
|
|
6249
|
+
*
|
|
6250
|
+
* This ensures that even in cases where the module is imported multiple times (e.g., in mixed environments
|
|
6251
|
+
* like CommonJS and ESM, or during hot-reloading in development), the value is computed only once and reused
|
|
6252
|
+
* thereafter.
|
|
6253
|
+
*
|
|
6254
|
+
* @example
|
|
6255
|
+
* ```ts
|
|
6256
|
+
* import { globalValue } from "effect/GlobalValue"
|
|
6257
|
+
*
|
|
6258
|
+
* // This cache will persist as long as the module is running,
|
|
6259
|
+
* // even if reloaded or imported elsewhere
|
|
6260
|
+
* const myCache = globalValue(
|
|
6261
|
+
* Symbol.for("myCache"),
|
|
6262
|
+
* () => new WeakMap<object, number>()
|
|
6263
|
+
* )
|
|
6264
|
+
* ```
|
|
6265
|
+
*
|
|
6266
|
+
* @since 2.0.0
|
|
6267
|
+
*/
|
|
6268
|
+
const globalValue = (id, compute) => {
|
|
6269
|
+
if (!globalStore) {
|
|
6270
|
+
// @ts-expect-error
|
|
6271
|
+
globalThis[globalStoreId] ??= new Map();
|
|
6272
|
+
// @ts-expect-error
|
|
6273
|
+
globalStore = globalThis[globalStoreId];
|
|
6274
|
+
}
|
|
6275
|
+
if (!globalStore.has(id)) {
|
|
6276
|
+
globalStore.set(id, compute());
|
|
6277
|
+
}
|
|
6278
|
+
return globalStore.get(id);
|
|
6279
|
+
};
|
|
5997
6280
|
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6281
|
+
/**
|
|
6282
|
+
* This module provides a collection of functions for working with predicates and refinements.
|
|
6283
|
+
*
|
|
6284
|
+
* A `Predicate<A>` is a function that takes a value of type `A` and returns a boolean.
|
|
6285
|
+
* It is used to check if a value satisfies a certain condition.
|
|
6286
|
+
*
|
|
6287
|
+
* A `Refinement<A, B>` is a special type of predicate that not only checks a condition
|
|
6288
|
+
* but also provides a type guard, allowing TypeScript to narrow the type of the input
|
|
6289
|
+
* value from `A` to a more specific type `B` within a conditional block.
|
|
6290
|
+
*
|
|
6291
|
+
* The module includes:
|
|
6292
|
+
* - Basic predicates and refinements for common types (e.g., `isString`, `isNumber`).
|
|
6293
|
+
* - Combinators to create new predicates from existing ones (e.g., `and`, `or`, `not`).
|
|
6294
|
+
* - Advanced combinators for working with data structures (e.g., `tuple`, `struct`).
|
|
6295
|
+
* - Type-level utilities for inspecting predicate and refinement types.
|
|
6296
|
+
*
|
|
6297
|
+
* @since 2.0.0
|
|
6298
|
+
*/
|
|
6299
|
+
/**
|
|
6300
|
+
* A refinement that checks if a value is a `Function`.
|
|
6301
|
+
*
|
|
6302
|
+
* @example
|
|
6303
|
+
* ```ts
|
|
6304
|
+
* import * as assert from "node:assert"
|
|
6305
|
+
* import { isFunction } from "effect/Predicate"
|
|
6306
|
+
*
|
|
6307
|
+
* assert.strictEqual(isFunction(() => {}), true)
|
|
6308
|
+
* assert.strictEqual(isFunction(isFunction), true)
|
|
6309
|
+
*
|
|
6310
|
+
* assert.strictEqual(isFunction("function"), false)
|
|
6311
|
+
* ```
|
|
6312
|
+
*
|
|
6313
|
+
* @category guards
|
|
6314
|
+
* @since 2.0.0
|
|
6315
|
+
*/
|
|
6316
|
+
const isFunction = isFunction$1;
|
|
6317
|
+
/**
|
|
6318
|
+
* Checks if the input is an object or an array.
|
|
6319
|
+
* @internal
|
|
6320
|
+
*/
|
|
6321
|
+
const isRecordOrArray = input => typeof input === "object" && input !== null;
|
|
6322
|
+
/**
|
|
6323
|
+
* A refinement that checks if a value is an `object`. Note that in JavaScript,
|
|
6324
|
+
* arrays and functions are also considered objects.
|
|
6325
|
+
*
|
|
6326
|
+
* @example
|
|
6327
|
+
* ```ts
|
|
6328
|
+
* import * as assert from "node:assert"
|
|
6329
|
+
* import { isObject } from "effect/Predicate"
|
|
6330
|
+
*
|
|
6331
|
+
* assert.strictEqual(isObject({}), true)
|
|
6332
|
+
* assert.strictEqual(isObject([]), true)
|
|
6333
|
+
* assert.strictEqual(isObject(() => {}), true)
|
|
6334
|
+
*
|
|
6335
|
+
* assert.strictEqual(isObject(null), false)
|
|
6336
|
+
* assert.strictEqual(isObject("hello"), false)
|
|
6337
|
+
* ```
|
|
6338
|
+
*
|
|
6339
|
+
* @category guards
|
|
6340
|
+
* @since 2.0.0
|
|
6341
|
+
* @see isRecord to check for plain objects (excluding arrays and functions).
|
|
6342
|
+
*/
|
|
6343
|
+
const isObject = input => isRecordOrArray(input) || isFunction(input);
|
|
6344
|
+
/**
|
|
6345
|
+
* A refinement that checks if a value is an object-like value and has a specific property key.
|
|
6346
|
+
*
|
|
6347
|
+
* @example
|
|
6348
|
+
* ```ts
|
|
6349
|
+
* import * as assert from "node:assert"
|
|
6350
|
+
* import { hasProperty } from "effect/Predicate"
|
|
6351
|
+
*
|
|
6352
|
+
* assert.strictEqual(hasProperty({ a: 1 }, "a"), true)
|
|
6353
|
+
* assert.strictEqual(hasProperty({ a: 1 }, "b"), false)
|
|
6354
|
+
*
|
|
6355
|
+
* const value: unknown = { name: "Alice" };
|
|
6356
|
+
* if (hasProperty(value, "name")) {
|
|
6357
|
+
* // The type of `value` is narrowed to `{ name: unknown }`
|
|
6358
|
+
* // and we can safely access `value.name`
|
|
6359
|
+
* console.log(value.name)
|
|
6360
|
+
* }
|
|
6361
|
+
* ```
|
|
6362
|
+
*
|
|
6363
|
+
* @category guards
|
|
6364
|
+
* @since 2.0.0
|
|
6365
|
+
*/
|
|
6366
|
+
const hasProperty = /*#__PURE__*/dual(2, (self, property) => isObject(self) && property in self);
|
|
6367
|
+
|
|
6368
|
+
/**
|
|
6369
|
+
* @since 2.0.0
|
|
6370
|
+
*/
|
|
6371
|
+
/**
|
|
6372
|
+
* @category constructors
|
|
6373
|
+
* @since 2.0.0
|
|
6374
|
+
*/
|
|
6375
|
+
class SingleShotGen {
|
|
6376
|
+
self;
|
|
6377
|
+
called = false;
|
|
6378
|
+
constructor(self) {
|
|
6379
|
+
this.self = self;
|
|
6380
|
+
}
|
|
6381
|
+
/**
|
|
6382
|
+
* @since 2.0.0
|
|
6383
|
+
*/
|
|
6384
|
+
next(a) {
|
|
6385
|
+
return this.called ? {
|
|
6386
|
+
value: a,
|
|
6387
|
+
done: true
|
|
6388
|
+
} : (this.called = true, {
|
|
6389
|
+
value: this.self,
|
|
6390
|
+
done: false
|
|
6391
|
+
});
|
|
6392
|
+
}
|
|
6393
|
+
/**
|
|
6394
|
+
* @since 2.0.0
|
|
6395
|
+
*/
|
|
6396
|
+
return(a) {
|
|
6397
|
+
return {
|
|
6398
|
+
value: a,
|
|
6399
|
+
done: true
|
|
6400
|
+
};
|
|
6401
|
+
}
|
|
6402
|
+
/**
|
|
6403
|
+
* @since 2.0.0
|
|
6404
|
+
*/
|
|
6405
|
+
throw(e) {
|
|
6406
|
+
throw e;
|
|
6407
|
+
}
|
|
6408
|
+
/**
|
|
6409
|
+
* @since 2.0.0
|
|
6410
|
+
*/
|
|
6411
|
+
[Symbol.iterator]() {
|
|
6412
|
+
return new SingleShotGen(this.self);
|
|
6413
|
+
}
|
|
6414
|
+
}
|
|
6415
|
+
/**
|
|
6416
|
+
* @since 3.0.6
|
|
6417
|
+
*/
|
|
6418
|
+
const YieldWrapTypeId = /*#__PURE__*/Symbol.for("effect/Utils/YieldWrap");
|
|
6419
|
+
/**
|
|
6420
|
+
* @since 3.0.6
|
|
6421
|
+
*/
|
|
6422
|
+
class YieldWrap {
|
|
6423
|
+
/**
|
|
6424
|
+
* @since 3.0.6
|
|
6425
|
+
*/
|
|
6426
|
+
#value;
|
|
6427
|
+
constructor(value) {
|
|
6428
|
+
this.#value = value;
|
|
6429
|
+
}
|
|
6430
|
+
/**
|
|
6431
|
+
* @since 3.0.6
|
|
6432
|
+
*/
|
|
6433
|
+
[YieldWrapTypeId]() {
|
|
6434
|
+
return this.#value;
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6437
|
+
/**
|
|
6438
|
+
* Note: this is an experimental feature made available to allow custom matchers in tests, not to be directly used yet in user code
|
|
6439
|
+
*
|
|
6440
|
+
* @since 3.1.1
|
|
6441
|
+
* @status experimental
|
|
6442
|
+
* @category modifiers
|
|
6443
|
+
*/
|
|
6444
|
+
const structuralRegionState = /*#__PURE__*/globalValue("effect/Utils/isStructuralRegion", () => ({
|
|
6445
|
+
enabled: false,
|
|
6446
|
+
tester: undefined
|
|
6447
|
+
}));
|
|
6448
|
+
|
|
6449
|
+
/**
|
|
6450
|
+
* @since 2.0.0
|
|
6451
|
+
*/
|
|
6452
|
+
/** @internal */
|
|
6453
|
+
const randomHashCache = /*#__PURE__*/globalValue(/*#__PURE__*/Symbol.for("effect/Hash/randomHashCache"), () => new WeakMap());
|
|
6454
|
+
/**
|
|
6455
|
+
* @since 2.0.0
|
|
6456
|
+
* @category symbols
|
|
6457
|
+
*/
|
|
6458
|
+
const symbol$1 = /*#__PURE__*/Symbol.for("effect/Hash");
|
|
6459
|
+
/**
|
|
6460
|
+
* @since 2.0.0
|
|
6461
|
+
* @category hashing
|
|
6462
|
+
*/
|
|
6463
|
+
const hash = self => {
|
|
6464
|
+
if (structuralRegionState.enabled === true) {
|
|
6465
|
+
return 0;
|
|
6466
|
+
}
|
|
6467
|
+
switch (typeof self) {
|
|
6468
|
+
case "number":
|
|
6469
|
+
return number(self);
|
|
6470
|
+
case "bigint":
|
|
6471
|
+
return string(self.toString(10));
|
|
6472
|
+
case "boolean":
|
|
6473
|
+
return string(String(self));
|
|
6474
|
+
case "symbol":
|
|
6475
|
+
return string(String(self));
|
|
6476
|
+
case "string":
|
|
6477
|
+
return string(self);
|
|
6478
|
+
case "undefined":
|
|
6479
|
+
return string("undefined");
|
|
6480
|
+
case "function":
|
|
6481
|
+
case "object":
|
|
6482
|
+
{
|
|
6483
|
+
if (self === null) {
|
|
6484
|
+
return string("null");
|
|
6485
|
+
} else if (self instanceof Date) {
|
|
6486
|
+
if (Number.isNaN(self.getTime())) {
|
|
6487
|
+
return string("Invalid Date");
|
|
6488
|
+
}
|
|
6489
|
+
return hash(self.toISOString());
|
|
6490
|
+
} else if (self instanceof URL) {
|
|
6491
|
+
return hash(self.href);
|
|
6492
|
+
} else if (isHash(self)) {
|
|
6493
|
+
return self[symbol$1]();
|
|
6494
|
+
} else {
|
|
6495
|
+
return random(self);
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
default:
|
|
6499
|
+
throw new Error(`BUG: unhandled typeof ${typeof self} - please report an issue at https://github.com/Effect-TS/effect/issues`);
|
|
6500
|
+
}
|
|
6501
|
+
};
|
|
6502
|
+
/**
|
|
6503
|
+
* @since 2.0.0
|
|
6504
|
+
* @category hashing
|
|
6505
|
+
*/
|
|
6506
|
+
const random = self => {
|
|
6507
|
+
if (!randomHashCache.has(self)) {
|
|
6508
|
+
randomHashCache.set(self, number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)));
|
|
6509
|
+
}
|
|
6510
|
+
return randomHashCache.get(self);
|
|
6511
|
+
};
|
|
6512
|
+
/**
|
|
6513
|
+
* @since 2.0.0
|
|
6514
|
+
* @category hashing
|
|
6515
|
+
*/
|
|
6516
|
+
const combine = b => self => self * 53 ^ b;
|
|
6517
|
+
/**
|
|
6518
|
+
* @since 2.0.0
|
|
6519
|
+
* @category hashing
|
|
6520
|
+
*/
|
|
6521
|
+
const optimize = n => n & 0xbfffffff | n >>> 1 & 0x40000000;
|
|
6522
|
+
/**
|
|
6523
|
+
* @since 2.0.0
|
|
6524
|
+
* @category guards
|
|
6525
|
+
*/
|
|
6526
|
+
const isHash = u => hasProperty(u, symbol$1);
|
|
6527
|
+
/**
|
|
6528
|
+
* @since 2.0.0
|
|
6529
|
+
* @category hashing
|
|
6530
|
+
*/
|
|
6531
|
+
const number = n => {
|
|
6532
|
+
if (n !== n || n === Infinity) {
|
|
6533
|
+
return 0;
|
|
6534
|
+
}
|
|
6535
|
+
let h = n | 0;
|
|
6536
|
+
if (h !== n) {
|
|
6537
|
+
h ^= n * 0xffffffff;
|
|
6538
|
+
}
|
|
6539
|
+
while (n > 0xffffffff) {
|
|
6540
|
+
h ^= n /= 0xffffffff;
|
|
6541
|
+
}
|
|
6542
|
+
return optimize(h);
|
|
6543
|
+
};
|
|
6544
|
+
/**
|
|
6545
|
+
* @since 2.0.0
|
|
6546
|
+
* @category hashing
|
|
6547
|
+
*/
|
|
6548
|
+
const string = str => {
|
|
6549
|
+
let h = 5381,
|
|
6550
|
+
i = str.length;
|
|
6551
|
+
while (i) {
|
|
6552
|
+
h = h * 33 ^ str.charCodeAt(--i);
|
|
6553
|
+
}
|
|
6554
|
+
return optimize(h);
|
|
6555
|
+
};
|
|
6556
|
+
/**
|
|
6557
|
+
* @since 2.0.0
|
|
6558
|
+
* @category hashing
|
|
6559
|
+
*/
|
|
6560
|
+
const structureKeys = (o, keys) => {
|
|
6561
|
+
let h = 12289;
|
|
6562
|
+
for (let i = 0; i < keys.length; i++) {
|
|
6563
|
+
h ^= pipe(string(keys[i]), combine(hash(o[keys[i]])));
|
|
6564
|
+
}
|
|
6565
|
+
return optimize(h);
|
|
6566
|
+
};
|
|
6567
|
+
/**
|
|
6568
|
+
* @since 2.0.0
|
|
6569
|
+
* @category hashing
|
|
6570
|
+
*/
|
|
6571
|
+
const structure = o => structureKeys(o, Object.keys(o));
|
|
6572
|
+
/**
|
|
6573
|
+
* @since 2.0.0
|
|
6574
|
+
* @category hashing
|
|
6575
|
+
*/
|
|
6576
|
+
const cached = function () {
|
|
6577
|
+
if (arguments.length === 1) {
|
|
6578
|
+
const self = arguments[0];
|
|
6579
|
+
return function (hash) {
|
|
6580
|
+
Object.defineProperty(self, symbol$1, {
|
|
6581
|
+
value() {
|
|
6582
|
+
return hash;
|
|
6583
|
+
},
|
|
6584
|
+
enumerable: false
|
|
6585
|
+
});
|
|
6586
|
+
return hash;
|
|
6587
|
+
};
|
|
6588
|
+
}
|
|
6589
|
+
const self = arguments[0];
|
|
6590
|
+
const hash = arguments[1];
|
|
6591
|
+
Object.defineProperty(self, symbol$1, {
|
|
6592
|
+
value() {
|
|
6593
|
+
return hash;
|
|
6594
|
+
},
|
|
6595
|
+
enumerable: false
|
|
6596
|
+
});
|
|
6597
|
+
return hash;
|
|
6598
|
+
};
|
|
6599
|
+
|
|
6600
|
+
/**
|
|
6601
|
+
* @since 2.0.0
|
|
6602
|
+
* @category symbols
|
|
6603
|
+
*/
|
|
6604
|
+
const symbol = /*#__PURE__*/Symbol.for("effect/Equal");
|
|
6605
|
+
function equals() {
|
|
6606
|
+
if (arguments.length === 1) {
|
|
6607
|
+
return self => compareBoth(self, arguments[0]);
|
|
6608
|
+
}
|
|
6609
|
+
return compareBoth(arguments[0], arguments[1]);
|
|
6610
|
+
}
|
|
6611
|
+
function compareBoth(self, that) {
|
|
6612
|
+
if (self === that) {
|
|
6613
|
+
return true;
|
|
6614
|
+
}
|
|
6615
|
+
const selfType = typeof self;
|
|
6616
|
+
if (selfType !== typeof that) {
|
|
6617
|
+
return false;
|
|
6618
|
+
}
|
|
6619
|
+
if (selfType === "object" || selfType === "function") {
|
|
6620
|
+
if (self !== null && that !== null) {
|
|
6621
|
+
if (isEqual(self) && isEqual(that)) {
|
|
6622
|
+
if (hash(self) === hash(that) && self[symbol](that)) {
|
|
6623
|
+
return true;
|
|
6624
|
+
} else {
|
|
6625
|
+
return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
6626
|
+
}
|
|
6627
|
+
} else if (self instanceof Date && that instanceof Date) {
|
|
6628
|
+
const t1 = self.getTime();
|
|
6629
|
+
const t2 = that.getTime();
|
|
6630
|
+
return t1 === t2 || Number.isNaN(t1) && Number.isNaN(t2);
|
|
6631
|
+
} else if (self instanceof URL && that instanceof URL) {
|
|
6632
|
+
return self.href === that.href;
|
|
6633
|
+
}
|
|
6001
6634
|
}
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
return
|
|
6635
|
+
if (structuralRegionState.enabled) {
|
|
6636
|
+
if (self === null || that === null) {
|
|
6637
|
+
return false;
|
|
6638
|
+
}
|
|
6639
|
+
if (Array.isArray(self) && Array.isArray(that)) {
|
|
6640
|
+
return self.length === that.length && self.every((v, i) => compareBoth(v, that[i]));
|
|
6641
|
+
}
|
|
6642
|
+
if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(that) === Object.prototype) {
|
|
6643
|
+
const keysSelf = Object.keys(self);
|
|
6644
|
+
const keysThat = Object.keys(that);
|
|
6645
|
+
if (keysSelf.length === keysThat.length) {
|
|
6646
|
+
for (const key of keysSelf) {
|
|
6647
|
+
// @ts-expect-error
|
|
6648
|
+
if (!(key in that && compareBoth(self[key], that[key]))) {
|
|
6649
|
+
return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
6650
|
+
}
|
|
6651
|
+
}
|
|
6652
|
+
return true;
|
|
6653
|
+
}
|
|
6654
|
+
}
|
|
6655
|
+
return structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
6005
6656
|
}
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6657
|
+
}
|
|
6658
|
+
return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
6659
|
+
}
|
|
6660
|
+
/**
|
|
6661
|
+
* @since 2.0.0
|
|
6662
|
+
* @category guards
|
|
6663
|
+
*/
|
|
6664
|
+
const isEqual = u => hasProperty(u, symbol);
|
|
6665
|
+
|
|
6666
|
+
/**
|
|
6667
|
+
* @since 2.0.0
|
|
6668
|
+
* @category symbols
|
|
6669
|
+
*/
|
|
6670
|
+
const NodeInspectSymbol = /*#__PURE__*/Symbol.for("nodejs.util.inspect.custom");
|
|
6671
|
+
/**
|
|
6672
|
+
* @since 2.0.0
|
|
6673
|
+
*/
|
|
6674
|
+
const toJSON = x => {
|
|
6675
|
+
try {
|
|
6676
|
+
if (hasProperty(x, "toJSON") && isFunction(x["toJSON"]) && x["toJSON"].length === 0) {
|
|
6677
|
+
return x.toJSON();
|
|
6678
|
+
} else if (Array.isArray(x)) {
|
|
6679
|
+
return x.map(toJSON);
|
|
6680
|
+
}
|
|
6681
|
+
} catch {
|
|
6682
|
+
return {};
|
|
6683
|
+
}
|
|
6684
|
+
return redact(x);
|
|
6685
|
+
};
|
|
6686
|
+
/**
|
|
6687
|
+
* @since 2.0.0
|
|
6688
|
+
*/
|
|
6689
|
+
const format = x => JSON.stringify(x, null, 2);
|
|
6690
|
+
/**
|
|
6691
|
+
* @since 2.0.0
|
|
6692
|
+
*/
|
|
6693
|
+
const toStringUnknown = (u, whitespace = 2) => {
|
|
6694
|
+
if (typeof u === "string") {
|
|
6695
|
+
return u;
|
|
6696
|
+
}
|
|
6697
|
+
try {
|
|
6698
|
+
return typeof u === "object" ? stringifyCircular(u, whitespace) : String(u);
|
|
6699
|
+
} catch {
|
|
6700
|
+
return String(u);
|
|
6701
|
+
}
|
|
6702
|
+
};
|
|
6703
|
+
/**
|
|
6704
|
+
* @since 2.0.0
|
|
6705
|
+
*/
|
|
6706
|
+
const stringifyCircular = (obj, whitespace) => {
|
|
6707
|
+
let cache = [];
|
|
6708
|
+
const retVal = JSON.stringify(obj, (_key, value) => typeof value === "object" && value !== null ? cache.includes(value) ? undefined // circular reference
|
|
6709
|
+
: cache.push(value) && (redactableState.fiberRefs !== undefined && isRedactable(value) ? value[symbolRedactable](redactableState.fiberRefs) : value) : value, whitespace);
|
|
6710
|
+
cache = undefined;
|
|
6711
|
+
return retVal;
|
|
6712
|
+
};
|
|
6713
|
+
/**
|
|
6714
|
+
* @since 3.10.0
|
|
6715
|
+
* @category redactable
|
|
6716
|
+
*/
|
|
6717
|
+
const symbolRedactable = /*#__PURE__*/Symbol.for("effect/Inspectable/Redactable");
|
|
6718
|
+
/**
|
|
6719
|
+
* @since 3.10.0
|
|
6720
|
+
* @category redactable
|
|
6721
|
+
*/
|
|
6722
|
+
const isRedactable = u => typeof u === "object" && u !== null && symbolRedactable in u;
|
|
6723
|
+
const redactableState = /*#__PURE__*/globalValue("effect/Inspectable/redactableState", () => ({
|
|
6724
|
+
fiberRefs: undefined
|
|
6725
|
+
}));
|
|
6726
|
+
/**
|
|
6727
|
+
* @since 3.10.0
|
|
6728
|
+
* @category redactable
|
|
6729
|
+
*/
|
|
6730
|
+
const redact = u => {
|
|
6731
|
+
if (isRedactable(u) && redactableState.fiberRefs !== undefined) {
|
|
6732
|
+
return u[symbolRedactable](redactableState.fiberRefs);
|
|
6733
|
+
}
|
|
6734
|
+
return u;
|
|
6735
|
+
};
|
|
6736
|
+
|
|
6737
|
+
/**
|
|
6738
|
+
* @since 2.0.0
|
|
6739
|
+
*/
|
|
6740
|
+
/**
|
|
6741
|
+
* @since 2.0.0
|
|
6742
|
+
*/
|
|
6743
|
+
const pipeArguments = (self, args) => {
|
|
6744
|
+
switch (args.length) {
|
|
6745
|
+
case 0:
|
|
6746
|
+
return self;
|
|
6747
|
+
case 1:
|
|
6748
|
+
return args[0](self);
|
|
6749
|
+
case 2:
|
|
6750
|
+
return args[1](args[0](self));
|
|
6751
|
+
case 3:
|
|
6752
|
+
return args[2](args[1](args[0](self)));
|
|
6753
|
+
case 4:
|
|
6754
|
+
return args[3](args[2](args[1](args[0](self))));
|
|
6755
|
+
case 5:
|
|
6756
|
+
return args[4](args[3](args[2](args[1](args[0](self)))));
|
|
6757
|
+
case 6:
|
|
6758
|
+
return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
|
|
6759
|
+
case 7:
|
|
6760
|
+
return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
|
|
6761
|
+
case 8:
|
|
6762
|
+
return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
|
|
6763
|
+
case 9:
|
|
6764
|
+
return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
|
|
6765
|
+
default:
|
|
6766
|
+
{
|
|
6767
|
+
let ret = self;
|
|
6768
|
+
for (let i = 0, len = args.length; i < len; i++) {
|
|
6769
|
+
ret = args[i](ret);
|
|
6770
|
+
}
|
|
6771
|
+
return ret;
|
|
6772
|
+
}
|
|
6773
|
+
}
|
|
6774
|
+
};
|
|
6775
|
+
|
|
6776
|
+
let moduleVersion = "3.21.1";
|
|
6777
|
+
const getCurrentVersion = () => moduleVersion;
|
|
6778
|
+
|
|
6779
|
+
/** @internal */
|
|
6780
|
+
const EffectTypeId = /*#__PURE__*/Symbol.for("effect/Effect");
|
|
6781
|
+
/** @internal */
|
|
6782
|
+
const StreamTypeId = /*#__PURE__*/Symbol.for("effect/Stream");
|
|
6783
|
+
/** @internal */
|
|
6784
|
+
const SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink");
|
|
6785
|
+
/** @internal */
|
|
6786
|
+
const ChannelTypeId = /*#__PURE__*/Symbol.for("effect/Channel");
|
|
6787
|
+
/** @internal */
|
|
6788
|
+
const effectVariance = {
|
|
6789
|
+
/* c8 ignore next */
|
|
6790
|
+
_R: _ => _,
|
|
6791
|
+
/* c8 ignore next */
|
|
6792
|
+
_E: _ => _,
|
|
6793
|
+
/* c8 ignore next */
|
|
6794
|
+
_A: _ => _,
|
|
6795
|
+
_V: /*#__PURE__*/getCurrentVersion()
|
|
6796
|
+
};
|
|
6797
|
+
const sinkVariance = {
|
|
6798
|
+
/* c8 ignore next */
|
|
6799
|
+
_A: _ => _,
|
|
6800
|
+
/* c8 ignore next */
|
|
6801
|
+
_In: _ => _,
|
|
6802
|
+
/* c8 ignore next */
|
|
6803
|
+
_L: _ => _,
|
|
6804
|
+
/* c8 ignore next */
|
|
6805
|
+
_E: _ => _,
|
|
6806
|
+
/* c8 ignore next */
|
|
6807
|
+
_R: _ => _
|
|
6808
|
+
};
|
|
6809
|
+
const channelVariance = {
|
|
6810
|
+
/* c8 ignore next */
|
|
6811
|
+
_Env: _ => _,
|
|
6812
|
+
/* c8 ignore next */
|
|
6813
|
+
_InErr: _ => _,
|
|
6814
|
+
/* c8 ignore next */
|
|
6815
|
+
_InElem: _ => _,
|
|
6816
|
+
/* c8 ignore next */
|
|
6817
|
+
_InDone: _ => _,
|
|
6818
|
+
/* c8 ignore next */
|
|
6819
|
+
_OutErr: _ => _,
|
|
6820
|
+
/* c8 ignore next */
|
|
6821
|
+
_OutElem: _ => _,
|
|
6822
|
+
/* c8 ignore next */
|
|
6823
|
+
_OutDone: _ => _
|
|
6824
|
+
};
|
|
6825
|
+
/** @internal */
|
|
6826
|
+
const EffectPrototype$1 = {
|
|
6827
|
+
[EffectTypeId]: effectVariance,
|
|
6828
|
+
[StreamTypeId]: effectVariance,
|
|
6829
|
+
[SinkTypeId]: sinkVariance,
|
|
6830
|
+
[ChannelTypeId]: channelVariance,
|
|
6831
|
+
[symbol](that) {
|
|
6832
|
+
return this === that;
|
|
6833
|
+
},
|
|
6834
|
+
[symbol$1]() {
|
|
6835
|
+
return cached(this, random(this));
|
|
6836
|
+
},
|
|
6837
|
+
[Symbol.iterator]() {
|
|
6838
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
6839
|
+
},
|
|
6840
|
+
pipe() {
|
|
6841
|
+
return pipeArguments(this, arguments);
|
|
6842
|
+
}
|
|
6843
|
+
};
|
|
6844
|
+
/** @internal */
|
|
6845
|
+
const StructuralPrototype = {
|
|
6846
|
+
[symbol$1]() {
|
|
6847
|
+
return cached(this, structure(this));
|
|
6848
|
+
},
|
|
6849
|
+
[symbol](that) {
|
|
6850
|
+
const selfKeys = Object.keys(this);
|
|
6851
|
+
const thatKeys = Object.keys(that);
|
|
6852
|
+
if (selfKeys.length !== thatKeys.length) {
|
|
6853
|
+
return false;
|
|
6854
|
+
}
|
|
6855
|
+
for (const key of selfKeys) {
|
|
6856
|
+
if (!(key in that && equals(this[key], that[key]))) {
|
|
6857
|
+
return false;
|
|
6858
|
+
}
|
|
6859
|
+
}
|
|
6860
|
+
return true;
|
|
6861
|
+
}
|
|
6862
|
+
};
|
|
6863
|
+
|
|
6864
|
+
/**
|
|
6865
|
+
* @since 2.0.0
|
|
6866
|
+
*/
|
|
6867
|
+
const TypeId$3 = /*#__PURE__*/Symbol.for("effect/Option");
|
|
6868
|
+
const CommonProto$1 = {
|
|
6869
|
+
...EffectPrototype$1,
|
|
6870
|
+
[TypeId$3]: {
|
|
6871
|
+
_A: _ => _
|
|
6872
|
+
},
|
|
6873
|
+
[NodeInspectSymbol]() {
|
|
6874
|
+
return this.toJSON();
|
|
6875
|
+
},
|
|
6876
|
+
toString() {
|
|
6877
|
+
return format(this.toJSON());
|
|
6878
|
+
}
|
|
6879
|
+
};
|
|
6880
|
+
const SomeProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(CommonProto$1), {
|
|
6881
|
+
_tag: "Some",
|
|
6882
|
+
_op: "Some",
|
|
6883
|
+
[symbol](that) {
|
|
6884
|
+
return isOption(that) && isSome(that) && equals(this.value, that.value);
|
|
6885
|
+
},
|
|
6886
|
+
[symbol$1]() {
|
|
6887
|
+
return cached(this, combine(hash(this._tag))(hash(this.value)));
|
|
6888
|
+
},
|
|
6889
|
+
toJSON() {
|
|
6890
|
+
return {
|
|
6891
|
+
_id: "Option",
|
|
6892
|
+
_tag: this._tag,
|
|
6893
|
+
value: toJSON(this.value)
|
|
6894
|
+
};
|
|
6895
|
+
}
|
|
6896
|
+
});
|
|
6897
|
+
const NoneHash = /*#__PURE__*/hash("None");
|
|
6898
|
+
const NoneProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(CommonProto$1), {
|
|
6899
|
+
_tag: "None",
|
|
6900
|
+
_op: "None",
|
|
6901
|
+
[symbol](that) {
|
|
6902
|
+
return isOption(that) && isNone$1(that);
|
|
6903
|
+
},
|
|
6904
|
+
[symbol$1]() {
|
|
6905
|
+
return NoneHash;
|
|
6906
|
+
},
|
|
6907
|
+
toJSON() {
|
|
6908
|
+
return {
|
|
6909
|
+
_id: "Option",
|
|
6910
|
+
_tag: this._tag
|
|
6911
|
+
};
|
|
6912
|
+
}
|
|
6913
|
+
});
|
|
6914
|
+
/** @internal */
|
|
6915
|
+
const isOption = input => hasProperty(input, TypeId$3);
|
|
6916
|
+
/** @internal */
|
|
6917
|
+
const isNone$1 = fa => fa._tag === "None";
|
|
6918
|
+
/** @internal */
|
|
6919
|
+
const isSome = fa => fa._tag === "Some";
|
|
6920
|
+
/** @internal */
|
|
6921
|
+
const none = /*#__PURE__*/Object.create(NoneProto);
|
|
6922
|
+
/** @internal */
|
|
6923
|
+
const some = value => {
|
|
6924
|
+
const a = Object.create(SomeProto);
|
|
6925
|
+
a.value = value;
|
|
6926
|
+
return a;
|
|
6927
|
+
};
|
|
6928
|
+
|
|
6929
|
+
/**
|
|
6930
|
+
* @since 2.0.0
|
|
6931
|
+
*/
|
|
6932
|
+
/**
|
|
6933
|
+
* @internal
|
|
6934
|
+
*/
|
|
6935
|
+
const TypeId$2 = /*#__PURE__*/Symbol.for("effect/Either");
|
|
6936
|
+
const CommonProto = {
|
|
6937
|
+
...EffectPrototype$1,
|
|
6938
|
+
[TypeId$2]: {
|
|
6939
|
+
_R: _ => _
|
|
6940
|
+
},
|
|
6941
|
+
[NodeInspectSymbol]() {
|
|
6942
|
+
return this.toJSON();
|
|
6943
|
+
},
|
|
6944
|
+
toString() {
|
|
6945
|
+
return format(this.toJSON());
|
|
6946
|
+
}
|
|
6947
|
+
};
|
|
6948
|
+
const RightProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(CommonProto), {
|
|
6949
|
+
_tag: "Right",
|
|
6950
|
+
_op: "Right",
|
|
6951
|
+
[symbol](that) {
|
|
6952
|
+
return isEither(that) && isRight$1(that) && equals(this.right, that.right);
|
|
6953
|
+
},
|
|
6954
|
+
[symbol$1]() {
|
|
6955
|
+
return combine(hash(this._tag))(hash(this.right));
|
|
6956
|
+
},
|
|
6957
|
+
toJSON() {
|
|
6958
|
+
return {
|
|
6959
|
+
_id: "Either",
|
|
6960
|
+
_tag: this._tag,
|
|
6961
|
+
right: toJSON(this.right)
|
|
6962
|
+
};
|
|
6963
|
+
}
|
|
6964
|
+
});
|
|
6965
|
+
const LeftProto = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(CommonProto), {
|
|
6966
|
+
_tag: "Left",
|
|
6967
|
+
_op: "Left",
|
|
6968
|
+
[symbol](that) {
|
|
6969
|
+
return isEither(that) && isLeft(that) && equals(this.left, that.left);
|
|
6970
|
+
},
|
|
6971
|
+
[symbol$1]() {
|
|
6972
|
+
return combine(hash(this._tag))(hash(this.left));
|
|
6973
|
+
},
|
|
6974
|
+
toJSON() {
|
|
6975
|
+
return {
|
|
6976
|
+
_id: "Either",
|
|
6977
|
+
_tag: this._tag,
|
|
6978
|
+
left: toJSON(this.left)
|
|
6979
|
+
};
|
|
6980
|
+
}
|
|
6981
|
+
});
|
|
6982
|
+
/** @internal */
|
|
6983
|
+
const isEither = input => hasProperty(input, TypeId$2);
|
|
6984
|
+
/** @internal */
|
|
6985
|
+
const isLeft = ma => ma._tag === "Left";
|
|
6986
|
+
/** @internal */
|
|
6987
|
+
const isRight$1 = ma => ma._tag === "Right";
|
|
6988
|
+
/** @internal */
|
|
6989
|
+
const left$1 = left => {
|
|
6990
|
+
const a = Object.create(LeftProto);
|
|
6991
|
+
a.left = left;
|
|
6992
|
+
return a;
|
|
6993
|
+
};
|
|
6994
|
+
/** @internal */
|
|
6995
|
+
const right$1 = right => {
|
|
6996
|
+
const a = Object.create(RightProto);
|
|
6997
|
+
a.right = right;
|
|
6998
|
+
return a;
|
|
6999
|
+
};
|
|
7000
|
+
/** @internal */
|
|
7001
|
+
const getRight$1 = self => isLeft(self) ? none : some(self.right);
|
|
7002
|
+
|
|
7003
|
+
/**
|
|
7004
|
+
* @since 2.0.0
|
|
7005
|
+
*/
|
|
7006
|
+
/**
|
|
7007
|
+
* Constructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias
|
|
7008
|
+
* of this structure.
|
|
7009
|
+
*
|
|
7010
|
+
* @category constructors
|
|
7011
|
+
* @since 2.0.0
|
|
7012
|
+
*/
|
|
7013
|
+
const right = right$1;
|
|
7014
|
+
/**
|
|
7015
|
+
* Constructs a new `Either` holding a `Left` value. This usually represents a failure, due to the right-bias of this
|
|
7016
|
+
* structure.
|
|
7017
|
+
*
|
|
7018
|
+
* @category constructors
|
|
7019
|
+
* @since 2.0.0
|
|
7020
|
+
*/
|
|
7021
|
+
const left = left$1;
|
|
7022
|
+
/**
|
|
7023
|
+
* Determine if a `Either` is a `Right`.
|
|
7024
|
+
*
|
|
7025
|
+
* @example
|
|
7026
|
+
* ```ts
|
|
7027
|
+
* import * as assert from "node:assert"
|
|
7028
|
+
* import { Either } from "effect"
|
|
7029
|
+
*
|
|
7030
|
+
* assert.deepStrictEqual(Either.isRight(Either.right(1)), true)
|
|
7031
|
+
* assert.deepStrictEqual(Either.isRight(Either.left("a")), false)
|
|
7032
|
+
* ```
|
|
7033
|
+
*
|
|
7034
|
+
* @category guards
|
|
7035
|
+
* @since 2.0.0
|
|
7036
|
+
*/
|
|
7037
|
+
const isRight = isRight$1;
|
|
7038
|
+
/**
|
|
7039
|
+
* Extracts the value of an `Either` or throws if the `Either` is `Left`.
|
|
7040
|
+
*
|
|
7041
|
+
* If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.
|
|
7042
|
+
*
|
|
7043
|
+
* @example
|
|
7044
|
+
* ```ts
|
|
7045
|
+
* import * as assert from "node:assert"
|
|
7046
|
+
* import { Either } from "effect"
|
|
7047
|
+
*
|
|
7048
|
+
* assert.deepStrictEqual(
|
|
7049
|
+
* Either.getOrThrowWith(Either.right(1), () => new Error('Unexpected Left')),
|
|
7050
|
+
* 1
|
|
7051
|
+
* )
|
|
7052
|
+
* assert.throws(() => Either.getOrThrowWith(Either.left("error"), () => new Error('Unexpected Left')))
|
|
7053
|
+
* ```
|
|
7054
|
+
*
|
|
7055
|
+
* @category getters
|
|
7056
|
+
* @since 2.0.0
|
|
7057
|
+
*/
|
|
7058
|
+
const getOrThrowWith = /*#__PURE__*/dual(2, (self, onLeft) => {
|
|
7059
|
+
if (isRight(self)) {
|
|
7060
|
+
return self.right;
|
|
7061
|
+
}
|
|
7062
|
+
throw onLeft(self.left);
|
|
7063
|
+
});
|
|
7064
|
+
|
|
7065
|
+
/**
|
|
7066
|
+
* Checks whether an `Option` represents the absence of a value (`None`).
|
|
7067
|
+
*
|
|
7068
|
+
* @example
|
|
7069
|
+
* ```ts
|
|
7070
|
+
* import { Option } from "effect"
|
|
7071
|
+
*
|
|
7072
|
+
* console.log(Option.isNone(Option.some(1)))
|
|
7073
|
+
* // Output: false
|
|
7074
|
+
*
|
|
7075
|
+
* console.log(Option.isNone(Option.none()))
|
|
7076
|
+
* // Output: true
|
|
7077
|
+
* ```
|
|
7078
|
+
*
|
|
7079
|
+
* @see {@link isSome} for the opposite check.
|
|
7080
|
+
*
|
|
7081
|
+
* @category Guards
|
|
7082
|
+
* @since 2.0.0
|
|
7083
|
+
*/
|
|
7084
|
+
const isNone = isNone$1;
|
|
7085
|
+
/**
|
|
7086
|
+
* Performs pattern matching on an `Option` to handle both `Some` and `None`
|
|
7087
|
+
* cases.
|
|
7088
|
+
*
|
|
7089
|
+
* **Details**
|
|
7090
|
+
*
|
|
7091
|
+
* This function allows you to match against an `Option` and handle both
|
|
7092
|
+
* scenarios: when the `Option` is `None` (i.e., contains no value), and when
|
|
7093
|
+
* the `Option` is `Some` (i.e., contains a value). It executes one of the
|
|
7094
|
+
* provided functions based on the case:
|
|
7095
|
+
*
|
|
7096
|
+
* - If the `Option` is `None`, the `onNone` function is executed and its result
|
|
7097
|
+
* is returned.
|
|
7098
|
+
* - If the `Option` is `Some`, the `onSome` function is executed with the
|
|
7099
|
+
* contained value, and its result is returned.
|
|
7100
|
+
*
|
|
7101
|
+
* This function provides a concise and functional way to handle optional values
|
|
7102
|
+
* without resorting to `if` or manual checks, making your code more declarative
|
|
7103
|
+
* and readable.
|
|
7104
|
+
*
|
|
7105
|
+
* **Example** (Pattern Matching with Option)
|
|
7106
|
+
*
|
|
7107
|
+
* ```ts
|
|
7108
|
+
* import { Option } from "effect"
|
|
7109
|
+
*
|
|
7110
|
+
* const foo = Option.some(1)
|
|
7111
|
+
*
|
|
7112
|
+
* const message = Option.match(foo, {
|
|
7113
|
+
* onNone: () => "Option is empty",
|
|
7114
|
+
* onSome: (value) => `Option has a value: ${value}`
|
|
7115
|
+
* })
|
|
7116
|
+
*
|
|
7117
|
+
* console.log(message)
|
|
7118
|
+
* // Output: "Option has a value: 1"
|
|
7119
|
+
* ```
|
|
7120
|
+
*
|
|
7121
|
+
* @category Pattern matching
|
|
7122
|
+
* @since 2.0.0
|
|
7123
|
+
*/
|
|
7124
|
+
const match = /*#__PURE__*/dual(2, (self, {
|
|
7125
|
+
onNone,
|
|
7126
|
+
onSome
|
|
7127
|
+
}) => isNone(self) ? onNone() : onSome(self.value));
|
|
7128
|
+
/**
|
|
7129
|
+
* Converts an `Either` into an `Option` by discarding the error and extracting
|
|
7130
|
+
* the right value.
|
|
7131
|
+
*
|
|
7132
|
+
* **Details**
|
|
7133
|
+
*
|
|
7134
|
+
* This function takes an `Either` and returns an `Option` based on its value:
|
|
7135
|
+
*
|
|
7136
|
+
* - If the `Either` is a `Right`, its value is wrapped in a `Some` and
|
|
7137
|
+
* returned.
|
|
7138
|
+
* - If the `Either` is a `Left`, the error is discarded, and `None` is
|
|
7139
|
+
* returned.
|
|
7140
|
+
*
|
|
7141
|
+
* This is particularly useful when you only care about the success case
|
|
7142
|
+
* (`Right`) of an `Either` and want to handle the result using `Option`. By
|
|
7143
|
+
* using this function, you can convert `Either` into a simpler structure for
|
|
7144
|
+
* cases where error handling is not required.
|
|
7145
|
+
*
|
|
7146
|
+
* @example
|
|
7147
|
+
* ```ts
|
|
7148
|
+
* import { Either, Option } from "effect"
|
|
7149
|
+
*
|
|
7150
|
+
* console.log(Option.getRight(Either.right("ok")))
|
|
7151
|
+
* // Output: { _id: 'Option', _tag: 'Some', value: 'ok' }
|
|
7152
|
+
*
|
|
7153
|
+
* console.log(Option.getRight(Either.left("err")))
|
|
7154
|
+
* // Output: { _id: 'Option', _tag: 'None' }
|
|
7155
|
+
* ```
|
|
7156
|
+
*
|
|
7157
|
+
* @see {@link getLeft} for the opposite operation.
|
|
7158
|
+
*
|
|
7159
|
+
* @category Conversions
|
|
7160
|
+
* @since 2.0.0
|
|
7161
|
+
*/
|
|
7162
|
+
const getRight = getRight$1;
|
|
7163
|
+
|
|
7164
|
+
/**
|
|
7165
|
+
* This module provides types and utility functions to create and work with branded types,
|
|
7166
|
+
* which are TypeScript types with an added type tag to prevent accidental usage of a value in the wrong context.
|
|
7167
|
+
*
|
|
7168
|
+
* The `refined` and `nominal` functions are both used to create branded types in TypeScript.
|
|
7169
|
+
* The main difference between them is that `refined` allows for validation of the data, while `nominal` does not.
|
|
7170
|
+
*
|
|
7171
|
+
* The `nominal` function is used to create a new branded type that has the same underlying type as the input, but with a different name.
|
|
7172
|
+
* This is useful when you want to distinguish between two values of the same type that have different meanings.
|
|
7173
|
+
* The `nominal` function does not perform any validation of the input data.
|
|
7174
|
+
*
|
|
7175
|
+
* On the other hand, the `refined` function is used to create a new branded type that has the same underlying type as the input,
|
|
7176
|
+
* but with a different name, and it also allows for validation of the input data.
|
|
7177
|
+
* The `refined` function takes a predicate that is used to validate the input data.
|
|
7178
|
+
* If the input data fails the validation, a `BrandErrors` is returned, which provides information about the specific validation failure.
|
|
7179
|
+
*
|
|
7180
|
+
* @since 2.0.0
|
|
7181
|
+
*/
|
|
7182
|
+
/**
|
|
7183
|
+
* @since 2.0.0
|
|
7184
|
+
* @category symbols
|
|
7185
|
+
*/
|
|
7186
|
+
const RefinedConstructorsTypeId = /*#__PURE__*/Symbol.for("effect/Brand/Refined");
|
|
7187
|
+
/**
|
|
7188
|
+
* Returns a `BrandErrors` that contains a single `RefinementError`.
|
|
7189
|
+
*
|
|
7190
|
+
* @since 2.0.0
|
|
7191
|
+
* @category constructors
|
|
7192
|
+
*/
|
|
7193
|
+
const error = (message, meta) => [{
|
|
7194
|
+
message,
|
|
7195
|
+
meta
|
|
7196
|
+
}];
|
|
7197
|
+
function refined(...args) {
|
|
7198
|
+
const either = args.length === 2 ? unbranded => args[0](unbranded) ? right(unbranded) : left(args[1](unbranded)) : unbranded => {
|
|
7199
|
+
return match(args[0](unbranded), {
|
|
7200
|
+
onNone: () => right(unbranded),
|
|
7201
|
+
onSome: left
|
|
7202
|
+
});
|
|
7203
|
+
};
|
|
7204
|
+
return Object.assign(unbranded => getOrThrowWith(either(unbranded), identity), {
|
|
7205
|
+
[RefinedConstructorsTypeId]: RefinedConstructorsTypeId,
|
|
7206
|
+
option: args => getRight(either(args)),
|
|
7207
|
+
either,
|
|
7208
|
+
is: args => isRight(either(args))
|
|
7209
|
+
});
|
|
7210
|
+
}
|
|
7211
|
+
|
|
7212
|
+
/** @internal */
|
|
7213
|
+
const TagTypeId = /*#__PURE__*/Symbol.for("effect/Context/Tag");
|
|
7214
|
+
/** @internal */
|
|
7215
|
+
const ReferenceTypeId = /*#__PURE__*/Symbol.for("effect/Context/Reference");
|
|
7216
|
+
/** @internal */
|
|
7217
|
+
const STMSymbolKey = "effect/STM";
|
|
7218
|
+
/** @internal */
|
|
7219
|
+
const STMTypeId = /*#__PURE__*/Symbol.for(STMSymbolKey);
|
|
7220
|
+
/** @internal */
|
|
7221
|
+
const TagProto = {
|
|
7222
|
+
...EffectPrototype$1,
|
|
7223
|
+
_op: "Tag",
|
|
7224
|
+
[STMTypeId]: effectVariance,
|
|
7225
|
+
[TagTypeId]: {
|
|
7226
|
+
_Service: _ => _,
|
|
7227
|
+
_Identifier: _ => _
|
|
7228
|
+
},
|
|
7229
|
+
toString() {
|
|
7230
|
+
return format(this.toJSON());
|
|
7231
|
+
},
|
|
7232
|
+
toJSON() {
|
|
7233
|
+
return {
|
|
7234
|
+
_id: "Tag",
|
|
7235
|
+
key: this.key,
|
|
7236
|
+
stack: this.stack
|
|
7237
|
+
};
|
|
7238
|
+
},
|
|
7239
|
+
[NodeInspectSymbol]() {
|
|
7240
|
+
return this.toJSON();
|
|
7241
|
+
},
|
|
7242
|
+
of(self) {
|
|
7243
|
+
return self;
|
|
7244
|
+
},
|
|
7245
|
+
context(self) {
|
|
7246
|
+
return make(this, self);
|
|
7247
|
+
}
|
|
7248
|
+
};
|
|
7249
|
+
const ReferenceProto = {
|
|
7250
|
+
...TagProto,
|
|
7251
|
+
[ReferenceTypeId]: ReferenceTypeId
|
|
7252
|
+
};
|
|
7253
|
+
/** @internal */
|
|
7254
|
+
const Reference$1 = () => (id, options) => {
|
|
7255
|
+
const limit = Error.stackTraceLimit;
|
|
7256
|
+
Error.stackTraceLimit = 2;
|
|
7257
|
+
const creationError = new Error();
|
|
7258
|
+
Error.stackTraceLimit = limit;
|
|
7259
|
+
function ReferenceClass() {}
|
|
7260
|
+
Object.setPrototypeOf(ReferenceClass, ReferenceProto);
|
|
7261
|
+
ReferenceClass.key = id;
|
|
7262
|
+
ReferenceClass.defaultValue = options.defaultValue;
|
|
7263
|
+
Object.defineProperty(ReferenceClass, "stack", {
|
|
7264
|
+
get() {
|
|
7265
|
+
return creationError.stack;
|
|
7266
|
+
}
|
|
7267
|
+
});
|
|
7268
|
+
return ReferenceClass;
|
|
7269
|
+
};
|
|
7270
|
+
/** @internal */
|
|
7271
|
+
const TypeId$1 = /*#__PURE__*/Symbol.for("effect/Context");
|
|
7272
|
+
/** @internal */
|
|
7273
|
+
const ContextProto = {
|
|
7274
|
+
[TypeId$1]: {
|
|
7275
|
+
_Services: _ => _
|
|
7276
|
+
},
|
|
7277
|
+
[symbol](that) {
|
|
7278
|
+
if (isContext(that)) {
|
|
7279
|
+
if (this.unsafeMap.size === that.unsafeMap.size) {
|
|
7280
|
+
for (const k of this.unsafeMap.keys()) {
|
|
7281
|
+
if (!that.unsafeMap.has(k) || !equals(this.unsafeMap.get(k), that.unsafeMap.get(k))) {
|
|
7282
|
+
return false;
|
|
7283
|
+
}
|
|
7284
|
+
}
|
|
7285
|
+
return true;
|
|
7286
|
+
}
|
|
7287
|
+
}
|
|
7288
|
+
return false;
|
|
7289
|
+
},
|
|
7290
|
+
[symbol$1]() {
|
|
7291
|
+
return cached(this, number(this.unsafeMap.size));
|
|
7292
|
+
},
|
|
7293
|
+
pipe() {
|
|
7294
|
+
return pipeArguments(this, arguments);
|
|
7295
|
+
},
|
|
7296
|
+
toString() {
|
|
7297
|
+
return format(this.toJSON());
|
|
7298
|
+
},
|
|
7299
|
+
toJSON() {
|
|
7300
|
+
return {
|
|
7301
|
+
_id: "Context",
|
|
7302
|
+
services: Array.from(this.unsafeMap).map(toJSON)
|
|
7303
|
+
};
|
|
7304
|
+
},
|
|
7305
|
+
[NodeInspectSymbol]() {
|
|
7306
|
+
return this.toJSON();
|
|
7307
|
+
}
|
|
7308
|
+
};
|
|
7309
|
+
/** @internal */
|
|
7310
|
+
const makeContext = unsafeMap => {
|
|
7311
|
+
const context = Object.create(ContextProto);
|
|
7312
|
+
context.unsafeMap = unsafeMap;
|
|
7313
|
+
return context;
|
|
7314
|
+
};
|
|
7315
|
+
/** @internal */
|
|
7316
|
+
const isContext = u => hasProperty(u, TypeId$1);
|
|
7317
|
+
/** @internal */
|
|
7318
|
+
const make = (tag, service) => makeContext(new Map([[tag.key, service]]));
|
|
7319
|
+
const defaultValueCache = /*#__PURE__*/globalValue("effect/Context/defaultValueCache", () => new Map());
|
|
7320
|
+
const getDefaultValue = tag => {
|
|
7321
|
+
if (defaultValueCache.has(tag.key)) {
|
|
7322
|
+
return defaultValueCache.get(tag.key);
|
|
7323
|
+
}
|
|
7324
|
+
const value = tag.defaultValue();
|
|
7325
|
+
defaultValueCache.set(tag.key, value);
|
|
7326
|
+
return value;
|
|
7327
|
+
};
|
|
7328
|
+
/** @internal */
|
|
7329
|
+
const unsafeGetReference = (self, tag) => {
|
|
7330
|
+
return self.unsafeMap.has(tag.key) ? self.unsafeMap.get(tag.key) : getDefaultValue(tag);
|
|
7331
|
+
};
|
|
7332
|
+
|
|
7333
|
+
/**
|
|
7334
|
+
* Creates a context tag with a default value.
|
|
7335
|
+
*
|
|
7336
|
+
* **Details**
|
|
7337
|
+
*
|
|
7338
|
+
* `Context.Reference` allows you to create a tag that can hold a value. You can
|
|
7339
|
+
* provide a default value for the service, which will automatically be used
|
|
7340
|
+
* when the context is accessed, or override it with a custom implementation
|
|
7341
|
+
* when needed.
|
|
7342
|
+
*
|
|
7343
|
+
* **Example** (Declaring a Tag with a default value)
|
|
7344
|
+
*
|
|
7345
|
+
* ```ts
|
|
7346
|
+
* import * as assert from "node:assert"
|
|
7347
|
+
* import { Context, Effect } from "effect"
|
|
7348
|
+
*
|
|
7349
|
+
* class SpecialNumber extends Context.Reference<SpecialNumber>()(
|
|
7350
|
+
* "SpecialNumber",
|
|
7351
|
+
* { defaultValue: () => 2048 }
|
|
7352
|
+
* ) {}
|
|
7353
|
+
*
|
|
7354
|
+
* // ┌─── Effect<void, never, never>
|
|
7355
|
+
* // ▼
|
|
7356
|
+
* const program = Effect.gen(function* () {
|
|
7357
|
+
* const specialNumber = yield* SpecialNumber
|
|
7358
|
+
* console.log(`The special number is ${specialNumber}`)
|
|
7359
|
+
* })
|
|
7360
|
+
*
|
|
7361
|
+
* // No need to provide the SpecialNumber implementation
|
|
7362
|
+
* Effect.runPromise(program)
|
|
7363
|
+
* // Output: The special number is 2048
|
|
7364
|
+
* ```
|
|
7365
|
+
*
|
|
7366
|
+
* **Example** (Overriding the default value)
|
|
7367
|
+
*
|
|
7368
|
+
* ```ts
|
|
7369
|
+
* import { Context, Effect } from "effect"
|
|
7370
|
+
*
|
|
7371
|
+
* class SpecialNumber extends Context.Reference<SpecialNumber>()(
|
|
7372
|
+
* "SpecialNumber",
|
|
7373
|
+
* { defaultValue: () => 2048 }
|
|
7374
|
+
* ) {}
|
|
7375
|
+
*
|
|
7376
|
+
* const program = Effect.gen(function* () {
|
|
7377
|
+
* const specialNumber = yield* SpecialNumber
|
|
7378
|
+
* console.log(`The special number is ${specialNumber}`)
|
|
7379
|
+
* })
|
|
7380
|
+
*
|
|
7381
|
+
* Effect.runPromise(program.pipe(Effect.provideService(SpecialNumber, -1)))
|
|
7382
|
+
* // Output: The special number is -1
|
|
7383
|
+
* ```
|
|
7384
|
+
*
|
|
7385
|
+
* @since 3.11.0
|
|
7386
|
+
* @category constructors
|
|
7387
|
+
* @experimental
|
|
7388
|
+
*/
|
|
7389
|
+
const Reference = Reference$1;
|
|
7390
|
+
|
|
7391
|
+
/**
|
|
7392
|
+
* @since 2.0.0
|
|
7393
|
+
* @category prototypes
|
|
7394
|
+
*/
|
|
7395
|
+
const EffectPrototype = EffectPrototype$1;
|
|
7396
|
+
|
|
7397
|
+
/**
|
|
7398
|
+
* A lightweight alternative to the `Effect` data type, with a subset of the functionality.
|
|
7399
|
+
*
|
|
7400
|
+
* @since 3.4.0
|
|
7401
|
+
* @experimental
|
|
7402
|
+
*/
|
|
7403
|
+
/**
|
|
7404
|
+
* @since 3.4.0
|
|
7405
|
+
* @experimental
|
|
7406
|
+
* @category type ids
|
|
7407
|
+
*/
|
|
7408
|
+
const TypeId = /*#__PURE__*/Symbol.for("effect/Micro");
|
|
7409
|
+
/**
|
|
7410
|
+
* @since 3.4.0
|
|
7411
|
+
* @experimental
|
|
7412
|
+
* @category MicroExit
|
|
7413
|
+
*/
|
|
7414
|
+
const MicroExitTypeId = /*#__PURE__*/Symbol.for("effect/Micro/MicroExit");
|
|
7415
|
+
// ----------------------------------------------------------------------------
|
|
7416
|
+
// MicroCause
|
|
7417
|
+
// ----------------------------------------------------------------------------
|
|
7418
|
+
/**
|
|
7419
|
+
* @since 3.4.6
|
|
7420
|
+
* @experimental
|
|
7421
|
+
* @category MicroCause
|
|
7422
|
+
*/
|
|
7423
|
+
const MicroCauseTypeId = /*#__PURE__*/Symbol.for("effect/Micro/MicroCause");
|
|
7424
|
+
const microCauseVariance = {
|
|
7425
|
+
_E: identity
|
|
7426
|
+
};
|
|
7427
|
+
class MicroCauseImpl extends globalThis.Error {
|
|
7428
|
+
_tag;
|
|
7429
|
+
traces;
|
|
7430
|
+
[MicroCauseTypeId];
|
|
7431
|
+
constructor(_tag, originalError, traces) {
|
|
7432
|
+
const causeName = `MicroCause.${_tag}`;
|
|
7433
|
+
let name;
|
|
7434
|
+
let message;
|
|
7435
|
+
let stack;
|
|
7436
|
+
if (originalError instanceof globalThis.Error) {
|
|
7437
|
+
name = `(${causeName}) ${originalError.name}`;
|
|
7438
|
+
message = originalError.message;
|
|
7439
|
+
const messageLines = message.split("\n").length;
|
|
7440
|
+
stack = originalError.stack ? `(${causeName}) ${originalError.stack.split("\n").slice(0, messageLines + 3).join("\n")}` : `${name}: ${message}`;
|
|
7441
|
+
} else {
|
|
7442
|
+
name = causeName;
|
|
7443
|
+
message = toStringUnknown(originalError, 0);
|
|
7444
|
+
stack = `${name}: ${message}`;
|
|
7445
|
+
}
|
|
7446
|
+
if (traces.length > 0) {
|
|
7447
|
+
stack += `\n ${traces.join("\n ")}`;
|
|
7448
|
+
}
|
|
7449
|
+
super(message);
|
|
7450
|
+
this._tag = _tag;
|
|
7451
|
+
this.traces = traces;
|
|
7452
|
+
this[MicroCauseTypeId] = microCauseVariance;
|
|
7453
|
+
this.name = name;
|
|
7454
|
+
this.stack = stack;
|
|
7455
|
+
}
|
|
7456
|
+
pipe() {
|
|
7457
|
+
return pipeArguments(this, arguments);
|
|
7458
|
+
}
|
|
7459
|
+
toString() {
|
|
7460
|
+
return this.stack;
|
|
7461
|
+
}
|
|
7462
|
+
[NodeInspectSymbol]() {
|
|
7463
|
+
return this.stack;
|
|
7464
|
+
}
|
|
7465
|
+
}
|
|
7466
|
+
class Fail extends MicroCauseImpl {
|
|
7467
|
+
error;
|
|
7468
|
+
constructor(error, traces = []) {
|
|
7469
|
+
super("Fail", error, traces);
|
|
7470
|
+
this.error = error;
|
|
7471
|
+
}
|
|
7472
|
+
}
|
|
7473
|
+
/**
|
|
7474
|
+
* @since 3.4.6
|
|
7475
|
+
* @experimental
|
|
7476
|
+
* @category MicroCause
|
|
7477
|
+
*/
|
|
7478
|
+
const causeFail = (error, traces = []) => new Fail(error, traces);
|
|
7479
|
+
class Die extends MicroCauseImpl {
|
|
7480
|
+
defect;
|
|
7481
|
+
constructor(defect, traces = []) {
|
|
7482
|
+
super("Die", defect, traces);
|
|
7483
|
+
this.defect = defect;
|
|
7484
|
+
}
|
|
7485
|
+
}
|
|
7486
|
+
/**
|
|
7487
|
+
* @since 3.4.6
|
|
7488
|
+
* @experimental
|
|
7489
|
+
* @category MicroCause
|
|
7490
|
+
*/
|
|
7491
|
+
const causeDie = (defect, traces = []) => new Die(defect, traces);
|
|
7492
|
+
class Interrupt extends MicroCauseImpl {
|
|
7493
|
+
constructor(traces = []) {
|
|
7494
|
+
super("Interrupt", "interrupted", traces);
|
|
7495
|
+
}
|
|
7496
|
+
}
|
|
7497
|
+
/**
|
|
7498
|
+
* @since 3.4.6
|
|
7499
|
+
* @experimental
|
|
7500
|
+
* @category MicroCause
|
|
7501
|
+
*/
|
|
7502
|
+
const causeInterrupt = (traces = []) => new Interrupt(traces);
|
|
7503
|
+
/**
|
|
7504
|
+
* @since 3.4.6
|
|
7505
|
+
* @experimental
|
|
7506
|
+
* @category MicroCause
|
|
7507
|
+
*/
|
|
7508
|
+
const causeIsInterrupt = self => self._tag === "Interrupt";
|
|
7509
|
+
// ----------------------------------------------------------------------------
|
|
7510
|
+
// MicroFiber
|
|
7511
|
+
// ----------------------------------------------------------------------------
|
|
7512
|
+
/**
|
|
7513
|
+
* @since 3.11.0
|
|
7514
|
+
* @experimental
|
|
7515
|
+
* @category MicroFiber
|
|
7516
|
+
*/
|
|
7517
|
+
const MicroFiberTypeId = /*#__PURE__*/Symbol.for("effect/Micro/MicroFiber");
|
|
7518
|
+
const fiberVariance = {
|
|
7519
|
+
_A: identity,
|
|
7520
|
+
_E: identity
|
|
7521
|
+
};
|
|
7522
|
+
class MicroFiberImpl {
|
|
7523
|
+
context;
|
|
7524
|
+
interruptible;
|
|
7525
|
+
[MicroFiberTypeId];
|
|
7526
|
+
_stack = [];
|
|
7527
|
+
_observers = [];
|
|
7528
|
+
_exit;
|
|
7529
|
+
_children;
|
|
7530
|
+
currentOpCount = 0;
|
|
7531
|
+
constructor(context, interruptible = true) {
|
|
7532
|
+
this.context = context;
|
|
7533
|
+
this.interruptible = interruptible;
|
|
7534
|
+
this[MicroFiberTypeId] = fiberVariance;
|
|
7535
|
+
}
|
|
7536
|
+
getRef(ref) {
|
|
7537
|
+
return unsafeGetReference(this.context, ref);
|
|
7538
|
+
}
|
|
7539
|
+
addObserver(cb) {
|
|
7540
|
+
if (this._exit) {
|
|
7541
|
+
cb(this._exit);
|
|
7542
|
+
return constVoid;
|
|
7543
|
+
}
|
|
7544
|
+
this._observers.push(cb);
|
|
7545
|
+
return () => {
|
|
7546
|
+
const index = this._observers.indexOf(cb);
|
|
7547
|
+
if (index >= 0) {
|
|
7548
|
+
this._observers.splice(index, 1);
|
|
7549
|
+
}
|
|
7550
|
+
};
|
|
7551
|
+
}
|
|
7552
|
+
_interrupted = false;
|
|
7553
|
+
unsafeInterrupt() {
|
|
7554
|
+
if (this._exit) {
|
|
7555
|
+
return;
|
|
7556
|
+
}
|
|
7557
|
+
this._interrupted = true;
|
|
7558
|
+
if (this.interruptible) {
|
|
7559
|
+
this.evaluate(exitInterrupt);
|
|
7560
|
+
}
|
|
7561
|
+
}
|
|
7562
|
+
unsafePoll() {
|
|
7563
|
+
return this._exit;
|
|
7564
|
+
}
|
|
7565
|
+
evaluate(effect) {
|
|
7566
|
+
if (this._exit) {
|
|
7567
|
+
return;
|
|
7568
|
+
} else if (this._yielded !== undefined) {
|
|
7569
|
+
const yielded = this._yielded;
|
|
7570
|
+
this._yielded = undefined;
|
|
7571
|
+
yielded();
|
|
7572
|
+
}
|
|
7573
|
+
const exit = this.runLoop(effect);
|
|
7574
|
+
if (exit === Yield) {
|
|
7575
|
+
return;
|
|
7576
|
+
}
|
|
7577
|
+
// the interruptChildren middlware is added in Micro.fork, so it can be
|
|
7578
|
+
// tree-shaken if not used
|
|
7579
|
+
const interruptChildren = fiberMiddleware.interruptChildren && fiberMiddleware.interruptChildren(this);
|
|
7580
|
+
if (interruptChildren !== undefined) {
|
|
7581
|
+
return this.evaluate(flatMap(interruptChildren, () => exit));
|
|
7582
|
+
}
|
|
7583
|
+
this._exit = exit;
|
|
7584
|
+
for (let i = 0; i < this._observers.length; i++) {
|
|
7585
|
+
this._observers[i](exit);
|
|
7586
|
+
}
|
|
7587
|
+
this._observers.length = 0;
|
|
7588
|
+
}
|
|
7589
|
+
runLoop(effect) {
|
|
7590
|
+
let yielding = false;
|
|
7591
|
+
let current = effect;
|
|
7592
|
+
this.currentOpCount = 0;
|
|
7593
|
+
try {
|
|
7594
|
+
while (true) {
|
|
7595
|
+
this.currentOpCount++;
|
|
7596
|
+
if (!yielding && this.getRef(CurrentScheduler).shouldYield(this)) {
|
|
7597
|
+
yielding = true;
|
|
7598
|
+
const prev = current;
|
|
7599
|
+
current = flatMap(yieldNow, () => prev);
|
|
7600
|
+
}
|
|
7601
|
+
current = current[evaluate](this);
|
|
7602
|
+
if (current === Yield) {
|
|
7603
|
+
const yielded = this._yielded;
|
|
7604
|
+
if (MicroExitTypeId in yielded) {
|
|
7605
|
+
this._yielded = undefined;
|
|
7606
|
+
return yielded;
|
|
7607
|
+
}
|
|
7608
|
+
return Yield;
|
|
7609
|
+
}
|
|
7610
|
+
}
|
|
7611
|
+
} catch (error) {
|
|
7612
|
+
if (!hasProperty(current, evaluate)) {
|
|
7613
|
+
return exitDie(`MicroFiber.runLoop: Not a valid effect: ${String(current)}`);
|
|
7614
|
+
}
|
|
7615
|
+
return exitDie(error);
|
|
7616
|
+
}
|
|
7617
|
+
}
|
|
7618
|
+
getCont(symbol) {
|
|
7619
|
+
while (true) {
|
|
7620
|
+
const op = this._stack.pop();
|
|
7621
|
+
if (!op) return undefined;
|
|
7622
|
+
const cont = op[ensureCont] && op[ensureCont](this);
|
|
7623
|
+
if (cont) return {
|
|
7624
|
+
[symbol]: cont
|
|
7625
|
+
};
|
|
7626
|
+
if (op[symbol]) return op;
|
|
7627
|
+
}
|
|
7628
|
+
}
|
|
7629
|
+
// cancel the yielded operation, or for the yielded exit value
|
|
7630
|
+
_yielded = undefined;
|
|
7631
|
+
yieldWith(value) {
|
|
7632
|
+
this._yielded = value;
|
|
7633
|
+
return Yield;
|
|
7634
|
+
}
|
|
7635
|
+
children() {
|
|
7636
|
+
return this._children ??= new Set();
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7639
|
+
const fiberMiddleware = /*#__PURE__*/globalValue("effect/Micro/fiberMiddleware", () => ({
|
|
7640
|
+
interruptChildren: undefined
|
|
7641
|
+
}));
|
|
7642
|
+
const identifier = /*#__PURE__*/Symbol.for("effect/Micro/identifier");
|
|
7643
|
+
const args = /*#__PURE__*/Symbol.for("effect/Micro/args");
|
|
7644
|
+
const evaluate = /*#__PURE__*/Symbol.for("effect/Micro/evaluate");
|
|
7645
|
+
const successCont = /*#__PURE__*/Symbol.for("effect/Micro/successCont");
|
|
7646
|
+
const failureCont = /*#__PURE__*/Symbol.for("effect/Micro/failureCont");
|
|
7647
|
+
const ensureCont = /*#__PURE__*/Symbol.for("effect/Micro/ensureCont");
|
|
7648
|
+
const Yield = /*#__PURE__*/Symbol.for("effect/Micro/Yield");
|
|
7649
|
+
const microVariance = {
|
|
7650
|
+
_A: identity,
|
|
7651
|
+
_E: identity,
|
|
7652
|
+
_R: identity
|
|
7653
|
+
};
|
|
7654
|
+
const MicroProto = {
|
|
7655
|
+
...EffectPrototype,
|
|
7656
|
+
_op: "Micro",
|
|
7657
|
+
[TypeId]: microVariance,
|
|
7658
|
+
pipe() {
|
|
7659
|
+
return pipeArguments(this, arguments);
|
|
7660
|
+
},
|
|
7661
|
+
[Symbol.iterator]() {
|
|
7662
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
7663
|
+
},
|
|
7664
|
+
toJSON() {
|
|
7665
|
+
return {
|
|
7666
|
+
_id: "Micro",
|
|
7667
|
+
op: this[identifier],
|
|
7668
|
+
...(args in this ? {
|
|
7669
|
+
args: this[args]
|
|
7670
|
+
} : undefined)
|
|
7671
|
+
};
|
|
7672
|
+
},
|
|
7673
|
+
toString() {
|
|
7674
|
+
return format(this);
|
|
7675
|
+
},
|
|
7676
|
+
[NodeInspectSymbol]() {
|
|
7677
|
+
return format(this);
|
|
7678
|
+
}
|
|
7679
|
+
};
|
|
7680
|
+
function defaultEvaluate(_fiber) {
|
|
7681
|
+
return exitDie(`Micro.evaluate: Not implemented`);
|
|
7682
|
+
}
|
|
7683
|
+
const makePrimitiveProto = options => ({
|
|
7684
|
+
...MicroProto,
|
|
7685
|
+
[identifier]: options.op,
|
|
7686
|
+
[evaluate]: options.eval ?? defaultEvaluate,
|
|
7687
|
+
[successCont]: options.contA,
|
|
7688
|
+
[failureCont]: options.contE,
|
|
7689
|
+
[ensureCont]: options.ensure
|
|
7690
|
+
});
|
|
7691
|
+
const makePrimitive = options => {
|
|
7692
|
+
const Proto = makePrimitiveProto(options);
|
|
7693
|
+
return function () {
|
|
7694
|
+
const self = Object.create(Proto);
|
|
7695
|
+
self[args] = options.single === false ? arguments : arguments[0];
|
|
7696
|
+
return self;
|
|
7697
|
+
};
|
|
7698
|
+
};
|
|
7699
|
+
const makeExit = options => {
|
|
7700
|
+
const Proto = {
|
|
7701
|
+
...makePrimitiveProto(options),
|
|
7702
|
+
[MicroExitTypeId]: MicroExitTypeId,
|
|
7703
|
+
_tag: options.op,
|
|
7704
|
+
get [options.prop]() {
|
|
7705
|
+
return this[args];
|
|
7706
|
+
},
|
|
7707
|
+
toJSON() {
|
|
7708
|
+
return {
|
|
7709
|
+
_id: "MicroExit",
|
|
7710
|
+
_tag: options.op,
|
|
7711
|
+
[options.prop]: this[args]
|
|
7712
|
+
};
|
|
7713
|
+
},
|
|
7714
|
+
[symbol](that) {
|
|
7715
|
+
return isMicroExit(that) && that._tag === options.op && equals(this[args], that[args]);
|
|
7716
|
+
},
|
|
7717
|
+
[symbol$1]() {
|
|
7718
|
+
return cached(this, combine(string(options.op))(hash(this[args])));
|
|
7719
|
+
}
|
|
7720
|
+
};
|
|
7721
|
+
return function (value) {
|
|
7722
|
+
const self = Object.create(Proto);
|
|
7723
|
+
self[args] = value;
|
|
7724
|
+
self[successCont] = undefined;
|
|
7725
|
+
self[failureCont] = undefined;
|
|
7726
|
+
self[ensureCont] = undefined;
|
|
7727
|
+
return self;
|
|
7728
|
+
};
|
|
7729
|
+
};
|
|
7730
|
+
/**
|
|
7731
|
+
* Creates a `Micro` effect that will succeed with the specified constant value.
|
|
7732
|
+
*
|
|
7733
|
+
* @since 3.4.0
|
|
7734
|
+
* @experimental
|
|
7735
|
+
* @category constructors
|
|
7736
|
+
*/
|
|
7737
|
+
const succeed = /*#__PURE__*/makeExit({
|
|
7738
|
+
op: "Success",
|
|
7739
|
+
prop: "value",
|
|
7740
|
+
eval(fiber) {
|
|
7741
|
+
const cont = fiber.getCont(successCont);
|
|
7742
|
+
return cont ? cont[successCont](this[args], fiber) : fiber.yieldWith(this);
|
|
7743
|
+
}
|
|
7744
|
+
});
|
|
7745
|
+
/**
|
|
7746
|
+
* Creates a `Micro` effect that will fail with the specified `MicroCause`.
|
|
7747
|
+
*
|
|
7748
|
+
* @since 3.4.6
|
|
7749
|
+
* @experimental
|
|
7750
|
+
* @category constructors
|
|
7751
|
+
*/
|
|
7752
|
+
const failCause = /*#__PURE__*/makeExit({
|
|
7753
|
+
op: "Failure",
|
|
7754
|
+
prop: "cause",
|
|
7755
|
+
eval(fiber) {
|
|
7756
|
+
let cont = fiber.getCont(failureCont);
|
|
7757
|
+
while (causeIsInterrupt(this[args]) && cont && fiber.interruptible) {
|
|
7758
|
+
cont = fiber.getCont(failureCont);
|
|
7759
|
+
}
|
|
7760
|
+
return cont ? cont[failureCont](this[args], fiber) : fiber.yieldWith(this);
|
|
7761
|
+
}
|
|
7762
|
+
});
|
|
7763
|
+
/**
|
|
7764
|
+
* Creates a `Micro` effect that fails with the given error.
|
|
7765
|
+
*
|
|
7766
|
+
* This results in a `Fail` variant of the `MicroCause` type, where the error is
|
|
7767
|
+
* tracked at the type level.
|
|
7768
|
+
*
|
|
7769
|
+
* @since 3.4.0
|
|
7770
|
+
* @experimental
|
|
7771
|
+
* @category constructors
|
|
7772
|
+
*/
|
|
7773
|
+
const fail = error => failCause(causeFail(error));
|
|
7774
|
+
/**
|
|
7775
|
+
* Lazily creates a `Micro` effect from the given side-effect.
|
|
7776
|
+
*
|
|
7777
|
+
* @since 3.4.0
|
|
7778
|
+
* @experimental
|
|
7779
|
+
* @category constructors
|
|
7780
|
+
*/
|
|
7781
|
+
const suspend = /*#__PURE__*/makePrimitive({
|
|
7782
|
+
op: "Suspend",
|
|
7783
|
+
eval(_fiber) {
|
|
7784
|
+
return this[args]();
|
|
7785
|
+
}
|
|
7786
|
+
});
|
|
7787
|
+
/**
|
|
7788
|
+
* Pause the execution of the current `Micro` effect, and resume it on the next
|
|
7789
|
+
* scheduler tick.
|
|
7790
|
+
*
|
|
7791
|
+
* @since 3.4.0
|
|
7792
|
+
* @experimental
|
|
7793
|
+
* @category constructors
|
|
7794
|
+
*/
|
|
7795
|
+
const yieldNowWith = /*#__PURE__*/makePrimitive({
|
|
7796
|
+
op: "Yield",
|
|
7797
|
+
eval(fiber) {
|
|
7798
|
+
let resumed = false;
|
|
7799
|
+
fiber.getRef(CurrentScheduler).scheduleTask(() => {
|
|
7800
|
+
if (resumed) return;
|
|
7801
|
+
fiber.evaluate(exitVoid);
|
|
7802
|
+
}, this[args] ?? 0);
|
|
7803
|
+
return fiber.yieldWith(() => {
|
|
7804
|
+
resumed = true;
|
|
7805
|
+
});
|
|
7806
|
+
}
|
|
7807
|
+
});
|
|
7808
|
+
/**
|
|
7809
|
+
* Pause the execution of the current `Micro` effect, and resume it on the next
|
|
7810
|
+
* scheduler tick.
|
|
7811
|
+
*
|
|
7812
|
+
* @since 3.4.0
|
|
7813
|
+
* @experimental
|
|
7814
|
+
* @category constructors
|
|
7815
|
+
*/
|
|
7816
|
+
const yieldNow = /*#__PURE__*/yieldNowWith(0);
|
|
7817
|
+
const try_ = options => suspend(() => {
|
|
7818
|
+
try {
|
|
7819
|
+
return succeed(options.try());
|
|
7820
|
+
} catch (err) {
|
|
7821
|
+
return fail(options.catch(err));
|
|
7822
|
+
}
|
|
7823
|
+
});
|
|
7824
|
+
/**
|
|
7825
|
+
* Map the success value of this `Micro` effect to another `Micro` effect, then
|
|
7826
|
+
* flatten the result.
|
|
7827
|
+
*
|
|
7828
|
+
* @since 3.4.0
|
|
7829
|
+
* @experimental
|
|
7830
|
+
* @category mapping & sequencing
|
|
7831
|
+
*/
|
|
7832
|
+
const flatMap = /*#__PURE__*/dual(2, (self, f) => {
|
|
7833
|
+
const onSuccess = Object.create(OnSuccessProto);
|
|
7834
|
+
onSuccess[args] = self;
|
|
7835
|
+
onSuccess[successCont] = f;
|
|
7836
|
+
return onSuccess;
|
|
7837
|
+
});
|
|
7838
|
+
const OnSuccessProto = /*#__PURE__*/makePrimitiveProto({
|
|
7839
|
+
op: "OnSuccess",
|
|
7840
|
+
eval(fiber) {
|
|
7841
|
+
fiber._stack.push(this);
|
|
7842
|
+
return this[args];
|
|
7843
|
+
}
|
|
7844
|
+
});
|
|
7845
|
+
/**
|
|
7846
|
+
* @since 3.4.6
|
|
7847
|
+
* @experimental
|
|
7848
|
+
* @category MicroExit
|
|
7849
|
+
*/
|
|
7850
|
+
const isMicroExit = u => hasProperty(u, MicroExitTypeId);
|
|
7851
|
+
/**
|
|
7852
|
+
* @since 3.4.6
|
|
7853
|
+
* @experimental
|
|
7854
|
+
* @category MicroExit
|
|
7855
|
+
*/
|
|
7856
|
+
const exitSucceed = succeed;
|
|
7857
|
+
/**
|
|
7858
|
+
* @since 3.4.6
|
|
7859
|
+
* @experimental
|
|
7860
|
+
* @category MicroExit
|
|
7861
|
+
*/
|
|
7862
|
+
const exitFailCause = failCause;
|
|
7863
|
+
/**
|
|
7864
|
+
* @since 3.4.6
|
|
7865
|
+
* @experimental
|
|
7866
|
+
* @category MicroExit
|
|
7867
|
+
*/
|
|
7868
|
+
const exitInterrupt = /*#__PURE__*/exitFailCause(/*#__PURE__*/causeInterrupt());
|
|
7869
|
+
/**
|
|
7870
|
+
* @since 3.4.6
|
|
7871
|
+
* @experimental
|
|
7872
|
+
* @category MicroExit
|
|
7873
|
+
*/
|
|
7874
|
+
const exitDie = defect => exitFailCause(causeDie(defect));
|
|
7875
|
+
/**
|
|
7876
|
+
* @since 3.4.6
|
|
7877
|
+
* @experimental
|
|
7878
|
+
* @category MicroExit
|
|
7879
|
+
*/
|
|
7880
|
+
const exitVoid = /*#__PURE__*/exitSucceed(void 0);
|
|
7881
|
+
const setImmediate = "setImmediate" in globalThis ? globalThis.setImmediate : f => setTimeout(f, 0);
|
|
7882
|
+
/**
|
|
7883
|
+
* @since 3.5.9
|
|
7884
|
+
* @experimental
|
|
7885
|
+
* @category scheduler
|
|
7886
|
+
*/
|
|
7887
|
+
class MicroSchedulerDefault {
|
|
7888
|
+
tasks = [];
|
|
7889
|
+
running = false;
|
|
7890
|
+
/**
|
|
7891
|
+
* @since 3.5.9
|
|
7892
|
+
*/
|
|
7893
|
+
scheduleTask(task, _priority) {
|
|
7894
|
+
this.tasks.push(task);
|
|
7895
|
+
if (!this.running) {
|
|
7896
|
+
this.running = true;
|
|
7897
|
+
setImmediate(this.afterScheduled);
|
|
7898
|
+
}
|
|
7899
|
+
}
|
|
7900
|
+
/**
|
|
7901
|
+
* @since 3.5.9
|
|
7902
|
+
*/
|
|
7903
|
+
afterScheduled = () => {
|
|
7904
|
+
this.running = false;
|
|
7905
|
+
this.runTasks();
|
|
7906
|
+
};
|
|
7907
|
+
/**
|
|
7908
|
+
* @since 3.5.9
|
|
7909
|
+
*/
|
|
7910
|
+
runTasks() {
|
|
7911
|
+
const tasks = this.tasks;
|
|
7912
|
+
this.tasks = [];
|
|
7913
|
+
for (let i = 0, len = tasks.length; i < len; i++) {
|
|
7914
|
+
tasks[i]();
|
|
7915
|
+
}
|
|
7916
|
+
}
|
|
7917
|
+
/**
|
|
7918
|
+
* @since 3.5.9
|
|
7919
|
+
*/
|
|
7920
|
+
shouldYield(fiber) {
|
|
7921
|
+
return fiber.currentOpCount >= fiber.getRef(MaxOpsBeforeYield);
|
|
7922
|
+
}
|
|
7923
|
+
/**
|
|
7924
|
+
* @since 3.5.9
|
|
7925
|
+
*/
|
|
7926
|
+
flush() {
|
|
7927
|
+
while (this.tasks.length > 0) {
|
|
7928
|
+
this.runTasks();
|
|
7929
|
+
}
|
|
7930
|
+
}
|
|
7931
|
+
}
|
|
7932
|
+
// ========================================================================
|
|
7933
|
+
// References
|
|
7934
|
+
// ========================================================================
|
|
7935
|
+
/**
|
|
7936
|
+
* @since 3.11.0
|
|
7937
|
+
* @experimental
|
|
7938
|
+
* @category references
|
|
7939
|
+
*/
|
|
7940
|
+
class MaxOpsBeforeYield extends /*#__PURE__*/Reference()("effect/Micro/currentMaxOpsBeforeYield", {
|
|
7941
|
+
defaultValue: () => 2048
|
|
7942
|
+
}) {}
|
|
7943
|
+
/**
|
|
7944
|
+
* @since 3.11.0
|
|
7945
|
+
* @experimental
|
|
7946
|
+
* @category environment refs
|
|
7947
|
+
*/
|
|
7948
|
+
class CurrentScheduler extends /*#__PURE__*/Reference()("effect/Micro/currentScheduler", {
|
|
7949
|
+
defaultValue: () => new MicroSchedulerDefault()
|
|
7950
|
+
}) {}
|
|
7951
|
+
// ----------------------------------------------------------------------------
|
|
7952
|
+
// execution
|
|
7953
|
+
// ----------------------------------------------------------------------------
|
|
7954
|
+
/**
|
|
7955
|
+
* Execute the `Micro` effect and return a `MicroFiber` that can be awaited, joined,
|
|
7956
|
+
* or aborted.
|
|
7957
|
+
*
|
|
7958
|
+
* You can listen for the result by adding an observer using the handle's
|
|
7959
|
+
* `addObserver` method.
|
|
7960
|
+
*
|
|
7961
|
+
* @example
|
|
7962
|
+
* ```ts
|
|
7963
|
+
* import * as Micro from "effect/Micro"
|
|
7964
|
+
*
|
|
7965
|
+
* const handle = Micro.succeed(42).pipe(
|
|
7966
|
+
* Micro.delay(1000),
|
|
7967
|
+
* Micro.runFork
|
|
7968
|
+
* )
|
|
7969
|
+
*
|
|
7970
|
+
* handle.addObserver((exit) => {
|
|
7971
|
+
* console.log(exit)
|
|
7972
|
+
* })
|
|
7973
|
+
* ```
|
|
7974
|
+
*
|
|
7975
|
+
* @since 3.4.0
|
|
7976
|
+
* @experimental
|
|
7977
|
+
* @category execution
|
|
7978
|
+
*/
|
|
7979
|
+
const runFork = (effect, options) => {
|
|
7980
|
+
const fiber = new MicroFiberImpl(CurrentScheduler.context(options?.scheduler ?? new MicroSchedulerDefault()));
|
|
7981
|
+
fiber.evaluate(effect);
|
|
7982
|
+
if (options?.signal) {
|
|
7983
|
+
if (options.signal.aborted) {
|
|
7984
|
+
fiber.unsafeInterrupt();
|
|
7985
|
+
} else {
|
|
7986
|
+
const abort = () => fiber.unsafeInterrupt();
|
|
7987
|
+
options.signal.addEventListener("abort", abort, {
|
|
7988
|
+
once: true
|
|
7989
|
+
});
|
|
7990
|
+
fiber.addObserver(() => options.signal.removeEventListener("abort", abort));
|
|
7991
|
+
}
|
|
7992
|
+
}
|
|
7993
|
+
return fiber;
|
|
7994
|
+
};
|
|
7995
|
+
/**
|
|
7996
|
+
* Attempt to execute the `Micro` effect synchronously and return the `MicroExit`.
|
|
7997
|
+
*
|
|
7998
|
+
* If any asynchronous effects are encountered, the function will return a
|
|
7999
|
+
* `CauseDie` containing the `MicroFiber`.
|
|
8000
|
+
*
|
|
8001
|
+
* @since 3.4.6
|
|
8002
|
+
* @experimental
|
|
8003
|
+
* @category execution
|
|
8004
|
+
*/
|
|
8005
|
+
const runSyncExit = effect => {
|
|
8006
|
+
const scheduler = new MicroSchedulerDefault();
|
|
8007
|
+
const fiber = runFork(effect, {
|
|
8008
|
+
scheduler
|
|
8009
|
+
});
|
|
8010
|
+
scheduler.flush();
|
|
8011
|
+
return fiber._exit ?? exitDie(fiber);
|
|
8012
|
+
};
|
|
8013
|
+
/**
|
|
8014
|
+
* Attempt to execute the `Micro` effect synchronously and return the success
|
|
8015
|
+
* value.
|
|
8016
|
+
*
|
|
8017
|
+
* @since 3.4.0
|
|
8018
|
+
* @experimental
|
|
8019
|
+
* @category execution
|
|
8020
|
+
*/
|
|
8021
|
+
const runSync = effect => {
|
|
8022
|
+
const exit = runSyncExit(effect);
|
|
8023
|
+
if (exit._tag === "Failure") throw exit.cause;
|
|
8024
|
+
return exit.value;
|
|
8025
|
+
};
|
|
8026
|
+
const YieldableError = /*#__PURE__*/function () {
|
|
8027
|
+
class YieldableError extends globalThis.Error {}
|
|
8028
|
+
// @effect-diagnostics-next-line floatingEffect:off
|
|
8029
|
+
Object.assign(YieldableError.prototype, MicroProto, StructuralPrototype, {
|
|
8030
|
+
[identifier]: "Failure",
|
|
8031
|
+
[evaluate]() {
|
|
8032
|
+
return fail(this);
|
|
8033
|
+
},
|
|
8034
|
+
toString() {
|
|
8035
|
+
return this.message ? `${this.name}: ${this.message}` : this.name;
|
|
8036
|
+
},
|
|
8037
|
+
toJSON() {
|
|
8038
|
+
return {
|
|
8039
|
+
...this
|
|
8040
|
+
};
|
|
8041
|
+
},
|
|
8042
|
+
[NodeInspectSymbol]() {
|
|
8043
|
+
const stack = this.stack;
|
|
8044
|
+
if (stack) {
|
|
8045
|
+
return `${this.toString()}\n${stack.split("\n").slice(1).join("\n")}`;
|
|
8046
|
+
}
|
|
8047
|
+
return this.toString();
|
|
8048
|
+
}
|
|
8049
|
+
});
|
|
8050
|
+
return YieldableError;
|
|
8051
|
+
}();
|
|
8052
|
+
/**
|
|
8053
|
+
* @since 3.4.0
|
|
8054
|
+
* @experimental
|
|
8055
|
+
* @category errors
|
|
8056
|
+
*/
|
|
8057
|
+
const Error$1 = /*#__PURE__*/function () {
|
|
8058
|
+
return class extends YieldableError {
|
|
8059
|
+
constructor(args) {
|
|
8060
|
+
super();
|
|
8061
|
+
if (args) {
|
|
8062
|
+
Object.assign(this, args);
|
|
8063
|
+
}
|
|
8064
|
+
}
|
|
8065
|
+
};
|
|
8066
|
+
}();
|
|
8067
|
+
/**
|
|
8068
|
+
* @since 3.4.0
|
|
8069
|
+
* @experimental
|
|
8070
|
+
* @category errors
|
|
8071
|
+
*/
|
|
8072
|
+
const TaggedError = tag => {
|
|
8073
|
+
class Base extends Error$1 {
|
|
8074
|
+
_tag = tag;
|
|
8075
|
+
}
|
|
8076
|
+
Base.prototype.name = tag;
|
|
8077
|
+
return Base;
|
|
8078
|
+
};
|
|
8079
|
+
|
|
8080
|
+
const hasProcessStdout = typeof process === "object" && process !== null && typeof process.stdout === "object" && process.stdout !== null;
|
|
8081
|
+
hasProcessStdout && process.stdout.isTTY === true;
|
|
8082
|
+
|
|
8083
|
+
const SVGString = refined(isValidSVG, () => error('SVG data is malformed'));
|
|
8084
|
+
class BrandValidationError extends TaggedError('BrandValidationError') {
|
|
8085
|
+
constructor(error, type) {
|
|
8086
|
+
super(new Error(`Brand validation failed for type ${type}.`, { cause: error }));
|
|
8087
|
+
}
|
|
8088
|
+
}
|
|
8089
|
+
/**
|
|
8090
|
+
* Creates a synchronous Micro effect that validates a string against the branded `SVGString` type.
|
|
8091
|
+
*
|
|
8092
|
+
* @param svg Raw SVG markup to validate.
|
|
8093
|
+
*/
|
|
8094
|
+
const validateSvg = (svg) => try_({
|
|
8095
|
+
try: () => SVGString(sanitizeSvg(svg)),
|
|
8096
|
+
catch: (error) => new BrandValidationError(error, 'SVGString'),
|
|
8097
|
+
});
|
|
8098
|
+
/**
|
|
8099
|
+
* Checks whether a string can be parsed into an SVG document.
|
|
8100
|
+
*
|
|
8101
|
+
* @param svg Raw SVG markup to validate.
|
|
8102
|
+
*/
|
|
8103
|
+
function isValidSVG(svg) {
|
|
8104
|
+
if (typeof svg !== 'string')
|
|
8105
|
+
return false;
|
|
8106
|
+
try {
|
|
8107
|
+
const parser = new DOMParser();
|
|
8108
|
+
const doc = parser.parseFromString(svg, 'image/svg+xml');
|
|
8109
|
+
return doc.documentElement.nodeName === 'svg';
|
|
8110
|
+
}
|
|
8111
|
+
catch {
|
|
8112
|
+
return false;
|
|
8113
|
+
}
|
|
8114
|
+
}
|
|
8115
|
+
function sanitizeSvg(svg) {
|
|
8116
|
+
const dataUriPrefix = 'data:image/svg+xml,';
|
|
8117
|
+
const dataUriPrefixWithEncoding = 'data:image/svg+xml;base64,';
|
|
8118
|
+
const base = svg.trim();
|
|
8119
|
+
if (base.startsWith(dataUriPrefixWithEncoding)) {
|
|
8120
|
+
return atob(base.slice(dataUriPrefixWithEncoding.length));
|
|
8121
|
+
}
|
|
8122
|
+
return !base.startsWith(dataUriPrefix) ? base : decodeURIComponent(base.slice(dataUriPrefix.length));
|
|
8123
|
+
}
|
|
8124
|
+
/**
|
|
8125
|
+
* Returns a valid, empty SVG.
|
|
8126
|
+
*/
|
|
8127
|
+
const emptyDefaultSvg = () => SVGString(`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"></svg>`);
|
|
8128
|
+
/**
|
|
8129
|
+
* Returns a valid SVG string, or a fallback empty SVG if the input is invalid.
|
|
8130
|
+
*
|
|
8131
|
+
* @param value The SVG string to validate.
|
|
8132
|
+
*/
|
|
8133
|
+
function toValidSvgStringWithFallback(value) {
|
|
8134
|
+
try {
|
|
8135
|
+
return runSync(validateSvg(value));
|
|
8136
|
+
}
|
|
8137
|
+
catch {
|
|
8138
|
+
console.warn('Invalid SVG string:', value);
|
|
8139
|
+
return emptyDefaultSvg();
|
|
8140
|
+
}
|
|
8141
|
+
}
|
|
8142
|
+
|
|
8143
|
+
const checkmarkSvg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIKICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgYXJpYS1oaWRkZW49InRydWUiIGZvY3VzYWJsZT0iZmFsc2UiPgogICAgPHBhdGggZD0iTTMuNzUgMTIuNTYyNUw4LjgzMDc5IDE3LjYyNUwyMC40Mzc1IDYuMzc1IiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+';
|
|
8144
|
+
|
|
8145
|
+
const lmvzCheckboxCss = () => `@layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } .sc-lmvz-checkbox-h { display: inline-block; --checkbox-box-size: var(--lmvz-global-s18, 18px); --checkbox-border-radius: var(--lmvz-global-s4, 4px); --checkbox-bg: var(--lmvz-semantic-color-surface-input-primary, #ffffff); --checkbox-border-color: var(--lmvz-semantic-color-border-default, #e0e0e0); --checkbox-border-color-hover: var(--lmvz-semantic-color-border-hover, #c7c7c7); --checkbox-border-color-checked: var(--lmvz-semantic-color-border-active, #0f8acc); --checkbox-border-color-error: var(--lmvz-semantic-color-status-on-danger, #e52a31); --checkbox-wrapper-bg-hover: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0); --checkbox-wrapper-bg-checked: var(--lmvz-semantic-color-status-active, #f1f9fe); --checkbox-ripple-bg: var(--lmvz-semantic-color-int-secondary-hover, #e0e0e0); --checkbox-checkmark-color: var(--lmvz-semantic-color-border-active, #0f8acc); --checkbox-label-color: var(--lmvz-semantic-color-on-surface-primary, #000000); --checkbox-label-color-checked: var(--lmvz-semantic-color-status-on-active, #0e7ab4); --checkbox-helper-color: var(--lmvz-semantic-color-on-surface-secondary, #7a7a7a); --checkbox-error-color: var(--lmvz-semantic-color-status-on-danger, #e52a31); --checkbox-focus-color: var(--lmvz-semantic-color-status-on-active, #0e7ab4); --checkbox-easing: var(--lmvz-global-easing-default, ease); --checkbox-duration: 0.2s; } .pill.sc-lmvz-checkbox { display: flex; align-items: center; gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); padding-block: var(--lmvz-dimension-2-8, clamp(0.13rem, 0.03rem + 0.39vw, 0.5rem)); padding-inline: var(--lmvz-dimension-4-10, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); border-radius: var(--lmvz-semantic-border-radius-round, 999px); cursor: pointer; text-decoration: none; background-color: transparent; transition: background-color var(--checkbox-duration) var(--checkbox-easing); } input.sc-lmvz-checkbox { position: absolute; opacity: 0; width: var(--checkbox-box-size); height: var(--checkbox-box-size); margin: 0; cursor: pointer; z-index: 1; } .box.sc-lmvz-checkbox { display: flex; align-items: center; justify-content: center; width: var(--checkbox-box-size); height: var(--checkbox-box-size); background-color: var(--checkbox-bg); border: var(--lmvz-semantic-border-width-default, 1px) solid var(--checkbox-border-color); border-radius: var(--checkbox-border-radius); color: var(--checkbox-checkmark-color); transition: border-color var(--checkbox-duration) var(--checkbox-easing), background-color var(--checkbox-duration) var(--checkbox-easing); pointer-events: none; flex-shrink: 0; } .indicator.sc-lmvz-checkbox { display: flex; align-items: center; justify-content: center; line-height: 0; } .content.sc-lmvz-checkbox { display: flex; flex-direction: column; overflow-wrap: break-word; min-width: 0; } label.sc-lmvz-checkbox { font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); color: var(--checkbox-label-color); transition: color var(--checkbox-duration) var(--checkbox-easing); } .helper-text.sc-lmvz-checkbox { font: var(--lmvz-typography-body-sm, 400 clamp(0.75rem, 0.73rem + 0.06vw, 0.81rem) / 1.4 Router); color: var(--checkbox-helper-color); margin-block-start: 2px; } .error-text.sc-lmvz-checkbox { font: var(--lmvz-typography-body-sm, 400 clamp(0.75rem, 0.73rem + 0.06vw, 0.81rem) / 1.4 Router); color: var(--checkbox-error-color); display: block; margin-block-start: 4px; padding-inline: 10px; } @media (hover: hover) { .pill.sc-lmvz-checkbox:hover { background-color: var(--checkbox-wrapper-bg-hover); } .pill.sc-lmvz-checkbox:hover .box.sc-lmvz-checkbox { border-color: var(--checkbox-border-color-hover); } } [checked].sc-lmvz-checkbox-h .pill.sc-lmvz-checkbox { background-color: var(--checkbox-wrapper-bg-checked); } [checked].sc-lmvz-checkbox-h .box.sc-lmvz-checkbox { border-color: var(--checkbox-border-color-checked); } [checked].sc-lmvz-checkbox-h label.sc-lmvz-checkbox { color: var(--checkbox-label-color-checked); } [error].sc-lmvz-checkbox-h .box.sc-lmvz-checkbox { border-color: var(--checkbox-border-color-error); } [error].sc-lmvz-checkbox-h .helper-text.sc-lmvz-checkbox { color: var(--checkbox-error-color); } [disabled].sc-lmvz-checkbox-h { opacity: var(--lmvz-component-input-disabled-opacity, 40%); pointer-events: none; } [disabled].sc-lmvz-checkbox-h .pill.sc-lmvz-checkbox { cursor: not-allowed; } [disabled].sc-lmvz-checkbox-h input.sc-lmvz-checkbox { cursor: not-allowed; } input.sc-lmvz-checkbox:focus-visible ~ .box.sc-lmvz-checkbox { outline: 2px solid var(--checkbox-focus-color); outline-offset: 2px; box-shadow: 0 var(--lmvz-semantic-shadow-l1-1-position-y, 2px) 0 var(--lmvz-semantic-shadow-l1-1-blur, 4px) var(--lmvz-semantic-color-shadow-l1-colored, rgba(175, 223, 249, 0.42)); } @media (forced-colors: active) { .box.sc-lmvz-checkbox { forced-color-adjust: auto; border-color: ButtonText; background-color: Field; } [checked].sc-lmvz-checkbox-h .box.sc-lmvz-checkbox { border-color: Highlight; background-color: Field; } .indicator.sc-lmvz-checkbox { color: ButtonText; } [checked].sc-lmvz-checkbox-h .indicator.sc-lmvz-checkbox { color: HighlightText; } input.sc-lmvz-checkbox:focus-visible ~ .box.sc-lmvz-checkbox { outline-color: Highlight; box-shadow: none; } }`;
|
|
8146
|
+
|
|
8147
|
+
const CHECKMARK_SVG = toValidSvgStringWithFallback(checkmarkSvg);
|
|
8148
|
+
let checkboxIdCounter = 0;
|
|
8149
|
+
class LmvzCheckbox extends ReactiveControllerHost {
|
|
8150
|
+
get el() { return getElement(this); }
|
|
8151
|
+
get validationEl() {
|
|
8152
|
+
return this.el;
|
|
8153
|
+
}
|
|
8154
|
+
internals;
|
|
8155
|
+
nativeInput;
|
|
8156
|
+
checkboxId = `lmvz-checkbox-${checkboxIdCounter++}`;
|
|
8157
|
+
initialChecked = false;
|
|
8158
|
+
get helperId() {
|
|
8159
|
+
return this.helperText ? `${this.checkboxId}-helper` : undefined;
|
|
8160
|
+
}
|
|
8161
|
+
get errorId() {
|
|
8162
|
+
return this.errorMessage ? `${this.checkboxId}-error` : undefined;
|
|
8163
|
+
}
|
|
8164
|
+
get ariaDescribedBy() {
|
|
8165
|
+
const ids = [this.errorId, this.helperId].filter(Boolean);
|
|
8166
|
+
return ids.length > 0 ? ids.join(' ') : undefined;
|
|
8167
|
+
}
|
|
8168
|
+
label;
|
|
8169
|
+
checked = false;
|
|
8170
|
+
value = 'on';
|
|
8171
|
+
name;
|
|
8172
|
+
disabled = false;
|
|
8173
|
+
required = false;
|
|
8174
|
+
error = false;
|
|
8175
|
+
errorMessage;
|
|
8176
|
+
helperText;
|
|
8177
|
+
form;
|
|
8178
|
+
autofocus = false;
|
|
8179
|
+
checkedState = false;
|
|
8180
|
+
handleCheckedChange(val) {
|
|
8181
|
+
this.checkedState = val;
|
|
8182
|
+
this.internals.setFormValue?.(val ? (this.value ?? 'on') : null);
|
|
8183
|
+
}
|
|
8184
|
+
lmvzChange;
|
|
8185
|
+
async focusInput() {
|
|
8186
|
+
this.nativeInput?.focus();
|
|
8187
|
+
}
|
|
8188
|
+
async checkValidity() {
|
|
8189
|
+
return this.internals?.checkValidity() ?? true;
|
|
8190
|
+
}
|
|
8191
|
+
async reportValidity() {
|
|
8192
|
+
return this.internals?.reportValidity() ?? true;
|
|
8193
|
+
}
|
|
8194
|
+
constructor(hostRef) {
|
|
8195
|
+
super();
|
|
8196
|
+
registerInstance(this, hostRef);
|
|
8197
|
+
this.lmvzChange = createEvent(this, "lmvzChange");
|
|
8198
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
8199
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
8200
|
+
}
|
|
8201
|
+
else {
|
|
8202
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
8203
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
8204
|
+
}
|
|
8205
|
+
this.addController(new AriaValidationController(this, {
|
|
8206
|
+
reValidateOnPropChanges: true,
|
|
8207
|
+
}));
|
|
8208
|
+
}
|
|
8209
|
+
componentWillLoad() {
|
|
8210
|
+
this.initialChecked = this.checked;
|
|
8211
|
+
this.checkedState = this.checked;
|
|
8212
|
+
this.internals.setFormValue?.(this.checked ? (this.value ?? 'on') : null);
|
|
8213
|
+
super.componentWillLoad();
|
|
8214
|
+
}
|
|
8215
|
+
componentWillRender() {
|
|
8216
|
+
if (this.error && !this.errorMessage) {
|
|
8217
|
+
console.warn('lmvz-checkbox: error=true set without errorMessage — no visual-only error state is rendered. Provide errorMessage to communicate the error to users.');
|
|
8218
|
+
}
|
|
8219
|
+
super.componentWillRender();
|
|
8220
|
+
}
|
|
8221
|
+
formAssociatedCallback() {
|
|
8222
|
+
this.internals.setFormValue?.(this.checked ? (this.value ?? 'on') : null);
|
|
8223
|
+
}
|
|
8224
|
+
formResetCallback() {
|
|
8225
|
+
this.checked = this.initialChecked;
|
|
8226
|
+
}
|
|
8227
|
+
formStateRestoreCallback(state) {
|
|
8228
|
+
this.checked = state === (this.value ?? 'on');
|
|
8229
|
+
}
|
|
8230
|
+
handleChange = (event) => {
|
|
8231
|
+
const input = event.target;
|
|
8232
|
+
this.checked = input.checked;
|
|
8233
|
+
this.lmvzChange.emit(this.checked);
|
|
8234
|
+
};
|
|
8235
|
+
render() {
|
|
8236
|
+
return (hAsync(Host, { key: '6014c885305bc9824f7a6d4f0ba8c642125f3a5b' }, hAsync("div", { key: 'cbc6de2b684acfb00b77a366e707d73de74a0b8a', class: "pill" }, hAsync("input", { key: '5b442512b6cab2e60a1d62fd40e4c868b1bf87ac', type: "checkbox", id: this.checkboxId, checked: this.checkedState, disabled: this.disabled, required: this.required, "aria-required": this.required ? 'true' : 'false', "aria-invalid": this.error ? 'true' : 'false', "aria-describedby": this.ariaDescribedBy, "aria-errormessage": this.error && this.errorId ? this.errorId : undefined, ref: (el) => (this.nativeInput = el), onChange: this.handleChange, autoFocus: this.autofocus }), hAsync("span", { key: '09c534b7c5642c620129ea05a4468bd584c56ce7', class: "box", "aria-hidden": "true" }, this.checkedState && hAsync("span", { key: 'eaa49e1a60054f8efc62ade0446a4704f0bb46e9', class: "indicator", innerHTML: CHECKMARK_SVG })), hAsync("span", { key: '8fb836d71cbb3d4eadaf67284f5bb52906549275', class: "content" }, hAsync("label", { key: '8df862f11e9885158264908fdac6599f21ecba07', htmlFor: this.checkboxId }, this.label), this.helperText && (hAsync("span", { key: '1e45e6177774e937311cddacd1a3d3379c9c6af5', class: "helper-text", id: this.helperId, role: "status" }, this.helperText)))), this.errorMessage && (hAsync("span", { key: '83fc1f7cd6828973e52ef27604f12f94f41d7f4b', class: "error-text", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
8237
|
+
}
|
|
8238
|
+
static get formAssociated() { return true; }
|
|
8239
|
+
static get watchers() { return {
|
|
8240
|
+
"checked": [{
|
|
8241
|
+
"handleCheckedChange": 0
|
|
8242
|
+
}]
|
|
8243
|
+
}; }
|
|
8244
|
+
static get style() { return lmvzCheckboxCss(); }
|
|
8245
|
+
static get cmpMeta() { return {
|
|
8246
|
+
"$flags$": 578,
|
|
8247
|
+
"$tagName$": "lmvz-checkbox",
|
|
8248
|
+
"$members$": {
|
|
8249
|
+
"label": [1],
|
|
8250
|
+
"checked": [1540],
|
|
8251
|
+
"value": [1],
|
|
8252
|
+
"name": [1],
|
|
8253
|
+
"disabled": [516],
|
|
8254
|
+
"required": [516],
|
|
8255
|
+
"error": [516],
|
|
8256
|
+
"errorMessage": [1, "error-message"],
|
|
8257
|
+
"helperText": [1, "helper-text"],
|
|
8258
|
+
"form": [1],
|
|
8259
|
+
"autofocus": [4],
|
|
8260
|
+
"checkedState": [32],
|
|
8261
|
+
"focusInput": [64],
|
|
8262
|
+
"checkValidity": [64],
|
|
8263
|
+
"reportValidity": [64]
|
|
8264
|
+
},
|
|
8265
|
+
"$listeners$": undefined,
|
|
8266
|
+
"$lazyBundleId$": "-",
|
|
8267
|
+
"$attrsToReflect$": [["checked", "checked"], ["disabled", "disabled"], ["required", "required"], ["error", "error"]]
|
|
8268
|
+
}; }
|
|
8269
|
+
}
|
|
8270
|
+
|
|
8271
|
+
function debounce(func, wait) {
|
|
8272
|
+
let timeout;
|
|
8273
|
+
return () => {
|
|
8274
|
+
if (timeout !== undefined) {
|
|
8275
|
+
window.clearTimeout(timeout);
|
|
8276
|
+
}
|
|
8277
|
+
timeout = window.setTimeout(() => {
|
|
8278
|
+
func();
|
|
8279
|
+
timeout = undefined;
|
|
8280
|
+
}, wait);
|
|
8281
|
+
};
|
|
8282
|
+
}
|
|
8283
|
+
|
|
8284
|
+
const chipTypes = ['active', 'warning', 'success', 'error', 'neutral'];
|
|
8285
|
+
const chipSizes = ['default', 'small'];
|
|
8286
|
+
|
|
8287
|
+
const lmvzChipCss = () => `:host { --lmvz-chip-border-color: var(--lmvz-semantic-color-status-on-neutral-subtle, #d4d4d4); --lmvz-chip-background-color: var(--lmvz-semantic-color-status-neutral, #fcfcfc); --lmvz-chip-foreground-color: var(--lmvz-semantic-color-status-on-neutral, #545454); padding-block: var(--lmvz-dimension-4-6, clamp(0.25rem, 0.22rem + 0.13vw, 0.38rem)); padding-inline: var(--lmvz-dimension-8-10, clamp(0.5rem, 0.47rem + 0.13vw, 0.63rem)); border: 1px solid var(--lmvz-chip-border-color); border-radius: var(--lmvz-semantic-border-radius-round, 999px); font: var(--lmvz-typography-body-xs-strong, 500 clamp(0.69rem, 0.67rem + 0.06vw, 0.75rem) / 1.4 Router); background-color: var(--lmvz-chip-background-color); color: var(--lmvz-chip-foreground-color); display: inline-flex; align-items: center; justify-content: center; gap: var(--lmvz-dimension-4-6, clamp(0.25rem, 0.22rem + 0.13vw, 0.38rem)); box-sizing: border-box; max-width: 100%; overflow: hidden; white-space: nowrap; > .content-overflow-wrapper { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } } :host([size='small']) { padding-block: var(--lmvz-dimension-2-4, clamp(0.13rem, 0.09rem + 0.13vw, 0.25rem)); padding-inline: var(--lmvz-dimension-6-8, clamp(0.38rem, 0.34rem + 0.13vw, 0.5rem)); font: var(--lmvz-typography-body-2xs-strong, 500 clamp(0.63rem, 0.61rem + 0.06vw, 0.69rem) / 1.4 Router); gap: var(--lmvz-dimension-2-4, clamp(0.13rem, 0.09rem + 0.13vw, 0.25rem)); } ::slotted(*) { display: inline; white-space: inherit; } ::slotted(lmvz-icon) { --lmvz-component-color: var(--lmvz-chip-foreground-color); --lmvz-component-size: var(--lmvz-dimension-12-14, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem)); } :host([size='small']) ::slotted(lmvz-icon) { --lmvz-component-size: var(--lmvz-dimension-10-12, clamp(0.63rem, 0.59rem + 0.13vw, 0.75rem)); } :host([type='active']) { --lmvz-chip-border-color: var(--lmvz-semantic-color-status-on-active-subtle, #c1e6fa); --lmvz-chip-background-color: var(--lmvz-semantic-color-status-active, #f1f9fe); --lmvz-chip-foreground-color: var(--lmvz-semantic-color-status-on-active, #0e7ab4); } :host([type='warning']) { --lmvz-chip-border-color: var(--lmvz-semantic-color-status-on-warning-subtle, #ffdf75); --lmvz-chip-background-color: var(--lmvz-semantic-color-status-warning, #fffbf0); --lmvz-chip-foreground-color: var(--lmvz-semantic-color-status-on-warning, #7a5e00); } :host([type='success']) { --lmvz-chip-border-color: var(--lmvz-semantic-color-status-on-success-subtle, #a5dad3); --lmvz-chip-background-color: var(--lmvz-semantic-color-status-success, #f1f9f8); --lmvz-chip-foreground-color: var(--lmvz-semantic-color-status-on-success, #37867c); } :host([type='error']) { --lmvz-chip-border-color: var(--lmvz-semantic-color-status-on-danger-subtle, #f7bfc2); --lmvz-chip-background-color: var(--lmvz-semantic-color-status-danger, #fdf1f2); --lmvz-chip-foreground-color: var(--lmvz-semantic-color-status-on-danger, #e52a31); } :host([type='neutral']) { --lmvz-chip-border-color: var(--lmvz-semantic-color-status-on-neutral-subtle, #d4d4d4); --lmvz-chip-background-color: var(--lmvz-semantic-color-status-neutral, #fcfcfc); --lmvz-chip-foreground-color: var(--lmvz-semantic-color-status-on-neutral, #545454); } `;
|
|
8288
|
+
|
|
8289
|
+
class LmvzChip extends ReactiveControllerHost {
|
|
8290
|
+
ariaValidationController = new AriaValidationController(this);
|
|
8291
|
+
beforeSlot;
|
|
8292
|
+
defaultSlot;
|
|
8293
|
+
afterSlot;
|
|
8294
|
+
get el() { return getElement(this); }
|
|
8295
|
+
get validationEl() {
|
|
8296
|
+
return this.el;
|
|
8297
|
+
}
|
|
8298
|
+
type = 'active';
|
|
8299
|
+
size = 'default';
|
|
8300
|
+
constructor(hostRef) {
|
|
8301
|
+
super();
|
|
8302
|
+
registerInstance(this, hostRef);
|
|
8303
|
+
this.addController(this.ariaValidationController);
|
|
8304
|
+
}
|
|
8305
|
+
normalizeType(value) {
|
|
8306
|
+
const normalizedType = chipTypes.includes(value) ? value : 'active';
|
|
8307
|
+
if (normalizedType !== this.type) {
|
|
8308
|
+
this.type = normalizedType;
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
normalizeSize(value) {
|
|
8312
|
+
const normalizedSize = chipSizes.includes(value) ? value : 'default';
|
|
8313
|
+
if (normalizedSize !== this.size) {
|
|
8314
|
+
this.size = normalizedSize;
|
|
8315
|
+
}
|
|
8316
|
+
}
|
|
8317
|
+
componentWillLoad() {
|
|
8318
|
+
this.normalizeType(this.type);
|
|
8319
|
+
this.normalizeSize(this.size);
|
|
8320
|
+
super.componentWillLoad();
|
|
8321
|
+
}
|
|
8322
|
+
connectedCallback() {
|
|
8323
|
+
super.connectedCallback();
|
|
8324
|
+
this.checkContent();
|
|
8325
|
+
}
|
|
8326
|
+
checkContent = debounce(() => {
|
|
8327
|
+
if (!isAriaValidationEnabled)
|
|
8328
|
+
return;
|
|
8329
|
+
const elements = [...(this.beforeSlot?.assignedElements() ?? []), ...(this.defaultSlot?.assignedElements() ?? []), ...(this.afterSlot?.assignedElements() ?? [])];
|
|
8330
|
+
if (!elements.length) {
|
|
8331
|
+
console.warn('LmvzChip has no assigned content. Please add content to the default slot or the before-text/after-text slots.');
|
|
8332
|
+
}
|
|
8333
|
+
}, 500);
|
|
8334
|
+
render() {
|
|
8335
|
+
return (hAsync(Host, { key: 'c77e8ae55531eefb31dd37b41b4851746a78f077', type: this.type, size: this.size }, hAsync("slot", { key: '3f4d0a8feb887080172d11facc01afbe730b2726', name: "before-text", ref: (el) => (this.beforeSlot = el), onSlotchange: () => this.checkContent() }), hAsync("span", { key: '6ec135ebcb32f15fea342379ac2b1dfebbe76fa6', class: "content-overflow-wrapper" }, hAsync("slot", { key: '053afb88e2d6702428aab195bfcec6aff6d9c55f', ref: (el) => (this.defaultSlot = el), onSlotchange: () => this.checkContent() })), hAsync("slot", { key: 'ed51db073a512a32d12da59dee285708b83ae87b', name: "after-text", ref: (el) => (this.afterSlot = el), onSlotchange: () => this.checkContent() })));
|
|
8336
|
+
}
|
|
8337
|
+
static get watchers() { return {
|
|
8338
|
+
"type": [{
|
|
8339
|
+
"normalizeType": 0
|
|
8340
|
+
}],
|
|
8341
|
+
"size": [{
|
|
8342
|
+
"normalizeSize": 0
|
|
8343
|
+
}]
|
|
8344
|
+
}; }
|
|
8345
|
+
static get style() { return lmvzChipCss(); }
|
|
8346
|
+
static get cmpMeta() { return {
|
|
8347
|
+
"$flags$": 777,
|
|
8348
|
+
"$tagName$": "lmvz-chip",
|
|
8349
|
+
"$members$": {
|
|
8350
|
+
"type": [1537],
|
|
8351
|
+
"size": [1537]
|
|
8352
|
+
},
|
|
8353
|
+
"$listeners$": undefined,
|
|
8354
|
+
"$lazyBundleId$": "-",
|
|
8355
|
+
"$attrsToReflect$": [["type", "type"], ["size", "size"]]
|
|
6016
8356
|
}; }
|
|
6017
8357
|
}
|
|
6018
8358
|
|
|
@@ -6148,7 +8488,7 @@ class LmvzHeader extends ReactiveControllerHost {
|
|
|
6148
8488
|
}
|
|
6149
8489
|
}
|
|
6150
8490
|
render() {
|
|
6151
|
-
return (hAsync(Host, { key: '
|
|
8491
|
+
return (hAsync(Host, { key: '87ecb9948039ea2f4b998bf35865e5839708a65c', onFocus: this.delegateFocus.bind(this) }, hAsync("div", { key: '4f1ae09b1a3e0a9c3eb12659b3952eef34cbd67b', class: "brand" }, hAsync("slot", { key: '99c03f87f0b3462d9b44835ba34ee05c75373b22', name: "brand" }, hAsync("img", { key: '1616ce8464c2e798a53bc7c879385e3882e4d32f', id: "fallback-logo-lmvz", src: logoSvg, alt: "Lehrmittelverlag Z\u00FCrich" }))), hAsync("nav", { key: 'ff7c56dbc9e80ba9a0757683069e1cba168abcb6', "aria-label": "Hauptnavigation" }, hAsync("div", { key: 'a3bb67d788b936422992b066431c73098ff2aa11', role: "menubar", class: "primary-menubar" }, hAsync("slot", { key: 'e85b93f943c6d97bd5a7fa6f75e4855785d09ec5', name: "nav-primary", ref: (el) => (this.primarySlot = el) }), hAsync("div", { key: 'e9efcfc5d3a8cb991c255b32b205924dafb5aaf6', role: "menu", id: "nav-secondary", class: "secondary-menubar", hidden: !this.lmvzActiveNav, ref: (el) => (this.secondaryNav = el) }, hAsync("slot", { key: '7314e6a72705d48b347fa30945b1d5513b87bfd3', name: this.secondarySlotName, ref: (el) => (this.secondarySlot = el) })))), hAsync("div", { key: 'aee503cddbf8964833934e594caf5faa6e073a02', class: "actions" }, hAsync("slot", { key: '5c1b15c0507ef24f67e37cd1652b4cc5ce4cc104', name: "actions" }))));
|
|
6152
8492
|
}
|
|
6153
8493
|
static get watchers() { return {
|
|
6154
8494
|
"lmvzActiveNav": [{
|
|
@@ -6169,7 +8509,7 @@ class LmvzHeader extends ReactiveControllerHost {
|
|
|
6169
8509
|
}; }
|
|
6170
8510
|
}
|
|
6171
8511
|
|
|
6172
|
-
const lmvzIconCss = () => `.sc-lmvz-icon-h{--lmvz-icon-color:var(--lmvz-component-color, var(--lmvz-semantic-color-on-surface-input-primary, #000000));display:inline-block;line-height:0;svg{display:block}svg path{stroke:var(--lmvz-icon-color);fill:none}}[size='xs'].sc-lmvz-icon-h{svg{
|
|
8512
|
+
const lmvzIconCss = () => `.sc-lmvz-icon-h{--lmvz-icon-color:var(--lmvz-component-color, var(--lmvz-semantic-color-on-surface-input-primary, #000000));--lmvz-icon-size:var(--lmvz-component-size, var(--lmvz-component-icon-size-md, clamp(1rem, 0.94rem + 0.26vw, 1.25rem)));display:inline-block;line-height:0;svg{display:block;height:var(--lmvz-icon-size);width:auto}svg path{stroke:var(--lmvz-icon-color);fill:none}}[size='xs'].sc-lmvz-icon-h{svg{--lmvz-icon-size:var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.72rem + 0.13vw, 0.88rem))}}[size='sm'].sc-lmvz-icon-h{svg{--lmvz-icon-size:var(--lmvz-component-icon-size-sm, clamp(0.88rem, 0.84rem + 0.13vw, 1rem))}}[size='md'].sc-lmvz-icon-h{svg{--lmvz-icon-size:var(--lmvz-component-icon-size-md, clamp(1rem, 0.94rem + 0.26vw, 1.25rem))}}[size='lg'].sc-lmvz-icon-h{svg{--lmvz-icon-size:var(--lmvz-component-icon-size-lg, clamp(1.5rem, 1.44rem + 0.26vw, 1.75rem))}}[size='inherit'].sc-lmvz-icon-h{svg{height:var(--lmvz-component-size, inherit)}}[weight='light'].sc-lmvz-icon-h{svg path{stroke-width:1}}[weight='medium'].sc-lmvz-icon-h{svg path{stroke-width:1.5}}[weight='bold'].sc-lmvz-icon-h{svg path{stroke-width:2}}[weight='filled'].sc-lmvz-icon-h{svg path{stroke-width:2;fill:var(--lmvz-icon-color)}}`;
|
|
6173
8513
|
|
|
6174
8514
|
class LmvzIcon extends ReactiveControllerHost {
|
|
6175
8515
|
intersectionObserver;
|
|
@@ -6216,7 +8556,7 @@ class LmvzIcon extends ReactiveControllerHost {
|
|
|
6216
8556
|
super.componentDidRender();
|
|
6217
8557
|
}
|
|
6218
8558
|
render() {
|
|
6219
|
-
return hAsync(Host, { key: '
|
|
8559
|
+
return hAsync(Host, { key: 'e76fe28500b3545b8917ecdad590da5bc04ed38f', role: "img", "aria-hidden": `${this.ariaHidden}`, innerHTML: this.iconData });
|
|
6220
8560
|
}
|
|
6221
8561
|
waitUntilVisible(callback, rootMargin = 50) {
|
|
6222
8562
|
{
|
|
@@ -6409,9 +8749,9 @@ class LmvzInput extends ReactiveControllerHost {
|
|
|
6409
8749
|
render() {
|
|
6410
8750
|
const hasValue = Boolean(this.value);
|
|
6411
8751
|
const shouldFloatLabel = hasValue || Boolean(this.placeholder);
|
|
6412
|
-
return (hAsync("div", { key: '
|
|
8752
|
+
return (hAsync("div", { key: '3cbfee5fccbb5efe1bfb9c6622653e11d4896615', class: classNames('input-container', {
|
|
6413
8753
|
'interaction-filled': hasValue,
|
|
6414
|
-
}) }, hAsync("div", { key: '
|
|
8754
|
+
}) }, hAsync("div", { key: '2712b0d5eda0ca1d4da70f362047df07acf922a5', class: "input-wrapper" }, hAsync("slot", { key: '992bc86de6b3bdd3cdbac1c000d38a338e6e4474', name: "before-input" }), hAsync("div", { key: '35ace7d889667f5d09eea76dcba161f8711c9b1c', class: "label-input-group" }, hAsync("label", { key: '28520dddf331d35ba75283673aa81e0046628907', htmlFor: this.inputId, class: classNames({ floating: shouldFloatLabel }) }, this.label, this.required && (hAsync("span", { key: 'b91766b86b1bc68ce3dbb4b734ee4aa40fe0759b', class: "required-indicator", "aria-hidden": "true" }, ' ', "*"))), hAsync("input", { key: 'ed7cd4b64091256df1c3b939c1e22d6082fe58b9', id: this.inputId, ref: (el) => (this.nativeInputElement = el), type: this.type, min: this.min, max: this.max, step: this.step, value: this.value, name: this.name, placeholder: this.placeholder, disabled: this.disabled, readOnly: this.readonly, required: this.required, form: this.form, autocomplete: this.autocomplete, inputmode: this.inputmode, autocorrect: this.autocorrect, autocapitalize: this.autocapitalize, spellcheck: this.spellcheck, autofocus: this.autofocus, minlength: this.minlength, maxlength: this.maxlength, pattern: this.pattern, "aria-invalid": this.error ? 'true' : 'false', "aria-required": this.required ? 'true' : 'false', "aria-describedby": this.describedBy, "aria-errormessage": this.errorId, onInput: this.handleInput, onChange: this.handleChange, onFocus: this.handleFocus, onBlur: this.handleBlur })), hAsync("slot", { key: '1e42c305b8e554fadd7c50fbbb54ea234c734b0a', name: "after-input" })), hAsync("div", { key: '190a1a92971a717f3ef594615fbe4dd0c9a72493', id: this.helperId, role: "status" }, this.helperText || null), hAsync("div", { key: '4d07b45a51d3733caf09a1bbc56ae6f51411ecbc', id: this.errorId, role: "alert" }, (this.showErrorMessage && this.errorMessage) || null)));
|
|
6415
8755
|
}
|
|
6416
8756
|
static get formAssociated() { return true; }
|
|
6417
8757
|
static get watchers() { return {
|
|
@@ -6466,7 +8806,7 @@ class LmvzInput extends ReactiveControllerHost {
|
|
|
6466
8806
|
}; }
|
|
6467
8807
|
}
|
|
6468
8808
|
|
|
6469
|
-
const lmvzMenuitemCss = () => `@layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } .sc-lmvz-menuitem-h { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); border-radius: var(--lmvz-semantic-border-radius-lg, 14px); font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); padding: var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)) var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)); cursor: pointer; --lmvz-menuitem-color: var(--lmvz-semantic-color-int-on-tertiary, #545454); --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary, #ffffff); background: var(--lmvz-menuitem-background); color: var(--lmvz-menuitem-color); } .sc-lmvz-menuitem-h:hover { --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0); } .sc-lmvz-menuitem-h:active { --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary-active, #e0e0e0); } .sc-lmvz-menuitem-h:focus-visible { z-index: 1; } [aria-expanded='true'].sc-lmvz-menuitem-h { --lmvz-menuitem-background: var(--lmvz-semantic-color-status-
|
|
8809
|
+
const lmvzMenuitemCss = () => `@layer lmvz-ds.reset, lmvz-ds.theme, lmvz-ds.components, lmvz-ds.overrides; @layer lmvz-ds.theme { @font-face { font-family: Router; src: local('Router-Book'), url('/assets/fonts/Router-Book.woff') format('woff'), local('Router'); font-weight: 400 normal; } @font-face { font-family: Router; src: local('Router-Medium'), url('/assets/fonts/Router-Medium.woff') format('woff'), local('Router'); font-weight: 500; } @font-face { font-family: Router; src: local('Router-Bold'), url('/assets/fonts/Router-Bold.woff') format('woff'), local('Router'); font-weight: 700 bold; } } .sc-lmvz-menuitem-h { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; gap: var(--lmvz-component-input-md-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem)); border-radius: var(--lmvz-semantic-border-radius-lg, 14px); font: var(--lmvz-typography-body-md, 400 clamp(0.88rem, 0.84rem + 0.13vw, 1rem) / 1.4 Router); padding: var(--lmvz-component-input-md-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)) var(--lmvz-component-input-md-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)); cursor: pointer; --lmvz-menuitem-color: var(--lmvz-semantic-color-int-on-tertiary, #545454); --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary, #ffffff); background: var(--lmvz-menuitem-background); color: var(--lmvz-menuitem-color); } .sc-lmvz-menuitem-h:hover { --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary-hover, #f0f0f0); } .sc-lmvz-menuitem-h:active { --lmvz-menuitem-background: var(--lmvz-semantic-color-int-tertiary-active, #e0e0e0); } .sc-lmvz-menuitem-h:focus-visible { z-index: 1; } [aria-expanded='true'].sc-lmvz-menuitem-h { --lmvz-menuitem-background: var(--lmvz-semantic-color-status-active, #f1f9fe); --lmvz-menuitem-color: var(--lmvz-semantic-color-status-on-active, #0e7ab4); }`;
|
|
6470
8810
|
|
|
6471
8811
|
class LmvzMenuItem extends ReactiveControllerHost {
|
|
6472
8812
|
get el() { return getElement(this); }
|
|
@@ -6489,7 +8829,7 @@ class LmvzMenuItem extends ReactiveControllerHost {
|
|
|
6489
8829
|
this.addController(new ElementActivationController(this));
|
|
6490
8830
|
}
|
|
6491
8831
|
render() {
|
|
6492
|
-
return (hAsync(Host, { key: '
|
|
8832
|
+
return (hAsync(Host, { key: 'a87116fba2d35c612e590c6b4e12c03b60d1ef0e' }, hAsync("slot", { key: 'b302049db0b5818d4d7f90c043eb5c3caf48ca1b', ref: (e) => (this.validationSlot = e) })));
|
|
6493
8833
|
}
|
|
6494
8834
|
static get style() { return lmvzMenuitemCss(); }
|
|
6495
8835
|
static get cmpMeta() { return {
|
|
@@ -6559,7 +8899,7 @@ class LmvzSelect extends ReactiveControllerHost {
|
|
|
6559
8899
|
render() {
|
|
6560
8900
|
const hasValue = this.hasValue;
|
|
6561
8901
|
const shouldShowLabel = hasValue;
|
|
6562
|
-
return (hAsync(Host, { key: '
|
|
8902
|
+
return (hAsync(Host, { key: '1bdd53df4a33c5292cc072b0a9abc45fa01b237f' }, hAsync("div", { key: 'e38d81e620d8c27cd34e1a7799c42d5640d4b0db', class: "select-wrapper" }, hAsync("label", { key: '3995206b564c7e17ac273709577eb8dd7a3b0ff1', htmlFor: this.selectId, class: shouldShowLabel ? 'floating-label' : 'assistive-label' }, this.label, this.required && shouldShowLabel && hAsync("span", { key: '7c04028f9ff3e0f365f76d10b0139dc6805f2af4', "aria-hidden": "true" }, " *")), hAsync("div", { key: '7b428d22a32181fc13e837b6821ab163ac286453', "aria-hidden": "true" }, hAsync("span", { key: '385ddb473337869777e835cc5b533f9a41c1fbe3' }, hasValue ? this.selectedLabel : this.label, this.required && !hasValue && hAsync("span", { key: 'c53036bd718b916b910225297b40df998729650c', "aria-hidden": "true" }, " *")), hAsync("span", { key: '06db17fbe01d9fea9904aa04e72b6cbfc9d93652' }, hAsync("img", { key: 'b4d46ada048e931aa71f2ace33c93ff9fc67e479', src: chevronDownSvg, alt: "" }))), hAsync("select", { key: '841c86f1d340cd36475a7757e9cad5f33aeac710', id: this.selectId, ref: (el) => (this.nativeSelectEl = el), name: this.name, disabled: this.disabled, required: this.required, "aria-label": this.label, onChange: this.handleChange }, !hasValue && hAsync("option", { key: '4bd193f7878da2077c9185cd093d61c62406a7b9', value: "", disabled: true, selected: true, hidden: true }), hAsync("slot", { key: 'c14a15e022f08ad72a5ad9d29befe0db7c6f24db' }))), this.helperText && hAsync("div", { key: '833eaa383f8a9722fd990fadcdff4a93aa0a79df', role: "status" }, this.helperText)));
|
|
6563
8903
|
}
|
|
6564
8904
|
static get watchers() { return {
|
|
6565
8905
|
"value": [{
|
|
@@ -6589,6 +8929,7 @@ registerComponents([
|
|
|
6589
8929
|
LmvzAction,
|
|
6590
8930
|
LmvzButton,
|
|
6591
8931
|
LmvzCard,
|
|
8932
|
+
LmvzCheckbox,
|
|
6592
8933
|
LmvzChip,
|
|
6593
8934
|
LmvzHeader,
|
|
6594
8935
|
LmvzIcon,
|