@bud.sh/app 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -31
- package/dist/client/assets/bud/design.js +1 -1
- package/dist/client/assets/canvas-Bih9EdKJ.js +1 -0
- package/dist/client/assets/difference-worker-Bzg-rizy.js +8 -0
- package/dist/client/assets/dist-CdE5wBkg.js +5 -0
- package/dist/client/assets/files-1dLuoM2f.js +1 -0
- package/dist/client/assets/i18n-CkO6VFI0.js +1 -0
- package/dist/client/assets/index-Cn2mxroU.css +2 -0
- package/dist/client/assets/{index-Dn2pfmXf.js → index-DtISWZp9.js} +2 -2
- package/dist/client/assets/pages-BJ-tNJ4J.js +1 -0
- package/dist/client/assets/{project-branches-CMGRmrqr.js → project-branches-Ce3rXrkc.js} +1 -1
- package/dist/client/assets/project-comments-CPUONfs8.js +1 -0
- package/dist/client/assets/project-thread-links-C-TGkq59.js +1 -0
- package/dist/client/assets/{project-threads-ZbKDh78d.js → project-threads-Bv7IDBgi.js} +105 -105
- package/dist/client/assets/project-work-DAE9-olg.js +1 -0
- package/dist/client/assets/{task-design-BPpc4Gd7.js → task-design-CwySIAOl.js} +3 -3
- package/dist/client/assets/tasks-KWsCLi_h.js +3 -0
- package/dist/client/assets/wasm-inline-DSUyFn1L.js +1 -0
- package/dist/client/assets/workspace-CVdcfaaB.js +2 -0
- package/dist/client/index.html +3 -3
- package/dist/hosted/assets/{canvas-BYTOp1p7.js → canvas-AII16n9i.js} +97 -6
- package/dist/hosted/assets/{comment-data-Cn5y2VxV.js → comment-data-BXfMElfx.js} +1998 -381
- package/dist/hosted/assets/dist-BCSTeNf4.js +4785 -0
- package/dist/hosted/assets/{files-B1P2_24q.js → files-D_1yeAVO.js} +10 -5
- package/dist/hosted/assets/{pages-B0ZlVdci.js → pages-CN_SbKWA.js} +3 -3
- package/dist/hosted/assets/{project-branches-DlCWmfRo.js → project-branches-Bxp0DCwg.js} +1 -1
- package/dist/hosted/assets/{project-thread-links-BZXQ200n.js → project-thread-links-KqQoKBLE.js} +76 -4
- package/dist/{node-host/assets/screen-DapOVrga.js → hosted/assets/screen-DpAcDUKR.js} +25 -1
- package/dist/hosted/assets/tasks-D66LlwxM.js +1423 -0
- package/dist/hosted/assets/wasm-inline-Dl9tqabx.js +4 -0
- package/dist/hosted/hosted.js +7885 -6219
- package/dist/node/assets/Stream-CAm1eJ2n.js +16604 -0
- package/dist/{server/assets/bridge-B_Blt55E.js → node/assets/bridge-DQSBYHmw.js} +124 -290
- package/dist/node/assets/config-9_jWwNBh.js +1067 -0
- package/dist/node/assets/load-config.server-CMVtRVmO.js +261 -0
- package/dist/node/assets/module-3GgtT4Xs.js +308 -0
- package/dist/node/assets/server-DTQFuoX2.js +846 -0
- package/dist/node/assets/src-D-kG1GxB.js +2 -0
- package/dist/node/assets/{src-CerrKjID.js → src-Dwe9APUx.js} +93 -3
- package/dist/node/assets/src-DysjfbM8.js +8592 -0
- package/dist/node/bridge.js +1 -845
- package/dist/node/cli.js +206 -0
- package/dist/node/design.js +811 -8
- package/dist/node/index.js +2 -739
- package/dist/node/plugins.js +5711 -0
- package/dist/node/server.js +1 -6746
- package/dist/node/vite.js +121 -0
- package/dist/{server/assets/canvas-CkMK4hoN.js → node-host/assets/canvas-BeDoufy1.js} +97 -7
- package/dist/node-host/assets/{comment-data-yfWEdDQL.js → comment-data-DE2T9yTj.js} +1974 -355
- package/dist/node-host/assets/dist-BCSTeNf4.js +4785 -0
- package/dist/node-host/assets/{files-anHi-apm.js → files-Dl-PTS09.js} +11 -6
- package/dist/node-host/assets/{pages-CW4aF6dK.js → pages-DL2sk6_U.js} +3 -3
- package/dist/node-host/assets/{project-branches-D7rVCxQX.js → project-branches-DGp5ELct.js} +1 -1
- package/dist/{server/assets/project-thread-links-lLS_rq7c.js → node-host/assets/project-thread-links-CgBV3Jcm.js} +76 -5
- package/dist/{hosted/assets/screen-CfdC3NbR.js → node-host/assets/screen-B55yyVfb.js} +25 -1
- package/dist/node-host/assets/tasks-DZRNkoxe.js +1425 -0
- package/dist/node-host/assets/wasm-inline-Dl9tqabx.js +4 -0
- package/dist/node-host/node-host.js +6127 -4438
- package/dist/server/assets/{branch-previews-ClkoJ0lM.js → branch-previews-DedrpnVR.js} +1555 -673
- package/dist/{node-host/assets/canvas-DxmcFZCh.js → server/assets/canvas-CJWQ-jjv.js} +98 -6
- package/dist/server/assets/{comment-data-NLeHG89b.js → comment-data-Rg42ToTW.js} +1660 -26
- package/dist/server/assets/dist-BCSTeNf4.js +4785 -0
- package/dist/server/assets/{events-iHpLGr3k.js → events-BH_rAu7O.js} +155 -20
- package/dist/server/assets/{files-CRdl489E.js → files-CPJqKeMo.js} +12 -7
- package/dist/server/assets/{listener-BAYn9Q-u.js → listener-D61O6PzF.js} +708 -12
- package/dist/server/assets/{pages-DXVlJlBC.js → pages-KJY_Ba92.js} +4 -4
- package/dist/server/assets/{project-branches-CwTsf6WQ.js → project-branches-qG9ACZvo.js} +2 -2
- package/dist/{node-host/assets/project-thread-links-m-OLpsD9.js → server/assets/project-thread-links-CqK0lqCF.js} +77 -4
- package/dist/{node-host/assets/tasks-request-B0aeNocI.js → server/assets/project-work-DoIwxWMm.js} +87 -2
- package/dist/server/assets/run-BJ8r5jSh.js +572 -0
- package/dist/server/assets/{screen-B1zH_1O3.js → screen-CBrHPFug.js} +26 -2
- package/dist/server/assets/{server-DxK-UB_Z.js → server-Dkbp5stG.js} +1521 -793
- package/dist/server/assets/{services-BRrgXYlT.js → services-BTfig8A8.js} +234 -997
- package/dist/server/assets/tasks-Bgu5Lg9Y.js +1427 -0
- package/dist/server/assets/wasm-inline-Dl9tqabx.js +4 -0
- package/dist/server/capture.js +1 -2
- package/dist/server/migration.js +569 -12
- package/dist/server/runtime.js +7 -5
- package/dist/server/server.js +3 -3
- package/dist/types/assets/{config-DIC2cf_S.d.ts → config-CvcYmE2s.d.ts} +188 -50
- package/dist/types/assets/{contract-CAT-XFNq.d.ts → contract-B7yuuqSn.d.ts} +44 -2
- package/dist/types/assets/{items-CaVkByHk.d.ts → items-BQdaVksf.d.ts} +12 -1
- package/dist/types/assets/memory-state-BBW-FAVA.d.ts +236 -0
- package/dist/types/assets/picker-Be5Gx4WR.d.ts +9 -0
- package/dist/types/assets/{task-design-xJOhRNWh.d.ts → task-design-BDHKFHpp.d.ts} +3 -1
- package/dist/types/bridge.d.ts +1 -1
- package/dist/types/companion.d.ts +3 -3
- package/dist/types/design.d.ts +2 -2
- package/dist/types/hosted.d.ts +3 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/node-host.d.ts +2 -2
- package/dist/types/plugins.d.ts +445 -0
- package/dist/types/screen.d.ts +2 -2
- package/dist/types/server.d.ts +2 -228
- package/dist/types/vite.d.ts +16 -0
- package/package.json +19 -3
- package/dist/client/assets/canvas-8GXJIuDK.js +0 -1
- package/dist/client/assets/difference-worker-C99ychYw.js +0 -8
- package/dist/client/assets/files-DkWt1l9H.js +0 -1
- package/dist/client/assets/i18n-hH_Ba5QO.js +0 -1
- package/dist/client/assets/index-tpHYVXma.css +0 -2
- package/dist/client/assets/pages-BVd6MQmu.js +0 -1
- package/dist/client/assets/project-comments-D1IIQwsW.js +0 -1
- package/dist/client/assets/project-thread-links-DKwe_SYb.js +0 -1
- package/dist/client/assets/project-work-D4DZqBCZ.js +0 -1
- package/dist/client/assets/tasks-Cn0VOZ9Z.js +0 -1
- package/dist/client/assets/tasks-request-BLyOzokZ.js +0 -1
- package/dist/client/assets/workspace-DGErsSg6.js +0 -2
- package/dist/hosted/assets/tasks-_yKh2Z6q.js +0 -649
- package/dist/hosted/assets/tasks-request-CFPLvLc7.js +0 -113
- package/dist/node-host/assets/tasks-BBK_CybR.js +0 -651
- package/dist/server/assets/project-work-CSZlCwH-.js +0 -88
- package/dist/server/assets/tasks-CGdz-uox.js +0 -652
- package/dist/server/assets/tasks-request-D2NBjCTl.js +0 -115
- package/dist/types/assets/picker-D1Bw3ndx.d.ts +0 -14
|
@@ -2752,9 +2752,9 @@ var Prototype = (options) => makePrimitiveProto({
|
|
|
2752
2752
|
/**
|
|
2753
2753
|
* @since 2.0.0
|
|
2754
2754
|
*/
|
|
2755
|
-
var TypeId$
|
|
2755
|
+
var TypeId$29 = "~effect/Option";
|
|
2756
2756
|
var CommonProto$1 = {
|
|
2757
|
-
[TypeId$
|
|
2757
|
+
[TypeId$29]: { _A: (_) => _ },
|
|
2758
2758
|
...PipeInspectableProto,
|
|
2759
2759
|
[Symbol.iterator]() {
|
|
2760
2760
|
return new SingleShotGen(this);
|
|
@@ -2804,13 +2804,13 @@ var NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(CommonPr
|
|
|
2804
2804
|
}
|
|
2805
2805
|
});
|
|
2806
2806
|
/** @internal */
|
|
2807
|
-
var isOption = (input) => hasProperty(input, TypeId$
|
|
2807
|
+
var isOption = (input) => hasProperty(input, TypeId$29);
|
|
2808
2808
|
/** @internal */
|
|
2809
2809
|
var isNone$1 = (fa) => fa._tag === "None";
|
|
2810
2810
|
/** @internal */
|
|
2811
2811
|
var isSome$1 = (fa) => fa._tag === "Some";
|
|
2812
2812
|
/** @internal */
|
|
2813
|
-
var none$
|
|
2813
|
+
var none$2 = /*#__PURE__*/ Object.create(NoneProto);
|
|
2814
2814
|
/** @internal */
|
|
2815
2815
|
var SomeImpl = function(value) {
|
|
2816
2816
|
this.value = value;
|
|
@@ -2820,9 +2820,9 @@ SomeImpl.prototype = SomeProto;
|
|
|
2820
2820
|
var some$1 = (value) => new SomeImpl(value);
|
|
2821
2821
|
//#endregion
|
|
2822
2822
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/result.js
|
|
2823
|
-
var TypeId$
|
|
2823
|
+
var TypeId$28 = "~effect/Result";
|
|
2824
2824
|
var CommonProto = {
|
|
2825
|
-
[TypeId$
|
|
2825
|
+
[TypeId$28]: {
|
|
2826
2826
|
/* v8 ignore next 2 */
|
|
2827
2827
|
_A: (_) => _,
|
|
2828
2828
|
_E: (_) => _
|
|
@@ -2873,7 +2873,7 @@ var FailureProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Commo
|
|
|
2873
2873
|
}
|
|
2874
2874
|
});
|
|
2875
2875
|
/** @internal */
|
|
2876
|
-
var isResult = (input) => hasProperty(input, TypeId$
|
|
2876
|
+
var isResult = (input) => hasProperty(input, TypeId$28);
|
|
2877
2877
|
/** @internal */
|
|
2878
2878
|
var isFailure$2 = (result) => result._tag === "Failure";
|
|
2879
2879
|
/** @internal */
|
|
@@ -2884,7 +2884,7 @@ var FailureImpl = function(failure) {
|
|
|
2884
2884
|
};
|
|
2885
2885
|
FailureImpl.prototype = FailureProto;
|
|
2886
2886
|
/** @internal */
|
|
2887
|
-
var fail$
|
|
2887
|
+
var fail$10 = (failure) => new FailureImpl(failure);
|
|
2888
2888
|
/** @internal */
|
|
2889
2889
|
var SuccessImpl = function(success) {
|
|
2890
2890
|
this.success = success;
|
|
@@ -3203,7 +3203,7 @@ var isGreaterThanOrEqualTo$1 = (O) => dual(2, (self, that) => O(self, that) !==
|
|
|
3203
3203
|
* @category constructors
|
|
3204
3204
|
* @since 2.0.0
|
|
3205
3205
|
*/
|
|
3206
|
-
var none = () => none$
|
|
3206
|
+
var none$1 = () => none$2;
|
|
3207
3207
|
/**
|
|
3208
3208
|
* Wraps the given value into an `Option` to represent its presence.
|
|
3209
3209
|
*
|
|
@@ -3414,7 +3414,7 @@ var orElse = /*#__PURE__*/ dual(2, (self, that) => isNone(self) ? that() : self)
|
|
|
3414
3414
|
* @category converting
|
|
3415
3415
|
* @since 4.0.0
|
|
3416
3416
|
*/
|
|
3417
|
-
var fromNullishOr = (a) => a == null ? none() : some(a);
|
|
3417
|
+
var fromNullishOr = (a) => a == null ? none$1() : some(a);
|
|
3418
3418
|
/**
|
|
3419
3419
|
* Extracts the value from a `Some`, or returns `null` for `None`.
|
|
3420
3420
|
*
|
|
@@ -3504,7 +3504,7 @@ var getOrUndefined$1 = /*#__PURE__*/ getOrElse(constUndefined);
|
|
|
3504
3504
|
* @category mapping
|
|
3505
3505
|
* @since 2.0.0
|
|
3506
3506
|
*/
|
|
3507
|
-
var map$8 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
|
|
3507
|
+
var map$8 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none$1() : some(f(self.value)));
|
|
3508
3508
|
/**
|
|
3509
3509
|
* Applies a function that returns an `Option` to the value of a `Some`,
|
|
3510
3510
|
* flattening the result. Returns `None` if the input is `None`.
|
|
@@ -3548,7 +3548,7 @@ var map$8 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(se
|
|
|
3548
3548
|
* @category sequencing
|
|
3549
3549
|
* @since 2.0.0
|
|
3550
3550
|
*/
|
|
3551
|
-
var flatMap$5 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(self.value));
|
|
3551
|
+
var flatMap$5 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none$1() : f(self.value));
|
|
3552
3552
|
//#endregion
|
|
3553
3553
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Context.js
|
|
3554
3554
|
/**
|
|
@@ -3656,7 +3656,7 @@ var ServiceProto = {
|
|
|
3656
3656
|
};
|
|
3657
3657
|
var cacheKeys = /*#__PURE__*/ new Set();
|
|
3658
3658
|
var ReferenceTypeId = "~effect/Context/Reference";
|
|
3659
|
-
var TypeId$
|
|
3659
|
+
var TypeId$27 = "~effect/Context";
|
|
3660
3660
|
var MaxDepth = 8;
|
|
3661
3661
|
var FlattenAfterBaseHits = 8;
|
|
3662
3662
|
var makeImpl = (cacheRoot, base, overlay, depth) => {
|
|
@@ -3674,7 +3674,7 @@ var applyOverlays = (map, overlay) => {
|
|
|
3674
3674
|
applyOverlays(map, overlay.parent);
|
|
3675
3675
|
map.set(overlay.key, overlay.value);
|
|
3676
3676
|
};
|
|
3677
|
-
var flatten$
|
|
3677
|
+
var flatten$4 = (self) => {
|
|
3678
3678
|
if (self._flat) return self._flat;
|
|
3679
3679
|
if (!self.overlay) return self._flat = self.base;
|
|
3680
3680
|
const map = new Map(self.base);
|
|
@@ -3693,7 +3693,7 @@ var lookup = (self, key) => {
|
|
|
3693
3693
|
const value = impl.base.get(key);
|
|
3694
3694
|
if (value === void 0 && !impl.base.has(key)) return notFound;
|
|
3695
3695
|
if (impl.overlay && ++impl.baseHits >= impl.base.size && impl.baseHits >= FlattenAfterBaseHits) {
|
|
3696
|
-
impl.base = flatten$
|
|
3696
|
+
impl.base = flatten$4(impl);
|
|
3697
3697
|
impl.overlay = void 0;
|
|
3698
3698
|
impl.depth = 0;
|
|
3699
3699
|
}
|
|
@@ -3734,10 +3734,10 @@ var lookup = (self, key) => {
|
|
|
3734
3734
|
var makeUnsafe$6 = (mapUnsafe) => makeImpl(void 0, mapUnsafe, void 0, 0);
|
|
3735
3735
|
var Proto$8 = {
|
|
3736
3736
|
get mapUnsafe() {
|
|
3737
|
-
return flatten$
|
|
3737
|
+
return flatten$4(this);
|
|
3738
3738
|
},
|
|
3739
3739
|
...PipeInspectableProto,
|
|
3740
|
-
[TypeId$
|
|
3740
|
+
[TypeId$27]: { _Services: (_) => _ },
|
|
3741
3741
|
toJSON() {
|
|
3742
3742
|
return {
|
|
3743
3743
|
_id: "Context",
|
|
@@ -3793,7 +3793,7 @@ var hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot;
|
|
|
3793
3793
|
* @category guards
|
|
3794
3794
|
* @since 2.0.0
|
|
3795
3795
|
*/
|
|
3796
|
-
var isContext = (u) => hasProperty(u, TypeId$
|
|
3796
|
+
var isContext = (u) => hasProperty(u, TypeId$27);
|
|
3797
3797
|
/**
|
|
3798
3798
|
* Checks whether the provided argument is a `Reference`.
|
|
3799
3799
|
*
|
|
@@ -4064,7 +4064,7 @@ var serviceNotFoundError = (service) => {
|
|
|
4064
4064
|
var getOption = /*#__PURE__*/ dual(2, (self, service) => {
|
|
4065
4065
|
const value = lookup(self, service.key);
|
|
4066
4066
|
if (value !== notFound) return some(value);
|
|
4067
|
-
return isReference(service) ? some(getDefaultValue(service)) : none();
|
|
4067
|
+
return isReference(service) ? some(getDefaultValue(service)) : none$1();
|
|
4068
4068
|
});
|
|
4069
4069
|
/**
|
|
4070
4070
|
* Merges two `Context`s into one.
|
|
@@ -4101,7 +4101,7 @@ var getOption = /*#__PURE__*/ dual(2, (self, service) => {
|
|
|
4101
4101
|
* @category combining
|
|
4102
4102
|
* @since 2.0.0
|
|
4103
4103
|
*/
|
|
4104
|
-
var merge$
|
|
4104
|
+
var merge$4 = /*#__PURE__*/ dual(2, (self, that) => {
|
|
4105
4105
|
if (self.mapUnsafe.size === 0) return that;
|
|
4106
4106
|
if (that.mapUnsafe.size === 0) return self;
|
|
4107
4107
|
return withFlat(self, (map) => that.mapUnsafe.forEach((value, key) => map.set(key, value)));
|
|
@@ -4203,7 +4203,7 @@ var mergeAll$2 = (...ctxs) => {
|
|
|
4203
4203
|
var Reference = Service;
|
|
4204
4204
|
//#endregion
|
|
4205
4205
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Duration.js
|
|
4206
|
-
var TypeId$
|
|
4206
|
+
var TypeId$26 = "~effect/Duration";
|
|
4207
4207
|
var bigint0$2 = /*#__PURE__*/ BigInt(0);
|
|
4208
4208
|
var bigint1$2 = /*#__PURE__*/ BigInt(1);
|
|
4209
4209
|
var bigint2 = /*#__PURE__*/ BigInt(2);
|
|
@@ -4286,7 +4286,7 @@ var fromInputUnsafe$1 = (input) => {
|
|
|
4286
4286
|
}
|
|
4287
4287
|
case "object": {
|
|
4288
4288
|
if (input === null) break;
|
|
4289
|
-
if (TypeId$
|
|
4289
|
+
if (TypeId$26 in input) return input;
|
|
4290
4290
|
if (Array.isArray(input)) {
|
|
4291
4291
|
if (input.length !== 2 || !input.every(isNumber)) return invalid$3(input);
|
|
4292
4292
|
if (Number.isNaN(input[0]) || Number.isNaN(input[1])) return zero$1;
|
|
@@ -4318,7 +4318,7 @@ var zeroDurationValue = {
|
|
|
4318
4318
|
var infinityDurationValue = { _tag: "Infinity" };
|
|
4319
4319
|
var negativeInfinityDurationValue = { _tag: "NegativeInfinity" };
|
|
4320
4320
|
var DurationProto = {
|
|
4321
|
-
[TypeId$
|
|
4321
|
+
[TypeId$26]: TypeId$26,
|
|
4322
4322
|
[symbol$1]() {
|
|
4323
4323
|
switch (this.value._tag) {
|
|
4324
4324
|
case "Millis": return hash(roundMillisToNanos(this.value.millis));
|
|
@@ -4402,7 +4402,7 @@ var make$24 = (input) => {
|
|
|
4402
4402
|
* @category guards
|
|
4403
4403
|
* @since 2.0.0
|
|
4404
4404
|
*/
|
|
4405
|
-
var isDuration = (u) => hasProperty(u, TypeId$
|
|
4405
|
+
var isDuration = (u) => hasProperty(u, TypeId$26);
|
|
4406
4406
|
/**
|
|
4407
4407
|
* A Duration representing zero time.
|
|
4408
4408
|
*
|
|
@@ -4787,7 +4787,7 @@ var succeed$7 = succeed$8;
|
|
|
4787
4787
|
* @category constructors
|
|
4788
4788
|
* @since 4.0.0
|
|
4789
4789
|
*/
|
|
4790
|
-
var fail$
|
|
4790
|
+
var fail$9 = fail$10;
|
|
4791
4791
|
/**
|
|
4792
4792
|
* Checks whether a `Result` is a `Failure`.
|
|
4793
4793
|
*
|
|
@@ -5007,7 +5007,7 @@ var headUnsafe = (self) => {
|
|
|
5007
5007
|
*/
|
|
5008
5008
|
var map$6 = /*#__PURE__*/ dual(2, (self, f) => {
|
|
5009
5009
|
const out = { ...self };
|
|
5010
|
-
for (const key of keys(self)) assignProperty(out, key, f(self[key], key));
|
|
5010
|
+
for (const key of keys$1(self)) assignProperty(out, key, f(self[key], key));
|
|
5011
5011
|
return out;
|
|
5012
5012
|
});
|
|
5013
5013
|
/**
|
|
@@ -5025,7 +5025,7 @@ var map$6 = /*#__PURE__*/ dual(2, (self, f) => {
|
|
|
5025
5025
|
* @category getters
|
|
5026
5026
|
* @since 2.0.0
|
|
5027
5027
|
*/
|
|
5028
|
-
var keys = (self) => Object.keys(self);
|
|
5028
|
+
var keys$1 = (self) => Object.keys(self);
|
|
5029
5029
|
//#endregion
|
|
5030
5030
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Array.js
|
|
5031
5031
|
/**
|
|
@@ -5655,7 +5655,7 @@ var hasFails$1 = (self) => self.reasons.some(isFailReason$1);
|
|
|
5655
5655
|
/** @internal */
|
|
5656
5656
|
var findFail = (self) => {
|
|
5657
5657
|
const reason = self.reasons.find(isFailReason$1);
|
|
5658
|
-
return reason ? succeed$7(reason) : fail$
|
|
5658
|
+
return reason ? succeed$7(reason) : fail$9(self);
|
|
5659
5659
|
};
|
|
5660
5660
|
/** @internal */
|
|
5661
5661
|
var findError$1 = (self) => {
|
|
@@ -5663,7 +5663,7 @@ var findError$1 = (self) => {
|
|
|
5663
5663
|
const reason = self.reasons[i];
|
|
5664
5664
|
if (reason._tag === "Fail") return succeed$7(reason.error);
|
|
5665
5665
|
}
|
|
5666
|
-
return fail$
|
|
5666
|
+
return fail$9(self);
|
|
5667
5667
|
};
|
|
5668
5668
|
/** @internal */
|
|
5669
5669
|
var hasInterrupts = (self) => self.reasons.some(isInterruptReason);
|
|
@@ -5676,7 +5676,7 @@ var causeFilterInterruptors = (self) => {
|
|
|
5676
5676
|
interruptors ??= /* @__PURE__ */ new Set();
|
|
5677
5677
|
if (f.fiberId !== void 0) interruptors.add(f.fiberId);
|
|
5678
5678
|
}
|
|
5679
|
-
return interruptors ? succeed$7(interruptors) : fail$
|
|
5679
|
+
return interruptors ? succeed$7(interruptors) : fail$9(self);
|
|
5680
5680
|
};
|
|
5681
5681
|
/** @internal */
|
|
5682
5682
|
var reasonAnnotations$1 = (self) => makeUnsafe$6(self.annotations);
|
|
@@ -6097,7 +6097,7 @@ var fiberInterrupt = (self) => withFiber$1((fiber) => fiberInterruptAs(self, fib
|
|
|
6097
6097
|
/** @internal */
|
|
6098
6098
|
var fiberInterruptAs = /*#__PURE__*/ dual((args) => hasProperty(args[0], FiberTypeId), (self, fiberId, annotations) => withFiber$1((parent) => {
|
|
6099
6099
|
let ann = fiberStackAnnotations(parent);
|
|
6100
|
-
ann = ann && annotations ? merge$
|
|
6100
|
+
ann = ann && annotations ? merge$4(ann, annotations) : ann ?? annotations;
|
|
6101
6101
|
self.interruptUnsafe(fiberId, ann);
|
|
6102
6102
|
return asVoid$1(fiberAwait(self));
|
|
6103
6103
|
}));
|
|
@@ -6116,7 +6116,7 @@ var succeed$6 = exitSucceed;
|
|
|
6116
6116
|
/** @internal */
|
|
6117
6117
|
var failCause$5 = exitFailCause;
|
|
6118
6118
|
/** @internal */
|
|
6119
|
-
var fail$
|
|
6119
|
+
var fail$8 = exitFail;
|
|
6120
6120
|
/** @internal */
|
|
6121
6121
|
var sync$2 = /*#__PURE__*/ makePrimitive({
|
|
6122
6122
|
op: "Sync",
|
|
@@ -6135,7 +6135,7 @@ var suspend$3 = /*#__PURE__*/ makePrimitive({
|
|
|
6135
6135
|
});
|
|
6136
6136
|
/** @internal */
|
|
6137
6137
|
var fromResult$1 = /*#__PURE__*/ match$2({
|
|
6138
|
-
onFailure: fail$
|
|
6138
|
+
onFailure: fail$8,
|
|
6139
6139
|
onSuccess: succeed$6
|
|
6140
6140
|
});
|
|
6141
6141
|
/** @internal */
|
|
@@ -6153,13 +6153,13 @@ var yieldNow$1 = /*#__PURE__*/ (/* @__PURE__ */ makePrimitive({
|
|
|
6153
6153
|
}
|
|
6154
6154
|
}))(0);
|
|
6155
6155
|
/** @internal */
|
|
6156
|
-
var succeedNone$1 = /*#__PURE__*/ succeed$6(/*#__PURE__*/ none());
|
|
6156
|
+
var succeedNone$1 = /*#__PURE__*/ succeed$6(/*#__PURE__*/ none$1());
|
|
6157
6157
|
/** @internal */
|
|
6158
6158
|
var failCauseSync$1 = (evaluate) => suspend$3(() => failCause$5(evaluate()));
|
|
6159
6159
|
/** @internal */
|
|
6160
6160
|
var die$2 = (defect) => exitDie(defect);
|
|
6161
6161
|
/** @internal */
|
|
6162
|
-
var failSync = (error) => suspend$3(() => fail$
|
|
6162
|
+
var failSync = (error) => suspend$3(() => fail$8(error()));
|
|
6163
6163
|
/** @internal */
|
|
6164
6164
|
var void_$2 = /*#__PURE__*/ succeed$6(void 0);
|
|
6165
6165
|
/** @internal */
|
|
@@ -6170,7 +6170,7 @@ var try_$1 = (options) => {
|
|
|
6170
6170
|
try {
|
|
6171
6171
|
return succeed$6(evaluate());
|
|
6172
6172
|
} catch (err) {
|
|
6173
|
-
return fail$
|
|
6173
|
+
return fail$8(catcher(err));
|
|
6174
6174
|
}
|
|
6175
6175
|
});
|
|
6176
6176
|
};
|
|
@@ -6185,7 +6185,7 @@ var tryPromise$1 = (options) => {
|
|
|
6185
6185
|
return callbackOptions(function(resume, signal) {
|
|
6186
6186
|
const failWithCatch = (cause) => suspend$3(() => {
|
|
6187
6187
|
try {
|
|
6188
|
-
return fail$
|
|
6188
|
+
return fail$8(internalCall(() => catcher(cause)));
|
|
6189
6189
|
} catch (err) {
|
|
6190
6190
|
return die$2(err);
|
|
6191
6191
|
}
|
|
@@ -6432,7 +6432,7 @@ var flatMapEager$1 = /*#__PURE__*/ dual(2, (self, f) => {
|
|
|
6432
6432
|
return flatMap$3(self, f);
|
|
6433
6433
|
});
|
|
6434
6434
|
/** @internal */
|
|
6435
|
-
var flatten$
|
|
6435
|
+
var flatten$3 = (self) => flatMap$3(self, identity$2);
|
|
6436
6436
|
/** @internal */
|
|
6437
6437
|
var map$4 = /*#__PURE__*/ dual(2, (self, f) => new ContImpl(self, mapCont, f));
|
|
6438
6438
|
/** @internal */
|
|
@@ -6456,7 +6456,7 @@ var exitIsSuccess = (self) => self._tag === "Success";
|
|
|
6456
6456
|
/** @internal */
|
|
6457
6457
|
var exitIsFailure = (self) => self._tag === "Failure";
|
|
6458
6458
|
/** @internal */
|
|
6459
|
-
var exitFilterCause = (self) => self._tag === "Failure" ? succeed$7(self.cause) : fail$
|
|
6459
|
+
var exitFilterCause = (self) => self._tag === "Failure" ? succeed$7(self.cause) : fail$9(self);
|
|
6460
6460
|
/** @internal */
|
|
6461
6461
|
var exitHasInterrupts = (self) => self._tag === "Failure" && hasInterrupts(self.cause);
|
|
6462
6462
|
/** @internal */
|
|
@@ -6506,7 +6506,7 @@ var contextWith$1 = (f) => withFiber$1((fiber) => f(fiber.context));
|
|
|
6506
6506
|
/** @internal */
|
|
6507
6507
|
var provideContext$1 = /*#__PURE__*/ dual(2, (self, context) => {
|
|
6508
6508
|
if (effectIsExit(self)) return self;
|
|
6509
|
-
return updateContext(self, merge$
|
|
6509
|
+
return updateContext(self, merge$4(context));
|
|
6510
6510
|
});
|
|
6511
6511
|
/** @internal */
|
|
6512
6512
|
var provideService$1 = function() {
|
|
@@ -6515,11 +6515,11 @@ var provideService$1 = function() {
|
|
|
6515
6515
|
};
|
|
6516
6516
|
var provideServiceImpl = (self, service, implementation) => updateContext(self, add(service, implementation));
|
|
6517
6517
|
/** @internal */
|
|
6518
|
-
var filterOrFail$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, orFailWith) => filterOrElse(self, predicate, orFailWith ? (a) => fail$
|
|
6518
|
+
var filterOrFail$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, orFailWith) => filterOrElse(self, predicate, orFailWith ? (a) => fail$8(orFailWith(a)) : () => fail$8(new NoSuchElementError())));
|
|
6519
6519
|
/** @internal */
|
|
6520
6520
|
var when$1 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$3(condition, (pass) => pass ? asSome$1(self) : succeedNone$1));
|
|
6521
6521
|
/** @internal */
|
|
6522
|
-
var forever$
|
|
6522
|
+
var forever$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options) => whileLoop$1({
|
|
6523
6523
|
while: constTrue,
|
|
6524
6524
|
body: constant(options?.disableYield ? self : flatMap$3(self, (_) => yieldNow$1)),
|
|
6525
6525
|
step: constVoid
|
|
@@ -6584,12 +6584,12 @@ var ignore$3 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, options)
|
|
|
6584
6584
|
});
|
|
6585
6585
|
/** @internal */
|
|
6586
6586
|
var option$1 = (self) => match$1(self, {
|
|
6587
|
-
onFailure: none,
|
|
6587
|
+
onFailure: none$1,
|
|
6588
6588
|
onSuccess: some
|
|
6589
6589
|
});
|
|
6590
6590
|
/** @internal */
|
|
6591
6591
|
var result$1 = (self) => matchEager(self, {
|
|
6592
|
-
onFailure: fail$
|
|
6592
|
+
onFailure: fail$9,
|
|
6593
6593
|
onSuccess: succeed$7
|
|
6594
6594
|
});
|
|
6595
6595
|
/** @internal */
|
|
@@ -6666,7 +6666,7 @@ var exitPrimitive = /*#__PURE__*/ makePrimitive({
|
|
|
6666
6666
|
/** @internal */
|
|
6667
6667
|
var timeoutOrElse$1 = /*#__PURE__*/ dual(2, (self, options) => flatMap$3(timeoutOption$1(self, options.duration), (option) => isNone(option) ? options.orElse() : succeed$6(option.value)));
|
|
6668
6668
|
/** @internal */
|
|
6669
|
-
var timeoutOption$1 = /*#__PURE__*/ dual(2, (self, duration) => raceFirst$1(asSome$1(self), as$2(sleep$1(duration), none())));
|
|
6669
|
+
var timeoutOption$1 = /*#__PURE__*/ dual(2, (self, duration) => raceFirst$1(asSome$1(self), as$2(sleep$1(duration), none$1())));
|
|
6670
6670
|
/** @internal */
|
|
6671
6671
|
var ScopeTypeId = "~effect/Scope";
|
|
6672
6672
|
/** @internal */
|
|
@@ -6790,7 +6790,7 @@ var scoped$1 = (self) => withFiber$1((fiber) => {
|
|
|
6790
6790
|
/** @internal */
|
|
6791
6791
|
var scopedWith$1 = (f) => suspend$3(() => {
|
|
6792
6792
|
const scope = scopeMakeUnsafe();
|
|
6793
|
-
return onExit$
|
|
6793
|
+
return onExit$2(f(scope), (exit) => suspend$3(() => scopeCloseUnsafe(scope, exit) ?? void_$2));
|
|
6794
6794
|
});
|
|
6795
6795
|
/** @internal */
|
|
6796
6796
|
var acquireRelease$1 = (acquire, release, options) => contextWith$1((context) => uninterruptibleMask$1((restore) => flatMap$3(scope$1, (scope) => tap$2(options?.interruptible ? restore(acquire) : acquire, (a) => scopeAddFinalizerExit(scope, (exit) => provideContext$1(release(a, exit), context))))));
|
|
@@ -6848,18 +6848,18 @@ var onExitUnsafe = (fiber, f) => {
|
|
|
6848
6848
|
fiber._stack.push(new OnExitImpl(void 0, f, void 0));
|
|
6849
6849
|
};
|
|
6850
6850
|
/** @internal */
|
|
6851
|
-
var onExit$
|
|
6851
|
+
var onExit$2 = /*#__PURE__*/ dual(2, onExitPrimitive$1);
|
|
6852
6852
|
/** @internal */
|
|
6853
|
-
var ensuring$
|
|
6853
|
+
var ensuring$3 = /*#__PURE__*/ dual(2, (self, finalizer) => onExit$2(self, (_) => finalizer));
|
|
6854
6854
|
/** @internal */
|
|
6855
|
-
var onExitFilter = /*#__PURE__*/ dual(3, (self, filter, f) => onExit$
|
|
6855
|
+
var onExitFilter = /*#__PURE__*/ dual(3, (self, filter, f) => onExit$2(self, (exit) => {
|
|
6856
6856
|
const b = filter(exit);
|
|
6857
6857
|
return isFailure$1(b) ? void_$2 : f(b.success, exit);
|
|
6858
6858
|
}));
|
|
6859
6859
|
/** @internal */
|
|
6860
6860
|
var onError$1 = /*#__PURE__*/ dual(2, (self, f) => onExitFilter(self, exitFilterCause, f));
|
|
6861
6861
|
/** @internal */
|
|
6862
|
-
var onErrorFilter = /*#__PURE__*/ dual(3, (self, filter, f) => onExit$
|
|
6862
|
+
var onErrorFilter = /*#__PURE__*/ dual(3, (self, filter, f) => onExit$2(self, (exit) => {
|
|
6863
6863
|
if (exit._tag !== "Failure") return void_$2;
|
|
6864
6864
|
const result = filter(exit.cause);
|
|
6865
6865
|
return isFailure$1(result) ? void_$2 : f(result.success, exit.cause);
|
|
@@ -7645,7 +7645,7 @@ var failCause$4 = exitFailCause;
|
|
|
7645
7645
|
* @category constructors
|
|
7646
7646
|
* @since 2.0.0
|
|
7647
7647
|
*/
|
|
7648
|
-
var fail$
|
|
7648
|
+
var fail$7 = exitFail;
|
|
7649
7649
|
/**
|
|
7650
7650
|
* Creates a failed Exit representing fiber interruption.
|
|
7651
7651
|
*
|
|
@@ -8374,7 +8374,7 @@ var forkUnsafe = scopeForkUnsafe;
|
|
|
8374
8374
|
var close = scopeClose;
|
|
8375
8375
|
//#endregion
|
|
8376
8376
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Layer.js
|
|
8377
|
-
var TypeId$
|
|
8377
|
+
var TypeId$24 = "~effect/Layer";
|
|
8378
8378
|
var MemoMapTypeId = "~effect/Layer/MemoMap";
|
|
8379
8379
|
var makeMemoMapEntry = (memoMap, layer) => {
|
|
8380
8380
|
const entry = {
|
|
@@ -8420,9 +8420,9 @@ var memoMapObserve = (entry, scope) => {
|
|
|
8420
8420
|
* @category guards
|
|
8421
8421
|
* @since 2.0.0
|
|
8422
8422
|
*/
|
|
8423
|
-
var isLayer = (u) => hasProperty(u, TypeId$
|
|
8423
|
+
var isLayer = (u) => hasProperty(u, TypeId$24);
|
|
8424
8424
|
var LayerProto = {
|
|
8425
|
-
[TypeId$
|
|
8425
|
+
[TypeId$24]: {
|
|
8426
8426
|
_ROut: identity$2,
|
|
8427
8427
|
_E: identity$2,
|
|
8428
8428
|
_RIn: identity$2
|
|
@@ -8472,7 +8472,7 @@ var fromBuildUnsafe = (build) => {
|
|
|
8472
8472
|
*/
|
|
8473
8473
|
var fromBuild = (build) => fromBuildUnsafe((memoMap, scope) => {
|
|
8474
8474
|
const layerScope = forkUnsafe(scope);
|
|
8475
|
-
return onExit$
|
|
8475
|
+
return onExit$2(build(memoMap, layerScope), (exit) => exit._tag === "Failure" ? close(layerScope, exit) : void_$2);
|
|
8476
8476
|
});
|
|
8477
8477
|
/**
|
|
8478
8478
|
* Constructs a `Layer` from a function that uses a `MemoMap` and `Scope` to
|
|
@@ -9208,7 +9208,7 @@ var mergeAll$1 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(lay
|
|
|
9208
9208
|
* @category zipping
|
|
9209
9209
|
* @since 2.0.0
|
|
9210
9210
|
*/
|
|
9211
|
-
var merge$
|
|
9211
|
+
var merge$3 = /*#__PURE__*/ dual(2, (self, that) => mergeAll$1(self, ...Array.isArray(that) ? that : [that]));
|
|
9212
9212
|
var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap$3(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext$1(context), map$4((merged) => f(merged, context)))));
|
|
9213
9213
|
/**
|
|
9214
9214
|
* Feeds the output services of the dependency layer into the requirements of
|
|
@@ -9379,7 +9379,7 @@ var provide$2 = /*#__PURE__*/ dual(2, (self, that) => provideWith(self, that, id
|
|
|
9379
9379
|
* @category providing services
|
|
9380
9380
|
* @since 2.0.0
|
|
9381
9381
|
*/
|
|
9382
|
-
var provideMerge = /*#__PURE__*/ dual(2, (self, that) => provideWith(self, that, (self, that) => merge$
|
|
9382
|
+
var provideMerge = /*#__PURE__*/ dual(2, (self, that) => provideWith(self, that, (self, that) => merge$4(that, self)));
|
|
9383
9383
|
/**
|
|
9384
9384
|
* Constructs a layer dynamically based on the output of this layer.
|
|
9385
9385
|
*
|
|
@@ -9572,7 +9572,7 @@ var fromReasons = causeFromReasons;
|
|
|
9572
9572
|
* @category constructors
|
|
9573
9573
|
* @since 2.0.0
|
|
9574
9574
|
*/
|
|
9575
|
-
var fail$
|
|
9575
|
+
var fail$6 = causeFail;
|
|
9576
9576
|
/**
|
|
9577
9577
|
* Creates a `Cause` containing a single `Die` reason with the
|
|
9578
9578
|
* given defect.
|
|
@@ -9918,11 +9918,11 @@ var currentTimeMillis = currentTimeMillis$1;
|
|
|
9918
9918
|
//#endregion
|
|
9919
9919
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/dateTime.js
|
|
9920
9920
|
/** @internal */
|
|
9921
|
-
var TypeId$
|
|
9921
|
+
var TypeId$23 = "~effect/DateTime";
|
|
9922
9922
|
/** @internal */
|
|
9923
9923
|
var TimeZoneTypeId = "~effect/DateTime/TimeZone";
|
|
9924
9924
|
var Proto$7 = {
|
|
9925
|
-
[TypeId$
|
|
9925
|
+
[TypeId$23]: TypeId$23,
|
|
9926
9926
|
pipe() {
|
|
9927
9927
|
return pipeArguments(this, arguments);
|
|
9928
9928
|
},
|
|
@@ -10068,8 +10068,8 @@ var filterDone = (cause) => {
|
|
|
10068
10068
|
let hasFailure = false;
|
|
10069
10069
|
for (const reason of cause.reasons) if (isDoneFailure(reason)) done ??= reason.error;
|
|
10070
10070
|
else if (reason._tag !== "Interrupt") hasFailure = true;
|
|
10071
|
-
if (done === void 0) return fail$
|
|
10072
|
-
return hasFailure ? fail$
|
|
10071
|
+
if (done === void 0) return fail$9(cause);
|
|
10072
|
+
return hasFailure ? fail$9(fromReasons(cause.reasons.filter((reason) => !isDoneFailure(reason)))) : succeed$7(done);
|
|
10073
10073
|
};
|
|
10074
10074
|
/**
|
|
10075
10075
|
* Filters a Cause to extract the leftover value from done errors.
|
|
@@ -10149,360 +10149,11 @@ var matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect$1(
|
|
|
10149
10149
|
}
|
|
10150
10150
|
}));
|
|
10151
10151
|
//#endregion
|
|
10152
|
-
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Schedule.js
|
|
10153
|
-
var TypeId$23 = "~effect/Schedule";
|
|
10154
|
-
/**
|
|
10155
|
-
* Context reference containing metadata for the currently running schedule step.
|
|
10156
|
-
*
|
|
10157
|
-
* **Details**
|
|
10158
|
-
*
|
|
10159
|
-
* Repeat, retry, stream, and channel scheduling operations provide this service
|
|
10160
|
-
* to effects run between schedule steps. The default value contains undefined
|
|
10161
|
-
* input and output values, zero duration, and zeroed timing fields before any
|
|
10162
|
-
* schedule step has produced metadata.
|
|
10163
|
-
*
|
|
10164
|
-
* @stability stable
|
|
10165
|
-
* @category services
|
|
10166
|
-
* @since 4.0.0
|
|
10167
|
-
*/
|
|
10168
|
-
var CurrentMetadata = /*#__PURE__*/ Reference("effect/Schedule/CurrentMetadata", { defaultValue: /*#__PURE__*/ constant({
|
|
10169
|
-
input: void 0,
|
|
10170
|
-
output: void 0,
|
|
10171
|
-
duration: zero$1,
|
|
10172
|
-
attempt: 0,
|
|
10173
|
-
start: 0,
|
|
10174
|
-
now: 0,
|
|
10175
|
-
elapsed: 0,
|
|
10176
|
-
elapsedSincePrevious: 0
|
|
10177
|
-
}) });
|
|
10178
|
-
var ScheduleProto = {
|
|
10179
|
-
[TypeId$23]: {
|
|
10180
|
-
_Out: identity$2,
|
|
10181
|
-
_In: identity$2,
|
|
10182
|
-
_Env: identity$2
|
|
10183
|
-
},
|
|
10184
|
-
pipe() {
|
|
10185
|
-
return pipeArguments(this, arguments);
|
|
10186
|
-
}
|
|
10187
|
-
};
|
|
10188
|
-
/**
|
|
10189
|
-
* Type guard that checks if a value is a Schedule.
|
|
10190
|
-
*
|
|
10191
|
-
* **Example** (Checking for schedules)
|
|
10192
|
-
*
|
|
10193
|
-
* ```ts import.meta.vitest
|
|
10194
|
-
* import { Schedule } from "effect"
|
|
10195
|
-
*
|
|
10196
|
-
* const schedule = Schedule.exponential("100 millis")
|
|
10197
|
-
* const notSchedule = { foo: "bar" }
|
|
10198
|
-
*
|
|
10199
|
-
* Schedule.isSchedule(schedule) // => true
|
|
10200
|
-
* Schedule.isSchedule(notSchedule) // => false
|
|
10201
|
-
* Schedule.isSchedule(null) // => false
|
|
10202
|
-
* Schedule.isSchedule(undefined) // => false
|
|
10203
|
-
* ```
|
|
10204
|
-
*
|
|
10205
|
-
* @stability stable
|
|
10206
|
-
* @category guards
|
|
10207
|
-
* @since 2.0.0
|
|
10208
|
-
*/
|
|
10209
|
-
var isSchedule = (u) => hasProperty(u, TypeId$23);
|
|
10210
|
-
/**
|
|
10211
|
-
* Creates a Schedule from a step function that returns a Pull.
|
|
10212
|
-
*
|
|
10213
|
-
* **Example** (Creating a custom schedule from a step function)
|
|
10214
|
-
*
|
|
10215
|
-
* ```ts import.meta.vitest
|
|
10216
|
-
* import { Cause, Duration, Effect, Schedule } from "effect"
|
|
10217
|
-
*
|
|
10218
|
-
* const schedule = Schedule.fromStep(Effect.sync(() => {
|
|
10219
|
-
* let count = 0
|
|
10220
|
-
*
|
|
10221
|
-
* return (_now: number, _input: string) => {
|
|
10222
|
-
* if (count >= 3) {
|
|
10223
|
-
* return Cause.done(count)
|
|
10224
|
-
* }
|
|
10225
|
-
* return Effect.succeed([count++, Duration.millis(100)] as [number, Duration.Duration])
|
|
10226
|
-
* }
|
|
10227
|
-
* }))
|
|
10228
|
-
*
|
|
10229
|
-
* const program = Effect.gen(function*() {
|
|
10230
|
-
* const step = yield* Schedule.toStep(schedule)
|
|
10231
|
-
* const [output] = yield* step(0, "input")
|
|
10232
|
-
* return output
|
|
10233
|
-
* })
|
|
10234
|
-
*
|
|
10235
|
-
* await Effect.runPromise(program) // => 0
|
|
10236
|
-
* ```
|
|
10237
|
-
*
|
|
10238
|
-
* @stability stable
|
|
10239
|
-
* @category constructors
|
|
10240
|
-
* @since 4.0.0
|
|
10241
|
-
*/
|
|
10242
|
-
var fromStep = (step) => {
|
|
10243
|
-
const self = Object.create(ScheduleProto);
|
|
10244
|
-
self.step = step;
|
|
10245
|
-
return self;
|
|
10246
|
-
};
|
|
10247
|
-
var metadataFn = () => {
|
|
10248
|
-
let n = 0;
|
|
10249
|
-
let previous;
|
|
10250
|
-
let start;
|
|
10251
|
-
return (now, input) => {
|
|
10252
|
-
if (start === void 0) start = now;
|
|
10253
|
-
const elapsed = now - start;
|
|
10254
|
-
const elapsedSincePrevious = previous === void 0 ? 0 : now - previous;
|
|
10255
|
-
previous = now;
|
|
10256
|
-
return {
|
|
10257
|
-
input,
|
|
10258
|
-
attempt: ++n,
|
|
10259
|
-
start,
|
|
10260
|
-
now,
|
|
10261
|
-
elapsed,
|
|
10262
|
-
elapsedSincePrevious
|
|
10263
|
-
};
|
|
10264
|
-
};
|
|
10265
|
-
};
|
|
10266
|
-
/**
|
|
10267
|
-
* Creates a Schedule from a step function that receives metadata about the schedule's execution.
|
|
10268
|
-
*
|
|
10269
|
-
* **Example** (Creating a metadata-aware schedule)
|
|
10270
|
-
*
|
|
10271
|
-
* ```ts import.meta.vitest
|
|
10272
|
-
* import { Cause, Duration, Effect, Schedule } from "effect"
|
|
10273
|
-
*
|
|
10274
|
-
* const firstThreeInputs = Schedule.fromStepWithMetadata(Effect.succeed((metadata: Schedule.InputMetadata<string>) => {
|
|
10275
|
-
* if (metadata.attempt > 3) {
|
|
10276
|
-
* return Cause.done("finished")
|
|
10277
|
-
* }
|
|
10278
|
-
*
|
|
10279
|
-
* return Effect.succeed([
|
|
10280
|
-
* `attempt ${metadata.attempt}: ${metadata.input}`,
|
|
10281
|
-
* Duration.millis(250)
|
|
10282
|
-
* ] as [string, Duration.Duration])
|
|
10283
|
-
* }))
|
|
10284
|
-
*
|
|
10285
|
-
* const program = Effect.gen(function*() {
|
|
10286
|
-
* const step = yield* Schedule.toStep(firstThreeInputs)
|
|
10287
|
-
* const [output] = yield* step(0, "input")
|
|
10288
|
-
* return output
|
|
10289
|
-
* })
|
|
10290
|
-
*
|
|
10291
|
-
* await Effect.runPromise(program) // => "attempt 1: input"
|
|
10292
|
-
* ```
|
|
10293
|
-
*
|
|
10294
|
-
* @stability stable
|
|
10295
|
-
* @category constructors
|
|
10296
|
-
* @since 4.0.0
|
|
10297
|
-
*/
|
|
10298
|
-
var fromStepWithMetadata = (step) => fromStep(map$4(step, (f) => {
|
|
10299
|
-
const meta = metadataFn();
|
|
10300
|
-
return (now, input) => f(meta(now, input));
|
|
10301
|
-
}));
|
|
10302
|
-
/**
|
|
10303
|
-
* Extracts the step function from a Schedule.
|
|
10304
|
-
*
|
|
10305
|
-
* **Example** (Extracting a schedule step function)
|
|
10306
|
-
*
|
|
10307
|
-
* ```ts import.meta.vitest
|
|
10308
|
-
* import { Duration, Effect, Schedule } from "effect"
|
|
10309
|
-
*
|
|
10310
|
-
* // Extract step function from an existing schedule
|
|
10311
|
-
* const schedule = Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
|
|
10312
|
-
*
|
|
10313
|
-
* const program = Effect.gen(function*() {
|
|
10314
|
-
* const stepFn = yield* Schedule.toStep(schedule)
|
|
10315
|
-
*
|
|
10316
|
-
* // Use the step function directly for custom logic. The timestamp is
|
|
10317
|
-
* // supplied by the caller, so tests can pass a deterministic value.
|
|
10318
|
-
* const now = 0
|
|
10319
|
-
* return yield* stepFn(now, "input")
|
|
10320
|
-
* })
|
|
10321
|
-
*
|
|
10322
|
-
* await Effect.runPromise(program) // => [Duration.millis(100), Duration.millis(100)]
|
|
10323
|
-
* ```
|
|
10324
|
-
*
|
|
10325
|
-
* @stability stable
|
|
10326
|
-
* @category destructors
|
|
10327
|
-
* @since 4.0.0
|
|
10328
|
-
*/
|
|
10329
|
-
var toStep = (schedule) => catchCause$2(schedule.step, (cause) => succeed$6(() => failCause$5(cause)));
|
|
10330
|
-
/**
|
|
10331
|
-
* Extracts a step function from a `Schedule` that sleeps for each computed
|
|
10332
|
-
* delay and returns metadata for the completed step.
|
|
10333
|
-
*
|
|
10334
|
-
* **When to use**
|
|
10335
|
-
*
|
|
10336
|
-
* Use to drive a schedule manually while preserving the computed output,
|
|
10337
|
-
* delay, input, attempt, and elapsed timing metadata for each step.
|
|
10338
|
-
*
|
|
10339
|
-
* **Details**
|
|
10340
|
-
*
|
|
10341
|
-
* The returned step reads the current time from `Clock` when invoked, calls the
|
|
10342
|
-
* schedule step with that timestamp and input, sleeps for the returned
|
|
10343
|
-
* duration, and then yields `Metadata`.
|
|
10344
|
-
*
|
|
10345
|
-
* @see {@link toStep} for manually supplying the timestamp and handling the returned delay yourself
|
|
10346
|
-
* @see {@link toStepWithSleep} for the same automatic sleeping behavior when only the schedule output is needed
|
|
10347
|
-
*
|
|
10348
|
-
* @stability stable
|
|
10349
|
-
* @category destructors
|
|
10350
|
-
* @since 4.0.0
|
|
10351
|
-
*/
|
|
10352
|
-
var toStepWithMetadata = (schedule) => clockWith$1((clock) => map$4(toStep(schedule), (step) => {
|
|
10353
|
-
const metaFn = metadataFn();
|
|
10354
|
-
return (input) => suspend$3(() => {
|
|
10355
|
-
const now = clock.currentTimeMillisUnsafe();
|
|
10356
|
-
return flatMap$3(step(now, input), ([output, duration]) => {
|
|
10357
|
-
const meta = metaFn(now, input);
|
|
10358
|
-
meta.output = output;
|
|
10359
|
-
meta.duration = duration;
|
|
10360
|
-
return as$2(sleep$1(duration), meta);
|
|
10361
|
-
});
|
|
10362
|
-
});
|
|
10363
|
-
}));
|
|
10364
|
-
/**
|
|
10365
|
-
* Returns a new `Schedule` that outputs the inputs of the specified schedule.
|
|
10366
|
-
*
|
|
10367
|
-
* **Example** (Passing inputs through as outputs)
|
|
10368
|
-
*
|
|
10369
|
-
* ```ts import.meta.vitest
|
|
10370
|
-
* import { Effect, Schedule } from "effect"
|
|
10371
|
-
*
|
|
10372
|
-
* const inputSchedule = Schedule.passthrough(
|
|
10373
|
-
* Schedule.exponential("100 millis").pipe(Schedule.upTo({ times: 3 }))
|
|
10374
|
-
* )
|
|
10375
|
-
* const program = Effect.gen(function*() {
|
|
10376
|
-
* const step = yield* Schedule.toStep(inputSchedule)
|
|
10377
|
-
* const [output] = yield* step(0, "input")
|
|
10378
|
-
* return output
|
|
10379
|
-
* })
|
|
10380
|
-
*
|
|
10381
|
-
* await Effect.runPromise(program) // => "input"
|
|
10382
|
-
* ```
|
|
10383
|
-
*
|
|
10384
|
-
* @stability stable
|
|
10385
|
-
* @category mapping
|
|
10386
|
-
* @since 2.0.0
|
|
10387
|
-
*/
|
|
10388
|
-
var passthrough$2 = (self) => fromStep(map$4(toStep(self), (step) => (now, input) => matchEffect$1(step(now, input), {
|
|
10389
|
-
onSuccess: (result) => succeed$6([input, result[1]]),
|
|
10390
|
-
onFailure: failCause$5,
|
|
10391
|
-
onDone: () => done(input)
|
|
10392
|
-
})));
|
|
10393
|
-
/**
|
|
10394
|
-
* Returns a schedule that recurs continuously, each repetition spaced the
|
|
10395
|
-
* specified duration from the last run.
|
|
10396
|
-
*
|
|
10397
|
-
* **When to use**
|
|
10398
|
-
*
|
|
10399
|
-
* Use when each delay should start after the previous action completes.
|
|
10400
|
-
*
|
|
10401
|
-
* **Example** (Repeating with fixed spacing)
|
|
10402
|
-
*
|
|
10403
|
-
* ```ts import.meta.vitest
|
|
10404
|
-
* import { Duration, Effect, Schedule } from "effect"
|
|
10405
|
-
*
|
|
10406
|
-
* const program = Effect.gen(function*() {
|
|
10407
|
-
* const step = yield* Schedule.toStep(Schedule.spaced("2 seconds"))
|
|
10408
|
-
* return yield* step(0, undefined)
|
|
10409
|
-
* })
|
|
10410
|
-
*
|
|
10411
|
-
* await Effect.runPromise(program) // => [0, Duration.seconds(2)]
|
|
10412
|
-
* ```
|
|
10413
|
-
*
|
|
10414
|
-
* @see {@link fixed} for recurrence aligned to a regular cadence
|
|
10415
|
-
*
|
|
10416
|
-
* @stability stable
|
|
10417
|
-
* @category constructors
|
|
10418
|
-
* @since 2.0.0
|
|
10419
|
-
*/
|
|
10420
|
-
var spaced = (duration) => {
|
|
10421
|
-
const decoded = fromInputUnsafe$1(duration);
|
|
10422
|
-
return fromStepWithMetadata(succeed$6((meta) => succeed$6([meta.attempt - 1, decoded])));
|
|
10423
|
-
};
|
|
10424
|
-
var while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$4(toStep(self), (step) => {
|
|
10425
|
-
const meta = metadataFn();
|
|
10426
|
-
return (now, input) => flatMap$3(step(now, input), (result) => {
|
|
10427
|
-
const [output, duration] = result;
|
|
10428
|
-
const eff = predicate({
|
|
10429
|
-
...meta(now, input),
|
|
10430
|
-
output,
|
|
10431
|
-
duration
|
|
10432
|
-
});
|
|
10433
|
-
return flatMap$3(isEffect$1(eff) ? eff : succeed$6(eff), (check) => check ? succeed$6(result) : done(output));
|
|
10434
|
-
});
|
|
10435
|
-
})));
|
|
10436
|
-
/**
|
|
10437
|
-
* Returns a new `Schedule` that will recur forever.
|
|
10438
|
-
*
|
|
10439
|
-
* **Details**
|
|
10440
|
-
*
|
|
10441
|
-
* The output of the schedule is the current count of its repetitions thus far
|
|
10442
|
-
* (i.e. `0, 1, 2, ...`).
|
|
10443
|
-
*
|
|
10444
|
-
* **Example** (Repeating forever)
|
|
10445
|
-
*
|
|
10446
|
-
* ```ts import.meta.vitest
|
|
10447
|
-
* import { Effect, Schedule } from "effect"
|
|
10448
|
-
* import { TestClock } from "effect/testing"
|
|
10449
|
-
*
|
|
10450
|
-
* const executions: Array<number> = []
|
|
10451
|
-
* const schedule = Schedule.forever.pipe(Schedule.upTo({ times: 2 }))
|
|
10452
|
-
* const program = Effect.sync(() => executions.push(executions.length + 1)).pipe(
|
|
10453
|
-
* Effect.repeat(schedule),
|
|
10454
|
-
* Effect.as(executions)
|
|
10455
|
-
* )
|
|
10456
|
-
*
|
|
10457
|
-
* await Effect.runPromise(Effect.provide(program, TestClock.layer())) // => [1, 2, 3]
|
|
10458
|
-
* ```
|
|
10459
|
-
*
|
|
10460
|
-
* @stability stable
|
|
10461
|
-
* @category constructors
|
|
10462
|
-
* @since 2.0.0
|
|
10463
|
-
*/
|
|
10464
|
-
var forever$1 = /*#__PURE__*/ spaced(zero$1);
|
|
10465
|
-
//#endregion
|
|
10466
10152
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/layer.js
|
|
10467
10153
|
var provideLayer = (self, layer, options) => scopedWith$1((scope) => flatMap$3(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext$1(self, context)));
|
|
10468
10154
|
/** @internal */
|
|
10469
10155
|
var provide$1 = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, source, options) => isContext(source) ? provideContext$1(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll$1(...source) : source, options));
|
|
10470
10156
|
//#endregion
|
|
10471
|
-
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/internal/schedule.js
|
|
10472
|
-
var findErrorOnly = (cause) => cause.reasons.every(isFailReason$1) ? findError$1(cause) : fail$8(cause);
|
|
10473
|
-
/** @internal */
|
|
10474
|
-
var retryOrElse = /*#__PURE__*/ dual(3, (self, policy, orElse) => flatMap$3(toStepWithMetadata(policy), (step) => {
|
|
10475
|
-
let meta = CurrentMetadata.defaultValue();
|
|
10476
|
-
let lastError;
|
|
10477
|
-
const loop = catchCauseFilter$1(suspend$3(() => provideService$1(self, CurrentMetadata, meta)), findErrorOnly, (error) => {
|
|
10478
|
-
lastError = error;
|
|
10479
|
-
return flatMap$3(step(error), (meta_) => {
|
|
10480
|
-
meta = meta_;
|
|
10481
|
-
return loop;
|
|
10482
|
-
});
|
|
10483
|
-
});
|
|
10484
|
-
return catchDone(loop, (out) => internalCall(() => orElse(lastError, out)));
|
|
10485
|
-
}));
|
|
10486
|
-
/** @internal */
|
|
10487
|
-
var retry$1 = /*#__PURE__*/ dual(2, (self, options) => {
|
|
10488
|
-
return retryOrElse(self, typeof options === "function" ? options(identity$2) : isSchedule(options) ? options : buildFromOptions(options), fail$7);
|
|
10489
|
-
});
|
|
10490
|
-
var passthroughForever = /*#__PURE__*/ passthrough$2(forever$1);
|
|
10491
|
-
/** @internal */
|
|
10492
|
-
var buildFromOptions = (options) => {
|
|
10493
|
-
let schedule = options.schedule ? passthrough$2(options.schedule) : passthroughForever;
|
|
10494
|
-
if (options.while) schedule = while_(schedule, ({ input }) => {
|
|
10495
|
-
const applied = options.while(input);
|
|
10496
|
-
return isEffect$1(applied) ? applied : succeed$6(applied);
|
|
10497
|
-
});
|
|
10498
|
-
if (options.until) schedule = while_(schedule, ({ input }) => {
|
|
10499
|
-
const applied = options.until(input);
|
|
10500
|
-
return isEffect$1(applied) ? map$4(applied, (b) => !b) : succeed$6(!applied);
|
|
10501
|
-
});
|
|
10502
|
-
if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$6(attempt <= options.times));
|
|
10503
|
-
return schedule;
|
|
10504
|
-
};
|
|
10505
|
-
//#endregion
|
|
10506
10157
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Effect.js
|
|
10507
10158
|
/**
|
|
10508
10159
|
* Checks whether a value is an `Effect`.
|
|
@@ -11162,7 +10813,7 @@ var gen = gen$1;
|
|
|
11162
10813
|
* @category constructors
|
|
11163
10814
|
* @since 2.0.0
|
|
11164
10815
|
*/
|
|
11165
|
-
var fail$
|
|
10816
|
+
var fail$5 = fail$8;
|
|
11166
10817
|
/**
|
|
11167
10818
|
* Creates an `Effect` that represents a failure with a specific `Cause`.
|
|
11168
10819
|
*
|
|
@@ -11429,7 +11080,7 @@ var flatMap$1 = flatMap$3;
|
|
|
11429
11080
|
* @category sequencing
|
|
11430
11081
|
* @since 2.0.0
|
|
11431
11082
|
*/
|
|
11432
|
-
var flatten$
|
|
11083
|
+
var flatten$2 = flatten$3;
|
|
11433
11084
|
/**
|
|
11434
11085
|
* Runs this effect and then runs another effect, optionally using the first
|
|
11435
11086
|
* effect's success value to choose the next effect.
|
|
@@ -12087,59 +11738,6 @@ var orDie = orDie$1;
|
|
|
12087
11738
|
*/
|
|
12088
11739
|
var tapError = tapError$1;
|
|
12089
11740
|
/**
|
|
12090
|
-
* Retries typed failures from an effect according to a retry policy.
|
|
12091
|
-
*
|
|
12092
|
-
* **When to use**
|
|
12093
|
-
*
|
|
12094
|
-
* Use when you need to rerun an effect after transient typed failures, such as
|
|
12095
|
-
* network issues or temporary resource unavailability.
|
|
12096
|
-
*
|
|
12097
|
-
* **Details**
|
|
12098
|
-
*
|
|
12099
|
-
* The policy can be a `Schedule`, a schedule builder, or a `Retry.Options`
|
|
12100
|
-
* object using `schedule`, `times`, `while`, or `until`. If a retry eventually
|
|
12101
|
-
* succeeds, the returned effect succeeds with that value. If the policy stops
|
|
12102
|
-
* while the effect is still failing, the last failure is propagated.
|
|
12103
|
-
*
|
|
12104
|
-
* **Gotchas**
|
|
12105
|
-
*
|
|
12106
|
-
* The source effect is always evaluated once before any retry policy is
|
|
12107
|
-
* applied. For example, `Schedule.recurs(3)` allows up to three retries after
|
|
12108
|
-
* the initial attempt.
|
|
12109
|
-
*
|
|
12110
|
-
* Defects and interruptions are not retried.
|
|
12111
|
-
*
|
|
12112
|
-
* **Example** (Retrying with a schedule)
|
|
12113
|
-
*
|
|
12114
|
-
* ```ts import.meta.vitest
|
|
12115
|
-
* import { Data, Effect, Schedule } from "effect"
|
|
12116
|
-
*
|
|
12117
|
-
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
12118
|
-
*
|
|
12119
|
-
* let attempt = 0
|
|
12120
|
-
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
12121
|
-
* attempt++
|
|
12122
|
-
* if (attempt <= 2) {
|
|
12123
|
-
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
12124
|
-
* } else {
|
|
12125
|
-
* resume(Effect.succeed("Success!"))
|
|
12126
|
-
* }
|
|
12127
|
-
* })
|
|
12128
|
-
*
|
|
12129
|
-
* const policy = Schedule.recurs(5)
|
|
12130
|
-
* const program = Effect.retry(task, policy)
|
|
12131
|
-
*
|
|
12132
|
-
* await Effect.runPromise(program) // => "Success!"
|
|
12133
|
-
* ```
|
|
12134
|
-
*
|
|
12135
|
-
* @see {@link retryOrElse} for a version that allows you to run a fallback.
|
|
12136
|
-
* @see {@link repeat} if your retry condition is based on successful outcomes rather than errors.
|
|
12137
|
-
* @stability stable
|
|
12138
|
-
* @category error handling
|
|
12139
|
-
* @since 2.0.0
|
|
12140
|
-
*/
|
|
12141
|
-
var retry = retry$1;
|
|
12142
|
-
/**
|
|
12143
11741
|
* Discards both the success and failure values of an effect.
|
|
12144
11742
|
*
|
|
12145
11743
|
* **When to use**
|
|
@@ -13209,7 +12807,7 @@ var addFinalizer = addFinalizer$2;
|
|
|
13209
12807
|
* @category resource management
|
|
13210
12808
|
* @since 2.0.0
|
|
13211
12809
|
*/
|
|
13212
|
-
var ensuring = ensuring$
|
|
12810
|
+
var ensuring$2 = ensuring$3;
|
|
13213
12811
|
/**
|
|
13214
12812
|
* Runs the specified effect if this effect fails, providing the error to the
|
|
13215
12813
|
* effect if it exists. The provided effect will not be interrupted.
|
|
@@ -13293,7 +12891,7 @@ var onExitPrimitive = onExitPrimitive$1;
|
|
|
13293
12891
|
* @category resource management
|
|
13294
12892
|
* @since 2.0.0
|
|
13295
12893
|
*/
|
|
13296
|
-
var onExit = onExit$
|
|
12894
|
+
var onExit$1 = onExit$2;
|
|
13297
12895
|
/**
|
|
13298
12896
|
* Returns an effect that lazily computes a result and caches it for subsequent
|
|
13299
12897
|
* evaluations.
|
|
@@ -13472,7 +13070,7 @@ var uninterruptibleMask = uninterruptibleMask$1;
|
|
|
13472
13070
|
* @category repetition
|
|
13473
13071
|
* @since 2.0.0
|
|
13474
13072
|
*/
|
|
13475
|
-
var forever = forever$
|
|
13073
|
+
var forever = forever$1;
|
|
13476
13074
|
/**
|
|
13477
13075
|
* Returns an effect that forks this effect into its own separate fiber,
|
|
13478
13076
|
* returning the fiber immediately, without waiting for it to begin executing
|
|
@@ -14358,11 +13956,11 @@ var annotateLogs = /*#__PURE__*/ dual((args) => isEffect(args[0]), (effect, ...a
|
|
|
14358
13956
|
var effectify = (fn, onError, onSyncError) => (...args) => callback$1((resume) => {
|
|
14359
13957
|
try {
|
|
14360
13958
|
fn(...args, (err, result) => {
|
|
14361
|
-
if (err) resume(onError ? suspend$2(() => fail$
|
|
13959
|
+
if (err) resume(onError ? suspend$2(() => fail$5(onError(err, args))) : fail$5(err));
|
|
14362
13960
|
else resume(succeed$2(result));
|
|
14363
13961
|
});
|
|
14364
13962
|
} catch (err) {
|
|
14365
|
-
resume(onSyncError ? fail$
|
|
13963
|
+
resume(onSyncError ? fail$5(onSyncError(err, args)) : die(err));
|
|
14366
13964
|
}
|
|
14367
13965
|
});
|
|
14368
13966
|
/**
|
|
@@ -14910,7 +14508,7 @@ var BigInt$4 = globalThis.BigInt;
|
|
|
14910
14508
|
* @since 2.0.0
|
|
14911
14509
|
*/
|
|
14912
14510
|
var toNumber = (b) => {
|
|
14913
|
-
if (b > BigInt$4(Number.MAX_SAFE_INTEGER) || b < BigInt$4(Number.MIN_SAFE_INTEGER)) return none();
|
|
14511
|
+
if (b > BigInt$4(Number.MAX_SAFE_INTEGER) || b < BigInt$4(Number.MIN_SAFE_INTEGER)) return none$1();
|
|
14914
14512
|
return some(Number(b));
|
|
14915
14513
|
};
|
|
14916
14514
|
//#endregion
|
|
@@ -15226,14 +14824,14 @@ var encode = (input) => encodeBytes(typeof input === "string" ? encoder$2.encode
|
|
|
15226
14824
|
var decode = (str) => {
|
|
15227
14825
|
const stripped = stripCrlf(str);
|
|
15228
14826
|
const length = stripped.length;
|
|
15229
|
-
if (length % 4 !== 0) return fail$
|
|
14827
|
+
if (length % 4 !== 0) return fail$9(new EncodingError({
|
|
15230
14828
|
kind: "Decode",
|
|
15231
14829
|
module: "Base64",
|
|
15232
14830
|
input: stripped,
|
|
15233
14831
|
message: `Length must be a multiple of 4, but is ${length}`
|
|
15234
14832
|
}));
|
|
15235
14833
|
const index = stripped.indexOf("=");
|
|
15236
|
-
if (index !== -1 && (index < length - 2 || index === length - 2 && stripped[length - 1] !== "=")) return fail$
|
|
14834
|
+
if (index !== -1 && (index < length - 2 || index === length - 2 && stripped[length - 1] !== "=")) return fail$9(new EncodingError({
|
|
15237
14835
|
kind: "Decode",
|
|
15238
14836
|
module: "Base64",
|
|
15239
14837
|
input: stripped,
|
|
@@ -15250,7 +14848,7 @@ var decode = (str) => {
|
|
|
15250
14848
|
}
|
|
15251
14849
|
return succeed$7(result);
|
|
15252
14850
|
} catch (cause) {
|
|
15253
|
-
return fail$
|
|
14851
|
+
return fail$9(new EncodingError({
|
|
15254
14852
|
kind: "Decode",
|
|
15255
14853
|
module: "Base64",
|
|
15256
14854
|
input: stripped,
|
|
@@ -15325,7 +14923,7 @@ var missingExit = /*#__PURE__*/ succeed$1(missing);
|
|
|
15325
14923
|
/** @internal */
|
|
15326
14924
|
var sameExit = /*#__PURE__*/ succeed$1(missing);
|
|
15327
14925
|
/** @internal */
|
|
15328
|
-
var toOption = (value) => value === missing ? none() : some(value);
|
|
14926
|
+
var toOption = (value) => value === missing ? none$1() : some(value);
|
|
15329
14927
|
/** @internal */
|
|
15330
14928
|
var fromOptionExit = (option) => option._tag === "None" ? missingExit : succeed$1(option.value);
|
|
15331
14929
|
//#endregion
|
|
@@ -16740,9 +16338,9 @@ var Arrays = class extends ASTNodeImpl {
|
|
|
16740
16338
|
if (options.errors === "all") {
|
|
16741
16339
|
if (state.issues) state.issues.push(issue);
|
|
16742
16340
|
else state.issues = [issue];
|
|
16743
|
-
} else return fail$
|
|
16341
|
+
} else return fail$5(new Composite(ast, [issue], input, options));
|
|
16744
16342
|
}
|
|
16745
|
-
if (state.issues) return fail$
|
|
16343
|
+
if (state.issues) return fail$5(new Composite(ast, state.issues, input, options));
|
|
16746
16344
|
return succeed$1(state.output);
|
|
16747
16345
|
};
|
|
16748
16346
|
const parse = (input, options) => {
|
|
@@ -16775,7 +16373,7 @@ var Arrays = class extends ASTNodeImpl {
|
|
|
16775
16373
|
return (input, options) => {
|
|
16776
16374
|
if (input === missing) return missingExit;
|
|
16777
16375
|
try {
|
|
16778
|
-
if (!Array.isArray(input)) return fail$
|
|
16376
|
+
if (!Array.isArray(input)) return fail$5(new InvalidType(ast, input, options));
|
|
16779
16377
|
if (!elements) {
|
|
16780
16378
|
elements = ast.elements.map((ast) => ({
|
|
16781
16379
|
ast,
|
|
@@ -16822,7 +16420,7 @@ function stepArray(s, item, exit, i) {
|
|
|
16822
16420
|
if (s.options.errors === "all") {
|
|
16823
16421
|
if (s.issues) s.issues.push(issue);
|
|
16824
16422
|
else s.issues = [issue];
|
|
16825
|
-
} else return fail$
|
|
16423
|
+
} else return fail$7(new Composite(s.ast, [issue], s.input, s.options));
|
|
16826
16424
|
}
|
|
16827
16425
|
}
|
|
16828
16426
|
var parseArrayOptions = {
|
|
@@ -16843,7 +16441,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => {
|
|
|
16843
16441
|
if (s.options.errors === "all") {
|
|
16844
16442
|
if (s.issues) s.issues.push(pointer);
|
|
16845
16443
|
else s.issues = [pointer];
|
|
16846
|
-
} else return fail$
|
|
16444
|
+
} else return fail$7(new Composite(ast, [pointer], s.input, s.options));
|
|
16847
16445
|
};
|
|
16848
16446
|
/**
|
|
16849
16447
|
* floating point or integer, with optional exponent
|
|
@@ -17000,7 +16598,7 @@ var Objects = class extends ASTNodeImpl {
|
|
|
17000
16598
|
}) : void 0;
|
|
17001
16599
|
return fnUntracedEager(function* (input, options) {
|
|
17002
16600
|
if (input === missing) return missing;
|
|
17003
|
-
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) return yield* fail$
|
|
16601
|
+
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) return yield* fail$5(new InvalidType(ast, input, options));
|
|
17004
16602
|
compileMembers();
|
|
17005
16603
|
const record = input;
|
|
17006
16604
|
const out = {};
|
|
@@ -17028,7 +16626,7 @@ var Objects = class extends ASTNodeImpl {
|
|
|
17028
16626
|
if (state.issues) state.issues.push(issue);
|
|
17029
16627
|
else state.issues = [issue];
|
|
17030
16628
|
continue;
|
|
17031
|
-
} else return yield* fail$
|
|
16629
|
+
} else return yield* fail$5(new Composite(ast, [issue], input, options));
|
|
17032
16630
|
}
|
|
17033
16631
|
}
|
|
17034
16632
|
}
|
|
@@ -17056,7 +16654,7 @@ var Objects = class extends ASTNodeImpl {
|
|
|
17056
16654
|
const eff = parseIndexes(state, keyPairs, { concurrency });
|
|
17057
16655
|
if (eff) yield* eff;
|
|
17058
16656
|
}
|
|
17059
|
-
if (state.issues) return yield* fail$
|
|
16657
|
+
if (state.issues) return yield* fail$5(new Composite(ast, state.issues, input, options));
|
|
17060
16658
|
return out;
|
|
17061
16659
|
});
|
|
17062
16660
|
};
|
|
@@ -17075,7 +16673,7 @@ var Objects = class extends ASTNodeImpl {
|
|
|
17075
16673
|
return (input, options) => {
|
|
17076
16674
|
if (input === missing) return missingExit;
|
|
17077
16675
|
if (options.errors === "all" || options.onExcessProperty !== void 0 || options.concurrency !== void 0 && resolveConcurrency(options.concurrency) !== 1) return (fallback ??= makeFallback())(input, options);
|
|
17078
|
-
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) return fail$
|
|
16676
|
+
if (!(typeof input === "object" && input !== null && !Array.isArray(input))) return fail$5(new InvalidType(ast, input, options));
|
|
17079
16677
|
const props = compileMembers();
|
|
17080
16678
|
const record = input;
|
|
17081
16679
|
const out = {};
|
|
@@ -17149,7 +16747,7 @@ function stepProperty(s, p, exit) {
|
|
|
17149
16747
|
if (s.issues) s.issues.push(issue);
|
|
17150
16748
|
else s.issues = [issue];
|
|
17151
16749
|
return;
|
|
17152
|
-
} else return fail$
|
|
16750
|
+
} else return fail$7(new Composite(s.ast, [issue], s.input, s.options));
|
|
17153
16751
|
}
|
|
17154
16752
|
}
|
|
17155
16753
|
var parsePropertiesOptions = {
|
|
@@ -17414,7 +17012,7 @@ var Union$1 = class extends ASTNodeImpl {
|
|
|
17414
17012
|
return (input, options) => {
|
|
17415
17013
|
if (input === missing) return missingExit;
|
|
17416
17014
|
const candidates = (index ??= getCandidateIndex(ast.types))(input, isConstructor);
|
|
17417
|
-
if (candidates.length === 0) return fail$
|
|
17015
|
+
if (candidates.length === 0) return fail$5(new AnyOf(ast, [], input, options));
|
|
17418
17016
|
if (candidates.length === 1) {
|
|
17419
17017
|
const result = parser(candidates[0])(input, options);
|
|
17420
17018
|
if (result._tag === "Success") return result;
|
|
@@ -17469,7 +17067,7 @@ var Union$1 = class extends ASTNodeImpl {
|
|
|
17469
17067
|
function failSingleUnionCandidate(ast, cause, input, options) {
|
|
17470
17068
|
const issue = getSchemaIssue(cause);
|
|
17471
17069
|
if (!issue) return failCause$4(cause);
|
|
17472
|
-
return fail$
|
|
17070
|
+
return fail$7(new AnyOf(ast, [issue], input, options));
|
|
17473
17071
|
}
|
|
17474
17072
|
function catchSingleUnionCandidate(ast, result, input, options) {
|
|
17475
17073
|
return catchCause$1(result, (cause) => failSingleUnionCandidate(ast, cause, input, options));
|
|
@@ -17487,7 +17085,7 @@ function parseUnionCandidates(ast, parser, candidates, input, options) {
|
|
|
17487
17085
|
const eff = parseUnion(state, candidates);
|
|
17488
17086
|
if (!eff) {
|
|
17489
17087
|
if (state.out) return state.out;
|
|
17490
|
-
return fail$
|
|
17088
|
+
return fail$5(new AnyOf(ast, state.issues ?? [], input, options));
|
|
17491
17089
|
}
|
|
17492
17090
|
if (effectIsExit(eff)) return resumeUnion(eff, state);
|
|
17493
17091
|
let first = true;
|
|
@@ -17501,7 +17099,7 @@ function resumeUnion(eff, state) {
|
|
|
17501
17099
|
return flatMapEager(eff, (_) => {
|
|
17502
17100
|
if (state.out === sameExit) return succeed$2(state.input);
|
|
17503
17101
|
if (state.out) return state.out;
|
|
17504
|
-
return fail$
|
|
17102
|
+
return fail$5(new AnyOf(state.ast, state.issues ?? [], state.input, state.options));
|
|
17505
17103
|
});
|
|
17506
17104
|
}
|
|
17507
17105
|
var parseUnion = /*#__PURE__*/ iterateEager()({
|
|
@@ -17517,7 +17115,7 @@ var parseUnion = /*#__PURE__*/ iterateEager()({
|
|
|
17517
17115
|
} else {
|
|
17518
17116
|
if (s.out && s.successes) {
|
|
17519
17117
|
s.successes.push(s.ast.types[i]);
|
|
17520
|
-
return fail$
|
|
17118
|
+
return fail$7(new OneOf(s.ast, s.successes, s.input, s.options));
|
|
17521
17119
|
}
|
|
17522
17120
|
s.out = exit;
|
|
17523
17121
|
if (s.successes) s.successes.push(s.ast.types[i]);
|
|
@@ -18006,14 +17604,14 @@ function fromConst(ast, value) {
|
|
|
18006
17604
|
return (input, options) => {
|
|
18007
17605
|
if (input === missing) return missingExit;
|
|
18008
17606
|
if (input === value) return succeed;
|
|
18009
|
-
return fail$
|
|
17607
|
+
return fail$5(new InvalidType(ast, input, options));
|
|
18010
17608
|
};
|
|
18011
17609
|
}
|
|
18012
17610
|
function fromRefinement(ast, refinement) {
|
|
18013
17611
|
return (input, options) => {
|
|
18014
17612
|
if (input === missing) return missingExit;
|
|
18015
17613
|
if (refinement(input)) return sameExit;
|
|
18016
|
-
return fail$
|
|
17614
|
+
return fail$5(new InvalidType(ast, input, options));
|
|
18017
17615
|
};
|
|
18018
17616
|
}
|
|
18019
17617
|
/** @internal */
|
|
@@ -18131,7 +17729,7 @@ function isStringTree(u) {
|
|
|
18131
17729
|
return isTree(u, isStringTreeLeaf);
|
|
18132
17730
|
}
|
|
18133
17731
|
/** @internal */
|
|
18134
|
-
var unknownToStringTree = /*#__PURE__*/ new Link(/* @__PURE__ */ new Declaration([], () => (input, ast, options) => isStringTree(input) ? sameExit : fail$
|
|
17732
|
+
var unknownToStringTree = /*#__PURE__*/ new Link(/* @__PURE__ */ new Declaration([], () => (input, ast, options) => isStringTree(input) ? sameExit : fail$5(new InvalidType(ast, input, options)), {
|
|
18135
17733
|
expected: "StringTree",
|
|
18136
17734
|
toCodecStringTree: () => void 0
|
|
18137
17735
|
}), /*#__PURE__*/ passthrough());
|
|
@@ -18209,13 +17807,13 @@ function compile(ast, compile, compileField, base, specialize) {
|
|
|
18209
17807
|
const output = result === sameExit ? input : result[args];
|
|
18210
17808
|
if (input !== missing && output !== missing) {
|
|
18211
17809
|
const issues = collectIssues(encodingChecks, input, void 0, ast, options);
|
|
18212
|
-
if (issues) result = fail$
|
|
17810
|
+
if (issues) result = fail$5(new Composite(ast, issues, input, options));
|
|
18213
17811
|
}
|
|
18214
17812
|
}
|
|
18215
17813
|
} else result = flatMap$1(result, (value) => {
|
|
18216
17814
|
if (input !== missing && value !== missing) {
|
|
18217
17815
|
const issues = collectIssues(encodingChecks, input, void 0, ast, options);
|
|
18218
|
-
if (issues) return fail$
|
|
17816
|
+
if (issues) return fail$5(new Composite(ast, issues, input, options));
|
|
18219
17817
|
}
|
|
18220
17818
|
return succeed$2(value);
|
|
18221
17819
|
});
|
|
@@ -18226,12 +17824,12 @@ function compile(ast, compile, compileField, base, specialize) {
|
|
|
18226
17824
|
const value = result === sameExit ? input : result[args];
|
|
18227
17825
|
if (value === missing) return result;
|
|
18228
17826
|
const issues = collectIssues(checks, value, void 0, ast, options);
|
|
18229
|
-
if (issues) result = fail$
|
|
17827
|
+
if (issues) result = fail$5(new Composite(ast, issues, value, options));
|
|
18230
17828
|
}
|
|
18231
17829
|
} else result = flatMap$1(result, (value) => {
|
|
18232
17830
|
if (value !== missing) {
|
|
18233
17831
|
const issues = collectIssues(checks, value, void 0, ast, options);
|
|
18234
|
-
if (issues) return fail$
|
|
17832
|
+
if (issues) return fail$5(new Composite(ast, issues, value, options));
|
|
18235
17833
|
}
|
|
18236
17834
|
return succeed$2(value);
|
|
18237
17835
|
});
|
|
@@ -18377,7 +17975,7 @@ function makeOption(schema) {
|
|
|
18377
17975
|
const exit = runSyncExit(parser(input, options));
|
|
18378
17976
|
if (isSuccess(exit)) return some(exit.value);
|
|
18379
17977
|
getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues");
|
|
18380
|
-
return none();
|
|
17978
|
+
return none$1();
|
|
18381
17979
|
};
|
|
18382
17980
|
}
|
|
18383
17981
|
/**
|
|
@@ -18479,7 +18077,7 @@ var mergeParseOptions = (options, overrideOptions) => overrideOptions ? {
|
|
|
18479
18077
|
...overrideOptions
|
|
18480
18078
|
} : options;
|
|
18481
18079
|
var getValue = (value) => {
|
|
18482
|
-
if (value === missing) return fail$
|
|
18080
|
+
if (value === missing) return fail$5(new InvalidValue());
|
|
18483
18081
|
return succeed$2(value);
|
|
18484
18082
|
};
|
|
18485
18083
|
/** @internal */
|
|
@@ -18819,7 +18417,7 @@ function declareConstructor() {
|
|
|
18819
18417
|
* @since 3.10.0
|
|
18820
18418
|
*/
|
|
18821
18419
|
function declare(is, annotations) {
|
|
18822
|
-
return declareConstructor()([], () => (input, ast, options) => is(input) ? succeed$2(input) : fail$
|
|
18420
|
+
return declareConstructor()([], () => (input, ast, options) => is(input) ? succeed$2(input) : fail$5(new InvalidType(ast, input, options)), annotations);
|
|
18823
18421
|
}
|
|
18824
18422
|
/**
|
|
18825
18423
|
* Error thrown or returned when schema decoding or encoding fails.
|
|
@@ -20657,7 +20255,7 @@ var SubscriptionTypeId = "~effect/PubSub/Subscription";
|
|
|
20657
20255
|
* @category constructors
|
|
20658
20256
|
* @since 4.0.0
|
|
20659
20257
|
*/
|
|
20660
|
-
var make$10 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), /* @__PURE__ */ new Map(), makeUnsafe$4(), makeUnsafe$1(false), make$12(false), options.strategy(), make$12(none())));
|
|
20258
|
+
var make$10 = (options) => sync(() => makePubSubUnsafe(options.atomicPubSub(), /* @__PURE__ */ new Map(), makeUnsafe$4(), makeUnsafe$1(false), make$12(false), options.strategy(), make$12(none$1())));
|
|
20661
20259
|
/**
|
|
20662
20260
|
* Creates a bounded `PubSub` with the sliding strategy. The `PubSub` will add new
|
|
20663
20261
|
* messages and drop old messages if the `PubSub` is at capacity.
|
|
@@ -23232,7 +22830,7 @@ var fromIterator = (iterator) => fromPull$1(sync(() => {
|
|
|
23232
22830
|
* @category constructors
|
|
23233
22831
|
* @since 2.0.0
|
|
23234
22832
|
*/
|
|
23235
|
-
var succeed = (value) => fromEffect
|
|
22833
|
+
var succeed = (value) => fromEffect(succeed$2(value));
|
|
23236
22834
|
/**
|
|
23237
22835
|
* Represents a `Channel` that emits no elements.
|
|
23238
22836
|
*
|
|
@@ -23276,7 +22874,7 @@ var empty$1 = /*#__PURE__*/ fromPull$1(/*#__PURE__*/ succeed$2(/*#__PURE__*/ don
|
|
|
23276
22874
|
* @category constructors
|
|
23277
22875
|
* @since 2.0.0
|
|
23278
22876
|
*/
|
|
23279
|
-
var fail$
|
|
22877
|
+
var fail$3 = (error) => fromPull$1(succeed$2(fail$5(error)));
|
|
23280
22878
|
/**
|
|
23281
22879
|
* Constructs a channel that fails immediately with the specified `Cause`.
|
|
23282
22880
|
*
|
|
@@ -23318,7 +22916,7 @@ var failCause = (cause) => fromPull$1(failCause$2(cause));
|
|
|
23318
22916
|
* @category constructors
|
|
23319
22917
|
* @since 2.0.0
|
|
23320
22918
|
*/
|
|
23321
|
-
var fromEffect
|
|
22919
|
+
var fromEffect = (effect) => fromPull$1(sync(() => {
|
|
23322
22920
|
let done$18 = false;
|
|
23323
22921
|
return suspend$2(() => {
|
|
23324
22922
|
if (done$18) return done();
|
|
@@ -23587,6 +23185,55 @@ var fromSubscriptionArray = (subscription) => fromPull$1(succeed$2(onInterrupt(t
|
|
|
23587
23185
|
*/
|
|
23588
23186
|
var fromPubSubArray = (pubsub) => unwrap$2(map$2(subscribe(pubsub), fromSubscriptionArray));
|
|
23589
23187
|
/**
|
|
23188
|
+
* Creates a channel that pulls values from an `AsyncIterable`.
|
|
23189
|
+
*
|
|
23190
|
+
* **Details**
|
|
23191
|
+
*
|
|
23192
|
+
* Each yielded value is emitted as an output element. The iterator's return
|
|
23193
|
+
* value becomes the channel's done value. Thrown or rejected iterator errors
|
|
23194
|
+
* are converted with `onError`. If the channel scope closes early and the
|
|
23195
|
+
* iterator has a `return` method, that method is called. It is awaited unless
|
|
23196
|
+
* a `next()` call is still pending, in which case its result is ignored and an
|
|
23197
|
+
* async generator may not run its cleanup until that pull settles.
|
|
23198
|
+
*
|
|
23199
|
+
* @stability stable
|
|
23200
|
+
* @category constructors
|
|
23201
|
+
* @since 4.0.0
|
|
23202
|
+
*/
|
|
23203
|
+
var fromAsyncIterable$1 = (iterable, onError) => fromTransform$1(fnUntraced(function* (_, scope) {
|
|
23204
|
+
const iter = iterable[Symbol.asyncIterator]();
|
|
23205
|
+
let pulling = false;
|
|
23206
|
+
if (iter.return) yield* addFinalizer$1(scope, suspend$2(() => pulling ? sync(() => void iter.return().catch(constVoid)) : promise(() => iter.return())));
|
|
23207
|
+
return flatMap$1(tryPromise({
|
|
23208
|
+
try: () => {
|
|
23209
|
+
const promise = iter.next();
|
|
23210
|
+
pulling = true;
|
|
23211
|
+
return promise.finally(() => {
|
|
23212
|
+
pulling = false;
|
|
23213
|
+
});
|
|
23214
|
+
},
|
|
23215
|
+
catch: onError
|
|
23216
|
+
}), (result) => result.done ? done(result.value) : succeed$2(result.value));
|
|
23217
|
+
}));
|
|
23218
|
+
/**
|
|
23219
|
+
* Creates a channel from an `AsyncIterable`, emitting each yielded value as a
|
|
23220
|
+
* single-element non-empty array.
|
|
23221
|
+
*
|
|
23222
|
+
* **Details**
|
|
23223
|
+
*
|
|
23224
|
+
* The iterator's return value becomes the channel's done value. Thrown or
|
|
23225
|
+
* rejected iterator errors are converted with `onError`. If the channel scope
|
|
23226
|
+
* closes early and the iterator has a `return` method, that method is called.
|
|
23227
|
+
* It is awaited unless a `next()` call is still pending, in which case its
|
|
23228
|
+
* result is ignored and an async generator may not run its cleanup until that
|
|
23229
|
+
* pull settles.
|
|
23230
|
+
*
|
|
23231
|
+
* @stability stable
|
|
23232
|
+
* @category constructors
|
|
23233
|
+
* @since 4.0.0
|
|
23234
|
+
*/
|
|
23235
|
+
var fromAsyncIterableArray = (iterable, onError) => map$1(fromAsyncIterable$1(iterable, onError), of);
|
|
23236
|
+
/**
|
|
23590
23237
|
* Maps the output of this channel using the specified function.
|
|
23591
23238
|
*
|
|
23592
23239
|
* **Example** (Mapping channel output)
|
|
@@ -23714,7 +23361,7 @@ var mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntraced(
|
|
|
23714
23361
|
} else {
|
|
23715
23362
|
const effects = yield* bounded(concurrencyN - 2);
|
|
23716
23363
|
yield* addFinalizer$1(forkedScope, shutdown(effects));
|
|
23717
|
-
yield* take(effects).pipe(flatten$
|
|
23364
|
+
yield* take(effects).pipe(flatten$2, flatMap$1((value) => offer(queue, value)), forever({ disableYield: true }), catchCause$1((cause) => failCause$1(queue, cause)), forkIn(forkedScope));
|
|
23718
23365
|
let errorCause;
|
|
23719
23366
|
const onExit = (exit) => {
|
|
23720
23367
|
if (exit._tag === "Success") return;
|
|
@@ -23819,7 +23466,7 @@ var flatMapConcurrent = (self, f, options) => self.pipe(map$1(f), mergeAll(optio
|
|
|
23819
23466
|
* @category constructors
|
|
23820
23467
|
* @since 2.0.0
|
|
23821
23468
|
*/
|
|
23822
|
-
var flatten = (channels) => flatMap(channels, identity$2);
|
|
23469
|
+
var flatten$1 = (channels) => flatMap(channels, identity$2);
|
|
23823
23470
|
/**
|
|
23824
23471
|
* Flattens a channel that outputs arrays into a channel that outputs individual elements.
|
|
23825
23472
|
*
|
|
@@ -24020,7 +23667,7 @@ var catch_ = /*#__PURE__*/ dual(2, (self, f) => catchCauseFilter(self, findError
|
|
|
24020
23667
|
* @category error handling
|
|
24021
23668
|
* @since 2.0.0
|
|
24022
23669
|
*/
|
|
24023
|
-
var mapError$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (err) => fail$
|
|
23670
|
+
var mapError$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (err) => fail$3(f(err))));
|
|
24024
23671
|
/**
|
|
24025
23672
|
* Ignores all errors in the channel, converting them to an empty channel.
|
|
24026
23673
|
*
|
|
@@ -24144,7 +23791,7 @@ var mergeAll = /*#__PURE__*/ dual(2, (channels, { bufferSize = 16, concurrency,
|
|
|
24144
23791
|
* @category combining
|
|
24145
23792
|
* @since 4.0.0
|
|
24146
23793
|
*/
|
|
24147
|
-
var merge$
|
|
23794
|
+
var merge$2 = /*#__PURE__*/ dual((args) => isChannel(args[0]) && isChannel(args[1]), (left, right, options) => fromTransformBracket(fnUntraced(function* (upstream, _scope, forkedScope) {
|
|
24148
23795
|
const strategy = options?.haltStrategy ?? "both";
|
|
24149
23796
|
const queue = yield* bounded(0);
|
|
24150
23797
|
yield* addFinalizer$1(forkedScope, shutdown(queue));
|
|
@@ -24197,7 +23844,7 @@ var merge$1 = /*#__PURE__*/ dual((args) => isChannel(args[0]) && isChannel(args[
|
|
|
24197
23844
|
var splitLines$1 = () => fromTransform$1((upstream, _scope) => sync(() => {
|
|
24198
23845
|
let stringBuilder = "";
|
|
24199
23846
|
let midCRLF = false;
|
|
24200
|
-
let done$14 = none();
|
|
23847
|
+
let done$14 = none$1();
|
|
24201
23848
|
function splitLinesArray(chunk) {
|
|
24202
23849
|
const chunkBuilder = [];
|
|
24203
23850
|
function pushLine(segment) {
|
|
@@ -24329,58 +23976,118 @@ var unwrap$2 = (channel) => fromTransform$1((upstream, scope) => {
|
|
|
24329
23976
|
return channel.pipe(provide$3(scope), flatMap$1((channel) => toTransform(channel)(upstream, scope)), flatMap$1((pull_) => pull = pull_));
|
|
24330
23977
|
}));
|
|
24331
23978
|
});
|
|
24332
|
-
var runWith = (self, f, onHalt) => suspend$2(() => {
|
|
24333
|
-
const scope = makeUnsafe$4();
|
|
24334
|
-
return catchDone(flatMap$1(toTransform(self)(done(), scope), f), onHalt ? onHalt : succeed$2).pipe(onExit((exit) => close(scope, exit)));
|
|
24335
|
-
});
|
|
24336
23979
|
/**
|
|
24337
|
-
*
|
|
23980
|
+
* Returns a channel with an exit-aware finalizer that is guaranteed to run once
|
|
23981
|
+
* the channel begins execution, whether it succeeds or fails.
|
|
24338
23982
|
*
|
|
24339
|
-
* **Example** (Running
|
|
23983
|
+
* **Example** (Running exit finalizers)
|
|
24340
23984
|
*
|
|
24341
23985
|
* ```ts import.meta.vitest
|
|
24342
|
-
* import { Channel, Data, Effect } from "effect"
|
|
23986
|
+
* import { Channel, Data, Effect, Exit } from "effect"
|
|
24343
23987
|
*
|
|
24344
|
-
* class
|
|
24345
|
-
* readonly
|
|
23988
|
+
* class ExitError extends Data.TaggedError("ExitError")<{
|
|
23989
|
+
* readonly stage: string
|
|
24346
23990
|
* }> {}
|
|
24347
23991
|
*
|
|
24348
|
-
* // Create a channel
|
|
24349
|
-
* const
|
|
24350
|
-
*
|
|
24351
|
-
* // Run forEach to process each element
|
|
24352
|
-
* const processed: Array<number> = []
|
|
24353
|
-
* const forEachEffect = Channel.runForEach(
|
|
24354
|
-
* numbersChannel,
|
|
24355
|
-
* (n) => Effect.sync(() => processed.push(n))
|
|
24356
|
-
* )
|
|
23992
|
+
* // Create a channel
|
|
23993
|
+
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
24357
23994
|
*
|
|
24358
|
-
*
|
|
24359
|
-
*
|
|
23995
|
+
* // Attach exit handler
|
|
23996
|
+
* const exits: Array<Exit.Exit<void, ExitError>> = []
|
|
23997
|
+
* const channelWithExit = Channel.onExit(dataChannel, (exit) => {
|
|
23998
|
+
* exits.push(exit)
|
|
23999
|
+
* return Effect.void
|
|
24000
|
+
* })
|
|
24001
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithExit)), exits] // => [[1, 2, 3], [Exit.void]]
|
|
24360
24002
|
* ```
|
|
24361
24003
|
*
|
|
24362
24004
|
* @stability stable
|
|
24363
|
-
* @category
|
|
24005
|
+
* @category resource management
|
|
24364
24006
|
* @since 4.0.0
|
|
24365
24007
|
*/
|
|
24366
|
-
var
|
|
24008
|
+
var onExit = /*#__PURE__*/ dual(2, (self, finalizer) => fromTransformBracket((upstream, scope, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen(toTransform(self)(upstream, scope)))));
|
|
24367
24009
|
/**
|
|
24368
|
-
*
|
|
24010
|
+
* Returns a channel with a finalizer effect that is guaranteed to run once the
|
|
24011
|
+
* channel begins execution, whether it succeeds or fails.
|
|
24369
24012
|
*
|
|
24370
|
-
* **Example** (
|
|
24013
|
+
* **Example** (Ensuring cleanup runs)
|
|
24371
24014
|
*
|
|
24372
24015
|
* ```ts import.meta.vitest
|
|
24373
24016
|
* import { Channel, Data, Effect } from "effect"
|
|
24374
24017
|
*
|
|
24375
|
-
* class
|
|
24018
|
+
* class EnsureError extends Data.TaggedError("EnsureError")<{
|
|
24376
24019
|
* readonly operation: string
|
|
24377
24020
|
* }> {}
|
|
24378
24021
|
*
|
|
24379
|
-
* // Create a channel
|
|
24380
|
-
* const
|
|
24022
|
+
* // Create a channel
|
|
24023
|
+
* const dataChannel = Channel.fromIterable([1, 2, 3])
|
|
24381
24024
|
*
|
|
24382
|
-
* //
|
|
24383
|
-
* const
|
|
24025
|
+
* // Ensure cleanup always runs
|
|
24026
|
+
* const events: Array<string> = []
|
|
24027
|
+
* const channelWithCleanup = Channel.ensuring(
|
|
24028
|
+
* dataChannel,
|
|
24029
|
+
* Effect.sync(() => events.push("cleanup"))
|
|
24030
|
+
* )
|
|
24031
|
+
* const observed = [await Effect.runPromise(Channel.runCollect(channelWithCleanup)), events] // => [[1, 2, 3], ["cleanup"]]
|
|
24032
|
+
* ```
|
|
24033
|
+
*
|
|
24034
|
+
* @stability stable
|
|
24035
|
+
* @category resource management
|
|
24036
|
+
* @since 2.0.0
|
|
24037
|
+
*/
|
|
24038
|
+
var ensuring$1 = /*#__PURE__*/ dual(2, (self, finalizer) => onExit(self, (_) => finalizer));
|
|
24039
|
+
var runWith = (self, f, onHalt) => suspend$2(() => {
|
|
24040
|
+
const scope = makeUnsafe$4();
|
|
24041
|
+
return catchDone(flatMap$1(toTransform(self)(done(), scope), f), onHalt ? onHalt : succeed$2).pipe(onExit$1((exit) => close(scope, exit)));
|
|
24042
|
+
});
|
|
24043
|
+
/**
|
|
24044
|
+
* Runs a channel and applies an effect to each output element.
|
|
24045
|
+
*
|
|
24046
|
+
* **Example** (Running effects for each output)
|
|
24047
|
+
*
|
|
24048
|
+
* ```ts import.meta.vitest
|
|
24049
|
+
* import { Channel, Data, Effect } from "effect"
|
|
24050
|
+
*
|
|
24051
|
+
* class ForEachError extends Data.TaggedError("ForEachError")<{
|
|
24052
|
+
* readonly element: unknown
|
|
24053
|
+
* }> {}
|
|
24054
|
+
*
|
|
24055
|
+
* // Create a channel with numbers
|
|
24056
|
+
* const numbersChannel = Channel.fromIterable([1, 2, 3])
|
|
24057
|
+
*
|
|
24058
|
+
* // Run forEach to process each element
|
|
24059
|
+
* const processed: Array<number> = []
|
|
24060
|
+
* const forEachEffect = Channel.runForEach(
|
|
24061
|
+
* numbersChannel,
|
|
24062
|
+
* (n) => Effect.sync(() => processed.push(n))
|
|
24063
|
+
* )
|
|
24064
|
+
*
|
|
24065
|
+
* await Effect.runPromise(forEachEffect)
|
|
24066
|
+
* processed // => [1, 2, 3]
|
|
24067
|
+
* ```
|
|
24068
|
+
*
|
|
24069
|
+
* @stability stable
|
|
24070
|
+
* @category running
|
|
24071
|
+
* @since 4.0.0
|
|
24072
|
+
*/
|
|
24073
|
+
var runForEach$1 = /*#__PURE__*/ dual(2, (self, f) => runWith(self, (pull) => forever(flatMap$1(pull, f), { disableYield: true })));
|
|
24074
|
+
/**
|
|
24075
|
+
* Runs a channel and folds over all output elements with an accumulator.
|
|
24076
|
+
*
|
|
24077
|
+
* **Example** (Folding channel output)
|
|
24078
|
+
*
|
|
24079
|
+
* ```ts import.meta.vitest
|
|
24080
|
+
* import { Channel, Data, Effect } from "effect"
|
|
24081
|
+
*
|
|
24082
|
+
* class FoldError extends Data.TaggedError("FoldError")<{
|
|
24083
|
+
* readonly operation: string
|
|
24084
|
+
* }> {}
|
|
24085
|
+
*
|
|
24086
|
+
* // Create a channel with numbers
|
|
24087
|
+
* const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5])
|
|
24088
|
+
*
|
|
24089
|
+
* // Fold to calculate sum
|
|
24090
|
+
* const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n)
|
|
24384
24091
|
*
|
|
24385
24092
|
* Effect.runSync(sumEffect) // => 15
|
|
24386
24093
|
* ```
|
|
@@ -24705,23 +24412,6 @@ var isStream = (u) => hasProperty(u, TypeId$4);
|
|
|
24705
24412
|
*/
|
|
24706
24413
|
var fromChannel = fromChannel$2;
|
|
24707
24414
|
/**
|
|
24708
|
-
* Creates a stream from an effect.
|
|
24709
|
-
*
|
|
24710
|
-
* **Example** (Creating a stream from an effect)
|
|
24711
|
-
*
|
|
24712
|
-
* ```ts import.meta.vitest
|
|
24713
|
-
* import { Effect, Stream } from "effect"
|
|
24714
|
-
*
|
|
24715
|
-
* const stream = Stream.fromEffect(Effect.succeed(42))
|
|
24716
|
-
* await Effect.runPromise(Stream.runCollect(stream)) // => [42]
|
|
24717
|
-
* ```
|
|
24718
|
-
*
|
|
24719
|
-
* @stability stable
|
|
24720
|
-
* @category constructors
|
|
24721
|
-
* @since 2.0.0
|
|
24722
|
-
*/
|
|
24723
|
-
var fromEffect = (effect) => fromChannel(fromEffect$1(map$2(effect, of)));
|
|
24724
|
-
/**
|
|
24725
24415
|
* Creates a stream from a pull effect, such as one produced by `Stream.toPull`.
|
|
24726
24416
|
*
|
|
24727
24417
|
* **Details**
|
|
@@ -24880,6 +24570,22 @@ var make$7 = (...values) => fromArray(values);
|
|
|
24880
24570
|
*/
|
|
24881
24571
|
var suspend = (stream) => fromChannel(suspend$1(() => stream().channel));
|
|
24882
24572
|
/**
|
|
24573
|
+
* Terminates with the specified error.
|
|
24574
|
+
*
|
|
24575
|
+
* **Example** (Failing a stream)
|
|
24576
|
+
*
|
|
24577
|
+
* ```ts import.meta.vitest
|
|
24578
|
+
* import { Effect, Exit, Stream } from "effect"
|
|
24579
|
+
*
|
|
24580
|
+
* await Effect.runPromise(Effect.exit(Stream.runCollect(Stream.fail("Uh oh!")))) // => Exit.fail("Uh oh!")
|
|
24581
|
+
* ```
|
|
24582
|
+
*
|
|
24583
|
+
* @stability stable
|
|
24584
|
+
* @category constructors
|
|
24585
|
+
* @since 2.0.0
|
|
24586
|
+
*/
|
|
24587
|
+
var fail$2 = (error) => fromChannel(fail$3(error));
|
|
24588
|
+
/**
|
|
24883
24589
|
* Creates a stream from an array of values.
|
|
24884
24590
|
*
|
|
24885
24591
|
* **Example** (Creating a stream from an array of values)
|
|
@@ -24935,6 +24641,35 @@ var fromArray = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel(succeed(
|
|
|
24935
24641
|
*/
|
|
24936
24642
|
var fromPubSub = (pubsub) => fromChannel(fromPubSubArray(pubsub));
|
|
24937
24643
|
/**
|
|
24644
|
+
* Creates a stream from an AsyncIterable.
|
|
24645
|
+
*
|
|
24646
|
+
* **Example** (Creating a stream from an AsyncIterable)
|
|
24647
|
+
*
|
|
24648
|
+
* ```ts import.meta.vitest
|
|
24649
|
+
* import { Data, Effect, Stream } from "effect"
|
|
24650
|
+
*
|
|
24651
|
+
* class StreamError extends Data.TaggedError("StreamError")<{ readonly cause: unknown }> {}
|
|
24652
|
+
*
|
|
24653
|
+
* const iterable = (async function*() {
|
|
24654
|
+
* yield 1
|
|
24655
|
+
* yield 2
|
|
24656
|
+
* yield 3
|
|
24657
|
+
* })()
|
|
24658
|
+
*
|
|
24659
|
+
* await Effect.runPromise(Effect.gen(function*() {
|
|
24660
|
+
* const stream = Stream.fromAsyncIterable(iterable, (cause) => new StreamError({ cause }))
|
|
24661
|
+
* const values = yield* Stream.runCollect(stream)
|
|
24662
|
+
* values // => [1, 2, 3]
|
|
24663
|
+
* }))
|
|
24664
|
+
*
|
|
24665
|
+
* ```
|
|
24666
|
+
*
|
|
24667
|
+
* @stability stable
|
|
24668
|
+
* @category constructors
|
|
24669
|
+
* @since 2.0.0
|
|
24670
|
+
*/
|
|
24671
|
+
var fromAsyncIterable = (iterable, onError) => fromChannel(fromAsyncIterableArray(iterable, onError));
|
|
24672
|
+
/**
|
|
24938
24673
|
* Creates a stream produced from an `Effect`.
|
|
24939
24674
|
*
|
|
24940
24675
|
* **Example** (Unwrapping a stream effect)
|
|
@@ -25094,7 +24829,7 @@ var tap = /*#__PURE__*/ dual((args) => isStream(args[0]), (self, f, options) =>
|
|
|
25094
24829
|
* @since 2.0.0
|
|
25095
24830
|
*/
|
|
25096
24831
|
var concat = /*#__PURE__*/ dual(2, (self, that) => {
|
|
25097
|
-
const stream = fromChannel(flatten(fromIterator(() => concatChannels(self, that))));
|
|
24832
|
+
const stream = fromChannel(flatten$1(fromIterator(() => concatChannels(self, that))));
|
|
25098
24833
|
concatParts.set(stream, [self, that]);
|
|
25099
24834
|
return stream;
|
|
25100
24835
|
});
|
|
@@ -25136,7 +24871,7 @@ function* concatChannels(self, that) {
|
|
|
25136
24871
|
* @category merging
|
|
25137
24872
|
* @since 2.0.0
|
|
25138
24873
|
*/
|
|
25139
|
-
var merge = /*#__PURE__*/ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel(merge$
|
|
24874
|
+
var merge$1 = /*#__PURE__*/ dual((args) => isStream(args[0]) && isStream(args[1]), (self, that, options) => fromChannel(merge$2(toChannel(self), toChannel(that), options)));
|
|
25140
24875
|
/**
|
|
25141
24876
|
* Filters a stream to the elements that satisfy a predicate.
|
|
25142
24877
|
*
|
|
@@ -25383,7 +25118,7 @@ var transduce = /*#__PURE__*/ dual(2, (self, sink) => transformPull(self, (upstr
|
|
|
25383
25118
|
}
|
|
25384
25119
|
return upstream;
|
|
25385
25120
|
}).pipe(catch_$1((error) => {
|
|
25386
|
-
done$3 = fail$
|
|
25121
|
+
done$3 = fail$7(error);
|
|
25387
25122
|
return done();
|
|
25388
25123
|
}));
|
|
25389
25124
|
const pull = map$2(suspend$2(() => sink.transform(upstreamWithLeftover, scope)), ([value, leftover_]) => {
|
|
@@ -25517,6 +25252,33 @@ var decodeText$1 = /*#__PURE__*/ dual((args) => isStream(args[0]), (self, option
|
|
|
25517
25252
|
*/
|
|
25518
25253
|
var splitLines = (self) => self.channel.pipe(pipeTo(splitLines$1()), fromChannel);
|
|
25519
25254
|
/**
|
|
25255
|
+
* Executes the provided finalizer after this stream's finalizers run.
|
|
25256
|
+
*
|
|
25257
|
+
* **Example** (Ensuring finalization)
|
|
25258
|
+
*
|
|
25259
|
+
* ```ts import.meta.vitest
|
|
25260
|
+
* import { Effect, Stream } from "effect"
|
|
25261
|
+
*
|
|
25262
|
+
* const events: Array<string> = []
|
|
25263
|
+
* const stream = Stream.fromArray([1, 2]).pipe(
|
|
25264
|
+
* Stream.ensuring(Effect.sync(() => events.push("cleanup")))
|
|
25265
|
+
* )
|
|
25266
|
+
*
|
|
25267
|
+
* const program = Effect.gen(function*() {
|
|
25268
|
+
* const collected = yield* Stream.runCollect(stream)
|
|
25269
|
+
* collected // => [1, 2]
|
|
25270
|
+
* })
|
|
25271
|
+
*
|
|
25272
|
+
* await Effect.runPromise(program)
|
|
25273
|
+
* events // => ["cleanup"]
|
|
25274
|
+
* ```
|
|
25275
|
+
*
|
|
25276
|
+
* @stability stable
|
|
25277
|
+
* @category resource management
|
|
25278
|
+
* @since 2.0.0
|
|
25279
|
+
*/
|
|
25280
|
+
var ensuring = /*#__PURE__*/ dual(2, (self, finalizer) => fromChannel(ensuring$1(self.channel, finalizer)));
|
|
25281
|
+
/**
|
|
25520
25282
|
* Runs a stream with a sink and returns the sink result.
|
|
25521
25283
|
*
|
|
25522
25284
|
* **Example** (Running a stream with a sink)
|
|
@@ -25697,7 +25459,7 @@ var FileSystem = /*#__PURE__*/ Service("effect/FileSystem");
|
|
|
25697
25459
|
var make$6 = (impl) => FileSystem.of({
|
|
25698
25460
|
...impl,
|
|
25699
25461
|
[TypeId$3]: TypeId$3,
|
|
25700
|
-
exists: (path) => pipe(impl.access(path), as$1(true), catchTag("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed$2(false) : fail$
|
|
25462
|
+
exists: (path) => pipe(impl.access(path), as$1(true), catchTag("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed$2(false) : fail$5(e))),
|
|
25701
25463
|
readFileString: (path, encoding) => flatMap$1(impl.readFile(path), (_) => try_({
|
|
25702
25464
|
try: () => new TextDecoder(encoding).decode(_),
|
|
25703
25465
|
catch: (cause) => badArgument({
|
|
@@ -25920,11 +25682,11 @@ var make$5 = (impl) => Path$1.of({
|
|
|
25920
25682
|
...impl,
|
|
25921
25683
|
[TypeId$2]: TypeId$2,
|
|
25922
25684
|
resolveWithin(root, input) {
|
|
25923
|
-
if (impl.parse(input).root !== "") return none();
|
|
25685
|
+
if (impl.parse(input).root !== "") return none$1();
|
|
25924
25686
|
const base = impl.resolve(root);
|
|
25925
25687
|
const candidate = impl.resolve(base, input);
|
|
25926
25688
|
const relative = impl.relative(base, candidate);
|
|
25927
|
-
return relative === ".." || relative.startsWith(`..${impl.sep}`) || impl.isAbsolute(relative) ? none() : some(candidate);
|
|
25689
|
+
return relative === ".." || relative.startsWith(`..${impl.sep}`) || impl.isAbsolute(relative) ? none$1() : some(candidate);
|
|
25928
25690
|
}
|
|
25929
25691
|
});
|
|
25930
25692
|
//#endregion
|
|
@@ -26607,7 +26369,7 @@ function schema(codec, path) {
|
|
|
26607
26369
|
const fullPath = [...pathPrefix, ...localPath];
|
|
26608
26370
|
return loadCursor(provider, fullPath).pipe(flatMapEager((cursor) => decodeCursor(cursor).pipe(mapEager(succeed$7), catchEager((issue) => {
|
|
26609
26371
|
const error = new ConfigError(new SchemaError(fullPath.length > 0 ? new Pointer(fullPath, issue) : issue));
|
|
26610
|
-
return hasProviderInput(encodedAst, cursor.node) ? fail$
|
|
26372
|
+
return hasProviderInput(encodedAst, cursor.node) ? fail$5(error) : succeed$2(fail$9(error));
|
|
26611
26373
|
}))), mapReasons((reason) => isDieReason(reason) && isSourceError(reason.defect) ? makeFailReason(new ConfigError(reason.defect)).annotate(reasonAnnotations(reason)) : reason));
|
|
26612
26374
|
});
|
|
26613
26375
|
}
|
|
@@ -26671,7 +26433,7 @@ var RuntimePolicy = class extends Service()("@bud.sh/runtime/RuntimePolicy") {};
|
|
|
26671
26433
|
* @returns A validated complete policy, or a typed configuration failure.
|
|
26672
26434
|
*/
|
|
26673
26435
|
function resolveRuntimeOptions(options = {}) {
|
|
26674
|
-
if (typeof options !== "object" || options === null || Array.isArray(options)) return fail$
|
|
26436
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) return fail$5(new RuntimeInputError({
|
|
26675
26437
|
operation: "runtime.config",
|
|
26676
26438
|
message: "Runtime configuration must be an object."
|
|
26677
26439
|
}));
|
|
@@ -27140,7 +26902,7 @@ var processRunnerLayer = effect(ProcessRunner, gen(function* () {
|
|
|
27140
26902
|
}).pipe(scoped);
|
|
27141
26903
|
return yield* semaphore.withPermit(execute).pipe(timeoutOrElse({
|
|
27142
26904
|
duration: timeoutMs,
|
|
27143
|
-
orElse: () => fail$
|
|
26905
|
+
orElse: () => fail$5(new ProcessError({
|
|
27144
26906
|
reason: "timeout",
|
|
27145
26907
|
executable: command.executable,
|
|
27146
26908
|
limit: timeoutMs,
|
|
@@ -27166,7 +26928,7 @@ var writeOptions = Struct({ mode: optional$1(Int$1.check(isBetween({
|
|
|
27166
26928
|
maximum: 511
|
|
27167
26929
|
}))) });
|
|
27168
26930
|
function validPath(path, operation) {
|
|
27169
|
-
return typeof path === "string" && path.length > 0 && !path.includes("\0") ? void_ : fail$
|
|
26931
|
+
return typeof path === "string" && path.length > 0 && !path.includes("\0") ? void_ : fail$5(new RuntimeInputError({
|
|
27170
26932
|
operation,
|
|
27171
26933
|
message: "A nonempty filesystem path without NUL characters is required."
|
|
27172
26934
|
}));
|
|
@@ -27390,7 +27152,7 @@ var pullIntoWritable = (options) => options.pull.pipe(flatMap$1((chunk) => {
|
|
|
27390
27152
|
});
|
|
27391
27153
|
});
|
|
27392
27154
|
}) : identity$2, raceFirst(callback$1((resume) => {
|
|
27393
|
-
const onError = (error) => resume(fail$
|
|
27155
|
+
const onError = (error) => resume(fail$5(options.onError(error)));
|
|
27394
27156
|
options.writable.once("error", onError);
|
|
27395
27157
|
return sync(() => {
|
|
27396
27158
|
options.writable.off("error", onError);
|
|
@@ -27445,11 +27207,11 @@ var readableToPullUnsafe = (options) => {
|
|
|
27445
27207
|
latch.openUnsafe();
|
|
27446
27208
|
}
|
|
27447
27209
|
function onError(error) {
|
|
27448
|
-
exit.current = fail$
|
|
27210
|
+
exit.current = fail$7(options.onError(error));
|
|
27449
27211
|
latch.openUnsafe();
|
|
27450
27212
|
}
|
|
27451
27213
|
function onEnd() {
|
|
27452
|
-
exit.current = fail$
|
|
27214
|
+
exit.current = fail$7(Done());
|
|
27453
27215
|
latch.openUnsafe();
|
|
27454
27216
|
}
|
|
27455
27217
|
readable.on("readable", onReadable);
|
|
@@ -27459,7 +27221,7 @@ var readableToPullUnsafe = (options) => {
|
|
|
27459
27221
|
let item = options.readable.read(options.chunkSize);
|
|
27460
27222
|
if (item === null) {
|
|
27461
27223
|
if (exit.current) return exit.current;
|
|
27462
|
-
if (readable.readableEnded) return fail$
|
|
27224
|
+
if (readable.readableEnded) return fail$5(Done());
|
|
27463
27225
|
latch.closeUnsafe();
|
|
27464
27226
|
return flatMap$1(latch.await, loop);
|
|
27465
27227
|
}
|
|
@@ -27675,7 +27437,7 @@ var layer$4 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(func
|
|
|
27675
27437
|
})() : empty;
|
|
27676
27438
|
if (isSink(stdoutConfig.stream)) stdout = transduce(stdout, stdoutConfig.stream);
|
|
27677
27439
|
if (isSink(stderrConfig.stream)) stderr = transduce(stderr, stderrConfig.stream);
|
|
27678
|
-
const all = merge(stdout, stderr);
|
|
27440
|
+
const all = merge$1(stdout, stderr);
|
|
27679
27441
|
return {
|
|
27680
27442
|
stdout,
|
|
27681
27443
|
stderr,
|
|
@@ -27686,7 +27448,7 @@ var layer$4 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(func
|
|
|
27686
27448
|
const deferred = makeUnsafe$5();
|
|
27687
27449
|
const handle = NodeChildProcess.spawn(command.command, command.args, spawnOptions);
|
|
27688
27450
|
handle.on("error", (error) => {
|
|
27689
|
-
resume(fail$
|
|
27451
|
+
resume(fail$5(toPlatformError("spawn", error, command)));
|
|
27690
27452
|
});
|
|
27691
27453
|
handle.on("exit", (...args) => {
|
|
27692
27454
|
doneUnsafe(deferred, succeed$5(args));
|
|
@@ -27701,7 +27463,7 @@ var layer$4 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(func
|
|
|
27701
27463
|
const killProcessGroup = (command, childProcess, signal) => {
|
|
27702
27464
|
if (globalThis.process.platform === "win32") return callback$1((resume) => {
|
|
27703
27465
|
taskkill(childProcess, (error) => {
|
|
27704
|
-
if (error) resume(fail$
|
|
27466
|
+
if (error) resume(fail$5(toPlatformError("kill", toError(error), command)));
|
|
27705
27467
|
else resume(void_);
|
|
27706
27468
|
});
|
|
27707
27469
|
});
|
|
@@ -27722,7 +27484,7 @@ var layer$4 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(func
|
|
|
27722
27484
|
} catch {}
|
|
27723
27485
|
};
|
|
27724
27486
|
const killProcess = (command, childProcess, signal) => suspend$2(() => {
|
|
27725
|
-
if (!childProcess.kill(signal)) return fail$
|
|
27487
|
+
if (!childProcess.kill(signal)) return fail$5(toPlatformError("kill", new globalThis.Error("Failed to kill child process"), command));
|
|
27726
27488
|
return void_;
|
|
27727
27489
|
});
|
|
27728
27490
|
/** Waits for the leader and its process group, bounded by native time. */
|
|
@@ -27824,7 +27586,7 @@ var layer$4 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(func
|
|
|
27824
27586
|
const isRunning = map$2(isDone$1(exitSignal), (done) => !done);
|
|
27825
27587
|
const exitCode = flatMap$1(_await(exitSignal), ([code, signal]) => {
|
|
27826
27588
|
if (isNotNull(code)) return succeed$2(ExitCode(code));
|
|
27827
|
-
return fail$
|
|
27589
|
+
return fail$5(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: '${signal}'`), cmd));
|
|
27828
27590
|
});
|
|
27829
27591
|
const kill = (options) => terminateProcessGroup(cmd, childProcess, exitSignal, options);
|
|
27830
27592
|
return makeHandle({
|
|
@@ -28054,7 +27816,7 @@ var openFlagBits = (flag) => {
|
|
|
28054
27816
|
};
|
|
28055
27817
|
var noFollowFlags = (method, flag) => suspend$2(() => {
|
|
28056
27818
|
const { O_NOFOLLOW } = NFS.constants;
|
|
28057
|
-
if (process.platform === "win32" || typeof O_NOFOLLOW !== "number" || O_NOFOLLOW === 0) return fail$
|
|
27819
|
+
if (process.platform === "win32" || typeof O_NOFOLLOW !== "number" || O_NOFOLLOW === 0) return fail$5(badArgument({
|
|
28058
27820
|
module: "FileSystem",
|
|
28059
27821
|
method,
|
|
28060
27822
|
description: "noFollow is not supported on this platform"
|
|
@@ -28101,7 +27863,7 @@ var makeFile = /*#__PURE__*/ (() => {
|
|
|
28101
27863
|
seek(offset, from) {
|
|
28102
27864
|
return suspend$2(() => {
|
|
28103
27865
|
const position = from === "start" ? offset : this.position + offset;
|
|
28104
|
-
if (position < BigInt(0)) return fail$
|
|
27866
|
+
if (position < BigInt(0)) return fail$5(badArgument({
|
|
28105
27867
|
module: "FileSystem",
|
|
28106
27868
|
method: "seek",
|
|
28107
27869
|
description: "Cannot seek before the start of the file"
|
|
@@ -28113,7 +27875,7 @@ var makeFile = /*#__PURE__*/ (() => {
|
|
|
28113
27875
|
read(buffer, options) {
|
|
28114
27876
|
return suspend$2(() => {
|
|
28115
27877
|
const explicit = options?.position;
|
|
28116
|
-
if (explicit !== void 0) return explicit < BigInt(0) ? fail$
|
|
27878
|
+
if (explicit !== void 0) return explicit < BigInt(0) ? fail$5(negativePosition("read")) : nodeRead(this.fd, {
|
|
28117
27879
|
buffer,
|
|
28118
27880
|
position: explicit
|
|
28119
27881
|
});
|
|
@@ -28132,14 +27894,14 @@ var makeFile = /*#__PURE__*/ (() => {
|
|
|
28132
27894
|
try {
|
|
28133
27895
|
if (!Number.isInteger(size) || size < 0) throw new RangeError("size must be a non-negative integer");
|
|
28134
27896
|
const explicit = options?.position;
|
|
28135
|
-
if (explicit !== void 0 && explicit < BigInt(0)) return fail$
|
|
27897
|
+
if (explicit !== void 0 && explicit < BigInt(0)) return fail$5(negativePosition("readAlloc"));
|
|
28136
27898
|
const buffer = Buffer.allocUnsafeSlow(size);
|
|
28137
27899
|
const position = explicit ?? this.position;
|
|
28138
27900
|
return map$2(nodeReadAlloc(this.fd, {
|
|
28139
27901
|
buffer,
|
|
28140
27902
|
position
|
|
28141
27903
|
}), (bytesRead) => {
|
|
28142
|
-
if (bytesRead === 0) return none();
|
|
27904
|
+
if (bytesRead === 0) return none$1();
|
|
28143
27905
|
if (explicit === void 0) this.position = position + BigInt(bytesRead);
|
|
28144
27906
|
if (bytesRead === size) return some(buffer);
|
|
28145
27907
|
const dst = Buffer.allocUnsafeSlow(bytesRead);
|
|
@@ -28147,7 +27909,7 @@ var makeFile = /*#__PURE__*/ (() => {
|
|
|
28147
27909
|
return some(dst);
|
|
28148
27910
|
});
|
|
28149
27911
|
} catch (cause) {
|
|
28150
|
-
return fail$
|
|
27912
|
+
return fail$5(handleBadArgument("readAlloc")(cause));
|
|
28151
27913
|
}
|
|
28152
27914
|
});
|
|
28153
27915
|
}
|
|
@@ -28172,7 +27934,7 @@ var makeFile = /*#__PURE__*/ (() => {
|
|
|
28172
27934
|
return suspend$2(() => {
|
|
28173
27935
|
const position = this.position;
|
|
28174
27936
|
return flatMap$1(this.append ? succeed$2(void 0) : positionToNumber(position, "writeAll"), (nodePosition) => flatMap$1(nodeWriteAll(this.fd, buffer, void 0, void 0, nodePosition), (bytesWritten) => {
|
|
28175
|
-
if (bytesWritten === 0) return fail$
|
|
27937
|
+
if (bytesWritten === 0) return fail$5(systemError({
|
|
28176
27938
|
module: "FileSystem",
|
|
28177
27939
|
method: "writeAll",
|
|
28178
27940
|
_tag: "WriteZero",
|
|
@@ -28213,11 +27975,11 @@ var readDirectory = (path, options) => tryPromise({
|
|
|
28213
27975
|
var readFile$1 = (path) => callback$1((resume, signal) => {
|
|
28214
27976
|
try {
|
|
28215
27977
|
NFS.readFile(path, { signal }, (err, data) => {
|
|
28216
|
-
if (err) resume(fail$
|
|
27978
|
+
if (err) resume(fail$5(handleErrnoException("FileSystem", "readFile")(err, [path])));
|
|
28217
27979
|
else resume(succeed$2(data));
|
|
28218
27980
|
});
|
|
28219
27981
|
} catch (err) {
|
|
28220
|
-
resume(fail$
|
|
27982
|
+
resume(fail$5(handleBadArgument("readFile")(err)));
|
|
28221
27983
|
}
|
|
28222
27984
|
});
|
|
28223
27985
|
var readLink = /*#__PURE__*/ (() => {
|
|
@@ -28246,7 +28008,7 @@ var makeFileInfo = (stat) => try_({
|
|
|
28246
28008
|
uid: bigintToNumberOption(stat.uid),
|
|
28247
28009
|
gid: bigintToNumberOption(stat.gid),
|
|
28248
28010
|
size: bytes(stat.size),
|
|
28249
|
-
blksize: stat.blksize !== void 0 ? some(bytes(stat.blksize)) : none(),
|
|
28011
|
+
blksize: stat.blksize !== void 0 ? some(bytes(stat.blksize)) : none$1(),
|
|
28250
28012
|
blocks: fromNullishOr(stat.blocks)
|
|
28251
28013
|
}),
|
|
28252
28014
|
catch: handleBadArgument("stat")
|
|
@@ -28293,7 +28055,7 @@ var watchNode = (path, info, options) => callback((queue) => acquireRelease(sync
|
|
|
28293
28055
|
}
|
|
28294
28056
|
});
|
|
28295
28057
|
watcher.on("error", (error) => {
|
|
28296
|
-
failCauseUnsafe(queue, fail$
|
|
28058
|
+
failCauseUnsafe(queue, fail$6(systemError({
|
|
28297
28059
|
module: "FileSystem",
|
|
28298
28060
|
_tag: "Unknown",
|
|
28299
28061
|
method: "watch",
|
|
@@ -28314,11 +28076,11 @@ var writeFile$1 = (path, data, options) => callback$1((resume, signal) => {
|
|
|
28314
28076
|
flag: options?.flag,
|
|
28315
28077
|
mode: options?.mode
|
|
28316
28078
|
}, (err) => {
|
|
28317
|
-
if (err) resume(fail$
|
|
28079
|
+
if (err) resume(fail$5(handleErrnoException("FileSystem", "writeFile")(err, [path])));
|
|
28318
28080
|
else resume(void_);
|
|
28319
28081
|
});
|
|
28320
28082
|
} catch (err) {
|
|
28321
|
-
resume(fail$
|
|
28083
|
+
resume(fail$5(handleBadArgument("writeFile")(err)));
|
|
28322
28084
|
}
|
|
28323
28085
|
});
|
|
28324
28086
|
var makeFileSystem = /*#__PURE__*/ map$2(/*#__PURE__*/ serviceOption(WatchBackend), (backend) => make$6({
|
|
@@ -28628,6 +28390,133 @@ var BudLogoSchema = createSchema((value, context) => {
|
|
|
28628
28390
|
return fail(logoMessage, context.path);
|
|
28629
28391
|
});
|
|
28630
28392
|
//#endregion
|
|
28393
|
+
//#region ../project/src/lib/factory.ts
|
|
28394
|
+
/** The steps of a factory task, each a status in the project's task store. */
|
|
28395
|
+
var FACTORY_STATUS_ROLES = [
|
|
28396
|
+
"open",
|
|
28397
|
+
"inProgress",
|
|
28398
|
+
"needsApproval",
|
|
28399
|
+
"readyToMerge",
|
|
28400
|
+
"merged"
|
|
28401
|
+
];
|
|
28402
|
+
/** The default status names, as Beads stores them. */
|
|
28403
|
+
var DEFAULT_FACTORY_STATUSES = {
|
|
28404
|
+
open: "open",
|
|
28405
|
+
inProgress: "in_progress",
|
|
28406
|
+
needsApproval: "needs_approval",
|
|
28407
|
+
readyToMerge: "ready_to_merge",
|
|
28408
|
+
merged: "merged"
|
|
28409
|
+
};
|
|
28410
|
+
/** The status category each step needs in the task store. */
|
|
28411
|
+
var FACTORY_STATUS_CATEGORIES = {
|
|
28412
|
+
open: "unstarted",
|
|
28413
|
+
inProgress: "started",
|
|
28414
|
+
needsApproval: "started",
|
|
28415
|
+
readyToMerge: "started",
|
|
28416
|
+
merged: "done"
|
|
28417
|
+
};
|
|
28418
|
+
/**
|
|
28419
|
+
* The model an agent uses when the config names none: DeepSeek V4.1 Flash on OpenCode Zen's free
|
|
28420
|
+
* tier, which needs no key; enough for trying the factory, slower than a paid model.
|
|
28421
|
+
*/
|
|
28422
|
+
var DEFAULT_FACTORY_MODEL = "opencode/deepseek-v4.1-flash-free";
|
|
28423
|
+
var factoryMessage = "factory must be false or an object with statuses, setup, dev, branchPrefix, sleepAfter, instructions and push as documented.";
|
|
28424
|
+
var statusName = /^[A-Za-z][\w-]{0,63}$/;
|
|
28425
|
+
var keys = [
|
|
28426
|
+
"statuses",
|
|
28427
|
+
"setup",
|
|
28428
|
+
"dev",
|
|
28429
|
+
"branchPrefix",
|
|
28430
|
+
"sleepAfter",
|
|
28431
|
+
"instructions",
|
|
28432
|
+
"push"
|
|
28433
|
+
];
|
|
28434
|
+
var modulePath$1 = /^\.\/(?!.*(?:^|\/)\.\.?(?:\/|$))[\w./-]+$/;
|
|
28435
|
+
function short(value, max) {
|
|
28436
|
+
return typeof value === "string" && value.trim().length > 0 && value.length <= max;
|
|
28437
|
+
}
|
|
28438
|
+
function push(value) {
|
|
28439
|
+
if (value === void 0) value = {};
|
|
28440
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
28441
|
+
let { remote = "origin", credential = null, username = "x-access-token", ...rest } = value;
|
|
28442
|
+
if (Object.keys(rest).length || typeof remote !== "string" || !/^[\w][\w.-]{0,99}$/.test(remote) || !(credential === null || typeof credential === "string" && /^[A-Z_][A-Z0-9_]{0,99}$/.test(credential)) || typeof username !== "string" || !/^[\w][\w.@-]{0,99}$/.test(username)) return void 0;
|
|
28443
|
+
return {
|
|
28444
|
+
remote,
|
|
28445
|
+
credential,
|
|
28446
|
+
username
|
|
28447
|
+
};
|
|
28448
|
+
}
|
|
28449
|
+
function dev(value) {
|
|
28450
|
+
if (value === void 0) return null;
|
|
28451
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
28452
|
+
let { command, port, path = "/", env = {}, ...rest } = value;
|
|
28453
|
+
if (Object.keys(rest).length || !short(command, 4e3)) return void 0;
|
|
28454
|
+
if (typeof path !== "string" || !/^\/(?!\/)[^\s#?]{0,500}$/.test(path)) return void 0;
|
|
28455
|
+
if (typeof port !== "number" || !Number.isInteger(port) || port < 1 || port > 65535) return void 0;
|
|
28456
|
+
if (!env || typeof env !== "object" || Array.isArray(env)) return void 0;
|
|
28457
|
+
let entries = Object.entries(env);
|
|
28458
|
+
if (entries.some(([key, entry]) => !/^[A-Z_][A-Z0-9_]*$/.test(key) || typeof entry !== "string")) return void 0;
|
|
28459
|
+
return {
|
|
28460
|
+
command,
|
|
28461
|
+
port,
|
|
28462
|
+
path,
|
|
28463
|
+
env: Object.fromEntries(entries)
|
|
28464
|
+
};
|
|
28465
|
+
}
|
|
28466
|
+
/** `factory` in bud.config.ts: off by default, with Beads' status names unless mapped. */
|
|
28467
|
+
var BudFactorySchema = createSchema((value, context) => {
|
|
28468
|
+
if (value === void 0 || value === false) return { value: null };
|
|
28469
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return fail(factoryMessage, context.path);
|
|
28470
|
+
let input = value;
|
|
28471
|
+
let statuses = input.statuses ?? {};
|
|
28472
|
+
if (Object.keys(input).some((key) => !keys.includes(key)) || !statuses || typeof statuses !== "object") return fail(factoryMessage, context.path);
|
|
28473
|
+
let given = statuses;
|
|
28474
|
+
if (Object.keys(given).some((key) => !FACTORY_STATUS_ROLES.includes(key))) return fail(factoryMessage, context.path);
|
|
28475
|
+
let resolved = { ...DEFAULT_FACTORY_STATUSES };
|
|
28476
|
+
for (let role of FACTORY_STATUS_ROLES) {
|
|
28477
|
+
let name = given[role];
|
|
28478
|
+
if (name === void 0) continue;
|
|
28479
|
+
if (typeof name !== "string" || !statusName.test(name)) return fail(factoryMessage, context.path);
|
|
28480
|
+
resolved[role] = name;
|
|
28481
|
+
}
|
|
28482
|
+
if (new Set(Object.values(resolved)).size !== FACTORY_STATUS_ROLES.length) return fail(factoryMessage, context.path);
|
|
28483
|
+
let server = dev(input.dev);
|
|
28484
|
+
let pushing = push(input.push);
|
|
28485
|
+
if (server === void 0 || pushing === void 0) return fail(factoryMessage, context.path);
|
|
28486
|
+
let prefix = input.branchPrefix ?? "dev/";
|
|
28487
|
+
if (typeof prefix !== "string" || !/^[a-z0-9][a-z0-9._-]*\/$/i.test(prefix) || prefix.length > 50 || input.sleepAfter !== void 0 && !(typeof input.sleepAfter === "number" && Number.isInteger(input.sleepAfter) && input.sleepAfter >= 0 && input.sleepAfter <= 1440) || input.setup !== void 0 && !short(input.setup, 4e3) || input.instructions !== void 0 && !(typeof input.instructions === "string" && modulePath$1.test(input.instructions))) return fail(factoryMessage, context.path);
|
|
28488
|
+
return { value: {
|
|
28489
|
+
statuses: resolved,
|
|
28490
|
+
sandbox: null,
|
|
28491
|
+
agent: {
|
|
28492
|
+
harness: "bud:opencode",
|
|
28493
|
+
model: DEFAULT_FACTORY_MODEL,
|
|
28494
|
+
keys: []
|
|
28495
|
+
},
|
|
28496
|
+
setup: input.setup ?? null,
|
|
28497
|
+
dev: server,
|
|
28498
|
+
branchPrefix: prefix,
|
|
28499
|
+
sleepAfter: input.sleepAfter ?? 5,
|
|
28500
|
+
instructions: input.instructions ?? null,
|
|
28501
|
+
push: pushing
|
|
28502
|
+
} };
|
|
28503
|
+
});
|
|
28504
|
+
/**
|
|
28505
|
+
* What the factory keeps of a harness plugin: its name, model and keys, checked.
|
|
28506
|
+
* @param name - The plugin's name.
|
|
28507
|
+
* @param harness - The plugin's `harness`.
|
|
28508
|
+
* @returns The agent settings for the resolved factory.
|
|
28509
|
+
*/
|
|
28510
|
+
function factoryAgent(name, harness) {
|
|
28511
|
+
let { model, keys = [] } = harness ?? {};
|
|
28512
|
+
if (!short(model, 200) || !Array.isArray(keys) || keys.length > 20 || keys.some((key) => typeof key !== "string" || !/^[A-Z_][A-Z0-9_]{0,99}$/.test(key))) throw new Error(`Plugin ${name}: harness needs a model and at most 20 keys naming server environment variables, such as DEEPSEEK_API_KEY.`);
|
|
28513
|
+
return {
|
|
28514
|
+
harness: name,
|
|
28515
|
+
model,
|
|
28516
|
+
keys: [...new Set(keys)]
|
|
28517
|
+
};
|
|
28518
|
+
}
|
|
28519
|
+
//#endregion
|
|
28631
28520
|
//#region ../project/src/lib/theme.ts
|
|
28632
28521
|
/**
|
|
28633
28522
|
* Bud's colors and shadows a theme may set, as `--bud-<name>` in its styles. Everything else
|
|
@@ -28681,7 +28570,27 @@ var THEME_TOKENS = Object.freeze([
|
|
|
28681
28570
|
"focus",
|
|
28682
28571
|
"scrollbar-hover",
|
|
28683
28572
|
"tooltip-border",
|
|
28684
|
-
"tooltip-shadow"
|
|
28573
|
+
"tooltip-shadow",
|
|
28574
|
+
"terminal",
|
|
28575
|
+
"terminal-foreground",
|
|
28576
|
+
"terminal-cursor",
|
|
28577
|
+
"terminal-selection",
|
|
28578
|
+
"terminal-black",
|
|
28579
|
+
"terminal-red",
|
|
28580
|
+
"terminal-green",
|
|
28581
|
+
"terminal-yellow",
|
|
28582
|
+
"terminal-blue",
|
|
28583
|
+
"terminal-magenta",
|
|
28584
|
+
"terminal-cyan",
|
|
28585
|
+
"terminal-white",
|
|
28586
|
+
"terminal-bright-black",
|
|
28587
|
+
"terminal-bright-red",
|
|
28588
|
+
"terminal-bright-green",
|
|
28589
|
+
"terminal-bright-yellow",
|
|
28590
|
+
"terminal-bright-blue",
|
|
28591
|
+
"terminal-bright-magenta",
|
|
28592
|
+
"terminal-bright-cyan",
|
|
28593
|
+
"terminal-bright-white"
|
|
28685
28594
|
]);
|
|
28686
28595
|
var themeMessage = `theme must be { light, dark }, each mapping Bud's tokens (${THEME_TOKENS.slice(0, 3).join(", ")}, …) to CSS colors or shadows.`;
|
|
28687
28596
|
function cssValue(value) {
|
|
@@ -28788,15 +28697,8 @@ function modulePath(name, server, message) {
|
|
|
28788
28697
|
let extension = server ? /\.server\.ts$/ : /\.(?:ts|tsx|js|jsx)$/;
|
|
28789
28698
|
return described(string().refine((value) => value.length <= 1024 && value.startsWith("./") && !/[\u0000-\u001f\u007f\\?#%]/.test(value) && extension.test(value) && (server || !/\.server\.[cm]?[jt]sx?$/.test(value)) && !value.slice(2).split("/").some((part) => !part || part === "." || part === ".." || part === "node_modules")), message ?? (server ? `${name} must be a built-in adapter or a ./ module ending in .server.ts inside the project.` : `${name} must be bud:beads or a ./ browser module ending in .ts, .tsx, .js or .jsx inside the project.`));
|
|
28790
28699
|
}
|
|
28791
|
-
var builtInStores = enum_([
|
|
28792
|
-
false,
|
|
28793
|
-
"bud:beads",
|
|
28794
|
-
"bud:memory",
|
|
28795
|
-
"bud:git-comments"
|
|
28796
|
-
]);
|
|
28797
28700
|
function store(kind) {
|
|
28798
|
-
|
|
28799
|
-
return defaulted(check(select((value) => value === false || value === "bud:beads" || value === "bud:memory" || value === "bud:git-comments" ? builtInStores : module), (value) => kind === "work" && value === "bud:git-comments" ? "storage.work cannot use bud:git-comments; it only stores threads." : void 0), "bud:beads");
|
|
28701
|
+
return defaulted(select((value) => value === false ? enum_([false]) : described(string().refine((name) => /^[\w@:./-]{1,100}$/.test(name)), `storage.${kind} is false, or a store named by its plugin, such as bud:beads.`)), "bud:beads");
|
|
28800
28702
|
}
|
|
28801
28703
|
/** The selected work and discussion stores, with Beads as the default for both. */
|
|
28802
28704
|
var BudStorageSchema = defaulted(settings("storage", {
|
|
@@ -28814,14 +28716,6 @@ var BudDesignsSchema = defaulted(settings("designs", {
|
|
|
28814
28716
|
tasks: "bud:beads",
|
|
28815
28717
|
pages: "path"
|
|
28816
28718
|
}));
|
|
28817
|
-
/**
|
|
28818
|
-
* Validates the selected work and discussion stores before modules are loaded.
|
|
28819
|
-
* @param value - The optional storage configuration.
|
|
28820
|
-
* @returns Explicit selections, with Beads as the default for both stores.
|
|
28821
|
-
*/
|
|
28822
|
-
function resolveStorage(value) {
|
|
28823
|
-
return parseConfig(BudStorageSchema, value);
|
|
28824
|
-
}
|
|
28825
28719
|
//#endregion
|
|
28826
28720
|
//#region ../project/src/lib/picker.ts
|
|
28827
28721
|
var builtIn = /* @__PURE__ */ new Set([
|
|
@@ -28846,67 +28740,14 @@ var BudPickerSchema = createSchema((value, context) => {
|
|
|
28846
28740
|
module: result.value
|
|
28847
28741
|
} };
|
|
28848
28742
|
});
|
|
28849
|
-
|
|
28850
|
-
|
|
28851
|
-
|
|
28852
|
-
|
|
28853
|
-
|
|
28854
|
-
|
|
28855
|
-
|
|
28856
|
-
let entries = Object.entries(ready);
|
|
28857
|
-
let [key, text] = entries[0] ?? [];
|
|
28858
|
-
if (entries.length === 1 && (key === "selector" || key === "expression") && typeof text === "string" && text.trim() && text.length <= 4096) return { value: key === "selector" ? { selector: text.trim() } : { expression: text.trim() } };
|
|
28859
|
-
}
|
|
28860
|
-
return fail(readyMessage, context.path);
|
|
28861
|
-
});
|
|
28862
|
-
var defaultThemes = () => ["light", "dark"];
|
|
28863
|
-
var defaultViewports = () => [{
|
|
28864
|
-
id: "desktop",
|
|
28865
|
-
name: "Desktop",
|
|
28866
|
-
width: 1440,
|
|
28867
|
-
height: 900,
|
|
28868
|
-
mobile: false
|
|
28869
|
-
}];
|
|
28870
|
-
var viewportsMessage = "previews.viewports must list up to 4 { name, width, height?, mobile? } with distinct names, widths from 240 to 3840 and heights from 240 to 4000.";
|
|
28871
|
-
function viewportId(name) {
|
|
28872
|
-
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32);
|
|
28743
|
+
/**
|
|
28744
|
+
* Validates the picker setting.
|
|
28745
|
+
* @param value - The config's optional `picker` setting.
|
|
28746
|
+
* @returns The picker and its project module, if it is the project's own.
|
|
28747
|
+
*/
|
|
28748
|
+
function resolvePicker(value) {
|
|
28749
|
+
return parseConfig(BudPickerSchema, value);
|
|
28873
28750
|
}
|
|
28874
|
-
var ViewportsSchema = createSchema((value, context) => {
|
|
28875
|
-
if (!Array.isArray(value) || value.length === 0 || value.length > 4) return fail(viewportsMessage, context.path);
|
|
28876
|
-
let viewports = [];
|
|
28877
|
-
for (let entry of value) {
|
|
28878
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return fail(viewportsMessage, context.path);
|
|
28879
|
-
let { name, width, height, mobile, ...rest } = entry;
|
|
28880
|
-
let size = (pixels, from, to) => typeof pixels === "number" && Number.isInteger(pixels) && pixels >= from && pixels <= to;
|
|
28881
|
-
if (Object.keys(rest).length || typeof name !== "string" || !name.trim() || name.length > 40 || !viewportId(name) || !size(width, 240, 3840) || height !== void 0 && !size(height, 240, 4e3) || mobile !== void 0 && typeof mobile !== "boolean") return fail(viewportsMessage, context.path);
|
|
28882
|
-
let phone = mobile ?? width < 800;
|
|
28883
|
-
viewports.push({
|
|
28884
|
-
id: viewportId(name),
|
|
28885
|
-
name: name.trim(),
|
|
28886
|
-
width,
|
|
28887
|
-
height: height ?? (phone ? Math.round(width * 844 / 390) : 900),
|
|
28888
|
-
mobile: phone
|
|
28889
|
-
});
|
|
28890
|
-
}
|
|
28891
|
-
if (new Set(viewports.map((viewport) => viewport.id)).size !== viewports.length) return fail(viewportsMessage, context.path);
|
|
28892
|
-
return { value: viewports };
|
|
28893
|
-
});
|
|
28894
|
-
/** The preview settings, with their defaults filled in. */
|
|
28895
|
-
var BudPreviewsSchema = defaulted(settings("previews", {
|
|
28896
|
-
scale: fallback(described(number().refine((scale) => Number.isInteger(scale) && scale >= 1 && scale <= 3), "previews.scale must be 1, 2 or 3."), () => 2),
|
|
28897
|
-
themes: fallback(described(array(enum_(["light", "dark"])).refine((themes) => themes.length > 0 && new Set(themes).size === themes.length), "previews.themes must list light, dark or both, once each."), defaultThemes),
|
|
28898
|
-
viewports: fallback(ViewportsSchema, defaultViewports),
|
|
28899
|
-
ready: fallback(PreviewReadySchema, () => null),
|
|
28900
|
-
readyTimeout: fallback(described(number().refine((ms) => Number.isInteger(ms) && ms >= 1e3 && ms <= 6e5), "previews.readyTimeout must be whole milliseconds from 1000 to 600000."), () => 6e4),
|
|
28901
|
-
css: fallback(described(string().refine((css) => css.length <= 2e4 && !css.includes("<")), "previews.css must be CSS text without <, up to 20000 characters."), () => "")
|
|
28902
|
-
}), () => ({
|
|
28903
|
-
scale: 2,
|
|
28904
|
-
themes: defaultThemes(),
|
|
28905
|
-
viewports: defaultViewports(),
|
|
28906
|
-
ready: null,
|
|
28907
|
-
readyTimeout: 6e4,
|
|
28908
|
-
css: ""
|
|
28909
|
-
}));
|
|
28910
28751
|
//#endregion
|
|
28911
28752
|
//#region ../project/src/lib/screen-routes.ts
|
|
28912
28753
|
/**
|
|
@@ -29062,6 +28903,196 @@ var BudScreensSchema = defaulted(delegate(described(array(any()).refine((screens
|
|
|
29062
28903
|
});
|
|
29063
28904
|
}), () => defaultScreens.map((screen) => ({ ...screen })));
|
|
29064
28905
|
//#endregion
|
|
28906
|
+
//#region ../project/src/lib/plugins.ts
|
|
28907
|
+
var registry = globalThis;
|
|
28908
|
+
var key = Symbol.for("@bud.sh/project/plugins");
|
|
28909
|
+
registry[key] ??= /* @__PURE__ */ new WeakMap();
|
|
28910
|
+
var known = registry[key];
|
|
28911
|
+
/**
|
|
28912
|
+
* The plugin objects behind a resolved config, for the server: their stores, sandbox and harness.
|
|
28913
|
+
* @param config - A config from resolveBudConfig.
|
|
28914
|
+
* @returns Its plugins, in hook order; none for a config made without them.
|
|
28915
|
+
*/
|
|
28916
|
+
function configPlugins(config) {
|
|
28917
|
+
return known.get(config) ?? [];
|
|
28918
|
+
}
|
|
28919
|
+
/**
|
|
28920
|
+
* Remembers the plugins a resolved config came from.
|
|
28921
|
+
* @param config - The resolved config.
|
|
28922
|
+
* @param plugins - Its plugins.
|
|
28923
|
+
* @returns The config.
|
|
28924
|
+
*/
|
|
28925
|
+
function withPlugins(config, plugins) {
|
|
28926
|
+
known.set(config, plugins);
|
|
28927
|
+
return config;
|
|
28928
|
+
}
|
|
28929
|
+
function flatten(option, into) {
|
|
28930
|
+
if (option === false || option === null || option === void 0) return;
|
|
28931
|
+
if (Array.isArray(option)) {
|
|
28932
|
+
for (let entry of option) flatten(entry, into);
|
|
28933
|
+
return;
|
|
28934
|
+
}
|
|
28935
|
+
let plugin = option;
|
|
28936
|
+
if (!plugin || typeof plugin !== "object" || typeof plugin.name !== "string" || !/^[\w@:./-]{1,100}$/.test(plugin.name)) throw new Error("Each plugin must be an object with a name such as bud:beads.");
|
|
28937
|
+
if (plugin.enforce !== void 0 && plugin.enforce !== "pre" && plugin.enforce !== "post") throw new Error(`Plugin ${plugin.name}: enforce must be pre or post.`);
|
|
28938
|
+
if (plugin.config !== void 0 && typeof plugin.config !== "function") throw new Error(`Plugin ${plugin.name}: config must be a function.`);
|
|
28939
|
+
into.push(plugin);
|
|
28940
|
+
}
|
|
28941
|
+
function isObject(value) {
|
|
28942
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
28943
|
+
}
|
|
28944
|
+
function merge(config, partial) {
|
|
28945
|
+
let merged = { ...config };
|
|
28946
|
+
for (let [key, value] of Object.entries(partial)) {
|
|
28947
|
+
if (key === "plugins") continue;
|
|
28948
|
+
merged[key] = isObject(merged[key]) && isObject(value) ? {
|
|
28949
|
+
...merged[key],
|
|
28950
|
+
...value
|
|
28951
|
+
} : value;
|
|
28952
|
+
}
|
|
28953
|
+
return merged;
|
|
28954
|
+
}
|
|
28955
|
+
/**
|
|
28956
|
+
* Runs the config's plugins: flattens `plugins`, orders them, applies their `config` hooks, and
|
|
28957
|
+
* finds which plugin provides each store, the picker, the task design and the sandbox.
|
|
28958
|
+
* @param value - The config module's default export.
|
|
28959
|
+
* @returns The config after the hooks, without `plugins`, the plugins in order and what they
|
|
28960
|
+
* provide.
|
|
28961
|
+
*/
|
|
28962
|
+
function applyPlugins(value) {
|
|
28963
|
+
if (!isObject(value)) return {
|
|
28964
|
+
config: value,
|
|
28965
|
+
plugins: [],
|
|
28966
|
+
provides: none()
|
|
28967
|
+
};
|
|
28968
|
+
let found = [];
|
|
28969
|
+
flatten(value.plugins, found);
|
|
28970
|
+
let names = /* @__PURE__ */ new Set();
|
|
28971
|
+
for (let plugin of found) {
|
|
28972
|
+
if (names.has(plugin.name)) throw new Error(`Two plugins are named ${plugin.name}.`);
|
|
28973
|
+
names.add(plugin.name);
|
|
28974
|
+
}
|
|
28975
|
+
let plugins = [
|
|
28976
|
+
...found.filter((plugin) => plugin.enforce === "pre"),
|
|
28977
|
+
...found.filter((plugin) => !plugin.enforce),
|
|
28978
|
+
...found.filter((plugin) => plugin.enforce === "post")
|
|
28979
|
+
];
|
|
28980
|
+
let { plugins: _plugins, ...config } = value;
|
|
28981
|
+
for (let plugin of plugins) {
|
|
28982
|
+
let partial = plugin.config?.(config);
|
|
28983
|
+
if (partial !== void 0 && partial !== null) {
|
|
28984
|
+
if (!isObject(partial)) throw new Error(`Plugin ${plugin.name}: config must return an object or nothing.`);
|
|
28985
|
+
config = merge(config, partial);
|
|
28986
|
+
}
|
|
28987
|
+
}
|
|
28988
|
+
let screens = plugins.flatMap((plugin) => plugin.screens ?? []);
|
|
28989
|
+
if (screens.length) config.screens = [...config.screens ?? defaultScreens.map((screen) => ({ ...screen })), ...screens];
|
|
28990
|
+
let one = (key, what) => {
|
|
28991
|
+
let providers = plugins.filter((plugin) => plugin[key] !== void 0);
|
|
28992
|
+
if (providers.length > 1) throw new Error(`Only one plugin may provide ${what}; ${providers.map((plugin) => plugin.name).join(" and ")} both do.`);
|
|
28993
|
+
return providers[0] ?? null;
|
|
28994
|
+
};
|
|
28995
|
+
return {
|
|
28996
|
+
config,
|
|
28997
|
+
plugins,
|
|
28998
|
+
provides: {
|
|
28999
|
+
work: one("work", "the task store"),
|
|
29000
|
+
threads: one("threads", "the discussion store"),
|
|
29001
|
+
picker: one("picker", "the picker"),
|
|
29002
|
+
taskDesign: one("taskDesign", "the task design"),
|
|
29003
|
+
sandbox: one("sandbox", "the factory’s sandboxes"),
|
|
29004
|
+
harness: one("harness", "the agent harness")
|
|
29005
|
+
}
|
|
29006
|
+
};
|
|
29007
|
+
}
|
|
29008
|
+
function none() {
|
|
29009
|
+
return {
|
|
29010
|
+
work: null,
|
|
29011
|
+
threads: null,
|
|
29012
|
+
picker: null,
|
|
29013
|
+
taskDesign: null,
|
|
29014
|
+
sandbox: null,
|
|
29015
|
+
harness: null
|
|
29016
|
+
};
|
|
29017
|
+
}
|
|
29018
|
+
/**
|
|
29019
|
+
* Fails for settings that moved into plugins, naming the plugin that replaces each.
|
|
29020
|
+
* @param config - The config after the plugins' hooks.
|
|
29021
|
+
*/
|
|
29022
|
+
function rejectMovedSettings(config) {
|
|
29023
|
+
if (!isObject(config)) return;
|
|
29024
|
+
let storage = config.storage;
|
|
29025
|
+
if (isObject(storage)) for (let kind of ["work", "threads"]) {
|
|
29026
|
+
let value = storage[kind];
|
|
29027
|
+
if (value !== void 0 && value !== false) throw new Error(`storage.${kind} no longer names a store: add the store's plugin to plugins, such as beads(), gitComments() or memory() from @bud.sh/app/plugins, or your own; storage.${kind}: false still turns it off.`);
|
|
29028
|
+
}
|
|
29029
|
+
if (isObject(config.designs) && config.designs.tasks !== void 0) throw new Error("designs.tasks moved into a plugin: add taskDesign(\"./your-design.tsx\") from @bud.sh/app/plugins to plugins.");
|
|
29030
|
+
if (config.picker !== void 0) throw new Error("picker moved into a plugin: add reactGrab(), react() or picker(\"./your-picker.ts\") from @bud.sh/app/plugins to plugins.");
|
|
29031
|
+
if (isObject(config.factory) && config.factory.sandbox !== void 0) throw new Error("factory.sandbox moved into a plugin: add local() or boat() from @bud.sh/app/plugins to plugins.");
|
|
29032
|
+
if (isObject(config.factory) && config.factory.agent !== void 0) throw new Error("factory.agent moved into a plugin: add opencode({ model, keys }) from @bud.sh/app/plugins to plugins.");
|
|
29033
|
+
}
|
|
29034
|
+
//#endregion
|
|
29035
|
+
//#region ../project/src/lib/previews.ts
|
|
29036
|
+
var readyMessage = "ready must be a CSS selector, { selector } or { expression }.";
|
|
29037
|
+
/** A readiness condition; a string is a selector. */
|
|
29038
|
+
var PreviewReadySchema = createSchema((value, context) => {
|
|
29039
|
+
let ready = typeof value === "string" ? { selector: value } : value;
|
|
29040
|
+
if (ready && typeof ready === "object" && !Array.isArray(ready)) {
|
|
29041
|
+
let entries = Object.entries(ready);
|
|
29042
|
+
let [key, text] = entries[0] ?? [];
|
|
29043
|
+
if (entries.length === 1 && (key === "selector" || key === "expression") && typeof text === "string" && text.trim() && text.length <= 4096) return { value: key === "selector" ? { selector: text.trim() } : { expression: text.trim() } };
|
|
29044
|
+
}
|
|
29045
|
+
return fail(readyMessage, context.path);
|
|
29046
|
+
});
|
|
29047
|
+
var defaultThemes = () => ["light", "dark"];
|
|
29048
|
+
var defaultViewports = () => [{
|
|
29049
|
+
id: "desktop",
|
|
29050
|
+
name: "Desktop",
|
|
29051
|
+
width: 1440,
|
|
29052
|
+
height: 900,
|
|
29053
|
+
mobile: false
|
|
29054
|
+
}];
|
|
29055
|
+
var viewportsMessage = "previews.viewports must list up to 4 { name, width, height?, mobile? } with distinct names, widths from 240 to 3840 and heights from 240 to 4000.";
|
|
29056
|
+
function viewportId(name) {
|
|
29057
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32);
|
|
29058
|
+
}
|
|
29059
|
+
var ViewportsSchema = createSchema((value, context) => {
|
|
29060
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 4) return fail(viewportsMessage, context.path);
|
|
29061
|
+
let viewports = [];
|
|
29062
|
+
for (let entry of value) {
|
|
29063
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return fail(viewportsMessage, context.path);
|
|
29064
|
+
let { name, width, height, mobile, ...rest } = entry;
|
|
29065
|
+
let size = (pixels, from, to) => typeof pixels === "number" && Number.isInteger(pixels) && pixels >= from && pixels <= to;
|
|
29066
|
+
if (Object.keys(rest).length || typeof name !== "string" || !name.trim() || name.length > 40 || !viewportId(name) || !size(width, 240, 3840) || height !== void 0 && !size(height, 240, 4e3) || mobile !== void 0 && typeof mobile !== "boolean") return fail(viewportsMessage, context.path);
|
|
29067
|
+
let phone = mobile ?? width < 800;
|
|
29068
|
+
viewports.push({
|
|
29069
|
+
id: viewportId(name),
|
|
29070
|
+
name: name.trim(),
|
|
29071
|
+
width,
|
|
29072
|
+
height: height ?? (phone ? Math.round(width * 844 / 390) : 900),
|
|
29073
|
+
mobile: phone
|
|
29074
|
+
});
|
|
29075
|
+
}
|
|
29076
|
+
if (new Set(viewports.map((viewport) => viewport.id)).size !== viewports.length) return fail(viewportsMessage, context.path);
|
|
29077
|
+
return { value: viewports };
|
|
29078
|
+
});
|
|
29079
|
+
/** The preview settings, with their defaults filled in. */
|
|
29080
|
+
var BudPreviewsSchema = defaulted(settings("previews", {
|
|
29081
|
+
scale: fallback(described(number().refine((scale) => Number.isInteger(scale) && scale >= 1 && scale <= 3), "previews.scale must be 1, 2 or 3."), () => 2),
|
|
29082
|
+
themes: fallback(described(array(enum_(["light", "dark"])).refine((themes) => themes.length > 0 && new Set(themes).size === themes.length), "previews.themes must list light, dark or both, once each."), defaultThemes),
|
|
29083
|
+
viewports: fallback(ViewportsSchema, defaultViewports),
|
|
29084
|
+
ready: fallback(PreviewReadySchema, () => null),
|
|
29085
|
+
readyTimeout: fallback(described(number().refine((ms) => Number.isInteger(ms) && ms >= 1e3 && ms <= 6e5), "previews.readyTimeout must be whole milliseconds from 1000 to 600000."), () => 6e4),
|
|
29086
|
+
css: fallback(described(string().refine((css) => css.length <= 2e4 && !css.includes("<")), "previews.css must be CSS text without <, up to 20000 characters."), () => "")
|
|
29087
|
+
}), () => ({
|
|
29088
|
+
scale: 2,
|
|
29089
|
+
themes: defaultThemes(),
|
|
29090
|
+
viewports: defaultViewports(),
|
|
29091
|
+
ready: null,
|
|
29092
|
+
readyTimeout: 6e4,
|
|
29093
|
+
css: ""
|
|
29094
|
+
}));
|
|
29095
|
+
//#endregion
|
|
29065
29096
|
//#region ../project/src/lib/config.ts
|
|
29066
29097
|
var objectLike = (value) => !!value && typeof value === "object";
|
|
29067
29098
|
function section(message, shape) {
|
|
@@ -29085,6 +29116,7 @@ var ConfigFields = check(section("Bud config must export an object.", {
|
|
|
29085
29116
|
logo: any(),
|
|
29086
29117
|
theme: any(),
|
|
29087
29118
|
locale: any(),
|
|
29119
|
+
factory: any(),
|
|
29088
29120
|
picker: any(),
|
|
29089
29121
|
branches: any(),
|
|
29090
29122
|
flows: any()
|
|
@@ -29162,6 +29194,7 @@ var BudConfigSchema = delegate(check(delegate(check(check(delegate(check(delegat
|
|
|
29162
29194
|
logo: parseConfig(BudLogoSchema, config.logo),
|
|
29163
29195
|
theme: parseConfig(BudThemeSchema, config.theme),
|
|
29164
29196
|
locale: config.locale === void 0 ? "en" : config.locale,
|
|
29197
|
+
factory: parseConfig(BudFactorySchema, config.factory),
|
|
29165
29198
|
picker: parseConfig(BudPickerSchema, config.picker),
|
|
29166
29199
|
branches: parseConfig(BudBranchesSchema, config.branches)
|
|
29167
29200
|
}));
|
|
@@ -29171,7 +29204,32 @@ var BudConfigSchema = delegate(check(delegate(check(check(delegate(check(delegat
|
|
|
29171
29204
|
* @returns Normalized route IDs, ports, and URLs.
|
|
29172
29205
|
*/
|
|
29173
29206
|
function resolveBudConfig(value) {
|
|
29174
|
-
|
|
29207
|
+
let { config, plugins, provides } = applyPlugins(value);
|
|
29208
|
+
rejectMovedSettings(config);
|
|
29209
|
+
let resolved = parseConfig(BudConfigSchema, config);
|
|
29210
|
+
let store = (kind) => resolved.storage[kind] === false ? false : provides[kind]?.name ?? "bud:beads";
|
|
29211
|
+
let design = provides.taskDesign;
|
|
29212
|
+
let picker = provides.picker;
|
|
29213
|
+
return withPlugins({
|
|
29214
|
+
...resolved,
|
|
29215
|
+
storage: {
|
|
29216
|
+
work: store("work"),
|
|
29217
|
+
threads: store("threads")
|
|
29218
|
+
},
|
|
29219
|
+
designs: {
|
|
29220
|
+
...resolved.designs,
|
|
29221
|
+
tasks: design ? parseConfig(modulePath(`Plugin ${design.name}: taskDesign`, false), design.taskDesign) : "bud:beads"
|
|
29222
|
+
},
|
|
29223
|
+
picker: picker ? picker.picker ? {
|
|
29224
|
+
name: picker.name,
|
|
29225
|
+
module: parseConfig(modulePath(`Plugin ${picker.name}: picker`, false), picker.picker)
|
|
29226
|
+
} : resolvePicker(picker.name) : resolvePicker(void 0),
|
|
29227
|
+
factory: resolved.factory ? {
|
|
29228
|
+
...resolved.factory,
|
|
29229
|
+
sandbox: provides.sandbox?.name ?? null,
|
|
29230
|
+
agent: provides.harness ? factoryAgent(provides.harness.name, provides.harness.harness) : resolved.factory.agent
|
|
29231
|
+
} : null
|
|
29232
|
+
}, plugins);
|
|
29175
29233
|
}
|
|
29176
29234
|
/**
|
|
29177
29235
|
* Returns a bare HTTP(S) origin, rejecting credentials, paths, queries and fragments.
|
|
@@ -29685,7 +29743,7 @@ function objectId(bytes, operation) {
|
|
|
29685
29743
|
})));
|
|
29686
29744
|
}
|
|
29687
29745
|
function records(bytes, operation) {
|
|
29688
|
-
return decodeText(bytes, operation).pipe(flatMap$1((text) => text && !text.endsWith("\0") ? fail$
|
|
29746
|
+
return decodeText(bytes, operation).pipe(flatMap$1((text) => text && !text.endsWith("\0") ? fail$5(invalid(operation)) : succeed$2(text ? text.slice(0, -1).split("\0") : [])));
|
|
29689
29747
|
}
|
|
29690
29748
|
/**
|
|
29691
29749
|
* Parses NUL-terminated repository-relative paths, such as from `ls-files -z`.
|
|
@@ -30748,7 +30806,7 @@ function gitLayer(options$1 = {}) {
|
|
|
30748
30806
|
}));
|
|
30749
30807
|
let semaphore = yield* make$8(1);
|
|
30750
30808
|
function scoped(program) {
|
|
30751
|
-
return semaphore.withPermit(suspend$2(() => active ? program : fail$
|
|
30809
|
+
return semaphore.withPermit(suspend$2(() => active ? program : fail$5(new GitInputError({
|
|
30752
30810
|
operation: "index",
|
|
30753
30811
|
message: "The temporary index scope is closed."
|
|
30754
30812
|
}))));
|
|
@@ -31050,6 +31108,830 @@ function gitLayer(options$1 = {}) {
|
|
|
31050
31108
|
}));
|
|
31051
31109
|
}
|
|
31052
31110
|
//#endregion
|
|
31111
|
+
//#region ../picker/src/lib/runtime.ts
|
|
31112
|
+
/**
|
|
31113
|
+
* The page side of every picker: Bud's DOM picker composed with a framework adapter. It runs in
|
|
31114
|
+
* the project's pages as module text, so it must not reference anything outside its own body.
|
|
31115
|
+
* @param adapter - The configured picker's page module, or null for the DOM picker alone.
|
|
31116
|
+
* @param name - The picker's name, recorded on every anchor it describes.
|
|
31117
|
+
* @returns The picker's page operations.
|
|
31118
|
+
*/
|
|
31119
|
+
function pickerRuntime(adapter, name) {
|
|
31120
|
+
let blocks = "article, section, li, figure, form, header, footer, nav, aside, main, dialog, [data-block], [data-component], [role=\"listitem\"], [role=\"region\"], [role=\"dialog\"]";
|
|
31121
|
+
let ignored = "[data-react-grab], [data-bud-picker], script, style, link, meta, noscript";
|
|
31122
|
+
let active = null;
|
|
31123
|
+
function clip(text, length) {
|
|
31124
|
+
return text.length > length ? text.slice(0, length) : text;
|
|
31125
|
+
}
|
|
31126
|
+
function normalize(text) {
|
|
31127
|
+
return (text ?? "").replace(/\s+/g, " ").trim();
|
|
31128
|
+
}
|
|
31129
|
+
function textOf(element) {
|
|
31130
|
+
return clip(normalize(element instanceof HTMLElement ? element.innerText : element.textContent), 1e3);
|
|
31131
|
+
}
|
|
31132
|
+
function fingerprint(element) {
|
|
31133
|
+
let value = `${element.localName}\u0000${textOf(element)}`;
|
|
31134
|
+
let hash = 2166136261;
|
|
31135
|
+
for (let index = 0; index < value.length; index++) {
|
|
31136
|
+
hash ^= value.charCodeAt(index);
|
|
31137
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
31138
|
+
}
|
|
31139
|
+
return hash.toString(16).padStart(8, "0");
|
|
31140
|
+
}
|
|
31141
|
+
function stableId(element) {
|
|
31142
|
+
let id = element.id;
|
|
31143
|
+
if (!id || /[:\d]/.test(id) || id.length > 64) return null;
|
|
31144
|
+
return document.querySelectorAll(`#${CSS.escape(id)}`).length === 1 ? id : null;
|
|
31145
|
+
}
|
|
31146
|
+
function segment(element) {
|
|
31147
|
+
let id = stableId(element);
|
|
31148
|
+
if (id) return `#${CSS.escape(id)}`;
|
|
31149
|
+
let tag = element.localName;
|
|
31150
|
+
let parent = element.parentElement;
|
|
31151
|
+
if (!parent) return tag;
|
|
31152
|
+
let same = [...parent.children].filter((child) => child.localName === tag);
|
|
31153
|
+
return same.length > 1 ? `${tag}:nth-of-type(${same.indexOf(element) + 1})` : tag;
|
|
31154
|
+
}
|
|
31155
|
+
function selectorOf(element) {
|
|
31156
|
+
let parts = [];
|
|
31157
|
+
for (let node = element; node; node = node.parentElement) {
|
|
31158
|
+
if (node === document.documentElement) break;
|
|
31159
|
+
let part = segment(node);
|
|
31160
|
+
parts.unshift(part);
|
|
31161
|
+
if (part.startsWith("#") || node === document.body) break;
|
|
31162
|
+
}
|
|
31163
|
+
return clip(parts.join(" > "), 4096);
|
|
31164
|
+
}
|
|
31165
|
+
function breadcrumbOf(element) {
|
|
31166
|
+
let parts = [];
|
|
31167
|
+
for (let node = element; node && parts.length < 5; node = node.parentElement) {
|
|
31168
|
+
if (node === document.body || node === document.documentElement) break;
|
|
31169
|
+
parts.unshift(node.localName);
|
|
31170
|
+
}
|
|
31171
|
+
return clip(parts.join(" > ") || element.localName, 4096);
|
|
31172
|
+
}
|
|
31173
|
+
function labelOf(element) {
|
|
31174
|
+
return clip(normalize(element.getAttribute("aria-label") || element.getAttribute("alt") || element.getAttribute("title")) || clip(textOf(element), 80) || element.localName, 500);
|
|
31175
|
+
}
|
|
31176
|
+
function query(selector) {
|
|
31177
|
+
try {
|
|
31178
|
+
return document.querySelector(selector);
|
|
31179
|
+
} catch {
|
|
31180
|
+
return null;
|
|
31181
|
+
}
|
|
31182
|
+
}
|
|
31183
|
+
function box(element) {
|
|
31184
|
+
let rect = element.getBoundingClientRect();
|
|
31185
|
+
return {
|
|
31186
|
+
left: rect.left + scrollX,
|
|
31187
|
+
top: rect.top + scrollY,
|
|
31188
|
+
width: rect.width,
|
|
31189
|
+
height: rect.height
|
|
31190
|
+
};
|
|
31191
|
+
}
|
|
31192
|
+
function fraction(offset, size) {
|
|
31193
|
+
return size > 0 ? Math.min(1, Math.max(0, offset / size)) : .5;
|
|
31194
|
+
}
|
|
31195
|
+
function elementAt(clientX, clientY) {
|
|
31196
|
+
for (let element of document.elementsFromPoint(clientX, clientY)) {
|
|
31197
|
+
if (element === document.documentElement || element.closest(ignored)) continue;
|
|
31198
|
+
return element;
|
|
31199
|
+
}
|
|
31200
|
+
return null;
|
|
31201
|
+
}
|
|
31202
|
+
async function blockOf(element) {
|
|
31203
|
+
return (adapter?.block ? await Promise.resolve(adapter.block(element)).catch(() => null) : null) ?? element.closest(blocks);
|
|
31204
|
+
}
|
|
31205
|
+
async function anchor(element, x, y) {
|
|
31206
|
+
let rect = box(element);
|
|
31207
|
+
let around = await blockOf(element);
|
|
31208
|
+
let described = adapter?.describe ? await Promise.resolve(adapter.describe(element)).catch(() => null) : null;
|
|
31209
|
+
let block = null;
|
|
31210
|
+
if (around) {
|
|
31211
|
+
let outer = box(around);
|
|
31212
|
+
block = {
|
|
31213
|
+
selector: selectorOf(around),
|
|
31214
|
+
label: labelOf(around),
|
|
31215
|
+
tagName: around.localName,
|
|
31216
|
+
offsetX: fraction(x - outer.left, outer.width),
|
|
31217
|
+
offsetY: fraction(y - outer.top, outer.height)
|
|
31218
|
+
};
|
|
31219
|
+
}
|
|
31220
|
+
return {
|
|
31221
|
+
selector: selectorOf(element),
|
|
31222
|
+
breadcrumb: breadcrumbOf(element),
|
|
31223
|
+
contentHash: fingerprint(element),
|
|
31224
|
+
label: described?.label ? clip(described.label, 500) : labelOf(element),
|
|
31225
|
+
tagName: clip(element.localName, 100),
|
|
31226
|
+
text: textOf(element),
|
|
31227
|
+
offsetX: fraction(x - rect.left, rect.width),
|
|
31228
|
+
offsetY: fraction(y - rect.top, rect.height),
|
|
31229
|
+
block,
|
|
31230
|
+
source: described?.source ?? null,
|
|
31231
|
+
picker: name
|
|
31232
|
+
};
|
|
31233
|
+
}
|
|
31234
|
+
function alike(a, b) {
|
|
31235
|
+
let words = (text) => new Set(text.toLowerCase().split(/\s+/).filter(Boolean));
|
|
31236
|
+
let left = words(a);
|
|
31237
|
+
let right = words(b);
|
|
31238
|
+
let shared = [...left].filter((word) => right.has(word)).length;
|
|
31239
|
+
let all = (/* @__PURE__ */ new Set([...left, ...right])).size;
|
|
31240
|
+
return all === 0 || shared / all >= .5;
|
|
31241
|
+
}
|
|
31242
|
+
function find(stored) {
|
|
31243
|
+
let candidate = query(stored.selector);
|
|
31244
|
+
let same = (element) => element.localName === stored.tagName && (!stored.text || fingerprint(element) === stored.contentHash);
|
|
31245
|
+
if (candidate && same(candidate)) return {
|
|
31246
|
+
element: candidate,
|
|
31247
|
+
offsetX: stored.offsetX,
|
|
31248
|
+
offsetY: stored.offsetY
|
|
31249
|
+
};
|
|
31250
|
+
if (stored.text) {
|
|
31251
|
+
let moved = [...document.getElementsByTagName(stored.tagName)].filter((element) => !element.closest(ignored) && same(element));
|
|
31252
|
+
let container = stored.block ? query(stored.block.selector) : null;
|
|
31253
|
+
let inside = container ? moved.filter((element) => container.contains(element)) : [];
|
|
31254
|
+
let found = moved.length === 1 ? moved[0] : inside.length === 1 ? inside[0] : null;
|
|
31255
|
+
if (found) return {
|
|
31256
|
+
element: found,
|
|
31257
|
+
offsetX: stored.offsetX,
|
|
31258
|
+
offsetY: stored.offsetY
|
|
31259
|
+
};
|
|
31260
|
+
}
|
|
31261
|
+
let block = stored.block ? query(stored.block.selector) : null;
|
|
31262
|
+
if (block && block.localName === stored.block.tagName && alike(labelOf(block), stored.block.label)) return {
|
|
31263
|
+
element: block,
|
|
31264
|
+
offsetX: stored.block.offsetX,
|
|
31265
|
+
offsetY: stored.block.offsetY,
|
|
31266
|
+
block: true
|
|
31267
|
+
};
|
|
31268
|
+
return null;
|
|
31269
|
+
}
|
|
31270
|
+
return {
|
|
31271
|
+
async describe(x, y) {
|
|
31272
|
+
let from = {
|
|
31273
|
+
left: scrollX,
|
|
31274
|
+
top: scrollY
|
|
31275
|
+
};
|
|
31276
|
+
scrollTo({
|
|
31277
|
+
left: 0,
|
|
31278
|
+
top: Math.max(0, y - innerHeight / 2),
|
|
31279
|
+
behavior: "instant"
|
|
31280
|
+
});
|
|
31281
|
+
try {
|
|
31282
|
+
let element = elementAt(x - scrollX, y - scrollY);
|
|
31283
|
+
return element ? await anchor(element, x, y) : null;
|
|
31284
|
+
} finally {
|
|
31285
|
+
scrollTo({
|
|
31286
|
+
...from,
|
|
31287
|
+
behavior: "instant"
|
|
31288
|
+
});
|
|
31289
|
+
}
|
|
31290
|
+
},
|
|
31291
|
+
async locate(anchors) {
|
|
31292
|
+
return anchors.map(({ id, element }) => {
|
|
31293
|
+
let found = find(element);
|
|
31294
|
+
if (!found) return {
|
|
31295
|
+
id,
|
|
31296
|
+
match: "missing",
|
|
31297
|
+
x: null,
|
|
31298
|
+
y: null
|
|
31299
|
+
};
|
|
31300
|
+
let rect = box(found.element);
|
|
31301
|
+
return {
|
|
31302
|
+
id,
|
|
31303
|
+
match: "block" in found ? "block" : "element",
|
|
31304
|
+
x: rect.left + found.offsetX * rect.width,
|
|
31305
|
+
y: rect.top + found.offsetY * rect.height
|
|
31306
|
+
};
|
|
31307
|
+
});
|
|
31308
|
+
},
|
|
31309
|
+
pick() {
|
|
31310
|
+
active?.abort();
|
|
31311
|
+
return new Promise((resolve) => {
|
|
31312
|
+
let controller = new AbortController();
|
|
31313
|
+
let outline = document.createElement("div");
|
|
31314
|
+
outline.setAttribute("data-bud-picker", "");
|
|
31315
|
+
outline.style.cssText = "position:fixed;z-index:2147483647;pointer-events:none;border:2px solid #7c3aed;border-radius:4px;background:rgb(124 58 237 / 0.08);display:none;box-sizing:border-box";
|
|
31316
|
+
let done = false;
|
|
31317
|
+
let finish = (value) => {
|
|
31318
|
+
if (done) return;
|
|
31319
|
+
done = true;
|
|
31320
|
+
controller.abort();
|
|
31321
|
+
outline.remove();
|
|
31322
|
+
if (active === session) active = null;
|
|
31323
|
+
resolve(value);
|
|
31324
|
+
};
|
|
31325
|
+
let session = { abort: () => finish(null) };
|
|
31326
|
+
active = session;
|
|
31327
|
+
let signal = controller.signal;
|
|
31328
|
+
if (adapter?.pick) {
|
|
31329
|
+
adapter.pick(signal).then(async (element) => {
|
|
31330
|
+
if (!element || done) return finish(null);
|
|
31331
|
+
let rect = box(element);
|
|
31332
|
+
finish(await anchor(element, rect.left + rect.width / 2, rect.top + rect.height / 2));
|
|
31333
|
+
}).catch(() => finish(null));
|
|
31334
|
+
return;
|
|
31335
|
+
}
|
|
31336
|
+
document.documentElement.append(outline);
|
|
31337
|
+
let hovered = null;
|
|
31338
|
+
let options = {
|
|
31339
|
+
capture: true,
|
|
31340
|
+
signal
|
|
31341
|
+
};
|
|
31342
|
+
addEventListener("pointermove", (event) => {
|
|
31343
|
+
hovered = elementAt(event.clientX, event.clientY);
|
|
31344
|
+
if (!hovered) return void (outline.style.display = "none");
|
|
31345
|
+
let rect = hovered.getBoundingClientRect();
|
|
31346
|
+
Object.assign(outline.style, {
|
|
31347
|
+
display: "block",
|
|
31348
|
+
left: `${rect.left}px`,
|
|
31349
|
+
top: `${rect.top}px`,
|
|
31350
|
+
width: `${rect.width}px`,
|
|
31351
|
+
height: `${rect.height}px`
|
|
31352
|
+
});
|
|
31353
|
+
}, options);
|
|
31354
|
+
for (let type of [
|
|
31355
|
+
"pointerdown",
|
|
31356
|
+
"mousedown",
|
|
31357
|
+
"pointerup",
|
|
31358
|
+
"mouseup"
|
|
31359
|
+
]) addEventListener(type, (event) => event.preventDefault(), options);
|
|
31360
|
+
addEventListener("click", (event) => {
|
|
31361
|
+
event.preventDefault();
|
|
31362
|
+
event.stopPropagation();
|
|
31363
|
+
let element = elementAt(event.clientX, event.clientY);
|
|
31364
|
+
if (!element) return;
|
|
31365
|
+
anchor(element, event.clientX + scrollX, event.clientY + scrollY).then(finish);
|
|
31366
|
+
}, options);
|
|
31367
|
+
addEventListener("keydown", (event) => {
|
|
31368
|
+
if (event.key !== "Escape") return;
|
|
31369
|
+
event.preventDefault();
|
|
31370
|
+
finish(null);
|
|
31371
|
+
}, options);
|
|
31372
|
+
});
|
|
31373
|
+
},
|
|
31374
|
+
cancel() {
|
|
31375
|
+
active?.abort();
|
|
31376
|
+
},
|
|
31377
|
+
async index(options = {}) {
|
|
31378
|
+
let limit = options.maxElements ?? 2e4;
|
|
31379
|
+
let mark = options.mark ?? null;
|
|
31380
|
+
let page = globalThis;
|
|
31381
|
+
let from = {
|
|
31382
|
+
left: scrollX,
|
|
31383
|
+
top: scrollY
|
|
31384
|
+
};
|
|
31385
|
+
let priming = page.__budPriming;
|
|
31386
|
+
page.__budPriming = true;
|
|
31387
|
+
try {
|
|
31388
|
+
scrollTo({
|
|
31389
|
+
left: 0,
|
|
31390
|
+
top: 0,
|
|
31391
|
+
behavior: "instant"
|
|
31392
|
+
});
|
|
31393
|
+
let round = (value) => Math.round(value * 100) / 100;
|
|
31394
|
+
let intersect = (a, b) => {
|
|
31395
|
+
let left = Math.max(a[0], b[0]);
|
|
31396
|
+
let top = Math.max(a[1], b[1]);
|
|
31397
|
+
let right = Math.min(a[0] + a[2], b[0] + b[2]);
|
|
31398
|
+
let bottom = Math.min(a[1] + a[3], b[1] + b[3]);
|
|
31399
|
+
return [
|
|
31400
|
+
left,
|
|
31401
|
+
top,
|
|
31402
|
+
Math.max(0, right - left),
|
|
31403
|
+
Math.max(0, bottom - top)
|
|
31404
|
+
];
|
|
31405
|
+
};
|
|
31406
|
+
let everywhere = [
|
|
31407
|
+
-1e6,
|
|
31408
|
+
-1e6,
|
|
31409
|
+
2e6,
|
|
31410
|
+
2e6
|
|
31411
|
+
];
|
|
31412
|
+
let found = [];
|
|
31413
|
+
let indexes = /* @__PURE__ */ new Map();
|
|
31414
|
+
let clips = /* @__PURE__ */ new Map();
|
|
31415
|
+
for (let element of document.body?.querySelectorAll("*") ?? []) {
|
|
31416
|
+
if (found.length >= limit) break;
|
|
31417
|
+
if (element.closest(ignored)) continue;
|
|
31418
|
+
let style = getComputedStyle(element);
|
|
31419
|
+
let rect = element.getBoundingClientRect();
|
|
31420
|
+
let own = [
|
|
31421
|
+
rect.left + scrollX,
|
|
31422
|
+
rect.top + scrollY,
|
|
31423
|
+
rect.width,
|
|
31424
|
+
rect.height
|
|
31425
|
+
];
|
|
31426
|
+
let container = element.parentElement;
|
|
31427
|
+
let clip = everywhere;
|
|
31428
|
+
if (style.position !== "fixed") for (let node = container; node; node = node.parentElement) {
|
|
31429
|
+
let known = clips.get(node);
|
|
31430
|
+
if (known) {
|
|
31431
|
+
clip = known;
|
|
31432
|
+
break;
|
|
31433
|
+
}
|
|
31434
|
+
}
|
|
31435
|
+
clips.set(element, style.overflowX !== "visible" || style.overflowY !== "visible" ? intersect(clip, own) : clip);
|
|
31436
|
+
if (rect.width <= 0 || rect.height <= 0) continue;
|
|
31437
|
+
let box = intersect(own, clip);
|
|
31438
|
+
let parent = -1;
|
|
31439
|
+
for (let node = container; node && parent < 0; node = node.parentElement) parent = indexes.get(node) ?? -1;
|
|
31440
|
+
indexes.set(element, found.length);
|
|
31441
|
+
found.push({
|
|
31442
|
+
element,
|
|
31443
|
+
box: [
|
|
31444
|
+
round(box[0]),
|
|
31445
|
+
round(box[1]),
|
|
31446
|
+
round(box[2]),
|
|
31447
|
+
round(box[3])
|
|
31448
|
+
],
|
|
31449
|
+
parent,
|
|
31450
|
+
inert: style.pointerEvents === "none" || style.visibility !== "visible"
|
|
31451
|
+
});
|
|
31452
|
+
}
|
|
31453
|
+
let sources = [];
|
|
31454
|
+
let known = /* @__PURE__ */ new Map();
|
|
31455
|
+
let elements = [];
|
|
31456
|
+
for (let [index, { element, box, parent, inert }] of found.entries()) {
|
|
31457
|
+
let around = await blockOf(element);
|
|
31458
|
+
let described = adapter?.describe ? await Promise.resolve(adapter.describe(element)).catch(() => null) : null;
|
|
31459
|
+
let source = -1;
|
|
31460
|
+
if (described?.source) {
|
|
31461
|
+
let key = JSON.stringify(described.source);
|
|
31462
|
+
source = known.get(key) ?? -1;
|
|
31463
|
+
if (source < 0) {
|
|
31464
|
+
source = sources.push(described.source) - 1;
|
|
31465
|
+
known.set(key, source);
|
|
31466
|
+
}
|
|
31467
|
+
}
|
|
31468
|
+
if (mark) element.setAttribute(mark, String(index));
|
|
31469
|
+
elements.push({
|
|
31470
|
+
box,
|
|
31471
|
+
parent,
|
|
31472
|
+
rank: inert ? -1 : 0,
|
|
31473
|
+
selector: selectorOf(element),
|
|
31474
|
+
breadcrumb: breadcrumbOf(element),
|
|
31475
|
+
contentHash: fingerprint(element),
|
|
31476
|
+
label: described?.label ? clip(described.label, 500) : labelOf(element),
|
|
31477
|
+
tagName: clip(element.localName, 100),
|
|
31478
|
+
text: textOf(element),
|
|
31479
|
+
block: around ? indexes.get(around) ?? -1 : -1,
|
|
31480
|
+
source
|
|
31481
|
+
});
|
|
31482
|
+
}
|
|
31483
|
+
return {
|
|
31484
|
+
version: 2,
|
|
31485
|
+
picker: name,
|
|
31486
|
+
width: document.documentElement.clientWidth,
|
|
31487
|
+
height: Math.min(document.documentElement.scrollHeight, 1e5),
|
|
31488
|
+
elements,
|
|
31489
|
+
sources
|
|
31490
|
+
};
|
|
31491
|
+
} finally {
|
|
31492
|
+
scrollTo({
|
|
31493
|
+
...from,
|
|
31494
|
+
behavior: "instant"
|
|
31495
|
+
});
|
|
31496
|
+
page.__budPriming = priming;
|
|
31497
|
+
}
|
|
31498
|
+
}
|
|
31499
|
+
};
|
|
31500
|
+
}
|
|
31501
|
+
//#endregion
|
|
31502
|
+
//#region ../picker/src/lib/module.ts
|
|
31503
|
+
/** Where pages import the picker module from. */
|
|
31504
|
+
var PICKER_MODULE_URL = "/@id/__x00__bud-picker";
|
|
31505
|
+
/** Where a picker script leaves the picker in a page that has no module to import it from. */
|
|
31506
|
+
var PICKER_GLOBAL = "__budPicker";
|
|
31507
|
+
function runtime() {
|
|
31508
|
+
return `((__name) => (${pickerRuntime.toString()}))((target) => target)`;
|
|
31509
|
+
}
|
|
31510
|
+
/**
|
|
31511
|
+
* The picker module's text: Bud's DOM picker composed with the configured adapter.
|
|
31512
|
+
* @param name - The picker's name, recorded on every anchor.
|
|
31513
|
+
* @param adapter - Where the adapter's page module is imported from, or null for the DOM picker.
|
|
31514
|
+
* @returns ES module text exporting describe, locate, pick and cancel.
|
|
31515
|
+
*/
|
|
31516
|
+
function pickerModule(name, adapter) {
|
|
31517
|
+
return [
|
|
31518
|
+
adapter ? `import adapter from ${JSON.stringify(adapter)}` : "const adapter = null",
|
|
31519
|
+
`const picker = (${runtime()})(adapter ?? null, ${JSON.stringify(name)})`,
|
|
31520
|
+
"export const describe = picker.describe",
|
|
31521
|
+
"export const locate = picker.locate",
|
|
31522
|
+
"export const pick = picker.pick",
|
|
31523
|
+
"export const cancel = picker.cancel",
|
|
31524
|
+
"export const index = picker.index"
|
|
31525
|
+
].join("\n");
|
|
31526
|
+
}
|
|
31527
|
+
/**
|
|
31528
|
+
* The picker as a classic script, for pages no Bud Vite plugin serves, such as builds of a
|
|
31529
|
+
* branch: running it leaves the picker on `window.__budPicker` (once) and evaluates to it.
|
|
31530
|
+
* @param name - The picker's name, recorded on every anchor.
|
|
31531
|
+
* @param adapter - An expression evaluating to the adapter, needing nothing from the page's
|
|
31532
|
+
* modules; null for the DOM picker.
|
|
31533
|
+
* @returns Script text.
|
|
31534
|
+
*/
|
|
31535
|
+
function pickerScript(name, adapter) {
|
|
31536
|
+
return `(globalThis.${PICKER_GLOBAL} ??= (${runtime()})(${adapter ?? "null"}, ${JSON.stringify(name)}))`;
|
|
31537
|
+
}
|
|
31538
|
+
//#endregion
|
|
31539
|
+
//#region ../picker-react-grab/src/lib/adapter.ts
|
|
31540
|
+
/**
|
|
31541
|
+
* The page side of `bud:react` and `bud:react-grab`: an element's component and source come from
|
|
31542
|
+
* React's development build, its block is the component's outermost element, and with React Grab
|
|
31543
|
+
* its own selection picks. It runs in the project's pages as module or script text, so it must not
|
|
31544
|
+
* reference anything outside its own body. The line comes from React's own stack, mapped through
|
|
31545
|
+
* the module's source map, so it is exact whichever React Grab a project runs; React Grab's own
|
|
31546
|
+
* answer fills in what that can't find. Production builds keep no source, so only the DOM picker's
|
|
31547
|
+
* own description remains.
|
|
31548
|
+
* @param grab - The project's `react-grab` module, or null to read React alone. Importing it
|
|
31549
|
+
* starts React Grab if it isn't yet.
|
|
31550
|
+
* @param helpers - Resolves file names and source map positions.
|
|
31551
|
+
* @returns The picker adapter.
|
|
31552
|
+
*/
|
|
31553
|
+
function reactGrabAdapter(grab, helpers) {
|
|
31554
|
+
let { sourceFile, projectFrames, sourceMapLookup } = helpers;
|
|
31555
|
+
let plugin = "bud:picker";
|
|
31556
|
+
let maps = /* @__PURE__ */ new Map();
|
|
31557
|
+
let host = 5;
|
|
31558
|
+
function fiberOf(element) {
|
|
31559
|
+
let key = Object.keys(element).find((name) => name.startsWith("__reactFiber$"));
|
|
31560
|
+
return key ? element[key] ?? null : null;
|
|
31561
|
+
}
|
|
31562
|
+
function outermost(component) {
|
|
31563
|
+
let node = component.child;
|
|
31564
|
+
while (node && node.tag !== host) node = node.child;
|
|
31565
|
+
return node?.stateNode instanceof Element ? node.stateNode : null;
|
|
31566
|
+
}
|
|
31567
|
+
function sourceMap(url) {
|
|
31568
|
+
let cached = maps.get(url);
|
|
31569
|
+
if (cached) return cached;
|
|
31570
|
+
cached = fetch(url).then((response) => response.ok ? response.text() : "").then(async (text) => {
|
|
31571
|
+
let reference = /\/\/[#@] sourceMappingURL=(\S+)\s*$/.exec(text)?.[1];
|
|
31572
|
+
let address = new URL(reference ?? `${url.replace(/[?#].*$/, "")}.map`, url);
|
|
31573
|
+
if (address.protocol !== "data:" && address.origin !== location.origin) return null;
|
|
31574
|
+
let response = await fetch(address);
|
|
31575
|
+
let map = response.ok ? await response.json() : null;
|
|
31576
|
+
let lookup = map && typeof map === "object" ? sourceMapLookup(map) : null;
|
|
31577
|
+
return lookup ? {
|
|
31578
|
+
lookup,
|
|
31579
|
+
base: address.protocol === "data:" ? url : address.href
|
|
31580
|
+
} : null;
|
|
31581
|
+
}).catch(() => null);
|
|
31582
|
+
maps.set(url, cached);
|
|
31583
|
+
if (maps.size > 50) maps.delete(maps.keys().next().value);
|
|
31584
|
+
return cached;
|
|
31585
|
+
}
|
|
31586
|
+
function servedPath(source, base, stack) {
|
|
31587
|
+
if (source.startsWith("/") && !source.startsWith("//")) return sourceFile(source, stack, location.origin);
|
|
31588
|
+
let url = new URL(source, base);
|
|
31589
|
+
return url.origin === location.origin && !url.pathname.startsWith("/@") && !url.pathname.includes("/node_modules/") ? url.pathname : null;
|
|
31590
|
+
}
|
|
31591
|
+
async function written(stack) {
|
|
31592
|
+
let frames = projectFrames(stack, location.origin);
|
|
31593
|
+
for (let frame of frames) {
|
|
31594
|
+
let map = await sourceMap(frame.url);
|
|
31595
|
+
let position = map ? map.lookup(frame.line, frame.column) : {
|
|
31596
|
+
source: frame.url,
|
|
31597
|
+
line: frame.line,
|
|
31598
|
+
column: frame.column
|
|
31599
|
+
};
|
|
31600
|
+
if (!position) continue;
|
|
31601
|
+
let file = servedPath(position.source, map?.base ?? frame.url, stack);
|
|
31602
|
+
if (file) return {
|
|
31603
|
+
name: frame.name,
|
|
31604
|
+
file,
|
|
31605
|
+
line: position.line,
|
|
31606
|
+
column: position.column
|
|
31607
|
+
};
|
|
31608
|
+
}
|
|
31609
|
+
return frames[0] ? {
|
|
31610
|
+
name: frames[0].name,
|
|
31611
|
+
file: null,
|
|
31612
|
+
line: null,
|
|
31613
|
+
column: null
|
|
31614
|
+
} : null;
|
|
31615
|
+
}
|
|
31616
|
+
function ownerName(element) {
|
|
31617
|
+
let type = fiberOf(element)?._debugOwner?.type;
|
|
31618
|
+
let name = type && typeof type === "object" ? type.displayName ?? type.name : null;
|
|
31619
|
+
return typeof name === "string" && name ? name : null;
|
|
31620
|
+
}
|
|
31621
|
+
let adapter = {
|
|
31622
|
+
async describe(element) {
|
|
31623
|
+
let api = grab?.getGlobalApi() ?? null;
|
|
31624
|
+
let stack = fiberOf(element)?._debugStack?.stack ?? "";
|
|
31625
|
+
let mapped = stack ? await written(stack).catch(() => null) : null;
|
|
31626
|
+
let found = !mapped?.file && api ? await api.getSource(element).catch(() => null) : null;
|
|
31627
|
+
let component = mapped?.name ?? found?.componentName ?? api?.getDisplayName(element) ?? ownerName(element);
|
|
31628
|
+
if (!mapped?.file && !found && !component) return null;
|
|
31629
|
+
if (mapped?.file) return { source: {
|
|
31630
|
+
component: component || null,
|
|
31631
|
+
file: mapped.file,
|
|
31632
|
+
line: mapped.line,
|
|
31633
|
+
column: mapped.column
|
|
31634
|
+
} };
|
|
31635
|
+
let file = found?.filePath ? sourceFile(found.filePath, stack, location.origin) : null;
|
|
31636
|
+
let line = found?.lineNumber && found.lineNumber > 0 ? found.lineNumber : null;
|
|
31637
|
+
let column = found?.columnNumber != null && found.columnNumber >= 0 ? found.columnNumber + 1 : null;
|
|
31638
|
+
return { source: {
|
|
31639
|
+
component: component || null,
|
|
31640
|
+
file,
|
|
31641
|
+
line,
|
|
31642
|
+
column
|
|
31643
|
+
} };
|
|
31644
|
+
},
|
|
31645
|
+
block(element) {
|
|
31646
|
+
for (let owner = fiberOf(element)?._debugOwner; owner; owner = owner._debugOwner) {
|
|
31647
|
+
let outer = outermost(owner);
|
|
31648
|
+
if (outer && outer !== document.body && outer.contains(element)) return outer;
|
|
31649
|
+
}
|
|
31650
|
+
return null;
|
|
31651
|
+
}
|
|
31652
|
+
};
|
|
31653
|
+
if (!grab) return adapter;
|
|
31654
|
+
return {
|
|
31655
|
+
...adapter,
|
|
31656
|
+
pick(signal) {
|
|
31657
|
+
let api = grab.getGlobalApi();
|
|
31658
|
+
if (!api || signal.aborted) return Promise.resolve(null);
|
|
31659
|
+
return new Promise((resolve) => {
|
|
31660
|
+
let settled = false;
|
|
31661
|
+
let tidy = () => {
|
|
31662
|
+
api.unregisterPlugin(plugin);
|
|
31663
|
+
if (api.isActive()) api.deactivate();
|
|
31664
|
+
};
|
|
31665
|
+
let finish = (element, during) => {
|
|
31666
|
+
if (settled) return;
|
|
31667
|
+
settled = true;
|
|
31668
|
+
signal.removeEventListener("abort", cancel);
|
|
31669
|
+
resolve(element);
|
|
31670
|
+
if (during) setTimeout(tidy, 1e3);
|
|
31671
|
+
else tidy();
|
|
31672
|
+
};
|
|
31673
|
+
let cancel = () => finish(null, false);
|
|
31674
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
31675
|
+
api.unregisterPlugin(plugin);
|
|
31676
|
+
api.registerPlugin({
|
|
31677
|
+
name: plugin,
|
|
31678
|
+
theme: { grabbedBoxes: { enabled: false } },
|
|
31679
|
+
hooks: {
|
|
31680
|
+
onElementSelect(element) {
|
|
31681
|
+
finish(element, true);
|
|
31682
|
+
return true;
|
|
31683
|
+
},
|
|
31684
|
+
onDeactivate: () => finish(null, true)
|
|
31685
|
+
}
|
|
31686
|
+
});
|
|
31687
|
+
api.activate();
|
|
31688
|
+
});
|
|
31689
|
+
}
|
|
31690
|
+
};
|
|
31691
|
+
}
|
|
31692
|
+
//#endregion
|
|
31693
|
+
//#region ../picker-react-grab/src/lib/source-map.ts
|
|
31694
|
+
/**
|
|
31695
|
+
* The frames of React's stack for an element that may have run in the project's own code, in
|
|
31696
|
+
* order: the first one whose source is the project's is the component that rendered it.
|
|
31697
|
+
* Dependencies the dev server serves apart, Vite's own modules and other origins are left out; a
|
|
31698
|
+
* build bundles dependencies with the project, so their frames stay for their source maps to
|
|
31699
|
+
* tell apart. It runs in the project's pages as module text, so it must not reference anything
|
|
31700
|
+
* outside its own body.
|
|
31701
|
+
* @param stack - React's stack for the element, as `Error.stack` text.
|
|
31702
|
+
* @param origin - The page's origin.
|
|
31703
|
+
* @returns The frames, possibly none.
|
|
31704
|
+
*/
|
|
31705
|
+
function projectFrames(stack, origin) {
|
|
31706
|
+
let frames = [];
|
|
31707
|
+
for (let text of stack.split("\n")) {
|
|
31708
|
+
let match = /^\s*at (?:(.+?) \()?(https?:\/\/[^\s()]+?):(\d+):(\d+)\)?\s*$/.exec(text);
|
|
31709
|
+
if (!match) continue;
|
|
31710
|
+
let url = new URL(match[2]);
|
|
31711
|
+
if (url.origin !== origin || url.pathname.startsWith("/@") || url.pathname.includes("/node_modules/")) continue;
|
|
31712
|
+
let name = match[1]?.replace(/^Object\./, "") ?? null;
|
|
31713
|
+
frames.push({
|
|
31714
|
+
name,
|
|
31715
|
+
url: url.href,
|
|
31716
|
+
line: Number(match[3]),
|
|
31717
|
+
column: Number(match[4])
|
|
31718
|
+
});
|
|
31719
|
+
}
|
|
31720
|
+
return frames;
|
|
31721
|
+
}
|
|
31722
|
+
/**
|
|
31723
|
+
* Decodes a module's source map once, for looking up many positions in it. It runs in the
|
|
31724
|
+
* project's pages as module text, so it must not reference anything outside its own body.
|
|
31725
|
+
* @param map - The source map, as parsed JSON.
|
|
31726
|
+
* @returns Maps a generated line and column, counted from one, to the original position; null
|
|
31727
|
+
* for a map that can't be read.
|
|
31728
|
+
*/
|
|
31729
|
+
function sourceMapLookup(map) {
|
|
31730
|
+
if (typeof map.mappings !== "string" || !Array.isArray(map.sources)) return null;
|
|
31731
|
+
let sources = map.sources;
|
|
31732
|
+
let root = typeof map.sourceRoot === "string" && map.sourceRoot ? map.sourceRoot : "";
|
|
31733
|
+
let digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
31734
|
+
let lines = [];
|
|
31735
|
+
let source = 0;
|
|
31736
|
+
let sourceLine = 0;
|
|
31737
|
+
let sourceColumn = 0;
|
|
31738
|
+
for (let text of map.mappings.split(";")) {
|
|
31739
|
+
let generated = 0;
|
|
31740
|
+
let segments = [];
|
|
31741
|
+
for (let segment of text.split(",")) {
|
|
31742
|
+
if (!segment) continue;
|
|
31743
|
+
let values = [];
|
|
31744
|
+
let value = 0;
|
|
31745
|
+
let shift = 0;
|
|
31746
|
+
for (let character of segment) {
|
|
31747
|
+
let digit = digits.indexOf(character);
|
|
31748
|
+
if (digit < 0) return null;
|
|
31749
|
+
value += (digit & 31) << shift;
|
|
31750
|
+
if (digit & 32) shift += 5;
|
|
31751
|
+
else {
|
|
31752
|
+
values.push(value & 1 ? -(value >>> 1) : value >>> 1);
|
|
31753
|
+
value = 0;
|
|
31754
|
+
shift = 0;
|
|
31755
|
+
}
|
|
31756
|
+
}
|
|
31757
|
+
generated += values[0] ?? 0;
|
|
31758
|
+
if (values.length < 4) continue;
|
|
31759
|
+
source += values[1];
|
|
31760
|
+
sourceLine += values[2];
|
|
31761
|
+
sourceColumn += values[3];
|
|
31762
|
+
segments.push([
|
|
31763
|
+
generated,
|
|
31764
|
+
source,
|
|
31765
|
+
sourceLine,
|
|
31766
|
+
sourceColumn
|
|
31767
|
+
]);
|
|
31768
|
+
}
|
|
31769
|
+
lines.push(segments);
|
|
31770
|
+
}
|
|
31771
|
+
return (line, column) => {
|
|
31772
|
+
let found = null;
|
|
31773
|
+
for (let segment of lines[line - 1] ?? []) if (segment[0] <= column - 1) found = segment;
|
|
31774
|
+
let name = found ? sources[found[1]] : null;
|
|
31775
|
+
if (!found || typeof name !== "string") return null;
|
|
31776
|
+
return {
|
|
31777
|
+
source: root ? `${root.replace(/\/$/, "")}/${name}` : name,
|
|
31778
|
+
line: found[2] + 1,
|
|
31779
|
+
column: found[3] + 1
|
|
31780
|
+
};
|
|
31781
|
+
};
|
|
31782
|
+
}
|
|
31783
|
+
//#endregion
|
|
31784
|
+
//#region ../picker-react-grab/src/lib/source.ts
|
|
31785
|
+
/**
|
|
31786
|
+
* The project path of a file React Grab names. React Grab maps React's stack through the dev
|
|
31787
|
+
* server's source maps, whose sources are relative to the module that names them (Vite writes
|
|
31788
|
+
* `card.tsx` for `/src/components/card.tsx`). The module's address is still in React's own stack,
|
|
31789
|
+
* so the file resolves against the first frame from the page's origin that shares its name. It runs
|
|
31790
|
+
* in the project's pages as module text, so it must not reference anything outside its own body.
|
|
31791
|
+
* @param file - The file React Grab reported: a name, a relative or absolute path, or a URL.
|
|
31792
|
+
* @param stack - React's stack for the element, as `Error.stack` text.
|
|
31793
|
+
* @param origin - The page's origin; frames from elsewhere are never the project's.
|
|
31794
|
+
* @returns A path as the dev server serves it, such as `/src/components/card.tsx`, or null.
|
|
31795
|
+
*/
|
|
31796
|
+
function sourceFile(file, stack, origin) {
|
|
31797
|
+
let served = (url) => url.origin === origin && !url.pathname.startsWith("/@") && !url.pathname.includes("/node_modules/") && !/[\\\u0000-\u001f\u007f]/.test(url.pathname);
|
|
31798
|
+
if (/^https?:\/\//.test(file)) {
|
|
31799
|
+
let url = new URL(file);
|
|
31800
|
+
return served(url) ? url.pathname : null;
|
|
31801
|
+
}
|
|
31802
|
+
let name = file.split("/").pop();
|
|
31803
|
+
for (let line of stack.split("\n")) {
|
|
31804
|
+
let match = /(https?:\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(line);
|
|
31805
|
+
if (!match) continue;
|
|
31806
|
+
let frame = new URL(match[1]);
|
|
31807
|
+
if (!served(frame) || frame.pathname.split("/").pop() !== name) continue;
|
|
31808
|
+
if (file.startsWith("/")) return file.endsWith(frame.pathname) ? frame.pathname : null;
|
|
31809
|
+
let resolved = new URL(file, frame);
|
|
31810
|
+
return served(resolved) ? resolved.pathname : null;
|
|
31811
|
+
}
|
|
31812
|
+
return null;
|
|
31813
|
+
}
|
|
31814
|
+
function helpers() {
|
|
31815
|
+
return [
|
|
31816
|
+
"{",
|
|
31817
|
+
` sourceFile: ${sourceFile.toString()},`,
|
|
31818
|
+
` projectFrames: ${projectFrames.toString()},`,
|
|
31819
|
+
` sourceMapLookup: ${sourceMapLookup.toString()},`,
|
|
31820
|
+
"}"
|
|
31821
|
+
].join("\n");
|
|
31822
|
+
}
|
|
31823
|
+
/**
|
|
31824
|
+
* An expression that builds the React adapter without React Grab, for module or script text.
|
|
31825
|
+
* It needs nothing from the project, so pages without a dev server can run it too.
|
|
31826
|
+
* @returns JavaScript expression text evaluating to the picker adapter.
|
|
31827
|
+
*/
|
|
31828
|
+
function reactAdapterExpression() {
|
|
31829
|
+
return `(${reactGrabAdapter.toString()})(null, ${helpers()})`;
|
|
31830
|
+
}
|
|
31831
|
+
//#endregion
|
|
31832
|
+
//#region src/bridge.ts
|
|
31833
|
+
/**
|
|
31834
|
+
* Hosts add this to the project's own pages during development, so Bud's Pages browser can follow
|
|
31835
|
+
* a page it shows in a cross-origin frame. It does nothing outside a frame, answers only its
|
|
31836
|
+
* parent, and reports where the page is. It receives nothing but back, forward, reload and the
|
|
31837
|
+
* picker's requests: `bud:pick` runs the project's picker and answers `bud:picked` with the
|
|
31838
|
+
* element, where it is on the page and the page's width; `bud:pick-cancel` ends a pick.
|
|
31839
|
+
*/
|
|
31840
|
+
var bridgeScript = `(() => {
|
|
31841
|
+
if (window.parent === window || window.__budBridge) return
|
|
31842
|
+
window.__budBridge = true
|
|
31843
|
+
let parentOrigin = null
|
|
31844
|
+
let send = () => {
|
|
31845
|
+
if (!parentOrigin) return
|
|
31846
|
+
window.parent.postMessage(
|
|
31847
|
+
{
|
|
31848
|
+
type: 'bud:location',
|
|
31849
|
+
path: location.pathname + location.search + location.hash,
|
|
31850
|
+
title: document.title,
|
|
31851
|
+
},
|
|
31852
|
+
parentOrigin,
|
|
31853
|
+
)
|
|
31854
|
+
}
|
|
31855
|
+
addEventListener('message', (event) => {
|
|
31856
|
+
if (event.source !== window.parent) return
|
|
31857
|
+
let type = event.data && event.data.type
|
|
31858
|
+
if (type === 'bud:hello') {
|
|
31859
|
+
parentOrigin = event.origin
|
|
31860
|
+
send()
|
|
31861
|
+
} else if (event.origin !== parentOrigin) return
|
|
31862
|
+
else if (type === 'bud:back') history.back()
|
|
31863
|
+
else if (type === 'bud:forward') history.forward()
|
|
31864
|
+
else if (type === 'bud:reload') location.reload()
|
|
31865
|
+
else if (type === 'bud:pick') pick(event.data.id, event.origin)
|
|
31866
|
+
else if (type === 'bud:pick-cancel') picker().then((module) => module.cancel(), () => {})
|
|
31867
|
+
})
|
|
31868
|
+
let picker = () => import(${JSON.stringify(PICKER_MODULE_URL)})
|
|
31869
|
+
// The element a person picks, its point in page pixels and where it shows in the viewport, for
|
|
31870
|
+
// the parent that asked.
|
|
31871
|
+
let pick = async (id, origin) => {
|
|
31872
|
+
if (typeof id !== 'string' || id.length > 64) return
|
|
31873
|
+
let anchor = null
|
|
31874
|
+
let point = null
|
|
31875
|
+
let view = null
|
|
31876
|
+
try {
|
|
31877
|
+
anchor = await (await picker()).pick()
|
|
31878
|
+
} catch {}
|
|
31879
|
+
try {
|
|
31880
|
+
let element = anchor && document.querySelector(anchor.selector)
|
|
31881
|
+
if (element) {
|
|
31882
|
+
let rect = element.getBoundingClientRect()
|
|
31883
|
+
point = {
|
|
31884
|
+
x: rect.left + scrollX + anchor.offsetX * rect.width,
|
|
31885
|
+
y: rect.top + scrollY + anchor.offsetY * rect.height,
|
|
31886
|
+
width: document.documentElement.clientWidth,
|
|
31887
|
+
}
|
|
31888
|
+
view = {
|
|
31889
|
+
x: rect.left + anchor.offsetX * rect.width,
|
|
31890
|
+
y: rect.top + anchor.offsetY * rect.height,
|
|
31891
|
+
}
|
|
31892
|
+
}
|
|
31893
|
+
} catch {}
|
|
31894
|
+
window.parent.postMessage(
|
|
31895
|
+
{
|
|
31896
|
+
type: 'bud:picked',
|
|
31897
|
+
id,
|
|
31898
|
+
path: location.pathname + location.search + location.hash,
|
|
31899
|
+
anchor,
|
|
31900
|
+
point,
|
|
31901
|
+
view,
|
|
31902
|
+
},
|
|
31903
|
+
origin,
|
|
31904
|
+
)
|
|
31905
|
+
}
|
|
31906
|
+
for (let method of ['pushState', 'replaceState']) {
|
|
31907
|
+
let original = history[method]
|
|
31908
|
+
history[method] = function (...args) {
|
|
31909
|
+
let result = original.apply(this, args)
|
|
31910
|
+
queueMicrotask(send)
|
|
31911
|
+
return result
|
|
31912
|
+
}
|
|
31913
|
+
}
|
|
31914
|
+
addEventListener('popstate', send)
|
|
31915
|
+
addEventListener('hashchange', send)
|
|
31916
|
+
addEventListener('load', send)
|
|
31917
|
+
new MutationObserver(send).observe(document.head || document.documentElement, {
|
|
31918
|
+
subtree: true,
|
|
31919
|
+
childList: true,
|
|
31920
|
+
characterData: true,
|
|
31921
|
+
})
|
|
31922
|
+
})()`;
|
|
31923
|
+
/**
|
|
31924
|
+
* The picker as a classic script, for pages no Bud Vite plugin serves, such as a branch's build.
|
|
31925
|
+
* React pickers read React's development build without React Grab, which such pages can't import;
|
|
31926
|
+
* a project's own picker module needs its dev server, so the DOM picker stands in for it.
|
|
31927
|
+
* @param picker - The project's configured picker.
|
|
31928
|
+
* @returns Script text that leaves the picker on `window.__budPicker`.
|
|
31929
|
+
*/
|
|
31930
|
+
function pickerPageScript(picker) {
|
|
31931
|
+
if (picker.name === "bud:react-grab" || picker.name === "bud:react") return pickerScript(picker.name, reactAdapterExpression());
|
|
31932
|
+
return pickerScript(picker.module ? "bud:dom" : picker.name, null);
|
|
31933
|
+
}
|
|
31934
|
+
//#endregion
|
|
31053
31935
|
//#region ../previews/src/server/errors.ts
|
|
31054
31936
|
/** An unknown route, or an image revision that is no longer the latest. */
|
|
31055
31937
|
var PreviewNotFoundError = class extends TaggedError("PreviewNotFoundError") {};
|
|
@@ -32868,21 +33750,21 @@ function run(command, directory, env, timeoutMs) {
|
|
|
32868
33750
|
let output = collect(child);
|
|
32869
33751
|
let timer = setTimeout(() => {
|
|
32870
33752
|
stop(child);
|
|
32871
|
-
resume(fail$
|
|
33753
|
+
resume(fail$5(new BranchBuildError({
|
|
32872
33754
|
message: `${command} took too long.`,
|
|
32873
33755
|
output: output()
|
|
32874
33756
|
})));
|
|
32875
33757
|
}, timeoutMs);
|
|
32876
33758
|
child.once("error", (cause) => {
|
|
32877
33759
|
clearTimeout(timer);
|
|
32878
|
-
resume(fail$
|
|
33760
|
+
resume(fail$5(new BranchBuildError({
|
|
32879
33761
|
message: cause.message,
|
|
32880
33762
|
output: output()
|
|
32881
33763
|
})));
|
|
32882
33764
|
});
|
|
32883
33765
|
child.once("exit", (code) => {
|
|
32884
33766
|
clearTimeout(timer);
|
|
32885
|
-
resume(code === 0 ? void_ : fail$
|
|
33767
|
+
resume(code === 0 ? void_ : fail$5(new BranchBuildError({
|
|
32886
33768
|
message: `${command} exited with ${code}.`,
|
|
32887
33769
|
output: output()
|
|
32888
33770
|
})));
|
|
@@ -33513,7 +34395,7 @@ function branchPreviewsLayer(project, options) {
|
|
|
33513
34395
|
if (remote) yield* follow.pipe(andThen(sleep(`${options.pollMs ?? 5e3} millis`)), forever, forkScoped);
|
|
33514
34396
|
let find = (branch) => {
|
|
33515
34397
|
let set = tracked().includes(branch) ? ensure(branch) : void 0;
|
|
33516
|
-
return set ? succeed$2(set) : fail$
|
|
34398
|
+
return set ? succeed$2(set) : fail$5(new BranchError({
|
|
33517
34399
|
code: "not-found",
|
|
33518
34400
|
message: "This branch is not active."
|
|
33519
34401
|
}));
|
|
@@ -33602,4 +34484,4 @@ function branchPreviewsLayer(project, options) {
|
|
|
33602
34484
|
}));
|
|
33603
34485
|
}
|
|
33604
34486
|
//#endregion
|
|
33605
|
-
export {
|
|
34487
|
+
export { unwrap as $, provide$2 as $n, map$2 as $t, ProcessRunner as A, tap$1 as An, andThen as At, ensuring as B, withFiber as Bn, context as Bt, themeStyle as C, scoped as Cn, TaggedError as Cr, isPattern as Ct, nodeLayer as D, succeedNone as Dn, acquireUseRelease as Dt, LOGO_TYPES as E, succeed$2 as En, acquireRelease as Et, changes as F, try_ as Fn, callback$1 as Ft, ignore as G, effect as Gn, flatMap$1 as Gt, filter as H, currentTimeMillis as Hn, ensuring$2 as Ht, concat as I, undefined_$2 as In, catchIf as It, mapError as J, empty$2 as Jn, forever as Jt, make$7 as K, effectContext as Kn, flatten$2 as Kt, debounce as L, uninterruptible as Ln, catchTag as Lt, Path$1 as M, timeoutOption as Mn, asSome as Mt, FileSystem as N, timeoutOrElse as Nn, asVoid as Nt, readText as O, suspend$2 as On, addFinalizer as Ot, as as P, tryPromise as Pn, cached as Pt, tap as Q, mergeAll$1 as Qn, ignore$2 as Qt, drop as R, uninterruptibleMask as Rn, catch_$1 as Rt, resolveScreenRoutes as S, scope as Sn, some as Sr, isNonEmpty as St, FACTORY_STATUS_ROLES as T, sleep as Tn, bytes as Tt, fromAsyncIterable as U, build as Un, fail$5 as Ut, fail$2 as V, yieldNow as Vn, die as Vt, fromPubSub as W, buildWithMemoMap as Wn, filterOrFail as Wt, runForEach as X, makeMemoMapUnsafe as Xn, forkScoped as Xt, merge$1 as Y, isLayer as Yn, forkIn as Yt, suspend as Z, merge$3 as Zn, gen as Zt, createProjectContext as _, runPromiseWith as _n, make$25 as _r, Struct as _t, followCapture as a, promise as an, close as ar, take as at, withPlugins as b, runSyncExitWith as bn, isNone as br, decodeEffect as bt, previewsLayer as c, provideService as cn, _await as cr, shutdown$1 as ct, pickerPageScript as d, runCallbackWith as dn, succeed$4 as dr, await_ as dt, mapError$2 as en, provideMerge as er, make$8 as et, PICKER_MODULE_URL as f, runFork as fn, void_$1 as fr, interrupt as ft, Project as g, runPromiseExitWith as gn, getOption as gr, String$1 as gt, gitLayer as h, runPromiseExit as hn, add as hr, Record as ht, projectFlows as i, orElseSucceed as in, unwrap$4 as ir, sliding as it, RuntimePolicy as j, tapError as jn, as$1 as jt, writeTextAtomic as k, sync as kn, all$1 as kt, PreviewSession as l, result as ln, doneUnsafe as lr, sliding$1 as lt, Git as m, runPromise as mn, Service as mr, ArraySchema as mt, branchIndexName as n, option as nn, succeedContext as nr, offer as nt, startBranchBuild as o, provide as on, forkUnsafe as or, publish as ot, pickerModule as p, runForkWith as pn, scopeRemoveFinalizerUnsafe as pr, runIn as pt, mapEffect as q, effectDiscard as qn, forEach$1 as qt, branchPreviewsLayer as r, orDie as rn, sync$1 as rr, shutdown as rt, Previews as s, provideContext as sn, makeUnsafe$4 as sr, publishAll as st, BranchPreviews as t, match as tn, succeed$3 as tr, makeUnsafe as tt, bridgeScript as u, runCallback as un, make$23 as ur, unbounded$1 as ut, projectModuleFile as v, runSync$1 as vn, getOrNull as vr, Undefined as vt, FACTORY_STATUS_CATEGORIES as w, serviceOption as wn, optional$1 as wt, defaultScreens as x, runSyncWith as xn, none$1 as xr, isMaxLength as xt, configPlugins as y, runSyncExit as yn, getOrUndefined$1 as yr, Union as yt, empty as z, void_ as zn, clockWith as zt };
|