guidex 0.1.1 → 0.2.4
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 +90 -82
- package/dist/lib/core-dx503oih.js +1191 -0
- package/dist/lib/embed/core.d.ts +35 -0
- package/dist/lib/embed/index.d.ts +8 -0
- package/dist/lib/embed/index.js +6 -0
- package/dist/lib/embed/manual.d.ts +6 -0
- package/dist/lib/embed/manual.js +2 -0
- package/dist/lib/fonts/antquab.ttf +0 -0
- package/dist/lib/fonts/antquabi.ttf +0 -0
- package/dist/lib/fonts/antquai.ttf +0 -0
- package/dist/lib/fonts/bkant.ttf +0 -0
- package/dist/lib/fonts/guidohu.ttf +0 -0
- package/dist/lib/fonts/liturgy.ttf +0 -0
- package/dist/lib/guidex.css +122 -0
- package/dist/lib/guidex.css.d.ts +2 -0
- package/dist/lib/guidoRender.d.ts +66 -0
- package/dist/lib/guidoScript.d.ts +38 -0
- package/dist/lib/guidoScriptTransforms.d.ts +41 -0
- package/dist/lib/guidoStyles.d.ts +171 -0
- package/dist/lib/main.d.ts +1 -0
- package/dist/lib/react/GuidexScore.d.ts +19 -0
- package/dist/lib/react/index.d.ts +7 -0
- package/dist/lib/react/index.js +42 -0
- package/dist/lib/settingsMenu.d.ts +1 -0
- package/dist/lib/theme.d.ts +19 -0
- package/dist-embed/guidex-embed.min.js +1 -1
- package/package.json +42 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StyleSetName } from '../guidoStyles';
|
|
2
|
+
export declare const version: string;
|
|
3
|
+
/** Line-breaking budget: a fixed pixel width, or 'auto' to fit the
|
|
4
|
+
* target element (re-rendered on resize). */
|
|
5
|
+
export type MaxWidth = number | 'auto';
|
|
6
|
+
/** Site-wide defaults, settable through `GuidexEmbed.init`. */
|
|
7
|
+
export interface EmbedOptions {
|
|
8
|
+
/** Selector for target elements (default '.guidex-script, .guido-script') */
|
|
9
|
+
selector?: string;
|
|
10
|
+
maxWidth?: MaxWidth;
|
|
11
|
+
style?: StyleSetName;
|
|
12
|
+
bold?: boolean;
|
|
13
|
+
textPx?: number;
|
|
14
|
+
transpose?: number;
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Cleans up a programmatically rendered element: stops resize
|
|
18
|
+
* re-rendering and drops the cached source and option overrides. Does
|
|
19
|
+
* not remove the rendered score itself. */
|
|
20
|
+
export declare function dispose(el: HTMLElement): void;
|
|
21
|
+
/** Renders a GuidoScript source string into one element
|
|
22
|
+
* programmatically — no selector scanning, no site-wide state. The
|
|
23
|
+
* element's own text content is replaced by the rendered score and
|
|
24
|
+
* re-rendered on resize. Call again with a new source to update.
|
|
25
|
+
* Options set here override `init` defaults; data attributes on the
|
|
26
|
+
* element still win. Resolves when the score has finished rendering. */
|
|
27
|
+
export declare function renderScore(el: HTMLElement, source: string, options?: Omit<EmbedOptions, 'selector'>): Promise<void>;
|
|
28
|
+
/** Renders every target under `root` (default: the whole document).
|
|
29
|
+
* Already-rendered targets re-render from their cached source, so a
|
|
30
|
+
* host can change data attributes or the source text and call this to
|
|
31
|
+
* refresh. Resolves when every score has finished rendering. */
|
|
32
|
+
export declare function renderAll(root?: ParentNode): Promise<void>;
|
|
33
|
+
/** Sets site-wide defaults and renders the document. Call again (even
|
|
34
|
+
* with different options) to re-render everything with new settings. */
|
|
35
|
+
export declare function init(options?: EmbedOptions): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-init ESM entry (`guidex/embed`): exports the full embed API and
|
|
3
|
+
* immediately renders the document, like the classic script-tag build —
|
|
4
|
+
* for bundler users who want the drop-in behavior. Framework code that
|
|
5
|
+
* controls its own rendering should import from `guidex` (side-effect
|
|
6
|
+
* free) or `guidex/react` instead.
|
|
7
|
+
*/
|
|
8
|
+
export * from './core';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { a as version, i as renderScore, n as init, r as renderAll, t as dispose } from "../core-dx503oih.js";
|
|
2
|
+
//#region src/embed/index.ts
|
|
3
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => init(), { once: true });
|
|
4
|
+
else init();
|
|
5
|
+
//#endregion
|
|
6
|
+
export { dispose, init, renderAll, renderScore, version };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Embeddable score styles (issue #30): everything a rendered score
|
|
3
|
+
* needs, namespaced under `.guidex-render` so host-page styles can't
|
|
4
|
+
* leak in and embed styles can't leak out. Fonts load from ./fonts/
|
|
5
|
+
* next to this file — ship the fonts folder alongside it.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
@font-face {
|
|
9
|
+
font-family: 'Book Antiqua';
|
|
10
|
+
src: url('./fonts/bkant.ttf') format('truetype');
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
font-style: normal;
|
|
13
|
+
font-display: swap;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@font-face {
|
|
17
|
+
font-family: 'Book Antiqua';
|
|
18
|
+
src: url('./fonts/antquai.ttf') format('truetype');
|
|
19
|
+
font-weight: 400;
|
|
20
|
+
font-style: italic;
|
|
21
|
+
font-display: swap;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@font-face {
|
|
25
|
+
font-family: 'Book Antiqua';
|
|
26
|
+
src: url('./fonts/antquab.ttf') format('truetype');
|
|
27
|
+
font-weight: 700;
|
|
28
|
+
font-style: normal;
|
|
29
|
+
font-display: swap;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@font-face {
|
|
33
|
+
font-family: 'Book Antiqua';
|
|
34
|
+
src: url('./fonts/antquabi.ttf') format('truetype');
|
|
35
|
+
font-weight: 700;
|
|
36
|
+
font-style: italic;
|
|
37
|
+
font-display: swap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Plainchant notation font (glyphs, not letters) */
|
|
41
|
+
@font-face {
|
|
42
|
+
font-family: 'Guidohu';
|
|
43
|
+
src: url('./fonts/guidohu.ttf') format('truetype');
|
|
44
|
+
font-display: swap;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Liturgical display font, used bold-only by the _…_ syllable decoration;
|
|
48
|
+
declared 700 so the renderer's font check sees a real bold face */
|
|
49
|
+
@font-face {
|
|
50
|
+
font-family: 'Liturgy';
|
|
51
|
+
src: url('./fonts/liturgy.ttf') format('truetype');
|
|
52
|
+
font-weight: 400;
|
|
53
|
+
font-display: swap;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.guidex-render {
|
|
57
|
+
/* The palette the style sets reference (var(--red) etc.); follows the
|
|
58
|
+
reader's system preference — the app's class-driven dark mode is an
|
|
59
|
+
editor feature that third-party pages don't have */
|
|
60
|
+
--red: #d40000;
|
|
61
|
+
--text: #2b2b2b;
|
|
62
|
+
--text-h: #1a1a1a;
|
|
63
|
+
|
|
64
|
+
color: var(--text);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@media (prefers-color-scheme: dark) {
|
|
68
|
+
.guidex-render {
|
|
69
|
+
--red: #ff4d4d;
|
|
70
|
+
--text: #d4cdc7;
|
|
71
|
+
--text-h: #f5f0ea;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Score line: notation font at 200% of the surrounding text size,
|
|
76
|
+
120% leading (matching the original Word layout: 20pt on 24pt).
|
|
77
|
+
Word carried the 6pt space before/after on this paragraph: 6pt
|
|
78
|
+
against the 20pt font is 0.3em, so it scales with the score. */
|
|
79
|
+
.guidex-render .guido {
|
|
80
|
+
font-family: 'Guidohu', 'Book Antiqua', 'Palatino Linotype', Palatino, Georgia, serif;
|
|
81
|
+
font-size: 200%;
|
|
82
|
+
line-height: 120%;
|
|
83
|
+
color: var(--text-h);
|
|
84
|
+
padding-block: 0.3em;
|
|
85
|
+
position: relative;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* The score's text line: margins reset (host pages style p freely) and
|
|
89
|
+
natural leading, like the app's .score p */
|
|
90
|
+
.guidex-render p {
|
|
91
|
+
margin: 0;
|
|
92
|
+
line-height: normal;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Host pages often drop-cap paragraphs (::first-letter rules like the
|
|
96
|
+
app's own); the score's text must never pick them up */
|
|
97
|
+
.guidex-render p::first-letter {
|
|
98
|
+
color: inherit;
|
|
99
|
+
font-weight: inherit;
|
|
100
|
+
float: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Syllable spans are positioning contexts for the renderer's inline
|
|
104
|
+
raise/relative offsets */
|
|
105
|
+
.guidex-render .syl {
|
|
106
|
+
position: relative;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* The line-break star: an inline span shifted by the renderer, sharing
|
|
110
|
+
the notes baseline */
|
|
111
|
+
.guidex-render .guido-break {
|
|
112
|
+
position: relative;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* A failed render (unknown style, unloadable font) leaves a note in
|
|
116
|
+
the score container */
|
|
117
|
+
.guidex-render .guidex-error {
|
|
118
|
+
margin: 0;
|
|
119
|
+
color: var(--red);
|
|
120
|
+
font: 14px/1.4 'Book Antiqua', 'Palatino Linotype', Palatino, Georgia, serif;
|
|
121
|
+
}
|
|
122
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { GuidoScript } from './guidoScript';
|
|
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";
|
|
17
|
+
/** Options for one render. All fields optional; defaults reproduce the
|
|
18
|
+
* original Book Antiqua look (style set BNS). */
|
|
19
|
+
export interface RenderOptions {
|
|
20
|
+
/** Named style set from STYLE_SETS (default: BNS) */
|
|
21
|
+
style?: StyleSetName;
|
|
22
|
+
/** Render all text bold, measurements included */
|
|
23
|
+
bold?: boolean;
|
|
24
|
+
/** Text line size in px (default 18) */
|
|
25
|
+
textPx?: number;
|
|
26
|
+
/** Notes line size in px (default textPx * 2) */
|
|
27
|
+
notesPx?: number;
|
|
28
|
+
/** Debug titles on the rendered spans */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
/** Maximum notes-line width before a staff break (default: none) */
|
|
31
|
+
maxWidthPx?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 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.
|
|
40
|
+
*
|
|
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.
|
|
44
|
+
*/
|
|
45
|
+
export declare class GuidoRender {
|
|
46
|
+
private readonly script;
|
|
47
|
+
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
|
+
/**
|
|
54
|
+
* Renders the score into `container` as (notes line, text line) pairs.
|
|
55
|
+
* When `maxWidthPx` is finite, a new pair starts before any syllable
|
|
56
|
+
* whose notes would push the current notes line past it; the clef is
|
|
57
|
+
* repeated at the start of every line. Throws when the style set is
|
|
58
|
+
* unknown or one of its fonts cannot be loaded.
|
|
59
|
+
*/
|
|
60
|
+
render(container: HTMLElement, options?: RenderOptions): Promise<void>;
|
|
61
|
+
/** 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. */
|
|
64
|
+
private static sylSpan;
|
|
65
|
+
private static spacer;
|
|
66
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ScriptTransform } from './guidoScriptTransforms';
|
|
2
|
+
export declare class GuidoScript {
|
|
3
|
+
readonly source: string;
|
|
4
|
+
constructor(source: string, options?: {
|
|
5
|
+
transforms?: ScriptTransform[];
|
|
6
|
+
});
|
|
7
|
+
/** The starting clef and note modifiers, or undefined when absent. */
|
|
8
|
+
get clef(): string | undefined;
|
|
9
|
+
/** The script broken into syllables, each with its sung text and notes. */
|
|
10
|
+
get syllables(): {
|
|
11
|
+
text: string;
|
|
12
|
+
notes: string;
|
|
13
|
+
wordEnd: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
/**
|
|
16
|
+
* The source with the typing conveniences folded in, so the parser
|
|
17
|
+
* itself only ever sees complete scripts:
|
|
18
|
+
*
|
|
19
|
+
* - an unclosed parenthesis is closed at the end, so the notes typed
|
|
20
|
+
* so far already preview on the score;
|
|
21
|
+
* - a trailing syllable with no note group gets an empty one, so it
|
|
22
|
+
* renders like a `*()` syllable (text without notes width).
|
|
23
|
+
*/
|
|
24
|
+
private get normalized();
|
|
25
|
+
/** The syllables grouped into the words of the text. */
|
|
26
|
+
get words(): {
|
|
27
|
+
text: string;
|
|
28
|
+
syllables: {
|
|
29
|
+
text: string;
|
|
30
|
+
notes: string;
|
|
31
|
+
}[];
|
|
32
|
+
}[];
|
|
33
|
+
/** The script rebuilt from the parsed pieces — a round-trip of the source. */
|
|
34
|
+
toString(): string;
|
|
35
|
+
}
|
|
36
|
+
/** Folds backslash escapes into the characters they stand for. Shared
|
|
37
|
+
* with the transforms module (guidoScriptTransforms.ts). */
|
|
38
|
+
export declare function unescape(text: string): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** A named source-to-source rewrite applied to a script before parsing. */
|
|
2
|
+
export interface ScriptTransform {
|
|
3
|
+
name: string;
|
|
4
|
+
apply: (source: string) => string;
|
|
5
|
+
}
|
|
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. */
|
|
10
|
+
declare function startWithInitial(source: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* The built-in transformations, keyed by name; pass the ones a feature
|
|
13
|
+
* needs to the GuidoScript constructor.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SCRIPT_TRANSFORMS: {
|
|
16
|
+
/** Wraps the first letter of the first syllable that has notes in
|
|
17
|
+
* `*…*`, the initial marker of the style marking system. */
|
|
18
|
+
startWithInitial: {
|
|
19
|
+
name: string;
|
|
20
|
+
apply: typeof startWithInitial;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** The pitch rows of the chant font: every character carrying pitch
|
|
24
|
+
* information, grouped into rows of neighbouring pitches from low to
|
|
25
|
+
* high. A transpose shift moves a character this many positions along
|
|
26
|
+
* its row; characters outside every row carry no pitch and stay put.
|
|
27
|
+
* Rows are searched in order, so a character found in several rows
|
|
28
|
+
* transposes within the first one. */
|
|
29
|
+
export declare const PITCH_ROWS: readonly ["ðñ0123456789öüó", "^]qwertzuiopõú", "ÝÞQWERTZUIOPÕÚ", "×sdfghjkléáû", "ØÙDFGHJKLÉÁÛ", "÷øaASÍYXCVBN$m", "ÈÊËÌÎÏÐÑÒþ¬ßòôùý", "“”•–—˜™š›œº»", "®−§ÿ\"+!%/=()ÖÜÓ", "Ÿ¡¢£[¥¦©ª«¬", "~¯‚ƒ„…†‡ˆ‰Š‹Œ‘’", "àâãäåæçèêëìîï", "½°±²³´μ·¾¸¹"];
|
|
30
|
+
/** What happens when a shift runs past the end of a pitch row:
|
|
31
|
+
* `clamp` keeps the first/last available character, `null` emits
|
|
32
|
+
* `U+0000`, which shows up as a missing glyph in the score. */
|
|
33
|
+
export type TransposeOverflow = 'clamp' | 'null';
|
|
34
|
+
/** The `transposeBy` transform factory: shifts every pitch character of
|
|
35
|
+
* every notes group `shift` positions along its pitch row. The clef
|
|
36
|
+
* group and the syllable text are left alone — clef handling is a
|
|
37
|
+
* separate, future tool. */
|
|
38
|
+
export declare function transposeBy(shift: number, options?: {
|
|
39
|
+
overflow?: TransposeOverflow;
|
|
40
|
+
}): ScriptTransform;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style sets for the renderer: named appearance rules (fonts, colors, and
|
|
3
|
+
* the special syllable decorations) kept in one constant registry, so a
|
|
4
|
+
* new style is a data entry here rather than a renderer fork.
|
|
5
|
+
*/
|
|
6
|
+
/** How one run of syllable text is drawn. Unset fields inherit from the
|
|
7
|
+
* surrounding text line: the style set's text font stack, its base weight,
|
|
8
|
+
* and the theme's text color. */
|
|
9
|
+
export interface PartStyle {
|
|
10
|
+
/** Overrides the style's text font stack for this run */
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
weight?: '400' | '700';
|
|
13
|
+
italic?: boolean;
|
|
14
|
+
/** Font-size multiplier against the text size (0.8 = 80% smaller) */
|
|
15
|
+
scale?: number;
|
|
16
|
+
/** Font-size multiplier used only when measuring: lets a run render
|
|
17
|
+
* at its full size while its width is counted at a smaller one */
|
|
18
|
+
measureScale?: number;
|
|
19
|
+
/** Raised above the baseline by this fraction of the text size; does
|
|
20
|
+
* not affect width measurement (position: relative, out of flow) */
|
|
21
|
+
raise?: number;
|
|
22
|
+
/** The run's text is uppercased before measuring and rendering: the
|
|
23
|
+
* small-caps look is faked as uniformly scaled capitals, which canvas
|
|
24
|
+
* measures exactly like the DOM lays out (font-variant: small-caps
|
|
25
|
+
* does not — the browser's canvas synthesis measures wider than the
|
|
26
|
+
* real smcp glyphs it uses for DOM layout) */
|
|
27
|
+
uppercase?: boolean;
|
|
28
|
+
/** Inline color; absent means inherit (keeps dark mode working) */
|
|
29
|
+
color?: string;
|
|
30
|
+
/** The run carries the initial class in the DOM (the `*…*` marker) */
|
|
31
|
+
initial?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** A named appearance for a whole score. */
|
|
34
|
+
export interface StyleSet {
|
|
35
|
+
/** Text line font stack (the notes always render in the chant font) */
|
|
36
|
+
textFontStack: string;
|
|
37
|
+
/** Notes line font stack */
|
|
38
|
+
notesFontStack: string;
|
|
39
|
+
/** Text characters drawn in a dedicated font (e.g. * and † glyphs) */
|
|
40
|
+
markerGlyphs?: {
|
|
41
|
+
chars: Set<string>;
|
|
42
|
+
fontFamily: string;
|
|
43
|
+
};
|
|
44
|
+
/** Fonts verified before measuring; render() throws when one of them
|
|
45
|
+
* cannot be loaded. System fonts pass the check vacuously (they have
|
|
46
|
+
* no FontFaceSet entries), so only @font-face'd webfonts belong here. */
|
|
47
|
+
verifiedFonts: {
|
|
48
|
+
family: string;
|
|
49
|
+
weight: '400' | '700';
|
|
50
|
+
}[];
|
|
51
|
+
/** Special syllable renderings keyed by their wrapper character:
|
|
52
|
+
* `__…__` the Liturgy font, `_…_` rubrics, `*…*` the initial (which
|
|
53
|
+
* may also wrap any part of a syllable) */
|
|
54
|
+
decorations: Record<string, PartStyle>;
|
|
55
|
+
/** The whole-syllable `**` star: rendered as ∗ at the base size,
|
|
56
|
+
* raised like the `+`; measured at 95% because no font in the stacks
|
|
57
|
+
* has U+2217 and the fallback glyph's advance is wider than the Times
|
|
58
|
+
* `*` (0.523 em vs 0.5 em) — the smaller measure size keeps the star's
|
|
59
|
+
* footprint at the plain star's. */
|
|
60
|
+
specialStarStyle: PartStyle;
|
|
61
|
+
/** Line-end padding in px: the break marker `*` lands this far past
|
|
62
|
+
* the max-width position. Defaults to 0 (the star sits on the edge). */
|
|
63
|
+
padding?: number;
|
|
64
|
+
}
|
|
65
|
+
export declare const STYLE_SETS: {
|
|
66
|
+
/** Book Antiqua text with red accents. */
|
|
67
|
+
BNS: {
|
|
68
|
+
textFontStack: string;
|
|
69
|
+
notesFontStack: string;
|
|
70
|
+
markerGlyphs: {
|
|
71
|
+
chars: Set<string>;
|
|
72
|
+
fontFamily: string;
|
|
73
|
+
};
|
|
74
|
+
verifiedFonts: ({
|
|
75
|
+
family: string;
|
|
76
|
+
weight: "400";
|
|
77
|
+
} | {
|
|
78
|
+
family: string;
|
|
79
|
+
weight: "700";
|
|
80
|
+
})[];
|
|
81
|
+
decorations: {
|
|
82
|
+
__: {
|
|
83
|
+
fontFamily: string;
|
|
84
|
+
weight: "700";
|
|
85
|
+
color: string;
|
|
86
|
+
};
|
|
87
|
+
_: {
|
|
88
|
+
uppercase: true;
|
|
89
|
+
scale: number;
|
|
90
|
+
color: string;
|
|
91
|
+
};
|
|
92
|
+
'*': {
|
|
93
|
+
weight: "700";
|
|
94
|
+
color: string;
|
|
95
|
+
initial: true;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
specialStarStyle: {
|
|
99
|
+
fontFamily: string;
|
|
100
|
+
weight: "700";
|
|
101
|
+
scale: number;
|
|
102
|
+
measureScale: number;
|
|
103
|
+
raise: number;
|
|
104
|
+
color: string;
|
|
105
|
+
};
|
|
106
|
+
padding: number;
|
|
107
|
+
};
|
|
108
|
+
/** Times New Roman text, strictly black and white. */
|
|
109
|
+
Vesperale: {
|
|
110
|
+
textFontStack: string;
|
|
111
|
+
notesFontStack: string;
|
|
112
|
+
verifiedFonts: ({
|
|
113
|
+
family: string;
|
|
114
|
+
weight: "400";
|
|
115
|
+
} | {
|
|
116
|
+
family: string;
|
|
117
|
+
weight: "700";
|
|
118
|
+
})[];
|
|
119
|
+
decorations: {
|
|
120
|
+
__: {
|
|
121
|
+
fontFamily: string;
|
|
122
|
+
weight: "700";
|
|
123
|
+
};
|
|
124
|
+
_: {
|
|
125
|
+
scale: number;
|
|
126
|
+
italic: true;
|
|
127
|
+
};
|
|
128
|
+
'*': {
|
|
129
|
+
weight: "700";
|
|
130
|
+
initial: true;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
specialStarStyle: {
|
|
134
|
+
fontFamily: string;
|
|
135
|
+
weight: "700";
|
|
136
|
+
scale: number;
|
|
137
|
+
measureScale: number;
|
|
138
|
+
raise: number;
|
|
139
|
+
};
|
|
140
|
+
padding: number;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
export type StyleSetName = keyof typeof STYLE_SETS;
|
|
144
|
+
export declare const DEFAULT_STYLE_SET: StyleSetName;
|
|
145
|
+
/** One resolved run of syllable text: its (already transformed) string and
|
|
146
|
+
* how to draw it. */
|
|
147
|
+
export interface SyllablePart {
|
|
148
|
+
text: string;
|
|
149
|
+
style: PartStyle;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolves a syllable's raw text into the runs it renders as: the whole-
|
|
153
|
+
* syllable `**` star renders as the bold ∗ operator, a `__…__` or `_…_`
|
|
154
|
+
* wrapper (the same characters on both ends, content between) picks up
|
|
155
|
+
* its decoration rule from the style set, and paired `*` markers wrap any
|
|
156
|
+
* part of the syllable — even the whole of it — with the initial rule
|
|
157
|
+
* (`*sam*ple` → "sam" in the initial style, "ple" normal; an unmatched
|
|
158
|
+
* `*` renders literally), the `bold` option forces weight 700 onto every
|
|
159
|
+
* run, and marker-glyph characters split off into runs of their own font.
|
|
160
|
+
* Inside a Liturgy-font run, `+` gets its own weight-400 runs — the font
|
|
161
|
+
* is bold-looking by design, so the weight stays normal. The wrapper
|
|
162
|
+
* characters themselves are dropped.
|
|
163
|
+
*/
|
|
164
|
+
export declare function resolveSyllableParts(text: string, styleSet: StyleSet, bold: boolean): SyllablePart[];
|
|
165
|
+
/** The canvas font shorthand for measuring a run at the text size. */
|
|
166
|
+
export declare function measurementFont(style: PartStyle, textPx: number, fallbackStack: string): string;
|
|
167
|
+
/** The inline CSS properties that draw a run, as dash-cased names for
|
|
168
|
+
* CSSStyleDeclaration.setProperty. */
|
|
169
|
+
export declare function inlineStylesFor(style: PartStyle, textPx: number): Record<string, string>;
|
|
170
|
+
/** The font strings render() must load and verify for a style set. */
|
|
171
|
+
export declare function fontStringsToVerify(styleSet: StyleSet, textPx: number): string[];
|
|
@@ -0,0 +1 @@
|
|
|
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-.)";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MaxWidth } from '../embed/core';
|
|
2
|
+
import { StyleSetName } from '../guidoStyles';
|
|
3
|
+
export interface GuidexScoreProps {
|
|
4
|
+
/** The score source in GuidoScript notation, e.g. `'(c4) fat(2)ue(2)'`. */
|
|
5
|
+
script: string;
|
|
6
|
+
/** Line-breaking budget in px, or 'auto' to fit the container (default). */
|
|
7
|
+
maxWidth?: MaxWidth;
|
|
8
|
+
/** Named style set (see `guidex` style sets). */
|
|
9
|
+
style?: StyleSetName;
|
|
10
|
+
bold?: boolean;
|
|
11
|
+
/** Text size in px (default 18). */
|
|
12
|
+
textPx?: number;
|
|
13
|
+
/** Transpose the score by N diatonic steps. */
|
|
14
|
+
transpose?: number;
|
|
15
|
+
/** Render measurement debug markers. */
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function GuidexScore({ script, maxWidth, style, bold, textPx, transpose, debug, className, }: GuidexScoreProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React entry (`guidex/react`): the `GuidexScore` client component plus
|
|
3
|
+
* a re-export of the imperative embed API for advanced use.
|
|
4
|
+
*/
|
|
5
|
+
export { GuidexScore, type GuidexScoreProps } from './GuidexScore';
|
|
6
|
+
export { renderScore, renderAll, init, dispose, version, type EmbedOptions, type MaxWidth } from '../embed/core';
|
|
7
|
+
export type { StyleSetName } from '../guidoStyles';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as version, i as renderScore, n as init, r as renderAll, t as dispose } from "../core-dx503oih.js";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/react/GuidexScore.tsx
|
|
6
|
+
/**
|
|
7
|
+
* React client component wrapping the embed runtime's `renderScore`
|
|
8
|
+
* (`guidex/react`). Renders a GuidoScript source string into a div and
|
|
9
|
+
* re-renders on resize, like every other embed target. The `'use
|
|
10
|
+
* client'` directive marks it for React Server Components (Next.js App
|
|
11
|
+
* Router); in plain client-side React it is a no-op.
|
|
12
|
+
*/
|
|
13
|
+
function GuidexScore({ script, maxWidth, style, bold, textPx, transpose, debug, className }) {
|
|
14
|
+
const ref = useRef(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const el = ref.current;
|
|
17
|
+
if (!el) return;
|
|
18
|
+
renderScore(el, script, {
|
|
19
|
+
maxWidth,
|
|
20
|
+
style,
|
|
21
|
+
bold,
|
|
22
|
+
textPx,
|
|
23
|
+
transpose,
|
|
24
|
+
debug
|
|
25
|
+
});
|
|
26
|
+
return () => dispose(el);
|
|
27
|
+
}, [
|
|
28
|
+
script,
|
|
29
|
+
maxWidth,
|
|
30
|
+
style,
|
|
31
|
+
bold,
|
|
32
|
+
textPx,
|
|
33
|
+
transpose,
|
|
34
|
+
debug
|
|
35
|
+
]);
|
|
36
|
+
return /* @__PURE__ */ jsx("div", {
|
|
37
|
+
ref,
|
|
38
|
+
className
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { GuidexScore, dispose, init, renderAll, renderScore, version };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createSettingsMenu(): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-set dark mode (issue #16): the theme choice lives in a cookie and is
|
|
3
|
+
* applied as a class on <html> that style.css reacts to.
|
|
4
|
+
*
|
|
5
|
+
* The same resolve logic is duplicated as a tiny inline script in
|
|
6
|
+
* index.html's <head> — it must run before the CSS body renders to avoid a
|
|
7
|
+
* theme flash, long before this module loads.
|
|
8
|
+
*/
|
|
9
|
+
export declare const THEME_COOKIE = "theme";
|
|
10
|
+
export type Theme = 'light' | 'dark';
|
|
11
|
+
export declare function readThemeCookie(cookie: string): Theme | null;
|
|
12
|
+
export declare function writeThemeCookie(theme: Theme): void;
|
|
13
|
+
/** Applies a theme as the `dark`/`light` class on <html>. */
|
|
14
|
+
export declare function applyTheme(theme: Theme): void;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the effective theme: the cookie wins; with no cookie the system
|
|
17
|
+
* preference decides (and nothing is persisted).
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveTheme(cookie: string, systemDark: boolean): Theme;
|