@athrio/loom 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bun
2
- import { t as __commonJSMin } from "./rolldown-runtime-yvBN9yY6.js";
3
- import { $ as get, $n as filter, $t as ignore, A as Boolean, An as mergeAll, Ar as identity, At as makeUnsafe, B as make$8, Bn as fail$2, Bt as catchTag, C as errorReported, Cn as try_, Cr as format, Ct as endUnsafe, D as make$9, Dr as isNullish, Dt as offerUnsafe, E as Crypto$1, En as catchDone, Er as isNotUndefined, Et as offer, F as FileDescriptor, Fn as MinimumLogLevel, Ft as as, G as isStream, Gn as fail$3, Gt as ensuring, H as decodeText, Hn as Done, Ht as catch_, I as FileSystem, In as _await, It as asVoid, J as run$2, Jn as empty, Jt as fnUntraced, K as merge, Kn as Reference, Kt as fail, L as FileTypeId, Ln as doneUnsafe, Lt as callback, M as TrueValues, Mn as provideMerge, Mr as pipeArguments, Mt as acquireRelease, N as Path$1, Nn as succeed$3, Nt as addFinalizer$1, O as error, On as taggedEnum, Or as isUndefined, Ot as take, P as TypeId$5, Pn as addFinalizer, Pt as andThen, Q as unwrap, Qn as dedupe, Qt as gen, R as Size, Rn as isDone, S as errorExitCode, Sn as tryPromise, Sr as BaseProto, St as mapDone, Tn as void_, Tr as isNotNull, Tt as make$12, U as empty$1, Un as UnknownError, V as callback$1, Vn as succeed$2, Vt as catchTags, W as fromChannel$1, Wn as done, Wt as effectify, X as splitLines, Xn as make$6, Xt as forever, Y as runCollect, Yn as getUnsafe, Yt as forEach, Z as transduce, Zn as Prototype, Zt as forkScoped, _ as Terminal, _n as succeed, _r as map$4, _t as tag, a as storeDir, an as match$1, ar as of, at as badArgument, b as Stdio, br as some, c as LoomCompiler, cn as orElseSucceed, cr as fail$1, ct as Defect, d as PackageConfig, dn as provideService, dr as fromNullishOr, dt as String$1, en as interrupt, et as make$11, f as LoomConfig, fn as raceFirst, fr as fromUndefinedOr, ft as Struct, g as QuitError, gn as serviceOption, gr as isSome, gt as optional$3, hn as scoped, hr as isNone, ht as is, i as servicePackage, in as mapError, ir as match, it as BadArgument, j as FalseValues, jn as provide, jr as pipe, jt as nominal, k as log, kn as effect, kr as dual, kt as make$7, ln as provide$1, lr as succeed$1, lt as ErrorClass, mn as runFork, mr as getOrUndefined, mt as decodeUnknownEffect, n as installedServices, nt as fromChannel, o as workspaceRoot, on as matchEffect, or as reduce, ot as systemError, pn as result, pr as getOrElse, pt as Union, q as mkString, qn as Service, qt as flatMap, r as removeService, rn as map$2, rr as map$3, rt as isSink, s as DocumentSource, sn as orDie, sr as sort, st as ArraySchema, t as addService, tn as isEffect, tt as drain, un as provideContext, ur as flatMap$1, ut as Literal, v as isQuitError, vn as suspend, vr as match$2, vt as toCodecStringTree, w as makeRunMain, wn as uninterruptible, wr as hasProperty, wt as failCauseUnsafe, x as make$10, xn as timeoutOrElse, xr as String$2, xt as fromTransform, y as make$13, yn as sync, yr as none, z as WatchBackend, zn as makeUnsafe$1, zt as catchFilter } from "./LoomStore-DMf2PkfP.js";
1
+ #!/usr/bin/env node
2
+ import { t as __commonJSMin } from "./rolldown-runtime-YU9U6SYh.js";
3
+ import { $ as mkString, $n as done, $t as ensuring, A as log, An as timeoutOrElse, Ar as none, At as mapDone, B as WatchBackend, Bn as provide, Br as dual, Bt as acquireRelease, C as errorExitCode, Cn as runFork, Cr as fromUndefinedOr, Ct as is, D as Crypto$1, Dn as suspend, Dr as isSome, En as succeed, Er as isNone, Et as toCodecStringTree, F as TypeId$5, Fn as catchDone, Fr as hasProperty, Ft as offerUnsafe, G as empty$1, Gn as _await, Gt as callback, H as callback$1, Hn as succeed$3, Hr as pipe, Ht as andThen, I as FileDescriptor, Ir as isNotNull, It as take, J as fromEffect, Jn as makeUnsafe$1, Jt as catchTag, K as filter$1, Kn as doneUnsafe, L as FileSystem, Ln as taggedEnum, Lr as isNotUndefined, Lt as make$7, M as FalseValues, Mn as try_, Mr as String$2, Mt as failCauseUnsafe, N as TrueValues, Nn as uninterruptible, Nr as BaseProto, Nt as make$12, O as make$9, On as sync, Or as map$4, P as Path$1, Pn as void_, Pr as format, Pt as offer, Q as merge, Qn as UnknownError, Qt as effectify, R as FileTypeId, Rn as effect, Rr as isNullish, Rt as makeUnsafe, S as make$10, Sn as result, Sr as fromNullishOr, St as decodeUnknownEffect, T as makeRunMain, Tn as serviceOption, Tr as getOrUndefined, Tt as tag, U as concat, Un as addFinalizer, Ur as pipeArguments, Ut as as, V as make$8, Vn as provideMerge, Vr as identity, Vt as addFinalizer$1, W as decodeText, Wn as MinimumLogLevel, Wt as asVoid, X as isStream, Xn as succeed$2, Xt as catch_, Y as groupedWithin, Yn as fail$2, Yt as catchTags, Z as mapEffect, Zn as Done, _ as QuitError, _n as orElseSucceed, _r as fail$1, _t as ErrorClass, a as storeDir, an as forkScoped, ar as make$6, at as transduce, b as make$13, bn as provideService, br as contains, bt as Struct, c as LoomCompiler, cn as interrupt, cr as filter, ct as make$11, dn as map$2, dt as isSink, en as fail, er as fail$3, et as orDie$1, f as PackageConfig, fn as mapError, fr as map$3, ft as BadArgument, gn as orDie, gr as sort, gt as Defect, hn as option, hr as reduce, ht as ArraySchema, i as servicePackage, in as forever, ir as getUnsafe, it as splitLines, j as Boolean, jn as tryPromise, jr as some, jt as endUnsafe, k as error, kr as match$2, kt as fromTransform, l as ignoredDirs, ln as isEffect, lt as drain, mn as matchEffect, mr as of, mt as systemError, n as installedServices, nn as fnUntraced, nr as Service, nt as runCollect, o as workspaceRoot, on as gen, or as Prototype, ot as unwrap, p as LoomConfig, pn as match$1, pr as match, pt as badArgument, q as fromChannel$1, qn as isDone, qt as catchFilter, r as removeService, rn as forEach, rr as empty, rt as runForEach, s as DocumentSource, sn as ignore, sr as dedupe, st as get, t as addService, tn as flatMap, tr as Reference, tt as run$2, ut as fromChannel, v as Terminal, vn as provide$1, vr as match$3, vt as Literal, w as errorReported, wn as scoped, wr as getOrElse, wt as optional$3, x as Stdio, xn as raceFirst, xr as flatMap$1, xt as Union, y as isQuitError, yn as provideContext, yr as succeed$1, yt as String$1, z as Size, zn as mergeAll, zr as isUndefined, zt as nominal } from "./LoomStore-DOjrkJaQ.js";
4
4
  import * as NodeChildProcess from "node:child_process";
