@athrio/loom 0.0.9 → 0.0.11
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/LICENSE +21 -0
- package/dist/{LoomServer-BZL6KQOM.js → LoomServer-mL8VcuCS.js} +2 -2
- package/dist/{LoomServer-BZL6KQOM.js.map → LoomServer-mL8VcuCS.js.map} +1 -1
- package/dist/{LoomStore-BBRhdzet.js → LoomStore-DTpgIJ9l.js} +7 -4
- package/dist/{LoomStore-BBRhdzet.js.map → LoomStore-DTpgIJ9l.js.map} +1 -1
- package/dist/main.js +185 -6
- package/dist/main.js.map +1 -1
- package/package.json +3 -2
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as __commonJSMin } from "./rolldown-runtime-YU9U6SYh.js";
|
|
3
|
-
import { $ as mkString, $n as
|
|
3
|
+
import { $ as mkString, $n as UnknownError, $t as effectify, A as log, Ar as map$4, At as fromTransform, B as WatchBackend, Bn as mergeAll, Br as isNullish, Bt as nominal, C as errorExitCode, Cn as result, Cr as flatMap$1, Ct as decodeUnknownEffect, D as Crypto$1, Dn as succeed, Dr as getOrUndefined, Dt as toCodecStringTree, En as serviceOption, Er as getOrElse, Et as tag, F as TypeId$5, Fn as void_, Fr as BaseProto, Ft as offer, G as empty$1, Gn as MinimumLogLevel, Gr as pipeArguments, Gt as asVoid, H as callback$1, Hn as provideMerge, Hr as dual, Ht as addFinalizer$1, I as FileDescriptor, In as catchDone, Ir as format, It as offerUnsafe, J as fromEffect, Jn as isDone, Jt as catchFilter, K as filter$1, Kn as _await, Kt as callback, L as FileSystem, Ln as TaggedError, Lr as hasProperty, Lt as take, M as FalseValues, Mn as tryPromise, Mr as none, Mt as endUnsafe, N as TrueValues, Nn as try_, Nr as some, Nt as failCauseUnsafe, O as make$9, On as suspend, Or as isNone, P as Path$1, Pn as uninterruptible, Pr as String$2, Pt as make$12, Q as merge, Qn as Done, R as FileTypeId, Rn as taggedEnum, Rr as isNotNull, Rt as make$7, S as make$10, Sn as raceFirst, Sr as contains, St as Union, T as makeRunMain, Tn as scoped, Tr as fromUndefinedOr, Tt as optional$3, U as concat, Un as succeed$3, Ur as identity, Ut as andThen, V as make$8, Vn as provide, Vr as isUndefined, Vt as acquireRelease, W as decodeText, Wn as addFinalizer, Wr as pipe, Wt as as, X as isStream, Xn as fail$2, Xt as catchTags, Y as groupedWithin, Yn as makeUnsafe$1, Yt as catchTag, Z as mapEffect$1, Zn as succeed$2, Zt as catch_, _ as QuitError, _n as orDie, _r as reduce, _t as ErrorClass, a as storeDir, an as forever, ar as empty, at as transduce, b as make$13, bn as provideContext, br as match$3, bt as String$1, c as LoomCompiler, cn as ignore, cr as Prototype, ct as make$11, dt as isSink, en as ensuring, er as done, et as orDie$1, f as PackageConfig, fn as map$2, ft as BadArgument, gn as option, gr as of, gt as Defect, hn as matchEffect, hr as match, ht as ArraySchema, i as servicePackage, in as forEach, ir as Service, it as splitLines, j as Boolean, jn as timeoutOrElse, jr as match$2, jt as mapDone, k as error, kn as sync, kr as isSome, l as ignoredDirs, ln as interrupt, lr as dedupe, lt as drain, mn as match$1, mr as map$3, mt as systemError, n as installedServices, nn as flatMap, nr as pretty, nt as runCollect, o as workspaceRoot, on as forkScoped, or as getUnsafe, ot as unwrap, p as LoomConfig, pn as mapError, pt as badArgument, q as fromChannel$1, qn as doneUnsafe, qt as catchCause, r as removeService, rn as fnUntraced, rr as Reference, rt as runForEach, s as DocumentSource, sn as gen, sr as make$6, st as get, t as addService, tn as fail, tr as fail$3, tt as run$2, un as isEffect, ur as filter, ut as fromChannel, v as Terminal, vn as orElseSucceed, vr as sort, vt as Int, w as errorReported, wn as runFork, wr as fromNullishOr, wt as is, x as Stdio, xn as provideService, xr as succeed$1, xt as Struct, y as isQuitError, yn as provide$1, yr as fail$1, yt as Literal, z as Size, zn as effect, zr as isNotUndefined, zt as makeUnsafe } from "./LoomStore-DTpgIJ9l.js";
|
|
4
4
|
import * as NodeChildProcess from "node:child_process";
|
|
5
5
|
import { PassThrough } from "node:stream";
|
|
6
6
|
import * as Crypto from "node:crypto";
|
|
@@ -11,6 +11,7 @@ import * as Path from "node:path";
|
|
|
11
11
|
import { dirname, relative, resolve } from "node:path";
|
|
12
12
|
import * as NodeUrl from "node:url";
|
|
13
13
|
import * as readline from "node:readline";
|
|
14
|
+
import { createRequire } from "node:module";
|
|
14
15
|
//#region ../../node_modules/effect/dist/unstable/cli/CliError.js
|
|
15
16
|
/**
|
|
16
17
|
* Defines structured errors for the unstable CLI parser and runner.
|
|
@@ -4873,6 +4874,31 @@ var makeSchemaPrimitive = (tag, schema) => {
|
|
|
4873
4874
|
*/
|
|
4874
4875
|
var boolean$2 = /*#__PURE__*/ makeSchemaPrimitive("Boolean", Boolean);
|
|
4875
4876
|
/**
|
|
4877
|
+
* Creates a primitive that parses integer numbers from string input.
|
|
4878
|
+
*
|
|
4879
|
+
* **Example** (Parsing integer values)
|
|
4880
|
+
*
|
|
4881
|
+
* ```ts
|
|
4882
|
+
* import { Effect } from "effect"
|
|
4883
|
+
* import { Primitive } from "effect/unstable/cli"
|
|
4884
|
+
*
|
|
4885
|
+
* const parseInteger = Effect.gen(function*() {
|
|
4886
|
+
* const result1 = yield* Primitive.integer.parse("42")
|
|
4887
|
+
* console.log(result1) // 42
|
|
4888
|
+
*
|
|
4889
|
+
* const result2 = yield* Primitive.integer.parse("-123")
|
|
4890
|
+
* console.log(result2) // -123
|
|
4891
|
+
*
|
|
4892
|
+
* const result3 = yield* Primitive.integer.parse("0")
|
|
4893
|
+
* console.log(result3) // 0
|
|
4894
|
+
* })
|
|
4895
|
+
* ```
|
|
4896
|
+
*
|
|
4897
|
+
* @category constructors
|
|
4898
|
+
* @since 4.0.0
|
|
4899
|
+
*/
|
|
4900
|
+
var integer$2 = /*#__PURE__*/ makeSchemaPrimitive("Integer", Int);
|
|
4901
|
+
/**
|
|
4876
4902
|
* Creates a primitive that accepts any string value without validation.
|
|
4877
4903
|
*
|
|
4878
4904
|
* **Example** (Parsing string values)
|
|
@@ -5609,6 +5635,31 @@ var boolean$1 = (kind, name) => makeSingle({
|
|
|
5609
5635
|
kind
|
|
5610
5636
|
});
|
|
5611
5637
|
/**
|
|
5638
|
+
* Creates an integer parameter.
|
|
5639
|
+
*
|
|
5640
|
+
* **Example** (Creating integer parameters)
|
|
5641
|
+
*
|
|
5642
|
+
* ```ts
|
|
5643
|
+
* import { Param } from "effect/unstable/cli"
|
|
5644
|
+
*
|
|
5645
|
+
* // Create an integer flag
|
|
5646
|
+
* const portFlag = Param.integer(Param.flagKind, "port")
|
|
5647
|
+
*
|
|
5648
|
+
* // Create an integer argument
|
|
5649
|
+
* const countArg = Param.integer(Param.argumentKind, "count")
|
|
5650
|
+
*
|
|
5651
|
+
* // Usage in CLI: --port 8080 or as positional argument: 42
|
|
5652
|
+
* ```
|
|
5653
|
+
*
|
|
5654
|
+
* @category constructors
|
|
5655
|
+
* @since 4.0.0
|
|
5656
|
+
*/
|
|
5657
|
+
var integer$1 = (kind, name) => makeSingle({
|
|
5658
|
+
name,
|
|
5659
|
+
primitiveType: integer$2,
|
|
5660
|
+
kind
|
|
5661
|
+
});
|
|
5662
|
+
/**
|
|
5612
5663
|
* Constructs command-line params that represent a choice between several
|
|
5613
5664
|
* inputs. The input will be mapped to it's associated value during parsing.
|
|
5614
5665
|
*
|
|
@@ -5827,6 +5878,35 @@ var transform = (self, f) => Object.assign(Object.create(Proto$2), {
|
|
|
5827
5878
|
parse: f(self.parse)
|
|
5828
5879
|
});
|
|
5829
5880
|
/**
|
|
5881
|
+
* Transforms the parsed value of an option using an effectful mapping function.
|
|
5882
|
+
*
|
|
5883
|
+
* **Example** (Mapping parsed values effectfully)
|
|
5884
|
+
*
|
|
5885
|
+
* ```ts
|
|
5886
|
+
* import { Effect } from "effect"
|
|
5887
|
+
* import { CliError, Param } from "effect/unstable/cli"
|
|
5888
|
+
*
|
|
5889
|
+
* const validatedEmail = Param.string(Param.flagKind, "email").pipe(
|
|
5890
|
+
* Param.mapEffect((email) =>
|
|
5891
|
+
* email.includes("@")
|
|
5892
|
+
* ? Effect.succeed(email)
|
|
5893
|
+
* : Effect.fail(
|
|
5894
|
+
* new CliError.InvalidValue({
|
|
5895
|
+
* option: "email",
|
|
5896
|
+
* value: email,
|
|
5897
|
+
* expected: "valid email format",
|
|
5898
|
+
* kind: "flag"
|
|
5899
|
+
* })
|
|
5900
|
+
* )
|
|
5901
|
+
* )
|
|
5902
|
+
* )
|
|
5903
|
+
* ```
|
|
5904
|
+
*
|
|
5905
|
+
* @category combinators
|
|
5906
|
+
* @since 4.0.0
|
|
5907
|
+
*/
|
|
5908
|
+
var mapEffect = /*#__PURE__*/ dual(2, (self, f) => transform(self, (parse) => (args) => flatMap(parse(args), ([leftover, a]) => f(a).pipe(map$2((b) => [leftover, b])))));
|
|
5909
|
+
/**
|
|
5830
5910
|
* Makes a flag or positional argument optional.
|
|
5831
5911
|
*
|
|
5832
5912
|
* **Details**
|
|
@@ -5866,6 +5946,42 @@ var optional$2 = (param) => {
|
|
|
5866
5946
|
});
|
|
5867
5947
|
};
|
|
5868
5948
|
/**
|
|
5949
|
+
* Makes a flag or positional argument optional by supplying a fallback value.
|
|
5950
|
+
*
|
|
5951
|
+
* **Details**
|
|
5952
|
+
*
|
|
5953
|
+
* The fallback may be a pure value or an effect. It is used only when the
|
|
5954
|
+
* parameter is absent; provided values are parsed normally.
|
|
5955
|
+
*
|
|
5956
|
+
* **Example** (Providing default values)
|
|
5957
|
+
*
|
|
5958
|
+
* ```ts
|
|
5959
|
+
* import { Param } from "effect/unstable/cli"
|
|
5960
|
+
*
|
|
5961
|
+
* // Using the pipe operator to make an option optional
|
|
5962
|
+
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
5963
|
+
* Param.withDefault(8080)
|
|
5964
|
+
* )
|
|
5965
|
+
*
|
|
5966
|
+
* // Can also be used with other combinators
|
|
5967
|
+
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
5968
|
+
* Param.withAlias("-v"),
|
|
5969
|
+
* Param.withDescription("Enable verbose output"),
|
|
5970
|
+
* Param.withDefault(false)
|
|
5971
|
+
* )
|
|
5972
|
+
* ```
|
|
5973
|
+
*
|
|
5974
|
+
* @category combinators
|
|
5975
|
+
* @since 4.0.0
|
|
5976
|
+
*/
|
|
5977
|
+
var withDefault$1 = /*#__PURE__*/ dual(2, (self, defaultValue) => {
|
|
5978
|
+
if (!isEffect(defaultValue)) return map$1(optional$2(self), getOrElse(() => defaultValue));
|
|
5979
|
+
return mapEffect(optional$2(self), match$2({
|
|
5980
|
+
onNone: () => defaultValue,
|
|
5981
|
+
onSome: succeed
|
|
5982
|
+
}));
|
|
5983
|
+
});
|
|
5984
|
+
/**
|
|
5869
5985
|
* Creates a variadic parameter that can be specified multiple times.
|
|
5870
5986
|
*
|
|
5871
5987
|
* **Details**
|
|
@@ -6879,6 +6995,22 @@ var generate = (executableName, shell, descriptor) => {
|
|
|
6879
6995
|
*/
|
|
6880
6996
|
var boolean = (name) => boolean$1(flagKind, name);
|
|
6881
6997
|
/**
|
|
6998
|
+
* Creates an integer flag that accepts whole number input.
|
|
6999
|
+
*
|
|
7000
|
+
* **Example** (Creating integer flags)
|
|
7001
|
+
*
|
|
7002
|
+
* ```ts
|
|
7003
|
+
* import { Flag } from "effect/unstable/cli"
|
|
7004
|
+
*
|
|
7005
|
+
* const portFlag = Flag.integer("port")
|
|
7006
|
+
* // Usage: --port 8080
|
|
7007
|
+
* ```
|
|
7008
|
+
*
|
|
7009
|
+
* @category constructors
|
|
7010
|
+
* @since 4.0.0
|
|
7011
|
+
*/
|
|
7012
|
+
var integer = (name) => integer$1(flagKind, name);
|
|
7013
|
+
/**
|
|
6882
7014
|
* Constructs option parameters that represent a choice between several inputs.
|
|
6883
7015
|
* Each tuple maps a string flag value to an associated typed value.
|
|
6884
7016
|
*
|
|
@@ -7024,6 +7156,29 @@ var withMetavar = /*#__PURE__*/ dual(2, (self, metavar) => withMetavar$1(self, m
|
|
|
7024
7156
|
*/
|
|
7025
7157
|
var optional = (param) => optional$2(param);
|
|
7026
7158
|
/**
|
|
7159
|
+
* Provides a default value for a flag when it's not specified.
|
|
7160
|
+
*
|
|
7161
|
+
* **Example** (Providing default values)
|
|
7162
|
+
*
|
|
7163
|
+
* ```ts
|
|
7164
|
+
* import { Flag } from "effect/unstable/cli"
|
|
7165
|
+
*
|
|
7166
|
+
* const portFlag = Flag.integer("port").pipe(
|
|
7167
|
+
* Flag.withDefault(8080)
|
|
7168
|
+
* )
|
|
7169
|
+
* // If --port is not provided, defaults to 8080
|
|
7170
|
+
*
|
|
7171
|
+
* const hostFlag = Flag.string("host").pipe(
|
|
7172
|
+
* Flag.withDefault("localhost")
|
|
7173
|
+
* )
|
|
7174
|
+
* // If --host is not provided, defaults to "localhost"
|
|
7175
|
+
* ```
|
|
7176
|
+
*
|
|
7177
|
+
* @category optionality
|
|
7178
|
+
* @since 4.0.0
|
|
7179
|
+
*/
|
|
7180
|
+
var withDefault = withDefault$1;
|
|
7181
|
+
/**
|
|
7027
7182
|
* Transforms the parsed value of a flag using a mapping function.
|
|
7028
7183
|
*
|
|
7029
7184
|
* **Example** (Mapping parsed values)
|
|
@@ -10259,7 +10414,7 @@ var LoomTangler = class extends Service()("LoomTangler", { make: gen(function* (
|
|
|
10259
10414
|
const batchLimit = 1e3;
|
|
10260
10415
|
const isLoomEvent = (event) => event.path.endsWith(".loom") && !isStorePath(event.path);
|
|
10261
10416
|
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)))));
|
|
10417
|
+
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$1((events) => forEach(dedupe(map$3(events, (event) => resolve(root, event.path))), (changed) => compiler.invalidate(changed), { discard: true }).pipe(andThen(result(tangle(path))))), orDie$1)))));
|
|
10263
10418
|
return {
|
|
10264
10419
|
tangle,
|
|
10265
10420
|
orphans,
|
|
@@ -10437,6 +10592,25 @@ var set = (name, value) => gen(function* () {
|
|
|
10437
10592
|
const corpus = resolve(workspace, current?.corpus ?? "corpus");
|
|
10438
10593
|
yield* log(`loom: set ${name} = ${value} (re-tangled ${(yield* tangler.tangle(corpus)).length} files)`);
|
|
10439
10594
|
}).pipe(catchTag("TangleError", (e) => error(e.message).pipe(andThen(sync(() => void (process.exitCode = 1))))));
|
|
10595
|
+
var DesignMissing = class extends TaggedError("DesignMissing") {};
|
|
10596
|
+
var manifestOf = (base) => try_(() => createRequire(base).resolve("@athrio/loom-design/package.json"));
|
|
10597
|
+
var designBinary = gen(function* () {
|
|
10598
|
+
const directory = process.cwd();
|
|
10599
|
+
return resolve(dirname(yield* manifestOf(resolve(directory, "index.js")).pipe(catch_(() => manifestOf(import.meta.url)), mapError(() => new DesignMissing({ directory })))), "dist", "loom-design.js");
|
|
10600
|
+
});
|
|
10601
|
+
var design = (project, application, port) => gen(function* () {
|
|
10602
|
+
const code = yield* scoped(flatMap(make$3(yield* designBinary, [
|
|
10603
|
+
project,
|
|
10604
|
+
application,
|
|
10605
|
+
"--port",
|
|
10606
|
+
String(port)
|
|
10607
|
+
], {
|
|
10608
|
+
stdin: "inherit",
|
|
10609
|
+
stdout: "inherit",
|
|
10610
|
+
stderr: "inherit"
|
|
10611
|
+
}), (running) => running.exitCode));
|
|
10612
|
+
yield* sync(() => void (process.exitCode = code));
|
|
10613
|
+
}).pipe(catchTag("DesignMissing", () => error("loom: Loom Design is not installed.\n Add it with `bun add -d @athrio/loom-design`, then run this again.").pipe(andThen(sync(() => void (process.exitCode = 1))))), catchCause((cause) => error(`loom: Loom Design could not start\n${pretty(cause)}`).pipe(andThen(sync(() => void (process.exitCode = 1))))));
|
|
10440
10614
|
var tangleCommand = make$5("tangle", {
|
|
10441
10615
|
path: string("path"),
|
|
10442
10616
|
watch: boolean("watch")
|
|
@@ -10455,6 +10629,11 @@ var setCommand = make$5("set", {
|
|
|
10455
10629
|
name: string("name"),
|
|
10456
10630
|
value: string("value")
|
|
10457
10631
|
}, ({ name, value }) => set(name, value));
|
|
10632
|
+
var designCommand = make$5("design", {
|
|
10633
|
+
project: string("name"),
|
|
10634
|
+
application: string("address"),
|
|
10635
|
+
port: integer("port").pipe(withDefault(5710))
|
|
10636
|
+
}, ({ project, application, port }) => design(project, application, port));
|
|
10458
10637
|
var program = run(make$5("loom").pipe(withSubcommands([
|
|
10459
10638
|
tangleCommand,
|
|
10460
10639
|
orphansCommand,
|
|
@@ -10464,12 +10643,12 @@ var program = run(make$5("loom").pipe(withSubcommands([
|
|
|
10464
10643
|
addCommand,
|
|
10465
10644
|
removeCommand,
|
|
10466
10645
|
statusCommand,
|
|
10467
|
-
setCommand
|
|
10468
|
-
|
|
10646
|
+
setCommand,
|
|
10647
|
+
designCommand
|
|
10648
|
+
])), { version: "0.0.11" }).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));
|
|
10469
10649
|
if (process.argv[2] === "lsp") {
|
|
10470
|
-
const { createRequire } = await import("node:module");
|
|
10471
10650
|
globalThis.require = createRequire(import.meta.url);
|
|
10472
|
-
const { startLanguageServer } = await import("./LoomServer-
|
|
10651
|
+
const { startLanguageServer } = await import("./LoomServer-mL8VcuCS.js");
|
|
10473
10652
|
startLanguageServer();
|
|
10474
10653
|
} else runMain(program);
|
|
10475
10654
|
//#endregion
|