@hozo/typography 0.3.0 → 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.
Files changed (53) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -1
  3. package/dist/code/meta.d.ts +14 -0
  4. package/dist/code/meta.d.ts.map +1 -0
  5. package/dist/code/meta.js +62 -0
  6. package/dist/code/meta.js.map +1 -0
  7. package/dist/code/model.d.ts +66 -0
  8. package/dist/code/model.d.ts.map +1 -0
  9. package/dist/code/model.js +139 -0
  10. package/dist/code/model.js.map +1 -0
  11. package/dist/code/reuse.d.ts +22 -0
  12. package/dist/code/reuse.d.ts.map +1 -0
  13. package/dist/code/reuse.js +54 -0
  14. package/dist/code/reuse.js.map +1 -0
  15. package/dist/code/shiki.d.ts +12 -0
  16. package/dist/code/shiki.d.ts.map +1 -0
  17. package/dist/code/shiki.js +28 -0
  18. package/dist/code/shiki.js.map +1 -0
  19. package/dist/code-lines.d.ts +34 -0
  20. package/dist/code-lines.d.ts.map +1 -0
  21. package/dist/code-lines.js +192 -0
  22. package/dist/code-lines.js.map +1 -0
  23. package/dist/code-lines.native.d.ts +54 -0
  24. package/dist/code-lines.native.d.ts.map +1 -0
  25. package/dist/code-lines.native.js +114 -0
  26. package/dist/code-lines.native.js.map +1 -0
  27. package/dist/index.d.ts +3 -41
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -69
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.native.d.ts +3 -82
  32. package/dist/index.native.d.ts.map +1 -1
  33. package/dist/index.native.js +3 -140
  34. package/dist/index.native.js.map +1 -1
  35. package/dist/text.d.ts +43 -0
  36. package/dist/text.d.ts.map +1 -0
  37. package/dist/text.js +75 -0
  38. package/dist/text.js.map +1 -0
  39. package/dist/text.native.d.ts +84 -0
  40. package/dist/text.native.d.ts.map +1 -0
  41. package/dist/text.native.js +144 -0
  42. package/dist/text.native.js.map +1 -0
  43. package/package.json +30 -4
  44. package/src/code/meta.ts +69 -0
  45. package/src/code/model.ts +189 -0
  46. package/src/code/reuse.ts +70 -0
  47. package/src/code/shiki.ts +38 -0
  48. package/src/code-lines.native.tsx +191 -0
  49. package/src/code-lines.tsx +310 -0
  50. package/src/index.native.tsx +4 -245
  51. package/src/index.tsx +4 -164
  52. package/src/text.native.tsx +250 -0
  53. package/src/text.tsx +179 -0
