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,16 +1,30 @@
|
|
|
1
1
|
import { ScriptTransform } from './guidoScriptTransforms';
|
|
2
|
+
import { SpanProblem, TextRun } from './textMarkup';
|
|
2
3
|
/** One parsed token of the script: a syllable, or a control statement.
|
|
3
4
|
* `spaceBefore` records whether the source had whitespace between the
|
|
4
5
|
* previous group and this token's group — it feeds the previous
|
|
5
6
|
* syllable's `wordEnd` and the `toString()` round-trip. */
|
|
6
7
|
export type ScriptToken = SyllableToken | StatementToken;
|
|
8
|
+
/** What a syllable token is for, independent of its look. `sung` is the
|
|
9
|
+
* text; `label` a heading that is not sung (`V.`, `ANT.`: a wrapped syllable
|
|
10
|
+
* with no pitch); `sign` a singer's sign (`**`, `*`, the cross); `aid` sung
|
|
11
|
+
* but not part of the text (the differentia, inside `(@aid)`). */
|
|
12
|
+
export type SyllableRole = 'sung' | 'label' | 'sign' | 'aid';
|
|
7
13
|
/** A syllable token. `held` marks a text-less group held by the syllable
|
|
8
14
|
* before it (its `wordEnd` is that syllable's); `empty` marks an empty
|
|
9
15
|
* slot (`~`, or a text-less group at the start): notes but no syllable.
|
|
10
|
-
* Both flags are only present when set.
|
|
16
|
+
* Both flags are only present when set. `text` is what it reads, with no
|
|
17
|
+
* markup in it; `runs` what it draws; `source` how it is written, standing
|
|
18
|
+
* on its own, which is what the rewrites write back. `hyphen` is the marks
|
|
19
|
+
* of the hyphen after it, when a `{…}` span runs on into the next syllable.
|
|
20
|
+
* Text fields are empty on a held group and an empty slot. */
|
|
11
21
|
export type SyllableToken = {
|
|
12
22
|
kind: 'syllable';
|
|
13
23
|
text: string;
|
|
24
|
+
source: string;
|
|
25
|
+
runs: TextRun[];
|
|
26
|
+
hyphen?: string[];
|
|
27
|
+
role: SyllableRole;
|
|
14
28
|
notes: string;
|
|
15
29
|
wordEnd: boolean;
|
|
16
30
|
spaceBefore: boolean;
|
|
@@ -19,6 +33,11 @@ export type SyllableToken = {
|
|
|
19
33
|
};
|
|
20
34
|
/** A syllable as `GuidoScript.syllables` lists it. */
|
|
21
35
|
export type Syllable = Pick<SyllableToken, 'text' | 'notes' | 'wordEnd' | 'held' | 'empty'>;
|
|
36
|
+
/** One word of the script (`GuidoScript.words`). */
|
|
37
|
+
export interface Word {
|
|
38
|
+
text: string;
|
|
39
|
+
syllables: Pick<SyllableToken, 'text' | 'source' | 'runs' | 'role' | 'notes'>[];
|
|
40
|
+
}
|
|
22
41
|
/** Source offsets of one token (see `GuidoScript.tokenSpans`): `start`
|
|
23
42
|
* is its text's first character (its group's `(` when it has no text),
|
|
24
43
|
* `notesStart`/`notesEnd` bound its group's content, `end` is just past
|
|
@@ -44,7 +63,29 @@ export type StatementToken = {
|
|
|
44
63
|
kind: 'key';
|
|
45
64
|
key: string;
|
|
46
65
|
spaceBefore: boolean;
|
|
66
|
+
} | {
|
|
67
|
+
kind: 'tight';
|
|
68
|
+
on: boolean;
|
|
69
|
+
spaceBefore: boolean;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'keep';
|
|
72
|
+
on: boolean;
|
|
73
|
+
spaceBefore: boolean;
|
|
74
|
+
} | {
|
|
75
|
+
kind: 'unit';
|
|
76
|
+
on: boolean;
|
|
77
|
+
spaceBefore: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
kind: 'aid';
|
|
80
|
+
on: boolean;
|
|
81
|
+
spaceBefore: boolean;
|
|
47
82
|
};
|
|
83
|
+
/** The statements that open and close a run of syllables (issue #100):
|
|
84
|
+
* `tight` spacing, `keep` on one line, `unit` both, and `aid` the syllables
|
|
85
|
+
* that are sung but are not the text (issue #110). */
|
|
86
|
+
export type RunStatementKind = 'tight' | 'keep' | 'unit' | 'aid';
|
|
87
|
+
/** The run properties a run statement sets. */
|
|
88
|
+
export declare function runProperties(kind: RunStatementKind): ('tight' | 'keep' | 'aid')[];
|
|
48
89
|
/** Whether a group's content is a control statement (`@`-keyword,
|
|
49
90
|
* trimmed). Shared with the transforms, which must leave statement
|
|
50
91
|
* groups alone — their keyword characters are pitch glyphs otherwise.
|
|
@@ -79,6 +120,9 @@ export declare class GuidoScript {
|
|
|
79
120
|
* content and just past its group's `)`. The walker
|
|
80
121
|
* (`scriptSyllables`) reads them. */
|
|
81
122
|
get tokenSpans(): TokenSpan[];
|
|
123
|
+
/** What is wrong with the script's `{…}` spans: such a span renders
|
|
124
|
+
* plainly instead of failing the score. */
|
|
125
|
+
get spanProblems(): SpanProblem[];
|
|
82
126
|
private parse;
|
|
83
127
|
/** The script broken into syllables, each with its sung text and
|
|
84
128
|
* notes — the syllable tokens, statements filtered out. */
|
|
@@ -95,21 +139,18 @@ export declare class GuidoScript {
|
|
|
95
139
|
private get normalized();
|
|
96
140
|
/** The syllables grouped into the words of the text. Held groups and
|
|
97
141
|
* empty slots sing no syllable of their own, so they are left out. */
|
|
98
|
-
get words():
|
|
99
|
-
text: string;
|
|
100
|
-
syllables: {
|
|
101
|
-
text: string;
|
|
102
|
-
notes: string;
|
|
103
|
-
}[];
|
|
104
|
-
}[];
|
|
142
|
+
get words(): Word[];
|
|
105
143
|
/** The script rebuilt from the parsed pieces — a round-trip of the
|
|
106
144
|
* source, statements and stanzas included. */
|
|
107
145
|
toString(): string;
|
|
108
146
|
}
|
|
109
|
-
/** One
|
|
147
|
+
/** One syllable of a script (see `scriptSyllables`). */
|
|
110
148
|
export interface ScriptSyllable {
|
|
111
|
-
/**
|
|
149
|
+
/** The text to read: escapes folded, no markup in it */
|
|
112
150
|
text: string;
|
|
151
|
+
/** Its text as written, markup and escapes kept */
|
|
152
|
+
source: string;
|
|
153
|
+
role: SyllableRole;
|
|
113
154
|
/** Its own note group's content, escapes folded */
|
|
114
155
|
notes: string;
|
|
115
156
|
/** The groups it holds (issue #83), escapes folded, in order */
|
|
@@ -130,17 +171,30 @@ export interface ScriptSyllable {
|
|
|
130
171
|
token: number;
|
|
131
172
|
}
|
|
132
173
|
/**
|
|
133
|
-
* The syllables of a script
|
|
134
|
-
*
|
|
135
|
-
* (
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* `composeScript`'s
|
|
174
|
+
* The syllables of a script, in order: by default the sung ones, labels and
|
|
175
|
+
* signs left out (`roles` chooses others). Held groups ride on their
|
|
176
|
+
* syllable (`held`); `~` empty slots, statements and `(@stanza …)` are
|
|
177
|
+
* skipped. Word starts and ends are the listed syllables' own, so a word
|
|
178
|
+
* end on a left-out syllable lands on the one before it. Offsets index the
|
|
179
|
+
* script's source; index i is the "syllable i" of `composeScript`'s
|
|
180
|
+
* `from`/`to`.
|
|
139
181
|
*/
|
|
140
|
-
export declare function scriptSyllables(script: GuidoScript | string
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
182
|
+
export declare function scriptSyllables(script: GuidoScript | string, options?: {
|
|
183
|
+
roles?: readonly SyllableRole[];
|
|
184
|
+
}): ScriptSyllable[];
|
|
185
|
+
/** What `chantText` adds to the sung words, both off by default. */
|
|
186
|
+
export interface ChantTextOptions {
|
|
187
|
+
/** Keep the labels (`V.`, `R.`, `ANT.`) */
|
|
188
|
+
labels?: boolean;
|
|
189
|
+
/** Keep the sung aids (the differentia) */
|
|
190
|
+
aids?: boolean;
|
|
191
|
+
}
|
|
192
|
+
/** The text of the script to read: the sung words joined with single
|
|
193
|
+
* spaces, with no markup, labels, signs or aids in them. Characters the
|
|
194
|
+
* author escaped stay. */
|
|
195
|
+
export declare function chantText(script: string, options?: ChantTextOptions): string;
|
|
196
|
+
/** A syllable's text fields, from text written on its own. */
|
|
197
|
+
export declare function syllableText(written: string): Pick<SyllableToken, 'text' | 'source' | 'runs' | 'hyphen'>;
|
|
144
198
|
/** Folds backslash escapes into the characters they stand for. Shared
|
|
145
199
|
* with the transforms module (guidoScriptTransforms.ts). */
|
|
146
200
|
export declare function unescape(text: string): string;
|
|
@@ -5,24 +5,6 @@ export interface ScriptTransform {
|
|
|
5
5
|
name: string;
|
|
6
6
|
apply: (source: string) => string;
|
|
7
7
|
}
|
|
8
|
-
/** The `startWithInitial` transform: finds the first syllable group with
|
|
9
|
-
* actual notes and text (the clef, no-notes groups, control statements,
|
|
10
|
-
* text-less groups and `~` empty slots don't count) and wraps the
|
|
11
|
-
* syllable's first character in the `*…*` initial marker. Already-marked
|
|
12
|
-
* text (leading `*`) is left alone. */
|
|
13
|
-
declare function startWithInitial(source: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* The built-in transformations, keyed by name; pass the ones a feature
|
|
16
|
-
* needs to the GuidoScript constructor.
|
|
17
|
-
*/
|
|
18
|
-
export declare const SCRIPT_TRANSFORMS: {
|
|
19
|
-
/** Wraps the first letter of the first syllable that has notes in
|
|
20
|
-
* `*…*`, the initial marker of the style marking system. */
|
|
21
|
-
startWithInitial: {
|
|
22
|
-
name: string;
|
|
23
|
-
apply: typeof startWithInitial;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
8
|
/** The pitch rows of the chant font: every character carrying pitch
|
|
27
9
|
* information, grouped into rows of neighbouring pitches from low to
|
|
28
10
|
* high. A transpose shift moves a character this many positions along
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Mark, TextRun } from './textMarkup';
|
|
2
2
|
/** How one run of syllable text is drawn. Unset fields inherit from the
|
|
3
3
|
* surrounding text line: the style set's text font stack, its base weight,
|
|
4
4
|
* and the theme's text color. */
|
|
@@ -15,12 +15,16 @@ export interface PartStyle {
|
|
|
15
15
|
/** Raised above the baseline by this fraction of the text size; does
|
|
16
16
|
* not affect width measurement (position: relative, out of flow) */
|
|
17
17
|
raise?: number;
|
|
18
|
-
/** The run
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
18
|
+
/** The run draws in capitals, through CSS text-transform; its
|
|
19
|
+
* capitals are measured as they draw, which canvas does exactly like
|
|
20
|
+
* the DOM lays out (font-variant: small-caps does not — the browser's
|
|
21
|
+
* canvas synthesis measures wider than the real smcp glyphs it uses
|
|
22
|
+
* for DOM layout). Display only: the run's text stays as written. */
|
|
23
23
|
uppercase?: boolean;
|
|
24
|
+
/** True small caps (the `sc` mark): lowercase letters draw as capitals
|
|
25
|
+
* at `SMALL_CAP_SCALE`, in runs of their own, and the rest at full size.
|
|
26
|
+
* On a resolved run, marks the small letters (Word's small-caps run). */
|
|
27
|
+
smallCaps?: boolean;
|
|
24
28
|
/** Inline color; absent means inherit (keeps dark mode working) */
|
|
25
29
|
color?: string;
|
|
26
30
|
/** The run carries the initial class in the DOM (the `*…*` marker) */
|
|
@@ -44,24 +48,21 @@ export interface StyleSet {
|
|
|
44
48
|
family: string;
|
|
45
49
|
weight: '400' | '700';
|
|
46
50
|
}[];
|
|
47
|
-
/**
|
|
48
|
-
* `__…__`
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
/** The marks this style set draws, by name: the semantic ones the
|
|
52
|
+
* sugar produces (`liturgy` for `__…__`, `rubric` for `_…_`, `initial`
|
|
53
|
+
* for `*…*`, `star` for `**`, `plus` for a Liturgy run's `+`) and any
|
|
54
|
+
* others a script names in a `{…}` span. A consumer's style set extends
|
|
55
|
+
* them; the primitives (`red`, `b`, `i`, `sc`…) always mean the same. */
|
|
56
|
+
marks: Record<string, PartStyle>;
|
|
57
|
+
/** Colors `color:<name>` and a mark's `color` can name, past the
|
|
58
|
+
* built-in palette: a CSS color or a `var(--…)` the Word export knows */
|
|
59
|
+
colors?: Record<string, string>;
|
|
60
|
+
/** Fonts `font:<name>` can name, past the built-in ones: a font stack.
|
|
61
|
+
* A webfont also belongs in `verifiedFonts`. */
|
|
62
|
+
fonts?: Record<string, string>;
|
|
57
63
|
/** Line-end padding in px: the break marker `*` lands this far past
|
|
58
64
|
* the max-width position. Defaults to 0 (the star sits on the edge). */
|
|
59
65
|
padding?: number;
|
|
60
|
-
/** Script transforms applied by default when a score renders in this
|
|
61
|
-
* style: whoever parses the score's source (embed runtime, editor)
|
|
62
|
-
* starts from this list and layers user-requested transforms (e.g.
|
|
63
|
-
* transpose) on top. Defaults to no transforms. */
|
|
64
|
-
scriptTransforms?: ScriptTransform[];
|
|
65
66
|
}
|
|
66
67
|
export declare const STYLE_SETS: {
|
|
67
68
|
/** Book Antiqua text with red accents. */
|
|
@@ -79,36 +80,33 @@ export declare const STYLE_SETS: {
|
|
|
79
80
|
family: string;
|
|
80
81
|
weight: "700";
|
|
81
82
|
})[];
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
marks: {
|
|
84
|
+
liturgy: {
|
|
84
85
|
fontFamily: string;
|
|
85
86
|
weight: "700";
|
|
86
87
|
color: string;
|
|
87
88
|
};
|
|
88
|
-
|
|
89
|
+
rubric: {
|
|
89
90
|
uppercase: true;
|
|
90
91
|
scale: number;
|
|
91
92
|
color: string;
|
|
92
93
|
};
|
|
93
|
-
|
|
94
|
+
initial: {
|
|
94
95
|
weight: "700";
|
|
95
96
|
color: string;
|
|
96
97
|
initial: true;
|
|
97
98
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
star: {
|
|
100
|
+
fontFamily: string;
|
|
101
|
+
weight: "700";
|
|
102
|
+
scale: number;
|
|
103
|
+
measureScale: number;
|
|
104
|
+
raise: number;
|
|
105
|
+
color: string;
|
|
106
|
+
};
|
|
107
|
+
plus: PartStyle;
|
|
106
108
|
};
|
|
107
109
|
padding: number;
|
|
108
|
-
scriptTransforms: {
|
|
109
|
-
name: string;
|
|
110
|
-
apply: (source: string) => string;
|
|
111
|
-
}[];
|
|
112
110
|
};
|
|
113
111
|
/** Times New Roman text, strictly black and white. */
|
|
114
112
|
Vesperale: {
|
|
@@ -121,33 +119,45 @@ export declare const STYLE_SETS: {
|
|
|
121
119
|
family: string;
|
|
122
120
|
weight: "700";
|
|
123
121
|
})[];
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
marks: {
|
|
123
|
+
liturgy: {
|
|
126
124
|
fontFamily: string;
|
|
127
125
|
weight: "700";
|
|
128
126
|
};
|
|
129
|
-
|
|
127
|
+
rubric: {
|
|
130
128
|
scale: number;
|
|
131
129
|
italic: true;
|
|
132
130
|
};
|
|
133
|
-
|
|
131
|
+
initial: {
|
|
134
132
|
weight: "700";
|
|
135
133
|
initial: true;
|
|
136
134
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
star: {
|
|
136
|
+
fontFamily: string;
|
|
137
|
+
weight: "700";
|
|
138
|
+
scale: number;
|
|
139
|
+
measureScale: number;
|
|
140
|
+
raise: number;
|
|
141
|
+
};
|
|
142
|
+
plus: PartStyle;
|
|
144
143
|
};
|
|
145
144
|
padding: number;
|
|
146
|
-
scriptTransforms: never[];
|
|
147
145
|
};
|
|
148
146
|
};
|
|
149
|
-
|
|
147
|
+
/** A style set's name: a built-in one, or one `defineStyleSet` added. */
|
|
148
|
+
export type StyleSetName = keyof typeof STYLE_SETS | (string & {});
|
|
150
149
|
export declare const DEFAULT_STYLE_SET: StyleSetName;
|
|
150
|
+
/** The style set of that name, built-in or defined. */
|
|
151
|
+
export declare function styleSetOf(name: StyleSetName): StyleSet | undefined;
|
|
152
|
+
/** What a new style set says: the set it extends (default: the default
|
|
153
|
+
* one), and whatever differs from it. `marks`, `colors` and `fonts` merge
|
|
154
|
+
* over the extended set's, the rest replaces it. */
|
|
155
|
+
export type StyleSetDefinition = Partial<StyleSet> & {
|
|
156
|
+
extends?: StyleSetName;
|
|
157
|
+
};
|
|
158
|
+
/** Adds a style set under a name `style` can then give, without patching
|
|
159
|
+
* the package. Returns it. */
|
|
160
|
+
export declare function defineStyleSet(name: string, definition: StyleSetDefinition): StyleSet;
|
|
151
161
|
/** What one run of syllable text is, independent of how a style set
|
|
152
162
|
* draws it: the notation-fixed meaning of the markup that produced it.
|
|
153
163
|
* `liturgy` the `__…__` wrapper, `rubric` `_…_`, `star` the whole-syllable
|
|
@@ -162,30 +172,31 @@ export interface SyllablePart {
|
|
|
162
172
|
style: PartStyle;
|
|
163
173
|
kind?: ChantRunKind;
|
|
164
174
|
}
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
*
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
*
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* `marker`, `plus`)
|
|
181
|
-
* renderer's run classes share
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
export declare function
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
/** How much smaller small capitals draw than the full capitals. */
|
|
176
|
+
export declare const SMALL_CAP_SCALE = 0.75;
|
|
177
|
+
/** The run kind of a run's marks: the last of the notation's own. */
|
|
178
|
+
export declare function kindOf(marks: Mark[]): ChantRunKind | undefined;
|
|
179
|
+
/** Marks a score adds to its style set's. */
|
|
180
|
+
export type MarkDefinitions = Record<string, PartStyle>;
|
|
181
|
+
/** The look of comma-separated marks (`red,sc`), for a host styling prose
|
|
182
|
+
* to match the score. */
|
|
183
|
+
export declare function resolveMarks(marks: string, styleSet: StyleSet, extra?: MarkDefinitions): PartStyle;
|
|
184
|
+
/** The marks of `marks` that neither the primitives, the style set nor
|
|
185
|
+
* `extra` define. */
|
|
186
|
+
export declare function unknownMarks(marks: Mark[], styleSet: StyleSet, extra?: MarkDefinitions): Mark[];
|
|
187
|
+
/** Resolves parsed text runs (`SyllableToken.runs`) into how a style set
|
|
188
|
+
* draws them: each run takes the style of its marks, the `bold` option
|
|
189
|
+
* forces weight 700 onto every run, and `kind` names its notation-fixed
|
|
190
|
+
* semantic (`liturgy`, `rubric`, `star`, `marker`, `plus`), the vocabulary
|
|
191
|
+
* the marked-up text export and the renderer's run classes share. A
|
|
192
|
+
* small-caps run splits into full and small parts. Text stays as written:
|
|
193
|
+
* capitals are the part's display (`drawnText`). */
|
|
194
|
+
export declare function resolveTextRuns(runs: readonly TextRun[], styleSet: StyleSet, bold: boolean, extra?: MarkDefinitions): SyllablePart[];
|
|
195
|
+
/** The characters a part draws, which measuring must see. */
|
|
196
|
+
export declare function drawnText(part: Pick<SyllablePart, 'text' | 'style'>): string;
|
|
197
|
+
/** Parses a syllable as written (`SyllableToken.source`) and resolves its
|
|
198
|
+
* runs in one step (see `resolveSpans`, `resolveTextRuns`). */
|
|
199
|
+
export declare function resolveSyllableParts(written: string, styleSet: StyleSet, bold: boolean, extra?: MarkDefinitions): SyllablePart[];
|
|
189
200
|
/** The canvas font shorthand for measuring a run at the text size. */
|
|
190
201
|
export declare function measurementFont(style: PartStyle, textPx: number, fallbackStack: string): string;
|
|
191
202
|
/** The inline CSS properties that draw a run, as dash-cased names for
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { MaxWidth } from '../embed/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { MaxWidth, ScoreWarning } from '../embed/core';
|
|
2
|
+
import { StaffFill } from '../chantLayout';
|
|
3
|
+
import { StyleSetName, MarkDefinitions } from '../guidoStyles';
|
|
4
|
+
import { EmptySlots, StanzaStack } from '../stanzas';
|
|
4
5
|
export interface GuidexScoreProps {
|
|
5
6
|
/** The score source in GuidoScript notation, e.g. `'(M)A(0) di(0q)e(qQ0)bus(1) an(3)ti(1e)quis(qQ0-:)'`. */
|
|
6
7
|
script: string;
|
|
@@ -11,6 +12,14 @@ export interface GuidexScoreProps {
|
|
|
11
12
|
bold?: boolean;
|
|
12
13
|
/** Text size in px (default 18). */
|
|
13
14
|
textPx?: number;
|
|
15
|
+
/** Dashes in a normal junction between note groups, in steps of a third (default 3). */
|
|
16
|
+
junctionDashes?: number;
|
|
17
|
+
/** Marks this score adds to its style set's */
|
|
18
|
+
marks?: MarkDefinitions;
|
|
19
|
+
/** How far each staff line runs (default `all-but-last`). */
|
|
20
|
+
staffFill?: StaffFill;
|
|
21
|
+
/** With `staffFill: 'longest'`: the distance from the available width within which every line runs to it instead (default 0). */
|
|
22
|
+
staffFillSnapPx?: number;
|
|
14
23
|
/** Transpose the score by N diatonic steps. */
|
|
15
24
|
transpose?: number;
|
|
16
25
|
/** The stanza sung under the notes (1-based, default 1: the
|
|
@@ -29,9 +38,9 @@ export interface GuidexScoreProps {
|
|
|
29
38
|
emptySlots?: EmptySlots;
|
|
30
39
|
/** Called after each render with the rendered stanzas' count
|
|
31
40
|
* mismatches (empty when it fits). */
|
|
32
|
-
onWarnings?: (warnings:
|
|
41
|
+
onWarnings?: (warnings: ScoreWarning[]) => void;
|
|
33
42
|
/** Render measurement debug markers. */
|
|
34
43
|
debug?: boolean;
|
|
35
44
|
className?: string;
|
|
36
45
|
}
|
|
37
|
-
export declare function GuidexScore({ script, maxWidth, style, bold, textPx, transpose, stanza, stack, stanzas, emptySlots, onWarnings, debug, className, }: GuidexScoreProps): import('react').JSX.Element;
|
|
46
|
+
export declare function GuidexScore({ script, maxWidth, style, bold, textPx, junctionDashes, marks, staffFill, staffFillSnapPx, transpose, stanza, stack, stanzas, emptySlots, onWarnings, debug, className, }: GuidexScoreProps): import('react').JSX.Element;
|
|
@@ -5,5 +5,7 @@
|
|
|
5
5
|
export { GuidexScore, type GuidexScoreProps } from './GuidexScore';
|
|
6
6
|
export { renderScore, renderAll, init, dispose, version, type EmbedOptions, type MaxWidth, type RenderResult, type RenderScoreOptions, } from '../embed/core';
|
|
7
7
|
export { downloadScorePng, downloadScoreSvg, scorePngBlob, scoreSvg, type ScoreDownloadOptions, type ScoreImageOptions, } from '../scoreImage';
|
|
8
|
+
export type { StaffFill } from '../chantLayout';
|
|
8
9
|
export type { StyleSetName } from '../guidoStyles';
|
|
10
|
+
export type { MarkWarning } from '../chantMarkup';
|
|
9
11
|
export type { EmptySlots, StanzaStack, StanzaWarning } from '../stanzas';
|
package/dist/lib/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
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 { 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";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/react/GuidexScore.tsx
|
|
@@ -10,23 +10,29 @@ import { jsx } from "react/jsx-runtime";
|
|
|
10
10
|
* client'` directive marks it for React Server Components (Next.js App
|
|
11
11
|
* Router); in plain client-side React it is a no-op.
|
|
12
12
|
*/
|
|
13
|
-
function GuidexScore({ script, maxWidth, style, bold, textPx, transpose, stanza, stack, stanzas, emptySlots, onWarnings, debug, className }) {
|
|
13
|
+
function GuidexScore({ script, maxWidth, style, bold, textPx, junctionDashes, marks, staffFill, staffFillSnapPx, transpose, stanza, stack, stanzas, emptySlots, onWarnings, debug, className }) {
|
|
14
14
|
const ref = useRef(null);
|
|
15
15
|
const onWarningsRef = useRef(onWarnings);
|
|
16
16
|
onWarningsRef.current = onWarnings;
|
|
17
17
|
const stanzasKey = stanzas === void 0 ? void 0 : JSON.stringify(stanzas);
|
|
18
|
+
const marksKey = marks === void 0 ? void 0 : JSON.stringify(marks);
|
|
18
19
|
const stackKey = stack === void 0 ? void 0 : JSON.stringify(stack);
|
|
19
20
|
useEffect(() => {
|
|
20
21
|
const el = ref.current;
|
|
21
22
|
if (!el) return;
|
|
22
23
|
let live = true;
|
|
24
|
+
const scoreMarks = marksKey === void 0 ? void 0 : JSON.parse(marksKey);
|
|
23
25
|
const stanzaTexts = stanzasKey === void 0 ? void 0 : JSON.parse(stanzasKey);
|
|
24
26
|
const stacked = stackKey === void 0 ? void 0 : JSON.parse(stackKey);
|
|
25
27
|
renderScore(el, script, {
|
|
26
28
|
maxWidth,
|
|
27
29
|
style,
|
|
30
|
+
marks: scoreMarks,
|
|
28
31
|
bold,
|
|
29
32
|
textPx,
|
|
33
|
+
junctionDashes,
|
|
34
|
+
staffFill,
|
|
35
|
+
staffFillSnapPx,
|
|
30
36
|
transpose,
|
|
31
37
|
stanza,
|
|
32
38
|
stack: stacked,
|
|
@@ -44,8 +50,12 @@ function GuidexScore({ script, maxWidth, style, bold, textPx, transpose, stanza,
|
|
|
44
50
|
script,
|
|
45
51
|
maxWidth,
|
|
46
52
|
style,
|
|
53
|
+
marksKey,
|
|
47
54
|
bold,
|
|
48
55
|
textPx,
|
|
56
|
+
junctionDashes,
|
|
57
|
+
staffFill,
|
|
58
|
+
staffFillSnapPx,
|
|
49
59
|
transpose,
|
|
50
60
|
stanza,
|
|
51
61
|
stackKey,
|