@athrio/loom 0.0.12 → 0.0.13
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/LanguageLoader-DJGDopcP.js +3 -0
- package/dist/{LanguageLoader-BzlRnQhO.js → LanguageLoader-kZ-5Qbwr.js} +19 -11
- package/dist/{LanguageLoader-BzlRnQhO.js.map → LanguageLoader-kZ-5Qbwr.js.map} +1 -1
- package/dist/{LanguageService-BTCvgdWm.js → LanguageService-CcElIYBZ.js} +2 -2
- package/dist/{LanguageService-BTCvgdWm.js.map → LanguageService-CcElIYBZ.js.map} +1 -1
- package/dist/{LoomFormatter-Bu8L8cdR.js → LoomFormatter-D6wh-SLN.js} +11 -3
- package/dist/{LoomFormatter-Bu8L8cdR.js.map → LoomFormatter-D6wh-SLN.js.map} +1 -1
- package/dist/{LoomServer-DXIree_1.js → LoomServer-C54yIIo1.js} +28 -12
- package/dist/{LoomServer-DXIree_1.js.map → LoomServer-C54yIIo1.js.map} +1 -1
- package/dist/{LoomStore-pA-ohGNX.js → LoomStore-axDgE8RF.js} +103 -21
- package/dist/LoomStore-axDgE8RF.js.map +1 -0
- package/dist/{Runtime-XT-nb-2w.js → Runtime-Cj1Rsxs1.js} +1 -1
- package/dist/{Runtime-Byw6clui.js → Runtime-D4WijrpR.js} +3 -3
- package/dist/{Runtime-Byw6clui.js.map → Runtime-D4WijrpR.js.map} +1 -1
- package/dist/_virtual_tree-sitter-loom-CFLf84Ng.js +15 -0
- package/dist/{dist-D3YSXNOO.js → dist-LBqwqmSY.js} +2 -2
- package/dist/{dist-D3YSXNOO.js.map → dist-LBqwqmSY.js.map} +1 -1
- package/dist/main.js +224 -49
- package/dist/main.js.map +1 -1
- package/package.json +3 -1
- package/dist/LanguageLoader-DJZBFaqF.js +0 -3
- package/dist/LoomStore-pA-ohGNX.js.map +0 -1
- package/dist/tree-sitter-loom/editors/helix/queries/loom/highlights.scm +0 -120
- package/dist/tree-sitter-loom/editors/helix/queries/loom/injections.scm +0 -413
- package/dist/tree-sitter-loom/queries/highlights.scm +0 -120
- package/dist/tree-sitter-loom/queries/injections.scm +0 -85
- package/dist/tree-sitter-loom/src/parser.c +0 -4689
- package/dist/tree-sitter-loom/src/scanner.c +0 -293
- package/dist/tree-sitter-loom/src/tree_sitter/alloc.h +0 -54
- package/dist/tree-sitter-loom/src/tree_sitter/array.h +0 -330
- package/dist/tree-sitter-loom/src/tree_sitter/parser.h +0 -286
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { An as forEach, Bt as Struct, Fi as flatMap$1, Gi as liftThrowable, Gr as findFirst, Gt as Unknown, Hn as mapError, Ji as none, Ki as map$1, Kt as decodeUnknownEffect, Li as fromNullishOr, Mi as contains, Nr as TaggedError, On as flatMap$2, Pn as gen, Pr as taggedEnum, Pt as Literals, Qt as optional, Rt as Record, Tn as fail, Xi as some, Yr as flatMap, Zi as toArray, _ as orElse, _a as pipe, ar as sync, b as when, cr as tryPromise, g as exhaustive, li as map, lr as try_, qi as match, qt as decodeUnknownOption, rr as succeed, y as value, zi as getOrElse, zt as String } from "./dist-LBqwqmSY.js";
|
|
3
3
|
import { execFile } from "node:child_process";
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
|
+
import { gunzipSync } from "node:zlib";
|
|
6
7
|
import { promisify } from "node:util";
|
|
7
8
|
Literals([
|
|
8
9
|
"headingTitle",
|
|
@@ -116,8 +117,17 @@ var workspaceOf = (dir) => {
|
|
|
116
117
|
};
|
|
117
118
|
var workspaceRoot = (dir) => getOrElse(workspaceOf(dir), () => dir);
|
|
118
119
|
var storeDir = (dir) => process.env.LOOM_HOME === void 0 ? join(workspaceRoot(dir), ".loom", "services") : join(process.env.LOOM_HOME, "services");
|
|
119
|
-
var
|
|
120
|
-
|
|
120
|
+
var ServiceManifestSchema = Struct({
|
|
121
|
+
version: optional(String),
|
|
122
|
+
main: optional(String),
|
|
123
|
+
exports: optional(Unknown)
|
|
124
|
+
});
|
|
125
|
+
var serviceDir = (id, dir) => join(storeDir(dir), "node_modules", servicePackage(id));
|
|
126
|
+
var serviceManifest = (id, dir) => pipe(liftThrowable(() => readFileSync(join(serviceDir(id, dir), "package.json"), "utf8"))(), flatMap$1(liftThrowable((text) => JSON.parse(text))), flatMap$1(decodeUnknownOption(ServiceManifestSchema)));
|
|
127
|
+
var serviceVersion = "0.0.13";
|
|
128
|
+
var installedVersion = (id, dir) => flatMap$1(serviceManifest(id, dir), (manifest) => fromNullishOr(manifest.version));
|
|
129
|
+
var standalone = /[\\/](\$bunfs|~BUN)[\\/]/.test(import.meta.url);
|
|
130
|
+
var embeddedFile = (name) => pipe(fromNullishOr(globalThis.Bun?.embeddedFiles), flatMap$1(findFirst((file) => file.name === name)));
|
|
121
131
|
var StoreError = class extends TaggedError("StoreError") {};
|
|
122
132
|
var prepareStore = (store) => {
|
|
123
133
|
mkdirSync(store, { recursive: true });
|
|
@@ -127,37 +137,109 @@ var prepareStore = (store) => {
|
|
|
127
137
|
private: true
|
|
128
138
|
}, null, 2)}\n`);
|
|
129
139
|
};
|
|
130
|
-
var
|
|
131
|
-
|
|
140
|
+
var packageManager = (store, spec) => standalone ? {
|
|
141
|
+
command: process.execPath,
|
|
142
|
+
args: [
|
|
143
|
+
"add",
|
|
144
|
+
spec,
|
|
145
|
+
"--cwd",
|
|
146
|
+
store,
|
|
147
|
+
"--omit",
|
|
148
|
+
"peer"
|
|
149
|
+
],
|
|
150
|
+
env: {
|
|
151
|
+
...process.env,
|
|
152
|
+
BUN_BE_BUN: "1"
|
|
153
|
+
}
|
|
154
|
+
} : {
|
|
155
|
+
command: "npm",
|
|
156
|
+
args: [
|
|
157
|
+
"install",
|
|
158
|
+
spec,
|
|
159
|
+
"--prefix",
|
|
160
|
+
store,
|
|
161
|
+
"--omit=peer",
|
|
162
|
+
"--no-audit",
|
|
163
|
+
"--no-fund"
|
|
164
|
+
],
|
|
165
|
+
env: process.env
|
|
166
|
+
};
|
|
167
|
+
var installPackage = (dir, packageName, range) => gen(function* () {
|
|
132
168
|
const store = storeDir(dir);
|
|
133
|
-
const installed = installedVersion(id, dir);
|
|
134
|
-
if (contains(installed, "0.0.12")) return ServiceInstall.Current();
|
|
135
169
|
yield* sync(() => prepareStore(store));
|
|
170
|
+
const manager = packageManager(store, `${packageName}@${range}`);
|
|
136
171
|
yield* tryPromise({
|
|
137
|
-
try: () => run(
|
|
138
|
-
"install",
|
|
139
|
-
`${servicePackage(id)}@${serviceVersion}`,
|
|
140
|
-
"--prefix",
|
|
141
|
-
store,
|
|
142
|
-
"--omit=peer",
|
|
143
|
-
"--no-audit",
|
|
144
|
-
"--no-fund"
|
|
145
|
-
]),
|
|
172
|
+
try: () => run(manager.command, [...manager.args], { env: manager.env }),
|
|
146
173
|
catch: (cause) => new StoreError({
|
|
147
|
-
|
|
174
|
+
packageName,
|
|
148
175
|
cause
|
|
149
176
|
})
|
|
150
177
|
});
|
|
178
|
+
});
|
|
179
|
+
var ServiceInstall = taggedEnum();
|
|
180
|
+
var installService = (id, dir) => gen(function* () {
|
|
181
|
+
const installed = installedVersion(id, dir);
|
|
182
|
+
if (contains(installed, "0.0.13")) return ServiceInstall.Current();
|
|
183
|
+
yield* installPackage(dir, servicePackage(id), serviceVersion);
|
|
151
184
|
return match(installed, {
|
|
152
185
|
onNone: () => ServiceInstall.Installed(),
|
|
153
186
|
onSome: (from) => ServiceInstall.Updated({ from })
|
|
154
187
|
});
|
|
155
188
|
});
|
|
156
|
-
var
|
|
189
|
+
var storeTypeScript = (dir) => {
|
|
190
|
+
const file = join(storeDir(dir), "node_modules", "typescript", "lib", "typescript.js");
|
|
191
|
+
return existsSync(file) ? some(file) : none();
|
|
192
|
+
};
|
|
193
|
+
var typeScriptAsset = "typescript.json.gz";
|
|
194
|
+
var PackedTypeScriptSchema = Struct({ files: Record(String, String) });
|
|
195
|
+
var typeScriptError = (cause) => new StoreError({
|
|
196
|
+
packageName: "typescript",
|
|
197
|
+
cause
|
|
198
|
+
});
|
|
199
|
+
var unpackTypeScript = (dir, packed) => gen(function* () {
|
|
200
|
+
const archive = yield* tryPromise({
|
|
201
|
+
try: async () => new Uint8Array(await packed.arrayBuffer()),
|
|
202
|
+
catch: typeScriptError
|
|
203
|
+
});
|
|
204
|
+
const json = yield* try_({
|
|
205
|
+
try: () => JSON.parse(gunzipSync(archive).toString("utf8")),
|
|
206
|
+
catch: typeScriptError
|
|
207
|
+
});
|
|
208
|
+
const { files } = yield* decodeUnknownEffect(PackedTypeScriptSchema)(json).pipe(mapError(typeScriptError));
|
|
209
|
+
const store = storeDir(dir);
|
|
210
|
+
const modules = join(store, "node_modules");
|
|
211
|
+
const partial = join(modules, `.typescript-${process.pid}`);
|
|
212
|
+
yield* sync(() => prepareStore(store));
|
|
213
|
+
yield* forEach(Object.entries(files), ([path, text]) => try_({
|
|
214
|
+
try: () => {
|
|
215
|
+
mkdirSync(dirname(join(partial, path)), { recursive: true });
|
|
216
|
+
writeFileSync(join(partial, path), text);
|
|
217
|
+
},
|
|
218
|
+
catch: typeScriptError
|
|
219
|
+
}), { discard: true });
|
|
220
|
+
yield* try_({
|
|
221
|
+
try: () => {
|
|
222
|
+
rmSync(join(modules, "typescript"), {
|
|
223
|
+
recursive: true,
|
|
224
|
+
force: true
|
|
225
|
+
});
|
|
226
|
+
renameSync(partial, join(modules, "typescript"));
|
|
227
|
+
},
|
|
228
|
+
catch: typeScriptError
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
var installTypeScript = (dir) => match(embeddedFile(typeScriptAsset), {
|
|
232
|
+
onSome: (packed) => unpackTypeScript(dir, packed),
|
|
233
|
+
onNone: () => installPackage(dir, "typescript", "^6")
|
|
234
|
+
}).pipe(flatMap$2(() => match(storeTypeScript(dir), {
|
|
235
|
+
onNone: () => fail(typeScriptError("the store holds no lib/typescript.js")),
|
|
236
|
+
onSome: succeed
|
|
237
|
+
})));
|
|
238
|
+
var removeService = (id, dir) => sync(() => rmSync(serviceDir(id, dir), {
|
|
157
239
|
recursive: true,
|
|
158
240
|
force: true
|
|
159
241
|
}));
|
|
160
242
|
//#endregion
|
|
161
|
-
export {
|
|
243
|
+
export { profileOf as _, installedVersion as a, serviceManifest as c, standalone as d, storeDir as f, SemanticTokenSchema as g, workspaceRoot as h, installTypeScript as i, servicePackage as l, workspaceOf as m, embeddedFile as n, removeService as o, storeTypeScript as p, installService as r, serviceDir as s, ServiceInstall as t, serviceVersion as u, symbolAt as v, symbolsOf as y };
|
|
162
244
|
|
|
163
|
-
//# sourceMappingURL=LoomStore-
|
|
245
|
+
//# sourceMappingURL=LoomStore-axDgE8RF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoomStore-axDgE8RF.js","names":[],"sources":["../../loom-ast/src/ast/LoomSymbol.ts","../../loom-lang-services/src/LoomStore.ts"],"sourcesContent":["import { Array, Match, Option, Schema } from 'effect'\nimport { type Position } from '#ast/LoomNode'\nimport {\n type LoomDocument,\n type LoomFrontmatter,\n type LoomHeading,\n type LoomSection,\n} from '#ast/LoomAst'\nimport { type SectionBodyWeft, type TocWeft } from '#ast/Weft'\nimport { type WarpAnchorToken, type WarpToken } from '#ast/LoomTokens'\n\nexport const SymbolKindSchema = Schema.Literals([\n 'headingTitle',\n 'sectionAnchor',\n 'warpAnchor',\n 'warpDef',\n 'specifier',\n 'sink',\n 'arrow',\n 'tilde',\n 'prose',\n 'frontmatterMembership',\n 'frontmatterValue',\n 'frontmatterTitle',\n 'frontmatterPart',\n 'frontmatterPartName',\n 'tocPart',\n 'tocEntry',\n])\nexport type SymbolKind = typeof SymbolKindSchema.Type\n\nexport interface SpanFeatures {\n readonly navigation?: boolean\n readonly semantic?: boolean\n readonly structure?: boolean\n readonly verification?: boolean\n readonly completion?: boolean\n}\n\nexport const SemanticTokenSchema = Schema.Literals([\n 'namespace',\n 'variable',\n 'keyword',\n 'string',\n 'operator',\n])\nexport type SemanticToken = typeof SemanticTokenSchema.Type\n\nexport interface SymbolProfile {\n readonly semantic: Option.Option<SemanticToken>\n readonly features: SpanFeatures\n}\n\nconst profile = (\n semantic: Option.Option<SemanticToken>,\n features: SpanFeatures,\n): SymbolProfile => ({ semantic, features })\n\nexport const profileOf = (kind: SymbolKind): SymbolProfile =>\n Match.value(kind).pipe(\n Match.when('headingTitle', () =>\n profile(Option.some('namespace'), { navigation: true, structure: true }),\n ),\n Match.when('sectionAnchor', () =>\n profile(Option.some('namespace'), {\n navigation: true,\n structure: true,\n verification: true,\n }),\n ),\n Match.when('warpAnchor', () =>\n profile(Option.some('variable'), { navigation: true, verification: true }),\n ),\n Match.when('warpDef', () => profile(Option.some('variable'), { navigation: true })),\n Match.when('specifier', () => profile(Option.some('keyword'), { verification: true })),\n Match.when('sink', () => profile(Option.some('string'), { verification: true })),\n Match.when('arrow', () => profile(Option.some('operator'), {})),\n Match.when('tilde', () => profile(Option.some('operator'), {})),\n Match.when('prose', () => profile(Option.none(), { structure: true })),\n Match.when('frontmatterMembership', () =>\n profile(Option.some('namespace'), { structure: true }),\n ),\n Match.when('frontmatterValue', () => profile(Option.some('string'), { structure: true })),\n Match.when('frontmatterTitle', () =>\n profile(Option.some('namespace'), { navigation: true, structure: true }),\n ),\n Match.when('frontmatterPart', () =>\n profile(Option.some('namespace'), { navigation: true, structure: true }),\n ),\n Match.when('frontmatterPartName', () =>\n profile(Option.some('namespace'), { navigation: true, structure: true }),\n ),\n Match.when('tocPart', () =>\n profile(Option.some('namespace'), { navigation: true, structure: true }),\n ),\n Match.when('tocEntry', () =>\n profile(Option.some('namespace'), {\n navigation: true,\n structure: true,\n verification: true,\n }),\n ),\n Match.exhaustive,\n )\n\nexport interface Symbol {\n readonly kind: SymbolKind\n readonly position: Position\n}\n\nconst anchorKind = (warpsInScope: ReadonlySet<string>, anchor: WarpAnchorToken): SymbolKind =>\n warpsInScope.has(anchor.name.value) ? 'warpAnchor' : 'sectionAnchor'\n\nconst namesOf = (warps: ReadonlyArray<WarpToken>): ReadonlyArray<string> =>\n Array.map(warps, (warp) => warp.name.value)\n\nconst at = (kind: SymbolKind, position: Position): Symbol => ({ kind, position })\n\nconst optSymbol = (\n kind: SymbolKind,\n token: { readonly position: Position } | undefined,\n): ReadonlyArray<Symbol> =>\n Option.toArray(Option.map(Option.fromNullishOr(token), (t) => at(kind, t.position)))\n\nconst frontmatterSymbols = (fm: LoomFrontmatter): ReadonlyArray<Symbol> => [\n ...optSymbol('frontmatterPart', fm.part),\n ...optSymbol('frontmatterPartName', fm.partName),\n ...optSymbol('frontmatterMembership', fm.chapter),\n ...optSymbol('frontmatterTitle', fm.title),\n ...optSymbol('frontmatterValue', fm.package),\n ...optSymbol('frontmatterValue', fm.language),\n]\n\nconst tocSymbols = (weft: TocWeft): ReadonlyArray<Symbol> => [\n ...optSymbol('tocPart', weft.part),\n ...optSymbol('tocEntry', weft.title),\n]\n\nconst headingSymbols = (heading: LoomHeading): ReadonlyArray<Symbol> => [\n ...Option.toArray(\n Option.map(Option.fromNullishOr(heading.title), (t) => at('headingTitle', t.position)),\n ),\n ...Option.toArray(\n Option.map(Option.fromNullishOr(heading.specifier), (s) => at('specifier', s.label.position)),\n ),\n ...Option.toArray(Option.map(Option.fromNullishOr(heading.sink), (s) => at('sink', s.position))),\n]\n\nconst delimiterOf = (weft: SectionBodyWeft): ReadonlyArray<Symbol> =>\n Match.value(weft).pipe(\n Match.when({ type: 'ArrowWeft' }, (w) => [at('arrow', w.arrow.position)]),\n Match.when({ type: 'TildeWeft' }, (w) => [at('tilde', w.tilde.position)]),\n Match.orElse(() => []),\n )\n\nconst sectionSymbols = (\n section: LoomSection,\n documentWarps: ReadonlyArray<string>,\n): ReadonlyArray<Symbol> => {\n const warps = Array.flatMap(section.preamble, (weft) => weft.warps)\n const scope = new Set([...documentWarps, ...namesOf(warps)])\n const anchors = [\n ...Array.flatMap(section.preamble, (weft) => weft.anchors),\n ...Array.flatMap(section.code, (weft) => weft.anchors),\n ]\n return [\n ...headingSymbols(section.heading),\n ...Array.map(warps, (warp) => at('warpDef', warp.name.position)),\n ...Array.map(anchors, (anchor) => at(anchorKind(scope, anchor), anchor.name.position)),\n ...Array.flatMap(section.code, delimiterOf),\n ...Array.flatMap(section.entries ?? [], tocSymbols),\n ]\n}\n\nexport const symbolsOf = (doc: LoomDocument): ReadonlyArray<Symbol> => {\n const warps = Array.flatMap(doc.preamble, (weft) => weft.warps)\n const scope = new Set(namesOf(warps))\n return [\n ...Array.flatMap(Option.toArray(Option.fromNullishOr(doc.frontmatter)), frontmatterSymbols),\n ...Array.map(warps, (warp) => at('warpDef', warp.name.position)),\n ...Array.map(\n Array.flatMap(doc.preamble, (weft) => weft.anchors),\n (anchor) => at(anchorKind(scope, anchor), anchor.name.position),\n ),\n ...Array.flatMap(doc.sections, (section) => sectionSymbols(section, namesOf(warps))),\n ]\n}\n\nexport const symbolAt = (doc: LoomDocument, offset: number): Option.Option<Symbol> =>\n Array.findFirst(\n symbolsOf(doc),\n (symbol) => symbol.position.start.offset <= offset && offset <= symbol.position.end.offset,\n )\n","import { Array, Data, Effect, Option, Schema, pipe } from 'effect'\nimport { execFile } from 'node:child_process'\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { promisify } from 'node:util'\nimport { gunzipSync } from 'node:zlib'\n\nconst run = promisify(execFile)\n\nexport const servicePackage = (id: string): string => `@athrio/loom-service-${id}`\n\nexport const workspaceOf = (dir: string): Option.Option<string> => {\n if (existsSync(join(dir, '.loom'))) return Option.some(dir)\n const parent = dirname(dir)\n return parent === dir ? Option.none() : workspaceOf(parent)\n}\n\nexport const workspaceRoot = (dir: string): string => Option.getOrElse(workspaceOf(dir), () => dir)\n\nexport const storeDir = (dir: string): string =>\n process.env.LOOM_HOME === undefined\n ? join(workspaceRoot(dir), '.loom', 'services')\n : join(process.env.LOOM_HOME, 'services')\n\nconst servicePrefix = 'loom-service-'\n\nexport const installedServices = (dir: string): Effect.Effect<ReadonlyArray<string>> =>\n Effect.sync(() => {\n const scope = join(storeDir(dir), 'node_modules', '@athrio')\n if (!existsSync(scope)) return []\n return readdirSync(scope)\n .filter((name) => name.startsWith(servicePrefix))\n .map((name) => name.slice(servicePrefix.length))\n })\n\nexport const ServiceManifestSchema = Schema.Struct({\n version: Schema.optional(Schema.String),\n main: Schema.optional(Schema.String),\n exports: Schema.optional(Schema.Unknown),\n})\n\nexport type ServiceManifest = typeof ServiceManifestSchema.Type\n\nexport const serviceDir = (id: string, dir: string): string =>\n join(storeDir(dir), 'node_modules', servicePackage(id))\n\nexport const serviceManifest = (id: string, dir: string): Option.Option<ServiceManifest> =>\n pipe(\n Option.liftThrowable(() => readFileSync(join(serviceDir(id, dir), 'package.json'), 'utf8'))(),\n Option.flatMap(Option.liftThrowable((text: string): unknown => JSON.parse(text))),\n Option.flatMap(Schema.decodeUnknownOption(ServiceManifestSchema)),\n )\n\nexport const serviceVersion = '0.0.13'\n\nexport const installedVersion = (id: string, dir: string): Option.Option<string> =>\n Option.flatMap(serviceManifest(id, dir), (manifest) => Option.fromNullishOr(manifest.version))\n\nexport const standalone: boolean = /[\\\\/](\\$bunfs|~BUN)[\\\\/]/.test(import.meta.url)\n\ninterface EmbeddedFile extends Blob {\n readonly name?: string\n}\n\nexport const embeddedFile = (name: string): Option.Option<EmbeddedFile> =>\n pipe(\n Option.fromNullishOr(\n (globalThis as { readonly Bun?: { readonly embeddedFiles?: ReadonlyArray<EmbeddedFile> } })\n .Bun?.embeddedFiles,\n ),\n Option.flatMap(Array.findFirst((file) => file.name === name)),\n )\n\nexport class StoreError extends Data.TaggedError('StoreError')<{\n readonly packageName: string\n readonly cause: unknown\n}> {}\n\nconst prepareStore = (store: string): void => {\n mkdirSync(store, { recursive: true })\n const manifest = join(store, 'package.json')\n if (!existsSync(manifest))\n writeFileSync(\n manifest,\n `${JSON.stringify({ name: 'loom-services', private: true }, null, 2)}\\n`,\n )\n}\n\ninterface PackageManager {\n readonly command: string\n readonly args: ReadonlyArray<string>\n readonly env: NodeJS.ProcessEnv\n}\n\nconst packageManager = (store: string, spec: string): PackageManager =>\n standalone\n ? {\n command: process.execPath,\n args: ['add', spec, '--cwd', store, '--omit', 'peer'],\n env: { ...process.env, BUN_BE_BUN: '1' },\n }\n : {\n command: 'npm',\n args: ['install', spec, '--prefix', store, '--omit=peer', '--no-audit', '--no-fund'],\n env: process.env,\n }\n\nconst installPackage = (\n dir: string,\n packageName: string,\n range: string,\n): Effect.Effect<void, StoreError> =>\n Effect.gen(function* () {\n const store = storeDir(dir)\n yield* Effect.sync(() => prepareStore(store))\n const manager = packageManager(store, `${packageName}@${range}`)\n yield* Effect.tryPromise({\n try: () => run(manager.command, [...manager.args], { env: manager.env }),\n catch: (cause) => new StoreError({ packageName, cause }),\n })\n })\n\nexport type ServiceInstall = Data.TaggedEnum<{\n Current: {}\n Installed: {}\n Updated: { readonly from: string }\n}>\nexport const ServiceInstall = Data.taggedEnum<ServiceInstall>()\n\nexport const installService = (id: string, dir: string): Effect.Effect<ServiceInstall, StoreError> =>\n Effect.gen(function* () {\n const installed = installedVersion(id, dir)\n if (Option.contains(installed, serviceVersion)) return ServiceInstall.Current()\n yield* installPackage(dir, servicePackage(id), serviceVersion)\n return Option.match(installed, {\n onNone: () => ServiceInstall.Installed(),\n onSome: (from) => ServiceInstall.Updated({ from }),\n })\n })\n\nexport const typeScriptRange = '^6'\n\nexport const storeTypeScript = (dir: string): Option.Option<string> => {\n const file = join(storeDir(dir), 'node_modules', 'typescript', 'lib', 'typescript.js')\n return existsSync(file) ? Option.some(file) : Option.none()\n}\n\nconst typeScriptAsset = 'typescript.json.gz'\n\nconst PackedTypeScriptSchema = Schema.Struct({\n files: Schema.Record(Schema.String, Schema.String),\n})\n\nconst typeScriptError = (cause: unknown): StoreError =>\n new StoreError({ packageName: 'typescript', cause })\n\nconst unpackTypeScript = (dir: string, packed: Blob): Effect.Effect<void, StoreError> =>\n Effect.gen(function* () {\n const archive = yield* Effect.tryPromise({\n try: async () => new Uint8Array(await packed.arrayBuffer()),\n catch: typeScriptError,\n })\n const json = yield* Effect.try({\n try: (): unknown => JSON.parse(gunzipSync(archive).toString('utf8')),\n catch: typeScriptError,\n })\n const { files } = yield* Schema.decodeUnknownEffect(PackedTypeScriptSchema)(json).pipe(\n Effect.mapError(typeScriptError),\n )\n const store = storeDir(dir)\n const modules = join(store, 'node_modules')\n const partial = join(modules, `.typescript-${process.pid}`)\n yield* Effect.sync(() => prepareStore(store))\n yield* Effect.forEach(\n Object.entries(files),\n ([path, text]) =>\n Effect.try({\n try: () => {\n mkdirSync(dirname(join(partial, path)), { recursive: true })\n writeFileSync(join(partial, path), text)\n },\n catch: typeScriptError,\n }),\n { discard: true },\n )\n yield* Effect.try({\n try: () => {\n rmSync(join(modules, 'typescript'), { recursive: true, force: true })\n renameSync(partial, join(modules, 'typescript'))\n },\n catch: typeScriptError,\n })\n })\n\nexport const installTypeScript = (dir: string): Effect.Effect<string, StoreError> =>\n Option.match(embeddedFile(typeScriptAsset), {\n onSome: (packed) => unpackTypeScript(dir, packed),\n onNone: () => installPackage(dir, 'typescript', typeScriptRange),\n }).pipe(\n Effect.flatMap(() =>\n Option.match(storeTypeScript(dir), {\n onNone: () => Effect.fail(typeScriptError('the store holds no lib/typescript.js')),\n onSome: Effect.succeed,\n }),\n ),\n )\n\nexport const removeService = (id: string, dir: string): Effect.Effect<void> =>\n Effect.sync(() => rmSync(serviceDir(id, dir), { recursive: true, force: true }))\n"],"mappings":";;;;;;;AAWgC,SAAgB;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAWD,IAAa,sBAAsB,SAAgB;CACjD;CACA;CACA;C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,GAAG;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;GACpE,WAAW,SAAS,KAAK,SAAS,YAAY,CAAC;EACjD;EACA,OAAO;CACT,CAAC;AACH,CAAC;AAEH,IAAa,qBAAqB,QAChC,MAAa,aAAa,eAAe,GAAG;CAC1C,SAAS,WAAW,iBAAiB,KAAK,MAAM;CAChD,cAAc,eAAe,KAAK,cAAA,IAA6B;AACjE,CAAC,CAAC,CAAC,KACD,gBACE,MAAa,gBAAgB,GAAG,GAAG;CACjC,cAAc,KAAY,gBAAgB,sCAAsC,CAAC;CACjF,QAAQ;AACV,CAAC,CACH,CACF;AAEF,IAAa,iBAAiB,IAAY,QACxC,WAAkB,OAAO,WAAW,IAAI,GAAG,GAAG;CAAE,WAAW;CAAM,OAAO;AAAK,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as runtimeVersion, n as runtimeKey, r as runtimeSpecifiers, t as installHostRuntime } from "./Runtime-
|
|
2
|
+
import { i as runtimeVersion, n as runtimeKey, r as runtimeSpecifiers, t as installHostRuntime } from "./Runtime-D4WijrpR.js";
|
|
3
3
|
export { installHostRuntime, runtimeKey, runtimeSpecifiers, runtimeVersion };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as dist_exports } from "./dist-
|
|
3
|
-
import { r as LanguageService_exports } from "./LanguageService-
|
|
2
|
+
import { t as dist_exports } from "./dist-LBqwqmSY.js";
|
|
3
|
+
import { r as LanguageService_exports } from "./LanguageService-CcElIYBZ.js";
|
|
4
4
|
//#region ../loom-lang-services/src/Runtime.ts
|
|
5
5
|
var runtimeKey = "__loomRuntime";
|
|
6
6
|
var runtimeVersion = "1";
|
|
@@ -22,4 +22,4 @@ var installHostRuntime = (tsdk) => {
|
|
|
22
22
|
//#endregion
|
|
23
23
|
export { runtimeVersion as i, runtimeKey as n, runtimeSpecifiers as r, installHostRuntime as t };
|
|
24
24
|
|
|
25
|
-
//# sourceMappingURL=Runtime-
|
|
25
|
+
//# sourceMappingURL=Runtime-D4WijrpR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Runtime-
|
|
1
|
+
{"version":3,"file":"Runtime-D4WijrpR.js","names":[],"sources":["../../loom-lang-services/src/Runtime.ts"],"sourcesContent":["export const runtimeKey = '__loomRuntime'\n\nexport const runtimeVersion = '1'\n\nexport const runtimeSpecifiers: ReadonlyArray<string> = [\n 'effect',\n '@athrio/loom-lang-services/LanguageService',\n 'typescript',\n]\n\nimport * as EffectNS from 'effect'\nimport * as LanguageServiceNS from './LanguageService'\n\ninterface HostRuntime {\n readonly version: string\n readonly modules: Record<string, unknown>\n}\n\nexport const installHostRuntime = (tsdk: typeof import('typescript')): void => {\n ;(globalThis as Record<string, unknown>)[runtimeKey] = {\n version: runtimeVersion,\n modules: {\n effect: EffectNS,\n '@athrio/loom-lang-services/LanguageService': LanguageServiceNS,\n typescript: tsdk,\n },\n } satisfies HostRuntime\n}\n"],"mappings":";;;;AAAA,IAAa,aAAa;AAE1B,IAAa,iBAAiB;AAE9B,IAAa,oBAA2C;CACtD;CACA;CACA;AACF;AAUA,IAAa,sBAAsB,SAA4C;CAC5E,WAAwC,cAAc;EACrD,SAAA;EACA,SAAS;GACP,QAAQ;GACR,8CAA8C;GAC9C,YAAY;EACd;CACF;AACF"}
|