guidex 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -35
- package/dist/lib/app/editorState.d.ts +25 -23
- package/dist/lib/app/shareLink.d.ts +2 -3
- package/dist/lib/{chantLayout-B0xiaMo9.js → chantLayout-g_xuQ9nD.js} +875 -1167
- package/dist/lib/chantLayout.d.ts +37 -2
- package/dist/lib/chantMarkup.d.ts +63 -20
- package/dist/lib/editorStorage.d.ts +14 -4
- package/dist/lib/embed/core.d.ts +22 -4
- package/dist/lib/embed/index.js +1 -1
- package/dist/lib/embed/manual.d.ts +6 -3
- package/dist/lib/embed/manual.js +37 -46
- package/dist/lib/glyphFamilies.d.ts +7 -0
- package/dist/lib/guidex.css +29 -2
- package/dist/lib/guidoRender.d.ts +13 -3
- package/dist/lib/guidoScript.d.ts +74 -20
- package/dist/lib/guidoScriptTransforms.d.ts +0 -18
- package/dist/lib/guidoStyles.d.ts +85 -74
- package/dist/lib/react/GuidexScore.d.ts +14 -5
- package/dist/lib/react/index.d.ts +2 -0
- package/dist/lib/react/index.js +12 -2
- package/dist/lib/scoreImage-Dz3c55Zi.js +1985 -0
- package/dist/lib/stanzas.d.ts +6 -3
- package/dist/lib/textMarkup.d.ts +67 -0
- package/dist/lib/word/index.js +1 -1
- package/dist/lib/{wordChecker-EQx8frRp.js → wordChecker-B_9vyTt6.js} +39 -13
- package/dist/lib/wordExport.d.ts +19 -4
- package/dist-embed/guidex-embed.min.css +1 -1
- package/dist-embed/guidex-embed.min.js +1 -1
- package/package.json +1 -1
- package/dist/lib/scoreImage-DSEupCru.js +0 -1002
|
@@ -1,6 +1,6 @@
|
|
|
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
4
|
export { SCORE_MARKERS };
|
|
5
5
|
/**
|
|
6
6
|
* Special reciting notes: when such a note stands alone in a note group it
|
|
@@ -22,11 +22,20 @@ export declare const NOTE_MODIFIERS: string;
|
|
|
22
22
|
/** Canvas text measurement, shared with the emitters (the Word export
|
|
23
23
|
* measures the spacer character's natural advance for the unit width). */
|
|
24
24
|
export declare function measure(text: string, font: string): number;
|
|
25
|
+
/** How far each staff line runs (issue #107). `all-but-last` fills every
|
|
26
|
+
* line but the last to the available width; `none` stops every line at its
|
|
27
|
+
* own notes; `all` fills every line to the available width, or acts as
|
|
28
|
+
* `longest` at natural width, where there is none; `longest` fills every
|
|
29
|
+
* line to the end of the score's longest line, its text included. */
|
|
30
|
+
export type StaffFill = 'all-but-last' | 'none' | 'all' | 'longest';
|
|
31
|
+
export declare const STAFF_FILLS: readonly StaffFill[];
|
|
25
32
|
/** Options for one layout pass. All fields optional; defaults reproduce the
|
|
26
33
|
* original Book Antiqua look (style set BNS). */
|
|
27
34
|
export interface LayoutOptions {
|
|
28
|
-
/** Named style set
|
|
35
|
+
/** Named style set (default: BNS) */
|
|
29
36
|
style?: StyleSetName;
|
|
37
|
+
/** Marks this score adds to its style set's */
|
|
38
|
+
marks?: MarkDefinitions;
|
|
30
39
|
/** Lay out all text bold, measurements included */
|
|
31
40
|
bold?: boolean;
|
|
32
41
|
/** Text line size in px (default 18) */
|
|
@@ -35,6 +44,19 @@ export interface LayoutOptions {
|
|
|
35
44
|
notesPx?: number;
|
|
36
45
|
/** Maximum notes-line width before a staff break (default: none) */
|
|
37
46
|
maxWidthPx?: number;
|
|
47
|
+
/** Dashes in a normal junction between note groups: at least 1, in
|
|
48
|
+
* steps of a third (default 3; 2.67 reads as 2⅔). Three `¨` are about
|
|
49
|
+
* as wide as a `-`, so thirds are written with `¨` after the whole
|
|
50
|
+
* dashes (`--¨¨`). A group ending in markers or starting with an
|
|
51
|
+
* accidental takes one less, never under 1. Held groups keep their
|
|
52
|
+
* own join. */
|
|
53
|
+
junctionDashes?: number;
|
|
54
|
+
/** How far each staff line runs (default `all-but-last`) */
|
|
55
|
+
staffFill?: StaffFill;
|
|
56
|
+
/** With `staffFill: 'longest'`: when the longest line ends within this
|
|
57
|
+
* many px of the available width, every line runs to the available
|
|
58
|
+
* width instead (default 0) */
|
|
59
|
+
staffFillSnapPx?: number;
|
|
38
60
|
}
|
|
39
61
|
/** A horizontal whitespace gap on the text line: the lead-in shared with
|
|
40
62
|
* the clef, or the gap after a word-ending syllable. Both emitters fake it
|
|
@@ -55,6 +77,8 @@ export interface GapSegment {
|
|
|
55
77
|
/** A dash connector centered between two syllables of the same word. */
|
|
56
78
|
export interface ConnectorSegment {
|
|
57
79
|
kind: 'connector';
|
|
80
|
+
/** The hyphen's look, when a `{…}` span runs on across it */
|
|
81
|
+
parts?: SyllablePart[];
|
|
58
82
|
/** Each side pad's width in px (the DOM emitter's twin spacer spans) */
|
|
59
83
|
pad: number;
|
|
60
84
|
/** The full gap the dash centers in, px */
|
|
@@ -100,6 +124,8 @@ export interface WordSpaceSegment {
|
|
|
100
124
|
* the line's text end and its notes end. */
|
|
101
125
|
export interface LineEndDashSegment {
|
|
102
126
|
kind: 'line-end-dash';
|
|
127
|
+
/** The hyphen's look, when a `{…}` span runs on across it */
|
|
128
|
+
parts?: SyllablePart[];
|
|
103
129
|
/** Each side pad's width in px (the DOM emitter's twin spacer spans) */
|
|
104
130
|
pad: number;
|
|
105
131
|
dashWidth: number;
|
|
@@ -122,6 +148,13 @@ export interface LayoutTextLine {
|
|
|
122
148
|
/** Whether the text line's last syllable ends its word; null when it
|
|
123
149
|
* carries no syllable at all */
|
|
124
150
|
lastWordEnd: boolean | null;
|
|
151
|
+
/** The hyphen after the text line's last syllable */
|
|
152
|
+
hyphen?: Hyphen;
|
|
153
|
+
}
|
|
154
|
+
/** A text hyphen: its look when it has one of its own, and its width. */
|
|
155
|
+
export interface Hyphen {
|
|
156
|
+
parts?: SyllablePart[];
|
|
157
|
+
width: number;
|
|
125
158
|
}
|
|
126
159
|
/** One rendered line pair's layout: the notes-line model and the text
|
|
127
160
|
* line's ordered segments with their ideal absolute positions. Stacked
|
|
@@ -139,6 +172,8 @@ export interface LayoutLine {
|
|
|
139
172
|
textCursor: number;
|
|
140
173
|
/** Where the notes line ends (the notes width when the line closed) */
|
|
141
174
|
notesEnd: number;
|
|
175
|
+
/** Where the staff ends: `notesEnd` plus any staff fill */
|
|
176
|
+
staffEnd: number;
|
|
142
177
|
/** Whether the line's last syllable ends its word; null when the
|
|
143
178
|
* line carries no syllable at all */
|
|
144
179
|
lastWordEnd: boolean | null;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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)[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StaffFill } from './chantLayout';
|
|
1
2
|
import { StyleSetName } from './guidoStyles';
|
|
2
3
|
import { SpacerChar } from './wordExport';
|
|
3
4
|
/** Versioned localStorage key; an unknown version is ignored wholesale. */
|
|
@@ -19,6 +20,10 @@ export declare const MAX_WIDTH_PX_DEFAULT = 700;
|
|
|
19
20
|
export declare const MAX_WIDTH_PX_MIN = 300;
|
|
20
21
|
export declare const MAX_WIDTH_PX_MAX = 1400;
|
|
21
22
|
/** Declared range of the transpose slider. */
|
|
23
|
+
export declare const JUNCTION_DASHES_MIN = 1;
|
|
24
|
+
export declare const JUNCTION_DASHES_MAX = 8;
|
|
25
|
+
export declare const STAFF_FILL_SNAP_MIN = 0;
|
|
26
|
+
export declare const STAFF_FILL_SNAP_MAX = 60;
|
|
22
27
|
export declare const TRANSPOSE_MIN = -6;
|
|
23
28
|
export declare const TRANSPOSE_MAX = 6;
|
|
24
29
|
/** The destination Word text size default (notes ride at twice it) and the
|
|
@@ -44,8 +49,6 @@ export interface WordCopySettings {
|
|
|
44
49
|
export interface EditorSettings {
|
|
45
50
|
style: StyleSetName;
|
|
46
51
|
bold: boolean;
|
|
47
|
-
/** The start-with-initial transform enabled. */
|
|
48
|
-
initial: boolean;
|
|
49
52
|
maxWidthPx: number;
|
|
50
53
|
transpose: number;
|
|
51
54
|
basePx: number;
|
|
@@ -54,6 +57,12 @@ export interface EditorSettings {
|
|
|
54
57
|
notesPx: number;
|
|
55
58
|
/** True once the user typed a chant size of their own. */
|
|
56
59
|
notesCustom: boolean;
|
|
60
|
+
/** Dashes in a normal junction between note groups. */
|
|
61
|
+
junctionDashes: number;
|
|
62
|
+
/** How far each staff line runs. */
|
|
63
|
+
staffFill: StaffFill;
|
|
64
|
+
/** With `longest`: the distance from the max width that snaps to it. */
|
|
65
|
+
staffFillSnapPx: number;
|
|
57
66
|
customColors: boolean;
|
|
58
67
|
colorFg: string;
|
|
59
68
|
colorAccent: string;
|
|
@@ -140,14 +149,15 @@ export declare const CHANTS_SCHEMA_VERSION = 1;
|
|
|
140
149
|
export interface ChantPrefs {
|
|
141
150
|
style: StyleSetName;
|
|
142
151
|
bold: boolean;
|
|
143
|
-
/** The start-with-initial transform enabled. */
|
|
144
|
-
initial: boolean;
|
|
145
152
|
basePx: number;
|
|
146
153
|
decoupleNotes: boolean;
|
|
147
154
|
/** The chant size while decoupled (the adopted 2× base or a typed one). */
|
|
148
155
|
notesPx: number;
|
|
149
156
|
/** True once the user typed a chant size of their own. */
|
|
150
157
|
notesCustom: boolean;
|
|
158
|
+
junctionDashes: number;
|
|
159
|
+
staffFill: StaffFill;
|
|
160
|
+
staffFillSnapPx: number;
|
|
151
161
|
transpose: number;
|
|
152
162
|
}
|
|
153
163
|
export interface SavedChant {
|
package/dist/lib/embed/core.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { EmptySlots, StanzaStack, StanzaWarning } from '../stanzas';
|
|
2
|
-
import {
|
|
2
|
+
import { MarkWarning } from '../chantMarkup';
|
|
3
|
+
import { SpanProblem } from '../textMarkup';
|
|
4
|
+
import { StaffFill } from '../chantLayout';
|
|
5
|
+
import { MarkDefinitions, StyleSetName } from '../guidoStyles';
|
|
3
6
|
export declare const version: string;
|
|
4
7
|
/** Line-breaking budget: a fixed pixel width, or 'auto' to fit the
|
|
5
|
-
* target element (re-rendered on resize).
|
|
8
|
+
* target element (re-rendered on resize). `Infinity` (or any large
|
|
9
|
+
* number) means "never break": the score stays on one line, wider than
|
|
10
|
+
* its container if need be, and the host handles the overflow
|
|
11
|
+
* (`overflow-x: auto` to scroll, `hidden` to clip). */
|
|
6
12
|
export type MaxWidth = number | 'auto';
|
|
7
13
|
/** Site-wide defaults, settable through `GuidexEmbed.init`. */
|
|
8
14
|
export interface EmbedOptions {
|
|
@@ -12,6 +18,15 @@ export interface EmbedOptions {
|
|
|
12
18
|
style?: StyleSetName;
|
|
13
19
|
bold?: boolean;
|
|
14
20
|
textPx?: number;
|
|
21
|
+
/** Marks this score adds to its style set's */
|
|
22
|
+
marks?: MarkDefinitions;
|
|
23
|
+
/** Dashes in a normal junction between note groups, in steps of a third (default 3) */
|
|
24
|
+
junctionDashes?: number;
|
|
25
|
+
/** How far each staff line runs (default `all-but-last`) */
|
|
26
|
+
staffFill?: StaffFill;
|
|
27
|
+
/** With `staffFill: 'longest'`: the distance from the available width
|
|
28
|
+
* within which every line runs to it instead (default 0) */
|
|
29
|
+
staffFillSnapPx?: number;
|
|
15
30
|
transpose?: number;
|
|
16
31
|
/** The stanza sung under the notes (1-based; 1 is the script's own
|
|
17
32
|
* text, 2… its `(@stanza …)` statements or the `stanzas` option). */
|
|
@@ -34,10 +49,13 @@ export interface RenderScoreOptions extends Omit<EmbedOptions, 'selector'> {
|
|
|
34
49
|
}
|
|
35
50
|
/** What a finished render reports: the rendered stanzas' count
|
|
36
51
|
* mismatches (missing syllables show as placeholders, extra ones are
|
|
37
|
-
* dropped). */
|
|
52
|
+
* dropped) and the characters the Liturgy font does not have. */
|
|
38
53
|
export interface RenderResult {
|
|
39
|
-
warnings:
|
|
54
|
+
warnings: ScoreWarning[];
|
|
40
55
|
}
|
|
56
|
+
/** What a render warns about: a stanza's count mismatch, a malformed
|
|
57
|
+
* `{…}` span, an unknown mark, or a character the Liturgy font lacks. */
|
|
58
|
+
export type ScoreWarning = StanzaWarning | MarkWarning | SpanProblem;
|
|
41
59
|
/** Cleans up a programmatically rendered element: stops resize
|
|
42
60
|
* re-rendering and drops the cached source and option overrides. Does
|
|
43
61
|
* not remove the rendered score itself. */
|
package/dist/lib/embed/index.js
CHANGED
|
@@ -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-
|
|
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-Dz3c55Zi.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,6 +11,7 @@
|
|
|
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
|
|
16
17
|
* Word-compatible export (`toWordHtml`, `toWordText`, `layoutForWord`,
|
|
@@ -19,13 +20,15 @@
|
|
|
19
20
|
* (`scoreSvg`, `scorePngBlob`, `downloadScorePng`, `downloadScoreSvg`).
|
|
20
21
|
*/
|
|
21
22
|
export * from './core';
|
|
22
|
-
export { GuidoScript, unescape, chantText, scriptSyllables, type ScriptSyllable, } from '../guidoScript';
|
|
23
|
+
export { GuidoScript, unescape, chantText, scriptSyllables, type ChantTextOptions, type ScriptSyllable, type SyllableRole, } from '../guidoScript';
|
|
23
24
|
export { SCORE_MARKERS, splitNoteMarkers, type NoteGroupParts } from '../noteGroups';
|
|
24
25
|
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';
|
|
26
|
+
export { chantRuns, chantHtml, chantTextStyle, markupWarnings, type ChantHtmlOptions, type ChantWordRun, type MarkWarning, } from '../chantMarkup';
|
|
27
|
+
export { STYLE_SETS, DEFAULT_STYLE_SET, defineStyleSet, resolveSyllableParts, type MarkDefinitions, type StyleSetDefinition, } from '../guidoStyles';
|
|
28
|
+
export type { Mark, SpanProblem, TextRun } from '../textMarkup';
|
|
27
29
|
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
30
|
export type { StyleSetName, SyllablePart, PartStyle, ChantRunKind } from '../guidoStyles';
|
|
31
|
+
export type { StaffFill } from '../chantLayout';
|
|
29
32
|
export type { ChantRun, ChantSyllable, ChantWord, ChantMarkupOptions } from '../chantMarkup';
|
|
30
33
|
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
34
|
export { baseOf, gClefPitchOf, modifyDown, modifyNatural, modifyUp, toCephalicus, toConnectDown, toLonga, toSmallHead, toSmallPoint, toVirga, variantOf, type VariantRole, } from '../glyphFamilies';
|
package/dist/lib/embed/manual.js
CHANGED
|
@@ -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-
|
|
2
|
-
import {
|
|
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-
|
|
1
|
+
import { A as stackStanzas, C as STANZA_PLACEHOLDER, D as selectStanza, E as parseStanza, F as withStanza, M as stanzaCount, N as stanzaTexts, O as slotCount, P as stanzaWarnings, S as transposeScript, T as padStanza, _ as KEY_SIGNATURES, a as dispose, b as sameKeyGlyphs, c as renderScore, d as chantRuns, f as chantTextStyle, g as transposeNotes, h as transposeBy, i as scoreSvg, j as stackedStanzaNumbers, k as smallHeads, l as version, m as PITCH_ROWS, n as downloadScoreSvg, o as init, p as markupWarnings, r as scorePngBlob, s as renderAll, t as downloadScorePng, u as chantHtml, v as TranspositionRangeError, w as isSlot, x as transposeExact, y as parseInterval } from "../scoreImage-Dz3c55Zi.js";
|
|
2
|
+
import { B as toConnectDown, C as scriptSyllables, E as unescape, G as variantOf, H as toSmallHead, I as modifyDown, 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 toSmallPoint, V as toLonga, W as toVirga, _ 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, z as toCephalicus } from "../chantLayout-g_xuQ9nD.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-B_9vyTt6.js";
|
|
4
4
|
//#region src/composeScript.ts
|
|
5
5
|
/**
|
|
6
6
|
* Combining scripts (issue #71): one GuidoScript built from parts of
|
|
@@ -46,20 +46,37 @@ function stateAfter(tokens, state) {
|
|
|
46
46
|
};
|
|
47
47
|
return state;
|
|
48
48
|
}
|
|
49
|
+
/** The run properties still open after `tokens`, one entry per level. */
|
|
50
|
+
function openRuns(tokens) {
|
|
51
|
+
const depth = {
|
|
52
|
+
tight: 0,
|
|
53
|
+
keep: 0,
|
|
54
|
+
aid: 0
|
|
55
|
+
};
|
|
56
|
+
for (const tok of tokens) {
|
|
57
|
+
if (tok.kind !== "tight" && tok.kind !== "keep" && tok.kind !== "unit" && tok.kind !== "aid") continue;
|
|
58
|
+
for (const prop of runProperties(tok.kind)) depth[prop] = Math.max(0, depth[prop] + (tok.on ? 1 : -1));
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
"tight",
|
|
62
|
+
"keep",
|
|
63
|
+
"aid"
|
|
64
|
+
].flatMap((prop) => Array(depth[prop]).fill(prop));
|
|
65
|
+
}
|
|
49
66
|
/** Tokens written back as script source (the `GuidoScript.toString`
|
|
50
67
|
* rules: an empty slot always writes its `~`). */
|
|
51
68
|
function writeTokens(tokens) {
|
|
52
69
|
return tokens.map((tok, i) => {
|
|
53
70
|
const prefix = i > 0 && tok.spaceBefore ? " " : "";
|
|
54
71
|
if (tok.kind !== "syllable") return prefix + statementSource(tok);
|
|
55
|
-
return `${prefix}${tok.empty ? "~" : tok.
|
|
72
|
+
return `${prefix}${tok.empty ? "~" : tok.source}(${escape(tok.notes)})`;
|
|
56
73
|
}).join("");
|
|
57
74
|
}
|
|
58
75
|
/** A stanza item written back as stanza text (see `parseStanza`). */
|
|
59
76
|
function stanzaItemSource(item) {
|
|
60
77
|
if (item.kind === "hold") return "-";
|
|
61
78
|
if (item.kind === "empty") return "~";
|
|
62
|
-
const text =
|
|
79
|
+
const text = (item.source ?? escape(item.text)).replace(/\\.|./gsu, (unit) => unit[0] === "\\" ? unit : /\s/.test(unit) ? "~" : "-=~".includes(unit) ? `\\${unit}` : unit);
|
|
63
80
|
return item.wordEnd ? text : `${text}-`;
|
|
64
81
|
}
|
|
65
82
|
/** Applies a staff-degree or exact transposition to a whole script. */
|
|
@@ -115,6 +132,18 @@ function scriptChunk(part, state, first, options) {
|
|
|
115
132
|
const opening = stateAfter(tokens.slice(0, start), readClef(script.clef)) ?? state;
|
|
116
133
|
const slice = tokens.slice(start, end);
|
|
117
134
|
if (part.stripTrailingMarkers) stripTrailing(slice);
|
|
135
|
+
const opened = openRuns(tokens.slice(0, start));
|
|
136
|
+
const closed = openRuns(tokens.slice(0, end));
|
|
137
|
+
slice.unshift(...opened.map((kind) => ({
|
|
138
|
+
kind,
|
|
139
|
+
on: true,
|
|
140
|
+
spaceBefore: false
|
|
141
|
+
})));
|
|
142
|
+
slice.push(...closed.map((kind) => ({
|
|
143
|
+
kind,
|
|
144
|
+
on: false,
|
|
145
|
+
spaceBefore: false
|
|
146
|
+
})));
|
|
118
147
|
const slotIndices = tokens.flatMap((tok, i) => isSlot(tok) ? [i] : []);
|
|
119
148
|
const before = slotIndices.filter((i) => i < start).length;
|
|
120
149
|
const inside = slotIndices.filter((i) => i >= start && i < end).length;
|
|
@@ -244,7 +273,8 @@ function composeScript(parts, options = {}) {
|
|
|
244
273
|
append({
|
|
245
274
|
tokens: [{
|
|
246
275
|
kind: "syllable",
|
|
247
|
-
|
|
276
|
+
...syllableText("**"),
|
|
277
|
+
role: "sign",
|
|
248
278
|
notes: "",
|
|
249
279
|
wordEnd: true,
|
|
250
280
|
spaceBefore: false
|
|
@@ -321,43 +351,4 @@ function composeScript(parts, options = {}) {
|
|
|
321
351
|
return clefGroup(opening) + writeTokens(out) + stanzas.join("");
|
|
322
352
|
}
|
|
323
353
|
//#endregion
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* The marked-up sung text of a chant script, for other applications: the
|
|
327
|
-
* same run resolution the renderer draws, expressed as notation-fixed
|
|
328
|
-
* semantic kinds instead of style-set CSS values. `chantRuns` gives the
|
|
329
|
-
* structured form (words → syllables → runs); `chantHtml` serializes it
|
|
330
|
-
* as HTML spans classed with those kinds (`liturgy`, `rubric`, `star`,
|
|
331
|
-
* `marker`, `plus`, plus `initial`), so a consumer styles the classes
|
|
332
|
-
* with its own CSS.
|
|
333
|
-
*/
|
|
334
|
-
var chantRunOf = (part) => {
|
|
335
|
-
const run = { text: part.text };
|
|
336
|
-
if (part.kind !== void 0) run.kind = part.kind;
|
|
337
|
-
if (part.style.initial) run.initial = true;
|
|
338
|
-
return run;
|
|
339
|
-
};
|
|
340
|
-
/** The marked-up sung text of the script: its words, their syllables,
|
|
341
|
-
* and each syllable's runs of notation-fixed kinds. Renders exactly the
|
|
342
|
-
* text a score render would (including the style set's default script
|
|
343
|
-
* transforms) with the style-set presentation stripped; letter case is
|
|
344
|
-
* the raw text's, so a BNS-look consumer uppercases rubrics in CSS. */
|
|
345
|
-
function chantRuns(script, options = {}) {
|
|
346
|
-
const styleSet = STYLE_SETS[options.style ?? "BNS"];
|
|
347
|
-
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) })) }));
|
|
348
|
-
}
|
|
349
|
-
/** The marked-up sung text as an HTML string: one span per kinded or
|
|
350
|
-
* initial run, classed with the kind (and `initial`), bare text
|
|
351
|
-
* otherwise. Syllables of a word concatenate and words join with single
|
|
352
|
-
* spaces — hyphenation is the consumer's job, and `chantRuns` has the
|
|
353
|
-
* syllable boundaries. Text is HTML-escaped. */
|
|
354
|
-
function chantHtml(script, options = {}) {
|
|
355
|
-
return chantRuns(script, options).map((word) => word.syllables.map((syl) => syl.runs.map(runHtml).join("")).join("")).join(" ");
|
|
356
|
-
}
|
|
357
|
-
var runHtml = (run) => {
|
|
358
|
-
const classes = [...run.kind ? [run.kind] : [], ...run.initial ? ["initial"] : []].join(" ");
|
|
359
|
-
return classes ? `<span class="${classes}">${escapeHtml(run.text)}</span>` : escapeHtml(run.text);
|
|
360
|
-
};
|
|
361
|
-
var escapeHtml = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
362
|
-
//#endregion
|
|
363
|
-
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, STANZA_PLACEHOLDER, STYLE_SETS, SpacerMeter, TranspositionRangeError, baseOf, chantHtml, chantRuns, chantText, chantTextStyle, checkWordHtml, composeScript, copyWordHtml, copyWordPlainText, defineStyleSet, dispose, downloadScorePng, downloadScoreSvg, gClefPitchOf, init, layoutForWord, markupWarnings, 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 };
|
|
@@ -46,6 +46,13 @@ export declare function baseOf(ch: string): {
|
|
|
46
46
|
} | undefined;
|
|
47
47
|
/** Whether `ch` is a modifier glyph (a sharp, flat or natural sign). */
|
|
48
48
|
export declare function isModifierGlyph(ch: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The length of the bracketed accidental that opens `notes` at `from`:
|
|
51
|
+
* an opening bracket, one or more accidental signs, the matching closing
|
|
52
|
+
* bracket, and the `¨`/`-` spacing right after it (`ÄôŨ¨` in `ÄôŨ¨õ`).
|
|
53
|
+
* 0 when no such unit stands there.
|
|
54
|
+
*/
|
|
55
|
+
export declare function bracketedAccidentalLength(notes: string, from?: number): number;
|
|
49
56
|
/** The clef glyphs (issue #49) and the staff line each one sits on,
|
|
50
57
|
* counted from the bottom. The g-clef has two keybindings. */
|
|
51
58
|
export declare const CLEF_GLYPHS: Readonly<Record<string, {
|
package/dist/lib/guidex.css
CHANGED
|
@@ -63,13 +63,34 @@
|
|
|
63
63
|
|
|
64
64
|
color: var(--text);
|
|
65
65
|
|
|
66
|
+
/* The lines keep to one column. A fr track counts as zero under a
|
|
67
|
+
min-content constraint, so the nowrap lines below don't turn into
|
|
68
|
+
the host's minimum width: an 'auto' score in a flex or grid column
|
|
69
|
+
can still shrink and re-lay out. Its max-content size stays the
|
|
70
|
+
longest line, so shrink-to-fit hosts size to the score as before. */
|
|
71
|
+
display: grid;
|
|
72
|
+
grid-template-columns: minmax(0, 1fr);
|
|
73
|
+
align-content: start;
|
|
74
|
+
|
|
66
75
|
/* Score alignment is precomputed in px; Safari's text inflation on
|
|
67
76
|
rotation would resize the text but not the baked-in spacers. Host
|
|
68
|
-
pages don't necessarily set this, so do it here.
|
|
77
|
+
pages don't necessarily set this, so do it here.
|
|
78
|
+
iOS Safari reads only the prefixed property, and a host's Autoprefixer
|
|
79
|
+
deletes it when its browserslist omits ios_saf (Next.js's default),
|
|
80
|
+
so it is exempted here. */
|
|
81
|
+
/* autoprefixer: ignore next */
|
|
69
82
|
-webkit-text-size-adjust: 100%;
|
|
70
83
|
text-size-adjust: 100%;
|
|
71
84
|
}
|
|
72
85
|
|
|
86
|
+
/* A fixed maxWidth may lay lines out wider than the container. The
|
|
87
|
+
render then grows to its longest line and overflows as one box; the
|
|
88
|
+
host decides whether that scrolls or clips (issue #93). 'auto' leaves
|
|
89
|
+
this off: the render's width is what it measures. */
|
|
90
|
+
.guidex-render[data-fixed-width] {
|
|
91
|
+
min-width: max-content;
|
|
92
|
+
}
|
|
93
|
+
|
|
73
94
|
@media (prefers-color-scheme: dark) {
|
|
74
95
|
.guidex-render {
|
|
75
96
|
--red: #ff4d4d;
|
|
@@ -89,13 +110,18 @@
|
|
|
89
110
|
color: var(--text-h);
|
|
90
111
|
padding-block: 0.3em;
|
|
91
112
|
position: relative;
|
|
113
|
+
/* The layout pass owns every line break; a browser wrap would part
|
|
114
|
+
the syllables from their notes */
|
|
115
|
+
white-space: nowrap;
|
|
92
116
|
}
|
|
93
117
|
|
|
94
118
|
/* The score's text line: margins reset (host pages style p freely) and
|
|
95
|
-
natural leading, like the app's .score p
|
|
119
|
+
natural leading, like the app's .score p; never re-wrapped, like the
|
|
120
|
+
notes line */
|
|
96
121
|
.guidex-render p {
|
|
97
122
|
margin: 0;
|
|
98
123
|
line-height: normal;
|
|
124
|
+
white-space: nowrap;
|
|
99
125
|
}
|
|
100
126
|
|
|
101
127
|
/* Host pages often drop-cap paragraphs (::first-letter rules like the
|
|
@@ -123,6 +149,7 @@
|
|
|
123
149
|
.guidex-render .guidex-error {
|
|
124
150
|
margin: 0;
|
|
125
151
|
color: var(--red);
|
|
152
|
+
white-space: normal;
|
|
126
153
|
font: 14px/1.4 'Book Antiqua', 'Palatino Linotype', Palatino, Georgia, serif;
|
|
127
154
|
}
|
|
128
155
|
/*$vite$:1*/
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { StyleSetName } from './guidoStyles';
|
|
2
|
-
import { LayoutSource } from './chantLayout';
|
|
1
|
+
import { MarkDefinitions, StyleSetName } from './guidoStyles';
|
|
2
|
+
import { LayoutSource, StaffFill } from './chantLayout';
|
|
3
3
|
export { NOTE_MODIFIERS, SCORE_MARKERS } from './chantLayout';
|
|
4
4
|
/** Options for one render. All fields optional; defaults reproduce the
|
|
5
5
|
* original Book Antiqua look (style set BNS). */
|
|
6
6
|
export interface RenderOptions {
|
|
7
|
-
/** Named style set
|
|
7
|
+
/** Named style set (default: BNS) */
|
|
8
8
|
style?: StyleSetName;
|
|
9
|
+
/** Marks this score adds to its style set's */
|
|
10
|
+
marks?: MarkDefinitions;
|
|
9
11
|
/** Render all text bold, measurements included */
|
|
10
12
|
bold?: boolean;
|
|
11
13
|
/** Text line size in px (default 18) */
|
|
@@ -16,6 +18,13 @@ export interface RenderOptions {
|
|
|
16
18
|
debug?: boolean;
|
|
17
19
|
/** Maximum notes-line width before a staff break (default: none) */
|
|
18
20
|
maxWidthPx?: number;
|
|
21
|
+
/** Dashes in a normal junction between note groups, in steps of a third (default 3) */
|
|
22
|
+
junctionDashes?: number;
|
|
23
|
+
/** How far each staff line runs (default `all-but-last`) */
|
|
24
|
+
staffFill?: StaffFill;
|
|
25
|
+
/** With `staffFill: 'longest'`: the distance from the available width
|
|
26
|
+
* within which every line runs to it instead (default 0) */
|
|
27
|
+
staffFillSnapPx?: number;
|
|
19
28
|
}
|
|
20
29
|
/**
|
|
21
30
|
* Renders a GuidoScript into a tidy score: a notes line in the chant font,
|
|
@@ -56,6 +65,7 @@ export declare class GuidoRender {
|
|
|
56
65
|
* run, carrying the run's inline styles and its notation-fixed kind
|
|
57
66
|
* class (`liturgy`, `rubric`, `star`, `marker`, `plus`); runs marked
|
|
58
67
|
* `initial` by the `*…*` marker carry the initial class. */
|
|
68
|
+
private static dashSpan;
|
|
59
69
|
private static sylSpan;
|
|
60
70
|
private static spacer;
|
|
61
71
|
}
|