@athrio/loom 0.0.7 → 0.0.8

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.
@@ -149147,13 +149147,15 @@ var VariablesSchema = Record$1(String$1, Union([
149147
149147
  Number$1,
149148
149148
  Boolean$2
149149
149149
  ]));
149150
+ var HeaderSchema = Struct({ ascii: optional(Boolean$2) });
149150
149151
  var WorkspaceManifestSchema = Struct({
149151
149152
  languages: optional(Record$1(String$1, LanguageSchema)),
149152
149153
  corpus: optional(String$1),
149153
149154
  primary: optional(String$1),
149154
149155
  anchor: optional(AnchorSchema),
149155
149156
  settings: optional(SettingsSchema),
149156
- variables: optional(VariablesSchema)
149157
+ variables: optional(VariablesSchema),
149158
+ header: optional(HeaderSchema)
149157
149159
  });
149158
149160
  var empty = {
149159
149161
  anchor: void 0,
@@ -149161,6 +149163,7 @@ var empty = {
149161
149163
  languages: [],
149162
149164
  settings: {},
149163
149165
  variables: {},
149166
+ header: void 0,
149164
149167
  services: {},
149165
149168
  packageRoot: void 0,
149166
149169
  workspaceRoot: void 0,
@@ -149206,6 +149209,7 @@ var resolveFromManifest = (manifest, workspace, fromPath) => {
149206
149209
  languages: Object.keys(manifest.languages ?? {}),
149207
149210
  settings: manifest.settings ?? {},
149208
149211
  variables: variablesOf(manifest.variables),
149212
+ header: manifest.header === void 0 ? void 0 : { ascii: manifest.header.ascii ?? false },
149209
149213
  services: servicesOf(manifest.languages),
149210
149214
  packageRoot: containerRoot(dirname(fromPath), container, workspace),
149211
149215
  workspaceRoot: workspace,
@@ -149246,6 +149250,7 @@ var PackageConfig = class extends Service$1()("PackageConfig", { make: gen$1(fun
149246
149250
  delims: anchorDelimsOf(c.anchor),
149247
149251
  primaryLanguage: c.primary,
149248
149252
  variables: c.variables,
149253
+ header: c.header,
149249
149254
  packageRoot: c.packageRoot,
149250
149255
  workspaceRoot: c.workspaceRoot,
149251
149256
  corpusDir: c.corpusDir
@@ -149627,12 +149632,12 @@ var outputPath = (packageRoot, entry, sink) => match$13(packageRoot, {
149627
149632
  onNone: () => resolve(dirname(entry), sink),
149628
149633
  onSome: (root) => resolve(root, sink)
149629
149634
  });
149630
- var resolveSinks = (modules, entry, packageRoot) => pipe(fromNullishOr$4(modules.get(entry)), match$13({
149635
+ var resolveSinks = (modules, entry, packageRoot, header) => pipe(fromNullishOr$4(modules.get(entry)), match$13({
149631
149636
  onNone: () => [],
149632
149637
  onSome: (module) => map$24(module.product.files, (file) => ({
149633
149638
  section: file.code.origin.name,
149634
149639
  path: outputPath(packageRoot, entry, file.path),
149635
- content: fromProduct(modules, file.code.origin).code
149640
+ content: stamped(header, file.code.languageId, basename(entry), fromProduct(modules, file.code.origin).code)
149636
149641
  }))
149637
149642
  }));
149638
149643
  var TangleError = class extends TaggedError("TangleError") {
@@ -149642,6 +149647,72 @@ var TangleError = class extends TaggedError("TangleError") {
149642
149647
  return `loom: refusing to tangle ${this.entry} — ${count} error(s) across the corpus:\n${lines.join("\n")}`;
149643
149648
  }
149644
149649
  };
149650
+ var cStyle = {
149651
+ kind: "block",
149652
+ open: "/*",
149653
+ mid: " * ",
149654
+ close: " */"
149655
+ };
149656
+ var markupStyle = {
149657
+ kind: "block",
149658
+ open: "<!--",
149659
+ mid: " ",
149660
+ close: "-->"
149661
+ };
149662
+ var hashStyle = {
149663
+ kind: "line",
149664
+ prefix: "# "
149665
+ };
149666
+ var commentStyles = /* @__PURE__ */ new Map([
149667
+ ["typescript", cStyle],
149668
+ ["tsx", cStyle],
149669
+ ["javascript", cStyle],
149670
+ ["jsx", cStyle],
149671
+ ["css", cStyle],
149672
+ ["scss", cStyle],
149673
+ ["less", cStyle],
149674
+ ["html", markupStyle],
149675
+ ["xml", markupStyle],
149676
+ ["vue", markupStyle],
149677
+ ["svelte", markupStyle],
149678
+ ["bash", hashStyle],
149679
+ ["sh", hashStyle],
149680
+ ["shell", hashStyle],
149681
+ ["yaml", hashStyle],
149682
+ ["yml", hashStyle],
149683
+ ["toml", hashStyle],
149684
+ ["python", hashStyle],
149685
+ ["ruby", hashStyle]
149686
+ ]);
149687
+ var loomLogo = [
149688
+ "L OOOO OOOO M M",
149689
+ "L O O O O MM MM",
149690
+ "L O O O O M M M",
149691
+ "LLLL OOOO OOOO M M"
149692
+ ];
149693
+ var bannerLines = (ascii, loom) => [
149694
+ ...ascii ? [...loomLogo, ""] : [],
149695
+ `Tangled by Loom from ${loom} — composed from that`,
149696
+ `loom's code sections. Edit the loom and re-tangle;`,
149697
+ `changes made here are overwritten.`
149698
+ ];
149699
+ var commentBlock = (style, lines) => value$1(style).pipe(when({ kind: "block" }, (s) => [
149700
+ s.open,
149701
+ ...map$24(lines, (text) => `${s.mid}${text}`.trimEnd()),
149702
+ s.close
149703
+ ].join("\n")), when({ kind: "line" }, (s) => map$24(lines, (text) => `${s.prefix}${text}`.trimEnd()).join("\n")), exhaustive);
149704
+ var belowShebang = (content, banner) => {
149705
+ const newline = content.indexOf("\n");
149706
+ const cut = content.startsWith("#!") && newline !== -1 ? newline + 1 : 0;
149707
+ return `${content.slice(0, cut)}${banner}\n\n${content.slice(cut)}`;
149708
+ };
149709
+ var stamped = (header, languageId, loom, content) => match$13(header, {
149710
+ onNone: () => content,
149711
+ onSome: ({ ascii }) => match$13(fromNullishOr$4(commentStyles.get(languageId)), {
149712
+ onNone: () => content,
149713
+ onSome: (style) => belowShebang(content, commentBlock(style, bannerLines(ascii, loom)))
149714
+ })
149715
+ });
149645
149716
  var lineCharAt = (text, offset) => {
149646
149717
  const before = text.slice(0, offset);
149647
149718
  return {
@@ -149764,7 +149835,7 @@ var LoomCompiler = class extends Service$1()("LoomCompiler", { make: gen$1(funct
149764
149835
  return failures.length > 0 ? fail$8(new TangleError({
149765
149836
  entry: path,
149766
149837
  failures
149767
- })) : config.resolve(path).pipe(map$19(({ packageRoot }) => resolveSinks(scoped, path, fromNullishOr$4(packageRoot))));
149838
+ })) : config.resolve(path).pipe(map$19(({ packageRoot, header }) => resolveSinks(scoped, path, fromNullishOr$4(packageRoot), fromNullishOr$4(header))));
149768
149839
  })),
149769
149840
  composition: (path) => buildCorpus(documents, path).pipe(flatMap$7((modules) => forEach$8(fromIterable$15(modules.values()), (module) => config.resolve(module.path).pipe(map$19(({ packageRoot }) => map$24(module.product.files, (file) => ({
149770
149841
  path: outputPath(fromNullishOr$4(packageRoot), module.path, file.path),
@@ -149861,4 +149932,4 @@ var removeService = (id, dir) => sync$3(() => rmSync(join(storeDir(dir), "node_m
149861
149932
  //#endregion
149862
149933
  export { mkString as $, done$2 as $n, ensuring$3 as $t, log as A, timeoutOrElse$1 as An, none$1 as Ar, mapDone as At, WatchBackend as B, provide$5 as Bn, dual as Br, acquireRelease$1 as Bt, errorExitCode as C, runFork as Cn, fromUndefinedOr as Cr, is$2 as Ct, Crypto as D, suspend$4 as Dn, isSome as Dr, fromIterable$10 as Dt, make$22 as E, succeed$6 as En, isNone as Er, toCodecStringTree as Et, TypeId$33 as F, catchDone as Fn, hasProperty as Fr, offerUnsafe as Ft, empty$9 as G, _await$1 as Gn, callback$2 as Gt, callback as H, succeed$8 as Hn, pipe as Hr, andThen as Ht, FileDescriptor as I, TaggedError as In, isNotNull as Ir, take$7 as It, fromEffect$1 as J, makeUnsafe$16 as Jn, catchTag$2 as Jt, filter$5 as K, doneUnsafe as Kn, catchCause$3 as Kt, FileSystem as L, taggedEnum as Ln, isNotUndefined as Lr, make$50 as Lt, FalseValues as M, try_ as Mn, String$5 as Mr, failCauseUnsafe as Mt, TrueValues as N, uninterruptible as Nn, BaseProto as Nr, make$48 as Nt, make$30 as O, sync$3 as On, map$29 as Or, get$21 as Ot, Path as P, void_$1 as Pn, format$5 as Pr, offer$2 as Pt, merge$1 as Q, UnknownError as Qn, effectify as Qt, FileTypeId as R, effect as Rn, isNullish as Rr, makeUnsafe$12 as Rt, make$13 as S, result$3 as Sn, fromNullishOr$4 as Sr, decodeUnknownEffect as St, makeRunMain as T, serviceOption$1 as Tn, getOrUndefined$2 as Tr, tag$2 as Tt, concat$2 as U, addFinalizer$1 as Un, pipeArguments as Ur, as$1 as Ut, make$33 as V, provideMerge as Vn, identity$1 as Vr, addFinalizer as Vt, decodeText as W, MinimumLogLevel as Wn, asVoid as Wt, isStream as X, succeed$10 as Xn, catch_$3 as Xt, groupedWithin as Y, fail$11 as Yn, catchTags$1 as Yt, mapEffect as Z, Done as Zn, die$3 as Zt, QuitError as _, orElseSucceed$1 as _n, fail$14 as _r, ErrorClass as _t, storeDir as a, forkScoped as an, make$69 as ar, transduce as at, make$11 as b, provideService$3 as bn, contains$3 as br, Struct as bt, LoomCompiler as c, interrupt$3 as cn, filter$15 as cr, make$35 as ct, stringSnapshot as d, map$19 as dn, groupBy$1 as dr, isSink as dt, fail$8 as en, fail$12 as er, orDie as et, PackageConfig as f, mapError$3 as fn, map$24 as fr, BadArgument as ft, dist_exports as g, orDie$2 as gn, sort$1 as gr, Defect as gt, ReadError as h, option$4 as hn, reduce$10 as hr, ArraySchema as ht, servicePackage as i, forever$2 as in, getUnsafe$11 as ir, splitLines$1 as it, Boolean$1 as j, tryPromise as jn, some$13 as jr, endUnsafe as jt, error$1 as k, tap$2 as kn, match$13 as kr, fromTransform$1 as kt, ignoredDirs as l, isEffect as ln, fromIterable$15 as lr, drain$1 as lt, SemanticTokenSchema as m, matchEffect as mn, of$2 as mr, systemError as mt, installedServices as n, fnUntraced as nn, Service$1 as nr, runCollect as nt, workspaceRoot as o, gen$1 as on, Prototype as or, unwrap$1 as ot, LoomConfig as p, match$3 as pn, match$11 as pr, badArgument as pt, fromChannel as q, isDone$1 as qn, catchFilter$2 as qt, removeService as r, forEach$8 as rn, empty$20 as rr, runForEach as rt, DocumentSource as s, ignore$3 as sn, dedupe$1 as sr, get$16 as st, addService as t, flatMap$7 as tn, Reference as tr, run$4 as tt, loomsUnder as u, logWarning as un, getSomes as ur, fromChannel$1 as ut, Terminal as v, provide$3 as vn, match$12 as vr, Literal as vt, errorReported as w, scoped$2 as wn, getOrElse$2 as wr, optional as wt, Stdio as x, raceFirst as xn, flatMap$13 as xr, Union as xt, isQuitError as y, provideContext$3 as yn, succeed$12 as yr, String$1 as yt, Size as z, mergeAll$2 as zn, isUndefined$1 as zr, nominal as zt };
149863
149934
 
149864
- //# sourceMappingURL=LoomStore-BBRhdzet.js.map
149935
+ //# sourceMappingURL=LoomStore-C2tWuEsJ.js.map