@r_masseater/song-format 0.1.0 → 0.2.0
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/README.md +33 -1
- package/dist/analysis.d.mts +95 -0
- package/dist/analysis.mjs +328 -0
- package/dist/analysis.mjs.map +1 -0
- package/dist/convert-als.d.mts +18 -0
- package/dist/convert-als.mjs +504 -0
- package/dist/convert-als.mjs.map +1 -0
- package/dist/convert-midi.d.mts +2 -75
- package/dist/convert-midi.mjs +5 -650
- package/dist/convert-midi.mjs.map +1 -1
- package/dist/fumx-language-server.mjs +1 -1
- package/dist/fumx-language-server.mjs.map +1 -1
- package/dist/fumx-module-CmHFC-eI.mjs +12513 -0
- package/dist/fumx-module-CmHFC-eI.mjs.map +1 -0
- package/dist/fumx-module-DJQrnEVm.mjs +2660 -0
- package/dist/fumx-module-DJQrnEVm.mjs.map +1 -0
- package/dist/grammar-86_uhiTo.mjs +9836 -0
- package/dist/grammar-86_uhiTo.mjs.map +1 -0
- package/dist/index-Cup9xTad.d.mts +105 -0
- package/dist/index-DPt8MZ6e.d.mts +796 -0
- package/dist/index-JXjnMHXw.d.mts +1350 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +4 -0
- package/dist/language.d.mts +13 -0
- package/dist/language.mjs +3 -0
- package/dist/mapper.mjs +1 -1
- package/dist/midi-to-fumx.mjs +140 -45
- package/dist/midi-to-fumx.mjs.map +1 -1
- package/dist/read-song-CNrfcHrY.mjs +123 -0
- package/dist/read-song-CNrfcHrY.mjs.map +1 -0
- package/dist/read-song-CSIhaAEB.mjs +122 -0
- package/dist/read-song-CSIhaAEB.mjs.map +1 -0
- package/dist/run-main-Bf32CgzU.mjs +26 -0
- package/dist/run-main-Bf32CgzU.mjs.map +1 -0
- package/dist/song-3Zm9g84K.d.mts +1478 -0
- package/dist/song-CYFBSTbH.mjs +387 -0
- package/dist/song-CYFBSTbH.mjs.map +1 -0
- package/dist/song-report.mjs +327 -4
- package/dist/song-report.mjs.map +1 -1
- package/dist/ticks-CXehHP2w.mjs +27 -0
- package/dist/ticks-CXehHP2w.mjs.map +1 -0
- package/dist/transform-DQm5wTlA.mjs +489 -0
- package/dist/transform-DQm5wTlA.mjs.map +1 -0
- package/dist/vite.mjs +4 -3
- package/dist/vite.mjs.map +1 -1
- package/dist/write-CS-ZjoQB.mjs +746 -0
- package/dist/write-CS-ZjoQB.mjs.map +1 -0
- package/package.json +50 -8
- package/skills/read-fumx/SKILL.md +86 -0
- package/skills/use-fumx-tools/SKILL.md +1 -1
- package/dist/app-CdpGdiWq.mjs +0 -190
- package/dist/app-CdpGdiWq.mjs.map +0 -1
- package/dist/transform-C24h3upp.mjs +0 -108
- package/dist/transform-C24h3upp.mjs.map +0 -1
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Array, Effect, FileSystem, ManagedRuntime, Option, Record, Schema, pipe } from "effect";
|
|
2
|
-
import { SongSchema, readSong } from "@r_masseater/fumx-parser";
|
|
3
|
-
import { NodeFileSystem } from "@effect/platform-node-shared";
|
|
4
|
-
import { mappedOutput } from "@r_masseater/mapped-import/mapper";
|
|
5
|
-
import { nameLiteral, quoted, text } from "@r_masseater/mapped-import";
|
|
6
|
-
// src/features/build-song-module/model/song-module.ts
|
|
7
|
-
const NAMED_FIELDS = {
|
|
8
|
-
samples: "Sample",
|
|
9
|
-
kits: "Kit",
|
|
10
|
-
instruments: "Instrument",
|
|
11
|
-
buses: "Bus",
|
|
12
|
-
tracks: "Track",
|
|
13
|
-
plugins: "Plugin"
|
|
14
|
-
};
|
|
15
|
-
const SONG_MODULE = "@r_masseater/fumx-parser";
|
|
16
|
-
const NEVER_SONG = "export declare const song: never;\n";
|
|
17
|
-
const titleSegments = (song, outline) => Option.match(outline.title, {
|
|
18
|
-
onNone: () => [text(quoted(song.title))],
|
|
19
|
-
onSome: ({ start, end }) => [{
|
|
20
|
-
kind: "alias",
|
|
21
|
-
text: quoted(song.title),
|
|
22
|
-
start,
|
|
23
|
-
end
|
|
24
|
-
}]
|
|
25
|
-
});
|
|
26
|
-
const fieldSegments = (song, outline) => ([field, type]) => [
|
|
27
|
-
text(` readonly ${field}: readonly [\n`),
|
|
28
|
-
...pipe(song[field], Array.flatMap(({ name }) => [
|
|
29
|
-
text(` Song["${field}"][number] & { readonly name: `),
|
|
30
|
-
...nameLiteral({
|
|
31
|
-
name,
|
|
32
|
-
span: pipe(outline.names, Array.findFirst((found) => found.type === type && found.name === name), Option.map((found) => found.span))
|
|
33
|
-
}),
|
|
34
|
-
text(" },\n")
|
|
35
|
-
])),
|
|
36
|
-
text(" ];\n")
|
|
37
|
-
];
|
|
38
|
-
const segmentsOf = (song, outline) => [
|
|
39
|
-
text(`import type { Song } from "${SONG_MODULE}";\n`),
|
|
40
|
-
text("export declare const song: Song & {\n readonly title: "),
|
|
41
|
-
...titleSegments(song, outline),
|
|
42
|
-
text(";\n"),
|
|
43
|
-
...pipe(Record.toEntries(NAMED_FIELDS), Array.flatMap(fieldSegments(song, outline))),
|
|
44
|
-
text("};\n")
|
|
45
|
-
];
|
|
46
|
-
const issueOf = ({ path, outline }) => (issue) => {
|
|
47
|
-
if (issue.path === path) return {
|
|
48
|
-
message: issue.message,
|
|
49
|
-
start: issue.start,
|
|
50
|
-
end: issue.end
|
|
51
|
-
};
|
|
52
|
-
const at = pipe(outline.imports, Array.findFirst((found) => found.path === issue.path), Option.map((found) => found.span), Option.getOrElse(() => ({
|
|
53
|
-
start: 0,
|
|
54
|
-
end: 0
|
|
55
|
-
})));
|
|
56
|
-
return {
|
|
57
|
-
message: `${issue.path}:${String(issue.line)}:${String(issue.column)} ${issue.message}`,
|
|
58
|
-
...at
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
const moduleOf = (path) => (source) => {
|
|
62
|
-
if (source.status === "invalid") return {
|
|
63
|
-
mapped: {
|
|
64
|
-
status: "error",
|
|
65
|
-
fallback: NEVER_SONG,
|
|
66
|
-
issues: pipe(source.issues, Array.map(issueOf({
|
|
67
|
-
path,
|
|
68
|
-
outline: source.outline
|
|
69
|
-
})))
|
|
70
|
-
},
|
|
71
|
-
song: Option.none(),
|
|
72
|
-
files: source.outline.files
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
mapped: {
|
|
76
|
-
status: "ok",
|
|
77
|
-
segments: segmentsOf(source.song, source.outline)
|
|
78
|
-
},
|
|
79
|
-
song: Option.some(source.song),
|
|
80
|
-
files: source.outline.files
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
const songModuleOf = ({ path, content, read }) => readSong({
|
|
84
|
-
path,
|
|
85
|
-
read: (target) => {
|
|
86
|
-
if (target === path) return Effect.succeed(content);
|
|
87
|
-
return read(target);
|
|
88
|
-
}
|
|
89
|
-
}).pipe(Effect.map(moduleOf(path)));
|
|
90
|
-
Schema.encodeEffect(Schema.fromJsonString(SongSchema));
|
|
91
|
-
// src/app/transform.ts
|
|
92
|
-
const transformSong = Effect.fn("transformSong")(function* transformSong(request) {
|
|
93
|
-
const fileSystem = yield* FileSystem.FileSystem;
|
|
94
|
-
const { mapped } = yield* songModuleOf({
|
|
95
|
-
path: request.fileName,
|
|
96
|
-
content: request.content,
|
|
97
|
-
read: (path) => fileSystem.readFileString(path)
|
|
98
|
-
});
|
|
99
|
-
return mappedOutput({
|
|
100
|
-
request,
|
|
101
|
-
mapped
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
const runtime = ManagedRuntime.make(NodeFileSystem.layer);
|
|
105
|
-
const transform = (request) => runtime.runPromise(transformSong(request));
|
|
106
|
-
export { transform };
|
|
107
|
-
|
|
108
|
-
//# sourceMappingURL=transform-C24h3upp.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform-C24h3upp.mjs","names":["Arr","Rec"],"sources":["../src/features/build-song-module/model/song-module.ts","../src/app/transform.ts"],"sourcesContent":["import { SongSchema, readSong } from \"@r_masseater/fumx-parser\";\nimport type { Song, Named, Outline, SongSource, SourceIssue } from \"@r_masseater/fumx-parser\";\nimport { nameLiteral, quoted, text } from \"@r_masseater/mapped-import\";\nimport type { Segment } from \"@r_masseater/mapped-import\";\nimport type { Issue, Mapped } from \"@r_masseater/mapped-import/mapper\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, pipe } from \"effect\";\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-parser\";\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/mapped-import/mapper\";\nimport type { Request } from \"@r_masseater/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":";;;;;;AAyBA,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,IAAI,GACnE,OAAO,KAAK,UAAU,MAAM,IAAI,CAClC;EACF,CAAC;EACD,KAAK,OAAO;CACd,CAAC,CACH;CACA,KAAK,QAAQ;AACf;AAEF,MAAM,cAAc,MAAY,YAAyC;CACvE,KAAK,8BAA8B,YAAY,KAAK;CACpD,KAAK,yDAAyD;CAC9D,GAAG,cAA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