@@ -0,0 +1,192 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // biome-ignore-all lint/suspicious/noArrayIndexKey: code lines and tokens use source-position identity
3
+ import { useHozoMessage } from '@hozo/behaviors';
4
+ import { initialRange, ListMetrics, windowRange, } from '@hozo/primitives/windowing';
5
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from 'react';
6
+ import { widestCodeLine } from './code/model.js';
7
+ import { codeKey, useCodeRows, useNormalizedCodeLines } from './code/reuse.js';
8
+ export { codeKey, useNormalizedCodeLines };
9
+ const hidden = {
10
+ position: 'absolute',
11
+ width: 1,
12
+ height: 1,
13
+ padding: 0,
14
+ margin: -1,
15
+ overflow: 'hidden',
16
+ clipPath: 'inset(50%)',
17
+ whiteSpace: 'nowrap',
18
+ userSelect: 'none',
19
+ };
20
+ // The whole text of a windowed block, for a screen reader: its own reading
21
+ // moves through the document without scrolling the block, so it would stop
22
+ // at the last mounted line (#1408). One plain row per line costs a fraction
23
+ // of the token rows it stands in for. Line breaks are kept, not collapsed,
24
+ // and select-all and copy stay with the visible rows. Not
25
+ // `content-visibility: auto`, which would be cheaper still: Chrome then
26
+ // leaves the text out of the accessibility tree.
27
+ const readable = { ...hidden, whiteSpace: 'pre' };
28
+ const tokenCss = '.hozo-code-token{color:var(--hozo-code-light,inherit)}@media(prefers-color-scheme:dark){.hozo-code-token{color:var(--hozo-code-dark,var(--hozo-code-light,inherit))}}';
29
+ function tokenStyle(token, theme) {
30
+ const colors = typeof token.color === 'object' ? token.color : undefined;
31
+ return {
32
+ color: typeof token.color === 'string'
33
+ ? token.color
34
+ : theme
35
+ ? (colors?.[theme] ?? colors?.light)
36
+ : undefined,
37
+ ...(colors && !theme
38
+ ? { '--hozo-code-light': colors.light, '--hozo-code-dark': colors.dark }
39
+ : {}),
40
+ fontStyle: token.italic ? 'italic' : undefined,
41
+ fontWeight: token.bold ? 'bold' : undefined,
42
+ textDecoration: token.underline ? 'underline' : undefined,
43
+ };
44
+ }
45
+ // What a line is taken to be before one has been measured, and how many go
46
+ // in the first paint: a viewport's worth at ordinary sizes, so the server's
47
+ // HTML shows the top of the block rather than a gap.
48
+ const ESTIMATED_LINE = 20;
49
+ const INITIAL_LINES = 40;
50
+ // Two viewports either side, as on Native (#1382), and enough new lines per
51
+ // pass that 20px lines fill a viewport in a commit or two.
52
+ const WINDOW_SIZE = 5;
53
+ const LINES_PER_BATCH = 50;
54
+ // The server has nothing to measure, and `useLayoutEffect` warns there.
55
+ const useBrowserLayoutEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;
56
+ /**
57
+ * Which lines to mount, from where `scroller` is scrolled to.
58
+ *
59
+ * The arithmetic is the Web `FlatList`'s, but the lines stay one `<pre>` in
60
+ * the scroller `CodeBlock` already has rather than becoming rows of a list:
61
+ * what is mounted is still code to a screen reader, and the region still
62
+ * scrolls sideways. Lines are measured after every commit and whenever the
63
+ * scroller resizes, which is when a wrapped line can change height.
64
+ */
65
+ function useLineWindow(count, scroller) {
66
+ const code = useRef(null);
67
+ const metricsRef = useRef(undefined);
68
+ if (metricsRef.current === undefined)
69
+ metricsRef.current = new ListMetrics(ESTIMATED_LINE);
70
+ const metrics = metricsRef.current;
71
+ metrics.setKeys(Array.from({ length: count }, (_, index) => String(index)));
72
+ const all = { first: 0, last: count - 1 };
73
+ const [range, setRange] = useState(() => (scroller ? initialRange(count, INITIAL_LINES) : all));
74
+ const rangeRef = useRef(range);
75
+ rangeRef.current = range;
76
+ const update = useCallback(() => {
77
+ const root = scroller?.current;
78
+ const list = code.current;
79
+ if (!root || !list || root.clientHeight === 0)
80
+ return;
81
+ for (const line of list.querySelectorAll(':scope > [data-code-line]'))
82
+ metrics.measure(line.dataset.codeLine ?? '', line.getBoundingClientRect().height);
83
+ // Where line 0 starts in the scroller's content; padding above the lines
84
+ // moves it.
85
+ const origin = list.getBoundingClientRect().top - root.getBoundingClientRect().top + root.scrollTop;
86
+ const next = windowRange({
87
+ count,
88
+ offset: root.scrollTop - origin,
89
+ visibleLength: root.clientHeight,
90
+ windowSize: WINDOW_SIZE,
91
+ maxToRenderPerBatch: LINES_PER_BATCH,
92
+ previous: rangeRef.current,
93
+ metrics,
94
+ });
95
+ if (next.first === rangeRef.current.first && next.last === rangeRef.current.last)
96
+ return;
97
+ rangeRef.current = next;
98
+ setRange(next);
99
+ }, [count, scroller, metrics]);
100
+ // A mounted line is a measurable one, and measuring usually moves the
101
+ // window, so this runs after every commit rather than only on scroll.
102
+ useBrowserLayoutEffect(() => {
103
+ update();
104
+ });
105
+ useEffect(() => {
106
+ const root = scroller?.current;
107
+ if (!root)
108
+ return;
109
+ root.addEventListener('scroll', update, { passive: true });
110
+ const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);
111
+ observer?.observe(root);
112
+ return () => {
113
+ root.removeEventListener('scroll', update);
114
+ observer?.disconnect();
115
+ };
116
+ }, [scroller, update]);
117
+ if (!scroller)
118
+ return { code, range: all, leading: 0, trailing: 0 };
119
+ // Fewer lines than before can leave the window past the end until the
120
+ // next update; draw what exists.
121
+ const first = Math.max(0, Math.min(range.first, count - 1));
122
+ const last = Math.min(range.last, count - 1);
123
+ return {
124
+ code,
125
+ range: { first, last },
126
+ leading: count ? metrics.offsetAt(first) : 0,
127
+ trailing: count ? Math.max(0, metrics.offsetAt(count) - metrics.offsetAt(last + 1)) : 0,
128
+ };
129
+ }
130
+ export function CodeLines(props) {
131
+ const message = useHozoMessage();
132
+ const lines = useNormalizedCodeLines(props.lines, props.tabSize);
133
+ const labels = {
134
+ ins: message('hozo.code.added'),
135
+ del: message('hozo.code.removed'),
136
+ mark: message('hozo.code.highlighted'),
137
+ };
138
+ const shown = useLineWindow(lines.length, props.scroller);
139
+ const renderLine = useCodeRows(lines, props.renderGutter && props.gutterKey === undefined
140
+ ? undefined
141
+ : codeKey([
142
+ props.theme,
143
+ props.wrap,
144
+ labels,
145
+ props.gutterKey,
146
+ props.lineClassName,
147
+ props.insClassName,
148
+ props.delClassName,
149
+ props.markClassName,
150
+ props.lineStyle,
151
+ props.insStyle,
152
+ props.delStyle,
153
+ props.markStyle,
154
+ ]), drawLine);
155
+ const renderReadable = useCodeRows(lines, codeKey(labels), drawReadable);
156
+ function drawReadable(line, index) {
157
+ // A line feed between lines, not block rows: inside the one-pixel box
158
+ // NVDA read block rows as one run, "entry 1entry 2", wrapped at its own
159
+ // line length (#1408). Before the line rather than after it, so a line's
160
+ // row stays the same when lines are appended.
161
+ return (_jsxs("span", { children: [index > 0 ? '\n' : null, line.mark ? `${labels[line.mark]}: ` : null, line.tokens.map((token) => token.text).join('')] }, index));
162
+ }
163
+ function drawLine(line, index) {
164
+ const Tag = line.mark ?? 'span';
165
+ const className = [props.lineClassName, line.mark ? props[`${line.mark}ClassName`] : undefined]
166
+ .filter(Boolean)
167
+ .join(' ') || undefined;
168
+ return (_jsxs("span", { "data-code-line": index, style: { display: 'flex', minWidth: '100%' }, children: [props.renderGutter?.(line, index), _jsxs(Tag, { className: className, "data-code-mark": line.mark, style: {
169
+ display: 'block',
170
+ flex: props.wrap ? '1 1 0' : '1 0 auto',
171
+ minWidth: 0,
172
+ minHeight: '1lh',
173
+ ...props.lineStyle,
174
+ ...(line.mark ? props[`${line.mark}Style`] : undefined),
175
+ }, children: [line.mark ? _jsx("span", { style: hidden, children: `${labels[line.mark]}: ` }) : null, line.tokens.map((token, at) => (_jsx("span", { className: typeof token.color === 'object' && !props.theme ? 'hozo-code-token' : undefined, style: tokenStyle(token, props.theme), children: token.text }, at)))] })] }, index));
176
+ }
177
+ // An unwrapped block cannot be as wide as a line it has not mounted, so the
178
+ // widest one is drawn once more, at no height and hidden from reading and
179
+ // find-in-page, to hold the scrolling width open, as on Native.
180
+ const widest = props.scroller && !props.wrap ? widestCodeLine(lines) : undefined;
181
+ return (_jsxs(_Fragment, { children: [_jsx("style", { href: "hozo-code-tokens", precedence: "hozo-base", children: tokenCss }), props.scroller ? (_jsx("pre", { dir: "ltr", style: readable, children: _jsx("code", { children: lines.map(renderReadable) }) })) : null, _jsx("pre", { "aria-hidden": props.scroller ? true : undefined, className: props.className, dir: "ltr", style: {
182
+ margin: 0,
183
+ fontFamily: 'monospace',
184
+ lineHeight: 1.5,
185
+ ...props.style,
186
+ whiteSpace: props.wrap ? 'pre-wrap' : 'pre',
187
+ overflowWrap: props.wrap ? 'anywhere' : undefined,
188
+ }, children: _jsxs("code", { ref: shown.code, style: { font: 'inherit' }, children: [widest ? (_jsx("span", { "aria-hidden": "true", style: { display: 'block', width: 'max-content', height: 0, visibility: 'hidden' }, children: renderLine(widest.line, widest.index) })) : null, shown.leading ? (_jsx("span", { "aria-hidden": "true", style: { display: 'block', height: shown.leading } })) : null, lines
189
+ .slice(shown.range.first, shown.range.last + 1)
190
+ .map((line, at) => renderLine(line, shown.range.first + at)), shown.trailing ? (_jsx("span", { "aria-hidden": "true", style: { display: 'block', height: shown.trailing } })) : null] }) })] }));
191
+ }
192
+ //# sourceMappingURL=code-lines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-lines.js","sourceRoot":"","sources":["../src/code-lines.tsx"],"names":[],"mappings":";AAAA,uGAAuG;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,WAAW,GACZ,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAIL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAgD,cAAc,EAAE,MAAM,iBAAiB,CAAA;AA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AC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;6BAC9C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,EAC7D,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAChB,8BAAkB,MAAM,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAI,CACjF,CAAC,CAAC,CAAC,IAAI,IACH,GACH,IACL,CACJ,CAAA;AACH,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
3
+ import { type CodeLine, type normalizeCodeLines } from './code/model.ts';
4
+ import { useNormalizedCodeLines } from './code/reuse.ts';
5
+ export { useNormalizedCodeLines };
6
+ type CodeStyle = StyleProp<ViewStyle | TextStyle>;
7
+ export interface CodeLinesProps {
8
+ lines: readonly CodeLine[] | string;
9
+ tabSize?: number;
10
+ theme?: string;
11
+ wrap?: boolean;
12
+ className?: string;
13
+ lineClassName?: string;
14
+ insClassName?: string;
15
+ delClassName?: string;
16
+ markClassName?: string;
17
+ style?: CodeStyle;
18
+ lineStyle?: CodeStyle;
19
+ insStyle?: CodeStyle;
20
+ delStyle?: CodeStyle;
21
+ markStyle?: CodeStyle;
22
+ /** @internal A separate gutter supplied by CodeBlock. */
23
+ renderGutter?: (line: CodeLine, index: number) => ReactNode;
24
+ /**
25
+ * @internal Everything `renderGutter` draws from besides the line and its
26
+ * index, as `codeRowKey` gives it. Without it, a gutter's rows are not reused.
27
+ */
28
+ gutterKey?: string;
29
+ }
30
+ /**
31
+ * @internal One string for everything a row is drawn from besides its line
32
+ * and index, with styles flattened and classes resolved under each mark, so
33
+ * an equal key means an equal row. `undefined` when a value cannot be written
34
+ * out (an animated style, say): then nothing is reused.
35
+ */
36
+ export declare function codeRowKey(values: readonly unknown[], classNames?: readonly (string | undefined)[]): string | undefined;
37
+ /** A line after `normalizeCodeLines`: its tokens are always a list. */
38
+ export type NormalizedCodeLine = ReturnType<typeof normalizeCodeLines>[number];
39
+ export interface CodeLineRows {
40
+ lines: readonly NormalizedCodeLine[];
41
+ style: StyleProp<ViewStyle>;
42
+ renderLine: (line: NormalizedCodeLine, index: number) => ReactNode;
43
+ }
44
+ /**
45
+ * @internal What `CodeLines` draws, one line at a time: the normalized lines,
46
+ * the box around them, and the row for any one line.
47
+ *
48
+ * Separate from `CodeLines` so that `CodeBlock` can hand the rows to a
49
+ * `FlatList` and mount only the lines near the visible ones (#1289), with
50
+ * each row the same element the full list draws.
51
+ */
52
+ export declare function useCodeLineRows(props: CodeLinesProps): CodeLineRows;
53
+ export declare function CodeLines(props: CodeLinesProps): import("react").JSX.Element;
54
+ //# sourceMappingURL=code-lines.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-lines.native.d.ts","sourceRoot":"","sources":["../src/code-lines.native.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAA;AAClD,OAAO,EACL,KAAK,SAAS,EAGd,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,QAAQ,EAIb,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAwB,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAE9E,OAAO,EAAE,sBAAsB,EAAE,CAAA;AAEjC,KAAK,SAAS,GAAG,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;AACjD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAAA;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,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ignore-all lint/suspicious/noArrayIndexKey: code lines and tokens use source-position identity
3
+ import { useHozoMessage } from '@hozo/behaviors';
4
+ import { HozoTextSizeContext, hozoSplitTextStyle } from '@hozo/engine';
5
+ import { useHozoDark } from '@hozo/engine/generated/environment';
6
+ import { hozoClasses } from '@hozo/engine/project';
7
+ import { useContext } from 'react';
8
+ import { StyleSheet, Text, View, } from 'react-native';
9
+ import { drawnCodeTokens, } from './code/model.js';
10
+ import { codeKey, useCodeRows, useNormalizedCodeLines } from './code/reuse.js';
11
+ export { useNormalizedCodeLines };
12
+ const MARK_FACTS = [undefined, 'ins', 'del', 'mark'].map((mark) => ({
13
+ 'data-code-mark': Boolean(mark),
14
+ 'data-code-mark=ins': mark === 'ins',
15
+ 'data-code-mark=del': mark === 'del',
16
+ 'data-code-mark=mark': mark === 'mark',
17
+ }));
18
+ /**
19
+ * @internal One string for everything a row is drawn from besides its line
20
+ * and index, with styles flattened and classes resolved under each mark, so
21
+ * an equal key means an equal row. `undefined` when a value cannot be written
22
+ * out (an animated style, say): then nothing is reused.
23
+ */
24
+ export function codeRowKey(values, classNames = []) {
25
+ return codeKey([
26
+ values,
27
+ classNames.map((name) => MARK_FACTS.map((facts) => hozoClasses(name, facts))),
28
+ ]);
29
+ }
30
+ const split = (style) => hozoSplitTextStyle(StyleSheet.flatten(style) ?? {});
31
+ // Only what the run sets, so that on the line itself an unset colour still
32
+ // leaves the line's own.
33
+ function runStyle(run) {
34
+ return {
35
+ ...(run?.color ? { color: run.color } : {}),
36
+ ...(run?.italic ? { fontStyle: 'italic' } : {}),
37
+ ...(run?.bold ? { fontWeight: '700' } : {}),
38
+ ...(run?.underline ? { textDecorationLine: 'underline' } : {}),
39
+ };
40
+ }
41
+ /**
42
+ * @internal What `CodeLines` draws, one line at a time: the normalized lines,
43
+ * the box around them, and the row for any one line.
44
+ *
45
+ * Separate from `CodeLines` so that `CodeBlock` can hand the rows to a
46
+ * `FlatList` and mount only the lines near the visible ones (#1289), with
47
+ * each row the same element the full list draws.
48
+ */
49
+ export function useCodeLineRows(props) {
50
+ const message = useHozoMessage();
51
+ const dark = useHozoDark();
52
+ const inheritedSize = useContext(HozoTextSizeContext);
53
+ const theme = props.theme ?? (dark ? 'dark' : 'light');
54
+ const lines = useNormalizedCodeLines(props.lines, props.tabSize);
55
+ const [box, text] = split([hozoClasses(props.className), props.style]);
56
+ const labels = {
57
+ ins: message('hozo.code.added'),
58
+ del: message('hozo.code.removed'),
59
+ mark: message('hozo.code.highlighted'),
60
+ };
61
+ const fontSize = typeof text.fontSize === 'number' ? text.fontSize : inheritedSize;
62
+ const lineHeight = text.lineHeight ?? fontSize * 1.5;
63
+ const key = props.renderGutter && props.gutterKey === undefined
64
+ ? undefined
65
+ : codeRowKey([
66
+ theme,
67
+ fontSize,
68
+ lineHeight,
69
+ props.wrap,
70
+ text,
71
+ labels,
72
+ props.gutterKey,
73
+ ...[props.lineStyle, props.insStyle, props.delStyle, props.markStyle].map((style) => StyleSheet.flatten(style)),
74
+ ], [props.lineClassName, props.insClassName, props.delClassName, props.markClassName]);
75
+ const renderLine = useCodeRows(lines, key, drawLine);
76
+ function drawLine(line, index) {
77
+ const facts = {
78
+ 'data-code-mark': Boolean(line.mark),
79
+ 'data-code-mark=ins': line.mark === 'ins',
80
+ 'data-code-mark=del': line.mark === 'del',
81
+ 'data-code-mark=mark': line.mark === 'mark',
82
+ };
83
+ const [lineBox, lineText] = split([
84
+ hozoClasses(props.lineClassName, facts),
85
+ line.mark ? hozoClasses(props[`${line.mark}ClassName`], facts) : undefined,
86
+ props.lineStyle,
87
+ line.mark ? props[`${line.mark}Style`] : undefined,
88
+ ]);
89
+ const tokens = line.tokens;
90
+ const content = tokens.map((token) => token.text).join('');
91
+ const runs = drawnCodeTokens(tokens, theme);
92
+ return (_jsxs(View, { style: [{ flexDirection: 'row', minHeight: lineHeight }, lineBox], children: [props.renderGutter?.(line, index), _jsx(Text, { accessible: true, accessibilityLabel: line.mark ? `${labels[line.mark]}: ${content}` : content, style: [
93
+ { fontFamily: 'monospace', fontSize, lineHeight },
94
+ text,
95
+ lineText,
96
+ // A line drawn in one style needs no nested Text: the run's style
97
+ // goes on the line itself, which is the same drawing (#1431).
98
+ runs.length === 1 ? runStyle(runs[0]) : undefined,
99
+ { flexGrow: 1, flexShrink: props.wrap ? 1 : 0, minWidth: 0 },
100
+ ], children: runs.length === 1
101
+ ? runs[0]?.text
102
+ : runs.map((run, at) => (_jsx(Text, { style: runStyle(run), children: run.text }, at))) })] }, index));
103
+ }
104
+ return {
105
+ lines,
106
+ style: [box, props.wrap ? { alignSelf: 'stretch', minWidth: 0 } : undefined],
107
+ renderLine,
108
+ };
109
+ }
110
+ export function CodeLines(props) {
111
+ const { lines, style, renderLine } = useCodeLineRows(props);
112
+ return _jsx(View, { style: style, children: lines.map(renderLine) });
113
+ }
114
+ //# sourceMappingURL=code-lines.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-lines.native.js","sourceRoot":"","sources":["../src/code-lines.native.tsx"],"names":[],"mappings":";AAAA,uGAAuG;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAEL,UAAU,EACV,IAAI,EAEJ,IAAI,GAEL,MAAM,cAAc,CAAA;AACrB,OAAO,EAIL,eAAe,GAEhB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAE9E,OAAO,EAAE,sBAAsB,EAAE,CAAA;AA2BjC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,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K,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,UAAU;KACX,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IAC3D,OAAO,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,YAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAQ,CAAA;AAC3D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,42 +1,4 @@
1
- import { Link, type LinkProps, Text, type TextProps } from '@hozo/primitives';
2
- import type { CSSProperties, ReactNode } from 'react';
3
- export { Link, type LinkProps, Text, type TextProps };
4
- export interface TypographyUniversalProps {
5
- className?: string;
6
- children?: ReactNode;
7
- style?: CSSProperties;
8
- testID?: string;
9
- nativeID?: string;
10
- accessibilityLabel?: string;
11
- accessibilityHint?: string;
12
- 'aria-hidden'?: boolean;
13
- }
14
- export type SemanticTextProps = TypographyUniversalProps;
15
- export interface HeadingProps extends TypographyUniversalProps {
16
- level?: 1 | 2 | 3 | 4 | 5 | 6;
17
- }
18
- export declare function Paragraph({ className, children, style, ...props }: SemanticTextProps): import("react").JSX.Element;
19
- export declare function Heading({ level, className, children, style, ...props }: HeadingProps): import("react").JSX.Element;
20
- export declare function Strong({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
21
- export declare function Emphasis({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
22
- export declare function Underline({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
23
- export declare function Strikethrough({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
24
- export declare const Del: typeof Strikethrough;
25
- export declare function Sub({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
26
- export declare function Sup({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
27
- export declare function Code({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
28
- /**
29
- * A block whose spaces and line breaks are the content, a code sample above
30
- * all. Holds phrasing content -- put a `Code` inside for code, as `<pre><code>`
31
- * is written by hand.
32
- */
33
- export declare function Preformatted({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
34
- export declare function Small({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
35
- export declare function Mark({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
36
- export declare function NoBreak({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
37
- export declare function Ruby({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
38
- export declare namespace Ruby {
39
- export { RubyText };
40
- }
41
- export declare function RubyText({ className, children, style, ...props }: TypographyUniversalProps): import("react").JSX.Element;
1
+ export type { CodeLine, CodeMark, CodeRange, CodeToken } from './code/model.ts';
2
+ export { CodeLines, type CodeLinesProps } from './code-lines.tsx';
3
+ export * from './text.tsx';
42
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,CAAA;AAErD,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,MAAM,CAAC,EA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EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAMrF;AAED,wBAAgB,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAMtF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAM9F;AAED,wBAAgB,KAAK,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAMvF;AAED,wBAAgB,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAMtF;AAED,wBAAgB,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAMzF;AAED,wBAAgB,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAMtF;yBANe,IAAI;;;AAQpB,wBAAgB,QAAQ,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,wBAAwB,+BAM1F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -1,70 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Link, Text } from '@hozo/primitives';
3
- export { Link, Text };
4
- function domProps(props) {
5
- return {
6
- 'data-testid': props.testID,
7
- id: props.nativeID,
8
- 'aria-label': props.accessibilityLabel,
9
- 'aria-description': props.accessibilityHint,
10
- 'aria-hidden': props['aria-hidden'],
11
- };
12
- }
13
- export function Paragraph({ className, children, style, ...props }) {
14
- return (_jsx("p", { className: className, style: style, ...domProps(props), children: children }));
15
- }
16
- export function Heading({ level = 1, className, children, style, ...props }) {
17
- const Tag = `h${Math.min(6, Math.max(1, level))}`;
18
- return (_jsx(Tag, { className: className, style: style, ...domProps(props), children: children }));
19
- }
20
- export function Strong({ className, children, style, ...props }) {
21
- return (_jsx("strong", { className: className, style: style, ...domProps(props), children: children }));
22
- }
23
- export function Emphasis({ className, children, style, ...props }) {
24
- return (_jsx("em", { className: className, style: style, ...domProps(props), children: children }));
25
- }
26
- export function Underline({ className, children, style, ...props }) {
27
- return (_jsx("u", { className: className, style: style, ...domProps(props), children: children }));
28
- }
29
- export function Strikethrough({ className, children, style, ...props }) {
30
- return (_jsx("s", { className: className, style: style, ...domProps(props), children: children }));
31
- }
32
- export const Del = Strikethrough;
33
- export function Sub({ className, children, style, ...props }) {
34
- return (_jsx("sub", { className: className, style: style, ...domProps(props), children: children }));
35
- }
36
- export function Sup({ className, children, style, ...props }) {
37
- return (_jsx("sup", { className: className, style: style, ...domProps(props), children: children }));
38
- }
39
- export function Code({ className, children, style, ...props }) {
40
- return (_jsx("code", { className: className, style: style, ...domProps(props), children: children }));
41
- }
42
- /**
43
- * A block whose spaces and line breaks are the content, a code sample above
44
- * all. Holds phrasing content -- put a `Code` inside for code, as `<pre><code>`
45
- * is written by hand.
46
- */
47
- export function Preformatted({ className, children, style, ...props }) {
48
- return (_jsx("pre", { className: className, style: style, ...domProps(props), children: children }));
49
- }
50
- export function Small({ className, children, style, ...props }) {
51
- return (_jsx("small", { className: className, style: style, ...domProps(props), children: children }));
52
- }
53
- export function Mark({ className, children, style, ...props }) {
54
- return (_jsx("mark", { className: className, style: style, ...domProps(props), children: children }));
55
- }
56
- export function NoBreak({ className, children, style, ...props }) {
57
- return (_jsx("span", { className: className, style: { whiteSpace: 'nowrap', ...style }, ...domProps(props), children: children }));
58
- }
59
- export function Ruby({ className, children, style, ...props }) {
60
- return (_jsx("ruby", { className: className, style: style, ...domProps(props), children: children }));
61
- }
62
- export function RubyText({ className, children, style, ...props }) {
63
- return (_jsx("rt", { className: className, style: style, ...domProps(props), children: children }));
64
- }
65
- // Both spellings, the way `TermList` reads both. The member keeps the
66
- // full name rather than shortening to `Text`: a flat export has to be
67
- // readable on its own, and a `<Text>` that meant the annotation would
68
- // not be. The compiler recognises the pair in `hozo_parser`.
69
- Ruby.RubyText = RubyText;
1
+ // Keep data-driven code rendering out of apps that only use semantic text.
2
+ export { CodeLines } from './code-lines.js';
3
+ export * from './text.js';
70
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkB,IAAI,EAAkB,MAAM,kBAAkB,CAAA;AAG7E,OAAO,EAAE,IAAI,EAAkB,IAAI,EAAkB,CAAA;AAmBrD,SAAS,QAAQ,CAAC,KAAyE;IACzF,OAAO;QACL,aAAa,EAAE,KAAK,CAAC,MAAM;QAC3B,EAAE,EAAE,KAAK,CAAC,QAAQ;QAClB,YAAY,EAAE,KAAK,CAAC,kBAAkB;QACtC,kBAAkB,EAAE,KAAK,CAAC,iBAAiB;QAC3C,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC;KACpC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAqB;IACnF,OAAO,CACL,YAAG,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,KAAM,QAAQ,CAAC,KAAK,CAAC,YACvD,QAAQ,GACP,CACL,CAAA;AACH,CAAC;AAED,MAAM,UAA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CAAA;AACjE,cAAc,WAAY,CAAA"}
@@ -1,83 +1,4 @@
1
- import { Link, Text } from '@hozo/primitives';
2
- import React, { type ReactNode } from 'react';
3
- import type { AccessibilityRole, StyleProp, TextStyle } from 'react-native';
4
- export { BARE_TEXT_SIZE_RATIOS, TEXT_SIZE_RATIOS } from './text-size.ts';
5
- export { Link, Text };
6
- export interface TypographyNativeProps {
7
- /**
8
- * Tailwind classes, read by the compiler and gone by runtime.
9
- *
10
- * The Web half of this file has always declared it; this half never
11
- * did, and nothing noticed because the `react-native` export condition
12
- * carried no `types`, so a React Native app was type-checked against
13
- * the Web declarations instead. Uncompiled, the prop is simply ignored
14
- * here -- which is what the fallback components are for.
15
- */
16
- className?: string;
17
- children?: ReactNode;
18
- /**
19
- * React Native's own types rather than `any` and `string`.
20
- *
21
- * The Web half of this file says `CSSProperties`. This half agreed with
22
- * anything, so a Web-only style reached a native `Text` in silence --
23
- * the same erasure `@hozo/tailwind-conformance` exists to catch one
24
- * layer down.
25
- */
26
- style?: StyleProp<TextStyle>;
27
- testID?: string;
28
- nativeID?: string;
29
- accessibilityLabel?: string;
30
- accessibilityHint?: string;
31
- accessibilityRole?: AccessibilityRole;
32
- accessible?: boolean;
33
- numberOfLines?: number;
34
- ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip';
35
- }
36
- export type TypographyUniversalProps = TypographyNativeProps;
37
- export type TextProps = TypographyNativeProps;
38
- export type SemanticTextProps = TypographyNativeProps;
39
- export interface HeadingProps extends TypographyNativeProps {
40
- level?: 1 | 2 | 3 | 4 | 5 | 6;
41
- }
42
- /** Native declaration for the Link value re-exported from primitives. */
43
- export interface LinkProps extends TypographyNativeProps {
44
- href: string;
45
- external?: boolean;
46
- replace?: boolean;
47
- prefetch?: boolean;
48
- target?: string;
49
- rel?: string;
50
- download?: boolean | string;
51
- onPress?: (event: {
52
- defaultPrevented?: boolean;
53
- }) => void;
54
- }
55
- export declare function Paragraph(props: SemanticTextProps): React.JSX.Element;
56
- export declare function Heading({ level, accessibilityRole, style, ...props }: HeadingProps): React.JSX.Element;
57
- export declare function Strong({ style, ...props }: TypographyNativeProps): React.JSX.Element;
58
- export declare function Emphasis({ style, ...props }: TypographyNativeProps): React.JSX.Element;
59
- export declare function Underline({ style, ...props }: TypographyNativeProps): React.JSX.Element;
60
- export declare function Strikethrough({ style, ...props }: TypographyNativeProps): React.JSX.Element;
61
- export declare const Del: typeof Strikethrough;
62
- export declare function Sub({ style, ...props }: TypographyNativeProps): React.JSX.Element;
63
- export declare function Sup({ style, ...props }: TypographyNativeProps): React.JSX.Element;
64
- export declare function Code({ style, ...props }: TypographyNativeProps): React.JSX.Element;
65
- export declare function Preformatted({ style, ...props }: TypographyNativeProps): React.JSX.Element;
66
- export declare function Small({ style, ...props }: TypographyNativeProps): React.JSX.Element;
67
- export declare function Mark({ style, ...props }: TypographyNativeProps): React.JSX.Element;
68
- export declare function NoBreak({ children, ...props }: TypographyNativeProps): React.JSX.Element;
69
- /**
70
- * Ruby, sharing the pair the Native backend emits.
71
- *
72
- * React Native flattens nested `Text` into one accessibility node, so a
73
- * screen reader read the base and then the reading: 「漢字かんじ」. The
74
- * `accessible={false}` that used to be on the annotation could not stop
75
- * it -- the flattening happens above, and the parent's label is built
76
- * from the text it contains whatever the children say about themselves.
77
- */
78
- export declare function Ruby({ children, accessibilityLabel, style, ...props }: TypographyNativeProps): React.JSX.Element;
79
- export declare namespace Ruby {
80
- export { RubyText };
81
- }
82
- export declare function RubyText({ style, children, ...props }: TypographyNativeProps): React.JSX.Element;
1
+ export type { CodeLine, CodeMark, CodeRange, CodeToken } from './code/model.ts';
2
+ export { CodeLines, type CodeLinesProps } from './code-lines.native.tsx';
3
+ export * from './text.native.tsx';
83
4
  //# sourceMappingURL=index.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../src/index.native.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBA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