guidex 0.2.5 → 0.3.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.
Files changed (46) hide show
  1. package/README.md +239 -3
  2. package/dist/lib/app/ControlsRow.d.ts +1 -0
  3. package/dist/lib/app/Editor.d.ts +1 -0
  4. package/dist/lib/app/EditorContext.d.ts +17 -0
  5. package/dist/lib/app/EditorTextarea.d.ts +1 -0
  6. package/dist/lib/app/ExportSettings.d.ts +1 -0
  7. package/dist/lib/app/FeedbackSpan.d.ts +5 -0
  8. package/dist/lib/app/RenderSettings.d.ts +1 -0
  9. package/dist/lib/app/SamplesRow.d.ts +1 -0
  10. package/dist/lib/app/SettingsMenu.d.ts +1 -0
  11. package/dist/lib/app/SettingsPanel.d.ts +1 -0
  12. package/dist/lib/app/SyllablesTable.d.ts +1 -0
  13. package/dist/lib/app/WordCheckPanel.d.ts +1 -0
  14. package/dist/lib/app/WordCopyControls.d.ts +1 -0
  15. package/dist/lib/app/chantLibrary.d.ts +11 -0
  16. package/dist/lib/app/editorState.d.ts +159 -0
  17. package/dist/lib/app/samples.d.ts +10 -0
  18. package/dist/lib/app/wordCopy.d.ts +30 -0
  19. package/dist/lib/chantLayout-GAfg2iKS.js +1042 -0
  20. package/dist/lib/chantLayout.d.ts +169 -0
  21. package/dist/lib/chantMarkup.d.ts +36 -0
  22. package/dist/lib/editorStorage.d.ts +179 -0
  23. package/dist/lib/embed/index.d.ts +1 -0
  24. package/dist/lib/embed/index.js +2 -2
  25. package/dist/lib/embed/manual.d.ts +19 -1
  26. package/dist/lib/embed/manual.js +43 -2
  27. package/dist/lib/guidoRender.d.ts +22 -29
  28. package/dist/lib/guidoScript.d.ts +31 -3
  29. package/dist/lib/guidoScriptTransforms.d.ts +5 -4
  30. package/dist/lib/guidoStyles.d.ts +23 -5
  31. package/dist/lib/main.d.ts +0 -1
  32. package/dist/lib/react/GuidexScore.d.ts +1 -1
  33. package/dist/lib/react/index.d.ts +1 -0
  34. package/dist/lib/react/index.js +2 -2
  35. package/dist/lib/scoreImage-DnFIbtF_.js +951 -0
  36. package/dist/lib/scoreImage.d.ts +63 -0
  37. package/dist/lib/word/index.d.ts +17 -0
  38. package/dist/lib/word/index.js +2 -0
  39. package/dist/lib/wordChecker-C3nJrk_j.js +1042 -0
  40. package/dist/lib/wordChecker.d.ts +66 -0
  41. package/dist/lib/wordClipboard.d.ts +25 -0
  42. package/dist/lib/wordExport.d.ts +244 -0
  43. package/dist-embed/guidex-embed.min.js +1 -1
  44. package/package.json +8 -1
  45. package/dist/lib/core-CmzGmufM.js +0 -1262
  46. package/dist/lib/settingsMenu.d.ts +0 -1
