@athrio/loom 0.0.4 → 0.0.5
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/{LoomServer-D8I04Chj.js → LoomServer-DdMrIE4N.js} +2 -2
- package/dist/{LoomServer-D8I04Chj.js.map → LoomServer-DdMrIE4N.js.map} +1 -1
- package/dist/{LoomStore-DMf2PkfP.js → LoomStore-CxUQqaPK.js} +910 -1708
- package/dist/LoomStore-CxUQqaPK.js.map +1 -0
- package/dist/main.js +72 -39
- package/dist/main.js.map +1 -1
- package/package.json +3 -3
- package/dist/LoomStore-DMf2PkfP.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { t as __commonJSMin } from "./rolldown-runtime-yvBN9yY6.js";
|
|
3
|
-
import { $ as
|
|
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-CxUQqaPK.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$
|
|
8528
|
+
var showHelp = (command, error$3) => gen(function* () {
|
|
8529
8529
|
const formatter = yield* Formatter;
|
|
8530
|
-
const helpDoc = yield* getHelpForCommandPath(command, error$
|
|
8530
|
+
const helpDoc = yield* getHelpForCommandPath(command, error$3.commandPath, BuiltIns);
|
|
8531
8531
|
yield* log(formatter.formatHelpDoc(helpDoc));
|
|
8532
|
-
if (error$
|
|
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)
|
|
9244
|
-
|
|
9245
|
-
|
|
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 ?
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
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 (
|
|
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,
|
|
@@ -10214,17 +10234,13 @@ var pruned = (produced) => ({
|
|
|
10214
10234
|
});
|
|
10215
10235
|
//#endregion
|
|
10216
10236
|
//#region ../loom-lang/src/LoomTangler.ts
|
|
10217
|
-
var
|
|
10218
|
-
"node_modules",
|
|
10219
|
-
".loom",
|
|
10220
|
-
"dist",
|
|
10221
|
-
".git"
|
|
10222
|
-
]);
|
|
10223
|
-
var isStorePath = (name) => name.split("/").some((segment) => ignoredSegment.has(segment));
|
|
10237
|
+
var isStorePath = (name) => name.split("/").some((segment) => ignoredDirs.has(segment));
|
|
10224
10238
|
var LoomTangler = class extends Service()("LoomTangler", { make: gen(function* () {
|
|
10225
10239
|
const compiler = yield* LoomCompiler;
|
|
10226
10240
|
const fs = yield* FileSystem;
|
|
10227
|
-
const
|
|
10241
|
+
const config = yield* PackageConfig;
|
|
10242
|
+
const matchesDisk = (file) => fs.readFileString(file.path).pipe(option, map$2(contains(file.content)));
|
|
10243
|
+
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
10244
|
const tangleFile = (entry) => compiler.tangle(entry).pipe(flatMap((files) => forEach(files, writeFile)));
|
|
10229
10245
|
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
10246
|
const loomsOf = (path) => fs.stat(path).pipe(orDie, flatMap((info) => info.type === "Directory" ? loomsUnder(path) : succeed([path])));
|
|
@@ -10255,10 +10271,16 @@ var LoomTangler = class extends Service()("LoomTangler", { make: gen(function* (
|
|
|
10255
10271
|
yield* writeLock(root, pruned(produced));
|
|
10256
10272
|
return map$3(orphans, (rel) => resolve(root, rel));
|
|
10257
10273
|
});
|
|
10274
|
+
const batchWindow = "50 millis";
|
|
10275
|
+
const batchLimit = 1e3;
|
|
10276
|
+
const isLoomEvent = (event) => event.path.endsWith(".loom") && !isStorePath(event.path);
|
|
10277
|
+
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))))));
|
|
10278
|
+
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
10279
|
return {
|
|
10259
10280
|
tangle,
|
|
10260
10281
|
orphans,
|
|
10261
|
-
prune
|
|
10282
|
+
prune,
|
|
10283
|
+
watch
|
|
10262
10284
|
};
|
|
10263
10285
|
}) }) {
|
|
10264
10286
|
static {
|
|
@@ -10302,11 +10324,19 @@ var banner = log(`\n${teal([
|
|
|
10302
10324
|
" ███████╗╚██████╔╝╚██████╔╝██║ ╚═╝ ██║",
|
|
10303
10325
|
" ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝"
|
|
10304
10326
|
].join("\n"))}\n ${dim("a literate framework")}\n`);
|
|
10305
|
-
var
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
else yield* forEach(written, (f) => log(`loom: tangled ${f.section} → ${f.path}`));
|
|
10327
|
+
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 });
|
|
10328
|
+
var tangleOnce = (file) => gen(function* () {
|
|
10329
|
+
yield* reportWritten(yield* (yield* LoomTangler).tangle(resolve(process.cwd(), file)));
|
|
10309
10330
|
}).pipe(catchTag("TangleError", (e) => error(e.message).pipe(andThen(sync(() => void (process.exitCode = 1))))));
|
|
10331
|
+
var tangleWatch = (file) => gen(function* () {
|
|
10332
|
+
const tangler = yield* LoomTangler;
|
|
10333
|
+
yield* log(`loom: watching ${file} — re-tangling on change`);
|
|
10334
|
+
yield* runForEach(tangler.watch(resolve(process.cwd(), file)), match$3({
|
|
10335
|
+
onSuccess: reportWritten,
|
|
10336
|
+
onFailure: (error$1) => error(error$1.message)
|
|
10337
|
+
}));
|
|
10338
|
+
});
|
|
10339
|
+
var tangle = (file, watch) => watch ? tangleWatch(file) : tangleOnce(file);
|
|
10310
10340
|
var orphans = (prune) => gen(function* () {
|
|
10311
10341
|
const tangler = yield* LoomTangler;
|
|
10312
10342
|
if (prune) {
|
|
@@ -10378,7 +10408,7 @@ var add = (language) => gen(function* () {
|
|
|
10378
10408
|
yield* addService(language, dir);
|
|
10379
10409
|
yield* updateLanguages(config, dir, (ids) => [.../* @__PURE__ */ new Set([...ids, language])]);
|
|
10380
10410
|
yield* log(`\n ${teal("✓")} activated ${language}\n ${dim(`store: ${storeDir(dir)}`)}\n`);
|
|
10381
|
-
}).pipe(catchTag("StoreError", (error$
|
|
10411
|
+
}).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
10412
|
var remove = (language) => gen(function* () {
|
|
10383
10413
|
const config = yield* LoomConfig;
|
|
10384
10414
|
const dir = process.cwd();
|
|
@@ -10423,7 +10453,10 @@ var set = (name, value) => gen(function* () {
|
|
|
10423
10453
|
const corpus = resolve(workspace, current?.corpus ?? "corpus");
|
|
10424
10454
|
yield* log(`loom: set ${name} = ${value} (re-tangled ${(yield* tangler.tangle(corpus)).length} files)`);
|
|
10425
10455
|
}).pipe(catchTag("TangleError", (e) => error(e.message).pipe(andThen(sync(() => void (process.exitCode = 1))))));
|
|
10426
|
-
var tangleCommand = make$5("tangle", {
|
|
10456
|
+
var tangleCommand = make$5("tangle", {
|
|
10457
|
+
path: string("path"),
|
|
10458
|
+
watch: boolean("watch")
|
|
10459
|
+
}, ({ path, watch }) => tangle(path, watch));
|
|
10427
10460
|
var orphansCommand = make$5("orphans", { prune: boolean("prune") }, ({ prune }) => orphans(prune));
|
|
10428
10461
|
var weaveCommand = make$5("weave", {
|
|
10429
10462
|
path: string("path"),
|
|
@@ -10448,11 +10481,11 @@ var program = run(make$5("loom").pipe(withSubcommands([
|
|
|
10448
10481
|
removeCommand,
|
|
10449
10482
|
statusCommand,
|
|
10450
10483
|
setCommand
|
|
10451
|
-
])), { version: "0.0.
|
|
10484
|
+
])), { version: "0.0.5" }).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
10485
|
if (process.argv[2] === "lsp") {
|
|
10453
10486
|
const { createRequire } = await import("node:module");
|
|
10454
10487
|
globalThis.require = createRequire(import.meta.url);
|
|
10455
|
-
const { startLanguageServer } = await import("./LoomServer-
|
|
10488
|
+
const { startLanguageServer } = await import("./LoomServer-DdMrIE4N.js");
|
|
10456
10489
|
startLanguageServer();
|
|
10457
10490
|
} else runMain(program);
|
|
10458
10491
|
//#endregion
|