@r_masseater/song-format 0.2.0 → 0.2.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.
Files changed (40) hide show
  1. package/dist/als-to-fumx.mjs +525 -0
  2. package/dist/als-to-fumx.mjs.map +1 -0
  3. package/dist/convert-als.mjs +30 -22
  4. package/dist/convert-als.mjs.map +1 -1
  5. package/dist/convert-midi.mjs +1 -1
  6. package/dist/fumx-language-server.mjs +1 -1
  7. package/dist/{fumx-module-CmHFC-eI.mjs → fumx-module-BfH5pPUU.mjs} +63 -68
  8. package/dist/fumx-module-BfH5pPUU.mjs.map +1 -0
  9. package/dist/{fumx-module-DJQrnEVm.mjs → fumx-module-C1v5AGSG.mjs} +63 -68
  10. package/dist/fumx-module-C1v5AGSG.mjs.map +1 -0
  11. package/dist/index.mjs +1 -1
  12. package/dist/language.mjs +1 -1
  13. package/dist/mapper.mjs +1 -1
  14. package/dist/midi-to-fumx.mjs +10 -947
  15. package/dist/midi-to-fumx.mjs.map +1 -1
  16. package/dist/{run-main-Bf32CgzU.mjs → package-BhGdZERV.mjs} +4 -2
  17. package/dist/package-BhGdZERV.mjs.map +1 -0
  18. package/dist/{read-song-CNrfcHrY.mjs → read-song-CmIfnGfX.mjs} +11 -5
  19. package/dist/read-song-CmIfnGfX.mjs.map +1 -0
  20. package/dist/{read-song-CSIhaAEB.mjs → read-song-ypQjpC0y.mjs} +11 -5
  21. package/dist/read-song-ypQjpC0y.mjs.map +1 -0
  22. package/dist/round-trip-CIXCochn.mjs +946 -0
  23. package/dist/round-trip-CIXCochn.mjs.map +1 -0
  24. package/dist/song-report.mjs +4 -4
  25. package/dist/song-report.mjs.map +1 -1
  26. package/dist/transform-MqcJm-I-.mjs +109 -0
  27. package/dist/transform-MqcJm-I-.mjs.map +1 -0
  28. package/dist/vite.mjs +2 -2
  29. package/dist/{write-CS-ZjoQB.mjs → write-CuDbIkpM.mjs} +4 -3
  30. package/dist/{write-CS-ZjoQB.mjs.map → write-CuDbIkpM.mjs.map} +1 -1
  31. package/package.json +6 -11
  32. package/skills/read-fumx/SKILL.md +0 -1
  33. package/skills/use-fumx-tools/SKILL.md +0 -1
  34. package/dist/fumx-module-CmHFC-eI.mjs.map +0 -1
  35. package/dist/fumx-module-DJQrnEVm.mjs.map +0 -1
  36. package/dist/read-song-CNrfcHrY.mjs.map +0 -1
  37. package/dist/read-song-CSIhaAEB.mjs.map +0 -1
  38. package/dist/run-main-Bf32CgzU.mjs.map +0 -1
  39. package/dist/transform-DQm5wTlA.mjs +0 -489
  40. package/dist/transform-DQm5wTlA.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { $ as isWhile, A as isLet, B as isRepeat, C as isGateLength, D as isImportedSymbol, E as isImport, F as isPlayParam, G as isSong, H as isReturn, I as isPlugin, J as isTie, K as isSounding, L as isPluginEffect, M as isMaster, N as isNudge, O as isInstrument, P as isParam, Q as isVoiceLine, R as isPluginUse, S as isFor, T as isIf, U as isRole, V as isRest, W as isSample, X as isTypeRef, Y as isTrack, Z as isVelocity, _ as isEach, a as isAssign, b as isFade, c as isBend, d as isComputed, et as isWith, f as isControlHold, g as isDuck, h as isDelay, i as isArticulation, j as isLyric, k as isKit, l as isBinding, m as isDeclaration, n as FumxAstReflection, o as isAutomation, p as isControlLine, q as isTempoLine, s as isBar, t as FumxGrammar, u as isBus, v as isEvery, w as isGroove, x as isFn, y as isExpression, z as isReleaseVelocity } from "./grammar-86_uhiTo.mjs";
