@lmvz-ds/components 0.12.4 → 0.12.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/assets-Cswkqk_c.js +18971 -0
- package/dist/cjs/assets-Cswkqk_c.js.map +1 -0
- package/dist/cjs/axe-C2rxi-K2.js +32837 -0
- package/dist/cjs/axe-C2rxi-K2.js.map +1 -0
- package/dist/cjs/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-BTL_B6qg.js +3665 -0
- package/dist/cjs/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-BTL_B6qg.js.map +1 -0
- package/dist/cjs/header-integration_6.cjs.entry.js +18 -0
- package/dist/cjs/header-integration_6.cjs.entry.js.map +1 -0
- package/dist/cjs/icons-jn_Uak9B.js +1063 -0
- package/dist/cjs/icons-jn_Uak9B.js.map +1 -0
- package/dist/cjs/index-DpBPf1cE.js +2112 -0
- package/dist/cjs/index-DpBPf1cE.js.map +1 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/lmvz-action.cjs.entry.js.map +1 -0
- package/dist/cjs/lmvz-card.cjs.entry.js.map +1 -0
- package/dist/cjs/lmvz-chip.cjs.entry.js.map +1 -0
- package/dist/cjs/lmvz-components.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/collection/api/ds.constants.js.map +1 -0
- package/dist/collection/api/index.js.map +1 -0
- package/dist/collection/components/lmvz-action/lmvz-action.js.map +1 -0
- package/dist/collection/components/lmvz-button/lmvz-button.js.map +1 -0
- package/dist/collection/components/lmvz-card/lmvz-card.js.map +1 -0
- package/dist/collection/components/lmvz-chip/lmvz-chip.js.map +1 -0
- package/dist/collection/components/lmvz-header/lmvz-header.js.map +1 -0
- package/dist/collection/components/lmvz-icon/icons.js.map +1 -0
- package/dist/collection/components/lmvz-icon/lmvz-icon.js.map +1 -0
- package/dist/collection/components/lmvz-icon/public.js.map +1 -0
- package/dist/collection/components/lmvz-icon/test/icons.unit.js.map +1 -0
- package/dist/collection/components/lmvz-input/lmvz-input.js.map +1 -0
- package/dist/collection/components/lmvz-menuitem/lmvz-menuitem.js.map +1 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/integration/header-integration.js +22 -4
- package/dist/collection/integration/header-integration.js.map +1 -0
- package/dist/collection/utils/assets.js.map +1 -0
- package/dist/collection/utils/component.js.map +1 -0
- package/dist/collection/utils/effect.js.map +1 -0
- package/dist/collection/utils/element-activation-controller.js.map +1 -0
- package/dist/collection/utils/environment.js.map +1 -0
- package/dist/collection/utils/http.js.map +1 -0
- package/dist/collection/utils/http.test.js.map +1 -0
- package/dist/collection/utils/list-keyboard-controller.js.map +1 -0
- package/dist/collection/utils/public.js.map +1 -0
- package/dist/collection/utils/reactive-controller-host.js.map +1 -0
- package/dist/collection/utils/typing.js.map +1 -0
- package/dist/collection/utils/validation/aria-validation-controller.js.map +1 -0
- package/dist/collection/utils/validation/svg.js.map +1 -0
- package/dist/components/header-integration.d.ts +11 -0
- package/dist/components/header-integration.js +2 -0
- package/dist/components/header-integration.js.map +1 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/lmvz-action.js.map +1 -0
- package/dist/components/lmvz-button.js.map +1 -0
- package/dist/components/lmvz-card.js.map +1 -0
- package/dist/components/lmvz-chip.js.map +1 -0
- package/dist/components/lmvz-header.js.map +1 -0
- package/dist/components/lmvz-icon.js.map +1 -0
- package/dist/components/lmvz-input.js.map +1 -0
- package/dist/components/lmvz-menuitem.js.map +1 -0
- package/dist/components/p-B3JVFwO1.js.map +1 -0
- package/dist/components/p-B85MJLTf.js.map +1 -0
- package/dist/components/p-CN0JX9-m.js.map +1 -0
- package/dist/components/p-Cd4nH2vx.js +2 -0
- package/dist/components/p-Cd4nH2vx.js.map +1 -0
- package/dist/components/p-CdofjRtQ.js.map +1 -0
- package/dist/components/p-CkTUjPwD.js +2 -0
- package/dist/components/p-CkTUjPwD.js.map +1 -0
- package/dist/components/p-CpI4KFOu.js +2 -0
- package/dist/components/p-CpI4KFOu.js.map +1 -0
- package/dist/components/p-D1HbKFuh.js.map +1 -0
- package/dist/components/p-D7xthqTT.js +2 -0
- package/dist/components/p-D7xthqTT.js.map +1 -0
- package/dist/components/p-DBeynNeU.js +2 -0
- package/dist/components/p-DBeynNeU.js.map +1 -0
- package/dist/components/p-DMLRPGid.js.map +1 -0
- package/dist/components/p-UiqQVZhU.js +2 -0
- package/dist/components/p-UiqQVZhU.js.map +1 -0
- package/dist/components/p-Xq267cFM.js +2 -0
- package/dist/components/p-Xq267cFM.js.map +1 -0
- package/dist/components/p-glDDybgu.js +2 -0
- package/dist/components/p-glDDybgu.js.map +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/assets-K2FHD9qn.js +18770 -0
- package/dist/esm/assets-K2FHD9qn.js.map +1 -0
- package/dist/esm/axe-CZ0Rtkog.js +32835 -0
- package/dist/esm/axe-CZ0Rtkog.js.map +1 -0
- package/dist/esm/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-CW3FGLZC.js +3657 -0
- package/dist/esm/header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-CW3FGLZC.js.map +1 -0
- package/dist/esm/header-integration_6.entry.js +7 -0
- package/dist/esm/header-integration_6.entry.js.map +1 -0
- package/dist/esm/icons-BITzEzmq.js +1032 -0
- package/dist/esm/icons-BITzEzmq.js.map +1 -0
- package/dist/esm/index-D2eyw7iv.js +2101 -0
- package/dist/esm/index-D2eyw7iv.js.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lmvz-action.entry.js.map +1 -0
- package/dist/esm/lmvz-card.entry.js.map +1 -0
- package/dist/esm/lmvz-chip.entry.js.map +1 -0
- package/dist/esm/lmvz-components.js.map +1 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/lmvz-components/index.esm.js.map +1 -0
- package/dist/lmvz-components/lmvz-components.esm.js.map +1 -0
- package/dist/lmvz-components/p-366a01f8.entry.js +2 -0
- package/dist/lmvz-components/p-366a01f8.entry.js.map +1 -0
- package/dist/lmvz-components/p-84ee7919.entry.js +2 -0
- package/dist/lmvz-components/p-84ee7919.entry.js.map +1 -0
- package/dist/lmvz-components/p-BLwPC3DQ.js +2 -0
- package/dist/lmvz-components/p-BLwPC3DQ.js.map +1 -0
- package/dist/lmvz-components/p-D2eyw7iv.js +3 -0
- package/dist/lmvz-components/p-D2eyw7iv.js.map +1 -0
- package/dist/lmvz-components/p-DANVVVBd.js +7 -0
- package/dist/lmvz-components/p-DANVVVBd.js.map +1 -0
- package/dist/lmvz-components/p-DQuL1Twl.js.map +1 -0
- package/dist/lmvz-components/p-DlDurXvX.js +2 -0
- package/dist/lmvz-components/p-DlDurXvX.js.map +1 -0
- package/dist/lmvz-components/p-Hc4uxoTU.js +13 -0
- package/dist/lmvz-components/p-Hc4uxoTU.js.map +1 -0
- package/dist/lmvz-components/p-a4200b26.entry.js +2 -0
- package/dist/lmvz-components/p-a4200b26.entry.js.map +1 -0
- package/dist/lmvz-components/p-d3243bae.entry.js +2 -0
- package/dist/lmvz-components/p-d3243bae.entry.js.map +1 -0
- package/dist/manifest.json +26 -2
- package/package.json +10 -9
|
@@ -0,0 +1,3665 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-DpBPf1cE.js');
|
|
4
|
+
var assets = require('./assets-Cswkqk_c.js');
|
|
5
|
+
var icons = require('./icons-jn_Uak9B.js');
|
|
6
|
+
|
|
7
|
+
function getDefaultExportFromCjs (x) {
|
|
8
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @since 2.0.0
|
|
13
|
+
* @category constructors
|
|
14
|
+
*/
|
|
15
|
+
const make$3 = assets.make;
|
|
16
|
+
/**
|
|
17
|
+
* @since 2.0.0
|
|
18
|
+
* @category getters
|
|
19
|
+
*/
|
|
20
|
+
const get = assets.get;
|
|
21
|
+
/**
|
|
22
|
+
* @since 2.0.0
|
|
23
|
+
* @category utils
|
|
24
|
+
*/
|
|
25
|
+
const modify = assets.modify;
|
|
26
|
+
/**
|
|
27
|
+
* @since 2.0.0
|
|
28
|
+
* @category utils
|
|
29
|
+
*/
|
|
30
|
+
const update = assets.update;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates a `Fail` cause from an expected error.
|
|
34
|
+
*
|
|
35
|
+
* **Details**
|
|
36
|
+
*
|
|
37
|
+
* This function constructs a `Cause` carrying an error of type `E`. It's used
|
|
38
|
+
* when you want to represent a known or anticipated failure in your effectful
|
|
39
|
+
* computations.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link isFailure} Check if a `Cause` contains a failure
|
|
42
|
+
*
|
|
43
|
+
* @since 2.0.0
|
|
44
|
+
* @category Constructors
|
|
45
|
+
*/
|
|
46
|
+
const fail$1 = assets.fail;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a `Die` cause from an unexpected error.
|
|
49
|
+
*
|
|
50
|
+
* **Details**
|
|
51
|
+
*
|
|
52
|
+
* This function wraps an unhandled or unknown defect (like a runtime crash)
|
|
53
|
+
* into a `Cause`. It's useful for capturing unforeseen issues in a structured
|
|
54
|
+
* way.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link isDie} Check if a `Cause` contains a defect
|
|
57
|
+
*
|
|
58
|
+
* @since 2.0.0
|
|
59
|
+
* @category Constructors
|
|
60
|
+
*/
|
|
61
|
+
const die = assets.die;
|
|
62
|
+
/**
|
|
63
|
+
* Creates an `Interrupt` cause from a `FiberId`.
|
|
64
|
+
*
|
|
65
|
+
* **Details**
|
|
66
|
+
*
|
|
67
|
+
* This function represents a fiber that has been interrupted. It stores the
|
|
68
|
+
* identifier of the interrupted fiber, enabling precise tracking of concurrent
|
|
69
|
+
* cancellations.
|
|
70
|
+
*
|
|
71
|
+
* @see {@link isInterrupted} Check if a `Cause` contains an interruption
|
|
72
|
+
*
|
|
73
|
+
* @since 2.0.0
|
|
74
|
+
* @category Constructors
|
|
75
|
+
*/
|
|
76
|
+
const interrupt$1 = assets.interrupt;
|
|
77
|
+
/**
|
|
78
|
+
* Checks if a `Cause` is a `Die` type.
|
|
79
|
+
*
|
|
80
|
+
* @see {@link die} Create a new `Die` cause
|
|
81
|
+
*
|
|
82
|
+
* @since 2.0.0
|
|
83
|
+
* @category Guards
|
|
84
|
+
*/
|
|
85
|
+
const isDieType = assets.isDieType;
|
|
86
|
+
/**
|
|
87
|
+
* Checks if a `Cause` contains an interruption.
|
|
88
|
+
*
|
|
89
|
+
* **Details**
|
|
90
|
+
*
|
|
91
|
+
* This function returns `true` if the `Cause` includes any fiber interruptions.
|
|
92
|
+
*
|
|
93
|
+
* @since 2.0.0
|
|
94
|
+
* @category Getters
|
|
95
|
+
*/
|
|
96
|
+
const isInterrupted = assets.isInterrupted;
|
|
97
|
+
/**
|
|
98
|
+
* Checks if a `Cause` contains only interruptions.
|
|
99
|
+
*
|
|
100
|
+
* **Details**
|
|
101
|
+
*
|
|
102
|
+
* This function returns `true` if the `Cause` has been interrupted but does not
|
|
103
|
+
* contain any other failures, such as `Fail` or `Die`. It's helpful for
|
|
104
|
+
* verifying purely "cancellation" scenarios.
|
|
105
|
+
*
|
|
106
|
+
* @since 2.0.0
|
|
107
|
+
* @category Getters
|
|
108
|
+
*/
|
|
109
|
+
const isInterruptedOnly = assets.isInterruptedOnly;
|
|
110
|
+
/**
|
|
111
|
+
* Collects all `FiberId`s responsible for interrupting a fiber.
|
|
112
|
+
*
|
|
113
|
+
* **Details**
|
|
114
|
+
*
|
|
115
|
+
* This function returns a set of IDs indicating which fibers caused
|
|
116
|
+
* interruptions within this `Cause`. It's useful for debugging concurrency
|
|
117
|
+
* issues or tracing cancellations.
|
|
118
|
+
*
|
|
119
|
+
* @since 2.0.0
|
|
120
|
+
* @category Getters
|
|
121
|
+
*/
|
|
122
|
+
const interruptors = assets.interruptors;
|
|
123
|
+
/**
|
|
124
|
+
* Splits a `Cause` into either its first `Fail` error or the rest of the cause
|
|
125
|
+
* (which might only contain `Die` or `Interrupt`).
|
|
126
|
+
*
|
|
127
|
+
* **Details**
|
|
128
|
+
*
|
|
129
|
+
* This function either returns the checked error (`E`) or the remaining
|
|
130
|
+
* `Cause<never>` with defects/interruptions. It helps you decide if there's a
|
|
131
|
+
* recoverable path or if only unhandled issues remain.
|
|
132
|
+
*
|
|
133
|
+
* @since 2.0.0
|
|
134
|
+
* @category Getters
|
|
135
|
+
*/
|
|
136
|
+
const failureOrCause = assets.failureOrCause;
|
|
137
|
+
/**
|
|
138
|
+
* Strips out failures with an error of `None` from a `Cause<Option<E>>`.
|
|
139
|
+
*
|
|
140
|
+
* **Details**
|
|
141
|
+
*
|
|
142
|
+
* This function turns a `Cause<Option<E>>` into an `Option<Cause<E>>`. If the
|
|
143
|
+
* cause only contains failures of `None`, it becomes `None`; otherwise, it
|
|
144
|
+
* returns a `Cause` of the remaining errors. It's helpful when working with
|
|
145
|
+
* optional errors and filtering out certain error paths.
|
|
146
|
+
*
|
|
147
|
+
* @since 2.0.0
|
|
148
|
+
* @category Getters
|
|
149
|
+
*/
|
|
150
|
+
const flipCauseOption = assets.flipCauseOption;
|
|
151
|
+
/**
|
|
152
|
+
* Transforms the errors in a `Cause` using a user-provided function.
|
|
153
|
+
*
|
|
154
|
+
* **Details**
|
|
155
|
+
*
|
|
156
|
+
* This function applies `f` to each `Fail` error while leaving defects (`Die`)
|
|
157
|
+
* and interruptions untouched. It's useful for changing or simplifying error
|
|
158
|
+
* types in your effectful workflows.
|
|
159
|
+
*
|
|
160
|
+
* @see {@link as} Replace errors with a single constant
|
|
161
|
+
*
|
|
162
|
+
* @since 2.0.0
|
|
163
|
+
* @category Mapping
|
|
164
|
+
*/
|
|
165
|
+
const map$2 = assets.map;
|
|
166
|
+
|
|
167
|
+
const _await = assets._await;
|
|
168
|
+
/**
|
|
169
|
+
* Inherits values from all `FiberRef` instances into current fiber. This
|
|
170
|
+
* will resume immediately.
|
|
171
|
+
*
|
|
172
|
+
* @since 2.0.0
|
|
173
|
+
* @category destructors
|
|
174
|
+
*/
|
|
175
|
+
const inheritAll = assets.inheritAll;
|
|
176
|
+
/**
|
|
177
|
+
* Interrupts the fiber from whichever fiber is calling this method. If the
|
|
178
|
+
* fiber has already exited, the returned effect will resume immediately.
|
|
179
|
+
* Otherwise, the effect will resume when the fiber exits.
|
|
180
|
+
*
|
|
181
|
+
* @since 2.0.0
|
|
182
|
+
* @category interruption
|
|
183
|
+
*/
|
|
184
|
+
const interrupt = assets.interruptFiber;
|
|
185
|
+
/**
|
|
186
|
+
* Interrupts the fiber as if interrupted from the specified fiber. If the
|
|
187
|
+
* fiber has already exited, the returned effect will resume immediately.
|
|
188
|
+
* Otherwise, the effect will resume when the fiber exits.
|
|
189
|
+
*
|
|
190
|
+
* @since 2.0.0
|
|
191
|
+
* @category interruption
|
|
192
|
+
*/
|
|
193
|
+
const interruptAs = assets.interruptAsFiber;
|
|
194
|
+
/**
|
|
195
|
+
* Joins the fiber, which suspends the joining fiber until the result of the
|
|
196
|
+
* fiber has been determined. Attempting to join a fiber that has erred will
|
|
197
|
+
* result in a catchable error. Joining an interrupted fiber will result in an
|
|
198
|
+
* "inner interruption" of this fiber, unlike interruption triggered by
|
|
199
|
+
* another fiber, "inner interruption" can be caught and recovered.
|
|
200
|
+
*
|
|
201
|
+
* @since 2.0.0
|
|
202
|
+
* @category destructors
|
|
203
|
+
*/
|
|
204
|
+
const join = assets.join;
|
|
205
|
+
|
|
206
|
+
/** @internal */
|
|
207
|
+
const EnqueueSymbolKey = "effect/QueueEnqueue";
|
|
208
|
+
/** @internal */
|
|
209
|
+
const EnqueueTypeId = /*#__PURE__*/Symbol.for(EnqueueSymbolKey);
|
|
210
|
+
/** @internal */
|
|
211
|
+
const DequeueSymbolKey = "effect/QueueDequeue";
|
|
212
|
+
/** @internal */
|
|
213
|
+
const DequeueTypeId = /*#__PURE__*/Symbol.for(DequeueSymbolKey);
|
|
214
|
+
/** @internal */
|
|
215
|
+
const QueueStrategySymbolKey = "effect/QueueStrategy";
|
|
216
|
+
/** @internal */
|
|
217
|
+
const QueueStrategyTypeId = /*#__PURE__*/Symbol.for(QueueStrategySymbolKey);
|
|
218
|
+
/** @internal */
|
|
219
|
+
const BackingQueueSymbolKey = "effect/BackingQueue";
|
|
220
|
+
/** @internal */
|
|
221
|
+
const BackingQueueTypeId = /*#__PURE__*/Symbol.for(BackingQueueSymbolKey);
|
|
222
|
+
const queueStrategyVariance = {
|
|
223
|
+
/* c8 ignore next */
|
|
224
|
+
_A: _ => _
|
|
225
|
+
};
|
|
226
|
+
const backingQueueVariance = {
|
|
227
|
+
/* c8 ignore next */
|
|
228
|
+
_A: _ => _
|
|
229
|
+
};
|
|
230
|
+
/** @internal */
|
|
231
|
+
const enqueueVariance = {
|
|
232
|
+
/* c8 ignore next */
|
|
233
|
+
_In: _ => _
|
|
234
|
+
};
|
|
235
|
+
/** @internal */
|
|
236
|
+
const dequeueVariance = {
|
|
237
|
+
/* c8 ignore next */
|
|
238
|
+
_Out: _ => _
|
|
239
|
+
};
|
|
240
|
+
/** @internal */
|
|
241
|
+
class QueueImpl extends assets.Class {
|
|
242
|
+
queue;
|
|
243
|
+
takers;
|
|
244
|
+
shutdownHook;
|
|
245
|
+
shutdownFlag;
|
|
246
|
+
strategy;
|
|
247
|
+
[EnqueueTypeId] = enqueueVariance;
|
|
248
|
+
[DequeueTypeId] = dequeueVariance;
|
|
249
|
+
constructor(/** @internal */
|
|
250
|
+
queue, /** @internal */
|
|
251
|
+
takers, /** @internal */
|
|
252
|
+
shutdownHook, /** @internal */
|
|
253
|
+
shutdownFlag, /** @internal */
|
|
254
|
+
strategy) {
|
|
255
|
+
super();
|
|
256
|
+
this.queue = queue;
|
|
257
|
+
this.takers = takers;
|
|
258
|
+
this.shutdownHook = shutdownHook;
|
|
259
|
+
this.shutdownFlag = shutdownFlag;
|
|
260
|
+
this.strategy = strategy;
|
|
261
|
+
}
|
|
262
|
+
pipe() {
|
|
263
|
+
return assets.pipeArguments(this, arguments);
|
|
264
|
+
}
|
|
265
|
+
commit() {
|
|
266
|
+
return this.take;
|
|
267
|
+
}
|
|
268
|
+
capacity() {
|
|
269
|
+
return this.queue.capacity();
|
|
270
|
+
}
|
|
271
|
+
get size() {
|
|
272
|
+
return assets.suspend(() => assets.catchAll(this.unsafeSize(), () => assets.interrupt$1));
|
|
273
|
+
}
|
|
274
|
+
unsafeSize() {
|
|
275
|
+
if (assets.get$1(this.shutdownFlag)) {
|
|
276
|
+
return assets.none();
|
|
277
|
+
}
|
|
278
|
+
return assets.some(this.queue.length() - icons.length(this.takers) + this.strategy.surplusSize());
|
|
279
|
+
}
|
|
280
|
+
get isEmpty() {
|
|
281
|
+
return assets.map$1(this.size, size => size <= 0);
|
|
282
|
+
}
|
|
283
|
+
get isFull() {
|
|
284
|
+
return assets.map$1(this.size, size => size >= this.capacity());
|
|
285
|
+
}
|
|
286
|
+
get shutdown() {
|
|
287
|
+
return assets.uninterruptible(assets.withFiberRuntime(state => {
|
|
288
|
+
assets.pipe(this.shutdownFlag, assets.set(true));
|
|
289
|
+
return assets.pipe(assets.forEachConcurrentDiscard(unsafePollAll(this.takers), d => assets.deferredInterruptWith(d, state.id()), false, false), assets.zipRight(this.strategy.shutdown), assets.whenEffect(assets.deferredSucceed(this.shutdownHook, void 0)), assets.asVoid);
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
get isShutdown() {
|
|
293
|
+
return assets.sync(() => assets.get$1(this.shutdownFlag));
|
|
294
|
+
}
|
|
295
|
+
get awaitShutdown() {
|
|
296
|
+
return assets.deferredAwait(this.shutdownHook);
|
|
297
|
+
}
|
|
298
|
+
isActive() {
|
|
299
|
+
return !assets.get$1(this.shutdownFlag);
|
|
300
|
+
}
|
|
301
|
+
unsafeOffer(value) {
|
|
302
|
+
if (assets.get$1(this.shutdownFlag)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
let noRemaining;
|
|
306
|
+
if (this.queue.length() === 0) {
|
|
307
|
+
const taker = assets.pipe(this.takers, icons.poll(icons.EmptyMutableQueue));
|
|
308
|
+
if (taker !== icons.EmptyMutableQueue) {
|
|
309
|
+
unsafeCompleteDeferred(taker, value);
|
|
310
|
+
noRemaining = true;
|
|
311
|
+
} else {
|
|
312
|
+
noRemaining = false;
|
|
313
|
+
}
|
|
314
|
+
} else {
|
|
315
|
+
noRemaining = false;
|
|
316
|
+
}
|
|
317
|
+
if (noRemaining) {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
// Not enough takers, offer to the queue
|
|
321
|
+
const succeeded = this.queue.offer(value);
|
|
322
|
+
unsafeCompleteTakers(this.strategy, this.queue, this.takers);
|
|
323
|
+
return succeeded;
|
|
324
|
+
}
|
|
325
|
+
offer(value) {
|
|
326
|
+
return assets.suspend(() => {
|
|
327
|
+
if (assets.get$1(this.shutdownFlag)) {
|
|
328
|
+
return assets.interrupt$1;
|
|
329
|
+
}
|
|
330
|
+
let noRemaining;
|
|
331
|
+
if (this.queue.length() === 0) {
|
|
332
|
+
const taker = assets.pipe(this.takers, icons.poll(icons.EmptyMutableQueue));
|
|
333
|
+
if (taker !== icons.EmptyMutableQueue) {
|
|
334
|
+
unsafeCompleteDeferred(taker, value);
|
|
335
|
+
noRemaining = true;
|
|
336
|
+
} else {
|
|
337
|
+
noRemaining = false;
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
noRemaining = false;
|
|
341
|
+
}
|
|
342
|
+
if (noRemaining) {
|
|
343
|
+
return assets.succeed(true);
|
|
344
|
+
}
|
|
345
|
+
// Not enough takers, offer to the queue
|
|
346
|
+
const succeeded = this.queue.offer(value);
|
|
347
|
+
unsafeCompleteTakers(this.strategy, this.queue, this.takers);
|
|
348
|
+
return succeeded ? assets.succeed(true) : this.strategy.handleSurplus([value], this.queue, this.takers, this.shutdownFlag);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
offerAll(iterable) {
|
|
352
|
+
return assets.suspend(() => {
|
|
353
|
+
if (assets.get$1(this.shutdownFlag)) {
|
|
354
|
+
return assets.interrupt$1;
|
|
355
|
+
}
|
|
356
|
+
const values = assets.fromIterable(iterable);
|
|
357
|
+
const pTakers = this.queue.length() === 0 ? assets.fromIterable(unsafePollN(this.takers, values.length)) : assets.empty;
|
|
358
|
+
const [forTakers, remaining] = assets.pipe(values, assets.splitAt(pTakers.length));
|
|
359
|
+
for (let i = 0; i < pTakers.length; i++) {
|
|
360
|
+
const taker = pTakers[i];
|
|
361
|
+
const item = forTakers[i];
|
|
362
|
+
unsafeCompleteDeferred(taker, item);
|
|
363
|
+
}
|
|
364
|
+
if (remaining.length === 0) {
|
|
365
|
+
return assets.succeed(true);
|
|
366
|
+
}
|
|
367
|
+
// Not enough takers, offer to the queue
|
|
368
|
+
const surplus = this.queue.offerAll(remaining);
|
|
369
|
+
unsafeCompleteTakers(this.strategy, this.queue, this.takers);
|
|
370
|
+
return assets.isEmpty(surplus) ? assets.succeed(true) : this.strategy.handleSurplus(surplus, this.queue, this.takers, this.shutdownFlag);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
get take() {
|
|
374
|
+
return assets.withFiberRuntime(state => {
|
|
375
|
+
if (assets.get$1(this.shutdownFlag)) {
|
|
376
|
+
return assets.interrupt$1;
|
|
377
|
+
}
|
|
378
|
+
const item = this.queue.poll(icons.EmptyMutableQueue);
|
|
379
|
+
if (item !== icons.EmptyMutableQueue) {
|
|
380
|
+
this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
|
|
381
|
+
return assets.succeed(item);
|
|
382
|
+
} else {
|
|
383
|
+
// Add the deferred to takers, then:
|
|
384
|
+
// - Try to take again in case a value was added since
|
|
385
|
+
// - Wait for the deferred to be completed
|
|
386
|
+
// - Clean up resources in case of interruption
|
|
387
|
+
const deferred = assets.deferredUnsafeMake(state.id());
|
|
388
|
+
return assets.pipe(assets.suspend(() => {
|
|
389
|
+
assets.pipe(this.takers, icons.offer(deferred));
|
|
390
|
+
unsafeCompleteTakers(this.strategy, this.queue, this.takers);
|
|
391
|
+
return assets.get$1(this.shutdownFlag) ? assets.interrupt$1 : assets.deferredAwait(deferred);
|
|
392
|
+
}), assets.onInterrupt(() => {
|
|
393
|
+
return assets.sync(() => unsafeRemove(this.takers, deferred));
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
get takeAll() {
|
|
399
|
+
return assets.suspend(() => {
|
|
400
|
+
return assets.get$1(this.shutdownFlag) ? assets.interrupt$1 : assets.sync(() => {
|
|
401
|
+
const values = this.queue.pollUpTo(Number.POSITIVE_INFINITY);
|
|
402
|
+
this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
|
|
403
|
+
return assets.fromIterable$1(values);
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
takeUpTo(max) {
|
|
408
|
+
return assets.suspend(() => assets.get$1(this.shutdownFlag) ? assets.interrupt$1 : assets.sync(() => {
|
|
409
|
+
const values = this.queue.pollUpTo(max);
|
|
410
|
+
this.strategy.unsafeOnQueueEmptySpace(this.queue, this.takers);
|
|
411
|
+
return assets.fromIterable$1(values);
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
takeBetween(min, max) {
|
|
415
|
+
return assets.suspend(() => takeRemainderLoop(this, min, max, assets.empty$1()));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/** @internal */
|
|
419
|
+
const takeRemainderLoop = (self, min, max, acc) => {
|
|
420
|
+
if (max < min) {
|
|
421
|
+
return assets.succeed(acc);
|
|
422
|
+
}
|
|
423
|
+
return assets.pipe(takeUpTo(self, max), assets.flatMap(bs => {
|
|
424
|
+
const remaining = min - bs.length;
|
|
425
|
+
if (remaining === 1) {
|
|
426
|
+
return assets.pipe(take$1(self), assets.map$1(b => assets.pipe(acc, assets.appendAll(bs), assets.append(b))));
|
|
427
|
+
}
|
|
428
|
+
if (remaining > 1) {
|
|
429
|
+
return assets.pipe(take$1(self), assets.flatMap(b => takeRemainderLoop(self, remaining - 1, max - bs.length - 1, assets.pipe(acc, assets.appendAll(bs), assets.append(b)))));
|
|
430
|
+
}
|
|
431
|
+
return assets.succeed(assets.pipe(acc, assets.appendAll(bs)));
|
|
432
|
+
}));
|
|
433
|
+
};
|
|
434
|
+
/** @internal */
|
|
435
|
+
const bounded$1 = requestedCapacity => assets.pipe(assets.sync(() => icons.bounded(requestedCapacity)), assets.flatMap(queue => make$2(backingQueueFromMutableQueue(queue), backPressureStrategy())));
|
|
436
|
+
/** @internal */
|
|
437
|
+
const unbounded$1 = () => assets.pipe(assets.sync(() => icons.unbounded()), assets.flatMap(queue => make$2(backingQueueFromMutableQueue(queue), droppingStrategy())));
|
|
438
|
+
/** @internal */
|
|
439
|
+
const unsafeMake = (queue, takers, shutdownHook, shutdownFlag, strategy) => {
|
|
440
|
+
return new QueueImpl(queue, takers, shutdownHook, shutdownFlag, strategy);
|
|
441
|
+
};
|
|
442
|
+
/** @internal */
|
|
443
|
+
const make$2 = (queue, strategy) => assets.pipe(assets.deferredMake(), assets.map$1(deferred => unsafeMake(queue, icons.unbounded(), deferred, assets.make$1(false), strategy)));
|
|
444
|
+
/** @internal */
|
|
445
|
+
class BackingQueueFromMutableQueue {
|
|
446
|
+
mutable;
|
|
447
|
+
[BackingQueueTypeId] = backingQueueVariance;
|
|
448
|
+
constructor(mutable) {
|
|
449
|
+
this.mutable = mutable;
|
|
450
|
+
}
|
|
451
|
+
poll(def) {
|
|
452
|
+
return icons.poll(this.mutable, def);
|
|
453
|
+
}
|
|
454
|
+
pollUpTo(limit) {
|
|
455
|
+
return icons.pollUpTo(this.mutable, limit);
|
|
456
|
+
}
|
|
457
|
+
offerAll(elements) {
|
|
458
|
+
return icons.offerAll(this.mutable, elements);
|
|
459
|
+
}
|
|
460
|
+
offer(element) {
|
|
461
|
+
return icons.offer(this.mutable, element);
|
|
462
|
+
}
|
|
463
|
+
capacity() {
|
|
464
|
+
return icons.capacity(this.mutable);
|
|
465
|
+
}
|
|
466
|
+
length() {
|
|
467
|
+
return icons.length(this.mutable);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
/** @internal */
|
|
471
|
+
const backingQueueFromMutableQueue = mutable => new BackingQueueFromMutableQueue(mutable);
|
|
472
|
+
/** @internal */
|
|
473
|
+
const size$1 = self => self.size;
|
|
474
|
+
/** @internal */
|
|
475
|
+
const isShutdown$1 = self => self.isShutdown;
|
|
476
|
+
/** @internal */
|
|
477
|
+
const shutdown$1 = self => self.shutdown;
|
|
478
|
+
/** @internal */
|
|
479
|
+
const offer$1 = /*#__PURE__*/assets.dual(2, (self, value) => self.offer(value));
|
|
480
|
+
/** @internal */
|
|
481
|
+
const take$1 = self => self.take;
|
|
482
|
+
/** @internal */
|
|
483
|
+
const takeUpTo = /*#__PURE__*/assets.dual(2, (self, max) => self.takeUpTo(max));
|
|
484
|
+
/** @internal */
|
|
485
|
+
const takeBetween$1 = /*#__PURE__*/assets.dual(3, (self, min, max) => self.takeBetween(min, max));
|
|
486
|
+
// -----------------------------------------------------------------------------
|
|
487
|
+
// Strategy
|
|
488
|
+
// -----------------------------------------------------------------------------
|
|
489
|
+
/** @internal */
|
|
490
|
+
const backPressureStrategy = () => new BackPressureStrategy();
|
|
491
|
+
/** @internal */
|
|
492
|
+
const droppingStrategy = () => new DroppingStrategy();
|
|
493
|
+
/** @internal */
|
|
494
|
+
class BackPressureStrategy {
|
|
495
|
+
[QueueStrategyTypeId] = queueStrategyVariance;
|
|
496
|
+
putters = /*#__PURE__*/icons.unbounded();
|
|
497
|
+
surplusSize() {
|
|
498
|
+
return icons.length(this.putters);
|
|
499
|
+
}
|
|
500
|
+
onCompleteTakersWithEmptyQueue(takers) {
|
|
501
|
+
while (!icons.isEmpty(this.putters) && !icons.isEmpty(takers)) {
|
|
502
|
+
const taker = icons.poll(takers, void 0);
|
|
503
|
+
const putter = icons.poll(this.putters, void 0);
|
|
504
|
+
if (putter[2]) {
|
|
505
|
+
unsafeCompleteDeferred(putter[1], true);
|
|
506
|
+
}
|
|
507
|
+
unsafeCompleteDeferred(taker, putter[0]);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
get shutdown() {
|
|
511
|
+
return assets.pipe(assets.fiberId, assets.flatMap(fiberId => assets.pipe(assets.sync(() => unsafePollAll(this.putters)), assets.flatMap(putters => assets.forEachConcurrentDiscard(putters, ([_, deferred, isLastItem]) => isLastItem ? assets.pipe(assets.deferredInterruptWith(deferred, fiberId), assets.asVoid) : assets.void_, false, false)))));
|
|
512
|
+
}
|
|
513
|
+
handleSurplus(iterable, queue, takers, isShutdown) {
|
|
514
|
+
return assets.withFiberRuntime(state => {
|
|
515
|
+
const deferred = assets.deferredUnsafeMake(state.id());
|
|
516
|
+
return assets.pipe(assets.suspend(() => {
|
|
517
|
+
this.unsafeOffer(iterable, deferred);
|
|
518
|
+
this.unsafeOnQueueEmptySpace(queue, takers);
|
|
519
|
+
unsafeCompleteTakers(this, queue, takers);
|
|
520
|
+
return assets.get$1(isShutdown) ? assets.interrupt$1 : assets.deferredAwait(deferred);
|
|
521
|
+
}), assets.onInterrupt(() => assets.sync(() => this.unsafeRemove(deferred))));
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
unsafeOnQueueEmptySpace(queue, takers) {
|
|
525
|
+
let keepPolling = true;
|
|
526
|
+
while (keepPolling && (queue.capacity() === Number.POSITIVE_INFINITY || queue.length() < queue.capacity())) {
|
|
527
|
+
const putter = assets.pipe(this.putters, icons.poll(icons.EmptyMutableQueue));
|
|
528
|
+
if (putter === icons.EmptyMutableQueue) {
|
|
529
|
+
keepPolling = false;
|
|
530
|
+
} else {
|
|
531
|
+
const offered = queue.offer(putter[0]);
|
|
532
|
+
if (offered && putter[2]) {
|
|
533
|
+
unsafeCompleteDeferred(putter[1], true);
|
|
534
|
+
} else if (!offered) {
|
|
535
|
+
unsafeOfferAll(this.putters, assets.pipe(unsafePollAll(this.putters), assets.prepend(putter)));
|
|
536
|
+
}
|
|
537
|
+
unsafeCompleteTakers(this, queue, takers);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
unsafeOffer(iterable, deferred) {
|
|
542
|
+
const stuff = assets.fromIterable(iterable);
|
|
543
|
+
for (let i = 0; i < stuff.length; i++) {
|
|
544
|
+
const value = stuff[i];
|
|
545
|
+
if (i === stuff.length - 1) {
|
|
546
|
+
assets.pipe(this.putters, icons.offer([value, deferred, true]));
|
|
547
|
+
} else {
|
|
548
|
+
assets.pipe(this.putters, icons.offer([value, deferred, false]));
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
unsafeRemove(deferred) {
|
|
553
|
+
unsafeOfferAll(this.putters, assets.pipe(unsafePollAll(this.putters), assets.filter(([, _]) => _ !== deferred)));
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/** @internal */
|
|
557
|
+
class DroppingStrategy {
|
|
558
|
+
[QueueStrategyTypeId] = queueStrategyVariance;
|
|
559
|
+
surplusSize() {
|
|
560
|
+
return 0;
|
|
561
|
+
}
|
|
562
|
+
get shutdown() {
|
|
563
|
+
return assets.void_;
|
|
564
|
+
}
|
|
565
|
+
onCompleteTakersWithEmptyQueue() {}
|
|
566
|
+
handleSurplus(_iterable, _queue, _takers, _isShutdown) {
|
|
567
|
+
return assets.succeed(false);
|
|
568
|
+
}
|
|
569
|
+
unsafeOnQueueEmptySpace(_queue, _takers) {
|
|
570
|
+
//
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
/** @internal */
|
|
574
|
+
const unsafeCompleteDeferred = (deferred, a) => {
|
|
575
|
+
return assets.deferredUnsafeDone(deferred, assets.succeed(a));
|
|
576
|
+
};
|
|
577
|
+
/** @internal */
|
|
578
|
+
const unsafeOfferAll = (queue, as) => {
|
|
579
|
+
return assets.pipe(queue, icons.offerAll(as));
|
|
580
|
+
};
|
|
581
|
+
/** @internal */
|
|
582
|
+
const unsafePollAll = queue => {
|
|
583
|
+
return assets.pipe(queue, icons.pollUpTo(Number.POSITIVE_INFINITY));
|
|
584
|
+
};
|
|
585
|
+
/** @internal */
|
|
586
|
+
const unsafePollN = (queue, max) => {
|
|
587
|
+
return assets.pipe(queue, icons.pollUpTo(max));
|
|
588
|
+
};
|
|
589
|
+
/** @internal */
|
|
590
|
+
const unsafeRemove = (queue, a) => {
|
|
591
|
+
unsafeOfferAll(queue, assets.pipe(unsafePollAll(queue), assets.filter(b => a !== b)));
|
|
592
|
+
};
|
|
593
|
+
/** @internal */
|
|
594
|
+
const unsafeCompleteTakers = (strategy, queue, takers) => {
|
|
595
|
+
// Check both a taker and an item are in the queue, starting with the taker
|
|
596
|
+
let keepPolling = true;
|
|
597
|
+
while (keepPolling && queue.length() !== 0) {
|
|
598
|
+
const taker = assets.pipe(takers, icons.poll(icons.EmptyMutableQueue));
|
|
599
|
+
if (taker !== icons.EmptyMutableQueue) {
|
|
600
|
+
const element = queue.poll(icons.EmptyMutableQueue);
|
|
601
|
+
if (element !== icons.EmptyMutableQueue) {
|
|
602
|
+
unsafeCompleteDeferred(taker, element);
|
|
603
|
+
strategy.unsafeOnQueueEmptySpace(queue, takers);
|
|
604
|
+
} else {
|
|
605
|
+
unsafeOfferAll(takers, assets.pipe(unsafePollAll(takers), assets.prepend(taker)));
|
|
606
|
+
}
|
|
607
|
+
keepPolling = true;
|
|
608
|
+
} else {
|
|
609
|
+
keepPolling = false;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (keepPolling && queue.length() === 0 && !icons.isEmpty(takers)) {
|
|
613
|
+
strategy.onCompleteTakersWithEmptyQueue(takers);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Makes a new bounded `Queue`. When the capacity of the queue is reached, any
|
|
619
|
+
* additional calls to `offer` will be suspended until there is more room in
|
|
620
|
+
* the queue.
|
|
621
|
+
*
|
|
622
|
+
* **Note**: When possible use only power of 2 capacities; this will provide
|
|
623
|
+
* better performance by utilising an optimised version of the underlying
|
|
624
|
+
* `RingBuffer`.
|
|
625
|
+
*
|
|
626
|
+
* @since 2.0.0
|
|
627
|
+
* @category constructors
|
|
628
|
+
*/
|
|
629
|
+
const bounded = bounded$1;
|
|
630
|
+
/**
|
|
631
|
+
* Creates a new unbounded `Queue`.
|
|
632
|
+
*
|
|
633
|
+
* @since 2.0.0
|
|
634
|
+
* @category constructors
|
|
635
|
+
*/
|
|
636
|
+
const unbounded = unbounded$1;
|
|
637
|
+
/**
|
|
638
|
+
* Retrieves the size of the queue, which is equal to the number of elements
|
|
639
|
+
* in the queue. This may be negative if fibers are suspended waiting for
|
|
640
|
+
* elements to be added to the queue.
|
|
641
|
+
*
|
|
642
|
+
* @since 2.0.0
|
|
643
|
+
* @category getters
|
|
644
|
+
*/
|
|
645
|
+
const size = size$1;
|
|
646
|
+
/**
|
|
647
|
+
* Returns `true` if `shutdown` has been called, otherwise returns `false`.
|
|
648
|
+
*
|
|
649
|
+
* @since 2.0.0
|
|
650
|
+
* @category getters
|
|
651
|
+
*/
|
|
652
|
+
const isShutdown = isShutdown$1;
|
|
653
|
+
/**
|
|
654
|
+
* Interrupts any fibers that are suspended on `offer` or `take`. Future calls
|
|
655
|
+
* to `offer*` and `take*` will be interrupted immediately.
|
|
656
|
+
*
|
|
657
|
+
* @since 2.0.0
|
|
658
|
+
* @category utils
|
|
659
|
+
*/
|
|
660
|
+
const shutdown = shutdown$1;
|
|
661
|
+
/**
|
|
662
|
+
* Places one value in the queue.
|
|
663
|
+
*
|
|
664
|
+
* @since 2.0.0
|
|
665
|
+
* @category utils
|
|
666
|
+
*/
|
|
667
|
+
const offer = offer$1;
|
|
668
|
+
/**
|
|
669
|
+
* Takes the oldest value in the queue. If the queue is empty, this will return
|
|
670
|
+
* a computation that resumes when an item has been added to the queue.
|
|
671
|
+
*
|
|
672
|
+
* @since 2.0.0
|
|
673
|
+
* @category utils
|
|
674
|
+
*/
|
|
675
|
+
const take = take$1;
|
|
676
|
+
/**
|
|
677
|
+
* Takes a number of elements from the queue between the specified minimum and
|
|
678
|
+
* maximum. If there are fewer than the minimum number of elements available,
|
|
679
|
+
* suspends until at least the minimum number of elements have been collected.
|
|
680
|
+
*
|
|
681
|
+
* @since 2.0.0
|
|
682
|
+
* @category utils
|
|
683
|
+
*/
|
|
684
|
+
const takeBetween = takeBetween$1;
|
|
685
|
+
|
|
686
|
+
/** @internal */
|
|
687
|
+
const OP_CONTINUE = "Continue";
|
|
688
|
+
/** @internal */
|
|
689
|
+
const OP_CLOSE = "Close";
|
|
690
|
+
/** @internal */
|
|
691
|
+
const OP_YIELD = "Yield";
|
|
692
|
+
|
|
693
|
+
/** @internal */
|
|
694
|
+
const ChildExecutorDecisionSymbolKey = "effect/ChannelChildExecutorDecision";
|
|
695
|
+
/** @internal */
|
|
696
|
+
const ChildExecutorDecisionTypeId = /*#__PURE__*/Symbol.for(ChildExecutorDecisionSymbolKey);
|
|
697
|
+
/** @internal */
|
|
698
|
+
const proto$7 = {
|
|
699
|
+
[ChildExecutorDecisionTypeId]: ChildExecutorDecisionTypeId
|
|
700
|
+
};
|
|
701
|
+
/** @internal */
|
|
702
|
+
const Continue = _ => {
|
|
703
|
+
const op = Object.create(proto$7);
|
|
704
|
+
op._tag = OP_CONTINUE;
|
|
705
|
+
return op;
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
/** @internal */
|
|
709
|
+
const OP_CONTINUATION_K = "ContinuationK";
|
|
710
|
+
/** @internal */
|
|
711
|
+
const OP_CONTINUATION_FINALIZER = "ContinuationFinalizer";
|
|
712
|
+
|
|
713
|
+
/** @internal */
|
|
714
|
+
const ContinuationTypeId = /*#__PURE__*/Symbol.for("effect/ChannelContinuation");
|
|
715
|
+
const continuationVariance = {
|
|
716
|
+
/* c8 ignore next */
|
|
717
|
+
_Env: _ => _,
|
|
718
|
+
/* c8 ignore next */
|
|
719
|
+
_InErr: _ => _,
|
|
720
|
+
/* c8 ignore next */
|
|
721
|
+
_InElem: _ => _,
|
|
722
|
+
/* c8 ignore next */
|
|
723
|
+
_InDone: _ => _,
|
|
724
|
+
/* c8 ignore next */
|
|
725
|
+
_OutErr: _ => _,
|
|
726
|
+
/* c8 ignore next */
|
|
727
|
+
_OutDone: _ => _,
|
|
728
|
+
/* c8 ignore next */
|
|
729
|
+
_OutErr2: _ => _,
|
|
730
|
+
/* c8 ignore next */
|
|
731
|
+
_OutElem: _ => _,
|
|
732
|
+
/* c8 ignore next */
|
|
733
|
+
_OutDone2: _ => _
|
|
734
|
+
};
|
|
735
|
+
/** @internal */
|
|
736
|
+
class ContinuationKImpl {
|
|
737
|
+
onSuccess;
|
|
738
|
+
onHalt;
|
|
739
|
+
_tag = OP_CONTINUATION_K;
|
|
740
|
+
[ContinuationTypeId] = continuationVariance;
|
|
741
|
+
constructor(onSuccess, onHalt) {
|
|
742
|
+
this.onSuccess = onSuccess;
|
|
743
|
+
this.onHalt = onHalt;
|
|
744
|
+
}
|
|
745
|
+
onExit(exit) {
|
|
746
|
+
return icons.isFailure(exit) ? this.onHalt(exit.cause) : this.onSuccess(exit.value);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
/** @internal */
|
|
750
|
+
class ContinuationFinalizerImpl {
|
|
751
|
+
finalizer;
|
|
752
|
+
_tag = OP_CONTINUATION_FINALIZER;
|
|
753
|
+
[ContinuationTypeId] = continuationVariance;
|
|
754
|
+
constructor(finalizer) {
|
|
755
|
+
this.finalizer = finalizer;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** @internal */
|
|
760
|
+
const OP_PULL_AFTER_NEXT = "PullAfterNext";
|
|
761
|
+
/** @internal */
|
|
762
|
+
const OP_PULL_AFTER_ALL_ENQUEUED = "PullAfterAllEnqueued";
|
|
763
|
+
|
|
764
|
+
/** @internal */
|
|
765
|
+
const UpstreamPullStrategySymbolKey = "effect/ChannelUpstreamPullStrategy";
|
|
766
|
+
/** @internal */
|
|
767
|
+
const UpstreamPullStrategyTypeId = /*#__PURE__*/Symbol.for(UpstreamPullStrategySymbolKey);
|
|
768
|
+
const upstreamPullStrategyVariance = {
|
|
769
|
+
/* c8 ignore next */
|
|
770
|
+
_A: _ => _
|
|
771
|
+
};
|
|
772
|
+
/** @internal */
|
|
773
|
+
const proto$6 = {
|
|
774
|
+
[UpstreamPullStrategyTypeId]: upstreamPullStrategyVariance
|
|
775
|
+
};
|
|
776
|
+
/** @internal */
|
|
777
|
+
const PullAfterNext = emitSeparator => {
|
|
778
|
+
const op = Object.create(proto$6);
|
|
779
|
+
op._tag = OP_PULL_AFTER_NEXT;
|
|
780
|
+
op.emitSeparator = emitSeparator;
|
|
781
|
+
return op;
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
/** @internal */
|
|
785
|
+
const OP_BRACKET_OUT = "BracketOut";
|
|
786
|
+
/** @internal */
|
|
787
|
+
const OP_BRIDGE = "Bridge";
|
|
788
|
+
/** @internal */
|
|
789
|
+
const OP_CONCAT_ALL = "ConcatAll";
|
|
790
|
+
/** @internal */
|
|
791
|
+
const OP_EMIT$2 = "Emit";
|
|
792
|
+
/** @internal */
|
|
793
|
+
const OP_ENSURING = "Ensuring";
|
|
794
|
+
/** @internal */
|
|
795
|
+
const OP_FAIL = "Fail";
|
|
796
|
+
/** @internal */
|
|
797
|
+
const OP_FOLD = "Fold";
|
|
798
|
+
/** @internal */
|
|
799
|
+
const OP_FROM_EFFECT$1 = "FromEffect";
|
|
800
|
+
/** @internal */
|
|
801
|
+
const OP_PIPE_TO = "PipeTo";
|
|
802
|
+
/** @internal */
|
|
803
|
+
const OP_PROVIDE = "Provide";
|
|
804
|
+
/** @internal */
|
|
805
|
+
const OP_READ$1 = "Read";
|
|
806
|
+
/** @internal */
|
|
807
|
+
const OP_SUCCEED = "Succeed";
|
|
808
|
+
/** @internal */
|
|
809
|
+
const OP_SUCCEED_NOW = "SucceedNow";
|
|
810
|
+
/** @internal */
|
|
811
|
+
const OP_SUSPEND = "Suspend";
|
|
812
|
+
|
|
813
|
+
/** @internal */
|
|
814
|
+
const ChannelSymbolKey = "effect/Channel";
|
|
815
|
+
/** @internal */
|
|
816
|
+
const ChannelTypeId = /*#__PURE__*/Symbol.for(ChannelSymbolKey);
|
|
817
|
+
const channelVariance = {
|
|
818
|
+
/* c8 ignore next */
|
|
819
|
+
_Env: _ => _,
|
|
820
|
+
/* c8 ignore next */
|
|
821
|
+
_InErr: _ => _,
|
|
822
|
+
/* c8 ignore next */
|
|
823
|
+
_InElem: _ => _,
|
|
824
|
+
/* c8 ignore next */
|
|
825
|
+
_InDone: _ => _,
|
|
826
|
+
/* c8 ignore next */
|
|
827
|
+
_OutErr: _ => _,
|
|
828
|
+
/* c8 ignore next */
|
|
829
|
+
_OutElem: _ => _,
|
|
830
|
+
/* c8 ignore next */
|
|
831
|
+
_OutDone: _ => _
|
|
832
|
+
};
|
|
833
|
+
/** @internal */
|
|
834
|
+
const proto$5 = {
|
|
835
|
+
[ChannelTypeId]: channelVariance,
|
|
836
|
+
pipe() {
|
|
837
|
+
return assets.pipeArguments(this, arguments);
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
/** @internal */
|
|
841
|
+
const isChannel = u => assets.hasProperty(u, ChannelTypeId) || assets.isEffect(u);
|
|
842
|
+
/** @internal */
|
|
843
|
+
const acquireReleaseOut = /*#__PURE__*/assets.dual(2, (self, release) => {
|
|
844
|
+
const op = Object.create(proto$5);
|
|
845
|
+
op._tag = OP_BRACKET_OUT;
|
|
846
|
+
op.acquire = () => self;
|
|
847
|
+
op.finalizer = release;
|
|
848
|
+
return op;
|
|
849
|
+
});
|
|
850
|
+
/** @internal */
|
|
851
|
+
const concatAllWith = (channels, f, g) => {
|
|
852
|
+
const op = Object.create(proto$5);
|
|
853
|
+
op._tag = OP_CONCAT_ALL;
|
|
854
|
+
op.combineInners = f;
|
|
855
|
+
op.combineAll = g;
|
|
856
|
+
op.onPull = () => PullAfterNext(assets.none());
|
|
857
|
+
op.onEmit = () => Continue;
|
|
858
|
+
op.value = () => channels;
|
|
859
|
+
op.k = assets.identity;
|
|
860
|
+
return op;
|
|
861
|
+
};
|
|
862
|
+
/** @internal */
|
|
863
|
+
const concatMapWith = /*#__PURE__*/assets.dual(4, (self, f, g, h) => {
|
|
864
|
+
const op = Object.create(proto$5);
|
|
865
|
+
op._tag = OP_CONCAT_ALL;
|
|
866
|
+
op.combineInners = g;
|
|
867
|
+
op.combineAll = h;
|
|
868
|
+
op.onPull = () => PullAfterNext(assets.none());
|
|
869
|
+
op.onEmit = () => Continue;
|
|
870
|
+
op.value = () => self;
|
|
871
|
+
op.k = f;
|
|
872
|
+
return op;
|
|
873
|
+
});
|
|
874
|
+
/** @internal */
|
|
875
|
+
const embedInput = /*#__PURE__*/assets.dual(2, (self, input) => {
|
|
876
|
+
const op = Object.create(proto$5);
|
|
877
|
+
op._tag = OP_BRIDGE;
|
|
878
|
+
op.input = input;
|
|
879
|
+
op.channel = self;
|
|
880
|
+
return op;
|
|
881
|
+
});
|
|
882
|
+
/** @internal */
|
|
883
|
+
const ensuringWith = /*#__PURE__*/assets.dual(2, (self, finalizer) => {
|
|
884
|
+
const op = Object.create(proto$5);
|
|
885
|
+
op._tag = OP_ENSURING;
|
|
886
|
+
op.channel = self;
|
|
887
|
+
op.finalizer = finalizer;
|
|
888
|
+
return op;
|
|
889
|
+
});
|
|
890
|
+
/** @internal */
|
|
891
|
+
const fail = error => failCause$2(fail$1(error));
|
|
892
|
+
/** @internal */
|
|
893
|
+
const failCause$2 = cause => failCauseSync(() => cause);
|
|
894
|
+
/** @internal */
|
|
895
|
+
const failCauseSync = evaluate => {
|
|
896
|
+
const op = Object.create(proto$5);
|
|
897
|
+
op._tag = OP_FAIL;
|
|
898
|
+
op.error = evaluate;
|
|
899
|
+
return op;
|
|
900
|
+
};
|
|
901
|
+
/** @internal */
|
|
902
|
+
const flatMap$1 = /*#__PURE__*/assets.dual(2, (self, f) => {
|
|
903
|
+
const op = Object.create(proto$5);
|
|
904
|
+
op._tag = OP_FOLD;
|
|
905
|
+
op.channel = self;
|
|
906
|
+
op.k = new ContinuationKImpl(f, failCause$2);
|
|
907
|
+
return op;
|
|
908
|
+
});
|
|
909
|
+
/** @internal */
|
|
910
|
+
const fromEffect$3 = effect => {
|
|
911
|
+
const op = Object.create(proto$5);
|
|
912
|
+
op._tag = OP_FROM_EFFECT$1;
|
|
913
|
+
op.effect = () => effect;
|
|
914
|
+
return op;
|
|
915
|
+
};
|
|
916
|
+
/** @internal */
|
|
917
|
+
const pipeTo = /*#__PURE__*/assets.dual(2, (self, that) => {
|
|
918
|
+
const op = Object.create(proto$5);
|
|
919
|
+
op._tag = OP_PIPE_TO;
|
|
920
|
+
op.left = () => self;
|
|
921
|
+
op.right = () => that;
|
|
922
|
+
return op;
|
|
923
|
+
});
|
|
924
|
+
/** @internal */
|
|
925
|
+
const readWith = options => readWithCause({
|
|
926
|
+
onInput: options.onInput,
|
|
927
|
+
onFailure: cause => assets.match(failureOrCause(cause), {
|
|
928
|
+
onLeft: options.onFailure,
|
|
929
|
+
onRight: failCause$2
|
|
930
|
+
}),
|
|
931
|
+
onDone: options.onDone
|
|
932
|
+
});
|
|
933
|
+
/** @internal */
|
|
934
|
+
const readWithCause = options => {
|
|
935
|
+
const op = Object.create(proto$5);
|
|
936
|
+
op._tag = OP_READ$1;
|
|
937
|
+
op.more = options.onInput;
|
|
938
|
+
op.done = new ContinuationKImpl(options.onDone, options.onFailure);
|
|
939
|
+
return op;
|
|
940
|
+
};
|
|
941
|
+
/** @internal */
|
|
942
|
+
const succeed = value => sync(() => value);
|
|
943
|
+
/** @internal */
|
|
944
|
+
const succeedNow = result => {
|
|
945
|
+
const op = Object.create(proto$5);
|
|
946
|
+
op._tag = OP_SUCCEED_NOW;
|
|
947
|
+
op.terminal = result;
|
|
948
|
+
return op;
|
|
949
|
+
};
|
|
950
|
+
/** @internal */
|
|
951
|
+
const suspend$1 = evaluate => {
|
|
952
|
+
const op = Object.create(proto$5);
|
|
953
|
+
op._tag = OP_SUSPEND;
|
|
954
|
+
op.channel = evaluate;
|
|
955
|
+
return op;
|
|
956
|
+
};
|
|
957
|
+
const sync = evaluate => {
|
|
958
|
+
const op = Object.create(proto$5);
|
|
959
|
+
op._tag = OP_SUCCEED;
|
|
960
|
+
op.evaluate = evaluate;
|
|
961
|
+
return op;
|
|
962
|
+
};
|
|
963
|
+
const void_ = /*#__PURE__*/succeedNow(void 0);
|
|
964
|
+
/** @internal */
|
|
965
|
+
const write = out => {
|
|
966
|
+
const op = Object.create(proto$5);
|
|
967
|
+
op._tag = OP_EMIT$2;
|
|
968
|
+
op.out = out;
|
|
969
|
+
return op;
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
/** @internal */
|
|
973
|
+
const OP_DONE$1 = "Done";
|
|
974
|
+
/** @internal */
|
|
975
|
+
const OP_EMIT$1 = "Emit";
|
|
976
|
+
/** @internal */
|
|
977
|
+
const OP_FROM_EFFECT = "FromEffect";
|
|
978
|
+
/** @internal */
|
|
979
|
+
const OP_READ = "Read";
|
|
980
|
+
|
|
981
|
+
/** @internal */
|
|
982
|
+
const ChannelStateTypeId = /*#__PURE__*/Symbol.for("effect/ChannelState");
|
|
983
|
+
const channelStateVariance = {
|
|
984
|
+
/* c8 ignore next */
|
|
985
|
+
_E: _ => _,
|
|
986
|
+
/* c8 ignore next */
|
|
987
|
+
_R: _ => _
|
|
988
|
+
};
|
|
989
|
+
/** @internal */
|
|
990
|
+
const proto$4 = {
|
|
991
|
+
[ChannelStateTypeId]: channelStateVariance
|
|
992
|
+
};
|
|
993
|
+
/** @internal */
|
|
994
|
+
const Done = () => {
|
|
995
|
+
const op = Object.create(proto$4);
|
|
996
|
+
op._tag = OP_DONE$1;
|
|
997
|
+
return op;
|
|
998
|
+
};
|
|
999
|
+
/** @internal */
|
|
1000
|
+
const Emit$1 = () => {
|
|
1001
|
+
const op = Object.create(proto$4);
|
|
1002
|
+
op._tag = OP_EMIT$1;
|
|
1003
|
+
return op;
|
|
1004
|
+
};
|
|
1005
|
+
/** @internal */
|
|
1006
|
+
const fromEffect$2 = effect => {
|
|
1007
|
+
const op = Object.create(proto$4);
|
|
1008
|
+
op._tag = OP_FROM_EFFECT;
|
|
1009
|
+
op.effect = effect;
|
|
1010
|
+
return op;
|
|
1011
|
+
};
|
|
1012
|
+
/** @internal */
|
|
1013
|
+
const Read = (upstream, onEffect, onEmit, onDone) => {
|
|
1014
|
+
const op = Object.create(proto$4);
|
|
1015
|
+
op._tag = OP_READ;
|
|
1016
|
+
op.upstream = upstream;
|
|
1017
|
+
op.onEffect = onEffect;
|
|
1018
|
+
op.onEmit = onEmit;
|
|
1019
|
+
op.onDone = onDone;
|
|
1020
|
+
return op;
|
|
1021
|
+
};
|
|
1022
|
+
/** @internal */
|
|
1023
|
+
const isFromEffect = self => self._tag === OP_FROM_EFFECT;
|
|
1024
|
+
/** @internal */
|
|
1025
|
+
const effect = self => isFromEffect(self) ? self.effect : assets._void;
|
|
1026
|
+
/** @internal */
|
|
1027
|
+
const effectOrUndefinedIgnored = self => isFromEffect(self) ? assets.ignore(self.effect) : undefined;
|
|
1028
|
+
|
|
1029
|
+
/** @internal */
|
|
1030
|
+
const OP_PULL_FROM_CHILD = "PullFromChild";
|
|
1031
|
+
/** @internal */
|
|
1032
|
+
const OP_PULL_FROM_UPSTREAM = "PullFromUpstream";
|
|
1033
|
+
/** @internal */
|
|
1034
|
+
const OP_DRAIN_CHILD_EXECUTORS = "DrainChildExecutors";
|
|
1035
|
+
/** @internal */
|
|
1036
|
+
const OP_EMIT = "Emit";
|
|
1037
|
+
/**
|
|
1038
|
+
* Execute the `childExecutor` and on each emitted value, decide what to do by
|
|
1039
|
+
* `onEmit`.
|
|
1040
|
+
*
|
|
1041
|
+
* @internal
|
|
1042
|
+
*/
|
|
1043
|
+
class PullFromChild {
|
|
1044
|
+
childExecutor;
|
|
1045
|
+
parentSubexecutor;
|
|
1046
|
+
onEmit;
|
|
1047
|
+
_tag = OP_PULL_FROM_CHILD;
|
|
1048
|
+
constructor(childExecutor, parentSubexecutor, onEmit) {
|
|
1049
|
+
this.childExecutor = childExecutor;
|
|
1050
|
+
this.parentSubexecutor = parentSubexecutor;
|
|
1051
|
+
this.onEmit = onEmit;
|
|
1052
|
+
}
|
|
1053
|
+
close(exit) {
|
|
1054
|
+
const fin1 = this.childExecutor.close(exit);
|
|
1055
|
+
const fin2 = this.parentSubexecutor.close(exit);
|
|
1056
|
+
if (fin1 !== undefined && fin2 !== undefined) {
|
|
1057
|
+
return assets.zipWith(assets.exit(fin1), assets.exit(fin2), (exit1, exit2) => assets.pipe(exit1, icons.zipRight(exit2)));
|
|
1058
|
+
} else if (fin1 !== undefined) {
|
|
1059
|
+
return fin1;
|
|
1060
|
+
} else if (fin2 !== undefined) {
|
|
1061
|
+
return fin2;
|
|
1062
|
+
} else {
|
|
1063
|
+
return undefined;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
enqueuePullFromChild(_child) {
|
|
1067
|
+
return this;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Execute `upstreamExecutor` and for each emitted element, spawn a child
|
|
1072
|
+
* channel and continue with processing it by `PullFromChild`.
|
|
1073
|
+
*
|
|
1074
|
+
* @internal
|
|
1075
|
+
*/
|
|
1076
|
+
class PullFromUpstream {
|
|
1077
|
+
upstreamExecutor;
|
|
1078
|
+
createChild;
|
|
1079
|
+
lastDone;
|
|
1080
|
+
activeChildExecutors;
|
|
1081
|
+
combineChildResults;
|
|
1082
|
+
combineWithChildResult;
|
|
1083
|
+
onPull;
|
|
1084
|
+
onEmit;
|
|
1085
|
+
_tag = OP_PULL_FROM_UPSTREAM;
|
|
1086
|
+
constructor(upstreamExecutor, createChild, lastDone, activeChildExecutors, combineChildResults, combineWithChildResult, onPull, onEmit) {
|
|
1087
|
+
this.upstreamExecutor = upstreamExecutor;
|
|
1088
|
+
this.createChild = createChild;
|
|
1089
|
+
this.lastDone = lastDone;
|
|
1090
|
+
this.activeChildExecutors = activeChildExecutors;
|
|
1091
|
+
this.combineChildResults = combineChildResults;
|
|
1092
|
+
this.combineWithChildResult = combineWithChildResult;
|
|
1093
|
+
this.onPull = onPull;
|
|
1094
|
+
this.onEmit = onEmit;
|
|
1095
|
+
}
|
|
1096
|
+
close(exit) {
|
|
1097
|
+
const fin1 = this.upstreamExecutor.close(exit);
|
|
1098
|
+
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
|
|
1099
|
+
const result = fins.reduce((acc, next) => {
|
|
1100
|
+
if (acc !== undefined && next !== undefined) {
|
|
1101
|
+
return assets.zipWith(acc, assets.exit(next), (exit1, exit2) => icons.zipRight(exit1, exit2));
|
|
1102
|
+
} else if (acc !== undefined) {
|
|
1103
|
+
return acc;
|
|
1104
|
+
} else if (next !== undefined) {
|
|
1105
|
+
return assets.exit(next);
|
|
1106
|
+
} else {
|
|
1107
|
+
return undefined;
|
|
1108
|
+
}
|
|
1109
|
+
}, undefined);
|
|
1110
|
+
return result === undefined ? result : result;
|
|
1111
|
+
}
|
|
1112
|
+
enqueuePullFromChild(child) {
|
|
1113
|
+
return new PullFromUpstream(this.upstreamExecutor, this.createChild, this.lastDone, [...this.activeChildExecutors, child], this.combineChildResults, this.combineWithChildResult, this.onPull, this.onEmit);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Transformed from `PullFromUpstream` when upstream has finished but there
|
|
1118
|
+
* are still active child executors.
|
|
1119
|
+
*
|
|
1120
|
+
* @internal
|
|
1121
|
+
*/
|
|
1122
|
+
class DrainChildExecutors {
|
|
1123
|
+
upstreamExecutor;
|
|
1124
|
+
lastDone;
|
|
1125
|
+
activeChildExecutors;
|
|
1126
|
+
upstreamDone;
|
|
1127
|
+
combineChildResults;
|
|
1128
|
+
combineWithChildResult;
|
|
1129
|
+
onPull;
|
|
1130
|
+
_tag = OP_DRAIN_CHILD_EXECUTORS;
|
|
1131
|
+
constructor(upstreamExecutor, lastDone, activeChildExecutors, upstreamDone, combineChildResults, combineWithChildResult, onPull) {
|
|
1132
|
+
this.upstreamExecutor = upstreamExecutor;
|
|
1133
|
+
this.lastDone = lastDone;
|
|
1134
|
+
this.activeChildExecutors = activeChildExecutors;
|
|
1135
|
+
this.upstreamDone = upstreamDone;
|
|
1136
|
+
this.combineChildResults = combineChildResults;
|
|
1137
|
+
this.combineWithChildResult = combineWithChildResult;
|
|
1138
|
+
this.onPull = onPull;
|
|
1139
|
+
}
|
|
1140
|
+
close(exit) {
|
|
1141
|
+
const fin1 = this.upstreamExecutor.close(exit);
|
|
1142
|
+
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
|
|
1143
|
+
const result = fins.reduce((acc, next) => {
|
|
1144
|
+
if (acc !== undefined && next !== undefined) {
|
|
1145
|
+
return assets.zipWith(acc, assets.exit(next), (exit1, exit2) => icons.zipRight(exit1, exit2));
|
|
1146
|
+
} else if (acc !== undefined) {
|
|
1147
|
+
return acc;
|
|
1148
|
+
} else if (next !== undefined) {
|
|
1149
|
+
return assets.exit(next);
|
|
1150
|
+
} else {
|
|
1151
|
+
return undefined;
|
|
1152
|
+
}
|
|
1153
|
+
}, undefined);
|
|
1154
|
+
return result === undefined ? result : result;
|
|
1155
|
+
}
|
|
1156
|
+
enqueuePullFromChild(child) {
|
|
1157
|
+
return new DrainChildExecutors(this.upstreamExecutor, this.lastDone, [...this.activeChildExecutors, child], this.upstreamDone, this.combineChildResults, this.combineWithChildResult, this.onPull);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
/** @internal */
|
|
1161
|
+
class Emit {
|
|
1162
|
+
value;
|
|
1163
|
+
next;
|
|
1164
|
+
_tag = OP_EMIT;
|
|
1165
|
+
constructor(value, next) {
|
|
1166
|
+
this.value = value;
|
|
1167
|
+
this.next = next;
|
|
1168
|
+
}
|
|
1169
|
+
close(exit) {
|
|
1170
|
+
const result = this.next.close(exit);
|
|
1171
|
+
return result === undefined ? result : result;
|
|
1172
|
+
}
|
|
1173
|
+
enqueuePullFromChild(_child) {
|
|
1174
|
+
return this;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/** @internal */
|
|
1179
|
+
const OP_PULLED = "Pulled";
|
|
1180
|
+
/** @internal */
|
|
1181
|
+
const OP_NO_UPSTREAM = "NoUpstream";
|
|
1182
|
+
|
|
1183
|
+
/** @internal */
|
|
1184
|
+
const UpstreamPullRequestSymbolKey = "effect/ChannelUpstreamPullRequest";
|
|
1185
|
+
/** @internal */
|
|
1186
|
+
const UpstreamPullRequestTypeId = /*#__PURE__*/Symbol.for(UpstreamPullRequestSymbolKey);
|
|
1187
|
+
const upstreamPullRequestVariance = {
|
|
1188
|
+
/* c8 ignore next */
|
|
1189
|
+
_A: _ => _
|
|
1190
|
+
};
|
|
1191
|
+
/** @internal */
|
|
1192
|
+
const proto$3 = {
|
|
1193
|
+
[UpstreamPullRequestTypeId]: upstreamPullRequestVariance
|
|
1194
|
+
};
|
|
1195
|
+
/** @internal */
|
|
1196
|
+
const Pulled = value => {
|
|
1197
|
+
const op = Object.create(proto$3);
|
|
1198
|
+
op._tag = OP_PULLED;
|
|
1199
|
+
op.value = value;
|
|
1200
|
+
return op;
|
|
1201
|
+
};
|
|
1202
|
+
/** @internal */
|
|
1203
|
+
const NoUpstream = activeDownstreamCount => {
|
|
1204
|
+
const op = Object.create(proto$3);
|
|
1205
|
+
op._tag = OP_NO_UPSTREAM;
|
|
1206
|
+
op.activeDownstreamCount = activeDownstreamCount;
|
|
1207
|
+
return op;
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
/** @internal */
|
|
1211
|
+
class ChannelExecutor {
|
|
1212
|
+
_activeSubexecutor = undefined;
|
|
1213
|
+
_cancelled = undefined;
|
|
1214
|
+
_closeLastSubstream = undefined;
|
|
1215
|
+
_currentChannel;
|
|
1216
|
+
_done = undefined;
|
|
1217
|
+
_doneStack = [];
|
|
1218
|
+
_emitted = undefined;
|
|
1219
|
+
_executeCloseLastSubstream;
|
|
1220
|
+
_input = undefined;
|
|
1221
|
+
_inProgressFinalizer = undefined;
|
|
1222
|
+
_providedEnv;
|
|
1223
|
+
constructor(initialChannel, providedEnv, executeCloseLastSubstream) {
|
|
1224
|
+
this._currentChannel = initialChannel;
|
|
1225
|
+
this._executeCloseLastSubstream = executeCloseLastSubstream;
|
|
1226
|
+
this._providedEnv = providedEnv;
|
|
1227
|
+
}
|
|
1228
|
+
run() {
|
|
1229
|
+
let result = undefined;
|
|
1230
|
+
while (result === undefined) {
|
|
1231
|
+
if (this._cancelled !== undefined) {
|
|
1232
|
+
result = this.processCancellation();
|
|
1233
|
+
} else if (this._activeSubexecutor !== undefined) {
|
|
1234
|
+
result = this.runSubexecutor();
|
|
1235
|
+
} else {
|
|
1236
|
+
try {
|
|
1237
|
+
if (this._currentChannel === undefined) {
|
|
1238
|
+
result = Done();
|
|
1239
|
+
} else {
|
|
1240
|
+
if (assets.isEffect(this._currentChannel)) {
|
|
1241
|
+
this._currentChannel = fromEffect$3(this._currentChannel);
|
|
1242
|
+
}
|
|
1243
|
+
switch (this._currentChannel._tag) {
|
|
1244
|
+
case OP_BRACKET_OUT:
|
|
1245
|
+
{
|
|
1246
|
+
result = this.runBracketOut(this._currentChannel);
|
|
1247
|
+
break;
|
|
1248
|
+
}
|
|
1249
|
+
case OP_BRIDGE:
|
|
1250
|
+
{
|
|
1251
|
+
const bridgeInput = this._currentChannel.input;
|
|
1252
|
+
// PipeTo(left, Bridge(queue, channel))
|
|
1253
|
+
// In a fiber: repeatedly run left and push its outputs to the queue
|
|
1254
|
+
// Add a finalizer to interrupt the fiber and close the executor
|
|
1255
|
+
this._currentChannel = this._currentChannel.channel;
|
|
1256
|
+
if (this._input !== undefined) {
|
|
1257
|
+
const inputExecutor = this._input;
|
|
1258
|
+
this._input = undefined;
|
|
1259
|
+
const drainer = () => assets.flatMap$1(bridgeInput.awaitRead(), () => assets.suspend$1(() => {
|
|
1260
|
+
const state = inputExecutor.run();
|
|
1261
|
+
switch (state._tag) {
|
|
1262
|
+
case OP_DONE$1:
|
|
1263
|
+
{
|
|
1264
|
+
return icons.match(inputExecutor.getDone(), {
|
|
1265
|
+
onFailure: cause => bridgeInput.error(cause),
|
|
1266
|
+
onSuccess: value => bridgeInput.done(value)
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
case OP_EMIT$1:
|
|
1270
|
+
{
|
|
1271
|
+
return assets.flatMap$1(bridgeInput.emit(inputExecutor.getEmit()), () => drainer());
|
|
1272
|
+
}
|
|
1273
|
+
case OP_FROM_EFFECT:
|
|
1274
|
+
{
|
|
1275
|
+
return assets.matchCauseEffect(state.effect, {
|
|
1276
|
+
onFailure: cause => bridgeInput.error(cause),
|
|
1277
|
+
onSuccess: () => drainer()
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
case OP_READ:
|
|
1281
|
+
{
|
|
1282
|
+
return readUpstream(state, () => drainer(), cause => bridgeInput.error(cause));
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}));
|
|
1286
|
+
result = fromEffect$2(assets.flatMap$1(assets.forkDaemon(assets.interruptible(drainer())), fiber => assets.sync$1(() => this.addFinalizer(exit => assets.flatMap$1(interrupt(fiber), () => assets.suspend$1(() => {
|
|
1287
|
+
const effect = this.restorePipe(exit, inputExecutor);
|
|
1288
|
+
return effect !== undefined ? effect : assets._void;
|
|
1289
|
+
}))))));
|
|
1290
|
+
}
|
|
1291
|
+
break;
|
|
1292
|
+
}
|
|
1293
|
+
case OP_CONCAT_ALL:
|
|
1294
|
+
{
|
|
1295
|
+
const executor = new ChannelExecutor(this._currentChannel.value(), this._providedEnv, effect => assets.sync$1(() => {
|
|
1296
|
+
const prevLastClose = this._closeLastSubstream === undefined ? assets._void : this._closeLastSubstream;
|
|
1297
|
+
this._closeLastSubstream = assets.pipe(prevLastClose, assets.zipRight$1(effect));
|
|
1298
|
+
}));
|
|
1299
|
+
executor._input = this._input;
|
|
1300
|
+
const channel = this._currentChannel;
|
|
1301
|
+
this._activeSubexecutor = new PullFromUpstream(executor, value => channel.k(value), undefined, [], (x, y) => channel.combineInners(x, y), (x, y) => channel.combineAll(x, y), request => channel.onPull(request), value => channel.onEmit(value));
|
|
1302
|
+
this._closeLastSubstream = undefined;
|
|
1303
|
+
this._currentChannel = undefined;
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1306
|
+
case OP_EMIT$2:
|
|
1307
|
+
{
|
|
1308
|
+
this._emitted = this._currentChannel.out;
|
|
1309
|
+
this._currentChannel = this._activeSubexecutor !== undefined ? undefined : void_;
|
|
1310
|
+
result = Emit$1();
|
|
1311
|
+
break;
|
|
1312
|
+
}
|
|
1313
|
+
case OP_ENSURING:
|
|
1314
|
+
{
|
|
1315
|
+
this.runEnsuring(this._currentChannel);
|
|
1316
|
+
break;
|
|
1317
|
+
}
|
|
1318
|
+
case OP_FAIL:
|
|
1319
|
+
{
|
|
1320
|
+
result = this.doneHalt(this._currentChannel.error());
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
case OP_FOLD:
|
|
1324
|
+
{
|
|
1325
|
+
this._doneStack.push(this._currentChannel.k);
|
|
1326
|
+
this._currentChannel = this._currentChannel.channel;
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1329
|
+
case OP_FROM_EFFECT$1:
|
|
1330
|
+
{
|
|
1331
|
+
const effect = this._providedEnv === undefined ? this._currentChannel.effect() : assets.pipe(this._currentChannel.effect(), assets.provide(this._providedEnv));
|
|
1332
|
+
result = fromEffect$2(assets.matchCauseEffect(effect, {
|
|
1333
|
+
onFailure: cause => {
|
|
1334
|
+
const state = this.doneHalt(cause);
|
|
1335
|
+
return state !== undefined && isFromEffect(state) ? state.effect : assets._void;
|
|
1336
|
+
},
|
|
1337
|
+
onSuccess: value => {
|
|
1338
|
+
const state = this.doneSucceed(value);
|
|
1339
|
+
return state !== undefined && isFromEffect(state) ? state.effect : assets._void;
|
|
1340
|
+
}
|
|
1341
|
+
}));
|
|
1342
|
+
break;
|
|
1343
|
+
}
|
|
1344
|
+
case OP_PIPE_TO:
|
|
1345
|
+
{
|
|
1346
|
+
const previousInput = this._input;
|
|
1347
|
+
const leftExec = new ChannelExecutor(this._currentChannel.left(), this._providedEnv, effect => this._executeCloseLastSubstream(effect));
|
|
1348
|
+
leftExec._input = previousInput;
|
|
1349
|
+
this._input = leftExec;
|
|
1350
|
+
this.addFinalizer(exit => {
|
|
1351
|
+
const effect = this.restorePipe(exit, previousInput);
|
|
1352
|
+
return effect !== undefined ? effect : assets._void;
|
|
1353
|
+
});
|
|
1354
|
+
this._currentChannel = this._currentChannel.right();
|
|
1355
|
+
break;
|
|
1356
|
+
}
|
|
1357
|
+
case OP_PROVIDE:
|
|
1358
|
+
{
|
|
1359
|
+
const previousEnv = this._providedEnv;
|
|
1360
|
+
this._providedEnv = this._currentChannel.context();
|
|
1361
|
+
this._currentChannel = this._currentChannel.inner;
|
|
1362
|
+
this.addFinalizer(() => assets.sync$1(() => {
|
|
1363
|
+
this._providedEnv = previousEnv;
|
|
1364
|
+
}));
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
case OP_READ$1:
|
|
1368
|
+
{
|
|
1369
|
+
const read = this._currentChannel;
|
|
1370
|
+
result = Read(this._input, assets.identity, emitted => {
|
|
1371
|
+
try {
|
|
1372
|
+
this._currentChannel = read.more(emitted);
|
|
1373
|
+
} catch (error) {
|
|
1374
|
+
this._currentChannel = read.done.onExit(icons.die(error));
|
|
1375
|
+
}
|
|
1376
|
+
return undefined;
|
|
1377
|
+
}, exit => {
|
|
1378
|
+
const onExit = exit => {
|
|
1379
|
+
return read.done.onExit(exit);
|
|
1380
|
+
};
|
|
1381
|
+
this._currentChannel = onExit(exit);
|
|
1382
|
+
return undefined;
|
|
1383
|
+
});
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
case OP_SUCCEED:
|
|
1387
|
+
{
|
|
1388
|
+
result = this.doneSucceed(this._currentChannel.evaluate());
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
case OP_SUCCEED_NOW:
|
|
1392
|
+
{
|
|
1393
|
+
result = this.doneSucceed(this._currentChannel.terminal);
|
|
1394
|
+
break;
|
|
1395
|
+
}
|
|
1396
|
+
case OP_SUSPEND:
|
|
1397
|
+
{
|
|
1398
|
+
this._currentChannel = this._currentChannel.channel();
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
} catch (error) {
|
|
1404
|
+
this._currentChannel = failCause$2(die(error));
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
return result;
|
|
1409
|
+
}
|
|
1410
|
+
getDone() {
|
|
1411
|
+
return this._done;
|
|
1412
|
+
}
|
|
1413
|
+
getEmit() {
|
|
1414
|
+
return this._emitted;
|
|
1415
|
+
}
|
|
1416
|
+
cancelWith(exit) {
|
|
1417
|
+
this._cancelled = exit;
|
|
1418
|
+
}
|
|
1419
|
+
clearInProgressFinalizer() {
|
|
1420
|
+
this._inProgressFinalizer = undefined;
|
|
1421
|
+
}
|
|
1422
|
+
storeInProgressFinalizer(finalizer) {
|
|
1423
|
+
this._inProgressFinalizer = finalizer;
|
|
1424
|
+
}
|
|
1425
|
+
popAllFinalizers(exit) {
|
|
1426
|
+
const finalizers = [];
|
|
1427
|
+
let next = this._doneStack.pop();
|
|
1428
|
+
while (next) {
|
|
1429
|
+
if (next._tag === "ContinuationFinalizer") {
|
|
1430
|
+
finalizers.push(next.finalizer);
|
|
1431
|
+
}
|
|
1432
|
+
next = this._doneStack.pop();
|
|
1433
|
+
}
|
|
1434
|
+
const effect = finalizers.length === 0 ? assets._void : runFinalizers(finalizers, exit);
|
|
1435
|
+
this.storeInProgressFinalizer(effect);
|
|
1436
|
+
return effect;
|
|
1437
|
+
}
|
|
1438
|
+
popNextFinalizers() {
|
|
1439
|
+
const builder = [];
|
|
1440
|
+
while (this._doneStack.length !== 0) {
|
|
1441
|
+
const cont = this._doneStack[this._doneStack.length - 1];
|
|
1442
|
+
if (cont._tag === OP_CONTINUATION_K) {
|
|
1443
|
+
return builder;
|
|
1444
|
+
}
|
|
1445
|
+
builder.push(cont);
|
|
1446
|
+
this._doneStack.pop();
|
|
1447
|
+
}
|
|
1448
|
+
return builder;
|
|
1449
|
+
}
|
|
1450
|
+
restorePipe(exit, prev) {
|
|
1451
|
+
const currInput = this._input;
|
|
1452
|
+
this._input = prev;
|
|
1453
|
+
if (currInput !== undefined) {
|
|
1454
|
+
const effect = currInput.close(exit);
|
|
1455
|
+
return effect;
|
|
1456
|
+
}
|
|
1457
|
+
return assets._void;
|
|
1458
|
+
}
|
|
1459
|
+
close(exit) {
|
|
1460
|
+
let runInProgressFinalizers = undefined;
|
|
1461
|
+
const finalizer = this._inProgressFinalizer;
|
|
1462
|
+
if (finalizer !== undefined) {
|
|
1463
|
+
runInProgressFinalizers = assets.pipe(finalizer, assets.ensuring(assets.sync$1(() => this.clearInProgressFinalizer())));
|
|
1464
|
+
}
|
|
1465
|
+
let closeSelf = undefined;
|
|
1466
|
+
const selfFinalizers = this.popAllFinalizers(exit);
|
|
1467
|
+
if (selfFinalizers !== undefined) {
|
|
1468
|
+
closeSelf = assets.pipe(selfFinalizers, assets.ensuring(assets.sync$1(() => this.clearInProgressFinalizer())));
|
|
1469
|
+
}
|
|
1470
|
+
const closeSubexecutors = this._activeSubexecutor === undefined ? undefined : this._activeSubexecutor.close(exit);
|
|
1471
|
+
if (closeSubexecutors === undefined && runInProgressFinalizers === undefined && closeSelf === undefined) {
|
|
1472
|
+
return undefined;
|
|
1473
|
+
}
|
|
1474
|
+
return assets.pipe(assets.exit(ifNotNull(closeSubexecutors)), assets.zip(assets.exit(ifNotNull(runInProgressFinalizers))), assets.zip(assets.exit(ifNotNull(closeSelf))), assets.map$2(([[exit1, exit2], exit3]) => assets.pipe(exit1, icons.zipRight(exit2), icons.zipRight(exit3))), assets.uninterruptible$1,
|
|
1475
|
+
// TODO: remove
|
|
1476
|
+
assets.flatMap$1(exit => assets.suspend$1(() => exit)));
|
|
1477
|
+
}
|
|
1478
|
+
doneSucceed(value) {
|
|
1479
|
+
if (this._doneStack.length === 0) {
|
|
1480
|
+
this._done = icons.succeed(value);
|
|
1481
|
+
this._currentChannel = undefined;
|
|
1482
|
+
return Done();
|
|
1483
|
+
}
|
|
1484
|
+
const head = this._doneStack[this._doneStack.length - 1];
|
|
1485
|
+
if (head._tag === OP_CONTINUATION_K) {
|
|
1486
|
+
this._doneStack.pop();
|
|
1487
|
+
this._currentChannel = head.onSuccess(value);
|
|
1488
|
+
return undefined;
|
|
1489
|
+
}
|
|
1490
|
+
const finalizers = this.popNextFinalizers();
|
|
1491
|
+
if (this._doneStack.length === 0) {
|
|
1492
|
+
this._doneStack = finalizers.reverse();
|
|
1493
|
+
this._done = icons.succeed(value);
|
|
1494
|
+
this._currentChannel = undefined;
|
|
1495
|
+
return Done();
|
|
1496
|
+
}
|
|
1497
|
+
const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), icons.succeed(value));
|
|
1498
|
+
this.storeInProgressFinalizer(finalizerEffect);
|
|
1499
|
+
const effect = assets.pipe(finalizerEffect, assets.ensuring(assets.sync$1(() => this.clearInProgressFinalizer())), assets.uninterruptible$1, assets.flatMap$1(() => assets.sync$1(() => this.doneSucceed(value))));
|
|
1500
|
+
return fromEffect$2(effect);
|
|
1501
|
+
}
|
|
1502
|
+
doneHalt(cause) {
|
|
1503
|
+
if (this._doneStack.length === 0) {
|
|
1504
|
+
this._done = icons.failCause(cause);
|
|
1505
|
+
this._currentChannel = undefined;
|
|
1506
|
+
return Done();
|
|
1507
|
+
}
|
|
1508
|
+
const head = this._doneStack[this._doneStack.length - 1];
|
|
1509
|
+
if (head._tag === OP_CONTINUATION_K) {
|
|
1510
|
+
this._doneStack.pop();
|
|
1511
|
+
try {
|
|
1512
|
+
this._currentChannel = head.onHalt(cause);
|
|
1513
|
+
} catch (error) {
|
|
1514
|
+
this._currentChannel = failCause$2(die(error));
|
|
1515
|
+
}
|
|
1516
|
+
return undefined;
|
|
1517
|
+
}
|
|
1518
|
+
const finalizers = this.popNextFinalizers();
|
|
1519
|
+
if (this._doneStack.length === 0) {
|
|
1520
|
+
this._doneStack = finalizers.reverse();
|
|
1521
|
+
this._done = icons.failCause(cause);
|
|
1522
|
+
this._currentChannel = undefined;
|
|
1523
|
+
return Done();
|
|
1524
|
+
}
|
|
1525
|
+
const finalizerEffect = runFinalizers(finalizers.map(f => f.finalizer), icons.failCause(cause));
|
|
1526
|
+
this.storeInProgressFinalizer(finalizerEffect);
|
|
1527
|
+
const effect = assets.pipe(finalizerEffect, assets.ensuring(assets.sync$1(() => this.clearInProgressFinalizer())), assets.uninterruptible$1, assets.flatMap$1(() => assets.sync$1(() => this.doneHalt(cause))));
|
|
1528
|
+
return fromEffect$2(effect);
|
|
1529
|
+
}
|
|
1530
|
+
processCancellation() {
|
|
1531
|
+
this._currentChannel = undefined;
|
|
1532
|
+
this._done = this._cancelled;
|
|
1533
|
+
this._cancelled = undefined;
|
|
1534
|
+
return Done();
|
|
1535
|
+
}
|
|
1536
|
+
runBracketOut(bracketOut) {
|
|
1537
|
+
const effect = assets.uninterruptible$1(assets.matchCauseEffect(this.provide(bracketOut.acquire()), {
|
|
1538
|
+
onFailure: cause => assets.sync$1(() => {
|
|
1539
|
+
this._currentChannel = failCause$2(cause);
|
|
1540
|
+
}),
|
|
1541
|
+
onSuccess: out => assets.sync$1(() => {
|
|
1542
|
+
this.addFinalizer(exit => this.provide(bracketOut.finalizer(out, exit)));
|
|
1543
|
+
this._currentChannel = write(out);
|
|
1544
|
+
})
|
|
1545
|
+
}));
|
|
1546
|
+
return fromEffect$2(effect);
|
|
1547
|
+
}
|
|
1548
|
+
provide(effect) {
|
|
1549
|
+
if (this._providedEnv === undefined) {
|
|
1550
|
+
return effect;
|
|
1551
|
+
}
|
|
1552
|
+
return assets.pipe(effect, assets.provide(this._providedEnv));
|
|
1553
|
+
}
|
|
1554
|
+
runEnsuring(ensuring) {
|
|
1555
|
+
this.addFinalizer(ensuring.finalizer);
|
|
1556
|
+
this._currentChannel = ensuring.channel;
|
|
1557
|
+
}
|
|
1558
|
+
addFinalizer(f) {
|
|
1559
|
+
this._doneStack.push(new ContinuationFinalizerImpl(f));
|
|
1560
|
+
}
|
|
1561
|
+
runSubexecutor() {
|
|
1562
|
+
const subexecutor = this._activeSubexecutor;
|
|
1563
|
+
switch (subexecutor._tag) {
|
|
1564
|
+
case OP_PULL_FROM_CHILD:
|
|
1565
|
+
{
|
|
1566
|
+
return this.pullFromChild(subexecutor.childExecutor, subexecutor.parentSubexecutor, subexecutor.onEmit, subexecutor);
|
|
1567
|
+
}
|
|
1568
|
+
case OP_PULL_FROM_UPSTREAM:
|
|
1569
|
+
{
|
|
1570
|
+
return this.pullFromUpstream(subexecutor);
|
|
1571
|
+
}
|
|
1572
|
+
case OP_DRAIN_CHILD_EXECUTORS:
|
|
1573
|
+
{
|
|
1574
|
+
return this.drainChildExecutors(subexecutor);
|
|
1575
|
+
}
|
|
1576
|
+
case OP_EMIT:
|
|
1577
|
+
{
|
|
1578
|
+
this._emitted = subexecutor.value;
|
|
1579
|
+
this._activeSubexecutor = subexecutor.next;
|
|
1580
|
+
return Emit$1();
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
replaceSubexecutor(nextSubExec) {
|
|
1585
|
+
this._currentChannel = undefined;
|
|
1586
|
+
this._activeSubexecutor = nextSubExec;
|
|
1587
|
+
}
|
|
1588
|
+
finishWithExit(exit) {
|
|
1589
|
+
const state = icons.match(exit, {
|
|
1590
|
+
onFailure: cause => this.doneHalt(cause),
|
|
1591
|
+
onSuccess: value => this.doneSucceed(value)
|
|
1592
|
+
});
|
|
1593
|
+
this._activeSubexecutor = undefined;
|
|
1594
|
+
return state === undefined ? assets._void : effect(state);
|
|
1595
|
+
}
|
|
1596
|
+
finishSubexecutorWithCloseEffect(subexecutorDone, ...closeFuncs) {
|
|
1597
|
+
this.addFinalizer(() => assets.pipe(closeFuncs, assets.forEach(closeFunc => assets.pipe(assets.sync$1(() => closeFunc(subexecutorDone)), assets.flatMap$1(closeEffect => closeEffect !== undefined ? closeEffect : assets._void)), {
|
|
1598
|
+
discard: true
|
|
1599
|
+
})));
|
|
1600
|
+
const state = assets.pipe(subexecutorDone, icons.match({
|
|
1601
|
+
onFailure: cause => this.doneHalt(cause),
|
|
1602
|
+
onSuccess: value => this.doneSucceed(value)
|
|
1603
|
+
}));
|
|
1604
|
+
this._activeSubexecutor = undefined;
|
|
1605
|
+
return state;
|
|
1606
|
+
}
|
|
1607
|
+
applyUpstreamPullStrategy(upstreamFinished, queue, strategy) {
|
|
1608
|
+
switch (strategy._tag) {
|
|
1609
|
+
case OP_PULL_AFTER_NEXT:
|
|
1610
|
+
{
|
|
1611
|
+
const shouldPrepend = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
|
|
1612
|
+
return [strategy.emitSeparator, shouldPrepend ? [undefined, ...queue] : queue];
|
|
1613
|
+
}
|
|
1614
|
+
case OP_PULL_AFTER_ALL_ENQUEUED:
|
|
1615
|
+
{
|
|
1616
|
+
const shouldEnqueue = !upstreamFinished || queue.some(subexecutor => subexecutor !== undefined);
|
|
1617
|
+
return [strategy.emitSeparator, shouldEnqueue ? [...queue, undefined] : queue];
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
pullFromChild(childExecutor, parentSubexecutor, onEmitted, subexecutor) {
|
|
1622
|
+
return Read(childExecutor, assets.identity, emitted => {
|
|
1623
|
+
const childExecutorDecision = onEmitted(emitted);
|
|
1624
|
+
switch (childExecutorDecision._tag) {
|
|
1625
|
+
case OP_CONTINUE:
|
|
1626
|
+
{
|
|
1627
|
+
break;
|
|
1628
|
+
}
|
|
1629
|
+
case OP_CLOSE:
|
|
1630
|
+
{
|
|
1631
|
+
this.finishWithDoneValue(childExecutor, parentSubexecutor, childExecutorDecision.value);
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
case OP_YIELD:
|
|
1635
|
+
{
|
|
1636
|
+
const modifiedParent = parentSubexecutor.enqueuePullFromChild(subexecutor);
|
|
1637
|
+
this.replaceSubexecutor(modifiedParent);
|
|
1638
|
+
break;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
this._activeSubexecutor = new Emit(emitted, this._activeSubexecutor);
|
|
1642
|
+
return undefined;
|
|
1643
|
+
}, icons.match({
|
|
1644
|
+
onFailure: cause => {
|
|
1645
|
+
const state = this.handleSubexecutorFailure(childExecutor, parentSubexecutor, cause);
|
|
1646
|
+
return state === undefined ? undefined : effectOrUndefinedIgnored(state);
|
|
1647
|
+
},
|
|
1648
|
+
onSuccess: doneValue => {
|
|
1649
|
+
this.finishWithDoneValue(childExecutor, parentSubexecutor, doneValue);
|
|
1650
|
+
return undefined;
|
|
1651
|
+
}
|
|
1652
|
+
}));
|
|
1653
|
+
}
|
|
1654
|
+
finishWithDoneValue(childExecutor, parentSubexecutor, doneValue) {
|
|
1655
|
+
const subexecutor = parentSubexecutor;
|
|
1656
|
+
switch (subexecutor._tag) {
|
|
1657
|
+
case OP_PULL_FROM_UPSTREAM:
|
|
1658
|
+
{
|
|
1659
|
+
const modifiedParent = new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
|
|
1660
|
+
this._closeLastSubstream = childExecutor.close(icons.succeed(doneValue));
|
|
1661
|
+
this.replaceSubexecutor(modifiedParent);
|
|
1662
|
+
break;
|
|
1663
|
+
}
|
|
1664
|
+
case OP_DRAIN_CHILD_EXECUTORS:
|
|
1665
|
+
{
|
|
1666
|
+
const modifiedParent = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone !== undefined ? subexecutor.combineChildResults(subexecutor.lastDone, doneValue) : doneValue, subexecutor.activeChildExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
|
|
1667
|
+
this._closeLastSubstream = childExecutor.close(icons.succeed(doneValue));
|
|
1668
|
+
this.replaceSubexecutor(modifiedParent);
|
|
1669
|
+
break;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
handleSubexecutorFailure(childExecutor, parentSubexecutor, cause) {
|
|
1674
|
+
return this.finishSubexecutorWithCloseEffect(icons.failCause(cause), exit => parentSubexecutor.close(exit), exit => childExecutor.close(exit));
|
|
1675
|
+
}
|
|
1676
|
+
pullFromUpstream(subexecutor) {
|
|
1677
|
+
if (subexecutor.activeChildExecutors.length === 0) {
|
|
1678
|
+
return this.performPullFromUpstream(subexecutor);
|
|
1679
|
+
}
|
|
1680
|
+
const activeChild = subexecutor.activeChildExecutors[0];
|
|
1681
|
+
const parentSubexecutor = new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, subexecutor.activeChildExecutors.slice(1), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit);
|
|
1682
|
+
if (activeChild === undefined) {
|
|
1683
|
+
return this.performPullFromUpstream(parentSubexecutor);
|
|
1684
|
+
}
|
|
1685
|
+
this.replaceSubexecutor(new PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
|
|
1686
|
+
return undefined;
|
|
1687
|
+
}
|
|
1688
|
+
performPullFromUpstream(subexecutor) {
|
|
1689
|
+
return Read(subexecutor.upstreamExecutor, effect => {
|
|
1690
|
+
const closeLastSubstream = this._closeLastSubstream === undefined ? assets._void : this._closeLastSubstream;
|
|
1691
|
+
this._closeLastSubstream = undefined;
|
|
1692
|
+
return assets.pipe(this._executeCloseLastSubstream(closeLastSubstream), assets.zipRight$1(effect));
|
|
1693
|
+
}, emitted => {
|
|
1694
|
+
if (this._closeLastSubstream !== undefined) {
|
|
1695
|
+
const closeLastSubstream = this._closeLastSubstream;
|
|
1696
|
+
this._closeLastSubstream = undefined;
|
|
1697
|
+
return assets.pipe(this._executeCloseLastSubstream(closeLastSubstream), assets.map$2(() => {
|
|
1698
|
+
const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
|
|
1699
|
+
childExecutor._input = this._input;
|
|
1700
|
+
const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(Pulled(emitted)));
|
|
1701
|
+
this._activeSubexecutor = new PullFromChild(childExecutor, new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
|
|
1702
|
+
if (assets.isSome(emitSeparator)) {
|
|
1703
|
+
this._activeSubexecutor = new Emit(emitSeparator.value, this._activeSubexecutor);
|
|
1704
|
+
}
|
|
1705
|
+
return undefined;
|
|
1706
|
+
}));
|
|
1707
|
+
}
|
|
1708
|
+
const childExecutor = new ChannelExecutor(subexecutor.createChild(emitted), this._providedEnv, this._executeCloseLastSubstream);
|
|
1709
|
+
childExecutor._input = this._input;
|
|
1710
|
+
const [emitSeparator, updatedChildExecutors] = this.applyUpstreamPullStrategy(false, subexecutor.activeChildExecutors, subexecutor.onPull(Pulled(emitted)));
|
|
1711
|
+
this._activeSubexecutor = new PullFromChild(childExecutor, new PullFromUpstream(subexecutor.upstreamExecutor, subexecutor.createChild, subexecutor.lastDone, updatedChildExecutors, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull, subexecutor.onEmit), subexecutor.onEmit);
|
|
1712
|
+
if (assets.isSome(emitSeparator)) {
|
|
1713
|
+
this._activeSubexecutor = new Emit(emitSeparator.value, this._activeSubexecutor);
|
|
1714
|
+
}
|
|
1715
|
+
return undefined;
|
|
1716
|
+
}, exit => {
|
|
1717
|
+
if (subexecutor.activeChildExecutors.some(subexecutor => subexecutor !== undefined)) {
|
|
1718
|
+
const drain = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, [undefined, ...subexecutor.activeChildExecutors], subexecutor.upstreamExecutor.getDone(), subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
|
|
1719
|
+
if (this._closeLastSubstream !== undefined) {
|
|
1720
|
+
const closeLastSubstream = this._closeLastSubstream;
|
|
1721
|
+
this._closeLastSubstream = undefined;
|
|
1722
|
+
return assets.pipe(this._executeCloseLastSubstream(closeLastSubstream), assets.map$2(() => this.replaceSubexecutor(drain)));
|
|
1723
|
+
}
|
|
1724
|
+
this.replaceSubexecutor(drain);
|
|
1725
|
+
return undefined;
|
|
1726
|
+
}
|
|
1727
|
+
const closeLastSubstream = this._closeLastSubstream;
|
|
1728
|
+
const state = this.finishSubexecutorWithCloseEffect(assets.pipe(exit, icons.map(a => subexecutor.combineWithChildResult(subexecutor.lastDone, a))), () => closeLastSubstream, exit => subexecutor.upstreamExecutor.close(exit));
|
|
1729
|
+
return state === undefined ? undefined :
|
|
1730
|
+
// NOTE: assuming finalizers cannot fail
|
|
1731
|
+
effectOrUndefinedIgnored(state);
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
drainChildExecutors(subexecutor) {
|
|
1735
|
+
if (subexecutor.activeChildExecutors.length === 0) {
|
|
1736
|
+
const lastClose = this._closeLastSubstream;
|
|
1737
|
+
if (lastClose !== undefined) {
|
|
1738
|
+
this.addFinalizer(() => assets.succeed$1(lastClose));
|
|
1739
|
+
}
|
|
1740
|
+
return this.finishSubexecutorWithCloseEffect(subexecutor.upstreamDone, () => lastClose, exit => subexecutor.upstreamExecutor.close(exit));
|
|
1741
|
+
}
|
|
1742
|
+
const activeChild = subexecutor.activeChildExecutors[0];
|
|
1743
|
+
const rest = subexecutor.activeChildExecutors.slice(1);
|
|
1744
|
+
if (activeChild === undefined) {
|
|
1745
|
+
const [emitSeparator, remainingExecutors] = this.applyUpstreamPullStrategy(true, rest, subexecutor.onPull(NoUpstream(rest.reduce((n, curr) => curr !== undefined ? n + 1 : n, 0))));
|
|
1746
|
+
this.replaceSubexecutor(new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, remainingExecutors, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull));
|
|
1747
|
+
if (assets.isSome(emitSeparator)) {
|
|
1748
|
+
this._emitted = emitSeparator.value;
|
|
1749
|
+
return Emit$1();
|
|
1750
|
+
}
|
|
1751
|
+
return undefined;
|
|
1752
|
+
}
|
|
1753
|
+
const parentSubexecutor = new DrainChildExecutors(subexecutor.upstreamExecutor, subexecutor.lastDone, rest, subexecutor.upstreamDone, subexecutor.combineChildResults, subexecutor.combineWithChildResult, subexecutor.onPull);
|
|
1754
|
+
this.replaceSubexecutor(new PullFromChild(activeChild.childExecutor, parentSubexecutor, activeChild.onEmit));
|
|
1755
|
+
return undefined;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
const ifNotNull = effect => effect !== undefined ? effect : assets._void;
|
|
1759
|
+
const runFinalizers = (finalizers, exit) => {
|
|
1760
|
+
return assets.pipe(assets.forEach(finalizers, fin => assets.exit(fin(exit))), assets.map$2(exits => assets.pipe(icons.all(exits), assets.getOrElse(() => icons.void_))), assets.flatMap$1(exit => assets.suspend$1(() => exit)));
|
|
1761
|
+
};
|
|
1762
|
+
/**
|
|
1763
|
+
* @internal
|
|
1764
|
+
*/
|
|
1765
|
+
const readUpstream = (r, onSuccess, onFailure) => {
|
|
1766
|
+
const readStack = [r];
|
|
1767
|
+
const read = () => {
|
|
1768
|
+
const current = readStack.pop();
|
|
1769
|
+
if (current === undefined || current.upstream === undefined) {
|
|
1770
|
+
return assets.dieMessage("Unexpected end of input for channel execution");
|
|
1771
|
+
}
|
|
1772
|
+
const state = current.upstream.run();
|
|
1773
|
+
switch (state._tag) {
|
|
1774
|
+
case OP_EMIT$1:
|
|
1775
|
+
{
|
|
1776
|
+
const emitEffect = current.onEmit(current.upstream.getEmit());
|
|
1777
|
+
if (readStack.length === 0) {
|
|
1778
|
+
if (emitEffect === undefined) {
|
|
1779
|
+
return assets.suspend$1(onSuccess);
|
|
1780
|
+
}
|
|
1781
|
+
return assets.pipe(emitEffect, assets.matchCauseEffect({
|
|
1782
|
+
onFailure,
|
|
1783
|
+
onSuccess
|
|
1784
|
+
}));
|
|
1785
|
+
}
|
|
1786
|
+
if (emitEffect === undefined) {
|
|
1787
|
+
return assets.suspend$1(() => read());
|
|
1788
|
+
}
|
|
1789
|
+
return assets.pipe(emitEffect, assets.matchCauseEffect({
|
|
1790
|
+
onFailure,
|
|
1791
|
+
onSuccess: () => read()
|
|
1792
|
+
}));
|
|
1793
|
+
}
|
|
1794
|
+
case OP_DONE$1:
|
|
1795
|
+
{
|
|
1796
|
+
const doneEffect = current.onDone(current.upstream.getDone());
|
|
1797
|
+
if (readStack.length === 0) {
|
|
1798
|
+
if (doneEffect === undefined) {
|
|
1799
|
+
return assets.suspend$1(onSuccess);
|
|
1800
|
+
}
|
|
1801
|
+
return assets.pipe(doneEffect, assets.matchCauseEffect({
|
|
1802
|
+
onFailure,
|
|
1803
|
+
onSuccess
|
|
1804
|
+
}));
|
|
1805
|
+
}
|
|
1806
|
+
if (doneEffect === undefined) {
|
|
1807
|
+
return assets.suspend$1(() => read());
|
|
1808
|
+
}
|
|
1809
|
+
return assets.pipe(doneEffect, assets.matchCauseEffect({
|
|
1810
|
+
onFailure,
|
|
1811
|
+
onSuccess: () => read()
|
|
1812
|
+
}));
|
|
1813
|
+
}
|
|
1814
|
+
case OP_FROM_EFFECT:
|
|
1815
|
+
{
|
|
1816
|
+
readStack.push(current);
|
|
1817
|
+
return assets.pipe(current.onEffect(state.effect), assets.catchAllCause(cause => assets.suspend$1(() => {
|
|
1818
|
+
const doneEffect = current.onDone(icons.failCause(cause));
|
|
1819
|
+
return doneEffect === undefined ? assets._void : doneEffect;
|
|
1820
|
+
})), assets.matchCauseEffect({
|
|
1821
|
+
onFailure,
|
|
1822
|
+
onSuccess: () => read()
|
|
1823
|
+
}));
|
|
1824
|
+
}
|
|
1825
|
+
case OP_READ:
|
|
1826
|
+
{
|
|
1827
|
+
readStack.push(current);
|
|
1828
|
+
readStack.push(state);
|
|
1829
|
+
return assets.suspend$1(() => read());
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
return read();
|
|
1834
|
+
};
|
|
1835
|
+
/** @internal */
|
|
1836
|
+
const runIn = /*#__PURE__*/assets.dual(2, (self, scope) => {
|
|
1837
|
+
const run = (channelDeferred, scopeDeferred, scope) => assets.acquireUseRelease(assets.sync$1(() => new ChannelExecutor(self, void 0, assets.identity)), exec => assets.suspend$1(() => runScopedInterpret(exec.run(), exec).pipe(assets.intoDeferred(channelDeferred), assets.zipRight$1(icons._await(channelDeferred)), assets.zipLeft(icons._await(scopeDeferred)))), (exec, exit) => {
|
|
1838
|
+
const finalize = exec.close(exit);
|
|
1839
|
+
if (finalize === undefined) {
|
|
1840
|
+
return assets._void;
|
|
1841
|
+
}
|
|
1842
|
+
return assets.tapErrorCause(finalize, cause => assets.addFinalizer(scope, assets.failCause(cause)));
|
|
1843
|
+
});
|
|
1844
|
+
return assets.uninterruptibleMask(restore => assets.all([assets.fork(scope, assets.sequential), icons.make(), icons.make()]).pipe(assets.flatMap$1(([child, channelDeferred, scopeDeferred]) => restore(run(channelDeferred, scopeDeferred, child)).pipe(assets.forkIn(scope), assets.flatMap$1(fiber => scope.addFinalizer(exit => {
|
|
1845
|
+
const interruptors$1 = icons.isFailure(exit) ? interruptors(exit.cause) : undefined;
|
|
1846
|
+
return icons.isDone(channelDeferred).pipe(assets.flatMap$1(isDone => isDone ? icons.succeed$1(scopeDeferred, void 0).pipe(assets.zipRight$1(_await(fiber)), assets.zipRight$1(inheritAll(fiber))) : icons.succeed$1(scopeDeferred, void 0).pipe(assets.zipRight$1(interruptors$1 && assets.size(interruptors$1) > 0 ? interruptAs(fiber, assets.combineAll(interruptors$1)) : interrupt(fiber)), assets.zipRight$1(inheritAll(fiber)))));
|
|
1847
|
+
}).pipe(assets.zipRight$1(restore(icons._await(channelDeferred)))))))));
|
|
1848
|
+
});
|
|
1849
|
+
/** @internal */
|
|
1850
|
+
const runScopedInterpret = (channelState, exec) => {
|
|
1851
|
+
const op = channelState;
|
|
1852
|
+
switch (op._tag) {
|
|
1853
|
+
case OP_FROM_EFFECT:
|
|
1854
|
+
{
|
|
1855
|
+
return assets.pipe(op.effect, assets.flatMap$1(() => runScopedInterpret(exec.run(), exec)));
|
|
1856
|
+
}
|
|
1857
|
+
case OP_EMIT$1:
|
|
1858
|
+
{
|
|
1859
|
+
// Can't really happen because Out <:< Nothing. So just skip ahead.
|
|
1860
|
+
return runScopedInterpret(exec.run(), exec);
|
|
1861
|
+
}
|
|
1862
|
+
case OP_DONE$1:
|
|
1863
|
+
{
|
|
1864
|
+
return assets.suspend$1(() => exec.getDone());
|
|
1865
|
+
}
|
|
1866
|
+
case OP_READ:
|
|
1867
|
+
{
|
|
1868
|
+
return readUpstream(op, () => runScopedInterpret(exec.run(), exec), assets.failCause);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
|
|
1873
|
+
/** @internal */
|
|
1874
|
+
const OP_DONE = "Done";
|
|
1875
|
+
/** @internal */
|
|
1876
|
+
const OP_AWAIT = "Await";
|
|
1877
|
+
|
|
1878
|
+
/** @internal */
|
|
1879
|
+
const MergeDecisionSymbolKey = "effect/ChannelMergeDecision";
|
|
1880
|
+
/** @internal */
|
|
1881
|
+
const MergeDecisionTypeId = /*#__PURE__*/Symbol.for(MergeDecisionSymbolKey);
|
|
1882
|
+
/** @internal */
|
|
1883
|
+
const proto$2 = {
|
|
1884
|
+
[MergeDecisionTypeId]: {
|
|
1885
|
+
_R: _ => _,
|
|
1886
|
+
_E0: _ => _,
|
|
1887
|
+
_Z0: _ => _,
|
|
1888
|
+
_E: _ => _,
|
|
1889
|
+
_Z: _ => _
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
/** @internal */
|
|
1893
|
+
const Await = f => {
|
|
1894
|
+
const op = Object.create(proto$2);
|
|
1895
|
+
op._tag = OP_AWAIT;
|
|
1896
|
+
op.f = f;
|
|
1897
|
+
return op;
|
|
1898
|
+
};
|
|
1899
|
+
|
|
1900
|
+
/** @internal */
|
|
1901
|
+
const OP_BOTH_RUNNING = "BothRunning";
|
|
1902
|
+
/** @internal */
|
|
1903
|
+
const OP_LEFT_DONE = "LeftDone";
|
|
1904
|
+
/** @internal */
|
|
1905
|
+
const OP_RIGHT_DONE = "RightDone";
|
|
1906
|
+
|
|
1907
|
+
/** @internal */
|
|
1908
|
+
const MergeStateSymbolKey = "effect/ChannelMergeState";
|
|
1909
|
+
/** @internal */
|
|
1910
|
+
const MergeStateTypeId = /*#__PURE__*/Symbol.for(MergeStateSymbolKey);
|
|
1911
|
+
/** @internal */
|
|
1912
|
+
const proto$1 = {
|
|
1913
|
+
[MergeStateTypeId]: MergeStateTypeId
|
|
1914
|
+
};
|
|
1915
|
+
/** @internal */
|
|
1916
|
+
const BothRunning = (left, right) => {
|
|
1917
|
+
const op = Object.create(proto$1);
|
|
1918
|
+
op._tag = OP_BOTH_RUNNING;
|
|
1919
|
+
op.left = left;
|
|
1920
|
+
op.right = right;
|
|
1921
|
+
return op;
|
|
1922
|
+
};
|
|
1923
|
+
/** @internal */
|
|
1924
|
+
const LeftDone = f => {
|
|
1925
|
+
const op = Object.create(proto$1);
|
|
1926
|
+
op._tag = OP_LEFT_DONE;
|
|
1927
|
+
op.f = f;
|
|
1928
|
+
return op;
|
|
1929
|
+
};
|
|
1930
|
+
/** @internal */
|
|
1931
|
+
const RightDone = f => {
|
|
1932
|
+
const op = Object.create(proto$1);
|
|
1933
|
+
op._tag = OP_RIGHT_DONE;
|
|
1934
|
+
op.f = f;
|
|
1935
|
+
return op;
|
|
1936
|
+
};
|
|
1937
|
+
|
|
1938
|
+
/** @internal */
|
|
1939
|
+
const OP_BACK_PRESSURE = "BackPressure";
|
|
1940
|
+
/** @internal */
|
|
1941
|
+
const OP_BUFFER_SLIDING = "BufferSliding";
|
|
1942
|
+
|
|
1943
|
+
/** @internal */
|
|
1944
|
+
const MergeStrategySymbolKey = "effect/ChannelMergeStrategy";
|
|
1945
|
+
/** @internal */
|
|
1946
|
+
const MergeStrategyTypeId = /*#__PURE__*/Symbol.for(MergeStrategySymbolKey);
|
|
1947
|
+
/** @internal */
|
|
1948
|
+
const proto = {
|
|
1949
|
+
[MergeStrategyTypeId]: MergeStrategyTypeId
|
|
1950
|
+
};
|
|
1951
|
+
/** @internal */
|
|
1952
|
+
const BackPressure = _ => {
|
|
1953
|
+
const op = Object.create(proto);
|
|
1954
|
+
op._tag = OP_BACK_PRESSURE;
|
|
1955
|
+
return op;
|
|
1956
|
+
};
|
|
1957
|
+
/** @internal */
|
|
1958
|
+
const BufferSliding = _ => {
|
|
1959
|
+
const op = Object.create(proto);
|
|
1960
|
+
op._tag = OP_BUFFER_SLIDING;
|
|
1961
|
+
return op;
|
|
1962
|
+
};
|
|
1963
|
+
/** @internal */
|
|
1964
|
+
const match = /*#__PURE__*/assets.dual(2, (self, {
|
|
1965
|
+
onBackPressure,
|
|
1966
|
+
onBufferSliding
|
|
1967
|
+
}) => {
|
|
1968
|
+
switch (self._tag) {
|
|
1969
|
+
case OP_BACK_PRESSURE:
|
|
1970
|
+
{
|
|
1971
|
+
return onBackPressure();
|
|
1972
|
+
}
|
|
1973
|
+
case OP_BUFFER_SLIDING:
|
|
1974
|
+
{
|
|
1975
|
+
return onBufferSliding();
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
|
|
1980
|
+
/** @internal */
|
|
1981
|
+
const OP_STATE_EMPTY = "Empty";
|
|
1982
|
+
/** @internal */
|
|
1983
|
+
const OP_STATE_EMIT = "Emit";
|
|
1984
|
+
/** @internal */
|
|
1985
|
+
const OP_STATE_ERROR = "Error";
|
|
1986
|
+
/** @internal */
|
|
1987
|
+
const OP_STATE_DONE = "Done";
|
|
1988
|
+
/** @internal */
|
|
1989
|
+
const stateEmpty = notifyProducer => ({
|
|
1990
|
+
_tag: OP_STATE_EMPTY,
|
|
1991
|
+
notifyProducer
|
|
1992
|
+
});
|
|
1993
|
+
/** @internal */
|
|
1994
|
+
const stateEmit = notifyConsumers => ({
|
|
1995
|
+
_tag: OP_STATE_EMIT,
|
|
1996
|
+
notifyConsumers
|
|
1997
|
+
});
|
|
1998
|
+
/** @internal */
|
|
1999
|
+
const stateError = cause => ({
|
|
2000
|
+
_tag: OP_STATE_ERROR,
|
|
2001
|
+
cause
|
|
2002
|
+
});
|
|
2003
|
+
/** @internal */
|
|
2004
|
+
const stateDone = done => ({
|
|
2005
|
+
_tag: OP_STATE_DONE,
|
|
2006
|
+
done
|
|
2007
|
+
});
|
|
2008
|
+
/** @internal */
|
|
2009
|
+
class SingleProducerAsyncInputImpl {
|
|
2010
|
+
ref;
|
|
2011
|
+
constructor(ref) {
|
|
2012
|
+
this.ref = ref;
|
|
2013
|
+
}
|
|
2014
|
+
awaitRead() {
|
|
2015
|
+
return assets.flatten(modify(this.ref, state => state._tag === OP_STATE_EMPTY ? [icons._await(state.notifyProducer), state] : [assets._void, state]));
|
|
2016
|
+
}
|
|
2017
|
+
get close() {
|
|
2018
|
+
return assets.fiberIdWith(fiberId => this.error(interrupt$1(fiberId)));
|
|
2019
|
+
}
|
|
2020
|
+
done(value) {
|
|
2021
|
+
return assets.flatten(modify(this.ref, state => {
|
|
2022
|
+
switch (state._tag) {
|
|
2023
|
+
case OP_STATE_EMPTY:
|
|
2024
|
+
{
|
|
2025
|
+
return [icons._await(state.notifyProducer), state];
|
|
2026
|
+
}
|
|
2027
|
+
case OP_STATE_EMIT:
|
|
2028
|
+
{
|
|
2029
|
+
return [assets.forEach(state.notifyConsumers, deferred => icons.succeed$1(deferred, assets.left(value)), {
|
|
2030
|
+
discard: true
|
|
2031
|
+
}), stateDone(value)];
|
|
2032
|
+
}
|
|
2033
|
+
case OP_STATE_ERROR:
|
|
2034
|
+
{
|
|
2035
|
+
return [assets.interrupt$2, state];
|
|
2036
|
+
}
|
|
2037
|
+
case OP_STATE_DONE:
|
|
2038
|
+
{
|
|
2039
|
+
return [assets.interrupt$2, state];
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
}));
|
|
2043
|
+
}
|
|
2044
|
+
emit(element) {
|
|
2045
|
+
return assets.flatMap$1(icons.make(), deferred => assets.flatten(modify(this.ref, state => {
|
|
2046
|
+
switch (state._tag) {
|
|
2047
|
+
case OP_STATE_EMPTY:
|
|
2048
|
+
{
|
|
2049
|
+
return [icons._await(state.notifyProducer), state];
|
|
2050
|
+
}
|
|
2051
|
+
case OP_STATE_EMIT:
|
|
2052
|
+
{
|
|
2053
|
+
const notifyConsumer = state.notifyConsumers[0];
|
|
2054
|
+
const notifyConsumers = state.notifyConsumers.slice(1);
|
|
2055
|
+
if (notifyConsumer !== undefined) {
|
|
2056
|
+
return [icons.succeed$1(notifyConsumer, assets.right(element)), notifyConsumers.length === 0 ? stateEmpty(deferred) : stateEmit(notifyConsumers)];
|
|
2057
|
+
}
|
|
2058
|
+
throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues");
|
|
2059
|
+
}
|
|
2060
|
+
case OP_STATE_ERROR:
|
|
2061
|
+
{
|
|
2062
|
+
return [assets.interrupt$2, state];
|
|
2063
|
+
}
|
|
2064
|
+
case OP_STATE_DONE:
|
|
2065
|
+
{
|
|
2066
|
+
return [assets.interrupt$2, state];
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
})));
|
|
2070
|
+
}
|
|
2071
|
+
error(cause) {
|
|
2072
|
+
return assets.flatten(modify(this.ref, state => {
|
|
2073
|
+
switch (state._tag) {
|
|
2074
|
+
case OP_STATE_EMPTY:
|
|
2075
|
+
{
|
|
2076
|
+
return [icons._await(state.notifyProducer), state];
|
|
2077
|
+
}
|
|
2078
|
+
case OP_STATE_EMIT:
|
|
2079
|
+
{
|
|
2080
|
+
return [assets.forEach(state.notifyConsumers, deferred => icons.failCause$1(deferred, cause), {
|
|
2081
|
+
discard: true
|
|
2082
|
+
}), stateError(cause)];
|
|
2083
|
+
}
|
|
2084
|
+
case OP_STATE_ERROR:
|
|
2085
|
+
{
|
|
2086
|
+
return [assets.interrupt$2, state];
|
|
2087
|
+
}
|
|
2088
|
+
case OP_STATE_DONE:
|
|
2089
|
+
{
|
|
2090
|
+
return [assets.interrupt$2, state];
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
}));
|
|
2094
|
+
}
|
|
2095
|
+
get take() {
|
|
2096
|
+
return this.takeWith(cause => icons.failCause(map$2(cause, assets.left)), elem => icons.succeed(elem), done => icons.fail(assets.right(done)));
|
|
2097
|
+
}
|
|
2098
|
+
takeWith(onError, onElement, onDone) {
|
|
2099
|
+
return assets.flatMap$1(icons.make(), deferred => assets.flatten(modify(this.ref, state => {
|
|
2100
|
+
switch (state._tag) {
|
|
2101
|
+
case OP_STATE_EMPTY:
|
|
2102
|
+
{
|
|
2103
|
+
return [assets.zipRight$1(icons.succeed$1(state.notifyProducer, void 0), assets.matchCause(icons._await(deferred), {
|
|
2104
|
+
onFailure: onError,
|
|
2105
|
+
onSuccess: assets.match({
|
|
2106
|
+
onLeft: onDone,
|
|
2107
|
+
onRight: onElement
|
|
2108
|
+
})
|
|
2109
|
+
})), stateEmit([deferred])];
|
|
2110
|
+
}
|
|
2111
|
+
case OP_STATE_EMIT:
|
|
2112
|
+
{
|
|
2113
|
+
return [assets.matchCause(icons._await(deferred), {
|
|
2114
|
+
onFailure: onError,
|
|
2115
|
+
onSuccess: assets.match({
|
|
2116
|
+
onLeft: onDone,
|
|
2117
|
+
onRight: onElement
|
|
2118
|
+
})
|
|
2119
|
+
}), stateEmit([...state.notifyConsumers, deferred])];
|
|
2120
|
+
}
|
|
2121
|
+
case OP_STATE_ERROR:
|
|
2122
|
+
{
|
|
2123
|
+
return [assets.succeed$1(onError(state.cause)), state];
|
|
2124
|
+
}
|
|
2125
|
+
case OP_STATE_DONE:
|
|
2126
|
+
{
|
|
2127
|
+
return [assets.succeed$1(onDone(state.done)), state];
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
})));
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
/** @internal */
|
|
2134
|
+
const make$1 = () => assets.pipe(icons.make(), assets.flatMap$1(deferred => make$3(stateEmpty(deferred))), assets.map$2(ref => new SingleProducerAsyncInputImpl(ref)));
|
|
2135
|
+
|
|
2136
|
+
/** @internal */
|
|
2137
|
+
const concatMap = /*#__PURE__*/assets.dual(2, (self, f) => concatMapWith(self, f, () => void 0, () => void 0));
|
|
2138
|
+
/** @internal */
|
|
2139
|
+
const drain$1 = self => {
|
|
2140
|
+
const drainer = readWithCause({
|
|
2141
|
+
onInput: () => drainer,
|
|
2142
|
+
onFailure: failCause$2,
|
|
2143
|
+
onDone: succeed
|
|
2144
|
+
});
|
|
2145
|
+
return pipeTo(self, drainer);
|
|
2146
|
+
};
|
|
2147
|
+
/** @internal */
|
|
2148
|
+
const ensuring$1 = /*#__PURE__*/assets.dual(2, (self, finalizer) => ensuringWith(self, () => finalizer));
|
|
2149
|
+
/** @internal */
|
|
2150
|
+
const flatten$1 = self => flatMap$1(self, assets.identity);
|
|
2151
|
+
/** @internal */
|
|
2152
|
+
const fromInput = input => unwrap(input.takeWith(failCause$2, elem => flatMap$1(write(elem), () => fromInput(input)), succeed));
|
|
2153
|
+
/** @internal */
|
|
2154
|
+
const identityChannel = () => readWith({
|
|
2155
|
+
onInput: input => flatMap$1(write(input), () => identityChannel()),
|
|
2156
|
+
onFailure: fail,
|
|
2157
|
+
onDone: succeedNow
|
|
2158
|
+
});
|
|
2159
|
+
/** @internal */
|
|
2160
|
+
const map$1 = /*#__PURE__*/assets.dual(2, (self, f) => flatMap$1(self, a => sync(() => f(a))));
|
|
2161
|
+
/** @internal */
|
|
2162
|
+
const mapOut = /*#__PURE__*/assets.dual(2, (self, f) => {
|
|
2163
|
+
const reader = readWith({
|
|
2164
|
+
onInput: outElem => flatMap$1(write(f(outElem)), () => reader),
|
|
2165
|
+
onFailure: fail,
|
|
2166
|
+
onDone: succeedNow
|
|
2167
|
+
});
|
|
2168
|
+
return pipeTo(self, reader);
|
|
2169
|
+
});
|
|
2170
|
+
/** @internal */
|
|
2171
|
+
const mapOutEffectPar = /*#__PURE__*/assets.dual(3, (self, f, n) => unwrapScopedWith$1(scope => assets.gen(function* () {
|
|
2172
|
+
const input = yield* make$1();
|
|
2173
|
+
const queueReader = fromInput(input);
|
|
2174
|
+
const queue = yield* bounded(n);
|
|
2175
|
+
yield* assets.addFinalizer(scope, shutdown(queue));
|
|
2176
|
+
const errorSignal = yield* icons.make();
|
|
2177
|
+
const withPermits = n === Number.POSITIVE_INFINITY ? _ => assets.identity : (yield* assets.makeSemaphore(n)).withPermits;
|
|
2178
|
+
const pull = yield* queueReader.pipe(pipeTo(self), toPullIn(scope));
|
|
2179
|
+
yield* pull.pipe(assets.matchCauseEffect({
|
|
2180
|
+
onFailure: cause => offer(queue, assets.failCause(cause)),
|
|
2181
|
+
onSuccess: assets.match({
|
|
2182
|
+
onLeft: outDone => assets.zipRight$1(assets.interruptible(withPermits(n)(assets._void)), assets.asVoid$1(offer(queue, assets.succeed$1(assets.left(outDone))))),
|
|
2183
|
+
onRight: outElem => assets.gen(function* () {
|
|
2184
|
+
const deferred = yield* icons.make();
|
|
2185
|
+
const latch = yield* icons.make();
|
|
2186
|
+
yield* offer(queue, assets.map$2(icons._await(deferred), assets.right));
|
|
2187
|
+
yield* icons.succeed$1(latch, void 0).pipe(assets.zipRight$1(assets.uninterruptibleMask(restore => assets.exit(restore(icons._await(errorSignal))).pipe(assets.raceFirst(assets.exit(restore(f(outElem)))), assets.flatMap$1(assets.identity))).pipe(assets.tapErrorCause(cause => icons.failCause$1(errorSignal, cause)), assets.intoDeferred(deferred))), withPermits(1), assets.forkIn(scope));
|
|
2188
|
+
yield* icons._await(latch);
|
|
2189
|
+
})
|
|
2190
|
+
})
|
|
2191
|
+
}), assets.forever, assets.interruptible, assets.forkIn(scope));
|
|
2192
|
+
const consumer = unwrap(assets.matchCause(assets.flatten(take(queue)), {
|
|
2193
|
+
onFailure: failCause$2,
|
|
2194
|
+
onSuccess: assets.match({
|
|
2195
|
+
onLeft: succeedNow,
|
|
2196
|
+
onRight: outElem => flatMap$1(write(outElem), () => consumer)
|
|
2197
|
+
})
|
|
2198
|
+
}));
|
|
2199
|
+
return embedInput(consumer, input);
|
|
2200
|
+
})));
|
|
2201
|
+
/** @internal */
|
|
2202
|
+
const mergeAll = options => {
|
|
2203
|
+
return channels => mergeAllWith(options)(channels, assets.constVoid);
|
|
2204
|
+
};
|
|
2205
|
+
/** @internal */
|
|
2206
|
+
const mergeAllWith = ({
|
|
2207
|
+
bufferSize = 16,
|
|
2208
|
+
concurrency,
|
|
2209
|
+
mergeStrategy = BackPressure()
|
|
2210
|
+
}) => (channels, f) => unwrapScopedWith$1(scope => assets.gen(function* () {
|
|
2211
|
+
const concurrencyN = concurrency === "unbounded" ? Number.MAX_SAFE_INTEGER : concurrency;
|
|
2212
|
+
const input = yield* make$1();
|
|
2213
|
+
const queueReader = fromInput(input);
|
|
2214
|
+
const queue = yield* bounded(bufferSize);
|
|
2215
|
+
yield* assets.addFinalizer(scope, shutdown(queue));
|
|
2216
|
+
const cancelers = yield* unbounded();
|
|
2217
|
+
yield* assets.addFinalizer(scope, shutdown(cancelers));
|
|
2218
|
+
const lastDone = yield* make$3(assets.none());
|
|
2219
|
+
const errorSignal = yield* icons.make();
|
|
2220
|
+
const withPermits = (yield* assets.makeSemaphore(concurrencyN)).withPermits;
|
|
2221
|
+
const pull = yield* toPullIn(pipeTo(queueReader, channels), scope);
|
|
2222
|
+
function evaluatePull(pull) {
|
|
2223
|
+
return pull.pipe(assets.flatMap$1(assets.match({
|
|
2224
|
+
onLeft: done => assets.succeed$1(assets.some(done)),
|
|
2225
|
+
onRight: outElem => assets.as(offer(queue, assets.succeed$1(assets.right(outElem))), assets.none())
|
|
2226
|
+
})), assets.repeat({
|
|
2227
|
+
until: _ => assets.isSome(_)
|
|
2228
|
+
}), assets.flatMap$1(outDone => update(lastDone, assets.match$1({
|
|
2229
|
+
onNone: () => assets.some(outDone.value),
|
|
2230
|
+
onSome: lastDone => assets.some(f(lastDone, outDone.value))
|
|
2231
|
+
}))), assets.catchAllCause(cause => isInterrupted(cause) ? assets.failCause(cause) : offer(queue, assets.failCause(cause)).pipe(assets.zipRight$1(icons.succeed$1(errorSignal, void 0)), assets.asVoid$1)));
|
|
2232
|
+
}
|
|
2233
|
+
yield* pull.pipe(assets.matchCauseEffect({
|
|
2234
|
+
onFailure: cause => offer(queue, assets.failCause(cause)).pipe(assets.zipRight$1(assets.succeed$1(false))),
|
|
2235
|
+
onSuccess: assets.match({
|
|
2236
|
+
onLeft: outDone => assets.raceWith(assets.interruptible(icons._await(errorSignal)), assets.interruptible(withPermits(concurrencyN)(assets._void)), {
|
|
2237
|
+
onSelfDone: (_, permitAcquisition) => assets.as(interrupt(permitAcquisition), false),
|
|
2238
|
+
onOtherDone: (_, failureAwait) => assets.zipRight$1(interrupt(failureAwait), get(lastDone).pipe(assets.flatMap$1(assets.match$1({
|
|
2239
|
+
onNone: () => offer(queue, assets.succeed$1(assets.left(outDone))),
|
|
2240
|
+
onSome: lastDone => offer(queue, assets.succeed$1(assets.left(f(lastDone, outDone))))
|
|
2241
|
+
})), assets.as(false)))
|
|
2242
|
+
}),
|
|
2243
|
+
onRight: channel => match(mergeStrategy, {
|
|
2244
|
+
onBackPressure: () => assets.gen(function* () {
|
|
2245
|
+
const latch = yield* icons.make();
|
|
2246
|
+
const raceEffects = assets.scopedWith(scope => toPullIn(pipeTo(queueReader, channel), scope).pipe(assets.flatMap$1(pull => assets.race(assets.exit(evaluatePull(pull)), assets.exit(assets.interruptible(icons._await(errorSignal))))), assets.flatMap$1(assets.identity)));
|
|
2247
|
+
yield* icons.succeed$1(latch, void 0).pipe(assets.zipRight$1(raceEffects), withPermits(1), assets.forkIn(scope));
|
|
2248
|
+
yield* icons._await(latch);
|
|
2249
|
+
const errored = yield* icons.isDone(errorSignal);
|
|
2250
|
+
return !errored;
|
|
2251
|
+
}),
|
|
2252
|
+
onBufferSliding: () => assets.gen(function* () {
|
|
2253
|
+
const canceler = yield* icons.make();
|
|
2254
|
+
const latch = yield* icons.make();
|
|
2255
|
+
const size$1 = yield* size(cancelers);
|
|
2256
|
+
yield* take(cancelers).pipe(assets.flatMap$1(canceler => icons.succeed$1(canceler, void 0)), assets.when(() => size$1 >= concurrencyN));
|
|
2257
|
+
yield* offer(cancelers, canceler);
|
|
2258
|
+
const raceEffects = assets.scopedWith(scope => toPullIn(pipeTo(queueReader, channel), scope).pipe(assets.flatMap$1(pull => assets.exit(evaluatePull(pull)).pipe(assets.race(assets.exit(assets.interruptible(icons._await(errorSignal)))), assets.race(assets.exit(assets.interruptible(icons._await(canceler)))))), assets.flatMap$1(assets.identity)));
|
|
2259
|
+
yield* icons.succeed$1(latch, void 0).pipe(assets.zipRight$1(raceEffects), withPermits(1), assets.forkIn(scope));
|
|
2260
|
+
yield* icons._await(latch);
|
|
2261
|
+
const errored = yield* icons.isDone(errorSignal);
|
|
2262
|
+
return !errored;
|
|
2263
|
+
})
|
|
2264
|
+
})
|
|
2265
|
+
})
|
|
2266
|
+
}), assets.repeat({
|
|
2267
|
+
while: _ => _
|
|
2268
|
+
}), assets.forkIn(scope));
|
|
2269
|
+
const consumer = assets.pipe(take(queue), assets.flatten, assets.matchCause({
|
|
2270
|
+
onFailure: failCause$2,
|
|
2271
|
+
onSuccess: assets.match({
|
|
2272
|
+
onLeft: succeedNow,
|
|
2273
|
+
onRight: outElem => flatMap$1(write(outElem), () => consumer)
|
|
2274
|
+
})
|
|
2275
|
+
}), unwrap);
|
|
2276
|
+
return embedInput(consumer, input);
|
|
2277
|
+
}));
|
|
2278
|
+
/** @internal */
|
|
2279
|
+
const mergeMap = /*#__PURE__*/assets.dual(3, (self, f, options) => mergeAll(options)(mapOut(self, f)));
|
|
2280
|
+
/** @internal */
|
|
2281
|
+
const mergeWith = /*#__PURE__*/assets.dual(2, (self, options) => {
|
|
2282
|
+
function merge(scope) {
|
|
2283
|
+
return assets.gen(function* () {
|
|
2284
|
+
const input = yield* make$1();
|
|
2285
|
+
const queueReader = fromInput(input);
|
|
2286
|
+
const pullL = yield* toPullIn(pipeTo(queueReader, self), scope);
|
|
2287
|
+
const pullR = yield* toPullIn(pipeTo(queueReader, options.other), scope);
|
|
2288
|
+
function handleSide(exit, fiber, pull) {
|
|
2289
|
+
return (done, both, single) => {
|
|
2290
|
+
function onDecision(decision) {
|
|
2291
|
+
const op = decision;
|
|
2292
|
+
if (op._tag === OP_DONE) {
|
|
2293
|
+
return assets.succeed$1(fromEffect$3(assets.zipRight$1(interrupt(fiber), op.effect)));
|
|
2294
|
+
}
|
|
2295
|
+
return assets.map$2(_await(fiber), icons.match({
|
|
2296
|
+
onFailure: cause => fromEffect$3(op.f(icons.failCause(cause))),
|
|
2297
|
+
onSuccess: assets.match({
|
|
2298
|
+
onLeft: done => fromEffect$3(op.f(icons.succeed(done))),
|
|
2299
|
+
onRight: elem => zipRight(write(elem), go(single(op.f)))
|
|
2300
|
+
})
|
|
2301
|
+
}));
|
|
2302
|
+
}
|
|
2303
|
+
return icons.match(exit, {
|
|
2304
|
+
onFailure: cause => onDecision(done(icons.failCause(cause))),
|
|
2305
|
+
onSuccess: assets.match({
|
|
2306
|
+
onLeft: z => onDecision(done(icons.succeed(z))),
|
|
2307
|
+
onRight: elem => assets.succeed$1(flatMap$1(write(elem), () => flatMap$1(fromEffect$3(assets.forkIn(assets.interruptible(pull), scope)), leftFiber => go(both(leftFiber, fiber)))))
|
|
2308
|
+
})
|
|
2309
|
+
});
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
function go(state) {
|
|
2313
|
+
switch (state._tag) {
|
|
2314
|
+
case OP_BOTH_RUNNING:
|
|
2315
|
+
{
|
|
2316
|
+
const leftJoin = assets.interruptible(join(state.left));
|
|
2317
|
+
const rightJoin = assets.interruptible(join(state.right));
|
|
2318
|
+
return unwrap(assets.raceWith(leftJoin, rightJoin, {
|
|
2319
|
+
onSelfDone: (leftExit, rf) => assets.zipRight$1(interrupt(rf), handleSide(leftExit, state.right, pullL)(options.onSelfDone, BothRunning, f => LeftDone(f))),
|
|
2320
|
+
onOtherDone: (rightExit, lf) => assets.zipRight$1(interrupt(lf), handleSide(rightExit, state.left, pullR)(options.onOtherDone, (left, right) => BothRunning(right, left), f => RightDone(f)))
|
|
2321
|
+
}));
|
|
2322
|
+
}
|
|
2323
|
+
case OP_LEFT_DONE:
|
|
2324
|
+
{
|
|
2325
|
+
return unwrap(assets.map$2(assets.exit(pullR), icons.match({
|
|
2326
|
+
onFailure: cause => fromEffect$3(state.f(icons.failCause(cause))),
|
|
2327
|
+
onSuccess: assets.match({
|
|
2328
|
+
onLeft: done => fromEffect$3(state.f(icons.succeed(done))),
|
|
2329
|
+
onRight: elem => flatMap$1(write(elem), () => go(LeftDone(state.f)))
|
|
2330
|
+
})
|
|
2331
|
+
})));
|
|
2332
|
+
}
|
|
2333
|
+
case OP_RIGHT_DONE:
|
|
2334
|
+
{
|
|
2335
|
+
return unwrap(assets.map$2(assets.exit(pullL), icons.match({
|
|
2336
|
+
onFailure: cause => fromEffect$3(state.f(icons.failCause(cause))),
|
|
2337
|
+
onSuccess: assets.match({
|
|
2338
|
+
onLeft: done => fromEffect$3(state.f(icons.succeed(done))),
|
|
2339
|
+
onRight: elem => flatMap$1(write(elem), () => go(RightDone(state.f)))
|
|
2340
|
+
})
|
|
2341
|
+
})));
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
return fromEffect$3(assets.withFiberRuntime$1(parent => {
|
|
2346
|
+
const inherit = assets.withFiberRuntime$1(state => {
|
|
2347
|
+
state.transferChildren(parent.scope());
|
|
2348
|
+
return assets._void;
|
|
2349
|
+
});
|
|
2350
|
+
const leftFiber = assets.interruptible(pullL).pipe(assets.ensuring(inherit), assets.forkIn(scope));
|
|
2351
|
+
const rightFiber = assets.interruptible(pullR).pipe(assets.ensuring(inherit), assets.forkIn(scope));
|
|
2352
|
+
return assets.zipWith(leftFiber, rightFiber, (left, right) => BothRunning(left, right));
|
|
2353
|
+
})).pipe(flatMap$1(go), embedInput(input));
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
return unwrapScopedWith$1(merge);
|
|
2357
|
+
});
|
|
2358
|
+
/** @internal */
|
|
2359
|
+
const pipeToOrFail = /*#__PURE__*/assets.dual(2, (self, that) => suspend$1(() => {
|
|
2360
|
+
let channelException = undefined;
|
|
2361
|
+
const reader = readWith({
|
|
2362
|
+
onInput: outElem => flatMap$1(write(outElem), () => reader),
|
|
2363
|
+
onFailure: outErr => {
|
|
2364
|
+
channelException = ChannelException(outErr);
|
|
2365
|
+
return failCause$2(die(channelException));
|
|
2366
|
+
},
|
|
2367
|
+
onDone: succeedNow
|
|
2368
|
+
});
|
|
2369
|
+
const writer = readWithCause({
|
|
2370
|
+
onInput: outElem => assets.pipe(write(outElem), flatMap$1(() => writer)),
|
|
2371
|
+
onFailure: cause => isDieType(cause) && isChannelException(cause.defect) && assets.equals(cause.defect, channelException) ? fail(cause.defect.error) : failCause$2(cause),
|
|
2372
|
+
onDone: succeedNow
|
|
2373
|
+
});
|
|
2374
|
+
return pipeTo(pipeTo(pipeTo(self, reader), that), writer);
|
|
2375
|
+
}));
|
|
2376
|
+
/** @internal */
|
|
2377
|
+
const run$1 = self => assets.scopedWith(scope => runIn(self, scope));
|
|
2378
|
+
/** @internal */
|
|
2379
|
+
const runDrain$2 = self => run$1(drain$1(self));
|
|
2380
|
+
/** @internal */
|
|
2381
|
+
const scoped = effect => unwrap(assets.uninterruptibleMask(restore => assets.map$2(assets.make$2(), scope => acquireReleaseOut(assets.tapErrorCause(restore(assets.extend(effect, scope)), cause => assets.close(scope, icons.failCause(cause))), (_, exit) => assets.close(scope, exit)))));
|
|
2382
|
+
/** @internal */
|
|
2383
|
+
const scopedWith$1 = f => unwrapScoped(assets.map$2(assets.scope, scope => flatMap$1(fromEffect$3(f(scope)), write)));
|
|
2384
|
+
/** @internal */
|
|
2385
|
+
const toPullIn = /*#__PURE__*/assets.dual(2, (self, scope) => assets.zip(assets.sync$1(() => new ChannelExecutor(self, void 0, assets.identity)), assets.runtime()).pipe(assets.tap(([executor, runtime]) => assets.addFinalizerExit(scope, exit => {
|
|
2386
|
+
const finalizer = executor.close(exit);
|
|
2387
|
+
return finalizer !== undefined ? assets.provide(finalizer, runtime) : assets._void;
|
|
2388
|
+
})), assets.uninterruptible$1, assets.map$2(([executor]) => assets.suspend$1(() => interpretToPull(executor.run(), executor)))));
|
|
2389
|
+
/** @internal */
|
|
2390
|
+
const interpretToPull = (channelState, exec) => {
|
|
2391
|
+
const state = channelState;
|
|
2392
|
+
switch (state._tag) {
|
|
2393
|
+
case OP_DONE$1:
|
|
2394
|
+
{
|
|
2395
|
+
return icons.match(exec.getDone(), {
|
|
2396
|
+
onFailure: assets.failCause,
|
|
2397
|
+
onSuccess: done => assets.succeed$1(assets.left(done))
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
case OP_EMIT$1:
|
|
2401
|
+
{
|
|
2402
|
+
return assets.succeed$1(assets.right(exec.getEmit()));
|
|
2403
|
+
}
|
|
2404
|
+
case OP_FROM_EFFECT:
|
|
2405
|
+
{
|
|
2406
|
+
return assets.pipe(state.effect, assets.flatMap$1(() => interpretToPull(exec.run(), exec)));
|
|
2407
|
+
}
|
|
2408
|
+
case OP_READ:
|
|
2409
|
+
{
|
|
2410
|
+
return readUpstream(state, () => interpretToPull(exec.run(), exec), cause => assets.failCause(cause));
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
};
|
|
2414
|
+
/** @internal */
|
|
2415
|
+
const unwrap = channel => flatten$1(fromEffect$3(channel));
|
|
2416
|
+
/** @internal */
|
|
2417
|
+
const unwrapScoped = self => concatAllWith(scoped(self), (d, _) => d, (d, _) => d);
|
|
2418
|
+
/** @internal */
|
|
2419
|
+
const unwrapScopedWith$1 = f => concatAllWith(scopedWith$1(f), (d, _) => d, (d, _) => d);
|
|
2420
|
+
/** @internal */
|
|
2421
|
+
const writeChunk = outs => writeChunkWriter(0, outs.length, outs);
|
|
2422
|
+
/** @internal */
|
|
2423
|
+
const writeChunkWriter = (idx, len, chunk) => {
|
|
2424
|
+
return idx === len ? void_ : assets.pipe(write(assets.pipe(chunk, assets.unsafeGet(idx))), flatMap$1(() => writeChunkWriter(idx + 1, len, chunk)));
|
|
2425
|
+
};
|
|
2426
|
+
/** @internal */
|
|
2427
|
+
const zip = /*#__PURE__*/assets.dual(args => isChannel(args[1]), (self, that, options) => options?.concurrent ? mergeWith(self, {
|
|
2428
|
+
other: that,
|
|
2429
|
+
onSelfDone: exit1 => Await(exit2 => assets.suspend$1(() => icons.zip(exit1, exit2))),
|
|
2430
|
+
onOtherDone: exit2 => Await(exit1 => assets.suspend$1(() => icons.zip(exit1, exit2)))
|
|
2431
|
+
}) : flatMap$1(self, a => map$1(that, b => [a, b])));
|
|
2432
|
+
/** @internal */
|
|
2433
|
+
const zipRight = /*#__PURE__*/assets.dual(args => isChannel(args[1]), (self, that, options) => options?.concurrent ? map$1(zip(self, that, {
|
|
2434
|
+
concurrent: true
|
|
2435
|
+
}), tuple => tuple[1]) : flatMap$1(self, () => that));
|
|
2436
|
+
/** @internal */
|
|
2437
|
+
const ChannelExceptionTypeId = /*#__PURE__*/Symbol.for("effect/Channel/ChannelException");
|
|
2438
|
+
/** @internal */
|
|
2439
|
+
const ChannelException = error => ({
|
|
2440
|
+
_tag: "ChannelException",
|
|
2441
|
+
[ChannelExceptionTypeId]: ChannelExceptionTypeId,
|
|
2442
|
+
error
|
|
2443
|
+
});
|
|
2444
|
+
/** @internal */
|
|
2445
|
+
const isChannelException = u => assets.hasProperty(u, ChannelExceptionTypeId);
|
|
2446
|
+
|
|
2447
|
+
/** @internal */
|
|
2448
|
+
const SinkTypeId = /*#__PURE__*/Symbol.for("effect/Sink");
|
|
2449
|
+
const sinkVariance = {
|
|
2450
|
+
/* c8 ignore next */
|
|
2451
|
+
_A: _ => _,
|
|
2452
|
+
/* c8 ignore next */
|
|
2453
|
+
_In: _ => _,
|
|
2454
|
+
/* c8 ignore next */
|
|
2455
|
+
_L: _ => _,
|
|
2456
|
+
/* c8 ignore next */
|
|
2457
|
+
_E: _ => _,
|
|
2458
|
+
/* c8 ignore next */
|
|
2459
|
+
_R: _ => _
|
|
2460
|
+
};
|
|
2461
|
+
/** @internal */
|
|
2462
|
+
class SinkImpl {
|
|
2463
|
+
channel;
|
|
2464
|
+
[SinkTypeId] = sinkVariance;
|
|
2465
|
+
constructor(channel) {
|
|
2466
|
+
this.channel = channel;
|
|
2467
|
+
}
|
|
2468
|
+
pipe() {
|
|
2469
|
+
return assets.pipeArguments(this, arguments);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
/** @internal */
|
|
2473
|
+
const drain = /*#__PURE__*/new SinkImpl(/*#__PURE__*/drain$1(/*#__PURE__*/identityChannel()));
|
|
2474
|
+
/** @internal */
|
|
2475
|
+
const fromEffect$1 = effect => new SinkImpl(fromEffect$3(effect));
|
|
2476
|
+
/** @internal */
|
|
2477
|
+
const toChannel$1 = self => assets.isEffect(self) ? toChannel$1(fromEffect$1(self)) : self.channel;
|
|
2478
|
+
|
|
2479
|
+
/** @internal */
|
|
2480
|
+
const TakeSymbolKey = "effect/Take";
|
|
2481
|
+
/** @internal */
|
|
2482
|
+
const TakeTypeId = /*#__PURE__*/Symbol.for(TakeSymbolKey);
|
|
2483
|
+
const takeVariance = {
|
|
2484
|
+
/* c8 ignore next */
|
|
2485
|
+
_A: _ => _,
|
|
2486
|
+
/* c8 ignore next */
|
|
2487
|
+
_E: _ => _
|
|
2488
|
+
};
|
|
2489
|
+
/** @internal */
|
|
2490
|
+
class TakeImpl {
|
|
2491
|
+
exit;
|
|
2492
|
+
[TakeTypeId] = takeVariance;
|
|
2493
|
+
constructor(exit) {
|
|
2494
|
+
this.exit = exit;
|
|
2495
|
+
}
|
|
2496
|
+
pipe() {
|
|
2497
|
+
return assets.pipeArguments(this, arguments);
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
/** @internal */
|
|
2501
|
+
const chunk = chunk => new TakeImpl(icons.succeed(chunk));
|
|
2502
|
+
/** @internal */
|
|
2503
|
+
const end$1 = /*#__PURE__*/new TakeImpl(/*#__PURE__*/icons.fail(/*#__PURE__*/assets.none()));
|
|
2504
|
+
/** @internal */
|
|
2505
|
+
const failCause$1 = cause => new TakeImpl(icons.failCause(assets.pipe(cause, map$2(assets.some))));
|
|
2506
|
+
/** @internal */
|
|
2507
|
+
const of = value => new TakeImpl(icons.succeed(assets.of(value)));
|
|
2508
|
+
|
|
2509
|
+
/** @internal */
|
|
2510
|
+
const end = () => assets.fail$1(assets.none());
|
|
2511
|
+
/** @internal */
|
|
2512
|
+
const failCause = cause => assets.mapError(assets.failCause(cause), assets.some);
|
|
2513
|
+
|
|
2514
|
+
/** @internal */
|
|
2515
|
+
const StreamSymbolKey = "effect/Stream";
|
|
2516
|
+
/** @internal */
|
|
2517
|
+
const StreamTypeId = /*#__PURE__*/Symbol.for(StreamSymbolKey);
|
|
2518
|
+
/** @internal */
|
|
2519
|
+
const streamVariance = {
|
|
2520
|
+
_R: _ => _,
|
|
2521
|
+
_E: _ => _,
|
|
2522
|
+
_A: _ => _
|
|
2523
|
+
};
|
|
2524
|
+
/** @internal */
|
|
2525
|
+
class StreamImpl {
|
|
2526
|
+
channel;
|
|
2527
|
+
[StreamTypeId] = streamVariance;
|
|
2528
|
+
constructor(channel) {
|
|
2529
|
+
this.channel = channel;
|
|
2530
|
+
}
|
|
2531
|
+
pipe() {
|
|
2532
|
+
return assets.pipeArguments(this, arguments);
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
/** @internal */
|
|
2536
|
+
const isStream = u => assets.hasProperty(u, StreamTypeId) || assets.isEffect(u);
|
|
2537
|
+
/** @internal */
|
|
2538
|
+
const DefaultChunkSize = 4096;
|
|
2539
|
+
/** @internal */
|
|
2540
|
+
const ensuring = /*#__PURE__*/assets.dual(2, (self, finalizer) => new StreamImpl(assets.pipe(toChannel(self), ensuring$1(finalizer))));
|
|
2541
|
+
/** @internal */
|
|
2542
|
+
const flatMap = /*#__PURE__*/assets.dual(args => isStream(args[0]), (self, f, options) => {
|
|
2543
|
+
const bufferSize = options?.bufferSize ?? 16;
|
|
2544
|
+
if (options?.switch) {
|
|
2545
|
+
return matchConcurrency(options?.concurrency, () => flatMapParSwitchBuffer(self, 1, bufferSize, f), n => flatMapParSwitchBuffer(self, n, bufferSize, f));
|
|
2546
|
+
}
|
|
2547
|
+
return matchConcurrency(options?.concurrency, () => new StreamImpl(concatMap(toChannel(self), as => assets.pipe(as, assets.map$3(a => toChannel(f(a))), assets.reduce(void_, (left, right) => assets.pipe(left, zipRight(right)))))), _ => new StreamImpl(assets.pipe(toChannel(self), concatMap(writeChunk), mergeMap(out => toChannel(f(out)), options))));
|
|
2548
|
+
});
|
|
2549
|
+
/** @internal */
|
|
2550
|
+
const matchConcurrency = (concurrency, sequential, bounded) => {
|
|
2551
|
+
switch (concurrency) {
|
|
2552
|
+
case undefined:
|
|
2553
|
+
return sequential();
|
|
2554
|
+
case "unbounded":
|
|
2555
|
+
return bounded(Number.MAX_SAFE_INTEGER);
|
|
2556
|
+
default:
|
|
2557
|
+
return concurrency > 1 ? bounded(concurrency) : sequential();
|
|
2558
|
+
}
|
|
2559
|
+
};
|
|
2560
|
+
const flatMapParSwitchBuffer = /*#__PURE__*/assets.dual(4, (self, n, bufferSize, f) => new StreamImpl(assets.pipe(toChannel(self), concatMap(writeChunk), mergeMap(out => toChannel(f(out)), {
|
|
2561
|
+
concurrency: n,
|
|
2562
|
+
mergeStrategy: BufferSliding(),
|
|
2563
|
+
bufferSize
|
|
2564
|
+
}))));
|
|
2565
|
+
/** @internal */
|
|
2566
|
+
const flatten = /*#__PURE__*/assets.dual(args => isStream(args[0]), (self, options) => flatMap(self, assets.identity, options));
|
|
2567
|
+
/** @internal */
|
|
2568
|
+
const flattenChunks = self => {
|
|
2569
|
+
const flatten = readWithCause({
|
|
2570
|
+
onInput: chunks => flatMap$1(writeChunk(chunks), () => flatten),
|
|
2571
|
+
onFailure: failCause$2,
|
|
2572
|
+
onDone: () => void_
|
|
2573
|
+
});
|
|
2574
|
+
return new StreamImpl(assets.pipe(toChannel(self), pipeTo(flatten)));
|
|
2575
|
+
};
|
|
2576
|
+
/** @internal */
|
|
2577
|
+
const flattenExitOption = self => {
|
|
2578
|
+
const processChunk = (chunk, cont) => {
|
|
2579
|
+
const [toEmit, rest] = assets.pipe(chunk, assets.splitWhere(exit => !icons.isSuccess(exit)));
|
|
2580
|
+
const next = assets.pipe(assets.head(rest), assets.match$1({
|
|
2581
|
+
onNone: () => cont,
|
|
2582
|
+
onSome: icons.match({
|
|
2583
|
+
onFailure: cause => assets.match$1(flipCauseOption(cause), {
|
|
2584
|
+
onNone: () => void_,
|
|
2585
|
+
onSome: failCause$2
|
|
2586
|
+
}),
|
|
2587
|
+
onSuccess: () => void_
|
|
2588
|
+
})
|
|
2589
|
+
}));
|
|
2590
|
+
return assets.pipe(write(assets.pipe(toEmit, assets.filterMap(exit => icons.isSuccess(exit) ? assets.some(exit.value) : assets.none()))), flatMap$1(() => next));
|
|
2591
|
+
};
|
|
2592
|
+
const process = readWithCause({
|
|
2593
|
+
onInput: chunk => processChunk(chunk, process),
|
|
2594
|
+
onFailure: cause => failCause$2(cause),
|
|
2595
|
+
onDone: () => void_
|
|
2596
|
+
});
|
|
2597
|
+
return new StreamImpl(assets.pipe(toChannel(self), pipeTo(process)));
|
|
2598
|
+
};
|
|
2599
|
+
/** @internal */
|
|
2600
|
+
const flattenTake = self => flattenChunks(flattenExitOption(assets.pipe(self, map(take => take.exit))));
|
|
2601
|
+
/** @internal */
|
|
2602
|
+
const toChannel = stream => {
|
|
2603
|
+
if ("channel" in stream) {
|
|
2604
|
+
return stream.channel;
|
|
2605
|
+
} else if (assets.isEffect(stream)) {
|
|
2606
|
+
return toChannel(fromEffect(stream));
|
|
2607
|
+
} else {
|
|
2608
|
+
throw new TypeError(`Expected a Stream.`);
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
/** @internal */
|
|
2612
|
+
const fromEffect = effect => assets.pipe(effect, assets.mapError(assets.some), fromEffectOption);
|
|
2613
|
+
/** @internal */
|
|
2614
|
+
const fromEffectOption = effect => new StreamImpl(unwrap(assets.match$2(effect, {
|
|
2615
|
+
onFailure: assets.match$1({
|
|
2616
|
+
onNone: () => void_,
|
|
2617
|
+
onSome: fail
|
|
2618
|
+
}),
|
|
2619
|
+
onSuccess: a => write(assets.of(a))
|
|
2620
|
+
})));
|
|
2621
|
+
/** @internal */
|
|
2622
|
+
const fromQueue$1 = (queue, options) => assets.pipe(takeBetween(queue, 1, options?.maxChunkSize ?? DefaultChunkSize), assets.catchAllCause(cause => assets.pipe(isShutdown(queue), assets.flatMap$1(isShutdown => isShutdown && isInterrupted(cause) ? end() : failCause(cause)))), repeatEffectChunkOption, options?.shutdown ? ensuring(shutdown(queue)) : assets.identity);
|
|
2623
|
+
/** @internal */
|
|
2624
|
+
const map = /*#__PURE__*/assets.dual(2, (self, f) => new StreamImpl(assets.pipe(toChannel(self), mapOut(assets.map$3(f)))));
|
|
2625
|
+
/** @internal */
|
|
2626
|
+
const mapEffectSequential = /*#__PURE__*/assets.dual(2, (self, f) => {
|
|
2627
|
+
const loop = iterator => {
|
|
2628
|
+
const next = iterator.next();
|
|
2629
|
+
if (next.done) {
|
|
2630
|
+
return readWithCause({
|
|
2631
|
+
onInput: elem => loop(elem[Symbol.iterator]()),
|
|
2632
|
+
onFailure: failCause$2,
|
|
2633
|
+
onDone: succeed
|
|
2634
|
+
});
|
|
2635
|
+
} else {
|
|
2636
|
+
const value = next.value;
|
|
2637
|
+
return unwrap(assets.map$2(f(value), a2 => flatMap$1(write(assets.of(a2)), () => loop(iterator))));
|
|
2638
|
+
}
|
|
2639
|
+
};
|
|
2640
|
+
return new StreamImpl(assets.pipe(toChannel(self), pipeTo(suspend$1(() => loop(assets.empty$1()[Symbol.iterator]())))));
|
|
2641
|
+
});
|
|
2642
|
+
/** @internal */
|
|
2643
|
+
const mapEffectPar = /*#__PURE__*/assets.dual(3, (self, n, f) => new StreamImpl(assets.pipe(toChannel(self), concatMap(writeChunk), mapOutEffectPar(f, n), mapOut(assets.of))));
|
|
2644
|
+
/** @internal */
|
|
2645
|
+
const repeatEffectChunkOption = effect => unfoldChunkEffect(effect, effect => assets.pipe(assets.map$2(effect, chunk => assets.some([chunk, effect])), assets.catchAll$1(assets.match$1({
|
|
2646
|
+
onNone: () => assets.succeed$1(assets.none()),
|
|
2647
|
+
onSome: assets.fail$1
|
|
2648
|
+
}))));
|
|
2649
|
+
/** @internal */
|
|
2650
|
+
const run = /*#__PURE__*/assets.dual(2, (self, sink) => toChannel(self).pipe(pipeToOrFail(toChannel$1(sink)), runDrain$2));
|
|
2651
|
+
/** @internal */
|
|
2652
|
+
const runDrain$1 = self => run(self, drain);
|
|
2653
|
+
/** @internal */
|
|
2654
|
+
const scopedWith = f => new StreamImpl(scopedWith$1(scope => f(scope).pipe(assets.map$2(assets.of))));
|
|
2655
|
+
/** @internal */
|
|
2656
|
+
const suspend = stream => new StreamImpl(suspend$1(() => toChannel(stream())));
|
|
2657
|
+
/** @internal */
|
|
2658
|
+
const unfoldChunkEffect = (s, f) => suspend(() => {
|
|
2659
|
+
const loop = s => unwrap(assets.map$2(f(s), assets.match$1({
|
|
2660
|
+
onNone: () => void_,
|
|
2661
|
+
onSome: ([chunk, s]) => flatMap$1(write(chunk), () => loop(s))
|
|
2662
|
+
})));
|
|
2663
|
+
return new StreamImpl(loop(s));
|
|
2664
|
+
});
|
|
2665
|
+
/** @internal */
|
|
2666
|
+
const unwrapScopedWith = f => flatten(scopedWith(scope => f(scope)));
|
|
2667
|
+
|
|
2668
|
+
/** @internal */
|
|
2669
|
+
const GroupBySymbolKey = "effect/GroupBy";
|
|
2670
|
+
/** @internal */
|
|
2671
|
+
const GroupByTypeId = /*#__PURE__*/Symbol.for(GroupBySymbolKey);
|
|
2672
|
+
const groupByVariance = {
|
|
2673
|
+
/* c8 ignore next */
|
|
2674
|
+
_R: _ => _,
|
|
2675
|
+
/* c8 ignore next */
|
|
2676
|
+
_E: _ => _,
|
|
2677
|
+
/* c8 ignore next */
|
|
2678
|
+
_K: _ => _,
|
|
2679
|
+
/* c8 ignore next */
|
|
2680
|
+
_V: _ => _
|
|
2681
|
+
};
|
|
2682
|
+
/** @internal */
|
|
2683
|
+
const isGroupBy = u => assets.hasProperty(u, GroupByTypeId);
|
|
2684
|
+
/** @internal */
|
|
2685
|
+
const evaluate = /*#__PURE__*/assets.dual(args => isGroupBy(args[0]), (self, f, options) => flatMap(self.grouped, ([key, queue]) => f(key, flattenTake(fromQueue$1(queue, {
|
|
2686
|
+
shutdown: true
|
|
2687
|
+
}))), {
|
|
2688
|
+
concurrency: "unbounded",
|
|
2689
|
+
bufferSize: options?.bufferSize ?? 16
|
|
2690
|
+
}));
|
|
2691
|
+
/** @internal */
|
|
2692
|
+
const make = grouped => ({
|
|
2693
|
+
[GroupByTypeId]: groupByVariance,
|
|
2694
|
+
pipe() {
|
|
2695
|
+
return assets.pipeArguments(this, arguments);
|
|
2696
|
+
},
|
|
2697
|
+
grouped
|
|
2698
|
+
});
|
|
2699
|
+
/** @internal */
|
|
2700
|
+
const mapEffectOptions = /*#__PURE__*/assets.dual(args => typeof args[0] !== "function", (self, f, options) => {
|
|
2701
|
+
if (options?.key) {
|
|
2702
|
+
return evaluate(groupByKey(self, options.key, {
|
|
2703
|
+
bufferSize: options.bufferSize
|
|
2704
|
+
}), (_, s) => mapEffectSequential(s, f));
|
|
2705
|
+
}
|
|
2706
|
+
return matchConcurrency(options?.concurrency, () => mapEffectSequential(self, f), n => options?.unordered ? flatMap(self, a => fromEffect(f(a)), {
|
|
2707
|
+
concurrency: n
|
|
2708
|
+
}) : mapEffectPar(self, n, f));
|
|
2709
|
+
});
|
|
2710
|
+
/** @internal */
|
|
2711
|
+
const groupByKey = /*#__PURE__*/assets.dual(args => typeof args[0] !== "function", (self, f, options) => {
|
|
2712
|
+
const loop = (map, outerQueue) => readWithCause({
|
|
2713
|
+
onInput: input => flatMap$1(fromEffect$3(assets.forEach(groupByIterable(input, f), ([key, values]) => {
|
|
2714
|
+
const innerQueue = map.get(key);
|
|
2715
|
+
if (innerQueue === undefined) {
|
|
2716
|
+
return assets.pipe(bounded(options?.bufferSize ?? 16), assets.flatMap$1(innerQueue => assets.pipe(assets.sync$1(() => {
|
|
2717
|
+
map.set(key, innerQueue);
|
|
2718
|
+
}), assets.zipRight$1(offer(outerQueue, of([key, innerQueue]))), assets.zipRight$1(assets.pipe(offer(innerQueue, chunk(values)), assets.catchSomeCause(cause => isInterruptedOnly(cause) ? assets.some(assets._void) : assets.none()))))));
|
|
2719
|
+
}
|
|
2720
|
+
return assets.catchSomeCause(offer(innerQueue, chunk(values)), cause => isInterruptedOnly(cause) ? assets.some(assets._void) : assets.none());
|
|
2721
|
+
}, {
|
|
2722
|
+
discard: true
|
|
2723
|
+
})), () => loop(map, outerQueue)),
|
|
2724
|
+
onFailure: cause => fromEffect$3(offer(outerQueue, failCause$1(cause))),
|
|
2725
|
+
onDone: () => fromEffect$3(assets.pipe(assets.forEach(map.entries(), ([_, innerQueue]) => assets.pipe(offer(innerQueue, end$1), assets.catchSomeCause(cause => isInterruptedOnly(cause) ? assets.some(assets._void) : assets.none())), {
|
|
2726
|
+
discard: true
|
|
2727
|
+
}), assets.zipRight$1(offer(outerQueue, end$1))))
|
|
2728
|
+
});
|
|
2729
|
+
return make(unwrapScopedWith(scope => assets.gen(function* () {
|
|
2730
|
+
const map = new Map();
|
|
2731
|
+
const queue = yield* unbounded();
|
|
2732
|
+
yield* assets.addFinalizer(scope, shutdown(queue));
|
|
2733
|
+
return yield* toChannel(self).pipe(pipeTo(loop(map, queue)), drain$1, runIn(scope), assets.forkIn(scope), assets.as(flattenTake(fromQueue$1(queue, {
|
|
2734
|
+
shutdown: true
|
|
2735
|
+
}))));
|
|
2736
|
+
})));
|
|
2737
|
+
});
|
|
2738
|
+
/**
|
|
2739
|
+
* A variant of `groupBy` that retains the insertion order of keys.
|
|
2740
|
+
*
|
|
2741
|
+
* @internal
|
|
2742
|
+
*/
|
|
2743
|
+
const groupByIterable = /*#__PURE__*/assets.dual(2, (iterable, f) => {
|
|
2744
|
+
const builder = [];
|
|
2745
|
+
const iterator = iterable[Symbol.iterator]();
|
|
2746
|
+
const map = new Map();
|
|
2747
|
+
let next;
|
|
2748
|
+
while ((next = iterator.next()) && !next.done) {
|
|
2749
|
+
const value = next.value;
|
|
2750
|
+
const key = f(value);
|
|
2751
|
+
if (map.has(key)) {
|
|
2752
|
+
const innerBuilder = map.get(key);
|
|
2753
|
+
innerBuilder.push(value);
|
|
2754
|
+
} else {
|
|
2755
|
+
const innerBuilder = [value];
|
|
2756
|
+
builder.push([key, innerBuilder]);
|
|
2757
|
+
map.set(key, innerBuilder);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
return assets.unsafeFromArray(builder.map(tuple => [tuple[0], assets.unsafeFromArray(tuple[1])]));
|
|
2761
|
+
});
|
|
2762
|
+
|
|
2763
|
+
/**
|
|
2764
|
+
* Creates a stream from a queue of values
|
|
2765
|
+
*
|
|
2766
|
+
* **Options**
|
|
2767
|
+
*
|
|
2768
|
+
* - `maxChunkSize`: The maximum number of queued elements to put in one chunk in the stream
|
|
2769
|
+
* - `shutdown`: If `true`, the queue will be shutdown after the stream is evaluated (defaults to `false`)
|
|
2770
|
+
*
|
|
2771
|
+
* @since 2.0.0
|
|
2772
|
+
* @category constructors
|
|
2773
|
+
*/
|
|
2774
|
+
const fromQueue = fromQueue$1;
|
|
2775
|
+
/**
|
|
2776
|
+
* Maps over elements of the stream with the specified effectful function.
|
|
2777
|
+
*
|
|
2778
|
+
* @example
|
|
2779
|
+
* ```ts
|
|
2780
|
+
* import { Effect, Random, Stream } from "effect"
|
|
2781
|
+
*
|
|
2782
|
+
* const stream = Stream.make(10, 20, 30).pipe(
|
|
2783
|
+
* Stream.mapEffect((n) => Random.nextIntBetween(0, n))
|
|
2784
|
+
* )
|
|
2785
|
+
*
|
|
2786
|
+
* Effect.runPromise(Stream.runCollect(stream)).then(console.log)
|
|
2787
|
+
* // Example Output: { _id: 'Chunk', values: [ 7, 19, 8 ] }
|
|
2788
|
+
* ```
|
|
2789
|
+
*
|
|
2790
|
+
* @since 2.0.0
|
|
2791
|
+
* @category mapping
|
|
2792
|
+
*/
|
|
2793
|
+
const mapEffect = mapEffectOptions;
|
|
2794
|
+
/**
|
|
2795
|
+
* Runs the stream only for its effects. The emitted elements are discarded.
|
|
2796
|
+
*
|
|
2797
|
+
* @since 2.0.0
|
|
2798
|
+
* @category destructors
|
|
2799
|
+
*/
|
|
2800
|
+
const runDrain = runDrain$1;
|
|
2801
|
+
|
|
2802
|
+
const HeaderIntegration = class {
|
|
2803
|
+
constructor(hostRef) {
|
|
2804
|
+
index.registerInstance(this, hostRef);
|
|
2805
|
+
}
|
|
2806
|
+
activeNav;
|
|
2807
|
+
activate(event) {
|
|
2808
|
+
const target = event.currentTarget;
|
|
2809
|
+
const navItem = target.closest('[slot="nav-primary"]');
|
|
2810
|
+
if (!navItem)
|
|
2811
|
+
return;
|
|
2812
|
+
const navId = navItem.id;
|
|
2813
|
+
if (!navId) {
|
|
2814
|
+
console.warn('Nav item does not have an id:', navItem);
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
console.log('Activating nav item:', navId);
|
|
2818
|
+
this.activeNav = navId;
|
|
2819
|
+
}
|
|
2820
|
+
render() {
|
|
2821
|
+
return (index.h(index.Host, { key: 'd36cd9202cfdea4bc684f2b17ba625fd37397616' }, index.h("lmvz-header", { key: '681f8b9fe603d98bad55bbbc7b4dbd43a3d7aff1', lmvzActiveNav: this.activeNav }, index.h("lmvz-menuitem", { key: '54a1b1d394c69e98e742e2dd53f000de028a8626', slot: "nav-primary", id: "lehrmittel", onLmvzActivation: this.activate.bind(this) }, "Lehrmittel"), index.h("lmvz-menuitem", { key: '1aa874d07f7e444433c818c97e300d0e1693fa06', slot: "nav-primary", id: "verwaltung", onLmvzActivation: this.activate.bind(this) }, "Verwaltung"), index.h("lmvz-menuitem", { key: 'd462954ef05c4d70252febfd184b363c4a2a3cde', slot: "connect-nav-lehrmittel" }, index.h("lmvz-icon", { key: '72e9bb03e05463b876bbf23e2e3e12838b15c76c', icon: "book" }), "Deutsch 7"), index.h("lmvz-menuitem", { key: '3f065f96ecd9ec59ae9ebd7885173e706f156a94', slot: "connect-nav-lehrmittel" }, index.h("lmvz-icon", { key: 'cb8039ffb7e590c201e7dc31ba55741c2dbe1181', icon: "book" }), "Mathe 2"), index.h("lmvz-menuitem", { key: '90eff45f7a773665a71eddceb4841e89fe54e5cb', slot: "connect-nav-verwaltung" }, index.h("lmvz-icon", { key: '1a9a36baab23233209649e65a5a25d0d1e9b455e', icon: "cog" }), "iwas mit Verwaltung"), index.h("lmvz-menuitem", { key: '14149a8355373308ff6a531fc6e796b0a67e44a3', slot: "connect-nav-verwaltung", "aria-label": "Einstellungen" }, index.h("lmvz-icon", { key: '0e713b2f6740e004c8897e986de0756c9392459e', icon: "cog" })), index.h("lmvz-button", { key: 'ee75293a9e256b5d3edf90a77a817aa1b60aea9e', slot: "actions", "aria-label": "Benutzerkonto" }, index.h("lmvz-icon", { key: '483e613ab4f5c32be0f942714fe649019b001f3f', icon: "user" }))), index.h("lmvz-input", { key: '63ec977b40a39ecd9bc37309ee2d917916cf3256', label: "test" })));
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
HeaderIntegration.style = `:host {
|
|
2825
|
+
display: block;
|
|
2826
|
+
min-height: 100vh;
|
|
2827
|
+
background: var(--lmvz-color-spec-bg-outer-view);
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
.active button {
|
|
2831
|
+
background-color: var(--lmvz-semantic-color-status-selected);
|
|
2832
|
+
}`;
|
|
2833
|
+
|
|
2834
|
+
var classnames = {exports: {}};
|
|
2835
|
+
|
|
2836
|
+
/*!
|
|
2837
|
+
Copyright (c) 2018 Jed Watson.
|
|
2838
|
+
Licensed under the MIT License (MIT), see
|
|
2839
|
+
http://jedwatson.github.io/classnames
|
|
2840
|
+
*/
|
|
2841
|
+
|
|
2842
|
+
var hasRequiredClassnames;
|
|
2843
|
+
|
|
2844
|
+
function requireClassnames () {
|
|
2845
|
+
if (hasRequiredClassnames) return classnames.exports;
|
|
2846
|
+
hasRequiredClassnames = 1;
|
|
2847
|
+
(function (module) {
|
|
2848
|
+
/* global define */
|
|
2849
|
+
|
|
2850
|
+
(function () {
|
|
2851
|
+
|
|
2852
|
+
var hasOwn = {}.hasOwnProperty;
|
|
2853
|
+
|
|
2854
|
+
function classNames () {
|
|
2855
|
+
var classes = '';
|
|
2856
|
+
|
|
2857
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
2858
|
+
var arg = arguments[i];
|
|
2859
|
+
if (arg) {
|
|
2860
|
+
classes = appendClass(classes, parseValue(arg));
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
return classes;
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
function parseValue (arg) {
|
|
2868
|
+
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
2869
|
+
return arg;
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
if (typeof arg !== 'object') {
|
|
2873
|
+
return '';
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
if (Array.isArray(arg)) {
|
|
2877
|
+
return classNames.apply(null, arg);
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
2881
|
+
return arg.toString();
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
var classes = '';
|
|
2885
|
+
|
|
2886
|
+
for (var key in arg) {
|
|
2887
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
2888
|
+
classes = appendClass(classes, key);
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
return classes;
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
function appendClass (value, newClass) {
|
|
2896
|
+
if (!newClass) {
|
|
2897
|
+
return value;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
if (value) {
|
|
2901
|
+
return value + ' ' + newClass;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
return value + newClass;
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
if (module.exports) {
|
|
2908
|
+
classNames.default = classNames;
|
|
2909
|
+
module.exports = classNames;
|
|
2910
|
+
} else {
|
|
2911
|
+
window.classNames = classNames;
|
|
2912
|
+
}
|
|
2913
|
+
}());
|
|
2914
|
+
} (classnames));
|
|
2915
|
+
return classnames.exports;
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
var classnamesExports = requireClassnames();
|
|
2919
|
+
var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
2920
|
+
|
|
2921
|
+
const componentOnReady = (el, callback) => {
|
|
2922
|
+
if (el.componentOnReady) {
|
|
2923
|
+
el.componentOnReady().then((resolvedEl) => callback(resolvedEl));
|
|
2924
|
+
}
|
|
2925
|
+
else {
|
|
2926
|
+
raf(() => callback(el));
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
const inheritAttributes = (el, attributes = []) => {
|
|
2930
|
+
const attributeObject = {};
|
|
2931
|
+
attributes.forEach(attr => {
|
|
2932
|
+
if (el.hasAttribute(attr)) {
|
|
2933
|
+
const value = el.getAttribute(attr);
|
|
2934
|
+
if (value !== null) {
|
|
2935
|
+
attributeObject[attr] = el.getAttribute(attr);
|
|
2936
|
+
}
|
|
2937
|
+
el.removeAttribute(attr);
|
|
2938
|
+
}
|
|
2939
|
+
});
|
|
2940
|
+
return attributeObject;
|
|
2941
|
+
};
|
|
2942
|
+
const ariaAttributes = [
|
|
2943
|
+
'role',
|
|
2944
|
+
'aria-activedescendant',
|
|
2945
|
+
'aria-atomic',
|
|
2946
|
+
'aria-autocomplete',
|
|
2947
|
+
'aria-braillelabel',
|
|
2948
|
+
'aria-brailleroledescription',
|
|
2949
|
+
'aria-busy',
|
|
2950
|
+
'aria-checked',
|
|
2951
|
+
'aria-colcount',
|
|
2952
|
+
'aria-colindex',
|
|
2953
|
+
'aria-colindextext',
|
|
2954
|
+
'aria-colspan',
|
|
2955
|
+
'aria-controls',
|
|
2956
|
+
'aria-current',
|
|
2957
|
+
'aria-describedby',
|
|
2958
|
+
'aria-description',
|
|
2959
|
+
'aria-details',
|
|
2960
|
+
'aria-disabled',
|
|
2961
|
+
'aria-errormessage',
|
|
2962
|
+
'aria-expanded',
|
|
2963
|
+
'aria-flowto',
|
|
2964
|
+
'aria-haspopup',
|
|
2965
|
+
'aria-hidden',
|
|
2966
|
+
'aria-invalid',
|
|
2967
|
+
'aria-keyshortcuts',
|
|
2968
|
+
'aria-label',
|
|
2969
|
+
'aria-labelledby',
|
|
2970
|
+
'aria-level',
|
|
2971
|
+
'aria-live',
|
|
2972
|
+
'aria-multiline',
|
|
2973
|
+
'aria-multiselectable',
|
|
2974
|
+
'aria-orientation',
|
|
2975
|
+
'aria-owns',
|
|
2976
|
+
'aria-placeholder',
|
|
2977
|
+
'aria-posinset',
|
|
2978
|
+
'aria-pressed',
|
|
2979
|
+
'aria-readonly',
|
|
2980
|
+
'aria-relevant',
|
|
2981
|
+
'aria-required',
|
|
2982
|
+
'aria-roledescription',
|
|
2983
|
+
'aria-rowcount',
|
|
2984
|
+
'aria-rowindex',
|
|
2985
|
+
'aria-rowindextext',
|
|
2986
|
+
'aria-rowspan',
|
|
2987
|
+
'aria-selected',
|
|
2988
|
+
'aria-setsize',
|
|
2989
|
+
'aria-sort',
|
|
2990
|
+
'aria-valuemax',
|
|
2991
|
+
'aria-valuemin',
|
|
2992
|
+
'aria-valuenow',
|
|
2993
|
+
'aria-valuetext',
|
|
2994
|
+
];
|
|
2995
|
+
const inheritAriaAttributes = (el, ignoreList) => {
|
|
2996
|
+
let attributesToInherit = ariaAttributes;
|
|
2997
|
+
return inheritAttributes(el, attributesToInherit);
|
|
2998
|
+
};
|
|
2999
|
+
const raf = (h) => {
|
|
3000
|
+
if (typeof __zone_symbol__requestAnimationFrame === 'function') {
|
|
3001
|
+
return __zone_symbol__requestAnimationFrame(h);
|
|
3002
|
+
}
|
|
3003
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
3004
|
+
return requestAnimationFrame(h);
|
|
3005
|
+
}
|
|
3006
|
+
return setTimeout(h);
|
|
3007
|
+
};
|
|
3008
|
+
function getDeepActiveElement(root = document) {
|
|
3009
|
+
let activeElement = root.activeElement;
|
|
3010
|
+
if (!activeElement) {
|
|
3011
|
+
return null;
|
|
3012
|
+
}
|
|
3013
|
+
while (activeElement && activeElement.shadowRoot) {
|
|
3014
|
+
const next = activeElement.shadowRoot.activeElement;
|
|
3015
|
+
if (!next) {
|
|
3016
|
+
break;
|
|
3017
|
+
}
|
|
3018
|
+
activeElement = next;
|
|
3019
|
+
}
|
|
3020
|
+
return activeElement;
|
|
3021
|
+
}
|
|
3022
|
+
function canReceiveFocus(el) {
|
|
3023
|
+
return (el instanceof HTMLElement && el.tabIndex >= 0 && !el.hasAttribute('disabled') && el.getAttribute('aria-hidden') !== 'true' && el.checkVisibility() && el.offsetParent !== null);
|
|
3024
|
+
}
|
|
3025
|
+
function findFormByRef(form, el) {
|
|
3026
|
+
if (form instanceof HTMLFormElement) {
|
|
3027
|
+
return form;
|
|
3028
|
+
}
|
|
3029
|
+
if (typeof form === 'string') {
|
|
3030
|
+
const el = document.getElementById(form);
|
|
3031
|
+
if (el) {
|
|
3032
|
+
if (el instanceof HTMLFormElement) {
|
|
3033
|
+
return el;
|
|
3034
|
+
}
|
|
3035
|
+
else {
|
|
3036
|
+
console.warn(`No Form found with selector: "#${form}". Verify that the element with id exists and is actually a <form> element.`, el);
|
|
3037
|
+
return null;
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
else {
|
|
3041
|
+
console.warn(`No Form found with selector: "#${form}". Verify that the id is correct and the form is rendered in the DOM.`, el);
|
|
3042
|
+
return null;
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
if (form !== undefined) {
|
|
3046
|
+
console.warn(`The provided "form" element is invalid. Verify that the form is a HTMLFormElement and rendered in the DOM.`, el);
|
|
3047
|
+
return null;
|
|
3048
|
+
}
|
|
3049
|
+
return el.closest('form');
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
class ElementActivationController {
|
|
3053
|
+
host;
|
|
3054
|
+
config;
|
|
3055
|
+
constructor(host, config) {
|
|
3056
|
+
this.host = host;
|
|
3057
|
+
this.config = config;
|
|
3058
|
+
}
|
|
3059
|
+
hostDidLoad() {
|
|
3060
|
+
if (!this.host.el.hasAttribute('tabindex')) {
|
|
3061
|
+
console.warn('Interactive element does not have a tabindex attribute!', this.host.el);
|
|
3062
|
+
}
|
|
3063
|
+
this.host.el.addEventListener('keydown', this.handleKeyDown.bind(this));
|
|
3064
|
+
this.host.el.addEventListener('click', this.handleActivation.bind(this));
|
|
3065
|
+
}
|
|
3066
|
+
handleKeyDown = (event) => {
|
|
3067
|
+
if ((this.config?.keys ?? ['Enter', ' ']).includes(event.key)) {
|
|
3068
|
+
event.preventDefault();
|
|
3069
|
+
this.handleActivation(event);
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
handleActivation = (event) => {
|
|
3073
|
+
this.host.lmvzActivation.emit();
|
|
3074
|
+
if (this.config?.localHandler) {
|
|
3075
|
+
this.config.localHandler(event);
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
class ReactiveControllerHost {
|
|
3081
|
+
controllers = new Set();
|
|
3082
|
+
addController(controller) {
|
|
3083
|
+
this.controllers.add(controller);
|
|
3084
|
+
}
|
|
3085
|
+
removeController(controller) {
|
|
3086
|
+
this.controllers.delete(controller);
|
|
3087
|
+
}
|
|
3088
|
+
get activeControllers() {
|
|
3089
|
+
return Array.from(this.controllers).filter(controller => !controller.disabled);
|
|
3090
|
+
}
|
|
3091
|
+
connectedCallback() {
|
|
3092
|
+
if (!this.controllers.size) {
|
|
3093
|
+
console.warn('ReactiveControllerHost connected with no controllers registered.', this);
|
|
3094
|
+
}
|
|
3095
|
+
this.activeControllers.forEach(controller => controller.hostConnected?.());
|
|
3096
|
+
}
|
|
3097
|
+
disconnectedCallback() {
|
|
3098
|
+
this.activeControllers.forEach(controller => controller.hostDisconnected?.());
|
|
3099
|
+
}
|
|
3100
|
+
componentWillLoad() {
|
|
3101
|
+
this.activeControllers.forEach(controller => controller.hostWillLoad?.());
|
|
3102
|
+
}
|
|
3103
|
+
componentDidLoad() {
|
|
3104
|
+
this.activeControllers.forEach(controller => controller.hostDidLoad?.());
|
|
3105
|
+
}
|
|
3106
|
+
componentWillRender() {
|
|
3107
|
+
this.activeControllers.forEach(controller => controller.hostWillRender?.());
|
|
3108
|
+
}
|
|
3109
|
+
componentDidRender() {
|
|
3110
|
+
this.activeControllers.forEach(controller => controller.hostDidRender?.());
|
|
3111
|
+
}
|
|
3112
|
+
componentWillUpdate() {
|
|
3113
|
+
this.activeControllers.forEach(controller => controller.hostWillUpdate?.());
|
|
3114
|
+
}
|
|
3115
|
+
componentDidUpdate() {
|
|
3116
|
+
this.activeControllers.forEach(controller => controller.hostDidUpdate?.());
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
class AriaValidationController {
|
|
3121
|
+
host;
|
|
3122
|
+
config;
|
|
3123
|
+
static get globalValidationEnabled() {
|
|
3124
|
+
return index.Build.isDev;
|
|
3125
|
+
}
|
|
3126
|
+
static axe = this.globalValidationEnabled ? Promise.resolve().then(function () { return require('./axe-C2rxi-K2.js'); }).then(function (n) { return n.axe; }) : null;
|
|
3127
|
+
static axeQueue = null;
|
|
3128
|
+
static axeStreamFiber = null;
|
|
3129
|
+
visibilityObserver;
|
|
3130
|
+
elementQueued = false;
|
|
3131
|
+
elementValidated = false;
|
|
3132
|
+
knownValidationErrors = [];
|
|
3133
|
+
get disabled() {
|
|
3134
|
+
return true;
|
|
3135
|
+
}
|
|
3136
|
+
constructor(host, config) {
|
|
3137
|
+
this.host = host;
|
|
3138
|
+
this.config = config;
|
|
3139
|
+
AriaValidationController.initializeAxeStream();
|
|
3140
|
+
}
|
|
3141
|
+
static initializeAxeStream() {
|
|
3142
|
+
if (!this.globalValidationEnabled)
|
|
3143
|
+
return;
|
|
3144
|
+
if (this.axeStreamFiber)
|
|
3145
|
+
return;
|
|
3146
|
+
const program = assets.gen(function* () {
|
|
3147
|
+
const queue = (AriaValidationController.axeQueue = yield* bounded(100));
|
|
3148
|
+
const axeLib = yield* assets.promise(() => AriaValidationController.axe);
|
|
3149
|
+
if (!axeLib) {
|
|
3150
|
+
console.error('Axe library not available, ARIA validation will not run.');
|
|
3151
|
+
return;
|
|
3152
|
+
}
|
|
3153
|
+
const stream = fromQueue(queue).pipe(mapEffect(({ context, onComplete }) => assets.async(resume => {
|
|
3154
|
+
axeLib.run(context, {}, (error, results) => {
|
|
3155
|
+
onComplete(error, results);
|
|
3156
|
+
resume(assets._void);
|
|
3157
|
+
});
|
|
3158
|
+
})));
|
|
3159
|
+
yield* runDrain(stream);
|
|
3160
|
+
});
|
|
3161
|
+
this.axeStreamFiber = assets.runFork(program);
|
|
3162
|
+
}
|
|
3163
|
+
hostDidLoad() {
|
|
3164
|
+
if (this.elementQueued || this.elementValidated)
|
|
3165
|
+
return;
|
|
3166
|
+
if (!this.host.el.checkVisibility()) {
|
|
3167
|
+
this.observeVisibilityOnce();
|
|
3168
|
+
return;
|
|
3169
|
+
}
|
|
3170
|
+
this.enqueueValidation();
|
|
3171
|
+
}
|
|
3172
|
+
hostDidUpdate() {
|
|
3173
|
+
this.checkLazyValidation();
|
|
3174
|
+
}
|
|
3175
|
+
hostDisconnected() {
|
|
3176
|
+
this.discardVisibilityObserver();
|
|
3177
|
+
}
|
|
3178
|
+
observeVisibilityOnce() {
|
|
3179
|
+
this.visibilityObserver = new IntersectionObserver(entries => {
|
|
3180
|
+
for (const entry of entries) {
|
|
3181
|
+
if (entry.target !== this.host.el)
|
|
3182
|
+
continue;
|
|
3183
|
+
if (!entry.isIntersecting)
|
|
3184
|
+
continue;
|
|
3185
|
+
this.checkLazyValidation();
|
|
3186
|
+
this.discardVisibilityObserver();
|
|
3187
|
+
}
|
|
3188
|
+
}, {
|
|
3189
|
+
root: this.host.el.parentElement,
|
|
3190
|
+
rootMargin: '0px',
|
|
3191
|
+
threshold: 0.01,
|
|
3192
|
+
});
|
|
3193
|
+
this.visibilityObserver.observe(this.host.el);
|
|
3194
|
+
}
|
|
3195
|
+
checkLazyValidation() {
|
|
3196
|
+
if (!this.config?.reValidateOnPropChanges && (this.elementQueued || this.elementValidated))
|
|
3197
|
+
return;
|
|
3198
|
+
this.enqueueValidation();
|
|
3199
|
+
}
|
|
3200
|
+
enqueueValidation() {
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
3203
|
+
discardVisibilityObserver() {
|
|
3204
|
+
if (!this.visibilityObserver)
|
|
3205
|
+
return;
|
|
3206
|
+
this.visibilityObserver.disconnect();
|
|
3207
|
+
this.visibilityObserver = undefined;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
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 { 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-selected, #f1f9fe); 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, #d4d4d4); } 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); } `;
|
|
3212
|
+
|
|
3213
|
+
const LmvzButton = class extends ReactiveControllerHost {
|
|
3214
|
+
get el() { return index.getElement(this); }
|
|
3215
|
+
inheritedAttributes = {};
|
|
3216
|
+
formEl = null;
|
|
3217
|
+
formButtonEl = null;
|
|
3218
|
+
lmvzActivation;
|
|
3219
|
+
get ti() {
|
|
3220
|
+
return 0;
|
|
3221
|
+
}
|
|
3222
|
+
scale = 'default';
|
|
3223
|
+
variant = 'secondary';
|
|
3224
|
+
disabled = false;
|
|
3225
|
+
type = 'button';
|
|
3226
|
+
form;
|
|
3227
|
+
constructor(hostRef) {
|
|
3228
|
+
super();
|
|
3229
|
+
index.registerInstance(this, hostRef);
|
|
3230
|
+
this.lmvzActivation = index.createEvent(this, "lmvzActivation");
|
|
3231
|
+
this.addController(new AriaValidationController(this));
|
|
3232
|
+
this.addController(new ElementActivationController(this, {
|
|
3233
|
+
localHandler: this.handleClick.bind(this),
|
|
3234
|
+
keys: ['Enter'],
|
|
3235
|
+
}));
|
|
3236
|
+
}
|
|
3237
|
+
connectedCallback() {
|
|
3238
|
+
this.inheritedAttributes = inheritAriaAttributes(this.el);
|
|
3239
|
+
}
|
|
3240
|
+
renderHiddenButton() {
|
|
3241
|
+
const formEl = (this.formEl = findFormByRef(this.form, this.el));
|
|
3242
|
+
if (!formEl)
|
|
3243
|
+
return;
|
|
3244
|
+
const { formButtonEl } = this;
|
|
3245
|
+
if (formButtonEl !== null && formEl.contains(formButtonEl))
|
|
3246
|
+
return;
|
|
3247
|
+
const newFormButtonEl = (this.formButtonEl = document.createElement('button'));
|
|
3248
|
+
newFormButtonEl.type = 'submit';
|
|
3249
|
+
newFormButtonEl.style.display = 'none';
|
|
3250
|
+
newFormButtonEl.disabled = this.disabled;
|
|
3251
|
+
formEl.appendChild(newFormButtonEl);
|
|
3252
|
+
}
|
|
3253
|
+
submitForm(ev) {
|
|
3254
|
+
if (this.formEl && this.formButtonEl) {
|
|
3255
|
+
ev.preventDefault();
|
|
3256
|
+
this.formButtonEl.click();
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
handleClick = (ev) => {
|
|
3260
|
+
if (this.type === 'submit') {
|
|
3261
|
+
this.submitForm(ev);
|
|
3262
|
+
}
|
|
3263
|
+
};
|
|
3264
|
+
render() {
|
|
3265
|
+
this.renderHiddenButton();
|
|
3266
|
+
return (index.h(index.Host, { key: '1c96281344dd604e2e4c919ea72907a9e934e5c6', "aria-disabled": this.disabled ? 'true' : null }, index.h("button", { key: '16728ce6fee7d121e7120aa993031777f6d8570e', disabled: this.disabled, class: classNames(this.variant, { [this.scale ?? '']: !!this.scale, disabled: this.disabled }), ...this.inheritedAttributes }, index.h("slot", { key: 'e1b0d95953bdbd42885eecdeef8b457070e7e247' }))));
|
|
3267
|
+
}
|
|
3268
|
+
static get delegatesFocus() { return true; }
|
|
3269
|
+
};
|
|
3270
|
+
LmvzButton.style = lmvzButtonCss();
|
|
3271
|
+
|
|
3272
|
+
class ListKeyboardNavigationController {
|
|
3273
|
+
host;
|
|
3274
|
+
elements = [];
|
|
3275
|
+
constructor(host) {
|
|
3276
|
+
this.host = host;
|
|
3277
|
+
}
|
|
3278
|
+
hostDidRender() {
|
|
3279
|
+
this.host.el.addEventListener('keydown', this.handleKeydown);
|
|
3280
|
+
}
|
|
3281
|
+
updateElements(elements) {
|
|
3282
|
+
this.elements = elements;
|
|
3283
|
+
}
|
|
3284
|
+
handleKeydown = (event) => {
|
|
3285
|
+
const { key } = event;
|
|
3286
|
+
if (!['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'].includes(key))
|
|
3287
|
+
return;
|
|
3288
|
+
const activeElement = getDeepActiveElement(document);
|
|
3289
|
+
const nextElement = this.getNextFocusableElement(activeElement, ['ArrowDown', 'ArrowRight'].includes(key) ? 'down' : 'up');
|
|
3290
|
+
if (nextElement) {
|
|
3291
|
+
event.preventDefault();
|
|
3292
|
+
nextElement.focus?.();
|
|
3293
|
+
}
|
|
3294
|
+
};
|
|
3295
|
+
getNextFocusableElement(current, direction) {
|
|
3296
|
+
const { elements } = this;
|
|
3297
|
+
const currentIndex = elements.indexOf(current);
|
|
3298
|
+
if (currentIndex === -1)
|
|
3299
|
+
return null;
|
|
3300
|
+
let nextIndex = null;
|
|
3301
|
+
if (direction === 'down') {
|
|
3302
|
+
nextIndex = (currentIndex + 1) % elements.length;
|
|
3303
|
+
}
|
|
3304
|
+
else if (direction === 'up') {
|
|
3305
|
+
nextIndex = (currentIndex - 1 + elements.length) % elements.length;
|
|
3306
|
+
}
|
|
3307
|
+
if (nextIndex == null)
|
|
3308
|
+
return null;
|
|
3309
|
+
const candidate = elements[nextIndex];
|
|
3310
|
+
if (!canReceiveFocus(candidate))
|
|
3311
|
+
return this.getNextFocusableElement(candidate, direction);
|
|
3312
|
+
return candidate;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
const lmvzHeaderCss = () => `:host{display:flex;width:100vw;flex-direction:row;align-items:center;box-sizing:border-box;background-color:var(--lmvz-semantic-color-surface-primary, #ffffff);--lmvz-header-x-spacing-level-1:var(--lmvz-dimension-8-28, clamp(0.5rem, 0.2rem + 1.29vw, 1.75rem));--lmvz-header-x-spacing-level-2:var(--lmvz-component-buttongroup-wrapper-gap-x, clamp(0.25rem, 0.16rem + 0.39vw, 0.63rem));padding:var(--lmvz-dimension-8-16, clamp(0.5rem, 0.38rem + 0.52vw, 1rem)) var(--lmvz-header-x-spacing-level-1);gap:var(--lmvz-header-x-spacing-level-1);.brand{display:inline-flex;justify-content:center;align-items:center}#fallback-logo-lmvz{height:34px;width:auto}nav{flex-grow:1}.primary-menubar{display:flex;flex-direction:row;align-items:center}.secondary-menubar{display:flex;flex-direction:row;align-items:center;margin-left:var(--lmvz-header-x-spacing-level-2);padding-left:var(--lmvz-header-x-spacing-level-2);border-left:1px solid var(--lmvz-semantic-color-border-default, #e0e0e0)}}`;
|
|
3317
|
+
|
|
3318
|
+
const LmvzHeader = class extends ReactiveControllerHost {
|
|
3319
|
+
get el() { return index.getElement(this); }
|
|
3320
|
+
primarySlot;
|
|
3321
|
+
secondarySlot;
|
|
3322
|
+
secondaryNav;
|
|
3323
|
+
keyboardNavigationController = new ListKeyboardNavigationController(this);
|
|
3324
|
+
get primaryMenuitems() {
|
|
3325
|
+
return this.primarySlot.assignedElements({ flatten: false });
|
|
3326
|
+
}
|
|
3327
|
+
get secondaryMenuitems() {
|
|
3328
|
+
return this.secondarySlot.assignedElements({ flatten: true });
|
|
3329
|
+
}
|
|
3330
|
+
get role() {
|
|
3331
|
+
return 'banner';
|
|
3332
|
+
}
|
|
3333
|
+
lmvzActiveNav;
|
|
3334
|
+
get secondarySlotName() {
|
|
3335
|
+
return `connect-nav-${this.lmvzActiveNav}`;
|
|
3336
|
+
}
|
|
3337
|
+
constructor(hostRef) {
|
|
3338
|
+
super();
|
|
3339
|
+
index.registerInstance(this, hostRef);
|
|
3340
|
+
this.addController(new AriaValidationController(this, { reValidateOnPropChanges: true }));
|
|
3341
|
+
this.addController(this.keyboardNavigationController);
|
|
3342
|
+
}
|
|
3343
|
+
handleActiveNavChange() {
|
|
3344
|
+
this.updateElementsActive();
|
|
3345
|
+
}
|
|
3346
|
+
componentDidLoad() {
|
|
3347
|
+
this.primarySlot.addEventListener('slotchange', this.handlePrimaryNavChange.bind(this));
|
|
3348
|
+
this.handlePrimaryNavChange();
|
|
3349
|
+
this.secondarySlot.addEventListener('slotchange', this.handleSecondaryNavChange.bind(this));
|
|
3350
|
+
}
|
|
3351
|
+
handlePrimaryNavChange() {
|
|
3352
|
+
const items = this.primaryMenuitems;
|
|
3353
|
+
if (!items.length) {
|
|
3354
|
+
console.warn('Primary slot has no assigned elements. Please add navigation items to the primary slot.');
|
|
3355
|
+
return;
|
|
3356
|
+
}
|
|
3357
|
+
items.forEach(el => {
|
|
3358
|
+
el.setAttribute('aria-haspopup', 'true');
|
|
3359
|
+
el.setAttribute('aria-controls', `nav-secondary`);
|
|
3360
|
+
});
|
|
3361
|
+
this.updateElementsActive();
|
|
3362
|
+
}
|
|
3363
|
+
handleSecondaryNavChange() {
|
|
3364
|
+
const items = this.secondaryMenuitems;
|
|
3365
|
+
if (!items.length) {
|
|
3366
|
+
return;
|
|
3367
|
+
}
|
|
3368
|
+
this.keyboardNavigationController.updateElements([...this.primaryMenuitems, ...this.secondaryMenuitems]);
|
|
3369
|
+
}
|
|
3370
|
+
updateElementsActive() {
|
|
3371
|
+
const items = this.primaryMenuitems;
|
|
3372
|
+
let label;
|
|
3373
|
+
items.forEach(el => {
|
|
3374
|
+
const isActive = el.id === this.lmvzActiveNav;
|
|
3375
|
+
if (isActive)
|
|
3376
|
+
label = el.textContent || el.id;
|
|
3377
|
+
el.setAttribute('aria-expanded', isActive ? 'true' : 'false');
|
|
3378
|
+
});
|
|
3379
|
+
this.secondaryNav.setAttribute('aria-label', `Untermenü für ${label}`);
|
|
3380
|
+
}
|
|
3381
|
+
delegateFocus() {
|
|
3382
|
+
const firstFocusable = this.primaryMenuitems[0];
|
|
3383
|
+
if (firstFocusable) {
|
|
3384
|
+
firstFocusable.focus();
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
render() {
|
|
3388
|
+
return (index.h(index.Host, { key: '58934683ff442801eb34f025ac809631f93a27e8', onFocus: this.delegateFocus.bind(this) }, index.h("div", { key: '35d3eadfabb70f83b313f946c8d31f9c223e8344', class: "brand" }, index.h("slot", { key: '5ce98314d980d63e1c87f508d96119aca2e702a9', name: "brand" }, index.h("lmvz-icon", { key: 'b24e61a9071d81948d506a8c545e012d3f0e5dd2', id: "fallback-logo-lmvz", icon: "Logo", size: "inherit", "aria-label": "Lehrmittelverlag Z\u00FCrich" }))), index.h("nav", { key: '1d5cc9010ef90e6cebc8a7b054db595f35f9e040', "aria-label": "Hauptnavigation" }, index.h("div", { key: '488a1b1544242562b57d76169f1988d84c611de4', role: "menubar", class: "primary-menubar" }, index.h("slot", { key: '59c6dd1442290931ed9a55f7bacc65ea4bb9ff6d', name: "nav-primary", ref: el => (this.primarySlot = el) }), index.h("separator", { key: '2729f0e8b115614c50c4a16b6684a3bdb21856b8' }), index.h("div", { key: '6b5bed5951bad9173fefdc78039e71c4ccc120b2', role: "menu", id: "nav-secondary", class: "secondary-menubar", hidden: !this.lmvzActiveNav, ref: el => (this.secondaryNav = el) }, index.h("slot", { key: '02f5a13e8851372c1698e3f786a8757a0a09c32f', name: this.secondarySlotName, ref: el => (this.secondarySlot = el) })))), index.h("div", { key: '53aafe8139bcea27d3039f64a48974cdb5aac5f9', class: "actions" }, index.h("slot", { key: 'f12ee19831073253e6ba8e251ba31ec403c21035', name: "actions" }))));
|
|
3389
|
+
}
|
|
3390
|
+
static get watchers() { return {
|
|
3391
|
+
"lmvzActiveNav": [{
|
|
3392
|
+
"handleActiveNavChange": 0
|
|
3393
|
+
}]
|
|
3394
|
+
}; }
|
|
3395
|
+
};
|
|
3396
|
+
LmvzHeader.style = lmvzHeaderCss();
|
|
3397
|
+
|
|
3398
|
+
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{width:var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.69rem + 0.26vw, 1rem));height:var(--lmvz-component-icon-size-xs, clamp(0.75rem, 0.69rem + 0.26vw, 1rem))}}[size='sm'].sc-lmvz-icon-h{svg{width:var(--lmvz-component-icon-size-sm, clamp(0.88rem, 0.81rem + 0.26vw, 1.13rem));height:var(--lmvz-component-icon-size-sm, clamp(0.88rem, 0.81rem + 0.26vw, 1.13rem))}}[size='md'].sc-lmvz-icon-h{svg{width:var(--lmvz-component-icon-size-md, clamp(1rem, 0.88rem + 0.52vw, 1.5rem));height:var(--lmvz-component-icon-size-md, clamp(1rem, 0.88rem + 0.52vw, 1.5rem))}}[size='lg'].sc-lmvz-icon-h{svg{width:var(--lmvz-component-icon-size-lg, clamp(1.5rem, 1.38rem + 0.52vw, 2rem));height:var(--lmvz-component-icon-size-lg, clamp(1.5rem, 1.38rem + 0.52vw, 2rem))}}[size='inherit'].sc-lmvz-icon-h{svg{width:inherit;height: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)}}`;
|
|
3399
|
+
|
|
3400
|
+
const LmvzIcon = class extends ReactiveControllerHost {
|
|
3401
|
+
intersectionObserver;
|
|
3402
|
+
get el() { return index.getElement(this); }
|
|
3403
|
+
icon;
|
|
3404
|
+
weight = 'medium';
|
|
3405
|
+
size = 'md';
|
|
3406
|
+
iconData;
|
|
3407
|
+
visible = false;
|
|
3408
|
+
ariaLabel;
|
|
3409
|
+
get ariaHidden() {
|
|
3410
|
+
return !this.ariaLabel;
|
|
3411
|
+
}
|
|
3412
|
+
constructor(hostRef) {
|
|
3413
|
+
super();
|
|
3414
|
+
index.registerInstance(this, hostRef);
|
|
3415
|
+
this.addController(new AriaValidationController(this));
|
|
3416
|
+
}
|
|
3417
|
+
connectedCallback() {
|
|
3418
|
+
this.waitUntilVisible(() => {
|
|
3419
|
+
this.visible = true;
|
|
3420
|
+
this.loadIconPathData();
|
|
3421
|
+
});
|
|
3422
|
+
}
|
|
3423
|
+
disconnectedCallback() {
|
|
3424
|
+
if (this.intersectionObserver) {
|
|
3425
|
+
this.intersectionObserver.disconnect();
|
|
3426
|
+
this.intersectionObserver = null;
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
async loadIconPathData() {
|
|
3430
|
+
const { icon, visible } = this;
|
|
3431
|
+
if (!icon || !visible) {
|
|
3432
|
+
return;
|
|
3433
|
+
}
|
|
3434
|
+
this.iconData = await assets.runPromise(icons.fetchIconSvg(this.icon).pipe(assets.tapError(error => assets.logError(`Error loading icon "${icon}":`, error.message, error.cause, error.stack)), assets.catchAll$1(() => assets.succeed$1(icons.emptyDefaultSvg()))));
|
|
3435
|
+
}
|
|
3436
|
+
render() {
|
|
3437
|
+
return index.h(index.Host, { key: '50d0f96ec5085a47ca7783e5232dfb503fa32d29', role: "img", "aria-hidden": `${this.ariaHidden}`, innerHTML: this.iconData });
|
|
3438
|
+
}
|
|
3439
|
+
waitUntilVisible(callback, rootMargin = 50) {
|
|
3440
|
+
if (typeof window === 'undefined' || !window.IntersectionObserver) {
|
|
3441
|
+
callback();
|
|
3442
|
+
return;
|
|
3443
|
+
}
|
|
3444
|
+
this.intersectionObserver = new IntersectionObserver(entries => {
|
|
3445
|
+
entries.some(entry => {
|
|
3446
|
+
if (entry.isIntersecting) {
|
|
3447
|
+
this.intersectionObserver.disconnect();
|
|
3448
|
+
this.intersectionObserver = null;
|
|
3449
|
+
callback();
|
|
3450
|
+
return true;
|
|
3451
|
+
}
|
|
3452
|
+
return false;
|
|
3453
|
+
});
|
|
3454
|
+
}, { rootMargin: `${rootMargin}px` });
|
|
3455
|
+
this.intersectionObserver.observe(this.el);
|
|
3456
|
+
}
|
|
3457
|
+
static get assetsDirs() { return ["../../assets/icons"]; }
|
|
3458
|
+
static get watchers() { return {
|
|
3459
|
+
"icon": [{
|
|
3460
|
+
"loadIconPathData": 0
|
|
3461
|
+
}]
|
|
3462
|
+
}; }
|
|
3463
|
+
};
|
|
3464
|
+
LmvzIcon.style = lmvzIconCss();
|
|
3465
|
+
|
|
3466
|
+
const lmvzInputCss = () => `@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-input-h { display: block; font-family: var(--lmvz-global-font-family-default, Router); --input-radius: var(--lmvz-component-input-radius-default, 999px); --input-bg: var(--lmvz-semantic-color-surface-input-primary, #ffffff); --input-border-color: var(--lmvz-semantic-color-border-default, #e0e0e0); --input-border-color-hover: var(--lmvz-semantic-color-border-hover, #c7c7c7); --input-border-color-focus: var(--lmvz-semantic-color-status-on-selected, #0e7ab4); --input-border-width: var(--lmvz-semantic-border-width-default, 1px); --input-height: 48px; --input-padding-x: 16px; --label-color: var(--lmvz-semantic-color-on-surface-input-secondary, #7a7a7a); --input-text-color: var(--lmvz-semantic-color-on-surface-input-primary, #000000); --helper-text-color: var(--lmvz-semantic-color-on-surface-input-secondary, #7a7a7a); --error-text-color: var(--lmvz-semantic-color-status-on-danger, #e52a31); --label-floating-scale: 0.85; --label-minimized-top: -6px; --label-minimized-bg: var(--input-bg); --label-minimized-padding-x: 4px; --input-disabled-opacity: var(--lmvz-component-input-disabled-opacity, 40%); } .input-container.sc-lmvz-input { display: flex; flex-direction: column; position: relative; width: 100%; } .input-wrapper.sc-lmvz-input { background-color: var(--input-bg); border: var(--input-border-width) solid var(--input-border-color); border-radius: var(--input-radius); display: flex; align-items: center; height: var(--input-height); padding: 0 var(--input-padding-x); position: relative; transition: border-color 0.2s ease; gap: 8px; } [disabled].sc-lmvz-input-h .input-wrapper.sc-lmvz-input { opacity: var(--input-disabled-opacity); cursor: not-allowed; pointer-events: none; } .input-container.sc-lmvz-input:focus-within .input-wrapper.sc-lmvz-input { border-color: var(--input-border-color-focus); outline: 2px solid var(--input-border-color-focus); outline-offset: 2px; } .input-container.sc-lmvz-input:has(input:focus-visible) .input-wrapper.sc-lmvz-input { box-shadow: 0 0 0 3px rgb(0 86 214 / 20%); } [error].sc-lmvz-input-h .input-wrapper.sc-lmvz-input { border-color: var(--error-text-color); } [error].sc-lmvz-input-h:focus-within .input-wrapper.sc-lmvz-input { border-color: var(--error-text-color); outline-color: var(--error-text-color); } .sc-lmvz-input-h:not([disabled]) .input-wrapper.sc-lmvz-input:hover { border-color: var(--input-border-color-hover); } .label-input-group.sc-lmvz-input { position: relative; flex-grow: 1; display: flex; align-items: center; height: 100%; } label.sc-lmvz-input { position: absolute; left: 0; top: 50%; transform: translateY(-50%); color: var(--label-color); font-size: 14px; font-family: Router, sans-serif; font-weight: 400; pointer-events: none; transition: all 0.2s ease-out; background-color: transparent; padding: 0; margin: 0; line-height: normal; white-space: nowrap; } label.floating.sc-lmvz-input { top: 0; transform: translateY(-50%) scale(0.85); transform-origin: left top; background-color: var(--label-minimized-bg); padding: 0 var(--label-minimized-padding-x); left: -2px; color: var(--input-text-color); font-weight: 500; } .required-indicator.sc-lmvz-input { color: var(--error-text-color); margin-left: 2px; } input.sc-lmvz-input { border: none; background: transparent; width: 100%; height: 100%; color: var(--input-text-color); font-family: inherit; font-size: 14px; outline: none; padding: 0; margin: 0; font-weight: 400; } input.sc-lmvz-input::placeholder { color: var(--label-color); } .helper-text.sc-lmvz-input { padding-top: 8px; padding-left: 12px; font-size: 12px; color: var(--helper-text-color); font-family: Router, sans-serif; font-weight: 500; } .error-message.sc-lmvz-input { padding-top: 8px; padding-left: 12px; font-size: 12px; color: var(--error-text-color); font-family: Router, sans-serif; font-weight: 500; } .sc-lmvz-input-s > lmvz-button { --lmvz-button-padding: 4px; }`;
|
|
3467
|
+
|
|
3468
|
+
let inputIdCounter = 0;
|
|
3469
|
+
const LmvzInput = class extends ReactiveControllerHost {
|
|
3470
|
+
get el() { return index.getElement(this); }
|
|
3471
|
+
lmvzInput;
|
|
3472
|
+
internals;
|
|
3473
|
+
nativeInputElement;
|
|
3474
|
+
inputId = `lmvz-input-${inputIdCounter++}`;
|
|
3475
|
+
initialValue = '';
|
|
3476
|
+
nativeError = false;
|
|
3477
|
+
errorFromProp = false;
|
|
3478
|
+
get helperId() {
|
|
3479
|
+
return this.helperText ? `${this.inputId}-helper` : undefined;
|
|
3480
|
+
}
|
|
3481
|
+
get showErrorMessage() {
|
|
3482
|
+
return this.error && Boolean(this.errorMessage);
|
|
3483
|
+
}
|
|
3484
|
+
get errorId() {
|
|
3485
|
+
return `${this.inputId}-error`;
|
|
3486
|
+
}
|
|
3487
|
+
get describedBy() {
|
|
3488
|
+
const ids = [];
|
|
3489
|
+
if (this.helperId)
|
|
3490
|
+
ids.push(this.helperId);
|
|
3491
|
+
if (this.showErrorMessage)
|
|
3492
|
+
ids.push(this.errorId);
|
|
3493
|
+
return ids.length > 0 ? ids.join(' ') : undefined;
|
|
3494
|
+
}
|
|
3495
|
+
value;
|
|
3496
|
+
label;
|
|
3497
|
+
helperText;
|
|
3498
|
+
placeholder;
|
|
3499
|
+
disabled = false;
|
|
3500
|
+
readonly = false;
|
|
3501
|
+
required = false;
|
|
3502
|
+
name;
|
|
3503
|
+
type = 'text';
|
|
3504
|
+
errorMessage;
|
|
3505
|
+
autocomplete;
|
|
3506
|
+
inputmode;
|
|
3507
|
+
autocorrect;
|
|
3508
|
+
autocapitalize;
|
|
3509
|
+
spellcheck;
|
|
3510
|
+
autofocus = false;
|
|
3511
|
+
minlength;
|
|
3512
|
+
maxlength;
|
|
3513
|
+
pattern;
|
|
3514
|
+
min;
|
|
3515
|
+
max;
|
|
3516
|
+
step;
|
|
3517
|
+
form;
|
|
3518
|
+
get error() {
|
|
3519
|
+
return this.errorFromProp || this.nativeError;
|
|
3520
|
+
}
|
|
3521
|
+
set error(value) {
|
|
3522
|
+
this.errorFromProp = value;
|
|
3523
|
+
}
|
|
3524
|
+
async setValue(newValue) {
|
|
3525
|
+
const input = this.nativeInputElement;
|
|
3526
|
+
this.value = input.value = newValue ?? '';
|
|
3527
|
+
this.internals.setFormValue?.(newValue);
|
|
3528
|
+
this.lmvzInput.emit(newValue);
|
|
3529
|
+
}
|
|
3530
|
+
async focusInput() {
|
|
3531
|
+
this.nativeInputElement?.focus();
|
|
3532
|
+
}
|
|
3533
|
+
async blurInput() {
|
|
3534
|
+
this.nativeInputElement?.blur();
|
|
3535
|
+
}
|
|
3536
|
+
async select() {
|
|
3537
|
+
this.nativeInputElement?.select();
|
|
3538
|
+
}
|
|
3539
|
+
async checkValidity() {
|
|
3540
|
+
return this.nativeInputElement?.checkValidity?.() ?? false;
|
|
3541
|
+
}
|
|
3542
|
+
async reportValidity() {
|
|
3543
|
+
return this.nativeInputElement?.reportValidity?.() ?? false;
|
|
3544
|
+
}
|
|
3545
|
+
async getInputElement() {
|
|
3546
|
+
if (!this.nativeInputElement) {
|
|
3547
|
+
await new Promise(resolve => componentOnReady(this.el, resolve));
|
|
3548
|
+
}
|
|
3549
|
+
return Promise.resolve(this.nativeInputElement);
|
|
3550
|
+
}
|
|
3551
|
+
constructor(hostRef) {
|
|
3552
|
+
super();
|
|
3553
|
+
index.registerInstance(this, hostRef);
|
|
3554
|
+
this.lmvzInput = index.createEvent(this, "lmvzInput");
|
|
3555
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
3556
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
3557
|
+
}
|
|
3558
|
+
else {
|
|
3559
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
3560
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
3561
|
+
}
|
|
3562
|
+
this.addController(new AriaValidationController(this, {
|
|
3563
|
+
reValidateOnPropChanges: true,
|
|
3564
|
+
}));
|
|
3565
|
+
}
|
|
3566
|
+
componentWillLoad() {
|
|
3567
|
+
this.initialValue = this.value;
|
|
3568
|
+
}
|
|
3569
|
+
formAssociatedCallback(form) {
|
|
3570
|
+
if (!form)
|
|
3571
|
+
return;
|
|
3572
|
+
this.internals.setFormValue?.(this.value);
|
|
3573
|
+
}
|
|
3574
|
+
formResetCallback() {
|
|
3575
|
+
this.internals.setValidity({});
|
|
3576
|
+
this.setValue(this.initialValue);
|
|
3577
|
+
}
|
|
3578
|
+
formStateRestoreCallback(state) {
|
|
3579
|
+
this.setValue(state);
|
|
3580
|
+
}
|
|
3581
|
+
handleValueChange(newValue) {
|
|
3582
|
+
if (!this.nativeInputElement)
|
|
3583
|
+
return;
|
|
3584
|
+
const isInternalChange = this.nativeInputElement.value === newValue;
|
|
3585
|
+
if (isInternalChange)
|
|
3586
|
+
return;
|
|
3587
|
+
this.setValue(newValue);
|
|
3588
|
+
}
|
|
3589
|
+
handleDisabledChange(disabled) {
|
|
3590
|
+
if (disabled && this.nativeInputElement) {
|
|
3591
|
+
this.nativeInputElement.blur();
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
handleInput = (event) => {
|
|
3595
|
+
const input = event.target;
|
|
3596
|
+
this.setValue(input.value);
|
|
3597
|
+
};
|
|
3598
|
+
handleChange = (event) => {
|
|
3599
|
+
const input = event.target ?? this.nativeInputElement;
|
|
3600
|
+
this.updateNativeError(input);
|
|
3601
|
+
};
|
|
3602
|
+
handleFocus = () => { };
|
|
3603
|
+
handleBlur = (event) => {
|
|
3604
|
+
const input = event.target;
|
|
3605
|
+
input.reportValidity?.();
|
|
3606
|
+
};
|
|
3607
|
+
updateNativeError(fromEvent) {
|
|
3608
|
+
const input = fromEvent ?? this.nativeInputElement;
|
|
3609
|
+
if (!input)
|
|
3610
|
+
return;
|
|
3611
|
+
this.nativeError = !(input.checkValidity?.() ?? true);
|
|
3612
|
+
}
|
|
3613
|
+
render() {
|
|
3614
|
+
const hasValue = Boolean(this.value);
|
|
3615
|
+
const shouldFloatLabel = hasValue || Boolean(this.placeholder);
|
|
3616
|
+
return (index.h("div", { key: '402189a211eec970a9f5b8fcc551c6c3508bec05', class: classNames('input-container', {
|
|
3617
|
+
'interaction-filled': hasValue,
|
|
3618
|
+
}) }, index.h("div", { key: '1cbe6011f14774e1226406ef4fe301fd94338444', class: "input-wrapper" }, index.h("slot", { key: 'ea0f30124315c88e9721bb4457126bd6cf18110a', name: "before-input" }), index.h("div", { key: 'f630b5f3a33a961f94b5a782b0ce6b4d49d1958c', class: "label-input-group" }, index.h("label", { key: 'dbb3fe066ebf93f7fcbe6973a1e37685d7206888', htmlFor: this.inputId, class: classNames({ floating: shouldFloatLabel }) }, this.label, this.required && (index.h("span", { key: '7c1a2458b66becb45c730bfe3ff0c570293f702f', class: "required-indicator", "aria-hidden": "true" }, ' ', "*"))), index.h("input", { key: '14b14457e200d20faf9053848662743dfe1cf417', 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 })), index.h("slot", { key: '4b530738ff7404eb1bcecc10a0388570e2243cf3', name: "after-input" })), this.helperText && (index.h("div", { key: 'f1a287047e9b4d58aa90af157d50b3d564555e9b', id: this.helperId, class: "helper-text" }, this.helperText)), this.showErrorMessage && (index.h("div", { key: '2a25c4a88a63363cdd814f1d4fead5e8a238621b', id: this.errorId, class: "error-message", role: "alert" }, this.errorMessage))));
|
|
3619
|
+
}
|
|
3620
|
+
static get formAssociated() { return true; }
|
|
3621
|
+
static get watchers() { return {
|
|
3622
|
+
"value": [{
|
|
3623
|
+
"handleValueChange": 0
|
|
3624
|
+
}],
|
|
3625
|
+
"disabled": [{
|
|
3626
|
+
"handleDisabledChange": 0
|
|
3627
|
+
}]
|
|
3628
|
+
}; }
|
|
3629
|
+
};
|
|
3630
|
+
LmvzInput.style = lmvzInputCss();
|
|
3631
|
+
|
|
3632
|
+
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-selected, #f1f9fe); --lmvz-menuitem-color: var(--lmvz-semantic-color-status-on-selected, #0e7ab4); }`;
|
|
3633
|
+
|
|
3634
|
+
const LmvzMenuItem = class extends ReactiveControllerHost {
|
|
3635
|
+
get el() { return index.getElement(this); }
|
|
3636
|
+
get role() {
|
|
3637
|
+
return 'menuitem';
|
|
3638
|
+
}
|
|
3639
|
+
get ti() {
|
|
3640
|
+
return 0;
|
|
3641
|
+
}
|
|
3642
|
+
lmvzActivation;
|
|
3643
|
+
constructor(hostRef) {
|
|
3644
|
+
super();
|
|
3645
|
+
index.registerInstance(this, hostRef);
|
|
3646
|
+
this.lmvzActivation = index.createEvent(this, "lmvzActivation");
|
|
3647
|
+
this.addController(new AriaValidationController(this));
|
|
3648
|
+
this.addController(new ElementActivationController(this));
|
|
3649
|
+
}
|
|
3650
|
+
render() {
|
|
3651
|
+
return (index.h(index.Host, { key: '44399be11122af25d05e5b3b5f05dd90a89fddc4' }, index.h("slot", { key: '2809f9e89a0c38af4d3f1f17ad78397487370134' })));
|
|
3652
|
+
}
|
|
3653
|
+
};
|
|
3654
|
+
LmvzMenuItem.style = lmvzMenuitemCss();
|
|
3655
|
+
|
|
3656
|
+
exports.HeaderIntegration = HeaderIntegration;
|
|
3657
|
+
exports.LmvzButton = LmvzButton;
|
|
3658
|
+
exports.LmvzHeader = LmvzHeader;
|
|
3659
|
+
exports.LmvzIcon = LmvzIcon;
|
|
3660
|
+
exports.LmvzInput = LmvzInput;
|
|
3661
|
+
exports.LmvzMenuItem = LmvzMenuItem;
|
|
3662
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
3663
|
+
//# sourceMappingURL=header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-BTL_B6qg.js.map
|
|
3664
|
+
|
|
3665
|
+
//# sourceMappingURL=header-integration.lmvz-button.lmvz-header.lmvz-icon.lmvz-input.lmvz-menuitem-BTL_B6qg.js.map
|