guidex 0.2.6 → 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 (45) hide show
  1. package/README.md +219 -0
  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 +15 -4
  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 +28 -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/index.d.ts +1 -0
  33. package/dist/lib/react/index.js +2 -2
  34. package/dist/lib/scoreImage-DnFIbtF_.js +951 -0
  35. package/dist/lib/scoreImage.d.ts +63 -0
  36. package/dist/lib/word/index.d.ts +17 -0
  37. package/dist/lib/word/index.js +2 -0
  38. package/dist/lib/wordChecker-C3nJrk_j.js +1042 -0
  39. package/dist/lib/wordChecker.d.ts +66 -0
  40. package/dist/lib/wordClipboard.d.ts +25 -0
  41. package/dist/lib/wordExport.d.ts +244 -0
  42. package/dist-embed/guidex-embed.min.js +1 -1
  43. package/package.json +8 -1
  44. package/dist/lib/core-hF6L1EtS.js +0 -1268
  45. package/dist/lib/settingsMenu.d.ts +0 -1
@@ -0,0 +1,169 @@
1
+ import { GuidoScript } from './guidoScript';
2
+ import { StyleSet, StyleSetName, SyllablePart } from './guidoStyles';
3
+ /**
4
+ * Score marker characters: they carry no pitch, and when they sit at the
5
+ * start or end of a note group (with the adjacent dash) they act as
6
+ * whitespace rather than note width.
7
+ */
8
+ export declare const SCORE_MARKERS = ",.:?'\"+!%/=()\u00D6\u00DC\u00D3;";
9
+ /**
10
+ * Special reciting notes: when such a note stands alone in a note group it
11
+ * marks recited text. The glyph shows at a run's first syllable (the
12
+ * previous syllable has different notes) and at every line start; every
13
+ * other recited syllable contributes only the staff-line segments filling
14
+ * the space above its text, which flows tight after the previous text.
15
+ */
16
+ export declare const SPECIAL_NOTES = "\u0178\u00A1\u00A2\u00A3[\u00A5\u00A6\u00A9\u00AA\u00AB\u00AC";
17
+ /**
18
+ * Modifier glyphs: flats, sharps, and naturals. They carry pitch (and
19
+ * transpose with the melody) but modify the note that follows them, so
20
+ * they hang in the junction whitespace: the syllable text anchors on the
21
+ * note characters only, and a group starting with a modifier needs only
22
+ * two junction dashes — the glyph itself provides the third dash's
23
+ * separation.
24
+ */
25
+ export declare const NOTE_MODIFIERS: string;
26
+ /** Canvas text measurement, shared with the emitters (the Word export
27
+ * measures the spacer character's natural advance for the unit width). */
28
+ export declare function measure(text: string, font: string): number;
29
+ /** Options for one layout pass. All fields optional; defaults reproduce the
30
+ * original Book Antiqua look (style set BNS). */
31
+ export interface LayoutOptions {
32
+ /** Named style set from STYLE_SETS (default: BNS) */
33
+ style?: StyleSetName;
34
+ /** Lay out all text bold, measurements included */
35
+ bold?: boolean;
36
+ /** Text line size in px (default 18) */
37
+ textPx?: number;
38
+ /** Notes line size in px (default textPx * 2) */
39
+ notesPx?: number;
40
+ /** Maximum notes-line width before a staff break (default: none) */
41
+ maxWidthPx?: number;
42
+ }
43
+ /** A horizontal whitespace gap on the text line: the lead-in shared with
44
+ * the clef, or the gap after a word-ending syllable. Both emitters fake it
45
+ * with their own mechanism (px spacer span / unit × count run). */
46
+ export interface GapSegment {
47
+ kind: 'gap';
48
+ role: 'lead-in' | 'word-gap';
49
+ /** The gap's width in px (the DOM emitter's spacer span) */
50
+ width: number;
51
+ /** Ideal absolute px where the gap ends: the start of the content that
52
+ * follows it (a pending no-note run or the syllable text). The
53
+ * self-correcting unit accounting targets this anchor, not the width. */
54
+ endPx: number;
55
+ /** Ideal absolute px where the syllable text after any pending runs
56
+ * starts (debug output only) */
57
+ textStartPx: number;
58
+ }
59
+ /** A dash connector centered between two syllables of the same word. */
60
+ export interface ConnectorSegment {
61
+ kind: 'connector';
62
+ /** Each side pad's width in px (the DOM emitter's twin spacer spans) */
63
+ pad: number;
64
+ /** The full gap the dash centers in, px */
65
+ gapWidth: number;
66
+ /** The dash's measured width in the text font, px */
67
+ dashWidth: number;
68
+ /** Ideal absolute px where the dash starts */
69
+ dashStartPx: number;
70
+ /** Ideal absolute px where the text after the dash starts */
71
+ nextAnchorPx: number;
72
+ }
73
+ /** One syllable's text as its resolved runs. Noteless syllables deferred
74
+ * to just before the next noted syllable (or the end of the score) come
75
+ * through with `noNotes`; they have no notes-side numbers. */
76
+ export interface SylSegment {
77
+ kind: 'syl';
78
+ parts: SyllablePart[];
79
+ /** Ideal absolute px where the text starts */
80
+ textStart: number;
81
+ /** The text's measured width in px */
82
+ textWidth: number;
83
+ /** The notes group's note-run width — leading modifiers excluded
84
+ * (0 for no-note syllables) */
85
+ contentWidth: number;
86
+ /** The notes group's note-run start, past leading markers and
87
+ * modifiers (0 for no-note syllables) */
88
+ contentStart: number;
89
+ /** Pad dashes inserted before the group (tight pairs and cursor clears) */
90
+ extraDashes: number;
91
+ /** The syllable clamped hard against the previous one, no dash */
92
+ tight: boolean;
93
+ noNotes: boolean;
94
+ /** A no-note syllable at the very end of the score */
95
+ trailing?: boolean;
96
+ }
97
+ /** A plain word space between two words (a space character, not part of
98
+ * the spacer mechanism). */
99
+ export interface WordSpaceSegment {
100
+ kind: 'word-space';
101
+ width: number;
102
+ }
103
+ /** The syllable dash owed by a line that ends mid-word, centered between
104
+ * the line's text end and its notes end. */
105
+ export interface LineEndDashSegment {
106
+ kind: 'line-end-dash';
107
+ /** Each side pad's width in px (the DOM emitter's twin spacer spans) */
108
+ pad: number;
109
+ dashWidth: number;
110
+ /** Ideal absolute px where the dash starts */
111
+ dashStartPx: number;
112
+ /** Ideal absolute px where the trailing pad ends (the notes end; when
113
+ * the text runs past the notes there is no trailing width and this
114
+ * anchor yields a zero count) */
115
+ trailEndPx: number;
116
+ /** The line's text end in px (debug output only) */
117
+ textEndPx: number;
118
+ }
119
+ export type LayoutSegment = GapSegment | ConnectorSegment | SylSegment | WordSpaceSegment | LineEndDashSegment;
120
+ /** One rendered line pair's layout: the notes-line model and the text
121
+ * line's ordered segments with their ideal absolute positions. */
122
+ export interface LayoutLine {
123
+ notesParts: string[];
124
+ segments: LayoutSegment[];
125
+ /** Where the text line ends (the text cursor when the line closed) */
126
+ textCursor: number;
127
+ /** Where the notes line ends (the notes width when the line closed) */
128
+ notesEnd: number;
129
+ /** Whether the line's last syllable ends its word; null when the
130
+ * line carries no syllable at all */
131
+ lastWordEnd: boolean | null;
132
+ /** The break marker's relative left offset; only set on broken
133
+ * (non-final) lines, after their staff fill dashes */
134
+ breakMarkerLeftPx?: number;
135
+ }
136
+ export interface LayoutResult {
137
+ lines: LayoutLine[];
138
+ clefPrefix: string;
139
+ styleSet: StyleSet;
140
+ styleName: StyleSetName;
141
+ textPx: number;
142
+ notesPx: number;
143
+ bold: boolean;
144
+ /** The maximum width the lines were broken at */
145
+ maxWidthPx: number;
146
+ /** Where the line-end break marker lands: the max width plus the
147
+ * style set's padding */
148
+ starTarget: number;
149
+ starWidth: number;
150
+ }
151
+ /**
152
+ * Lays a GuidoScript score out: a notes line in the chant font, and a text
153
+ * line where each syllable is centered below its notes. The dashes of the
154
+ * chant font are pure whitespace: centering ignores them and happens under
155
+ * the non-whitespace note characters only. When a syllable's text would
156
+ * overlap the previous one, it starts right after it and the notes group is
157
+ * padded with extra dashes until it covers the text.
158
+ *
159
+ * This is the shared layout pass behind every emitter: the DOM renderer
160
+ * turns the returned lines into (notes div, text paragraph) pairs, and the
161
+ * Word export turns them into fake-spaced Word HTML. Both consume the same
162
+ * line breaks, notes parts, and syllable anchor positions.
163
+ *
164
+ * Appearance comes from a named style set (see guidoStyles.ts): the layout
165
+ * options reference it by name, together with the bold option and the
166
+ * text/notes sizes. Throws when the style set is unknown or one of its
167
+ * fonts cannot be loaded.
168
+ */
169
+ export declare function layoutScore(source: GuidoScript | string, options?: LayoutOptions): Promise<LayoutResult>;
@@ -0,0 +1,36 @@
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`. */
5
+ export interface ChantRun {
6
+ text: string;
7
+ kind?: ChantRunKind;
8
+ initial?: boolean;
9
+ }
10
+ /** The runs of one syllable. */
11
+ export interface ChantSyllable {
12
+ runs: ChantRun[];
13
+ }
14
+ /** The syllables of one word. */
15
+ export interface ChantWord {
16
+ syllables: ChantSyllable[];
17
+ }
18
+ 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. */
23
+ style?: StyleSetName;
24
+ }
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;
@@ -0,0 +1,179 @@
1
+ import { StyleSetName } from './guidoStyles';
2
+ import { SpacerChar } from './wordExport';
3
+ /** Versioned localStorage key; an unknown version is ignored wholesale. */
4
+ export declare const EDITOR_STORAGE_KEY = "guidex.editor.v1";
5
+ export declare const EDITOR_SCHEMA_VERSION = 1;
6
+ /** Base text size for every renderer on the page; the chant font is 2× this. */
7
+ export declare const RENDER_BASE_PX = 36;
8
+ /** Declared range of the base font size input: the min/max attributes and
9
+ * the sanitizer's clamp, from one source. */
10
+ export declare const BASE_PX_MIN = 12;
11
+ export declare const BASE_PX_MAX = 96;
12
+ /** Declared range of the chant font size input: the min/max attributes
13
+ * and the commit-time clamp, from one source. */
14
+ export declare const NOTES_PX_MIN = 12;
15
+ export declare const NOTES_PX_MAX = 192;
16
+ /** Maximum notes-line width default; the renderer breaks into a new staff
17
+ * before exceeding it. The score sections sit in a ~38em column. */
18
+ export declare const MAX_WIDTH_PX_DEFAULT = 700;
19
+ export declare const MAX_WIDTH_PX_MIN = 300;
20
+ export declare const MAX_WIDTH_PX_MAX = 1400;
21
+ /** Declared range of the transpose slider. */
22
+ export declare const TRANSPOSE_MIN = -6;
23
+ export declare const TRANSPOSE_MAX = 6;
24
+ /** The destination Word text size default (notes ride at twice it) and the
25
+ * line column of the BNS-nota tab stop, in the Word-copy inputs' ranges. */
26
+ export declare const WORD_TEXT_PT_DEFAULT = 10;
27
+ export declare const WORD_TEXT_PT_MIN = 1;
28
+ export declare const WORD_TEXT_PT_MAX = 72;
29
+ export declare const WORD_WIDTH_CM_DEFAULT = 10.8;
30
+ export declare const WORD_WIDTH_CM_MIN = 1;
31
+ export declare const WORD_WIDTH_CM_MAX = 60;
32
+ export declare const SPACER_WIDTH_MIN = 0.01;
33
+ export declare const SPACER_WIDTH_MAX = 40;
34
+ export interface WordCopySettings {
35
+ /** The selected spacer character (a member of SPACER_CHARS). */
36
+ spacerChar: SpacerChar;
37
+ /** The spacer's width: a scale factor, or mm for tabs. */
38
+ spacerWidth: number;
39
+ /** The destination Word text size in pt; notes ride at twice this. */
40
+ textPt: number;
41
+ /** The destination document's line column in cm. */
42
+ widthCm: number;
43
+ }
44
+ export interface EditorSettings {
45
+ style: StyleSetName;
46
+ bold: boolean;
47
+ /** The start-with-initial transform enabled. */
48
+ initial: boolean;
49
+ maxWidthPx: number;
50
+ transpose: number;
51
+ basePx: number;
52
+ decoupleNotes: boolean;
53
+ /** The chant size while decoupled (the adopted 2× base or a typed one). */
54
+ notesPx: number;
55
+ /** True once the user typed a chant size of their own. */
56
+ notesCustom: boolean;
57
+ customColors: boolean;
58
+ colorFg: string;
59
+ colorAccent: string;
60
+ colorBg: string;
61
+ colorTransparent: boolean;
62
+ /** The Word-copy controls' slice — owned by wordDemo.ts. */
63
+ word: WordCopySettings;
64
+ }
65
+ /** The settings a fresh browser gets — also the per-field fallback for
66
+ * missing or invalid stored values. */
67
+ export declare const DEFAULT_EDITOR_SETTINGS: EditorSettings;
68
+ /** A partial snapshot: each writer sends only its own slice (main.ts never
69
+ * sends `word`, wordDemo.ts only `word`) and the write merges it over what
70
+ * is stored, so the two never clobber each other. */
71
+ export type EditorSettingsPatch = Partial<Omit<EditorSettings, 'word'>> & {
72
+ word?: WordCopySettings;
73
+ };
74
+ /** #rrggbb for a color picker, or the fallback when the value is not a
75
+ * 6-digit hex (the theme's palette variables always are). */
76
+ export declare function hexColor(value: string, fallback: string): string;
77
+ /** Loads the sanitized settings — always complete, never throws. */
78
+ export declare function loadEditorSettings(): EditorSettings;
79
+ /** Schedules a debounced save of the given settings slice; repeated calls
80
+ * within the window accumulate into one write. */
81
+ export declare function scheduleSettingsSave(patch: EditorSettingsPatch): void;
82
+ /** Writes any pending change immediately — registered on `pagehide`, so
83
+ * closing the tab right after a change does not lose it. A no-op with
84
+ * nothing pending. */
85
+ export declare function flushSettingsSave(): void;
86
+ /**
87
+ * Draft autosave (issue #55): the editor textarea's script, under its own
88
+ * versioned key — separate from the settings blob because the draft is
89
+ * written on every keystroke and can be kilobytes, and a future "reset
90
+ * settings" action must never touch the script. The value is the raw
91
+ * textarea string, no JSON wrapper: versioning lives in the key suffix,
92
+ * and a future version would write a different key entirely, so there is
93
+ * nothing to mis-parse and nothing newer to clobber.
94
+ *
95
+ * Same best-effort rails as the settings: debounced (~400 ms — the
96
+ * textarea fires `input` on every keystroke), flushed on `pagehide`, and
97
+ * a failing `setItem` (Safari private mode, disabled storage) warns once
98
+ * and the editor keeps working without persistence.
99
+ */
100
+ /** Versioned localStorage key for the script draft; the value is the raw
101
+ * textarea string, so the version lives in the key itself. */
102
+ export declare const DRAFT_STORAGE_KEY = "guidex.draft.v1";
103
+ /** Schedules a debounced save of the given draft text; repeated calls
104
+ * within the window collapse into one write of the last text. */
105
+ export declare function scheduleDraftSave(text: string): void;
106
+ /** Writes the given draft immediately, cancelling any pending debounced
107
+ * save — the sample picker's explicit save: setting `.value` fires no
108
+ * `input` event, and the pending text of just-typed keystrokes must not
109
+ * land afterwards and resurrect the old script. */
110
+ export declare function saveDraftNow(text: string): void;
111
+ /** Writes any pending draft immediately — registered on `pagehide`, so
112
+ * closing the tab right after typing does not lose the last keystrokes.
113
+ * A no-op with nothing pending. */
114
+ export declare function flushDraftSave(): void;
115
+ /** The stored draft — the raw string, verbatim and never parsed (corrupt
116
+ * or not), or null when nothing was saved or storage is unreadable. */
117
+ export declare function loadDraft(): string | null;
118
+ /**
119
+ * Saved chants library (issue #56): full chants saved by name under
120
+ * `guidex.chants.v1`, one versioned blob like the settings — every chant
121
+ * carries a snapshot of the render prefs, so loading restores *how it
122
+ * was rendered*, not just its text. Saves are explicit user actions
123
+ * (unlike the debounced settings/draft writes) and can genuinely hit the
124
+ * ~5 MB quota after thousands of chants, so the write reports failure
125
+ * back for visible feedback instead of only warning — the caller turns a
126
+ * `QuotaExceededError` into "Storage full — delete an old chant".
127
+ *
128
+ * The same read/write rails as the other keys: JSON.parse in try/catch,
129
+ * per-field sanitization (clamped numbers, type-checked booleans, a
130
+ * `STYLE_SETS`-key style), corrupt or absent data loading as an empty
131
+ * library, and an unknown schema version ignored wholesale on read and
132
+ * left untouched on write. Chant entries that are not records or carry
133
+ * no usable script are dropped on read; everything else loads with its
134
+ * fields defaulted or clamped individually.
135
+ */
136
+ /** Versioned localStorage key for the chant library. */
137
+ export declare const CHANTS_STORAGE_KEY = "guidex.chants.v1";
138
+ export declare const CHANTS_SCHEMA_VERSION = 1;
139
+ /** The render settings a saved chant snapshots, restored when it loads. */
140
+ export interface ChantPrefs {
141
+ style: StyleSetName;
142
+ bold: boolean;
143
+ /** The start-with-initial transform enabled. */
144
+ initial: boolean;
145
+ basePx: number;
146
+ decoupleNotes: boolean;
147
+ /** The chant size while decoupled (the adopted 2× base or a typed one). */
148
+ notesPx: number;
149
+ /** True once the user typed a chant size of their own. */
150
+ notesCustom: boolean;
151
+ transpose: number;
152
+ }
153
+ export interface SavedChant {
154
+ id: string;
155
+ name: string;
156
+ /** The raw script source, as typed — transforms stay in the prefs. */
157
+ script: string;
158
+ createdAt: number;
159
+ updatedAt: number;
160
+ prefs: ChantPrefs;
161
+ }
162
+ /** The write outcome: quota failures get their own message ("Storage
163
+ * full — delete an old chant"), every other failure a generic one. */
164
+ export type SaveChantsResult = {
165
+ ok: true;
166
+ } | {
167
+ ok: false;
168
+ quota: boolean;
169
+ };
170
+ export declare function newChantId(): string;
171
+ /** The stored library, sanitized — an empty array when absent, corrupt,
172
+ * or written by an unknown schema version. Never throws. */
173
+ export declare function loadChants(): SavedChant[];
174
+ /** Writes the whole library in the given order — the array order is the
175
+ * display order everywhere. Best-effort like the other keys, but the
176
+ * outcome is reported: a `QuotaExceededError` (storage full) and any
177
+ * other failing write come back as `{ ok: false }` for visible UI
178
+ * feedback. */
179
+ export declare function writeChants(chants: readonly SavedChant[]): SaveChantsResult;
@@ -6,3 +6,4 @@
6
6
  * free) or `guidex/react` instead.
7
7
  */
8
8
  export * from './core';
9
+ export { downloadScorePng, downloadScoreSvg, scorePngBlob, scoreSvg, type ScoreDownloadOptions, type ScoreImageOptions, } from '../scoreImage';
@@ -1,6 +1,6 @@
1
- import { a as version, i as renderScore, n as init, r as renderAll, t as dispose } from "../core-hF6L1EtS.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-DnFIbtF_.js";
2
2
  //#region src/embed/index.ts
3
3
  if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => init(), { once: true });
4
4
  else init();
5
5
  //#endregion
6
- export { dispose, init, renderAll, renderScore, version };
6
+ export { dispose, downloadScorePng, downloadScoreSvg, init, renderAll, renderScore, scorePngBlob, scoreSvg, version };
@@ -3,11 +3,22 @@
3
3
  * runtime's imperative API without any auto-rendering. Nothing happens
4
4
  * until you call `renderScore`, `renderAll`, or `init`. Also re-exports
5
5
  * the script parser and text extraction (`GuidoScript`, `chantText`,
6
- * `unescape`) and the style-set registry (`STYLE_SETS`,
7
- * `DEFAULT_STYLE_SET`).
6
+ * `unescape`), the marked-up text export (`chantRuns`, `chantHtml`,
7
+ * plus the raw run resolver `resolveSyllableParts`), the style-set
8
+ * registry (`STYLE_SETS`, `DEFAULT_STYLE_SET`), the
9
+ * Word-compatible export (`toWordHtml`, `toWordText`, `layoutForWord`,
10
+ * `wordLayoutText` — also available alone as `guidex/word`, `copyWordHtml`,
11
+ * `copyWordPlainText`, `checkWordHtml`), and the image export
12
+ * (`scoreSvg`, `scorePngBlob`, `downloadScorePng`, `downloadScoreSvg`).
8
13
  */
9
14
  export * from './core';
10
15
  export { GuidoScript, unescape, chantText } from '../guidoScript';
11
- export { STYLE_SETS, DEFAULT_STYLE_SET } from '../guidoStyles';
16
+ export { chantRuns, chantHtml } from '../chantMarkup';
17
+ export { STYLE_SETS, DEFAULT_STYLE_SET, resolveSyllableParts } from '../guidoStyles';
12
18
  export type { ScriptTransform } from '../guidoScriptTransforms';
13
- export type { StyleSetName } from '../guidoStyles';
19
+ export type { StyleSetName, SyllablePart, PartStyle, ChantRunKind } from '../guidoStyles';
20
+ export type { ChantRun, ChantSyllable, ChantWord, ChantMarkupOptions } from '../chantMarkup';
21
+ 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';
22
+ export { copyWordHtml, copyWordPlainText, type CopyResult } from '../wordClipboard';
23
+ export { checkWordHtml, type WordCheckIssue, type WordCheckReport, type WordGapClass, type WordGapMechanism, type WordGapStat, type WordParagraphDiag, } from '../wordChecker';
24
+ export { downloadScorePng, downloadScoreSvg, scorePngBlob, scoreSvg, type ScoreDownloadOptions, type ScoreImageOptions, } from '../scoreImage';
@@ -1,2 +1,43 @@
1
- import { a as version, c as GuidoScript, i as renderScore, l as chantText, n as init, o as DEFAULT_STYLE_SET, r as renderAll, s as STYLE_SETS, t as dispose, u as unescape } from "../core-hF6L1EtS.js";
2
- export { DEFAULT_STYLE_SET, GuidoScript, STYLE_SETS, chantText, dispose, init, renderAll, renderScore, unescape, version };
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-DnFIbtF_.js";
2
+ import { f as GuidoScript, m as unescape, o as DEFAULT_STYLE_SET, p as chantText, s as STYLE_SETS, u as resolveSyllableParts } from "../chantLayout-GAfg2iKS.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-C3nJrk_j.js";
4
+ //#region src/chantMarkup.ts
5
+ /**
6
+ * The marked-up sung text of a chant script, for other applications: the
7
+ * same run resolution the renderer draws, expressed as notation-fixed
8
+ * semantic kinds instead of style-set CSS values. `chantRuns` gives the
9
+ * structured form (words → syllables → runs); `chantHtml` serializes it
10
+ * as HTML spans classed with those kinds (`liturgy`, `rubric`, `star`,
11
+ * `marker`, `plus`, plus `initial`), so a consumer styles the classes
12
+ * with its own CSS.
13
+ */
14
+ var chantRunOf = (part) => {
15
+ const run = { text: part.text };
16
+ if (part.kind !== void 0) run.kind = part.kind;
17
+ if (part.style.initial) run.initial = true;
18
+ return run;
19
+ };
20
+ /** The marked-up sung text of the script: its words, their syllables,
21
+ * and each syllable's runs of notation-fixed kinds. Renders exactly the
22
+ * text a score render would (including the style set's default script
23
+ * transforms) with the style-set presentation stripped; letter case is
24
+ * the raw text's, so a BNS-look consumer uppercases rubrics in CSS. */
25
+ function chantRuns(script, options = {}) {
26
+ const styleSet = STYLE_SETS[options.style ?? "BNS"];
27
+ 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) })) }));
28
+ }
29
+ /** The marked-up sung text as an HTML string: one span per kinded or
30
+ * initial run, classed with the kind (and `initial`), bare text
31
+ * otherwise. Syllables of a word concatenate and words join with single
32
+ * spaces — hyphenation is the consumer's job, and `chantRuns` has the
33
+ * syllable boundaries. Text is HTML-escaped. */
34
+ function chantHtml(script, options = {}) {
35
+ return chantRuns(script, options).map((word) => word.syllables.map((syl) => syl.runs.map(runHtml).join("")).join("")).join(" ");
36
+ }
37
+ var runHtml = (run) => {
38
+ const classes = [...run.kind ? [run.kind] : [], ...run.initial ? ["initial"] : []].join(" ");
39
+ return classes ? `<span class="${classes}">${escapeHtml(run.text)}</span>` : escapeHtml(run.text);
40
+ };
41
+ var escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
42
+ //#endregion
43
+ export { DEFAULT_SPACER, DEFAULT_STYLE_SET, DEFAULT_TAB_INTERVAL_PT, GuidoScript, STYLE_SETS, SpacerMeter, chantHtml, chantRuns, chantText, checkWordHtml, copyWordHtml, copyWordPlainText, dispose, downloadScorePng, downloadScoreSvg, init, layoutForWord, renderAll, renderScore, resolveSyllableParts, scorePngBlob, scoreSvg, toWordHtml, toWordText, unescape, version, wordLayoutText };
@@ -1,19 +1,6 @@
1
1
  import { GuidoScript } from './guidoScript';
2
2
  import { StyleSetName } from './guidoStyles';
3
- /**
4
- * Score marker characters: they carry no pitch, and when they sit at the
5
- * start or end of a note group (with the adjacent dash) they act as
6
- * whitespace rather than note width.
7
- */
8
- export declare const SCORE_MARKERS = ",.:?'\"+!%/=()\u00D6\u00DC\u00D3;";
9
- /**
10
- * Special reciting notes: when such a note stands alone in a note group it
11
- * marks recited text. The glyph shows at a run's first syllable (the
12
- * previous syllable has different notes) and at every line start; every
13
- * other recited syllable contributes only the staff-line segments filling
14
- * the space above its text, which flows tight after the previous text.
15
- */
16
- export declare const SPECIAL_NOTES = "\u0178\u00A1\u00A2\u00A3[\u00A5\u00A6\u00A9\u00AA\u00AB\u00AC";
3
+ export { NOTE_MODIFIERS, SCORE_MARKERS } from './chantLayout';
17
4
  /** Options for one render. All fields optional; defaults reproduce the
18
5
  * original Book Antiqua look (style set BNS). */
19
6
  export interface RenderOptions {
@@ -32,24 +19,18 @@ export interface RenderOptions {
32
19
  }
33
20
  /**
34
21
  * Renders a GuidoScript into a tidy score: a notes line in the chant font,
35
- * and a text line where each syllable is centered below its notes. The
36
- * dashes of the chant font are pure whitespace: centering ignores them and
37
- * happens under the non-whitespace note characters only. When a syllable's
38
- * text would overlap the previous one, it starts right after it and the
39
- * notes group is padded with extra dashes until it covers the text.
22
+ * and a text line where each syllable is centered below its notes.
40
23
  *
41
- * Appearance comes from a named style set (see guidoStyles.ts): the render
42
- * options reference it by name, together with the bold option and the
43
- * text/notes sizes.
24
+ * The DOM emitter of the shared layout pass (`layoutScore` in
25
+ * chantLayout.ts, which owns every line-breaking and placement decision):
26
+ * `render` turns the laid-out lines into (notes `.guido` div, text `<p>`)
27
+ * pairs — px-measured inline-block spacer spans fake the horizontal gaps.
28
+ * The Word export (wordExport.ts) consumes the same layout with a
29
+ * character-based spacer mechanism instead.
44
30
  */
45
31
  export declare class GuidoRender {
46
32
  private readonly script;
47
33
  constructor(source: GuidoScript | string);
48
- private static ctx;
49
- private static measure;
50
- /** Ink extents of the text relative to the glyph origin (negative left
51
- * means the ink starts left of the origin). */
52
- private static ink;
53
34
  /**
54
35
  * Renders the score into `container` as (notes line, text line) pairs.
55
36
  * When `maxWidthPx` is finite, a new pair starts before any syllable
@@ -58,9 +39,21 @@ export declare class GuidoRender {
58
39
  * unknown or one of its fonts cannot be loaded.
59
40
  */
60
41
  render(container: HTMLElement, options?: RenderOptions): Promise<void>;
42
+ /** Builds a line's notes div: the chant font text plus, on broken
43
+ * lines, the break marker `*` as an inline span (so it shares the
44
+ * text's baseline) shifted right so its right edge lands on the
45
+ * padding-extended max-width position. position: relative keeps the
46
+ * shift out of the flow measurements. */
47
+ private static notesLine;
48
+ /** Builds a line's text paragraph from its segments: spacer spans fake
49
+ * every horizontal gap (lead-in, word gaps, dash connector pads), each
50
+ * syllable is one span of nested runs, and word spaces are their own
51
+ * spans. */
52
+ private static textLine;
61
53
  /** Builds a syllable span from its resolved runs: one nested span per
62
- * run, carrying the run's inline styles; runs marked `initial` by the
63
- * `*…*` marker carry the initial class. */
54
+ * run, carrying the run's inline styles and its notation-fixed kind
55
+ * class (`liturgy`, `rubric`, `star`, `marker`, `plus`); runs marked
56
+ * `initial` by the `*…*` marker carry the initial class. */
64
57
  private static sylSpan;
65
58
  private static spacer;
66
59
  }
@@ -1,12 +1,36 @@
1
1
  import { ScriptTransform } from './guidoScriptTransforms';
2
+ /** One parsed token of the script: a syllable, or a control statement.
3
+ * `spaceBefore` records whether the source had whitespace between the
4
+ * previous group and this token's group — it feeds the previous
5
+ * syllable's `wordEnd` and the `toString()` round-trip. */
6
+ export type ScriptToken = {
7
+ kind: 'syllable';
8
+ text: string;
9
+ notes: string;
10
+ wordEnd: boolean;
11
+ spaceBefore: boolean;
12
+ } | {
13
+ kind: 'break';
14
+ spaceBefore: boolean;
15
+ };
16
+ /** Whether a group's content is a control statement (`@`-keyword,
17
+ * trimmed). Shared with the transforms, which must leave statement
18
+ * groups alone — their keyword characters are pitch glyphs otherwise. */
19
+ export declare function isStatementGroup(content: string): boolean;
2
20
  export declare class GuidoScript {
3
21
  readonly source: string;
4
22
  constructor(source: string, options?: {
5
23
  transforms?: ScriptTransform[];
6
24
  });
7
- /** The starting clef and note modifiers, or undefined when absent. */
25
+ /** The starting clef and note modifiers, or undefined when absent.
26
+ * A leading statement group is not a clef. */
8
27
  get clef(): string | undefined;
9
- /** The script broken into syllables, each with its sung text and notes. */
28
+ /** The script's tokens in source order: syllables interleaved with
29
+ * control statements. Throws on a malformed statement (syllable text
30
+ * attached to one, or an unknown `@` keyword). */
31
+ get tokens(): ScriptToken[];
32
+ /** The script broken into syllables, each with its sung text and
33
+ * notes — the syllable tokens, statements filtered out. */
10
34
  get syllables(): {
11
35
  text: string;
12
36
  notes: string;
@@ -30,7 +54,8 @@ export declare class GuidoScript {
30
54
  notes: string;
31
55
  }[];
32
56
  }[];
33
- /** The script rebuilt from the parsed pieces — a round-trip of the source. */
57
+ /** The script rebuilt from the parsed pieces — a round-trip of the
58
+ * source, statements included. */
34
59
  toString(): string;
35
60
  }
36
61
  /** The sung text of the script: the clef stripped, syllables joined
@@ -4,9 +4,10 @@ export interface ScriptTransform {
4
4
  apply: (source: string) => string;
5
5
  }
6
6
  /** The `startWithInitial` transform: finds the first syllable group with
7
- * actual notes (the clef and no-notes groups don't count) and wraps the
8
- * syllable's first character in the `*…*` initial marker. Already-marked
9
- * text (leading `*`) and syllables without text are left alone. */
7
+ * actual notes (the clef, no-notes groups, and control statements don't
8
+ * count) and wraps the syllable's first character in the `*…*` initial
9
+ * marker. Already-marked text (leading `*`) and syllables without text
10
+ * are left alone. */
10
11
  declare function startWithInitial(source: string): string;
11
12
  /**
12
13
  * The built-in transformations, keyed by name; pass the ones a feature
@@ -26,7 +27,7 @@ export declare const SCRIPT_TRANSFORMS: {
26
27
  * its row; characters outside every row carry no pitch and stay put.
27
28
  * Rows are searched in order, so a character found in several rows
28
29
  * transposes within the first one. */
29
- export declare const PITCH_ROWS: readonly ["ðñ0123456789öüó", "^]qwertzuiopõú", "ÝÞQWERTZUIOPÕÚ", "×sdfghjkléáû", "ØÙDFGHJKLÉÁÛ", "÷øaASÍYXCVBN$m", "ÈÊËÌÎÏÐÑÒþ¬ßòôùý", "“”•–—˜™š›œº»", "®−§ÿ\"+!%/=()ÖÜÓ", "Ÿ¡¢£[¥¦©ª«¬", "~¯‚ƒ„…†‡ˆ‰Š‹Œ‘’", "àâãäåæçèêëìîï", "½°±²³´μ·¾¸¹"];
30
+ export declare const PITCH_ROWS: readonly ["ðñ0123456789öüó", "^]qwertzuiopõú", "ÝÞQWERTZUIOPÕÚ", "×sdfghjkléáû", "ØÙDFGHJKLÉÁÛ", "÷øaASÍYXCVBN$m", "ÈÊËÌÎÏÐÑÒþßòôùý", "“”•–—˜™š›œº»", "®−§ÿ\"+!%/=()ÖÜÓ", "Ÿ¡¢£[¥¦©ª«¬", "~¯‚ƒ„…†‡ˆ‰Š‹Œ‘’", "àâãäåæçèêëìîï", "½°±²³´μ·¾¸¹"];
30
31
  /** What happens when a shift runs past the end of a pitch row:
31
32
  * `clamp` keeps the first/last available character, `null` emits
32
33
  * `U+0000`, which shows up as a missing glyph in the score. */