2
2
  import { a as groupsOf, i as ticksOf, n as fractionOf, r as partsOf, t as TICKS_PER_WHOLE } from "./ticks-CXehHP2w.mjs";
3
3
  import { Array, Match, Option, Predicate, Record, String as String$1, pipe } from "effect";
4
- import { AstUtils, DefaultScopeProvider, EmptyFileSystem, StreamScope, UriUtils, createDefaultCoreModule, createDefaultSharedCoreModule, inject, isReference } from "langium";
4
+ import { AstUtils, DefaultLexerErrorMessageProvider, DefaultScopeProvider, EmptyFileSystem, LangiumParserErrorMessageProvider, StreamScope, UriUtils, createDefaultCoreModule, createDefaultSharedCoreModule, inject, isReference } from "langium";
5
5
  import { Note } from "tonal";
6
6
  // generated/langium/module.ts
7
7
  const FumxLanguageMetaData = {
@@ -450,31 +450,20 @@ const moduleFor = (use) => (plugin) => {
450
450
  if (home.toString() === there.toString()) return plugin.module;
451
451
  return pathFrom(home)(there)(plugin.module);
452
452
  };
453
- const pluginValueOf = (value) => Match.value(value).pipe(Match.discriminatorsExhaustive("kind")({
454
- number: (number) => Option.some({
455
- kind: "number",
456
- value: number.value
457
- }),
458
- decibels: (amount) => Option.some({
459
- kind: "decibels",
460
- value: amount.value
461
- }),
453
+ const plain = (kind) => (amount) => Option.some({
454
+ kind,
455
+ value: amount.value
456
+ });
457
+ const pluginValueOf = (value) => Match.value(value).pipe(Match.discriminators("kind")({
458
+ number: plain("number"),
459
+ decibels: plain("decibels"),
460
+ hertz: plain("hertz"),
461
+ time: plain("milliseconds"),
462
+ semitones: plain("semitones"),
462
463
  percent: (amount) => Option.some({
463
464
  kind: "share",
464
465
  value: amount.value / HUNDRED
465
466
  }),
466
- hertz: (amount) => Option.some({
467
- kind: "hertz",
468
- value: amount.value
469
- }),
470
- time: (amount) => Option.some({
471
- kind: "milliseconds",
472
- value: amount.value
473
- }),
474
- semitones: (amount) => Option.some({
475
- kind: "semitones",
476
- value: amount.value
477
- }),
478
467
  duration: (duration) => Option.some({
479
468
  kind: "ticks",
480
469
  value: duration.ticks
@@ -491,10 +480,8 @@ const pluginValueOf = (value) => Match.value(value).pipe(Match.discriminatorsExh
491
480
  bool: (truth) => Option.some({
492
481
  kind: "flag",
493
482
  value: truth.value
494
- }),
495
- list: () => Option.none(),
496
- none: () => Option.none()
497
- }));
483
+ })
484
+ }), Match.orElse(() => Option.none()));
498
485
  const typedValueOf = ([param, literal]) => {
499
486
  const wanted = scalar(param.type.name);
500
487
  const read = literalValue(literal);
@@ -1621,20 +1608,10 @@ const ok = (value) => ({
1621
1608
  ok: true,
1622
1609
  value
1623
1610
  });
1624
- const amountOf = (value) => Match.value(value).pipe(Match.discriminatorsExhaustive("kind")({
1611
+ const amountOf = (value) => Match.value(value).pipe(Match.discriminators("kind")({
1625
1612
  duration: (duration) => duration.ticks,
1626
- pitch: (pitch) => pitch.midi + pitch.cents / CENTS,
1627
- number: (number) => number.value,
1628
- decibels: (amount) => amount.value,
1629
- percent: (amount) => amount.value,
1630
- hertz: (amount) => amount.value,
1631
- time: (amount) => amount.value,
1632
- semitones: (amount) => amount.value,
1633
- string: () => NaN,
1634
- bool: () => NaN,
1635
- list: () => NaN,
1636
- none: () => NaN
1637
- }));
1613
+ pitch: (pitch) => pitch.midi + pitch.cents / CENTS
1614
+ }), Match.when({ value: Match.number }, (amount) => amount.value), Match.orElse(() => NaN));
1638
1615
  const ARITHMETIC = {
1639
1616
  "+": ([left, right]) => left + right,
1640
1617
  "-": ([left, right]) => left - right,
@@ -1692,6 +1669,10 @@ const scalarOf = (type) => {
1692
1669
  if (type.kind === "list" || type.kind === "unknown") return Option.none();
1693
1670
  return Option.some(type.kind);
1694
1671
  };
1672
+ const boolRule = (holds) => ({
1673
+ result: scalar("bool"),
1674
+ apply: (pair) => ok(boolValue(holds(pair)))
1675
+ });
1695
1676
  const ruled = (kind) => (operator) => ({
1696
1677
  result: scalar(kind),
1697
1678
  apply: numeric(operator)(kind)
@@ -1734,29 +1715,17 @@ const joinRule = ({ operator, left, right }) => {
1734
1715
  const equalityRule = ({ operator, left, right }) => {
1735
1716
  if (operator !== "==" && operator !== "!=" || !fits(left)(right)) return Option.none();
1736
1717
  const wanted = operator === "==";
1737
- return Option.some({
1738
- result: scalar("bool"),
1739
- apply: ({ left: first, right: second }) => ok(boolValue(sameValue(first)(second) === wanted))
1740
- });
1718
+ return Option.some(boolRule(({ left: first, right: second }) => sameValue(first)(second) === wanted));
1741
1719
  };
1742
- const orderRule = ({ operator, left, right }) => pipe(Option.fromNullishOr(COMPARE[operator]), Option.filter(() => left.kind === right.kind && Array.contains([...COUNTABLE, "pitch"], left.kind)), Option.map((compare) => ({
1743
- result: scalar("bool"),
1744
- apply: ({ left: first, right: second }) => {
1745
- const holds = compare([amountOf(first), amountOf(second)]);
1746
- return ok(boolValue(holds));
1747
- }
1748
- })));
1720
+ const orderRule = ({ operator, left, right }) => pipe(Option.fromNullishOr(COMPARE[operator]), Option.filter(() => left.kind === right.kind && Array.contains([...COUNTABLE, "pitch"], left.kind)), Option.map((compare) => boolRule(({ left: first, right: second }) => compare([amountOf(first), amountOf(second)]))));
1749
1721
  const truthOf = (value) => value.kind === "bool" && value.value;
1750
1722
  const logicRule = ({ operator, left, right }) => {
1751
1723
  if (operator !== "and" && operator !== "or" || left.kind !== "bool" || right.kind !== "bool") return Option.none();
1752
1724
  const both = operator === "and";
1753
- return Option.some({
1754
- result: scalar("bool"),
1755
- apply: ({ left: first, right: second }) => {
1756
- if (both) return ok(boolValue(truthOf(first) && truthOf(second)));
1757
- return ok(boolValue(truthOf(first) || truthOf(second)));
1758
- }
1759
- });
1725
+ return Option.some(boolRule(({ left: first, right: second }) => {
1726
+ if (both) return truthOf(first) && truthOf(second);
1727
+ return truthOf(first) || truthOf(second);
1728
+ }));
1760
1729
  };
1761
1730
  const RULES = [
1762
1731
  additiveRule,
@@ -1978,15 +1947,18 @@ const computeType = (context) => (node) => Match.value(node).pipe(Match.discrimi
1978
1947
  Index: indexType(context),
1979
1948
  Binary: binaryType(context)
1980
1949
  }));
1981
- const declaredType = (context) => (binding) => Match.value(binding).pipe(Match.discriminatorsExhaustive("$type")({
1982
- Param: (param) => typeOfRef(param.type),
1983
- Let: (node) => pipe(Option.fromNullishOr(node.type), Option.match({
1984
- onNone: () => context.typeOf(node.value),
1985
- onSome: (type) => typeOfRef(type)
1986
- })),
1987
- For: (node) => pipe(elementOf(context.typeOf(node.items)), Option.getOrElse(() => UNKNOWN$1)),
1988
- Each: (node) => pipe(elementOf(context.typeOf(node.items)), Option.getOrElse(() => UNKNOWN$1))
1989
- }));
1950
+ const declaredType = (context) => {
1951
+ const element = (items) => pipe(elementOf(context.typeOf(items)), Option.getOrElse(() => UNKNOWN$1));
1952
+ return (binding) => Match.value(binding).pipe(Match.discriminatorsExhaustive("$type")({
1953
+ Param: (param) => typeOfRef(param.type),
1954
+ Let: (node) => pipe(Option.fromNullishOr(node.type), Option.match({
1955
+ onNone: () => context.typeOf(node.value),
1956
+ onSome: (type) => typeOfRef(type)
1957
+ })),
1958
+ For: (node) => element(node.items),
1959
+ Each: (node) => element(node.items)
1960
+ }));
1961
+ };
1990
1962
  const checkerFor = (problems) => {
1991
1963
  const memo = /* @__PURE__ */ new Map();
1992
1964
  const visiting = /* @__PURE__ */ new Set();
@@ -2633,6 +2605,29 @@ const compileSong = (song) => {
2633
2605
  ]
2634
2606
  };
2635
2607
  };
2608
+ // src/features/read-song/model/syntax-messages.ts
2609
+ const unexpected = (actual) => pipe(Array.head(actual), Option.map((token) => token.image), Option.filter(String$1.isNonEmpty), Option.match({
2610
+ onNone: () => "Unexpected end of file.",
2611
+ onSome: (image) => `Unexpected \`${image}\`.`
2612
+ }));
2613
+ const SyntaxMessagesModule = { parser: {
2614
+ ParserErrorMessageProvider: () => {
2615
+ const langium = new LangiumParserErrorMessageProvider();
2616
+ return {
2617
+ buildMismatchTokenMessage: (options) => langium.buildMismatchTokenMessage(options),
2618
+ buildNotAllInputParsedMessage: (options) => langium.buildNotAllInputParsedMessage(options),
2619
+ buildNoViableAltMessage: ({ actual }) => unexpected(actual),
2620
+ buildEarlyExitMessage: ({ actual }) => unexpected(actual)
2621
+ };
2622
+ },
2623
+ LexerErrorMessageProvider: () => {
2624
+ const langium = new DefaultLexerErrorMessageProvider();
2625
+ return {
2626
+ buildUnexpectedCharactersMessage: (fullText, startOffset, length) => `Unexpected character \`${String$1.slice(startOffset, startOffset + length)(fullText)}\`.`,
2627
+ buildUnableToPopLexerModeMessage: (token) => langium.buildUnableToPopLexerModeMessage(token)
2628
+ };
2629
+ }
2630
+ } };
2636
2631
  // src/features/read-song/model/fumx-module.ts
2637
2632
  const FumxModule = { references: { ScopeProvider: scopeProviderOf } };
2638
2633
  const registerChecks = (fumx) => {
@@ -2647,7 +2642,7 @@ const registerChecks = (fumx) => {
2647
2642
  };
2648
2643
  const createFumxServices = () => {
2649
2644
  const shared = inject(createDefaultSharedCoreModule(EmptyFileSystem), FumxGeneratedSharedModule);
2650
- const fumx = inject(createDefaultCoreModule({ shared }), FumxGeneratedModule, FumxModule);
2645
+ const fumx = inject(createDefaultCoreModule({ shared }), FumxGeneratedModule, FumxModule, SyntaxMessagesModule);
2651
2646
  shared.ServiceRegistry.register(fumx);
2652
2647
  registerChecks(fumx);
2653
2648
  return {
@@ -2657,4 +2652,4 @@ const createFumxServices = () => {
2657
2652
  };
2658
2653
  export { importedUriOf as a, FumxGeneratedSharedModule as c, compileSong as i, FumxLanguageMetaData as l, createFumxServices as n, isNamed as o, registerChecks as r, FumxGeneratedModule as s, FumxModule as t };
2659
2654
 
2660
- //# sourceMappingURL=fumx-module-DJQrnEVm.mjs.map
2655
+ //# sourceMappingURL=fumx-module-C1v5AGSG.mjs.map