5
- import "node:stream";
5
+ import { PassThrough } from "node:stream";
6
6
  import * as Crypto from "node:crypto";
7
7
  import * as NFS from "node:fs";
8
8
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
@@ -8525,11 +8525,11 @@ var getOutOfScopeGlobalFlagErrors = (allFlags, activeFlags, flagMap, commandPath
8525
8525
  }
8526
8526
  return errors;
8527
8527
  };
8528
- var showHelp = (command, error$2) => gen(function* () {
8528
+ var showHelp = (command, error$3) => gen(function* () {
8529
8529
  const formatter = yield* Formatter;
8530
- const helpDoc = yield* getHelpForCommandPath(command, error$2.commandPath, BuiltIns);
8530
+ const helpDoc = yield* getHelpForCommandPath(command, error$3.commandPath, BuiltIns);
8531
8531
  yield* log(formatter.formatHelpDoc(helpDoc));
8532
- if (error$2.errors.length > 0) yield* error(formatter.formatErrors(error$2.errors));
8532
+ if (error$3.errors.length > 0) yield* error(formatter.formatErrors(error$3.errors));
8533
8533
  });
8534
8534
  /**
8535
8535
  * Runs a command using the arguments supplied by the `Stdio` service.
@@ -9092,7 +9092,6 @@ var fromReadableChannel = (options) => fromTransform((_, scope) => readableToPul
9092
9092
  }));
9093
9093
  var readableToPullUnsafe = (options) => {
9094
9094
  const readable = options.readable;
9095
- if (readable.readableEnded) return succeed(done());
9096
9095
  const closeOnDone = options.closeOnDone ?? true;
9097
9096
  const exit = options.exit ?? make$7(void 0);
9098
9097
  const latch = makeUnsafe(false);
@@ -9114,6 +9113,7 @@ var readableToPullUnsafe = (options) => {
9114
9113
  let item = options.readable.read(options.chunkSize);
9115
9114
  if (item === null) {
9116
9115
  if (exit.current) return exit.current;
9116
+ if (readable.readableEnded) return fail(Done());
9117
9117
  latch.closeUnsafe();
9118
9118
  return flatMap(latch.await, loop);
9119
9119
  }
@@ -9240,10 +9240,15 @@ var layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(fun
9240
9240
  }
9241
9241
  case "output": {
9242
9242
  let stream = empty$1;
9243
- if (nodeStream && "read" in nodeStream) stream = fromReadable({
9244
- evaluate: () => nodeStream,
9245
- onError: (error) => toPlatformError(`fromReadable(fd${fd})`, toError(error), command)
9246
- });
9243
+ if (nodeStream && "read" in nodeStream) {
9244
+ const passThrough = new PassThrough();
9245
+ nodeStream.on("error", (error) => passThrough.destroy(error));
9246
+ nodeStream.pipe(passThrough);
9247
+ stream = fromReadable({
9248
+ evaluate: () => passThrough,
9249
+ onError: (error) => toPlatformError(`fromReadable(fd${fd})`, toError(error), command)
9250
+ });
9251
+ }
9247
9252
  if (config.sink) stream = transduce(stream, config.sink);
9248
9253
  outputStreams.set(fd, stream);
9249
9254
  break;
@@ -9267,14 +9272,24 @@ var layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(fun
9267
9272
  return succeed(sink);
9268
9273
  });
9269
9274
  const setupChildOutputStreams = (command, childProcess, stdoutConfig, stderrConfig) => {
9270
- let stdout = childProcess.stdout ? fromReadable({
9271
- evaluate: () => childProcess.stdout,
9272
- onError: (error) => toPlatformError("fromReadable(stdout)", toError(error), command)
9273
- }) : empty$1;
9274
- let stderr = childProcess.stderr ? fromReadable({
9275
- evaluate: () => childProcess.stderr,
9276
- onError: (error) => toPlatformError("fromReadable(stderr)", toError(error), command)
9277
- }) : empty$1;
9275
+ let stdout = childProcess.stdout ? (() => {
9276
+ const passThrough = new PassThrough();
9277
+ childProcess.stdout.on("error", (error) => passThrough.destroy(error));
9278
+ childProcess.stdout.pipe(passThrough);
9279
+ return fromReadable({
9280
+ evaluate: () => passThrough,
9281
+ onError: (error) => toPlatformError("fromReadable(stdout)", toError(error), command)
9282
+ });
9283
+ })() : empty$1;
9284
+ let stderr = childProcess.stderr ? (() => {
9285
+ const passThrough = new PassThrough();
9286
+ childProcess.stderr.on("error", (error) => passThrough.destroy(error));
9287
+ childProcess.stderr.pipe(passThrough);
9288
+ return fromReadable({
9289
+ evaluate: () => passThrough,
9290
+ onError: (error) => toPlatformError("fromReadable(stderr)", toError(error), command)
9291
+ });
9292
+ })() : empty$1;
9278
9293
  if (isSink(stdoutConfig.stream)) stdout = transduce(stdout, stdoutConfig.stream);
9279
9294
  if (isSink(stderrConfig.stream)) stderr = transduce(stderr, stderrConfig.stream);
9280
9295
  const all = merge(stdout, stderr);
@@ -9359,7 +9374,6 @@ var layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(fun
9359
9374
  const stderrConfig = resolveOutputOption(cmd.options, "stderr");
9360
9375
  const resolvedAdditionalFds = resolveAdditionalFds(cmd.options);
9361
9376
  let isReferenced = true;
9362
- let cleanupOnNonZeroExit = false;
9363
9377
  const cwd = yield* resolveWorkingDirectory(cmd.options);
9364
9378
  const env = resolveEnvironment(cmd.options);
9365
9379
  const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds);
@@ -9382,20 +9396,18 @@ var layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(fun
9382
9396
  }));
9383
9397
  const pid = ProcessId(childProcess.pid);
9384
9398
  childProcess.on("exit", (code) => {
9385
- if (cleanupOnNonZeroExit && code !== 0 && isNotNull(code)) killProcessGroupOnExit(childProcess, cmd.options.killSignal ?? "SIGTERM");
9399
+ if (code !== 0 && isNotNull(code)) killProcessGroupOnExit(childProcess, cmd.options.killSignal ?? "SIGTERM");
9386
9400
  });
9387
9401
  const reref = sync(() => {
9388
9402
  if (!isReferenced) {
9389
9403
  childProcess.ref();
9390
9404
  isReferenced = true;
9391
- cleanupOnNonZeroExit = false;
9392
9405
  }
9393
9406
  });
9394
9407
  const unref = sync(() => {
9395
9408
  if (isReferenced) {
9396
9409
  childProcess.unref();
9397
9410
  isReferenced = false;
9398
- cleanupOnNonZeroExit = true;
9399
9411
  }
9400
9412
  return reref;
9401
9413
  });
@@ -9566,6 +9578,13 @@ var chown = /*#__PURE__*/ (() => {
9566
9578
  const nodeChown = /*#__PURE__*/ effectify(NFS.chown, /*#__PURE__*/ handleErrnoException("FileSystem", "chown"), /*#__PURE__*/ handleBadArgument("chown"));
9567
9579
  return (path, uid, gid) => nodeChown(path, uid, gid);
9568
9580
  })();
9581
+ var glob = /*#__PURE__*/ (() => {
9582
+ const nodeGlob = /*#__PURE__*/ effectify(NFS.glob, /*#__PURE__*/ handleErrnoException("FileSystem", "glob"), /*#__PURE__*/ handleBadArgument("glob"));
9583
+ return (pattern, options) => nodeGlob(pattern, {
9584
+ cwd: options?.root,
9585
+ exclude: options?.exclude
9586
+ });
9587
+ })();
9569
9588
  var link = /*#__PURE__*/ (() => {
9570
9589
  const nodeLink = /*#__PURE__*/ effectify(NFS.link, /*#__PURE__*/ handleErrnoException("FileSystem", "link"), /*#__PURE__*/ handleBadArgument("link"));
9571
9590
  return (existingPath, newPath) => nodeLink(existingPath, newPath);
@@ -9843,6 +9862,7 @@ var makeFileSystem = /*#__PURE__*/ map$2(/*#__PURE__*/ serviceOption(WatchBacken
9843
9862
  chown,
9844
9863
  copy,
9845
9864
  copyFile,
9865
+ glob,
9846
9866
  link,
9847
9867
  makeDirectory,
9848
9868
  makeTempDirectory,
@@ -9866,18 +9886,19 @@ var makeFileSystem = /*#__PURE__*/ map$2(/*#__PURE__*/ serviceOption(WatchBacken
9866
9886
  writeFile
9867
9887
  }));
9868
9888
  //#endregion
9869
- //#region ../../node_modules/@effect/platform-bun/dist/BunFileSystem.js
9889
+ //#region ../../node_modules/@effect/platform-node/dist/NodeFileSystem.js
9870
9890
  /**
9871
- * Bun layer for Effect's `FileSystem` service.
9891
+ * Node.js `FileSystem` layer for programs that perform real filesystem I/O.
9872
9892
  *
9873
- * This module exposes one `layer` that provides `FileSystem` in Bun by using
9874
- * the shared Node file-system implementation. Once the layer is provided,
9875
- * programs use the standard `effect/FileSystem` service operations.
9893
+ * The exported layer satisfies the platform-independent `FileSystem` service
9894
+ * with Node-backed operations for files, directories, metadata, permissions,
9895
+ * links, temporary paths, and path watching. Effects still call the service from
9896
+ * `effect/FileSystem`; this module only chooses the Node implementation.
9876
9897
  *
9877
9898
  * @since 4.0.0
9878
9899
  */
9879
9900
  /**
9880
- * Layer that provides the `FileSystem` service for Bun using the shared Node file-system implementation.
9901
+ * Provides the `FileSystem` service backed by Node filesystem APIs.
9881
9902
  *
9882
9903
  * @category layers
9883
9904
  * @since 4.0.0
@@ -9914,22 +9935,22 @@ var digest = (algorithm, data) => try_({
9914
9935
  })
9915
9936
  });
9916
9937
  //#endregion
9917
- //#region ../../node_modules/@effect/platform-bun/dist/BunCrypto.js
9938
+ //#region ../../node_modules/@effect/platform-node/dist/NodeCrypto.js
9918
9939
  /**
9919
- * The `BunCrypto` module provides Bun's `Crypto` service layer for Effect
9920
- * programs. Provide {@link layer} at the edge of a Bun app, CLI, script, or
9921
- * test to satisfy `effect/Crypto` with cryptographically secure random bytes,
9922
- * UUID generation, random values, and SHA digest operations.
9940
+ * The `NodeCrypto` module provides the Node.js `Crypto` service layer for
9941
+ * Effect programs. Provide {@link layer} at the edge of a Node application,
9942
+ * CLI, script, or test to satisfy `effect/Crypto` with Node's `node:crypto`
9943
+ * implementation for secure random bytes, UUID generation, random values, and
9944
+ * SHA digest operations.
9923
9945
  *
9924
- * This adapter reuses the shared Node-compatible implementation, so randomness
9925
- * and digest behavior follow Bun's `node:crypto` compatibility layer. SHA-1 is
9926
- * present for interoperability with existing protocols, not for new
9927
- * security-sensitive designs.
9946
+ * This module is the public Node adapter around the shared Node-compatible
9947
+ * implementation. Digest failures are reported as platform errors, and SHA-1
9948
+ * remains available only for interoperability with existing protocols.
9928
9949
  *
9929
9950
  * @since 1.0.0
9930
9951
  */
9931
9952
  /**
9932
- * Layer that provides the Bun Crypto service implementation.
9953
+ * Layer that provides the Node.js Crypto service implementation.
9933
9954
  *
9934
9955
  * @category layers
9935
9956
  * @since 1.0.0
@@ -9969,19 +9990,20 @@ var toFileUrl = (path) => try_({
9969
9990
  ({ ...Path.posix });
9970
9991
  ({ ...Path.win32 });
9971
9992
  //#endregion
9972
- //#region ../../node_modules/@effect/platform-bun/dist/BunPath.js
9993
+ //#region ../../node_modules/@effect/platform-node/dist/NodePath.js
9973
9994
  /**
9974
- * Bun-backed layers for Effect's {@link Path} service.
9995
+ * Node.js layers for Effect's `Path` service.
9975
9996
  *
9976
- * This module provides the `Path` service for Bun programs by reusing the
9977
- * shared Node-compatible path implementation. Provide one of these layers when
9978
- * Bun code should receive path operations from the Effect environment instead
9979
- * of importing runtime path helpers directly.
9997
+ * This module provides the default, POSIX, and Windows variants of the
9998
+ * platform-independent `Path` service by reusing the shared Node path
9999
+ * implementation. The provided path services include Node file URL conversion
10000
+ * behavior.
9980
10001
  *
9981
10002
  * @since 4.0.0
9982
10003
  */
9983
10004
  /**
9984
- * Layer that provides the default `Path` service for Bun using the shared Node path implementation.
10005
+ * Provides the default Node `Path` service using the platform's `node:path`
10006
+ * implementation.
9985
10007
  *
9986
10008
  * @category layers
9987
10009
  * @since 4.0.0
@@ -9993,14 +10015,14 @@ var layer$5 = /* @__PURE__ */ succeed$3(Path$1)({
9993
10015
  toFileUrl
9994
10016
  });
9995
10017
  //#endregion
9996
- //#region ../../node_modules/@effect/platform-bun/dist/BunStdio.js
10018
+ //#region ../../node_modules/@effect/platform-node/dist/NodeStdio.js
9997
10019
  /**
9998
- * Process stdio for Bun applications.
10020
+ * Node.js `Stdio` layer for the current process.
9999
10021
  *
10000
- * This module provides the Bun layer for Effect's `Stdio` service by using the
10001
- * shared Node stdio implementation. Arguments come from `process.argv`, input
10002
- * is read from `process.stdin`, and output and error output write to
10003
- * `process.stdout` and `process.stderr`.
10022
+ * The exported layer reuses the shared Node stdio implementation. It satisfies
10023
+ * the platform-independent `Stdio` service by reading command-line arguments
10024
+ * from `process.argv`, consuming input from `process.stdin`, and writing output
10025
+ * streams to `process.stdout` and `process.stderr`.
10004
10026
  *
10005
10027
  * @since 4.0.0
10006
10028
  */
@@ -10113,42 +10135,24 @@ function defaultShouldQuit(input) {
10113
10135
  return input.key.ctrl && (input.key.name === "c" || input.key.name === "d");
10114
10136
  }
10115
10137
  //#endregion
10116
- //#region ../../node_modules/@effect/platform-bun/dist/BunTerminal.js
10117
- /**
10118
- * Bun-backed implementation of Effect's `Terminal` service.
10119
- *
10120
- * This module reuses the shared Node terminal implementation for Bun. `make`
10121
- * creates a scoped process-backed `Terminal` service, and `layer` provides the
10122
- * default terminal service with the standard quit behavior for key input.
10123
- *
10124
- * @since 4.0.0
10125
- */
10126
- /**
10127
- * Provides the default process-backed `Terminal` service, ending key input on
10128
- * the default quit keys.
10129
- *
10130
- * @category layers
10131
- * @since 4.0.0
10132
- */
10133
- var layer$1 = layer$2;
10134
- //#endregion
10135
- //#region ../../node_modules/@effect/platform-bun/dist/BunServices.js
10138
+ //#region ../../node_modules/@effect/platform-node/dist/NodeServices.js
10136
10139
  /**
10137
- * Provides the default Bun implementations for child process spawning,
10140
+ * Provides the default Node implementations for child process spawning,
10138
10141
  * filesystem, path, stdio, and terminal services.
10139
10142
  *
10140
10143
  * @category layers
10141
10144
  * @since 4.0.0
10142
10145
  */
10143
- var layer = /*#__PURE__*/ layer$11.pipe(/*#__PURE__*/ provideMerge(/*#__PURE__*/ mergeAll(layer$9, layer$7, layer$5, layer$3, layer$1)));
10146
+ var layer = /*#__PURE__*/ provideMerge(layer$11, /*#__PURE__*/ mergeAll(layer$9, layer$7, layer$5, layer$3, layer$2));
10144
10147
  //#endregion
10145
- //#region ../../node_modules/@effect/platform-bun/dist/BunRuntime.js
10148
+ //#region ../../node_modules/@effect/platform-node/dist/NodeRuntime.js
10146
10149
  /**
10147
- * Bun process runner for Effect programs.
10150
+ * Node.js process runner for Effect programs.
10148
10151
  *
10149
10152
  * This module exports `runMain`, which runs one Effect as the main process
10150
- * fiber in Bun. It reuses the shared Node runtime runner, including its error
10151
- * reporting, signal handling, and optional teardown behavior.
10153
+ * fiber in Node.js. It reuses the shared Node runtime runner, including its
10154
+ * error reporting, `SIGINT` / `SIGTERM` interruption, and optional teardown
10155
+ * behavior.
10152
10156
  *
10153
10157
  * @since 4.0.0
10154
10158
  */
@@ -10157,8 +10161,9 @@ var layer = /*#__PURE__*/ layer$11.pipe(/*#__PURE__*/ provideMerge(/*#__PURE__*/
10157
10161
  *
10158
10162
  * **When to use**
10159
10163
  *
10160
- * Use to run a Bun application's main Effect with structured error handling,
10161
- * log management, interrupt support, or advanced teardown capabilities.
10164
+ * Use to run a Node.js application's main Effect with structured error
10165
+ * handling, log management, interrupt support, or advanced teardown
10166
+ * capabilities.
10162
10167
  *
10163
10168
  * **Details**
10164
10169
  *
@@ -10168,9 +10173,8 @@ var layer = /*#__PURE__*/ layer$11.pipe(/*#__PURE__*/ provideMerge(/*#__PURE__*/
10168
10173
  * behaviors can be turned off. You can also provide custom teardown logic to
10169
10174
  * finalize resources or produce different exit codes.
10170
10175
  *
10171
- * An optional object that can include:
10176
+ * The optional configuration object can include:
10172
10177
  * - `disableErrorReporting`: Turn off automatic error logging.
10173
- * - `disablePrettyLogger`: Avoid adding the pretty logger.
10174
10178
  * - `teardown`: Provide custom finalization logic.
10175
10179
  *
10176
10180
  * @category running
@@ -10214,17 +10218,13 @@ var pruned = (produced) => ({
10214
10218
  });
10215
10219
  //#endregion
10216
10220
  //#region ../loom-lang/src/LoomTangler.ts
10217
- var ignoredSegment = /* @__PURE__ */ new Set([
10218
- "node_modules",
10219
- ".loom",
10220
- "dist",
10221
- ".git"
10222
- ]);
10223
- var isStorePath = (name) => name.split("/").some((segment) => ignoredSegment.has(segment));
10221
+ var isStorePath = (name) => name.split("/").some((segment) => ignoredDirs.has(segment));
10224
10222
  var LoomTangler = class extends Service()("LoomTangler", { make: gen(function* () {
10225
10223
  const compiler = yield* LoomCompiler;
10226
10224
  const fs = yield* FileSystem;
10227
- const writeFile = (file) => fs.makeDirectory(dirname(file.path), { recursive: true }).pipe(andThen(fs.writeFileString(file.path, file.content)), orDie, as(file));
10225
+ const config = yield* PackageConfig;
10226
+ const matchesDisk = (file) => fs.readFileString(file.path).pipe(option, map$2(contains(file.content)));
10227
+ const writeFile = (file) => matchesDisk(file).pipe(flatMap((same) => same ? void_ : fs.makeDirectory(dirname(file.path), { recursive: true }).pipe(andThen(fs.writeFileString(file.path, file.content)))), orDie, as(file));
10228
10228
  const tangleFile = (entry) => compiler.tangle(entry).pipe(flatMap((files) => forEach(files, writeFile)));
10229
10229
  const loomsUnder = (dir) => fs.readDirectory(dir, { recursive: true }).pipe(orDie, map$2((names) => pipe(names, filter((name) => name.endsWith(".loom") && !isStorePath(name)), map$3((name) => resolve(dir, name)))));
10230
10230
  const loomsOf = (path) => fs.stat(path).pipe(orDie, flatMap((info) => info.type === "Directory" ? loomsUnder(path) : succeed([path])));
@@ -10255,10 +10255,16 @@ var LoomTangler = class extends Service()("LoomTangler", { make: gen(function* (
10255
10255
  yield* writeLock(root, pruned(produced));
10256
10256
  return map$3(orphans, (rel) => resolve(root, rel));
10257
10257
  });
10258
+ const batchWindow = "50 millis";
10259
+ const batchLimit = 1e3;
10260
+ const isLoomEvent = (event) => event.path.endsWith(".loom") && !isStorePath(event.path);
10261
+ const watchRoot = (path) => fs.stat(path).pipe(orDie, flatMap((info) => info.type === "Directory" ? succeed(path) : config.resolve(path).pipe(map$2(({ corpusDir }) => getOrElse(fromNullishOr(corpusDir), () => dirname(path))))));
10262
+ const watch = (path) => unwrap(watchRoot(path).pipe(map$2((root) => concat(fromEffect(result(tangle(path))), fs.watch(root).pipe(filter$1(isLoomEvent), groupedWithin(batchLimit, batchWindow), mapEffect((events) => forEach(dedupe(map$3(events, (event) => resolve(root, event.path))), (changed) => compiler.invalidate(changed), { discard: true }).pipe(andThen(result(tangle(path))))), orDie$1)))));
10258
10263
  return {
10259
10264
  tangle,
10260
10265
  orphans,
10261
- prune
10266
+ prune,
10267
+ watch
10262
10268
  };
10263
10269
  }) }) {
10264
10270
  static {
@@ -10302,11 +10308,19 @@ var banner = log(`\n${teal([
10302
10308
  " ███████╗╚██████╔╝╚██████╔╝██║ ╚═╝ ██║",
10303
10309
  " ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
10304
10310
  ].join("\n"))}\n ${dim("a literate framework")}\n`);
10305
- var tangle = (file) => gen(function* () {
10306
- const written = yield* (yield* LoomTangler).tangle(resolve(process.cwd(), file));
10307
- if (written.length === 0) yield* log("loom: no {path} sinks to tangle");
10308
- else yield* forEach(written, (f) => log(`loom: tangled ${f.section} → ${f.path}`));
10311
+ var reportWritten = (written) => written.length === 0 ? log("loom: no {path} sinks to tangle") : forEach(written, (f) => log(`loom: tangled ${f.section} → ${f.path}`), { discard: true });
10312
+ var tangleOnce = (file) => gen(function* () {
10313
+ yield* reportWritten(yield* (yield* LoomTangler).tangle(resolve(process.cwd(), file)));
10309
10314
  }).pipe(catchTag("TangleError", (e) => error(e.message).pipe(andThen(sync(() => void (process.exitCode = 1))))));
10315
+ var tangleWatch = (file) => gen(function* () {
10316
+ const tangler = yield* LoomTangler;
10317
+ yield* log(`loom: watching ${file} — re-tangling on change`);
10318
+ yield* runForEach(tangler.watch(resolve(process.cwd(), file)), match$3({
10319
+ onSuccess: reportWritten,
10320
+ onFailure: (error$1) => error(error$1.message)
10321
+ }));
10322
+ });
10323
+ var tangle = (file, watch) => watch ? tangleWatch(file) : tangleOnce(file);
10310
10324
  var orphans = (prune) => gen(function* () {
10311
10325
  const tangler = yield* LoomTangler;
10312
10326
  if (prune) {
@@ -10378,7 +10392,7 @@ var add = (language) => gen(function* () {
10378
10392
  yield* addService(language, dir);
10379
10393
  yield* updateLanguages(config, dir, (ids) => [.../* @__PURE__ */ new Set([...ids, language])]);
10380
10394
  yield* log(`\n ${teal("✓")} activated ${language}\n ${dim(`store: ${storeDir(dir)}`)}\n`);
10381
- }).pipe(catchTag("StoreError", (error$1) => error(`loom: could not install ${servicePackage(error$1.id)} — ${String(error$1.cause)}`).pipe(andThen(sync(() => void (process.exitCode = 1))))));
10395
+ }).pipe(catchTag("StoreError", (error$2) => error(`loom: could not install ${servicePackage(error$2.id)} — ${String(error$2.cause)}`).pipe(andThen(sync(() => void (process.exitCode = 1))))));
10382
10396
  var remove = (language) => gen(function* () {
10383
10397
  const config = yield* LoomConfig;
10384
10398
  const dir = process.cwd();
@@ -10423,7 +10437,10 @@ var set = (name, value) => gen(function* () {
10423
10437
  const corpus = resolve(workspace, current?.corpus ?? "corpus");
10424
10438
  yield* log(`loom: set ${name} = ${value} (re-tangled ${(yield* tangler.tangle(corpus)).length} files)`);
10425
10439
  }).pipe(catchTag("TangleError", (e) => error(e.message).pipe(andThen(sync(() => void (process.exitCode = 1))))));
10426
- var tangleCommand = make$5("tangle", { path: string("path") }, ({ path }) => tangle(path));
10440
+ var tangleCommand = make$5("tangle", {
10441
+ path: string("path"),
10442
+ watch: boolean("watch")
10443
+ }, ({ path, watch }) => tangle(path, watch));
10427
10444
  var orphansCommand = make$5("orphans", { prune: boolean("prune") }, ({ prune }) => orphans(prune));
10428
10445
  var weaveCommand = make$5("weave", {
10429
10446
  path: string("path"),
@@ -10448,11 +10465,11 @@ var program = run(make$5("loom").pipe(withSubcommands([
10448
10465
  removeCommand,
10449
10466
  statusCommand,
10450
10467
  setCommand
10451
- ])), { version: "0.0.4" }).pipe(provide$1(LoomTangler.layer), provide$1(LoomWeaver.layer), provide$1(LoomContents.layer), provide$1(DocumentSource.layer), provide$1(PackageConfig.layer), provide$1(LoomConfig.layer), provide$1(layer));
10468
+ ])), { version: "0.0.6" }).pipe(provide$1(LoomTangler.layer), provide$1(LoomWeaver.layer), provide$1(LoomContents.layer), provide$1(DocumentSource.layer), provide$1(PackageConfig.layer), provide$1(LoomConfig.layer), provide$1(layer));
10452
10469
  if (process.argv[2] === "lsp") {
10453
10470
  const { createRequire } = await import("node:module");
10454
10471
  globalThis.require = createRequire(import.meta.url);
10455
- const { startLanguageServer } = await import("./LoomServer-D8I04Chj.js");
10472
+ const { startLanguageServer } = await import("./LoomServer-ew_Ofzfo.js");
10456
10473
  startLanguageServer();
10457
10474
  } else runMain(program);
10458
10475
  //#endregion