@r_masseater/fumx 0.1.1 → 0.1.2
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/{cli-D2DptmOG.mjs → cli-Ci7maCdL.mjs} +2 -2
- package/dist/{cli-D2DptmOG.mjs.map → cli-Ci7maCdL.mjs.map} +1 -1
- package/dist/fumx.mjs +1 -1
- package/dist/mapper.mjs +1 -1
- package/dist/{transform-CeFBPHqb.mjs → transform-DGUihHCR.mjs} +2 -2
- package/dist/transform-DGUihHCR.mjs.map +1 -0
- package/dist/vite.mjs +1 -1
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
- package/skills/lint-songs/SKILL.md +1 -1
- package/skills/read-fumx/SKILL.md +1 -1
- package/skills/use-fumx-tools/SKILL.md +1 -1
- package/skills/use-lint-presets/SKILL.md +1 -1
- package/dist/transform-CeFBPHqb.mjs.map +0 -1
package/dist/fumx.mjs
CHANGED
package/dist/mapper.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { runContentMapper } from "ts-content-mapper";
|
|
|
3
3
|
// src/app/mapper.ts
|
|
4
4
|
runContentMapper({
|
|
5
5
|
diagnosticSource: "fumx",
|
|
6
|
-
transform: ({ fileName, content }, { positionEncoding }) => runPromise(promise(() => import("./transform-
|
|
6
|
+
transform: ({ fileName, content }, { positionEncoding }) => runPromise(promise(() => import("./transform-DGUihHCR.mjs")).pipe(flatMap(({ transform }) => promise(() => transform({
|
|
7
7
|
fileName,
|
|
8
8
|
content,
|
|
9
9
|
positionEncoding
|
|
@@ -12,7 +12,7 @@ const NAMED_FIELDS = {
|
|
|
12
12
|
tracks: "Track",
|
|
13
13
|
plugins: "Plugin"
|
|
14
14
|
};
|
|
15
|
-
const SONG_MODULE = "
|
|
15
|
+
const SONG_MODULE = "@r_masseater/fumx";
|
|
16
16
|
const NEVER_SONG = "export declare const song: never;\n";
|
|
17
17
|
const titleSegments = (song, outline) => Option.match(outline.title, {
|
|
18
18
|
onNone: () => [text(quoted(song.title))],
|
|
@@ -105,4 +105,4 @@ const runtime = ManagedRuntime.make(NodeFileSystem.layer);
|
|
|
105
105
|
const transform = (request) => runtime.runPromise(transformSong(request));
|
|
106
106
|
export { transform };
|
|
107
107
|
|
|
108
|
-
//# sourceMappingURL=transform-
|
|
108
|
+
//# sourceMappingURL=transform-DGUihHCR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-DGUihHCR.mjs","names":["Arr","Rec"],"sources":["../src/features/build-song-module/model/song-module.ts","../src/app/transform.ts"],"sourcesContent":["import { nameLiteral, quoted, text } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Segment } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Issue, Mapped } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\n\nimport { SongSchema } from \"#/entities/song/index.ts\";\nimport type { Song } from \"#/entities/song/index.ts\";\nimport { readSong } from \"#/features/read-song/@x/build-song-module.ts\";\nimport type {\n Named,\n Outline,\n SongSource,\n SourceIssue,\n} from \"#/features/read-song/@x/build-song-module.ts\";\n\nexport interface SongModuleSource<Failure> {\n readonly path: string;\n readonly content: string;\n readonly read: (path: string) => Effect.Effect<string, Failure>;\n}\n\nexport interface SongModule {\n readonly mapped: Mapped;\n readonly song: Option.Option<Song>;\n readonly files: readonly string[];\n}\n\ntype NamedField = {\n readonly [Field in keyof Song]: Song[Field] extends readonly { readonly name: string }[]\n ? Field\n : never;\n}[keyof Song];\n\nconst NAMED_FIELDS = {\n samples: \"Sample\",\n kits: \"Kit\",\n instruments: \"Instrument\",\n buses: \"Bus\",\n tracks: \"Track\",\n plugins: \"Plugin\",\n} as const satisfies Readonly<Record<NamedField, Named[\"$type\"]>>;\n\nconst SONG_MODULE = \"@r_masseater/fumx\";\n\nconst NEVER_SONG = \"export declare const song: never;\\n\";\n\nconst titleSegments = (song: Song, outline: Outline): readonly Segment[] =>\n Option.match(outline.title, {\n onNone: () => [text(quoted(song.title))],\n onSome: ({ start, end }): readonly Segment[] => [\n { kind: \"alias\", text: quoted(song.title), start, end },\n ],\n });\n\nconst fieldSegments =\n (song: Song, outline: Outline) =>\n ([field, type]: readonly [NamedField, Named[\"$type\"]]): readonly Segment[] => [\n text(` readonly ${field}: readonly [\\n`),\n ...pipe(\n song[field],\n Arr.flatMap(({ name }) => [\n text(` Song[\"${field}\"][number] & { readonly name: `),\n ...nameLiteral({\n name,\n span: pipe(\n outline.names,\n Arr.findFirst((found) => found.type === type && found.name === name),\n Option.map((found) => found.span),\n ),\n }),\n text(\" },\\n\"),\n ]),\n ),\n text(\" ];\\n\"),\n ];\n\nconst segmentsOf = (song: Song, outline: Outline): readonly Segment[] => [\n text(`import type { Song } from \"${SONG_MODULE}\";\\n`),\n text(\"export declare const song: Song & {\\n readonly title: \"),\n ...titleSegments(song, outline),\n text(\";\\n\"),\n ...pipe(Rec.toEntries(NAMED_FIELDS), Arr.flatMap(fieldSegments(song, outline))),\n text(\"};\\n\"),\n];\n\nconst issueOf =\n ({ path, outline }: Readonly<{ path: string; outline: Outline }>) =>\n (issue: SourceIssue): Issue => {\n if (issue.path === path) {\n return { message: issue.message, start: issue.start, end: issue.end };\n }\n const at = pipe(\n outline.imports,\n Arr.findFirst((found) => found.path === issue.path),\n Option.map((found) => found.span),\n Option.getOrElse(() => ({ start: 0, end: 0 })),\n );\n return {\n message: `${issue.path}:${String(issue.line)}:${String(issue.column)} ${issue.message}`,\n ...at,\n };\n };\n\nconst moduleOf =\n (path: string) =>\n (source: SongSource): SongModule => {\n if (source.status === \"invalid\") {\n return {\n mapped: {\n status: \"error\",\n fallback: NEVER_SONG,\n issues: pipe(source.issues, Arr.map(issueOf({ path, outline: source.outline }))),\n },\n song: Option.none(),\n files: source.outline.files,\n };\n }\n return {\n mapped: { status: \"ok\", segments: segmentsOf(source.song, source.outline) },\n song: Option.some(source.song),\n files: source.outline.files,\n };\n };\n\nexport const songModuleOf = <Failure>({\n path,\n content,\n read,\n}: SongModuleSource<Failure>): Effect.Effect<SongModule> =>\n readSong({\n path,\n read: (target) => {\n if (target === path) {\n return Effect.succeed(content);\n }\n return read(target);\n },\n }).pipe(Effect.map(moduleOf(path)));\n\nconst encodeSong = Schema.encodeEffect(Schema.fromJsonString(SongSchema));\n\nexport const songCodeOf = (song: Song): Effect.Effect<string> =>\n encodeSong(song).pipe(\n Effect.orDie,\n Effect.map(\n (json) =>\n `import { Schema } from \"effect\";\\nimport { SongSchema } from \"${SONG_MODULE}\";\\nexport const song = Schema.decodeSync(Schema.fromJsonString(SongSchema))(${quoted(json)});\\n`,\n ),\n );\n","import { NodeFileSystem } from \"@effect/platform-node-shared\";\nimport { mappedOutput } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport type { Request } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport { Effect, FileSystem, ManagedRuntime } from \"effect\";\nimport type { TransformResult } from \"ts-content-mapper\";\n\nimport { songModuleOf } from \"#/features/build-song-module/index.ts\";\n\nconst transformSong = Effect.fn(\"transformSong\")(function* transformSong(request: Request) {\n const fileSystem = yield* FileSystem.FileSystem;\n const { mapped } = yield* songModuleOf({\n path: request.fileName,\n content: request.content,\n read: (path) => fileSystem.readFileString(path),\n });\n return mappedOutput({ request, mapped });\n});\n\nconst runtime = ManagedRuntime.make(NodeFileSystem.layer);\n\nexport const transform = (request: Request): Promise<TransformResult> =>\n runtime.runPromise(transformSong(request));\n"],"mappings":";;;;;;AAiCA,MAAM,eAAe;CACnB,SAAS;CACT,MAAM;CACN,aAAa;CACb,OAAO;CACP,QAAQ;CACR,SAAS;AACX;AAEA,MAAM,cAAc;AAEpB,MAAM,aAAa;AAEnB,MAAM,iBAAiB,MAAY,YACjC,OAAO,MAAM,QAAQ,OAAO;CAC1B,cAAc,CAAC,KAAK,OAAO,KAAK,KAAK,CAAC,CAAC;CACvC,SAAS,EAAE,OAAO,UAA8B,CAC9C;EAAE,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,QAAQ;GACR,UAAU;GACV,QAAQ,KAAK,OAAO,QAAQA,MAAI,IAAI,QAAQ;IAAE;IAAM,SAAS,OAAO;GAAQ,CAAC,CAAC,CAAC;EACjF;EACA,MAAM,OAAO,KAAK;EAClB,OAAO,OAAO,QAAQ;CACxB;CAEF,OAAO;EACL,QAAQ;GAAE,QAAQ;GAAM,UAAU,WAAW,OAAO,MAAM,OAAO,OAAO;EAAE;EAC1E,MAAM,OAAO,KAAK,OAAO,IAAI;EAC7B,OAAO,OAAO,QAAQ;CACxB;AACF;AAEF,MAAa,gBAAyB,EACpC,MACA,SACA,WAEA,SAAS;CACP;CACA,OAAO,WAAW;EAChB,IAAI,WAAW,MACb,OAAO,OAAO,QAAQ,OAAO;EAE/B,OAAO,KAAK,MAAM;CACpB;AACF,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,SAAS,IAAI,CAAC,CAAC;AAEjB,OAAO,aAAa,OAAO,eAAe,UAAU,CAAC;;ACnIxE,MAAM,gBAAgB,OAAO,GAAG,eAAe,CAAC,CAAC,UAAU,cAAc,SAAkB;CACzF,MAAM,aAAa,OAAO,WAAW;CACrC,MAAM,EAAE,WAAW,OAAO,aAAa;EACrC,MAAM,QAAQ;EACd,SAAS,QAAQ;EACjB,OAAO,SAAS,WAAW,eAAe,IAAI;CAChD,CAAC;CACD,OAAO,aAAa;EAAE;EAAS;CAAO,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,eAAe,KAAK,eAAe,KAAK;AAExD,MAAa,aAAa,YACxB,QAAQ,WAAW,cAAc,OAAO,CAAC"}
|
package/dist/vite.mjs
CHANGED
|
@@ -12,7 +12,7 @@ const NAMED_FIELDS = {
|
|
|
12
12
|
tracks: "Track",
|
|
13
13
|
plugins: "Plugin"
|
|
14
14
|
};
|
|
15
|
-
const SONG_MODULE = "
|
|
15
|
+
const SONG_MODULE = "@r_masseater/fumx";
|
|
16
16
|
const NEVER_SONG = "export declare const song: never;\n";
|
|
17
17
|
const titleSegments = (song, outline) => Option.match(outline.title, {
|
|
18
18
|
onNone: () => [text(quoted(song.title))],
|
package/dist/vite.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.mjs","names":["Arr","Rec","Arr"],"sources":["../src/features/build-song-module/model/song-module.ts","../src/app/vite.ts"],"sourcesContent":["import { nameLiteral, quoted, text } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Segment } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Issue, Mapped } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\n\nimport { SongSchema } from \"#/entities/song/index.ts\";\nimport type { Song } from \"#/entities/song/index.ts\";\nimport { readSong } from \"#/features/read-song/@x/build-song-module.ts\";\nimport type {\n Named,\n Outline,\n SongSource,\n SourceIssue,\n} from \"#/features/read-song/@x/build-song-module.ts\";\n\nexport interface SongModuleSource<Failure> {\n readonly path: string;\n readonly content: string;\n readonly read: (path: string) => Effect.Effect<string, Failure>;\n}\n\nexport interface SongModule {\n readonly mapped: Mapped;\n readonly song: Option.Option<Song>;\n readonly files: readonly string[];\n}\n\ntype NamedField = {\n readonly [Field in keyof Song]: Song[Field] extends readonly { readonly name: string }[]\n ? Field\n : never;\n}[keyof Song];\n\nconst NAMED_FIELDS = {\n samples: \"Sample\",\n kits: \"Kit\",\n instruments: \"Instrument\",\n buses: \"Bus\",\n tracks: \"Track\",\n plugins: \"Plugin\",\n} as const satisfies Readonly<Record<NamedField, Named[\"$type\"]>>;\n\nconst SONG_MODULE = \"
|
|
1
|
+
{"version":3,"file":"vite.mjs","names":["Arr","Rec","Arr"],"sources":["../src/features/build-song-module/model/song-module.ts","../src/app/vite.ts"],"sourcesContent":["import { nameLiteral, quoted, text } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Segment } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Issue, Mapped } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\n\nimport { SongSchema } from \"#/entities/song/index.ts\";\nimport type { Song } from \"#/entities/song/index.ts\";\nimport { readSong } from \"#/features/read-song/@x/build-song-module.ts\";\nimport type {\n Named,\n Outline,\n SongSource,\n SourceIssue,\n} from \"#/features/read-song/@x/build-song-module.ts\";\n\nexport interface SongModuleSource<Failure> {\n readonly path: string;\n readonly content: string;\n readonly read: (path: string) => Effect.Effect<string, Failure>;\n}\n\nexport interface SongModule {\n readonly mapped: Mapped;\n readonly song: Option.Option<Song>;\n readonly files: readonly string[];\n}\n\ntype NamedField = {\n readonly [Field in keyof Song]: Song[Field] extends readonly { readonly name: string }[]\n ? Field\n : never;\n}[keyof Song];\n\nconst NAMED_FIELDS = {\n samples: \"Sample\",\n kits: \"Kit\",\n instruments: \"Instrument\",\n buses: \"Bus\",\n tracks: \"Track\",\n plugins: \"Plugin\",\n} as const satisfies Readonly<Record<NamedField, Named[\"$type\"]>>;\n\nconst SONG_MODULE = \"@r_masseater/fumx\";\n\nconst NEVER_SONG = \"export declare const song: never;\\n\";\n\nconst titleSegments = (song: Song, outline: Outline): readonly Segment[] =>\n Option.match(outline.title, {\n onNone: () => [text(quoted(song.title))],\n onSome: ({ start, end }): readonly Segment[] => [\n { kind: \"alias\", text: quoted(song.title), start, end },\n ],\n });\n\nconst fieldSegments =\n (song: Song, outline: Outline) =>\n ([field, type]: readonly [NamedField, Named[\"$type\"]]): readonly Segment[] => [\n text(` readonly ${field}: readonly [\\n`),\n ...pipe(\n song[field],\n Arr.flatMap(({ name }) => [\n text(` Song[\"${field}\"][number] & { readonly name: `),\n ...nameLiteral({\n name,\n span: pipe(\n outline.names,\n Arr.findFirst((found) => found.type === type && found.name === name),\n Option.map((found) => found.span),\n ),\n }),\n text(\" },\\n\"),\n ]),\n ),\n text(\" ];\\n\"),\n ];\n\nconst segmentsOf = (song: Song, outline: Outline): readonly Segment[] => [\n text(`import type { Song } from \"${SONG_MODULE}\";\\n`),\n text(\"export declare const song: Song & {\\n readonly title: \"),\n ...titleSegments(song, outline),\n text(\";\\n\"),\n ...pipe(Rec.toEntries(NAMED_FIELDS), Arr.flatMap(fieldSegments(song, outline))),\n text(\"};\\n\"),\n];\n\nconst issueOf =\n ({ path, outline }: Readonly<{ path: string; outline: Outline }>) =>\n (issue: SourceIssue): Issue => {\n if (issue.path === path) {\n return { message: issue.message, start: issue.start, end: issue.end };\n }\n const at = pipe(\n outline.imports,\n Arr.findFirst((found) => found.path === issue.path),\n Option.map((found) => found.span),\n Option.getOrElse(() => ({ start: 0, end: 0 })),\n );\n return {\n message: `${issue.path}:${String(issue.line)}:${String(issue.column)} ${issue.message}`,\n ...at,\n };\n };\n\nconst moduleOf =\n (path: string) =>\n (source: SongSource): SongModule => {\n if (source.status === \"invalid\") {\n return {\n mapped: {\n status: \"error\",\n fallback: NEVER_SONG,\n issues: pipe(source.issues, Arr.map(issueOf({ path, outline: source.outline }))),\n },\n song: Option.none(),\n files: source.outline.files,\n };\n }\n return {\n mapped: { status: \"ok\", segments: segmentsOf(source.song, source.outline) },\n song: Option.some(source.song),\n files: source.outline.files,\n };\n };\n\nexport const songModuleOf = <Failure>({\n path,\n content,\n read,\n}: SongModuleSource<Failure>): Effect.Effect<SongModule> =>\n readSong({\n path,\n read: (target) => {\n if (target === path) {\n return Effect.succeed(content);\n }\n return read(target);\n },\n }).pipe(Effect.map(moduleOf(path)));\n\nconst encodeSong = Schema.encodeEffect(Schema.fromJsonString(SongSchema));\n\nexport const songCodeOf = (song: Song): Effect.Effect<string> =>\n encodeSong(song).pipe(\n Effect.orDie,\n Effect.map(\n (json) =>\n `import { Schema } from \"effect\";\\nimport { SongSchema } from \"${SONG_MODULE}\";\\nexport const song = Schema.decodeSync(Schema.fromJsonString(SongSchema))(${quoted(json)});\\n`,\n ),\n );\n","import { renderSegments } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Mapped } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport { contentImport } from \"@r_masseater/masseater-utils/mapped-import/vite\";\nimport { Array as Arr, Effect, Match, Option, pipe } from \"effect\";\nimport type { Plugin } from \"vite-plus\";\n\nimport { songCodeOf, songModuleOf } from \"#/features/build-song-module/index.ts\";\nimport type { FumxConfig } from \"#/features/check-songs/index.ts\";\nimport { FumxLanguageMetaData } from \"#generated/langium/module.ts\";\n\ndeclare module \"vite\" {\n interface UserConfig {\n readonly fumx?: FumxConfig;\n }\n}\n\nconst [EXTENSION] = FumxLanguageMetaData.fileExtensions;\n\nconst failure = (mapped: Mapped): string =>\n Match.value(mapped).pipe(\n Match.discriminatorsExhaustive(\"status\")({\n ok: () => \"\",\n error: ({ issues }) =>\n pipe(\n issues,\n Arr.map((issue) => issue.message),\n Arr.join(\"\\n\"),\n ),\n }),\n );\n\nconst declarationOf = (content: string, mapped: Mapped): Option.Option<string> =>\n Match.value(mapped).pipe(\n Match.discriminatorsExhaustive(\"status\")({\n ok: ({ segments }) => Option.some(renderSegments({ content, segments })),\n error: () => Option.none(),\n }),\n );\n\nexport const fumx = (): Plugin =>\n contentImport({\n name: \"fumx\",\n extension: EXTENSION,\n load: ({ id, content, read }) =>\n Effect.gen(function* load() {\n const module = yield* songModuleOf({ path: id, content, read });\n const song = yield* Option.match(module.song, {\n onNone: () => Effect.die(new Error(failure(module.mapped))),\n onSome: Effect.succeed,\n });\n return {\n code: yield* songCodeOf(song),\n declaration: declarationOf(content, module.mapped),\n watchFiles: pipe(\n module.files,\n Arr.filter((file) => file !== id),\n ),\n };\n }),\n });\n"],"mappings":";;;;;;AAiCA,MAAM,eAAe;CACnB,SAAS;CACT,MAAM;CACN,aAAa;CACb,OAAO;CACP,QAAQ;CACR,SAAS;AACX;AAEA,MAAM,cAAc;AAEpB,MAAM,aAAa;AAEnB,MAAM,iBAAiB,MAAY,YACjC,OAAO,MAAM,QAAQ,OAAO;CAC1B,cAAc,CAAC,KAAK,OAAO,KAAK,KAAK,CAAC,CAAC;CACvC,S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AC3B,CAAC,CACH;AAEF,MAAa,aACX,cAAc;CACZ,MAAM;CACN,WAAW;CACX,OAAO,EAAE,IAAI,SAAS,WACpB,OAAO,IAAI,UAAU,OAAO;EAC1B,MAAM,SAAS,OAAO,aAAa;GAAE,MAAM;GAAI;GAAS;EAAK,CAAC;EAC9D,MAAM,OAAO,OAAO,OAAO,MAAM,OAAO,MAAM;GAC5C,cAAc,OAAO,IAAI,IAAI,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;GAC1D,QAAQ,OAAO;EACjB,CAAC;EACD,OAAO;GACL,MAAM,OAAO,WAAW,IAAI;GAC5B,aAAa,cAAc,SAAS,OAAO,MAAM;GACjD,YAAY,KACV,OAAO,OACPA,MAAI,QAAQ,SAAS,SAAS,EAAE,CAClC;EACF;CACF,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/fumx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Everything for .fumx songs: read a song as a typed value, analyze its keys and chords, import it from TypeScript with Vite, edit it with a language server, convert MIDI and Ableton Live Sets with a check against the original, and lint musical rules such as notes outside the key, part ranges and parallel fifths from vite.config.ts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fumx",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@effect/platform-node-shared": "4.2.0",
|
|
75
75
|
"@effect/vitest": "4.2.0",
|
|
76
76
|
"@masseater.dev/lint-host": "0.0.0",
|
|
77
|
-
"@r_masseater/fumx": "0.1.
|
|
77
|
+
"@r_masseater/fumx": "0.1.2",
|
|
78
78
|
"@types/node": "26.6.11",
|
|
79
79
|
"effect": "4.2.0",
|
|
80
80
|
"langium-cli": "4.4.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform-CeFBPHqb.mjs","names":["Arr","Rec"],"sources":["../src/features/build-song-module/model/song-module.ts","../src/app/transform.ts"],"sourcesContent":["import { nameLiteral, quoted, text } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Segment } from \"@r_masseater/masseater-utils/mapped-import\";\nimport type { Issue, Mapped } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\n\nimport { SongSchema } from \"#/entities/song/index.ts\";\nimport type { Song } from \"#/entities/song/index.ts\";\nimport { readSong } from \"#/features/read-song/@x/build-song-module.ts\";\nimport type {\n Named,\n Outline,\n SongSource,\n SourceIssue,\n} from \"#/features/read-song/@x/build-song-module.ts\";\n\nexport interface SongModuleSource<Failure> {\n readonly path: string;\n readonly content: string;\n readonly read: (path: string) => Effect.Effect<string, Failure>;\n}\n\nexport interface SongModule {\n readonly mapped: Mapped;\n readonly song: Option.Option<Song>;\n readonly files: readonly string[];\n}\n\ntype NamedField = {\n readonly [Field in keyof Song]: Song[Field] extends readonly { readonly name: string }[]\n ? Field\n : never;\n}[keyof Song];\n\nconst NAMED_FIELDS = {\n samples: \"Sample\",\n kits: \"Kit\",\n instruments: \"Instrument\",\n buses: \"Bus\",\n tracks: \"Track\",\n plugins: \"Plugin\",\n} as const satisfies Readonly<Record<NamedField, Named[\"$type\"]>>;\n\nconst SONG_MODULE = \"#/app/index.ts\";\n\nconst NEVER_SONG = \"export declare const song: never;\\n\";\n\nconst titleSegments = (song: Song, outline: Outline): readonly Segment[] =>\n Option.match(outline.title, {\n onNone: () => [text(quoted(song.title))],\n onSome: ({ start, end }): readonly Segment[] => [\n { kind: \"alias\", text: quoted(song.title), start, end },\n ],\n });\n\nconst fieldSegments =\n (song: Song, outline: Outline) =>\n ([field, type]: readonly [NamedField, Named[\"$type\"]]): readonly Segment[] => [\n text(` readonly ${field}: readonly [\\n`),\n ...pipe(\n song[field],\n Arr.flatMap(({ name }) => [\n text(` Song[\"${field}\"][number] & { readonly name: `),\n ...nameLiteral({\n name,\n span: pipe(\n outline.names,\n Arr.findFirst((found) => found.type === type && found.name === name),\n Option.map((found) => found.span),\n ),\n }),\n text(\" },\\n\"),\n ]),\n ),\n text(\" ];\\n\"),\n ];\n\nconst segmentsOf = (song: Song, outline: Outline): readonly Segment[] => [\n text(`import type { Song } from \"${SONG_MODULE}\";\\n`),\n text(\"export declare const song: Song & {\\n readonly title: \"),\n ...titleSegments(song, outline),\n text(\";\\n\"),\n ...pipe(Rec.toEntries(NAMED_FIELDS), Arr.flatMap(fieldSegments(song, outline))),\n text(\"};\\n\"),\n];\n\nconst issueOf =\n ({ path, outline }: Readonly<{ path: string; outline: Outline }>) =>\n (issue: SourceIssue): Issue => {\n if (issue.path === path) {\n return { message: issue.message, start: issue.start, end: issue.end };\n }\n const at = pipe(\n outline.imports,\n Arr.findFirst((found) => found.path === issue.path),\n Option.map((found) => found.span),\n Option.getOrElse(() => ({ start: 0, end: 0 })),\n );\n return {\n message: `${issue.path}:${String(issue.line)}:${String(issue.column)} ${issue.message}`,\n ...at,\n };\n };\n\nconst moduleOf =\n (path: string) =>\n (source: SongSource): SongModule => {\n if (source.status === \"invalid\") {\n return {\n mapped: {\n status: \"error\",\n fallback: NEVER_SONG,\n issues: pipe(source.issues, Arr.map(issueOf({ path, outline: source.outline }))),\n },\n song: Option.none(),\n files: source.outline.files,\n };\n }\n return {\n mapped: { status: \"ok\", segments: segmentsOf(source.song, source.outline) },\n song: Option.some(source.song),\n files: source.outline.files,\n };\n };\n\nexport const songModuleOf = <Failure>({\n path,\n content,\n read,\n}: SongModuleSource<Failure>): Effect.Effect<SongModule> =>\n readSong({\n path,\n read: (target) => {\n if (target === path) {\n return Effect.succeed(content);\n }\n return read(target);\n },\n }).pipe(Effect.map(moduleOf(path)));\n\nconst encodeSong = Schema.encodeEffect(Schema.fromJsonString(SongSchema));\n\nexport const songCodeOf = (song: Song): Effect.Effect<string> =>\n encodeSong(song).pipe(\n Effect.orDie,\n Effect.map(\n (json) =>\n `import { Schema } from \"effect\";\\nimport { SongSchema } from \"${SONG_MODULE}\";\\nexport const song = Schema.decodeSync(Schema.fromJsonString(SongSchema))(${quoted(json)});\\n`,\n ),\n );\n","import { NodeFileSystem } from \"@effect/platform-node-shared\";\nimport { mappedOutput } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport type { Request } from \"@r_masseater/masseater-utils/mapped-import/mapper\";\nimport { Effect, FileSystem, ManagedRuntime } from \"effect\";\nimport type { TransformResult } from \"ts-content-mapper\";\n\nimport { songModuleOf } from \"#/features/build-song-module/index.ts\";\n\nconst transformSong = Effect.fn(\"transformSong\")(function* transformSong(request: Request) {\n const fileSystem = yield* FileSystem.FileSystem;\n const { mapped } = yield* songModuleOf({\n path: request.fileName,\n content: request.content,\n read: (path) => fileSystem.readFileString(path),\n });\n return mappedOutput({ request, mapped });\n});\n\nconst runtime = ManagedRuntime.make(NodeFileSystem.layer);\n\nexport const transform = (request: Request): Promise<TransformResult> =>\n runtime.runPromise(transformSong(request));\n"],"mappings":";;;;;;AAiCA,MAAM,eAAe;CACnB,SAAS;CACT,MAAM;CACN,aAAa;CACb,OAAO;CACP,QAAQ;CACR,SAAS;AACX;AAEA,MAAM,cAAc;AAEpB,MAAM,aAAa;AAEnB,MAAM,iBAAiB,MAAY,YACjC,OAAO,MAAM,QAAQ,OAAO;CAC1B,cAAc,CAAC,KAAK,OAAO,KAAK,KAAK,CAAC,CAAC;CACvC,SAAS,EAAE,OAAO,UAA8B,CAC9C;EAAE,MAAM;EAAS,MAAM,OAAO,KAAK,KAAK;EAAG;EAAO;CAAI,CACxD;AACF,CAAC;AAEH,MAAM,iBACH,MAAY,aACZ,CAAC,OAAO,UAAqE;CAC5E,KAAK,cAAc,MAAM,eAAe;CACxC,GAAG,KACD,KAAK,QACLA,MAAI,SAAS,EAAE,WAAW;EACxB,KAAK,aAAa,MAAM,+BAA+B;EACvD,GAAG,YAAY;GACb;GACA,MAAM,KACJ,QAAQ,OACRA,MAAI,WAAW,UAAU,MAAM,SAAS,QAAQ,MAAM,SAAS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