guidex 0.3.3 → 0.5.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 (36) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +266 -37
  3. package/dist/lib/app/StaffSettings.d.ts +1 -0
  4. package/dist/lib/app/editorState.d.ts +32 -23
  5. package/dist/lib/app/shareLink.d.ts +2 -3
  6. package/dist/lib/{chantLayout-CVVuJUJl.js → chantLayout-BrCQUOhp.js} +980 -1142
  7. package/dist/lib/chantLayout.d.ts +32 -3
  8. package/dist/lib/chantMarkup.d.ts +63 -20
  9. package/dist/lib/drawnStaff.d.ts +130 -0
  10. package/dist/lib/editorStorage.d.ts +44 -4
  11. package/dist/lib/embed/core.d.ts +26 -4
  12. package/dist/lib/embed/index.js +1 -1
  13. package/dist/lib/embed/manual.d.ts +9 -3
  14. package/dist/lib/embed/manual.js +16 -49
  15. package/dist/lib/fonts/guidohu-staffless.woff2 +0 -0
  16. package/dist/lib/guidex.css +27 -0
  17. package/dist/lib/guidoRender.d.ts +22 -4
  18. package/dist/lib/guidoScript.d.ts +60 -23
  19. package/dist/lib/guidoScriptTransforms.d.ts +0 -18
  20. package/dist/lib/guidoStyles.d.ts +85 -74
  21. package/dist/lib/react/GuidexScore.d.ts +18 -6
  22. package/dist/lib/react/index.d.ts +2 -0
  23. package/dist/lib/react/index.js +47 -4
  24. package/dist/lib/recitationSegments.d.ts +93 -0
  25. package/dist/lib/scoreImage-B2SGdROL.js +8391 -0
  26. package/dist/lib/staffGlyphs.d.ts +12 -0
  27. package/dist/lib/stanzas.d.ts +6 -3
  28. package/dist/lib/textMarkup.d.ts +67 -0
  29. package/dist/lib/word/index.js +1 -1
  30. package/dist/lib/{wordChecker-DG09l_ol.js → wordChecker-CjYl2yof.js} +40 -13
  31. package/dist/lib/wordExport.d.ts +23 -4
  32. package/dist-embed/fonts/guidohu-staffless.woff2 +0 -0
  33. package/dist-embed/guidex-embed.min.css +1 -1
  34. package/dist-embed/guidex-embed.min.js +1 -1
  35. package/package.json +3 -2
  36. package/dist/lib/scoreImage-lvOrTbG-.js +0 -1009
@@ -1,6 +1,7 @@
1
1
  import { GuidoScript } from './guidoScript';
2
2
  import { SCORE_MARKERS } from './noteGroups';
3
- import { StyleSet, StyleSetName, SyllablePart } from './guidoStyles';
3
+ import { StyleSet, MarkDefinitions, StyleSetName, SyllablePart } from './guidoStyles';
4
+ import { RecitationOptions } from './recitationSegments';
4
5
  export { SCORE_MARKERS };
5
6
  /**
6
7
  * Special reciting notes: when such a note stands alone in a note group it
@@ -22,11 +23,20 @@ export declare const NOTE_MODIFIERS: string;
22
23
  /** Canvas text measurement, shared with the emitters (the Word export
23
24
  * measures the spacer character's natural advance for the unit width). */
24
25
  export declare function measure(text: string, font: string): number;
26
+ /** How far each staff line runs (issue #107). `all-but-last` fills every
27
+ * line but the last to the available width; `none` stops every line at its
28
+ * own notes; `all` fills every line to the available width, or acts as
29
+ * `longest` at natural width, where there is none; `longest` fills every
30
+ * line to the end of the score's longest line, its text included. */
31
+ export type StaffFill = 'all-but-last' | 'none' | 'all' | 'longest';
32
+ export declare const STAFF_FILLS: readonly StaffFill[];
25
33
  /** Options for one layout pass. All fields optional; defaults reproduce the
26
34
  * original Book Antiqua look (style set BNS). */
