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.
- package/README.md +219 -0
- package/dist/lib/app/ControlsRow.d.ts +1 -0
- package/dist/lib/app/Editor.d.ts +1 -0
- package/dist/lib/app/EditorContext.d.ts +17 -0
- package/dist/lib/app/EditorTextarea.d.ts +1 -0
- package/dist/lib/app/ExportSettings.d.ts +1 -0
- package/dist/lib/app/FeedbackSpan.d.ts +5 -0
- package/dist/lib/app/RenderSettings.d.ts +1 -0
- package/dist/lib/app/SamplesRow.d.ts +1 -0
- package/dist/lib/app/SettingsMenu.d.ts +1 -0
- package/dist/lib/app/SettingsPanel.d.ts +1 -0
- package/dist/lib/app/SyllablesTable.d.ts +1 -0
- package/dist/lib/app/WordCheckPanel.d.ts +1 -0
- package/dist/lib/app/WordCopyControls.d.ts +1 -0
- package/dist/lib/app/chantLibrary.d.ts +11 -0
- package/dist/lib/app/editorState.d.ts +159 -0
- package/dist/lib/app/samples.d.ts +10 -0
- package/dist/lib/app/wordCopy.d.ts +30 -0
- package/dist/lib/chantLayout-GAfg2iKS.js +1042 -0
- package/dist/lib/chantLayout.d.ts +169 -0
- package/dist/lib/chantMarkup.d.ts +36 -0
- package/dist/lib/editorStorage.d.ts +179 -0
- package/dist/lib/embed/index.d.ts +1 -0
- package/dist/lib/embed/index.js +2 -2
- package/dist/lib/embed/manual.d.ts +15 -4
- package/dist/lib/embed/manual.js +43 -2
- package/dist/lib/guidoRender.d.ts +22 -29
- package/dist/lib/guidoScript.d.ts +28 -3
- package/dist/lib/guidoScriptTransforms.d.ts +5 -4
- package/dist/lib/guidoStyles.d.ts +23 -5
- package/dist/lib/main.d.ts +0 -1
- package/dist/lib/react/index.d.ts +1 -0
- package/dist/lib/react/index.js +2 -2
- package/dist/lib/scoreImage-DnFIbtF_.js +951 -0
- package/dist/lib/scoreImage.d.ts +63 -0
- package/dist/lib/word/index.d.ts +17 -0
- package/dist/lib/word/index.js +2 -0
- package/dist/lib/wordChecker-C3nJrk_j.js +1042 -0
- package/dist/lib/wordChecker.d.ts +66 -0
- package/dist/lib/wordClipboard.d.ts +25 -0
- package/dist/lib/wordExport.d.ts +244 -0
- package/dist-embed/guidex-embed.min.js +1 -1
- package/package.json +8 -1
- package/dist/lib/core-hF6L1EtS.js +0 -1268
- package/dist/lib/settingsMenu.d.ts +0 -1
package/README.md
CHANGED
|
@@ -21,9 +21,17 @@ The package ships a typed ESM build with an exports map:
|
|
|
21
21
|
`init(options?)`, `dispose(el)`, plus the sung-text helpers
|
|
22
22
|
(`chantText(script)`, the `GuidoScript` parser, `unescape`) and the
|
|
23
23
|
style sets (`STYLE_SETS`, `DEFAULT_STYLE_SET`, `StyleSetName`).
|
|
24
|
+
Also the Word-compatible export: `toWordHtml(script, options?)`,
|
|
25
|
+
`toWordText(script, options?)`, the clipboard writers
|
|
26
|
+
`copyWordHtml` / `copyWordPlainText`, and the paste checker
|
|
27
|
+
`checkWordHtml(html)` (see *Word export* below).
|
|
24
28
|
- **`guidex/react`** — the `GuidexScore` client component (`'use client'`
|
|
25
29
|
marked, works in Next.js App Router Server Components). React ≥ 18 is
|
|
26
30
|
an optional peer dependency; only React users install it.
|
|
31
|
+
- **`guidex/word`** — the Word export on its own: the Word functions above plus
|
|
32
|
+
`layoutForWord(script, options?)`, the layout as structured lines for
|
|
33
|
+
building `.docx` documents directly (see *Structured Word layout*
|
|
34
|
+
below). Browser-only, like the rest: it measures with canvas.
|
|
27
35
|
- **`guidex/embed`** — the same API plus auto-render: importing it scans
|
|
28
36
|
the document for `.guido-script` elements immediately, like the script
|
|
29
37
|
tag. Don't use this in frameworks that re-render the DOM.
|
|
@@ -56,6 +64,204 @@ new GuidoScript('(M)A(0) di(0q)e(qQ0)bus(1) an(3)ti(1e)quis(qQ0-:)').words
|
|
|
56
64
|
// { text: 'antiquis', syllables: [{ text: 'an', notes: '3' }, { text: 'ti', notes: '1e' }, { text: 'quis', notes: 'qQ0-:' }] }]
|
|
57
65
|
```
|
|
58
66
|
|
|
67
|
+
### Marked-up text
|
|
68
|
+
|
|
69
|
+
The sung text with its markup, for displaying the text outside the
|
|
70
|
+
score: `chantRuns` gives the structure (words → syllables → runs), and
|
|
71
|
+
`chantHtml` serializes it as HTML. The `**` star renders as `∗`, and the
|
|
72
|
+
decoration wrappers become notation-fixed kinds — `liturgy` for `__…__`,
|
|
73
|
+
`rubric` for `_…_`, `initial` for `*…*`, `marker` for the `*`/`†` glyph
|
|
74
|
+
runs, `plus` for a `+` inside a Liturgy run:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
import { chantHtml, chantRuns } from 'guidex'
|
|
78
|
+
|
|
79
|
+
const script = '(c4)__V.__() *Psa*lmus(1) **(2) De(7)us(2)'
|
|
80
|
+
|
|
81
|
+
chantHtml(script) // '<span class="liturgy">V.</span> <span class="initial">Psa</span>lmus <span class="star">∗</span> Deus'
|
|
82
|
+
chantRuns(script)
|
|
83
|
+
// [{ syllables: [{ runs: [{ text: 'V.', kind: 'liturgy' }] }] },
|
|
84
|
+
// { syllables: [{ runs: [{ text: 'Psa', initial: true }, { text: 'lmus' }] }] },
|
|
85
|
+
// { syllables: [{ runs: [{ text: '∗', kind: 'star' }] }] },
|
|
86
|
+
// { syllables: [{ runs: [{ text: 'De' }] }, { runs: [{ text: 'us' }] }] }]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Both take `{ style }` like the renderer (default BNS) and apply the
|
|
90
|
+
style set's default script transforms, so the text matches what a score
|
|
91
|
+
render shows. The kinds are identical across style sets and identical to
|
|
92
|
+
the class names the rendered score's spans carry, so one stylesheet
|
|
93
|
+
serves both. Style them yourself — the BNS and Vesperale looks
|
|
94
|
+
correspond to:
|
|
95
|
+
|
|
96
|
+
```css
|
|
97
|
+
.liturgy { font-family: 'Liturgy', serif; font-weight: 700; }
|
|
98
|
+
.initial { font-weight: 700; }
|
|
99
|
+
/* BNS flavour */
|
|
100
|
+
.rubric { text-transform: uppercase; font-size: 70%; }
|
|
101
|
+
.liturgy, .rubric, .initial { color: #d40000; }
|
|
102
|
+
/* Vesperale flavour */
|
|
103
|
+
.rubric { font-style: italic; font-size: 80%; }
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Letter case stays the raw text's (uppercasing BNS rubrics is
|
|
107
|
+
presentation), and the syllable boundaries live in `chantRuns` for
|
|
108
|
+
consumers that hyphenate.
|
|
109
|
+
|
|
110
|
+
### Word export
|
|
111
|
+
|
|
112
|
+
Move a score into Microsoft Word losslessly: the export lays the score
|
|
113
|
+
out exactly like the renderer and emits Word-flavoured HTML that pastes
|
|
114
|
+
as alternating `BNS-nota` / `BNS-textus` paragraphs — the chant-font
|
|
115
|
+
notes over their syllables, with the styles mapping onto the document's
|
|
116
|
+
own definitions by `mso-style-name`.
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
import { copyWordHtml, toWordHtml, toWordText, checkWordHtml } from 'guidex'
|
|
120
|
+
|
|
121
|
+
// one-shot: put the Word payload on the clipboard (text/html primary,
|
|
122
|
+
// text/plain fallback) — call it from a user gesture
|
|
123
|
+
await copyWordHtml(script, { maxWidthPx: 700 })
|
|
124
|
+
|
|
125
|
+
// or take the strings directly
|
|
126
|
+
const html = await toWordHtml(script, { maxWidthPx: 700 })
|
|
127
|
+
const text = await toWordText(script, { maxWidthPx: 700 })
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Both emitters accept the renderer's `style`, `bold`, `textPx`,
|
|
131
|
+
`notesPx`, and `maxWidthPx` options — plus the destination-document
|
|
132
|
+
sizes `textPt` / `notesPt` / `maxWidthPt`, which take precedence. The
|
|
133
|
+
pt options are what a real Word round-trip wants: Word renders the
|
|
134
|
+
pasted styles at the destination's own pt sizes regardless of the web
|
|
135
|
+
preview, so laying out at those sizes (the demo sends 10pt text /
|
|
136
|
+
20pt notes over a ~10.8 cm column) makes the width tuning converge on
|
|
137
|
+
the destination's true grid and the line breaks match the destination
|
|
138
|
+
column rather than the preview. The width options must be concrete
|
|
139
|
+
(the demo resolves them from its inputs); every broken notes line ends
|
|
140
|
+
with a tab + the Guido `*` glyph, right-aligned to the paragraph
|
|
141
|
+
style's tab stop.
|
|
142
|
+
|
|
143
|
+
Every horizontal gap — lead-in, word gaps, syllable junctions alike —
|
|
144
|
+
is faked by one spacer mechanism, `unit × count`, with two independent
|
|
145
|
+
knobs. The default is a no-break space at its natural advance: the
|
|
146
|
+
advance is proportional to the inherited font size, so it stays
|
|
147
|
+
correct at whatever size Word renders, and plain characters survive
|
|
148
|
+
any paste path — no mso machinery to lose:
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
await copyWordHtml(script, { textPt: 10, notesPt: 20, maxWidthPt: 306 })
|
|
152
|
+
// spacer defaults to { character: 'nbsp' }; the alternatives:
|
|
153
|
+
await copyWordHtml(script, {
|
|
154
|
+
spacer: { character: 'tab', width: { kind: 'tabInterval', pt: 1.42 } }, // 0.5 mm
|
|
155
|
+
// spacer: { character: 'en' } // or 'em' — proportional like nbsp
|
|
156
|
+
// spacer: { character: 'space' } // mso-spacerun:yes — fragile, see below
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Characters and widths validate against each other: a `tabInterval`
|
|
161
|
+
width only combines with the `tab` character (its counts advance on
|
|
162
|
+
Word's absolute interval grid), and space characters tune via
|
|
163
|
+
`scale`, `absolute`, or `letterSpacing` — the last stays tunable
|
|
164
|
+
inside Word after pasting. Plain spaces are the fragile choice:
|
|
165
|
+
`mso-spacerun:yes` (emitted with `xml:space="preserve"`) does not
|
|
166
|
+
survive every paste path — Word can collapse the runs into a single
|
|
167
|
+
space. Prefer the default no-break spaces or en/em.
|
|
168
|
+
|
|
169
|
+
Marker glyphs travel Word-safely too: the `**` star (U+2217, which no
|
|
170
|
+
Times-family font has a glyph for) is emitted as the Symbol-font `*`
|
|
171
|
+
marker run that Word documents already use — the same shape the paste
|
|
172
|
+
checker recognizes — instead of leaving Word to substitute a different
|
|
173
|
+
font on every line. The star sits on the baseline (Word's own marker
|
|
174
|
+
convention; the preview's slight raise would leave the glyph floating
|
|
175
|
+
above the line) and keeps the app's crimson. A color-mapping option
|
|
176
|
+
for the Word flavor — for documents that standardize on Word's plain
|
|
177
|
+
`red` instead — is a possible future addition.
|
|
178
|
+
|
|
179
|
+
The accounting is self-correcting: each gap's count targets the next
|
|
180
|
+
syllable's absolute anchor (`round((anchor − emitted) ÷ unit)`), so
|
|
181
|
+
quantization never accumulates and every anchor lands within ½ unit of
|
|
182
|
+
its ideal. Tabs use Word's absolute interval grid inherently. What
|
|
183
|
+
remains unmodellable is Word's own font metrics differing from the
|
|
184
|
+
canvas measurements — that is what the width tuning and the paste
|
|
185
|
+
checker's gap census are for. Round-trip with the checker: copy out of
|
|
186
|
+
Word and run the HTML clipboard flavour through it to get positioned
|
|
187
|
+
class/construction errors, the Word style names in use, and the
|
|
188
|
+
effective gap widths:
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
const report = checkWordHtml(pastedHtml)
|
|
192
|
+
report.ok // false when any error-level issue was found
|
|
193
|
+
report.issues // [{ severity, paragraph, offset, message }]
|
|
194
|
+
report.styleNames // e.g. ['BNS-nota', 'BNS-textus Char1']
|
|
195
|
+
report.gapCensus // spacer mechanism + effective width per gap class
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Structured Word layout
|
|
199
|
+
|
|
200
|
+
To assemble Word documents yourself (e.g. with the `docx` library)
|
|
201
|
+
instead of going through the clipboard, `layoutForWord` returns the same
|
|
202
|
+
layout as data — per line pair, the notes paragraph text and the text
|
|
203
|
+
paragraph as pieces: styled runs, dashes, word spaces, and spacer counts
|
|
204
|
+
from the same self-correcting accounting. It takes the same options as
|
|
205
|
+
`toWordHtml`, and `wordLayoutText(layout)` serializes it to exactly
|
|
206
|
+
`toWordText`'s output.
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
import { layoutForWord } from 'guidex/word'
|
|
210
|
+
|
|
211
|
+
const layout = await layoutForWord(script, { textPt: 10, notesPt: 20, maxWidthPt: 306 })
|
|
212
|
+
layout.styleNames // { nota: 'BNS-nota', textus: 'BNS-textus', … }
|
|
213
|
+
layout.spacer // { character, char, unitPt, letterSpacingPt, tabIntervalPt }
|
|
214
|
+
for (const line of layout.lines) {
|
|
215
|
+
line.notes // clef + notes, verbatim Guido HU text
|
|
216
|
+
line.breakMarker // ends with tab + '*' …
|
|
217
|
+
line.breakMarkerTabStopPt // … right-aligned to this stop (pt)
|
|
218
|
+
for (const piece of line.text) {
|
|
219
|
+
// { type: 'spacer', count, endPt } — endPt: absolute position,
|
|
220
|
+
// on the tab grid for tabs
|
|
221
|
+
// { type: 'run', run } — { text, bold, italic, fontFamily?,
|
|
222
|
+
// sizePt?, color?, raisePt?, symbol?, … }
|
|
223
|
+
// { type: 'dash' } | { type: 'space' }
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
A run with `symbol` set (the `**` star) has no glyph in the destination
|
|
229
|
+
fonts: emit `symbol.char` in `symbol.font` (the Symbol asterisk) instead
|
|
230
|
+
of its text. Absent run fields inherit the textus paragraph style.
|
|
231
|
+
|
|
232
|
+
### Image export
|
|
233
|
+
|
|
234
|
+
Take a rendered score out as an image. The export captures the very DOM
|
|
235
|
+
the page painted (a `foreignObject` SVG whose fonts are embedded and
|
|
236
|
+
whose colors are resolved to the currently displayed theme), so the
|
|
237
|
+
picture matches the screen exactly — placement included:
|
|
238
|
+
|
|
239
|
+
```js
|
|
240
|
+
import { scorePngBlob, downloadScorePng, downloadScoreSvg } from 'guidex'
|
|
241
|
+
|
|
242
|
+
// el is the element the score was rendered into — or any ancestor of it
|
|
243
|
+
const blob = await scorePngBlob(el) // 2× PNG, transparent
|
|
244
|
+
await downloadScorePng(el, { filename: 'chant.png' })
|
|
245
|
+
await downloadScoreSvg(el) // self-contained vector, the print-friendlier artifact
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Options: `scale` (raster multiplier against the CSS-pixel layout,
|
|
249
|
+
default 2), `background` (a CSS color painted behind the score —
|
|
250
|
+
default transparent), `padding` (margin around the cropped content, in
|
|
251
|
+
layout px), `filename` for the download helpers — and two ink remaps:
|
|
252
|
+
`foreground` recolors everything that is not the accent, `accent`
|
|
253
|
+
recolors the style set's accent runs (the red initial, rubrics, and
|
|
254
|
+
Liturgy text in BNS; Vesperale has no accent). Both default to the
|
|
255
|
+
displayed colors:
|
|
256
|
+
|
|
257
|
+
```js
|
|
258
|
+
// a print-ready black-and-white copy with a green accent on white
|
|
259
|
+
await downloadScorePng(el, { foreground: 'black', accent: '#008000', background: 'white' })
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The script-tag runtime exposes the same functions on the `GuidexEmbed`
|
|
263
|
+
global.
|
|
264
|
+
|
|
59
265
|
### React / Next.js
|
|
60
266
|
|
|
61
267
|
```jsx
|
|
@@ -128,6 +334,19 @@ its notes:
|
|
|
128
334
|
- Marker characters (`,.:?'"+!%/=()ÖÜÓ;` = `SCORE_MARKERS`) carry no
|
|
129
335
|
pitch; at the edges of a note group they count as whitespace, so a
|
|
130
336
|
junction after a marker-ending group needs only 2 dashes instead of 3.
|
|
337
|
+
- Modifier glyphs (flats, sharps, naturals = `NOTE_MODIFIERS`) carry
|
|
338
|
+
pitch and transpose with the melody, but they modify the note that
|
|
339
|
+
follows: they hang in the junction whitespace, the syllable text is
|
|
340
|
+
positioned under the note characters only, and a group starting with
|
|
341
|
+
a modifier needs only a 2-dash junction.
|
|
342
|
+
- Control statements are groups whose content is an `@`-keyword, set
|
|
343
|
+
between syllables where a syllable's text would stand:
|
|
344
|
+
`(@break)` ends the current line pair at its position — the staff fills
|
|
345
|
+
to the break marker, and the next syllable opens a fresh line with the
|
|
346
|
+
clef repeated. A statement must not carry syllable text (`rály(@break)`
|
|
347
|
+
is a parse error), and unknown `@` keywords are loud parse errors too.
|
|
348
|
+
Max-width auto-breaking still applies within each stretch between
|
|
349
|
+
forced breaks.
|
|
131
350
|
- Style decorations on syllable text: `__…__` renders in the Liturgy
|
|
132
351
|
font, bold; `_…_` renders small caps (BNS) or italic (Vesperale);
|
|
133
352
|
`*…*` marks an initial (bold, red in BNS). A syllable that is exactly
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ControlsRow(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Editor(): import('react').JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Dispatch, RefObject } from 'react';
|
|
2
|
+
import { GuidoScript } from '../guidoScript';
|
|
3
|
+
import { SavedChant } from '../editorStorage';
|
|
4
|
+
import { EditorAction, EditorState, FeedbackSlot, SyllableRow } from './editorState';
|
|
5
|
+
export interface EditorContextValue {
|
|
6
|
+
state: EditorState;
|
|
7
|
+
dispatch: Dispatch<EditorAction>;
|
|
8
|
+
script: GuidoScript;
|
|
9
|
+
syllableRows: SyllableRow[];
|
|
10
|
+
scoreRef: RefObject<HTMLDivElement | null>;
|
|
11
|
+
showFeedback: (slot: FeedbackSlot, message: string, error?: boolean) => void;
|
|
12
|
+
/** Applies one library action's intent over a fresh read of storage
|
|
13
|
+
* and writes the result; failures surface as visible feedback. */
|
|
14
|
+
persistChants: (apply: (fresh: SavedChant[]) => SavedChant[] | null) => boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const EditorContext: import('react').Context<EditorContextValue | null>;
|
|
17
|
+
export declare function useEditor(): EditorContextValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function EditorTextarea(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ExportSettings(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function RenderSettings(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SamplesRow(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SettingsMenu(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SettingsPanel(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SyllablesTable(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function WordCheckPanel(): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function WordCopyControls(): import('react').JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The save form's name suggestion: the chant's first few words. */
|
|
2
|
+
export declare function suggestName(script: string): string;
|
|
3
|
+
/** The row parts the samples row hosts: the chant chips and the two
|
|
4
|
+
* buttons live between the sample chips and the row's feedback spans. */
|
|
5
|
+
export declare function ChantLibraryRowParts(): import('react').JSX.Element;
|
|
6
|
+
/** Inline save form, between the chips row and the textarea. */
|
|
7
|
+
export declare function ChantSaveForm(): import('react').JSX.Element;
|
|
8
|
+
/** The reorderable list view: every chant as a row, rebuilt from state on
|
|
9
|
+
* every change, so the order, the rename input, and the delete confirm
|
|
10
|
+
* never go stale. */
|
|
11
|
+
export declare function ChantList(): import('react').JSX.Element;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { ChantPrefs, EditorSettings, SavedChant } from '../editorStorage';
|
|
2
|
+
import { StyleSetName } from '../guidoStyles';
|
|
3
|
+
import { ScriptTransform } from '../guidoScriptTransforms';
|
|
4
|
+
import { GuidoScript } from '../guidoScript';
|
|
5
|
+
import { SpacerChar } from '../wordExport';
|
|
6
|
+
import { WordInputs } from './wordCopy';
|
|
7
|
+
/** The render settings minus the fields that live elsewhere: `word` has
|
|
8
|
+
* its own raw-string inputs (wordCopy.ts) and `initial` is derived from
|
|
9
|
+
* the live transforms array — the single source of truth for both. */
|
|
10
|
+
export type RenderSettings = Omit<EditorSettings, 'word' | 'initial'>;
|
|
11
|
+
/** Transient feedback slots: one `word-copy-feedback`-style span each,
|
|
12
|
+
* shown for 4 s and cleared by their own timer (FeedbackSpan). */
|
|
13
|
+
export type FeedbackSlot = 'draft' | 'copyScript' | 'downloadImage' | 'wordCopy' | 'chantSaved' | 'chantSaveForm' | 'chantList';
|
|
14
|
+
export interface Feedback {
|
|
15
|
+
message: string;
|
|
16
|
+
error: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const FEEDBACK_MS = 4000;
|
|
19
|
+
export declare const QUOTA_MESSAGE = "Storage full \u2014 delete an old chant";
|
|
20
|
+
export declare const NAME_MAX_LENGTH = 60;
|
|
21
|
+
export interface SyllableRow {
|
|
22
|
+
index: number;
|
|
23
|
+
word: number;
|
|
24
|
+
wordStart: boolean;
|
|
25
|
+
text: string;
|
|
26
|
+
notes: string;
|
|
27
|
+
}
|
|
28
|
+
export interface EditorState {
|
|
29
|
+
/** The textarea's raw script — the draft. */
|
|
30
|
+
script: string;
|
|
31
|
+
/** The chip (sample or saved chant) the editor's content was loaded
|
|
32
|
+
* from; any hand edit clears it. */
|
|
33
|
+
activeChipId: string | null;
|
|
34
|
+
settings: RenderSettings;
|
|
35
|
+
/** The live transform set: rebuilt by style changes, toggled by the
|
|
36
|
+
* initial checkbox, persisted as the derived `initial` boolean. */
|
|
37
|
+
transforms: ScriptTransform[];
|
|
38
|
+
/** Raw typed strings of the base/chant size inputs — the render and
|
|
39
|
+
* persistence use the clamped settings numbers. */
|
|
40
|
+
inputs: {
|
|
41
|
+
basePx: string;
|
|
42
|
+
notesPx: string;
|
|
43
|
+
};
|
|
44
|
+
word: WordInputs;
|
|
45
|
+
chants: SavedChant[];
|
|
46
|
+
listOpen: boolean;
|
|
47
|
+
editingId: string | null;
|
|
48
|
+
confirmingDeleteId: string | null;
|
|
49
|
+
saveFormOpen: boolean;
|
|
50
|
+
saveName: string;
|
|
51
|
+
/** Bumped when the Save chant button is pressed while the form is
|
|
52
|
+
* already open — the form refocuses its name input. */
|
|
53
|
+
focusNameSeq: number;
|
|
54
|
+
feedback: Partial<Record<FeedbackSlot, Feedback>>;
|
|
55
|
+
}
|
|
56
|
+
export type EditorAction = {
|
|
57
|
+
type: 'EDIT_SCRIPT';
|
|
58
|
+
script: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'LOAD_SAMPLE';
|
|
61
|
+
index: number;
|
|
62
|
+
} | {
|
|
63
|
+
type: 'LOAD_CHANT';
|
|
64
|
+
chant: SavedChant;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'SET_STYLE';
|
|
67
|
+
style: StyleSetName;
|
|
68
|
+
} | {
|
|
69
|
+
type: 'SET_BOLD';
|
|
70
|
+
bold: boolean;
|
|
71
|
+
} | {
|
|
72
|
+
type: 'SET_INITIAL';
|
|
73
|
+
initial: boolean;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'SET_MAX_WIDTH';
|
|
76
|
+
px: number;
|
|
77
|
+
} | {
|
|
78
|
+
type: 'SET_TRANSPOSE';
|
|
79
|
+
shift: number;
|
|
80
|
+
} | {
|
|
81
|
+
type: 'SET_BASE_PX';
|
|
82
|
+
raw: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: 'SET_NOTES_PX';
|
|
85
|
+
raw: string;
|
|
86
|
+
} | {
|
|
87
|
+
type: 'COMMIT_NOTES_PX';
|
|
88
|
+
} | {
|
|
89
|
+
type: 'SET_DECOUPLE';
|
|
90
|
+
decouple: boolean;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'SET_CUSTOM_COLORS';
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
seedFg?: string;
|
|
95
|
+
seedAccent?: string;
|
|
96
|
+
} | {
|
|
97
|
+
type: 'SET_COLOR';
|
|
98
|
+
field: 'colorFg' | 'colorAccent' | 'colorBg';
|
|
99
|
+
value: string;
|
|
100
|
+
} | {
|
|
101
|
+
type: 'SET_COLOR_TRANSPARENT';
|
|
102
|
+
value: boolean;
|
|
103
|
+
} | {
|
|
104
|
+
type: 'SET_SPACER_CHAR';
|
|
105
|
+
char: SpacerChar;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'SET_WORD_INPUT';
|
|
108
|
+
field: 'spacerWidth' | 'textPt' | 'widthCm';
|
|
109
|
+
value: string;
|
|
110
|
+
} | {
|
|
111
|
+
type: 'SET_CHANTS';
|
|
112
|
+
chants: SavedChant[];
|
|
113
|
+
} | {
|
|
114
|
+
type: 'SET_LIST_OPEN';
|
|
115
|
+
open: boolean;
|
|
116
|
+
} | {
|
|
117
|
+
type: 'SET_EDITING_ID';
|
|
118
|
+
id: string | null;
|
|
119
|
+
} | {
|
|
120
|
+
type: 'SET_CONFIRM_DELETE';
|
|
121
|
+
id: string | null;
|
|
122
|
+
} | {
|
|
123
|
+
type: 'OPEN_SAVE_FORM';
|
|
124
|
+
suggestion: string;
|
|
125
|
+
} | {
|
|
126
|
+
type: 'FOCUS_SAVE_NAME';
|
|
127
|
+
} | {
|
|
128
|
+
type: 'CLOSE_SAVE_FORM';
|
|
129
|
+
} | {
|
|
130
|
+
type: 'SET_SAVE_NAME';
|
|
131
|
+
name: string;
|
|
132
|
+
} | {
|
|
133
|
+
type: 'SHOW_FEEDBACK';
|
|
134
|
+
slot: FeedbackSlot;
|
|
135
|
+
message: string;
|
|
136
|
+
error?: boolean;
|
|
137
|
+
} | {
|
|
138
|
+
type: 'HIDE_FEEDBACK';
|
|
139
|
+
slot: FeedbackSlot;
|
|
140
|
+
};
|
|
141
|
+
export declare function hasInitialTransform(transforms: ScriptTransform[]): boolean;
|
|
142
|
+
/** Signed label for the transpose slider: `+2`, `0` or `-3`. */
|
|
143
|
+
export declare function transposeLabel(shift: number): string;
|
|
144
|
+
/** Builds the editor script: the draft plus the transforms the
|
|
145
|
+
* checkboxes enable and the transpose slider sets. */
|
|
146
|
+
export declare function buildEditorScript(state: Pick<EditorState, 'script' | 'transforms' | 'settings'>): GuidoScript;
|
|
147
|
+
/** The render settings a saved chant snapshots: style, bold, the initial
|
|
148
|
+
* transform, base/chant sizes with their decouple state, and transpose —
|
|
149
|
+
* exactly what loading the chant re-applies. The max-width slider and
|
|
150
|
+
* the color pickers are not part of a chant. */
|
|
151
|
+
export declare function chantPrefsSnapshot(state: Pick<EditorState, 'settings' | 'transforms'>): ChantPrefs;
|
|
152
|
+
/** The full settings blob for storage: the live render settings plus the
|
|
153
|
+
* derived `initial` flag and the Word-copy slice's effective values. */
|
|
154
|
+
export declare function settingsSnapshot(state: EditorState): EditorSettings;
|
|
155
|
+
/** The editor's initial state, read straight from storage — the restore
|
|
156
|
+
* happens before the first render, so the controls mount already in the
|
|
157
|
+
* restored state (one render, no first-frame flash). */
|
|
158
|
+
export declare function initEditorState(): EditorState;
|
|
159
|
+
export declare function editorReducer(state: EditorState, action: EditorAction): EditorState;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const DEFAULT_SCRIPT = "(MX)Ki(3)r\u00E1ly(3)k\u00E9nt(5) tr\u00F3(7i)nol(7-:) **() az(7i) \u00DAr(5-/) mind(5)\u00F6(4t)r\u00F6k(3)k\u00E9.(3-.)";
|
|
2
|
+
export interface Sample {
|
|
3
|
+
name: string;
|
|
4
|
+
script: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const SAMPLES: Sample[];
|
|
7
|
+
export declare function sampleChipId(index: number): string;
|
|
8
|
+
/** The recap line under the editor: the default script as the parser
|
|
9
|
+
* normalizes it. */
|
|
10
|
+
export declare const sampleSource: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { WordCopySettings } from '../editorStorage';
|
|
2
|
+
import { SpacerChar, SpacerConfig, WordExportOptions } from '../wordExport';
|
|
3
|
+
export interface WordInputs {
|
|
4
|
+
spacerChar: SpacerChar;
|
|
5
|
+
/** Raw typed strings — the effective values clamp on use. */
|
|
6
|
+
spacerWidth: string;
|
|
7
|
+
textPt: string;
|
|
8
|
+
widthCm: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const SPACER_LABELS: {
|
|
11
|
+
value: SpacerChar;
|
|
12
|
+
label: string;
|
|
13
|
+
unit: string;
|
|
14
|
+
width: number;
|
|
15
|
+
}[];
|
|
16
|
+
export declare function spacerMeta(inputs: WordInputs): {
|
|
17
|
+
value: SpacerChar;
|
|
18
|
+
unit: string;
|
|
19
|
+
width: number;
|
|
20
|
+
};
|
|
21
|
+
export declare function effectiveSpacerWidth(inputs: WordInputs): number;
|
|
22
|
+
export declare function effectiveTextPt(inputs: WordInputs): number;
|
|
23
|
+
export declare function effectiveWidthCm(inputs: WordInputs): number;
|
|
24
|
+
export declare function spacerConfig(inputs: WordInputs): SpacerConfig;
|
|
25
|
+
/** The destination-document sizing the copy sends: Word text pt (notes
|
|
26
|
+
* ride at twice it) and the line column in cm → pt. */
|
|
27
|
+
export declare function wordDestination(inputs: WordInputs): Pick<WordExportOptions, 'textPt' | 'notesPt' | 'maxWidthPt'>;
|
|
28
|
+
/** The slice as it is saved: the same effective values the copy uses. */
|
|
29
|
+
export declare function wordSettings(inputs: WordInputs): WordCopySettings;
|
|
30
|
+
export declare function initialWordInputs(word: WordCopySettings): WordInputs;
|