@@ -0,0 +1,1042 @@
1
+ //#region src/guidoScript.ts
2
+ /** Whether a group's content is a control statement (`@`-keyword,
3
+ * trimmed). Shared with the transforms, which must leave statement
4
+ * groups alone — their keyword characters are pitch glyphs otherwise. */
5
+ function isStatementGroup(content) {
6
+ return content.trim().startsWith("@");
7
+ }
8
+ var GuidoScript = class {
9
+ source;
10
+ constructor(source, options = {}) {
11
+ this.source = (options.transforms ?? []).reduce((script, transform) => transform.apply(script), source);
12
+ }
13
+ /** The starting clef and note modifiers, or undefined when absent.
14
+ * A leading statement group is not a clef. */
15
+ get clef() {
16
+ const match = this.normalized.match(/^\s*\(([^)]*)\)/);
17
+ if (!match || isStatementGroup(match[1])) return void 0;
18
+ return match[1];
19
+ }
20
+ /** The script's tokens in source order: syllables interleaved with
21
+ * control statements. Throws on a malformed statement (syllable text
22
+ * attached to one, or an unknown `@` keyword). */
23
+ get tokens() {
24
+ const script = this.normalized;
25
+ const head = script.match(/^\s*\(([^)]*)\)/);
26
+ const tokens = [...(head && !isStatementGroup(head[1]) ? script.slice(head[0].length) : script).matchAll(/((?:[^()\\]|\\.)*)\(((?:[^)\\]|\\.)*)\)/g)].map(([, text, notes]) => {
27
+ if (isStatementGroup(notes)) {
28
+ const keyword = notes.trim();
29
+ if (keyword !== "@break") throw new Error(`Unknown statement "${keyword}"`);
30
+ if (text.trim() !== "") throw new Error(`statement must not carry syllable text: "${unescape(text.trim())}"`);
31
+ return {
32
+ kind: "break",
33
+ spaceBefore: /^\s/.test(text)
34
+ };
35
+ }
36
+ return {
37
+ kind: "syllable",
38
+ text: unescape(text.trim()),
39
+ notes: unescape(notes),
40
+ spaceBefore: /^\s/.test(text)
41
+ };
42
+ });
43
+ const lastSyllable = tokens.reduce((last, t, i) => t.kind === "syllable" ? i : last, -1);
44
+ for (const [i, t] of tokens.entries()) {
45
+ if (t.kind !== "syllable") continue;
46
+ t.wordEnd = i === lastSyllable;
47
+ for (let j = i + 1; !t.wordEnd && j < tokens.length; j++) {
48
+ const tok = tokens[j];
49
+ if (tok.spaceBefore) t.wordEnd = true;
50
+ if (tok.kind === "syllable") break;
51
+ }
52
+ }
53
+ return tokens;
54
+ }
55
+ /** The script broken into syllables, each with its sung text and
56
+ * notes — the syllable tokens, statements filtered out. */
57
+ get syllables() {
58
+ return this.tokens.filter((t) => t.kind === "syllable").map(({ text, notes, wordEnd }) => ({
59
+ text,
60
+ notes,
61
+ wordEnd
62
+ }));
63
+ }
64
+ /**
65
+ * The source with the typing conveniences folded in, so the parser
66
+ * itself only ever sees complete scripts:
67
+ *
68
+ * - an unclosed parenthesis is closed at the end, so the notes typed
69
+ * so far already preview on the score;
70
+ * - a trailing syllable with no note group gets an empty one, so it
71
+ * renders like a `*()` syllable (text without notes width).
72
+ */
73
+ get normalized() {
74
+ let script = this.source;
75
+ if ((script.match(/(^|[^\\])\(/g) ?? []).length > (script.match(/(^|[^\\])\)/g) ?? []).length) script += ")";
76
+ if (!/(^|[^\\])\)$/.test(script)) script += "()";
77
+ return script;
78
+ }
79
+ /** The syllables grouped into the words of the text. */
80
+ get words() {
81
+ const words = [];
82
+ let word;
83
+ for (const syl of this.syllables) {
84
+ word ??= {
85
+ text: "",
86
+ syllables: []
87
+ };
88
+ word.syllables.push({
89
+ text: syl.text,
90
+ notes: syl.notes
91
+ });
92
+ word.text = word.syllables.map((s) => s.text).join("");
93
+ if (syl.wordEnd) {
94
+ words.push(word);
95
+ word = void 0;
96
+ }
97
+ }
98
+ return words;
99
+ }
100
+ /** The script rebuilt from the parsed pieces — a round-trip of the
101
+ * source, statements included. */
102
+ toString() {
103
+ const parts = this.tokens.map((tok, i) => {
104
+ const prefix = i > 0 && tok.spaceBefore ? " " : "";
105
+ return tok.kind === "break" ? `${prefix}(@break)` : `${prefix}${escape(tok.text)}(${escape(tok.notes)})`;
106
+ });
107
+ return `${this.clef !== void 0 ? `(${this.clef})` : ""}${parts.join("")}`;
108
+ }
109
+ };
110
+ /** The sung text of the script: the clef stripped, syllables joined
111
+ * into words, and the words joined with single spaces. */
112
+ function chantText(script) {
113
+ return new GuidoScript(script).words.map((word) => word.text).join(" ");
114
+ }
115
+ /** Folds backslash escapes into the characters they stand for. Shared
116
+ * with the transforms module (guidoScriptTransforms.ts). */
117
+ function unescape(text) {
118
+ return text.replace(/\\(.)/g, "$1");
119
+ }
120
+ /** Turns literal parentheses and backslashes into their escape sequences. */
121
+ function escape(text) {
122
+ return text.replace(/\\/g, "\\\\").replace(/[()]/g, (ch) => `\\${ch}`);
123
+ }
124
+ //#endregion
125
+ //#region src/guidoScriptTransforms.ts
126
+ /**
127
+ * Source-level transformations for GuidoScript: named rewrites applied
128
+ * to a script's raw source before parsing (see the `transforms` option
129
+ * on the GuidoScript constructor). Each one receives the source and
130
+ * returns the rewritten source — or the source unchanged when the
131
+ * feature does not apply. They compose in registration order, and the
132
+ * parsed script never sees which ones ran. New script-level features
133
+ * are added here, and only here: as entries of SCRIPT_TRANSFORMS, or —
134
+ * when the feature takes parameters — as factories returning a
135
+ * ScriptTransform (see `transposeBy`).
136
+ */
137
+ /** The first character unit of a text run: a backslash escape pair or a
138
+ * single character, skipping leading whitespace. Returns null when the
139
+ * run has no characters to mark. */
140
+ function firstCharUnit(text) {
141
+ const chars = [...text];
142
+ for (let i = 0; i < chars.length; i++) {
143
+ const ch = chars[i];
144
+ if (/\s/.test(ch)) continue;
145
+ return {
146
+ unit: ch === "\\" && chars[i + 1] !== void 0 ? ch + chars[i + 1] : ch,
147
+ index: i
148
+ };
149
+ }
150
+ return null;
151
+ }
152
+ /** The `startWithInitial` transform: finds the first syllable group with
153
+ * actual notes (the clef, no-notes groups, and control statements don't
154
+ * count) and wraps the syllable's first character in the `*…*` initial
155
+ * marker. Already-marked text (leading `*`) and syllables without text
156
+ * are left alone. */
157
+ function startWithInitial(source) {
158
+ const clefMatch = source.match(/^\s*\(([^)]*)\)/);
159
+ const offset = clefMatch ? clefMatch[0].length : 0;
160
+ const rest = source.slice(offset);
161
+ for (const match of rest.matchAll(/((?:[^()\\]|\\.)*)\(((?:[^)\\]|\\.)*)\)/g)) {
162
+ const [, text, notes] = match;
163
+ if (unescape(notes).trim().length === 0) continue;
164
+ if (isStatementGroup(notes)) continue;
165
+ const unit = firstCharUnit(text);
166
+ if (!unit || text.trimStart().startsWith("*")) return source;
167
+ const unitStart = offset + match.index + unit.index;
168
+ const unitEnd = unitStart + unit.unit.length;
169
+ return `${source.slice(0, unitStart)}*${source.slice(unitStart, unitEnd)}*${source.slice(unitEnd)}`;
170
+ }
171
+ return source;
172
+ }
173
+ /**
174
+ * The built-in transformations, keyed by name; pass the ones a feature
175
+ * needs to the GuidoScript constructor.
176
+ */
177
+ var SCRIPT_TRANSFORMS = {
178
+ /** Wraps the first letter of the first syllable that has notes in
179
+ * `*…*`, the initial marker of the style marking system. */
180
+ startWithInitial: {
181
+ name: "startWithInitial",
182
+ apply: startWithInitial
183
+ } };
184
+ /** The pitch rows of the chant font: every character carrying pitch
185
+ * information, grouped into rows of neighbouring pitches from low to
186
+ * high. A transpose shift moves a character this many positions along
187
+ * its row; characters outside every row carry no pitch and stay put.
188
+ * Rows are searched in order, so a character found in several rows
189
+ * transposes within the first one. */
190
+ var PITCH_ROWS = [
191
+ "ðñ0123456789öüó",
192
+ "^]qwertzuiopõú",
193
+ "ÝÞQWERTZUIOPÕÚ",
194
+ "×sdfghjkléáû",
195
+ "ØÙDFGHJKLÉÁÛ",
196
+ "÷øaASÍYXCVBN$m",
197
+ "ÈÊËÌÎÏÐÑÒþßòôùý",
198
+ "“”•–—˜™š›œº»",
199
+ "®−§ÿ\"+!%/=()ÖÜÓ",
200
+ "Ÿ¡¢£[¥¦©ª«¬",
201
+ "~¯‚ƒ„…†‡ˆ‰Š‹Œ‘’",
202
+ "àâãäåæçèêëìîï",
203
+ "½°±²³´μ·¾¸¹"
204
+ ];
205
+ /** Maps one character to its pitch-shifted neighbour, or undefined when
206
+ * it is not a pitch character (and so stays unchanged). */
207
+ function shiftPitch(ch, shift, overflow) {
208
+ for (const row of PITCH_ROWS) {
209
+ const index = row.indexOf(ch);
210
+ if (index === -1) continue;
211
+ const target = index + shift;
212
+ if (target < 0 || target >= row.length) {
213
+ if (overflow === "null") return "\0";
214
+ return row[Math.max(0, Math.min(row.length - 1, target))];
215
+ }
216
+ return row[target];
217
+ }
218
+ }
219
+ /** Transposes the pitch characters of one notes group's content. Escape
220
+ * pairs stand for their underlying character (an escaped paren is the
221
+ * pitch glyph of row 6), and a shifted result that is a control
222
+ * character of the group syntax is written escaped. */
223
+ function transposeNotes(notes, shift, overflow) {
224
+ let out = "";
225
+ for (let i = 0; i < notes.length; i++) {
226
+ const ch = notes[i];
227
+ const escaped = ch === "\\" && notes[i + 1] !== void 0;
228
+ const shifted = shiftPitch(escaped ? notes[i + 1] : ch, shift, overflow);
229
+ if (shifted === void 0) {
230
+ out += escaped ? ch + notes[i + 1] : ch;
231
+ if (escaped) i++;
232
+ continue;
233
+ }
234
+ out += "\\()".includes(shifted) ? `\\${shifted}` : shifted;
235
+ if (escaped) i++;
236
+ }
237
+ return out;
238
+ }
239
+ /** The `transposeBy` transform factory: shifts every pitch character of
240
+ * every notes group `shift` positions along its pitch row. The clef
241
+ * group and the syllable text are left alone — clef handling is a
242
+ * separate, future tool. */
243
+ function transposeBy(shift, options = {}) {
244
+ const overflow = options.overflow ?? "clamp";
245
+ const apply = (source) => {
246
+ if (shift === 0) return source;
247
+ const clefMatch = source.match(/^\s*\(([^)]*)\)/);
248
+ const offset = clefMatch ? clefMatch[0].length : 0;
249
+ return source.slice(0, offset) + source.slice(offset).replace(/((?:[^()\\]|\\.)*)\(((?:[^)\\]|\\.)*)\)/g, (_, text, notes) => isStatementGroup(notes) ? `${text}(${notes})` : `${text}(${transposeNotes(notes, shift, overflow)})`);
250
+ };
251
+ return {
252
+ name: "transpose",
253
+ apply
254
+ };
255
+ }
256
+ //#endregion
257
+ //#region src/guidoStyles.ts
258
+ /**
259
+ * Style sets for the renderer: named appearance rules (fonts, colors, and
260
+ * the special syllable decorations) kept in one constant registry, so a
261
+ * new style is a data entry here rather than a renderer fork.
262
+ */
263
+ /** The notation's pause-marker characters: they split off into their own
264
+ * runs in every style set — carrying the style set's dedicated
265
+ * `markerGlyphs` font when one is configured, the text font otherwise
266
+ * (Vesperale's text is Times New Roman already) — and always the
267
+ * notation-fixed `marker` kind. */
268
+ var MARKER_CHARS$1 = /* @__PURE__ */ new Set(["*", "†"]);
269
+ /** Text characters (* and †) rendered in Times New Roman. */
270
+ var TIMES_MARKER_GLYPHS = {
271
+ chars: MARKER_CHARS$1,
272
+ fontFamily: "'Times New Roman', Times, serif"
273
+ };
274
+ /** How a `+` inside a Liturgy-font run is drawn: normal weight (the font
275
+ * is bold-looking by design), sized to 70% and raised 20% of the text
276
+ * size so it sits like a connecting sign between syllable parts. */
277
+ var LITURGY_PLUS_STYLE = {
278
+ weight: "400",
279
+ scale: .7,
280
+ raise: .2
281
+ };
282
+ var STYLE_SETS = {
283
+ /** Book Antiqua text with red accents. */
284
+ BNS: {
285
+ textFontStack: "'Book Antiqua', Georgia, serif",
286
+ notesFontStack: "'Guidohu'",
287
+ markerGlyphs: TIMES_MARKER_GLYPHS,
288
+ verifiedFonts: [
289
+ {
290
+ family: "'Book Antiqua'",
291
+ weight: "400"
292
+ },
293
+ {
294
+ family: "'Book Antiqua'",
295
+ weight: "700"
296
+ },
297
+ {
298
+ family: "'Guidohu'",
299
+ weight: "400"
300
+ },
301
+ {
302
+ family: "'Liturgy'",
303
+ weight: "700"
304
+ }
305
+ ],
306
+ decorations: {
307
+ __: {
308
+ fontFamily: "'Liturgy', serif",
309
+ weight: "700",
310
+ color: "var(--red)"
311
+ },
312
+ _: {
313
+ uppercase: true,
314
+ scale: .7,
315
+ color: "var(--red)"
316
+ },
317
+ "*": {
318
+ weight: "700",
319
+ color: "var(--red)",
320
+ initial: true
321
+ }
322
+ },
323
+ specialStarStyle: {
324
+ fontFamily: TIMES_MARKER_GLYPHS.fontFamily,
325
+ weight: "700",
326
+ scale: 1,
327
+ measureScale: .95,
328
+ raise: .1,
329
+ color: "var(--red)"
330
+ },
331
+ padding: 12,
332
+ scriptTransforms: [SCRIPT_TRANSFORMS.startWithInitial]
333
+ },
334
+ /** Times New Roman text, strictly black and white. */
335
+ Vesperale: {
336
+ textFontStack: "'Times New Roman', Times, serif",
337
+ notesFontStack: "'Guidohu'",
338
+ verifiedFonts: [
339
+ {
340
+ family: "'Times New Roman', Times, serif",
341
+ weight: "400"
342
+ },
343
+ {
344
+ family: "'Times New Roman', Times, serif",
345
+ weight: "700"
346
+ },
347
+ {
348
+ family: "'Guidohu'",
349
+ weight: "400"
350
+ },
351
+ {
352
+ family: "'Liturgy'",
353
+ weight: "700"
354
+ }
355
+ ],
356
+ decorations: {
357
+ __: {
358
+ fontFamily: "'Liturgy', serif",
359
+ weight: "700"
360
+ },
361
+ _: {
362
+ scale: .8,
363
+ italic: true
364
+ },
365
+ "*": {
366
+ weight: "700",
367
+ initial: true
368
+ }
369
+ },
370
+ specialStarStyle: {
371
+ fontFamily: TIMES_MARKER_GLYPHS.fontFamily,
372
+ weight: "700",
373
+ scale: 1,
374
+ measureScale: .95,
375
+ raise: .2
376
+ },
377
+ padding: 12,
378
+ scriptTransforms: []
379
+ }
380
+ };
381
+ var DEFAULT_STYLE_SET = "BNS";
382
+ /**
383
+ * Resolves a syllable's raw text into the runs it renders as: the whole-
384
+ * syllable `**` star renders as the bold ∗ operator, a `__…__` or `_…_`
385
+ * wrapper (the same characters on both ends, content between) picks up
386
+ * its decoration rule from the style set, and paired `*` markers wrap any
387
+ * part of the syllable — even the whole of it — with the initial rule
388
+ * (`*sam*ple` → "sam" in the initial style, "ple" normal; an unmatched
389
+ * `*` renders literally), the `bold` option forces weight 700 onto every
390
+ * run, and the marker characters (`*`, `†`) split off into runs of their
391
+ * own — with the style set's `markerGlyphs` font when one is configured,
392
+ * the text font otherwise (always the `marker` kind).
393
+ * Inside a Liturgy-font run, `+` gets its own weight-400 runs — the font
394
+ * is bold-looking by design, so the weight stays normal. The wrapper
395
+ * characters themselves are dropped. Each run also carries `kind`, the
396
+ * notation-fixed semantic of its markup (`liturgy`, `rubric`, `star`,
397
+ * `marker`, `plus`) — the vocabulary the marked-up text export and the
398
+ * renderer's run classes share, identical across style sets. `rawCase`
399
+ * skips the BNS rubric uppercasing: uppercasing is presentation, so the
400
+ * marked-up text export keeps the raw letter case (a consumer CSS applies
401
+ * text-transform instead).
402
+ */
403
+ function resolveSyllableParts(text, styleSet, bold, options = {}) {
404
+ if (text.length === 0) return [];
405
+ if (text === "**") return [{
406
+ text: "∗",
407
+ style: { ...styleSet.specialStarStyle },
408
+ kind: "star"
409
+ }];
410
+ let content = text;
411
+ let base = {};
412
+ let baseKind;
413
+ for (const wrapper of ["__", "_"]) {
414
+ const rule = styleSet.decorations[wrapper];
415
+ if (rule && text.length >= wrapper.length * 2 + 1 && text.startsWith(wrapper) && text.endsWith(wrapper)) {
416
+ content = text.slice(wrapper.length, -wrapper.length);
417
+ base = { ...rule };
418
+ baseKind = wrapper === "__" ? "liturgy" : "rubric";
419
+ break;
420
+ }
421
+ }
422
+ const initialRule = styleSet.decorations["*"];
423
+ const segmentSpecs = [];
424
+ let rest = content;
425
+ let plain = "";
426
+ for (let m = /\*([^*]+)\*/.exec(rest); m; m = /\*([^*]+)\*/.exec(rest)) {
427
+ plain += rest.slice(0, m.index);
428
+ if (plain) {
429
+ segmentSpecs.push({
430
+ text: plain,
431
+ marked: false
432
+ });
433
+ plain = "";
434
+ }
435
+ segmentSpecs.push({
436
+ text: m[1],
437
+ marked: true
438
+ });
439
+ rest = rest.slice(m.index + m[0].length);
440
+ }
441
+ plain += rest;
442
+ if (plain) segmentSpecs.push({
443
+ text: plain,
444
+ marked: false
445
+ });
446
+ const segments = segmentSpecs.map(({ text: segText, marked }) => ({
447
+ text: segText,
448
+ style: marked ? {
449
+ ...base,
450
+ ...initialRule,
451
+ initial: true
452
+ } : { ...base },
453
+ kind: baseKind
454
+ }));
455
+ const glyphs = styleSet.markerGlyphs;
456
+ const parts = [];
457
+ for (const segment of segments) {
458
+ if (segment.style.uppercase && !options.rawCase) segment.text = segment.text.toUpperCase();
459
+ if (bold) segment.style = {
460
+ ...segment.style,
461
+ weight: "700"
462
+ };
463
+ const chars = [...segment.text];
464
+ const inLiturgy = segment.style.fontFamily?.includes("Liturgy") ?? false;
465
+ const runKind = (ch) => {
466
+ if (MARKER_CHARS$1.has(ch) || glyphs && glyphs.chars.has(ch)) return "marker";
467
+ if (inLiturgy && ch === "+") return "plus";
468
+ return "text";
469
+ };
470
+ if (chars.every((ch) => runKind(ch) === "text")) {
471
+ parts.push({
472
+ text: segment.text,
473
+ style: { ...segment.style },
474
+ kind: segment.kind
475
+ });
476
+ continue;
477
+ }
478
+ let charRun = "";
479
+ let currentKind = null;
480
+ const pushRun = () => {
481
+ if (!charRun) return;
482
+ let runStyle = { ...segment.style };
483
+ let partKind = segment.kind;
484
+ if (currentKind === "marker") {
485
+ partKind = "marker";
486
+ if (glyphs && glyphs.chars.has(charRun[0])) runStyle = {
487
+ ...runStyle,
488
+ fontFamily: glyphs.fontFamily
489
+ };
490
+ } else if (currentKind === "plus") {
491
+ runStyle = {
492
+ ...runStyle,
493
+ ...LITURGY_PLUS_STYLE
494
+ };
495
+ partKind = "plus";
496
+ }
497
+ parts.push({
498
+ text: charRun,
499
+ style: runStyle,
500
+ kind: partKind
501
+ });
502
+ charRun = "";
503
+ };
504
+ for (const ch of chars) {
505
+ const kind = runKind(ch);
506
+ if (kind !== currentKind) pushRun();
507
+ currentKind = kind;
508
+ charRun += ch;
509
+ }
510
+ pushRun();
511
+ }
512
+ return parts;
513
+ }
514
+ /** The canvas font shorthand for measuring a run at the text size. */
515
+ function measurementFont(style, textPx, fallbackStack) {
516
+ return [
517
+ style.italic ? "italic" : "normal",
518
+ "normal",
519
+ style.weight ?? "400",
520
+ `${textPx * (style.measureScale ?? style.scale ?? 1)}px`,
521
+ style.fontFamily ?? fallbackStack
522
+ ].join(" ");
523
+ }
524
+ /** The inline CSS properties that draw a run, as dash-cased names for
525
+ * CSSStyleDeclaration.setProperty. */
526
+ function inlineStylesFor(style, textPx) {
527
+ const styles = {};
528
+ if (style.fontFamily) styles["font-family"] = style.fontFamily;
529
+ if (style.weight) styles["font-weight"] = style.weight;
530
+ if (style.italic) styles["font-style"] = "italic";
531
+ if (style.scale !== void 0) styles["font-size"] = `${textPx * style.scale}px`;
532
+ if (style.color) styles["color"] = style.color;
533
+ if (style.raise) {
534
+ styles["position"] = "relative";
535
+ styles["top"] = `${-textPx * style.raise}px`;
536
+ }
537
+ return styles;
538
+ }
539
+ /** The font strings render() must load and verify for a style set. */
540
+ function fontStringsToVerify(styleSet, textPx) {
541
+ return styleSet.verifiedFonts.map((f) => `${f.weight} ${textPx}px ${f.family}`);
542
+ }
543
+ //#endregion
544
+ //#region src/chantLayout.ts
545
+ /**
546
+ * Score marker characters: they carry no pitch, and when they sit at the
547
+ * start or end of a note group (with the adjacent dash) they act as
548
+ * whitespace rather than note width.
549
+ */
550
+ var SCORE_MARKERS = ",.:?'\"+!%/=()ÖÜÓ;";
551
+ var MARKER_CHARS = new Set(SCORE_MARKERS.split(""));
552
+ /**
553
+ * Special reciting notes: when such a note stands alone in a note group it
554
+ * marks recited text. The glyph shows at a run's first syllable (the
555
+ * previous syllable has different notes) and at every line start; every
556
+ * other recited syllable contributes only the staff-line segments filling
557
+ * the space above its text, which flows tight after the previous text.
558
+ */
559
+ var SPECIAL_NOTES = "Ÿ¡¢£[¥¦©ª«¬";
560
+ var SPECIAL_NOTE_CHARS = new Set(SPECIAL_NOTES.split(""));
561
+ /**
562
+ * Modifier glyphs: flats, sharps, and naturals. They carry pitch (and
563
+ * transpose with the melody) but modify the note that follows them, so
564
+ * they hang in the junction whitespace: the syllable text anchors on the
565
+ * note characters only, and a group starting with a modifier needs only
566
+ * two junction dashes — the glyph itself provides the third dash's
567
+ * separation.
568
+ */
569
+ var NOTE_MODIFIERS = "÷øaASÍYXCVBN$mÈÊËÌÎÏÐÑÒþßòôùý“”•–—˜™š›œº»";
570
+ var MODIFIER_CHARS = new Set(NOTE_MODIFIERS.split(""));
571
+ var NOTE_GROUP_SPLITTERS = ["-", "¨"];
572
+ function splitNoteMarkers(notes) {
573
+ let start = 0;
574
+ while (start < notes.length && MARKER_CHARS.has(notes[start])) start++;
575
+ if (start > 0 && start < notes.length && notes[start] === "-") start++;
576
+ let end = notes.length;
577
+ while (end > start && MARKER_CHARS.has(notes[end - 1])) end--;
578
+ if (end < notes.length && end > start && notes[end - 1] === "-") end--;
579
+ return {
580
+ leading: notes.slice(0, start),
581
+ core: notes.slice(start, end),
582
+ trailing: notes.slice(end)
583
+ };
584
+ }
585
+ var ctx = null;
586
+ /** Canvas text measurement, shared with the emitters (the Word export
587
+ * measures the spacer character's natural advance for the unit width). */
588
+ function measure(text, font) {
589
+ if (!ctx) ctx = document.createElement("canvas").getContext("2d");
590
+ ctx.font = font;
591
+ return ctx.measureText(text).width;
592
+ }
593
+ /** Ink extents of the text relative to the glyph origin (negative left
594
+ * means the ink starts left of the origin). */
595
+ function ink(text, font) {
596
+ if (!ctx) ctx = document.createElement("canvas").getContext("2d");
597
+ ctx.font = font;
598
+ const m = ctx.measureText(text);
599
+ return {
600
+ left: m.actualBoundingBoxLeft,
601
+ right: m.actualBoundingBoxRight
602
+ };
603
+ }
604
+ /**
605
+ * Lays a GuidoScript score out: a notes line in the chant font, and a text
606
+ * line where each syllable is centered below its notes. The dashes of the
607
+ * chant font are pure whitespace: centering ignores them and happens under
608
+ * the non-whitespace note characters only. When a syllable's text would
609
+ * overlap the previous one, it starts right after it and the notes group is
610
+ * padded with extra dashes until it covers the text.
611
+ *
612
+ * This is the shared layout pass behind every emitter: the DOM renderer
613
+ * turns the returned lines into (notes div, text paragraph) pairs, and the
614
+ * Word export turns them into fake-spaced Word HTML. Both consume the same
615
+ * line breaks, notes parts, and syllable anchor positions.
616
+ *
617
+ * Appearance comes from a named style set (see guidoStyles.ts): the layout
618
+ * options reference it by name, together with the bold option and the
619
+ * text/notes sizes. Throws when the style set is unknown or one of its
620
+ * fonts cannot be loaded.
621
+ */
622
+ async function layoutScore(source, options = {}) {
623
+ const { style: styleName = "BNS", bold = false, textPx = 18, notesPx = textPx * 2, maxWidthPx = Infinity } = options;
624
+ const script = typeof source === "string" ? new GuidoScript(source) : source;
625
+ const styleSet = STYLE_SETS[styleName];
626
+ if (!styleSet) throw new Error(`Unknown style set: "${styleName}"`);
627
+ for (const font of fontStringsToVerify(styleSet, textPx)) {
628
+ try {
629
+ await document.fonts.load(font);
630
+ } catch {}
631
+ if (!document.fonts.check(font)) throw new Error(`Font could not be loaded: ${font} (style "${styleName}")`);
632
+ }
633
+ const notesFont = `400 ${notesPx}px ${styleSet.notesFontStack}`;
634
+ const textStack = styleSet.textFontStack;
635
+ const spaceFont = measurementFont({ weight: bold ? "700" : "400" }, textPx, textStack);
636
+ const resolveParts = (spanText) => resolveSyllableParts(spanText, styleSet, bold);
637
+ const measureParts = (parts) => parts.reduce((w, part) => w + measure(part.text, measurementFont(part.style, textPx, textStack)), 0);
638
+ const dashNotesWidth = measure("-", notesFont);
639
+ const dashTextWidth = measure("-", spaceFont);
640
+ const clefPrefix = script.clef !== void 0 ? `${script.clef}-` : "";
641
+ const lines = [];
642
+ let line;
643
+ let notesSoFar;
644
+ let textCursor;
645
+ let lastGroupTrailingMarker;
646
+ let prevRecited = false;
647
+ let pending = [];
648
+ const startLine = () => {
649
+ if (line) {
650
+ line.textCursor = textCursor;
651
+ line.notesEnd = line.notesParts.length ? measure(clefPrefix + line.notesParts.join(""), notesFont) : 0;
652
+ }
653
+ line = {
654
+ notesParts: [],
655
+ segments: [],
656
+ textCursor: 0,
657
+ notesEnd: 0,
658
+ lastWordEnd: null
659
+ };
660
+ lines.push(line);
661
+ notesSoFar = clefPrefix;
662
+ textCursor = 0;
663
+ lastGroupTrailingMarker = false;
664
+ prevRecited = false;
665
+ };
666
+ startLine();
667
+ const tokens = script.tokens;
668
+ const syllables = tokens.filter((t) => t.kind === "syllable");
669
+ const items = [];
670
+ let sylIndex = 0;
671
+ for (const tok of tokens) if (tok.kind === "break") items.push({ kind: "break" });
672
+ else items.push({
673
+ kind: "syl",
674
+ syl: tok,
675
+ i: sylIndex++,
676
+ text: tok.text,
677
+ notes: tok.notes,
678
+ first: true,
679
+ lastSeg: true
680
+ });
681
+ const findBreakCut = (notes, room, measureFromLineStart) => {
682
+ for (let c = notes.length - 1; c > 0; c--) {
683
+ if (!NOTE_GROUP_SPLITTERS.includes(notes[c])) continue;
684
+ let end = c + 1;
685
+ while (end < notes.length && MARKER_CHARS.has(notes[end])) end++;
686
+ if (end >= notes.length) continue;
687
+ if (measureFromLineStart(notes.slice(0, end)) <= room) return c;
688
+ }
689
+ return -1;
690
+ };
691
+ const applyBreakCut = (item, cut) => {
692
+ const notes = item.notes;
693
+ let restStart = cut + 1;
694
+ while (restStart < notes.length && MARKER_CHARS.has(notes[restStart])) restStart++;
695
+ item.notes = notes.slice(0, cut) + notes.slice(cut + 1, restStart);
696
+ return notes.slice(restStart);
697
+ };
698
+ const queueContinuation = (item, idx, rest) => {
699
+ item.lastSeg = false;
700
+ items.splice(idx + 1, 0, {
701
+ kind: "syl",
702
+ syl: item.syl,
703
+ i: item.i,
704
+ text: "",
705
+ notes: rest,
706
+ first: false,
707
+ lastSeg: true
708
+ });
709
+ forceBreak = true;
710
+ };
711
+ const flushPending = (trailing) => {
712
+ while (pending.length > 0) {
713
+ const p = pending[0];
714
+ if (textCursor > 0 && textCursor + p.textWidth + (p.wordEnd ? 0 : dashTextWidth) > maxWidthPx) {
715
+ startLine();
716
+ continue;
717
+ }
718
+ pending.shift();
719
+ line.segments.push({
720
+ kind: "syl",
721
+ parts: p.sylParts,
722
+ textStart: textCursor,
723
+ textWidth: p.textWidth,
724
+ contentWidth: 0,
725
+ contentStart: 0,
726
+ extraDashes: 0,
727
+ tight: false,
728
+ noNotes: true,
729
+ ...trailing && pending.length === 0 ? { trailing: true } : {}
730
+ });
731
+ textCursor += p.textWidth;
732
+ if (p.spaceWidth > 0) {
733
+ line.segments.push({
734
+ kind: "word-space",
735
+ width: p.spaceWidth
736
+ });
737
+ textCursor += p.spaceWidth;
738
+ }
739
+ line.lastWordEnd = p.wordEnd;
740
+ line.textCursor = textCursor;
741
+ }
742
+ };
743
+ let forceBreak = false;
744
+ let prevWordEnd = void 0;
745
+ let idx = 0;
746
+ while (idx < items.length) {
747
+ const item = items[idx];
748
+ if (item.kind === "break") {
749
+ if (line.segments.length > 0 || pending.length > 0) {
750
+ flushPending(false);
751
+ forceBreak = true;
752
+ }
753
+ idx++;
754
+ continue;
755
+ }
756
+ const syl = item.syl;
757
+ const i = item.i;
758
+ if (forceBreak) {
759
+ startLine();
760
+ forceBreak = false;
761
+ }
762
+ const last = item.lastSeg && i === syllables.length - 1;
763
+ const spanText = item.text;
764
+ const sylParts = resolveParts(spanText);
765
+ const textWidth = measureParts(sylParts);
766
+ const spaceWidth = !last && syl.wordEnd ? measure(" ", spaceFont) : 0;
767
+ const pendingTotal = pending.reduce((s, p) => s + p.textWidth + p.spaceWidth, 0);
768
+ const special = syl.notes.length === 1 && SPECIAL_NOTE_CHARS.has(syl.notes);
769
+ const specialFits = textCursor === 0 || textCursor + pendingTotal + textWidth + (syl.wordEnd ? 0 : dashTextWidth) <= maxWidthPx;
770
+ if (syl.notes.length === 0) {
771
+ pending.push({
772
+ sylParts,
773
+ textWidth,
774
+ spaceWidth,
775
+ wordEnd: syl.wordEnd
776
+ });
777
+ idx++;
778
+ continue;
779
+ }
780
+ if (item.first && item.lastSeg && syl.text.trim() === "" && splitNoteMarkers(syl.notes).core === "") {
781
+ const last = notesSoFar[notesSoFar.length - 1];
782
+ const sep = last && last !== "-" && !MARKER_CHARS.has(last) && !syl.notes.startsWith("-") ? "-" : "";
783
+ line.notesParts.push(sep + syl.notes);
784
+ notesSoFar += sep + syl.notes;
785
+ lastGroupTrailingMarker = true;
786
+ prevRecited = false;
787
+ prevWordEnd = syl.wordEnd;
788
+ idx++;
789
+ continue;
790
+ }
791
+ const runStart = syllables[i - 1]?.notes !== syl.notes;
792
+ if (special && !runStart && line.notesParts.length > 0 && !specialFits) startLine();
793
+ if (!item.first) {
794
+ for (;;) {
795
+ if (measure(notesSoFar + item.notes, notesFont) <= maxWidthPx) break;
796
+ const cut = findBreakCut(item.notes, maxWidthPx, (prefix) => measure(notesSoFar + prefix, notesFont));
797
+ if (cut < 0 || cut + 1 >= item.notes.length) break;
798
+ const rest = applyBreakCut(item, cut);
799
+ queueContinuation(item, idx, rest);
800
+ }
801
+ const parts = splitNoteMarkers(item.notes);
802
+ line.notesParts.push(item.notes);
803
+ notesSoFar += item.notes;
804
+ if (item.lastSeg) lastGroupTrailingMarker = parts.trailing.length > 0;
805
+ line.lastWordEnd = true;
806
+ prevWordEnd = syl.wordEnd;
807
+ if (!item.lastSeg) forceBreak = true;
808
+ idx++;
809
+ continue;
810
+ }
811
+ let parts = splitNoteMarkers(item.notes);
812
+ let junctionPrefix = line.notesParts.length === 0 ? "" : prevRecited ? "" : lastGroupTrailingMarker || MODIFIER_CHARS.has(parts.core[0]) ? "--" : "---";
813
+ const place = (padDashes = 0) => {
814
+ let mods = 0;
815
+ while (mods < parts.core.length && MODIFIER_CHARS.has(parts.core[mods])) mods++;
816
+ if (mods === parts.core.length) mods = 0;
817
+ const anchorText = parts.core.slice(mods);
818
+ const contentWidth = measure(anchorText, notesFont);
819
+ const contentStart = measure(notesSoFar + junctionPrefix + "-".repeat(padDashes) + parts.leading + parts.core.slice(0, mods), notesFont);
820
+ const inkRaw = ink(anchorText, notesFont);
821
+ const inkStartOffset = -inkRaw.left;
822
+ const inkCenterOffset = (inkRaw.right - inkRaw.left) / 2;
823
+ return {
824
+ contentWidth,
825
+ contentStart,
826
+ textStart: contentWidth >= textWidth || special ? contentStart + inkStartOffset : contentStart + inkCenterOffset - textWidth / 2
827
+ };
828
+ };
829
+ let { contentWidth, contentStart, textStart } = place();
830
+ for (;;) {
831
+ const notesOver = measure(notesSoFar + junctionPrefix + item.notes, notesFont) > maxWidthPx;
832
+ const textOver = textStart + textWidth + (syl.wordEnd ? 0 : dashTextWidth) > maxWidthPx;
833
+ if (!notesOver && !textOver) break;
834
+ if (notesOver) {
835
+ const cut = findBreakCut(item.notes, maxWidthPx, (prefix) => measure(notesSoFar + junctionPrefix + prefix, notesFont));
836
+ if (cut >= 0 && cut + 1 < item.notes.length) {
837
+ const rest = applyBreakCut(item, cut);
838
+ queueContinuation(item, idx, rest);
839
+ parts = splitNoteMarkers(item.notes);
840
+ ({contentWidth, contentStart, textStart} = place());
841
+ break;
842
+ }
843
+ }
844
+ if (line.notesParts.length === 0 && textCursor === 0) {
845
+ if (notesOver) {
846
+ const cut = findBreakCut(item.notes, maxWidthPx, (prefix) => measure(notesSoFar + prefix, notesFont));
847
+ if (cut >= 0 && cut + 1 < item.notes.length) {
848
+ const rest = applyBreakCut(item, cut);
849
+ item.notes = item.notes.slice(0, cut);
850
+ queueContinuation(item, idx, rest);
851
+ parts = splitNoteMarkers(item.notes);
852
+ ({contentWidth, contentStart, textStart} = place());
853
+ }
854
+ }
855
+ break;
856
+ }
857
+ startLine();
858
+ junctionPrefix = "";
859
+ ({contentWidth, contentStart, textStart} = place());
860
+ }
861
+ const connectorDash = line.notesParts.length > 0 && !prevWordEnd && pendingTotal === 0;
862
+ const minStart = textCursor + dashTextWidth;
863
+ const minTextStart = textCursor + pendingTotal + (prevRecited && connectorDash ? dashTextWidth : 0);
864
+ let notesStr = junctionPrefix + item.notes;
865
+ let extraDashes = 0;
866
+ let tightPair = false;
867
+ const padAndPlace = (pads) => {
868
+ extraDashes = pads;
869
+ notesStr = junctionPrefix + "-".repeat(pads) + item.notes;
870
+ ({contentWidth, contentStart, textStart} = place(pads));
871
+ };
872
+ const hiddenSpecial = special && !runStart && line.notesParts.length > 0;
873
+ if (hiddenSpecial) {
874
+ junctionPrefix = "";
875
+ textStart = textCursor + pendingTotal;
876
+ const deficit = textStart + textWidth + spaceWidth - measure(notesSoFar, notesFont);
877
+ const room = maxWidthPx - measure(notesSoFar + junctionPrefix, notesFont);
878
+ const fill = deficit > 0 ? Math.min(Math.ceil(deficit / dashNotesWidth), Math.max(0, Math.floor(room / dashNotesWidth))) : 0;
879
+ item.notes = "-".repeat(fill);
880
+ parts = splitNoteMarkers(item.notes);
881
+ notesStr = junctionPrefix + item.notes;
882
+ tightPair = connectorDash;
883
+ }
884
+ if (hiddenSpecial) {} else if (!prevRecited && connectorDash && textStart < minStart && (textWidth > contentWidth || textStart < textCursor)) {
885
+ tightPair = true;
886
+ textStart = textCursor;
887
+ const idealContentStart = contentWidth >= textWidth ? textStart : textStart + (textWidth - contentWidth) / 2;
888
+ if (idealContentStart > contentStart) {
889
+ extraDashes = Math.round((idealContentStart - contentStart) / dashNotesWidth);
890
+ notesStr = junctionPrefix + "-".repeat(extraDashes) + item.notes;
891
+ }
892
+ } else if (textStart < minTextStart) {
893
+ const idealContentStart = contentWidth >= textWidth ? minTextStart : minTextStart + (textWidth - contentWidth) / 2;
894
+ if (idealContentStart > contentStart) {
895
+ let pads = Math.max(0, Math.floor((idealContentStart - contentStart) / dashNotesWidth));
896
+ padAndPlace(pads);
897
+ while (textStart < minTextStart) {
898
+ pads++;
899
+ padAndPlace(pads);
900
+ }
901
+ if (line.notesParts.length > 0 && measure(notesSoFar + notesStr, notesFont) > maxWidthPx) {
902
+ startLine();
903
+ junctionPrefix = "";
904
+ notesStr = junctionPrefix + item.notes;
905
+ extraDashes = 0;
906
+ ({contentWidth, contentStart, textStart} = place());
907
+ if (textStart < textCursor + pendingTotal) {
908
+ const freshIdeal = contentWidth >= textWidth ? textCursor + pendingTotal : textCursor + pendingTotal + (textWidth - contentWidth) / 2;
909
+ if (freshIdeal > contentStart) {
910
+ let pads = Math.max(0, Math.floor((freshIdeal - contentStart) / dashNotesWidth));
911
+ padAndPlace(pads);
912
+ while (textStart < textCursor + pendingTotal) {
913
+ pads++;
914
+ padAndPlace(pads);
915
+ }
916
+ }
917
+ }
918
+ }
919
+ }
920
+ }
921
+ if (pendingTotal > 0 && textStart < textCursor + pendingTotal) textStart = textCursor + pendingTotal;
922
+ const spacerWidth = Math.max(0, textStart - pendingTotal - textCursor);
923
+ if (line.notesParts.length === 0) line.segments.push({
924
+ kind: "gap",
925
+ role: "lead-in",
926
+ width: spacerWidth,
927
+ endPx: textStart - pendingTotal,
928
+ textStartPx: textStart
929
+ });
930
+ else if (prevWordEnd) line.segments.push({
931
+ kind: "gap",
932
+ role: "word-gap",
933
+ width: spacerWidth,
934
+ endPx: textStart - pendingTotal,
935
+ textStartPx: textStart
936
+ });
937
+ else if (pendingTotal === 0 && tightPair) {} else if (pendingTotal === 0) {
938
+ const pad = Math.max(0, (spacerWidth - dashTextWidth) / 2);
939
+ line.segments.push({
940
+ kind: "connector",
941
+ pad,
942
+ gapWidth: spacerWidth,
943
+ dashWidth: dashTextWidth,
944
+ dashStartPx: textCursor + pad,
945
+ nextAnchorPx: textStart
946
+ });
947
+ }
948
+ let pendingStart = textStart - pendingTotal;
949
+ for (const p of pending) {
950
+ line.segments.push({
951
+ kind: "syl",
952
+ parts: p.sylParts,
953
+ textStart: pendingStart,
954
+ textWidth: p.textWidth,
955
+ contentWidth: 0,
956
+ contentStart: 0,
957
+ extraDashes: 0,
958
+ tight: false,
959
+ noNotes: true
960
+ });
961
+ pendingStart += p.textWidth;
962
+ if (p.spaceWidth > 0) {
963
+ line.segments.push({
964
+ kind: "word-space",
965
+ width: p.spaceWidth
966
+ });
967
+ pendingStart += p.spaceWidth;
968
+ }
969
+ }
970
+ pending = [];
971
+ line.segments.push({
972
+ kind: "syl",
973
+ parts: sylParts,
974
+ textStart,
975
+ textWidth,
976
+ contentWidth,
977
+ contentStart,
978
+ extraDashes,
979
+ tight: tightPair,
980
+ noNotes: false
981
+ });
982
+ if (spaceWidth > 0) line.segments.push({
983
+ kind: "word-space",
984
+ width: spaceWidth
985
+ });
986
+ textCursor = textStart + textWidth + spaceWidth;
987
+ notesSoFar += notesStr;
988
+ line.notesParts.push(notesStr);
989
+ line.lastWordEnd = syl.wordEnd;
990
+ prevWordEnd = syl.wordEnd;
991
+ if (item.lastSeg) {
992
+ lastGroupTrailingMarker = parts.trailing.length > 0;
993
+ prevRecited = special;
994
+ }
995
+ if (!item.lastSeg) forceBreak = true;
996
+ idx++;
997
+ }
998
+ flushPending(true);
999
+ line.textCursor = textCursor;
1000
+ line.notesEnd = line.notesParts.length ? measure(clefPrefix + line.notesParts.join(""), notesFont) : 0;
1001
+ lines.forEach((l, li) => {
1002
+ if (li === lines.length - 1 || l.lastWordEnd !== false) return;
1003
+ const pad = l.notesEnd > l.textCursor ? Math.max(0, (l.notesEnd - l.textCursor - dashTextWidth) / 2) : 0;
1004
+ l.segments.push({
1005
+ kind: "line-end-dash",
1006
+ pad,
1007
+ dashWidth: dashTextWidth,
1008
+ dashStartPx: l.textCursor + pad,
1009
+ trailEndPx: l.notesEnd,
1010
+ textEndPx: l.textCursor
1011
+ });
1012
+ });
1013
+ const starTarget = maxWidthPx + (styleSet.padding ?? 0);
1014
+ const starWidth = measure("*", notesFont);
1015
+ lines.forEach((l, li) => {
1016
+ if (li === lines.length - 1) return;
1017
+ if (maxWidthPx === Infinity) {
1018
+ l.breakMarkerLeftPx = styleSet.padding ?? 0;
1019
+ return;
1020
+ }
1021
+ let lineEnd = measure(clefPrefix + l.notesParts.join(""), notesFont);
1022
+ while (lineEnd + dashNotesWidth <= starTarget - starWidth && lineEnd + dashNotesWidth < maxWidthPx) {
1023
+ l.notesParts.push("-");
1024
+ lineEnd += dashNotesWidth;
1025
+ }
1026
+ l.breakMarkerLeftPx = starTarget - lineEnd - starWidth;
1027
+ });
1028
+ return {
1029
+ lines,
1030
+ clefPrefix,
1031
+ styleSet,
1032
+ styleName,
1033
+ textPx,
1034
+ notesPx,
1035
+ bold,
1036
+ maxWidthPx,
1037
+ starTarget,
1038
+ starWidth
1039
+ };
1040
+ }
1041
+ //#endregion
1042
+ export { measure as a, inlineStylesFor as c, transposeBy as d, GuidoScript as f, layoutScore as i, measurementFont as l, unescape as m, SCORE_MARKERS as n, DEFAULT_STYLE_SET as o, chantText as p, SPECIAL_NOTES as r, STYLE_SETS as s, NOTE_MODIFIERS as t, resolveSyllableParts as u };