27
- export interface LayoutOptions {
28
- /** Named style set from STYLE_SETS (default: BNS) */
35
+ export interface LayoutOptions extends RecitationOptions {
36
+ /** Named style set (default: BNS) */
29
37
  style?: StyleSetName;
38
+ /** Marks this score adds to its style set's */
39
+ marks?: MarkDefinitions;
30
40
  /** Lay out all text bold, measurements included */
31
41
  bold?: boolean;
32
42
  /** Text line size in px (default 18) */
@@ -42,6 +52,12 @@ export interface LayoutOptions {
42
52
  * accidental takes one less, never under 1. Held groups keep their
43
53
  * own join. */
44
54
  junctionDashes?: number;
55
+ /** How far each staff line runs (default `all-but-last`) */
56
+ staffFill?: StaffFill;
57
+ /** With `staffFill: 'longest'`: when the longest line ends within this
58
+ * many px of the available width, every line runs to the available
59
+ * width instead (default 0) */
60
+ staffFillSnapPx?: number;
45
61
  }
46
62
  /** A horizontal whitespace gap on the text line: the lead-in shared with
47
63
  * the clef, or the gap after a word-ending syllable. Both emitters fake it
@@ -62,6 +78,8 @@ export interface GapSegment {
62
78
  /** A dash connector centered between two syllables of the same word. */
63
79
  export interface ConnectorSegment {
64
80
  kind: 'connector';
81
+ /** The hyphen's look, when a `{…}` span runs on across it */
82
+ parts?: SyllablePart[];
65
83
  /** Each side pad's width in px (the DOM emitter's twin spacer spans) */
66
84
  pad: number;
67
85
  /** The full gap the dash centers in, px */
@@ -107,6 +125,8 @@ export interface WordSpaceSegment {
107
125
  * the line's text end and its notes end. */
108
126
  export interface LineEndDashSegment {
109
127
  kind: 'line-end-dash';
128
+ /** The hyphen's look, when a `{…}` span runs on across it */
129
+ parts?: SyllablePart[];
110
130
  /** Each side pad's width in px (the DOM emitter's twin spacer spans) */
111
131
  pad: number;
112
132
  dashWidth: number;
@@ -129,6 +149,13 @@ export interface LayoutTextLine {
129
149
  /** Whether the text line's last syllable ends its word; null when it
130
150
  * carries no syllable at all */
131
151
  lastWordEnd: boolean | null;
152
+ /** The hyphen after the text line's last syllable */
153
+ hyphen?: Hyphen;
154
+ }
155
+ /** A text hyphen: its look when it has one of its own, and its width. */
156
+ export interface Hyphen {
157
+ parts?: SyllablePart[];
158
+ width: number;
132
159
  }
133
160
  /** One rendered line pair's layout: the notes-line model and the text
134
161
  * line's ordered segments with their ideal absolute positions. Stacked
@@ -146,6 +173,8 @@ export interface LayoutLine {
146
173
  textCursor: number;
147
174
  /** Where the notes line ends (the notes width when the line closed) */
148
175
  notesEnd: number;
176
+ /** Where the staff ends: `notesEnd` plus any staff fill */
177
+ staffEnd: number;
149
178
  /** Whether the line's last syllable ends its word; null when the
150
179
  * line carries no syllable at all */
151
180
  lastWordEnd: boolean | null;
@@ -1,11 +1,20 @@
1
- import { ChantRunKind, StyleSetName } from './guidoStyles';
2
- /** One run of marked-up chant text: the rendered text plus what markup
3
- * produced it. An absent `kind` is plain text; `initial` marks the
4
- * `*…*` initial and can combine with a `kind`. */
1
+ import { GuidoScript, SyllableRole } from './guidoScript';
2
+ import { ChantRunKind, MarkDefinitions, PartStyle, StyleSetName } from './guidoStyles';
3
+ import { Mark, SpanProblem } from './textMarkup';
4
+ /** One run of marked-up chant text. `marks` are all its marks; `kind` the
5
+ * notation-fixed one among them, absent on plain text (derived from
6
+ * `marks`, kept for existing consumers); `initial` a `*…*` initial, which
7
+ * combines with a `kind`. `role` is what its syllable is for. */
5
8
  export interface ChantRun {
6
9
  text: string;
7
10
  kind?: ChantRunKind;
8
11
  initial?: boolean;
12
+ marks: Mark[];
13
+ role: SyllableRole;
14
+ }
15
+ /** A merged run, which says where its word ends. */
16
+ export interface ChantWordRun extends ChantRun {
17
+ wordEnd: boolean;
9
18
  }
10
19
  /** The runs of one syllable. */
11
20
  export interface ChantSyllable {
@@ -16,21 +25,55 @@ export interface ChantWord {
16
25
  syllables: ChantSyllable[];
17
26
  }
18
27
  export interface ChantMarkupOptions {
19
- /** The style set whose default script transforms apply, mirroring
20
- * what a score render does (BNS marks the first initial). Defaults
21
- * to DEFAULT_STYLE_SET; presentation differences between style sets
22
- * never reach the output. */
28
+ /** The roles to keep (default: all of them) */
29
+ roles?: readonly SyllableRole[];
30
+ }
31
+ /** The marked-up text of the script: its words, their syllables, and each
32
+ * syllable's runs, as written (letter case included) and the same in every
33
+ * style set. With `merge: 'word'`, a flat list instead: within a word,
34
+ * neighbouring runs with the same marks and role join, so `De` + `us` read
35
+ * as `Deus`. */
36
+ export declare function chantRuns(script: string, options?: ChantMarkupOptions & {
37
+ merge?: undefined;
38
+ }): ChantWord[];
39
+ export declare function chantRuns(script: string, options: ChantMarkupOptions & {
40
+ merge: 'word';
41
+ }): ChantWordRun[];
42
+ /** Options of `chantHtml`. */
43
+ export interface ChantHtmlOptions extends ChantMarkupOptions {
44
+ /** Put before every class name, so they cannot collide with the host
45
+ * page's (`gx-` gives `gx-liturgy`) */
46
+ classPrefix?: string;
47
+ }
48
+ /** The marked-up text as an HTML string: one span per marked run, classed
49
+ * with its kind, `initial` and any marks of its own, bare text otherwise.
50
+ * Syllables of a word concatenate and words join with single spaces —
51
+ * hyphenation is the consumer's job, and `chantRuns` has the syllable
52
+ * boundaries. Text is HTML-escaped. */
53
+ export declare function chantHtml(script: string, options?: ChantHtmlOptions): string;
54
+ /** A style set and a score's own marks, for the look of a mark. */
55
+ export interface MarkLookOptions {
23
56
  style?: StyleSetName;
57
+ marks?: MarkDefinitions;
24
58
  }
25
- /** The marked-up sung text of the script: its words, their syllables,
26
- * and each syllable's runs of notation-fixed kinds. Renders exactly the
27
- * text a score render would (including the style set's default script
28
- * transforms) with the style-set presentation stripped; letter case is
29
- * the raw text's, so a BNS-look consumer uppercases rubrics in CSS. */
30
- export declare function chantRuns(script: string, options?: ChantMarkupOptions): ChantWord[];
31
- /** The marked-up sung text as an HTML string: one span per kinded or
32
- * initial run, classed with the kind (and `initial`), bare text
33
- * otherwise. Syllables of a word concatenate and words join with single
34
- * spaces — hyphenation is the consumer's job, and `chantRuns` has the
35
- * syllable boundaries. Text is HTML-escaped. */
36
- export declare function chantHtml(script: string, options?: ChantMarkupOptions): string;
59
+ /** The resolved look of comma-separated marks (`red,sc`), for a host styling
60
+ * prose to match a score. */
61
+ export declare function chantTextStyle(marks: string, options?: MarkLookOptions): PartStyle;
62
+ /** A mark no style set or score defines, or a character a mark's font does
63
+ * not have. The text still renders, without that look or in a fallback
64
+ * font. */
65
+ export type MarkWarning = {
66
+ kind: 'mark';
67
+ mark: Mark;
68
+ text: string;
69
+ message: string;
70
+ } | {
71
+ kind: 'glyph';
72
+ char: string;
73
+ text: string;
74
+ message: string;
75
+ };
76
+ /** What is wrong with the script's text markup: malformed `{…}` spans,
77
+ * unknown marks, and characters the Liturgy font does not have, each once
78
+ * per syllable. */
79
+ export declare function markupWarnings(script: GuidoScript | string, options?: MarkLookOptions): (SpanProblem | MarkWarning)[];
@@ -0,0 +1,130 @@
1
+ /** How the staff is drawn: by the font (Guido HU's own lines, the default)
2
+ * or as elements behind the staffless font. */
3
+ export type StaffMode = 'font' | 'drawn';
4
+ /** A staff line color: any CSS color (alpha included), or one for the light
5
+ * and one for the dark color scheme. */
6
+ export type StaffColor = string | {
7
+ readonly light: string;
8
+ readonly dark?: string;
9
+ };
10
+ export type PitchLetter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g';
11
+ /** The drawn staff's options (render, embed and React). */
12
+ export interface DrawnStaffOptions {
13
+ /** How the staff is drawn (default `font`); every option below needs `drawn` */
14
+ staff?: StaffMode;
15
+ /** The fewest lines to draw, 1–5 (default 5). The lines sit where the
16
+ * score's notes and clefs need them, and more are drawn when a note
17
+ * would otherwise need a ledger line (or a clef has no line to sit on). */
18
+ staffLines?: number;
19
+ /** Every drawn line's color (default: the notes' text color) */
20
+ staffColor?: StaffColor;
21
+ /** Colors by position, bottom line first; wins over `staffColor` */
22
+ staffLineColors?: readonly (StaffColor | null | undefined)[];
23
+ /** Colors by the pitch a line carries under the clef in effect (the
24
+ * historical red F and yellow C lines); wins over the others */
25
+ staffPitchColors?: Readonly<Partial<Record<PitchLetter, StaffColor>>>;
26
+ /** Every drawn line's thickness as a multiple of the font's (default 1).
27
+ * The weights multiply: all × by position × clef line. */
28
+ staffWeight?: number;
29
+ /** Thickness multipliers by position, bottom line first (default 1) */
30
+ staffLineWeights?: readonly (number | null | undefined)[];
31
+ /** Thickness multiplier of the line the clef in effect sits on, which
32
+ * follows inline clef changes (default 1): above 1, the clef's line
33
+ * stands out from the others */
34
+ staffClefLineWeight?: number;
35
+ /** Run every drawn line past the score: `start` is where the lines begin
36
+ * and `end` where they end, in px from the notes line's left edge (a
37
+ * negative `start` reaches left of it). A line already longer keeps its
38
+ * own ends. Nothing is resized: the lines just overflow the score (and
39
+ * its container), so the host decides how far, e.g. to the screen's
40
+ * edges, and whether a scrolling ancestor clips them. */
41
+ staffOverflow?: StaffOverflow;
42
+ /** Snap the lines to device pixels after a render (default true) */
43
+ staffSnap?: boolean;
44
+ }
45
+ /** How far the drawn lines run past the score (`DrawnStaffOptions.staffOverflow`). */
46
+ export interface StaffOverflow {
47
+ start?: number;
48
+ end?: number;
49
+ }
50
+ /** The staffless font's family, as the notes line's font stack names it. */
51
+ export declare const STAFFLESS_FONT_FAMILY = "'Guidohu Staffless'";
52
+ export declare const STAFF_LINE_COUNT: number;
53
+ /** The drawn lines, as line indices (0 = bottom) `lo`…`hi`. */
54
+ export interface StaffLineRange {
55
+ lo: number;
56
+ hi: number;
57
+ }
58
+ /**
59
+ * The lines to draw for a score: the lowest run of at least `fewest` lines
60
+ * that carries every note and clef without a ledger line. A note on a line
61
+ * needs that line; a note in a space needs a line next to it (a space just
62
+ * outside the outermost line is fine); a clef needs its line. A note beyond
63
+ * the five lines brings its ledger lines with the glyph, so the staff then
64
+ * runs to the outermost line. When the notes need more lines than `fewest`,
65
+ * more are drawn.
66
+ */
67
+ export declare function chooseStaffLines(lines: readonly {
68
+ clefPrefix: string;
69
+ notesParts: readonly string[];
70
+ }[], fewest?: number): StaffLineRange;
71
+ /** The color a line takes under `clef` (a clef glyph), or undefined for
72
+ * the default (the notes' text color). */
73
+ export declare function staffLineColor(index: number, clef: string, options: DrawnStaffOptions): StaffColor | undefined;
74
+ /** A line's thickness multiplier under `clef`: all lines × its position ×
75
+ * the clef's own line. */
76
+ export declare function staffLineWeight(index: number, clef: string, options: DrawnStaffOptions): number;
77
+ /** One stretch of a drawn line, in px from the notes line's start. */
78
+ export interface StaffSpan {
79
+ line: number;
80
+ left: number;
81
+ right: number;
82
+ color: StaffColor | undefined;
83
+ /** Thickness multiplier (1 = the font's line) */
84
+ weight: number;
85
+ }
86
+ /**
87
+ * The drawn line stretches of one notes line: `text` as the notes line holds
88
+ * it (clef prefix and notes), plus the break marker `*` when it stands
89
+ * `breakMarkerLeftPx` past the text. Each line index in `range` is one span
90
+ * per run of glyphs with the same color and weight, which change at an
91
+ * inline clef.
92
+ */
93
+ export declare function staffSpans(text: string, notesPx: number, range: StaffLineRange, options?: DrawnStaffOptions, breakMarkerLeftPx?: number): StaffSpan[];
94
+ /**
95
+ * The drawn staff of one notes line: a zero-size anchor on the baseline at
96
+ * the line's start, holding one absolutely placed span per stretch. Heights
97
+ * and offsets are in em of the notes font, so the lines sit right without
98
+ * measuring; `snapStaff` then aligns them to device pixels. A weighted line
99
+ * grows from the font line's centre. The spans sit at `z-index: -1`, so the
100
+ * notes paint over them once the notes line is its own stacking context
101
+ * (`isolation: isolate`, which GuidoRender sets).
102
+ */
103
+ export declare function staffLayer(spans: readonly StaffSpan[]): HTMLSpanElement;
104
+ /**
105
+ * Aligns every drawn staff line under `root` to device pixels: each line's
106
+ * thickness is rounded to whole device pixels (at least one) and its edges
107
+ * land on pixel boundaries, so every line draws as one even, sharp stroke.
108
+ * Needs `root` in the document; call it again after the score moves by a
109
+ * fraction of a pixel (a render calls it, and so does the embed's resize
110
+ * re-render).
111
+ */
112
+ export declare function snapStaff(root: ParentNode): void;
113
+ /**
114
+ * A staff color written as text (data attributes, settings): one CSS color,
115
+ * or `light|dark`. Empty → undefined; an invalid color warns and gives
116
+ * undefined.
117
+ */
118
+ export declare function parseStaffColor(text: string | undefined, label?: string): StaffColor | undefined;
119
+ /** Colors by position as text: up to five colors (`light|dark` each),
120
+ * bottom line first, separated by `;` (an empty entry keeps the default). */
121
+ export declare function parseStaffLineColors(text: string | undefined): (StaffColor | undefined)[] | undefined;
122
+ /** Colors by pitch as text: `c: gold; f: #d40000|#ff6060`. */
123
+ export declare function parseStaffPitchColors(text: string | undefined): Partial<Record<PitchLetter, StaffColor>> | undefined;
124
+ /** A weight written as text: a positive number, else undefined (warns). */
125
+ export declare function parseStaffWeight(text: string | undefined, label?: string): number | undefined;
126
+ /** Weights by position as text: up to five numbers, bottom line first,
127
+ * separated by `;` (an empty entry keeps 1). */
128
+ export declare function parseStaffLineWeights(text: string | undefined): (number | undefined)[] | undefined;
129
+ /** The text form of a staff color (`light|dark`), the inverse of `parseStaffColor`. */
130
+ export declare function formatStaffColor(color: StaffColor | undefined): string;
@@ -1,5 +1,7 @@
1
+ import { StaffFill } from './chantLayout';
1
2
  import { StyleSetName } from './guidoStyles';
2
3
  import { SpacerChar } from './wordExport';
4
+ import { StaffMode } from './drawnStaff';
3
5
  /** Versioned localStorage key; an unknown version is ignored wholesale. */
4
6
  export declare const EDITOR_STORAGE_KEY = "guidex.editor.v1";
5
7
  export declare const EDITOR_SCHEMA_VERSION = 1;
@@ -21,6 +23,13 @@ export declare const MAX_WIDTH_PX_MAX = 1400;
21
23
  /** Declared range of the transpose slider. */
22
24
  export declare const JUNCTION_DASHES_MIN = 1;
23
25
  export declare const JUNCTION_DASHES_MAX = 8;
26
+ export declare const STAFF_FILL_SNAP_MIN = 0;
27
+ export declare const STAFF_FILL_SNAP_MAX = 60;
28
+ export declare const STAFF_LINES_MIN = 1;
29
+ export declare const STAFF_LINES_MAX = 5;
30
+ /** The staff weight sliders' range (a multiple of the font's line). */
31
+ export declare const STAFF_WEIGHT_MIN = 0.5;
32
+ export declare const STAFF_WEIGHT_MAX = 4;
24
33
  export declare const TRANSPOSE_MIN = -6;
25
34
  export declare const TRANSPOSE_MAX = 6;
26
35
  /** The destination Word text size default (notes ride at twice it) and the
@@ -46,8 +55,6 @@ export interface WordCopySettings {
46
55
  export interface EditorSettings {
47
56
  style: StyleSetName;
48
57
  bold: boolean;
49
- /** The start-with-initial transform enabled. */
50
- initial: boolean;
51
58
  maxWidthPx: number;
52
59
  transpose: number;
53
60
  basePx: number;
@@ -58,6 +65,29 @@ export interface EditorSettings {
58
65
  notesCustom: boolean;
59
66
  /** Dashes in a normal junction between note groups. */
60
67
  junctionDashes: number;
68
+ /** How far each staff line runs. */
69
+ staffFill: StaffFill;
70
+ /** With `longest`: the distance from the max width that snaps to it. */
71
+ staffFillSnapPx: number;
72
+ /** Two-syllable recitations as plain notes (issue #21). */
73
+ twoSyllableRecitationsToPlain: boolean;
74
+ /** Three or more plain notes on a line as a recitation (issue #21). */
75
+ plainRunsToRecitation: boolean;
76
+ /** The drawn staff: mode, fewest lines and its colors as text
77
+ * (`light|dark` colors, `;`-separated lists — the embed's attribute syntax). */
78
+ staff: StaffMode;
79
+ staffLines: number;
80
+ staffColor: string;
81
+ staffLineColors: string;
82
+ staffPitchColors: string;
83
+ /** Line thickness multipliers: all lines, by position (`;` list), and
84
+ * the clef's own line. */
85
+ staffWeight: number;
86
+ staffLineWeights: string;
87
+ staffClefLineWeight: number;
88
+ /** The preview's drawn lines run to the screen's edges (a page
89
+ * setting: not part of a saved chant or a share link). */
90
+ staffToEdges: boolean;
61
91
  customColors: boolean;
62
92
  colorFg: string;
63
93
  colorAccent: string;
@@ -144,8 +174,6 @@ export declare const CHANTS_SCHEMA_VERSION = 1;
144
174
  export interface ChantPrefs {
145
175
  style: StyleSetName;
146
176
  bold: boolean;
147
- /** The start-with-initial transform enabled. */
148
- initial: boolean;
149
177
  basePx: number;
150
178
  decoupleNotes: boolean;
151
179
  /** The chant size while decoupled (the adopted 2× base or a typed one). */
@@ -153,6 +181,18 @@ export interface ChantPrefs {
153
181
  /** True once the user typed a chant size of their own. */
154
182
  notesCustom: boolean;
155
183
  junctionDashes: number;
184
+ staffFill: StaffFill;
185
+ staffFillSnapPx: number;
186
+ twoSyllableRecitationsToPlain: boolean;
187
+ plainRunsToRecitation: boolean;
188
+ staff: StaffMode;
189
+ staffLines: number;
190
+ staffColor: string;
191
+ staffLineColors: string;
192
+ staffPitchColors: string;
193
+ staffWeight: number;
194
+ staffLineWeights: string;
195
+ staffClefLineWeight: number;
156
196
  transpose: number;
157
197
  }
158
198
  export interface SavedChant {
@@ -1,5 +1,9 @@
1
1
  import { EmptySlots, StanzaStack, StanzaWarning } from '../stanzas';
2
- import { StyleSetName } from '../guidoStyles';
2
+ import { MarkWarning } from '../chantMarkup';
3
+ import { DrawnStaffOptions } from '../drawnStaff';
4
+ import { SpanProblem } from '../textMarkup';
5
+ import { StaffFill } from '../chantLayout';
6
+ import { MarkDefinitions, StyleSetName } from '../guidoStyles';
3
7
  export declare const version: string;
4
8
  /** Line-breaking budget: a fixed pixel width, or 'auto' to fit the
5
9
  * target element (re-rendered on resize). `Infinity` (or any large
@@ -8,15 +12,30 @@ export declare const version: string;
8
12
  * (`overflow-x: auto` to scroll, `hidden` to clip). */
9
13
  export type MaxWidth = number | 'auto';
10
14
  /** Site-wide defaults, settable through `GuidexEmbed.init`. */
11
- export interface EmbedOptions {
15
+ export interface EmbedOptions extends DrawnStaffOptions {
12
16
  /** Selector for target elements (default '.guidex-script, .guido-script') */
13
17
  selector?: string;
14
18
  maxWidth?: MaxWidth;
15
19
  style?: StyleSetName;
16
20
  bold?: boolean;
17
21
  textPx?: number;
22
+ /** Marks this score adds to its style set's */
23
+ marks?: MarkDefinitions;
18
24
  /** Dashes in a normal junction between note groups, in steps of a third (default 3) */
19
25
  junctionDashes?: number;
26
+ /** How far each staff line runs (default `all-but-last`) */
27
+ staffFill?: StaffFill;
28
+ /** With `staffFill: 'longest'`: the distance from the available width
29
+ * within which every line runs to it instead (default 0) */
30
+ staffFillSnapPx?: number;
31
+ /** Render a recitation that covers exactly 2 syllables on a line as
32
+ * plain notes of the same pitch (default true, issue #21;
33
+ * `data-two-syllable-recitations-to-plain`) */
34
+ twoSyllableRecitationsToPlain?: boolean;
35
+ /** Render 3 or more syllables on one plain note with a reciting glyph
36
+ * (`1`–`9`, `ö`, `ü`) on a line as a recitation (default false;
37
+ * `data-plain-runs-to-recitation`) */
38
+ plainRunsToRecitation?: boolean;
20
39
  transpose?: number;
21
40
  /** The stanza sung under the notes (1-based; 1 is the script's own
22
41
  * text, 2… its `(@stanza …)` statements or the `stanzas` option). */
@@ -39,10 +58,13 @@ export interface RenderScoreOptions extends Omit<EmbedOptions, 'selector'> {
39
58
  }
40
59
  /** What a finished render reports: the rendered stanzas' count
41
60
  * mismatches (missing syllables show as placeholders, extra ones are
42
- * dropped). */
61
+ * dropped) and the characters the Liturgy font does not have. */
43
62
  export interface RenderResult {
44
- warnings: StanzaWarning[];
63
+ warnings: ScoreWarning[];
45
64
  }
65
+ /** What a render warns about: a stanza's count mismatch, a malformed
66
+ * `{…}` span, an unknown mark, or a character the Liturgy font lacks. */
67
+ export type ScoreWarning = StanzaWarning | MarkWarning | SpanProblem;
46
68
  /** Cleans up a programmatically rendered element: stops resize
47
69
  * re-rendering and drops the cached source and option overrides. Does
48
70
  * not remove the rendered score itself. */
@@ -1,4 +1,4 @@
1
- import { a as dispose, c as renderScore, i as scoreSvg, l as version, n as downloadScoreSvg, o as init, r as scorePngBlob, s as renderAll, t as downloadScorePng } from "../scoreImage-lvOrTbG-.js";
1
+ import { a as dispose, c as renderScore, i as scoreSvg, l as version, n as downloadScoreSvg, o as init, r as scorePngBlob, s as renderAll, t as downloadScorePng } from "../scoreImage-B2SGdROL.js";
2
2
  //#region src/embed/index.ts
3
3
  if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => init(), { once: true });
4
4
  else init();
@@ -11,21 +11,27 @@
11
11
  * `KEY_SIGNATURES`), the stanzas (`withStanza`, `selectStanza`,
12
12
  * `parseStanza`, `stanzaWarnings`, `padStanza`, `stanzaCount`,
13
13
  * `slotCount`, and the stacked `stackStanzas`), the marked-up text export (`chantRuns`, `chantHtml`,
14
+ * `chantTextStyle`, `markupWarnings`,
14
15
  * plus the raw run resolver `resolveSyllableParts`), the style-set
15
16
  * registry (`STYLE_SETS`, `DEFAULT_STYLE_SET`), the
17
+ * drawn staff helpers (`snapStaff`, `chooseStaffLines`, `staffSpans`, the
18
+ * staff color parsers), the
16
19
  * Word-compatible export (`toWordHtml`, `toWordText`, `layoutForWord`,
17
20
  * `wordLayoutText` — also available alone as `guidex/word`, `copyWordHtml`,
18
21
  * `copyWordPlainText`, `checkWordHtml`), and the image export
19
22
  * (`scoreSvg`, `scorePngBlob`, `downloadScorePng`, `downloadScoreSvg`).
20
23
  */
21
24
  export * from './core';
22
- export { GuidoScript, unescape, chantText, scriptSyllables, type ScriptSyllable, } from '../guidoScript';
25
+ export { GuidoScript, unescape, chantText, scriptSyllables, type ChantTextOptions, type ScriptSyllable, type SyllableRole, } from '../guidoScript';
23
26
  export { SCORE_MARKERS, splitNoteMarkers, type NoteGroupParts } from '../noteGroups';
24
27
  export { composeScript, type ComposeOptions, type MarkerPart, type NotesPart, type PartTranspose, type ScriptPart, type ScriptSlicePart, } from '../composeScript';
25
- export { chantRuns, chantHtml } from '../chantMarkup';
26
- export { STYLE_SETS, DEFAULT_STYLE_SET, resolveSyllableParts } from '../guidoStyles';
28
+ export { chantRuns, chantHtml, chantTextStyle, markupWarnings, type ChantHtmlOptions, type ChantWordRun, type MarkWarning, } from '../chantMarkup';
29
+ export { STYLE_SETS, DEFAULT_STYLE_SET, defineStyleSet, resolveSyllableParts, type MarkDefinitions, type StyleSetDefinition, } from '../guidoStyles';
30
+ export type { Mark, SpanProblem, TextRun } from '../textMarkup';
27
31
  export { KEY_SIGNATURES, PITCH_ROWS, STANZA_PLACEHOLDER, padStanza, parseInterval, parseStanza, selectStanza, slotCount, smallHeads, stackStanzas, stackedStanzaNumbers, stanzaCount, stanzaTexts, stanzaWarnings, transposeBy, transposeExact, transposeNotes, transposeScript, TranspositionRangeError, withStanza, type EmptySlots, type SelectStanzaOptions, type ScriptTransform, type StanzaOptions, type StanzaStack, type StanzaSyllable, type StanzaWarning, type SpelledInterval, type TransposeOverflow, type TranspositionTarget, } from '../guidoScriptTransforms';
28
32
  export type { StyleSetName, SyllablePart, PartStyle, ChantRunKind } from '../guidoStyles';
33
+ export type { StaffFill } from '../chantLayout';
34
+ export { chooseStaffLines, formatStaffColor, parseStaffColor, parseStaffLineColors, parseStaffLineWeights, parseStaffPitchColors, parseStaffWeight, snapStaff, staffLineColor, staffLineWeight, staffSpans, STAFFLESS_FONT_FAMILY, type DrawnStaffOptions, type PitchLetter, type StaffColor, type StaffLineRange, type StaffMode, type StaffOverflow, type StaffSpan, } from '../drawnStaff';
29
35
  export type { ChantRun, ChantSyllable, ChantWord, ChantMarkupOptions } from '../chantMarkup';
30
36
  export { DEFAULT_SPACER, DEFAULT_TAB_INTERVAL_PT, SpacerMeter, layoutForWord, toWordHtml, toWordText, wordLayoutText, type SpacerChar, type SpacerConfig, type SpacerWidth, type WordExportOptions, type WordLayout, type WordLine, type WordRun, type WordStyleNames, type WordTextPiece, } from '../wordExport';
31
37
  export { baseOf, gClefPitchOf, modifyDown, modifyNatural, modifyUp, toCephalicus, toConnectDown, toLonga, toSmallHead, toSmallPoint, toVirga, variantOf, type VariantRole, } from '../glyphFamilies';
@@ -1,6 +1,6 @@
1
- import { a as dispose, c as renderScore, i as scoreSvg, l as version, n as downloadScoreSvg, o as init, r as scorePngBlob, s as renderAll, t as downloadScorePng } from "../scoreImage-lvOrTbG-.js";
2
- import { $ as toVirga, A as stanzaWarnings, B as unescape, C as selectStanza, D as stackedStanzaNumbers, E as stackStanzas, F as chantText, G as modifyDown, H as baseOf, I as escape, J as toCephalicus, K as modifyNatural, L as runProperties, M as SCORE_MARKERS, N as splitNoteMarkers, O as stanzaCount, P as GuidoScript, Q as toSmallPoint, R as scriptSyllables, S as parseStanza, T as smallHeads, U as gClefPitchOf, W as isClefGlyph, X as toLonga, Y as toConnectDown, Z as toSmallHead, _ as transposeExact, a as DEFAULT_STYLE_SET, b as isSlot, d as transposeBy, et as variantOf, f as transposeNotes, g as sameKeyGlyphs, h as parseInterval, j as withStanza, k as stanzaTexts, l as resolveSyllableParts, m as TranspositionRangeError, o as STYLE_SETS, p as KEY_SIGNATURES, q as modifyUp, u as PITCH_ROWS, v as transposeScript, w as slotCount, x as padStanza, y as STANZA_PLACEHOLDER, z as statementSource } from "../chantLayout-CVVuJUJl.js";
3
- import { a as DEFAULT_TAB_INTERVAL_PT, c as toWordHtml, i as DEFAULT_SPACER, l as toWordText, n as copyWordHtml, o as SpacerMeter, r as copyWordPlainText, s as layoutForWord, t as checkWordHtml, u as wordLayoutText } from "../wordChecker-DG09l_ol.js";
1
+ import { A as TranspositionRangeError, B as slotCount, C as chantRuns, D as transposeBy, E as PITCH_ROWS, F as STANZA_PLACEHOLDER, G as stanzaTexts, H as stackStanzas, I as isSlot, K as stanzaWarnings, L as padStanza, M as sameKeyGlyphs, N as transposeExact, O as transposeNotes, P as transposeScript, R as parseStanza, S as chantHtml, T as markupWarnings, U as stackedStanzaNumbers, V as smallHeads, W as stanzaCount, _ as parseStaffWeight, a as dispose, b as staffLineWeight, c as renderScore, d as chooseStaffLines, f as formatStaffColor, g as parseStaffPitchColors, h as parseStaffLineWeights, i as scoreSvg, j as parseInterval, k as KEY_SIGNATURES, l as version, m as parseStaffLineColors, n as downloadScoreSvg, o as init, p as parseStaffColor, q as withStanza, r as scorePngBlob, s as renderAll, t as downloadScorePng, u as STAFFLESS_FONT_FAMILY, v as snapStaff, w as chantTextStyle, x as staffSpans, y as staffLineColor, z as selectStanza } from "../scoreImage-B2SGdROL.js";
2
+ import { B as toCephalicus, C as scriptSyllables, E as unescape, G as toVirga, H as toLonga, I as modifyDown, K as variantOf, L as modifyNatural, M as baseOf, N as gClefPitchOf, O as SCORE_MARKERS, P as isClefGlyph, R as modifyUp, S as runProperties, T as syllableText, U as toSmallHead, V as toConnectDown, W as toSmallPoint, _ as GuidoScript, a as DEFAULT_STYLE_SET, c as defineStyleSet, k as splitNoteMarkers, p as resolveSyllableParts, s as STYLE_SETS, v as chantText, w as statementSource, y as escape } from "../chantLayout-BrCQUOhp.js";
3
+ import { a as DEFAULT_TAB_INTERVAL_PT, c as toWordHtml, i as DEFAULT_SPACER, l as toWordText, n as copyWordHtml, o as SpacerMeter, r as copyWordPlainText, s as layoutForWord, t as checkWordHtml, u as wordLayoutText } from "../wordChecker-CjYl2yof.js";
4
4
  //#region src/composeScript.ts
5
5
  /**
6
6
  * Combining scripts (issue #71): one GuidoScript built from parts of
@@ -50,13 +50,18 @@ function stateAfter(tokens, state) {
50
50
  function openRuns(tokens) {
51
51
  const depth = {
52
52
  tight: 0,
53
- keep: 0
53
+ keep: 0,
54
+ aid: 0
54
55
  };
55
56
  for (const tok of tokens) {
56
- if (tok.kind !== "tight" && tok.kind !== "keep" && tok.kind !== "unit") continue;
57
+ if (tok.kind !== "tight" && tok.kind !== "keep" && tok.kind !== "unit" && tok.kind !== "aid") continue;
57
58
  for (const prop of runProperties(tok.kind)) depth[prop] = Math.max(0, depth[prop] + (tok.on ? 1 : -1));
58
59
  }
59
- return ["tight", "keep"].flatMap((prop) => Array(depth[prop]).fill(prop));
60
+ return [
61
+ "tight",
62
+ "keep",
63
+ "aid"
64
+ ].flatMap((prop) => Array(depth[prop]).fill(prop));
60
65
  }
61
66
  /** Tokens written back as script source (the `GuidoScript.toString`
62
67
  * rules: an empty slot always writes its `~`). */
@@ -64,14 +69,14 @@ function writeTokens(tokens) {
64
69
  return tokens.map((tok, i) => {
65
70
  const prefix = i > 0 && tok.spaceBefore ? " " : "";
66
71
  if (tok.kind !== "syllable") return prefix + statementSource(tok);
67
- return `${prefix}${tok.empty ? "~" : tok.text === "~" ? "\\~" : escape(tok.text)}(${escape(tok.notes)})`;
72
+ return `${prefix}${tok.empty ? "~" : tok.source}(${escape(tok.notes)})`;
68
73
  }).join("");
69
74
  }
70
75
  /** A stanza item written back as stanza text (see `parseStanza`). */
71
76
  function stanzaItemSource(item) {
72
77
  if (item.kind === "hold") return "-";
73
78
  if (item.kind === "empty") return "~";
74
- const text = Array.from(item.text, (ch) => /\s/.test(ch) ? "~" : "\\-=­~()".includes(ch) ? `\\${ch}` : ch).join("");
79
+ const text = (item.source ?? escape(item.text)).replace(/\\.|./gsu, (unit) => unit[0] === "\\" ? unit : /\s/.test(unit) ? "~" : "-=­~".includes(unit) ? `\\${unit}` : unit);
75
80
  return item.wordEnd ? text : `${text}-`;
76
81
  }
77
82
  /** Applies a staff-degree or exact transposition to a whole script. */
@@ -268,7 +273,8 @@ function composeScript(parts, options = {}) {
268
273
  append({
269
274
  tokens: [{
270
275
  kind: "syllable",
271
- text: "**",
276
+ ...syllableText("**"),
277
+ role: "sign",
272
278
  notes: "",
273
279
  wordEnd: true,
274
280
  spaceBefore: false
@@ -345,43 +351,4 @@ function composeScript(parts, options = {}) {
345
351
  return clefGroup(opening) + writeTokens(out) + stanzas.join("");
346
352
  }
347
353
  //#endregion
348
- //#region src/chantMarkup.ts
349
- /**
350
- * The marked-up sung text of a chant script, for other applications: the
351
- * same run resolution the renderer draws, expressed as notation-fixed
352
- * semantic kinds instead of style-set CSS values. `chantRuns` gives the
353
- * structured form (words → syllables → runs); `chantHtml` serializes it
354
- * as HTML spans classed with those kinds (`liturgy`, `rubric`, `star`,
355
- * `marker`, `plus`, plus `initial`), so a consumer styles the classes
356
- * with its own CSS.
357
- */
358
- var chantRunOf = (part) => {
359
- const run = { text: part.text };
360
- if (part.kind !== void 0) run.kind = part.kind;
361
- if (part.style.initial) run.initial = true;
362
- return run;
363
- };
364
- /** The marked-up sung text of the script: its words, their syllables,
365
- * and each syllable's runs of notation-fixed kinds. Renders exactly the
366
- * text a score render would (including the style set's default script
367
- * transforms) with the style-set presentation stripped; letter case is
368
- * the raw text's, so a BNS-look consumer uppercases rubrics in CSS. */
369
- function chantRuns(script, options = {}) {
370
- const styleSet = STYLE_SETS[options.style ?? "BNS"];
371
- return new GuidoScript(script, { transforms: styleSet.scriptTransforms ?? [] }).words.map((word) => ({ syllables: word.syllables.map((syl) => ({ runs: resolveSyllableParts(syl.text, styleSet, false, { rawCase: true }).map(chantRunOf) })) }));
372
- }
373
- /** The marked-up sung text as an HTML string: one span per kinded or
374
- * initial run, classed with the kind (and `initial`), bare text
375
- * otherwise. Syllables of a word concatenate and words join with single
376
- * spaces — hyphenation is the consumer's job, and `chantRuns` has the
377
- * syllable boundaries. Text is HTML-escaped. */
378
- function chantHtml(script, options = {}) {
379
- return chantRuns(script, options).map((word) => word.syllables.map((syl) => syl.runs.map(runHtml).join("")).join("")).join(" ");
380
- }
381
- var runHtml = (run) => {
382
- const classes = [...run.kind ? [run.kind] : [], ...run.initial ? ["initial"] : []].join(" ");
383
- return classes ? `<span class="${classes}">${escapeHtml(run.text)}</span>` : escapeHtml(run.text);
384
- };
385
- var escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
386
- //#endregion
387
- export { DEFAULT_SPACER, DEFAULT_STYLE_SET, DEFAULT_TAB_INTERVAL_PT, GuidoScript, KEY_SIGNATURES, PITCH_ROWS, SCORE_MARKERS, STANZA_PLACEHOLDER, STYLE_SETS, SpacerMeter, TranspositionRangeError, baseOf, chantHtml, chantRuns, chantText, checkWordHtml, composeScript, copyWordHtml, copyWordPlainText, dispose, downloadScorePng, downloadScoreSvg, gClefPitchOf, init, layoutForWord, modifyDown, modifyNatural, modifyUp, padStanza, parseInterval, parseStanza, renderAll, renderScore, resolveSyllableParts, scorePngBlob, scoreSvg, scriptSyllables, selectStanza, slotCount, smallHeads, splitNoteMarkers, stackStanzas, stackedStanzaNumbers, stanzaCount, stanzaTexts, stanzaWarnings, toCephalicus, toConnectDown, toLonga, toSmallHead, toSmallPoint, toVirga, toWordHtml, toWordText, transposeBy, transposeExact, transposeNotes, transposeScript, unescape, variantOf, version, withStanza, wordLayoutText };
354
+ export { DEFAULT_SPACER, DEFAULT_STYLE_SET, DEFAULT_TAB_INTERVAL_PT, GuidoScript, KEY_SIGNATURES, PITCH_ROWS, SCORE_MARKERS, STAFFLESS_FONT_FAMILY, STANZA_PLACEHOLDER, STYLE_SETS, SpacerMeter, TranspositionRangeError, baseOf, chantHtml, chantRuns, chantText, chantTextStyle, checkWordHtml, chooseStaffLines, composeScript, copyWordHtml, copyWordPlainText, defineStyleSet, dispose, downloadScorePng, downloadScoreSvg, formatStaffColor, gClefPitchOf, init, layoutForWord, markupWarnings, modifyDown, modifyNatural, modifyUp, padStanza, parseInterval, parseStaffColor, parseStaffLineColors, parseStaffLineWeights, parseStaffPitchColors, parseStaffWeight, parseStanza, renderAll, renderScore, resolveSyllableParts, scorePngBlob, scoreSvg, scriptSyllables, selectStanza, slotCount, smallHeads, snapStaff, splitNoteMarkers, stackStanzas, stackedStanzaNumbers, staffLineColor, staffLineWeight, staffSpans, stanzaCount, stanzaTexts, stanzaWarnings, toCephalicus, toConnectDown, toLonga, toSmallHead, toSmallPoint, toVirga, toWordHtml, toWordText, transposeBy, transposeExact, transposeNotes, transposeScript, unescape, variantOf, version, withStanza, wordLayoutText };