@weasel-js/text 1.14.2 → 1.15.1

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.
@@ -519,6 +519,14 @@ declare function resolveRunFace(run: StyledRun, style: Pick<ResolvedTextStyle, '
519
519
  * `{ px }` size or spacing; the inherited ones arrived already resolved on
520
520
  * `style`. */
521
521
  declare function resolveRuns(runs: readonly StyledRun[], style: ResolvedTextStyle, viewScale?: number): ResolvedRun[];
522
+ /**
523
+ * {@link resolveRuns} into `out`, which is refilled in place and returned: a
524
+ * run already at an index is rewritten when it has the same optional fields as
525
+ * its replacement. For a caller that owns `out` and hands nothing it held
526
+ * to anyone who keeps it; one whose runs the text caches have seen calls
527
+ * `clearRuns` on them first.
528
+ */
529
+ declare function resolveRunsInto(out: ResolvedRun[], runs: readonly StyledRun[], style: ResolvedTextStyle, viewScale?: number): ResolvedRun[];
522
530
 
523
531
  /**
524
532
  * The bidi contract, declared here and implemented elsewhere.
@@ -613,11 +621,13 @@ interface ShapedCluster {
613
621
  d: string | null;
614
622
  /** Names `d` among the glyphs of one face, for caching what is built from it. */
615
623
  key: string;
616
- /** Each glyph and where it is drawn, in ems from the pen, y down. */
624
+ /** Each glyph, where it is drawn, and how far the shaper moved the pen past it, in ems
625
+ * from the pen, y down. A mark the shaper set over its base has no advance. */
617
626
  glyphs: readonly {
618
627
  gid: number;
619
628
  x: number;
620
629
  y: number;
630
+ advance: number;
621
631
  }[];
622
632
  /** Whether it was shaped right to left. */
623
633
  rtl: boolean;
@@ -967,6 +977,18 @@ declare function cachedLayoutRuns(runs: readonly ResolvedRun[], opts: LayoutRuns
967
977
  * Passing `runs` again afterwards is only a cache miss.
968
978
  */
969
979
  declare function dropRuns(runs: readonly ResolvedRun[]): void;
980
+ /**
981
+ * Forget what the caches hold for `runs`, which its caller is about to refill
982
+ * in place, leaving the array filed: unlike {@link dropRuns}, the next call
983
+ * with it costs no `WeakMap` set. A readout rewriting its text every frame
984
+ * refills one runs array this way, so the command it hands the renderer
985
+ * stays the same object.
986
+ *
987
+ * Call it before the first write to `runs` or any run in it: the structural
988
+ * list compares later runs with these, and a painting may still have to build
989
+ * its key from them.
990
+ */
991
+ declare function clearRuns(runs: readonly ResolvedRun[]): void;
970
992
  /** Test helper. Do not call from product code. */
971
993
  declare function _resetLayoutCacheForTests(): void;
972
994
 
@@ -982,13 +1004,20 @@ declare function _resetLayoutCacheForTests(): void;
982
1004
  * none. Pass `null`, or call the function returned, to take it out again.
983
1005
  */
984
1006
  declare function registerBidi(engine: BidiResolver | null): () => void;
1007
+ /** The engine {@link registerBidi} was last given, or null. */
1008
+ declare function registeredBidi(): BidiResolver | null;
985
1009
  /**
986
1010
  * The direction `text`'s first paragraph reads in: `direction` when it states
987
1011
  * one, otherwise its first strong character's. Finding that takes an engine,
988
1012
  * so with none registered the answer is `'ltr'`.
989
1013
  */
990
1014
  declare function paragraphDirection(text: string, direction?: TextDirection | 'auto', engine?: BidiResolver | null): TextDirection;
1015
+ /**
1016
+ * Warn, once per process, when `codePoints` hold right-to-left letters and
1017
+ * there is no engine to reorder them. `who` names the caller laying them out.
1018
+ */
1019
+ declare function warnRtlWithoutEngine(codePoints: ArrayLike<number>, who?: string): void;
991
1020
  /** Test helper. Do not call from product code. */
992
1021
  declare function _resetBidiWarningForTests(): void;
993
1022
 
994
- export { scriptMetrics as $, dropRuns as A, type BidiAnalysis as B, type CacheUse as C, DEFAULT_TEXT_FILL as D, fontString as E, type FontVariantCaps as F, halfLeadingFor as G, isBoldWeight as H, isSmallCapsLetter as I, layoutRuns as J, markdownToRuns as K, type LaidOutRuns as L, MARKDOWN_RUN_GRAMMAR as M, numericWeight as N, paragraphDirection as O, type PlacedGlyph as P, registerBidi as Q, type ResolvedTextStyle as R, type StyledRun as S, type TextStyle as T, resolveAlign as U, resolveRunFace as V, resolveRuns as W, resolveTextStyle as X, resolveTextStyleInto as Y, runsToMarkdown as Z, runsToPlainText as _, type ResolvedRun as a, scriptMetricsFor as a0, smallCapsScale as a1, smallCapsScaleFor as a2, smallCapsText as a3, toRuns as a4, transformRunTexts as a5, _resetBidiWarningForTests as a6, _resetLayoutCacheForTests as a7, type LayoutRunsOpts as b, type TextShaper as c, type TextPaint as d, type BidiReordering as e, type BidiResolver as f, DEFAULT_TEXT_STYLE as g, LAYOUT_CACHE_STRUCTURAL_LIMIT as h, LAYOUT_CACHE_VARIANT_LIMIT as i, type LaidOutCell as j, type LaidOutLineBox as k, type RunFlag as l, type RunGrammar as m, type RunMarker as n, type RunSourceMap as o, SCRIPT_METRICS as p, SMALL_CAPS_SCALE as q, type ScriptPreset as r, type ShapedCluster as s, type ShapedGlyph as t, type SmallCapsText as u, type TextAlign as v, type TextDirection as w, type TextTransform as x, type TransformedRunText as y, cachedLayoutRuns as z };
1023
+ export { resolveTextStyleInto as $, clearRuns as A, type BidiAnalysis as B, type CacheUse as C, DEFAULT_TEXT_FILL as D, dropRuns as E, type FontVariantCaps as F, fontString as G, halfLeadingFor as H, isBoldWeight as I, isSmallCapsLetter as J, layoutRuns as K, type LaidOutRuns as L, MARKDOWN_RUN_GRAMMAR as M, markdownToRuns as N, numericWeight as O, type PlacedGlyph as P, paragraphDirection as Q, type ResolvedTextStyle as R, type StyledRun as S, type TextStyle as T, registerBidi as U, registeredBidi as V, resolveAlign as W, resolveRunFace as X, resolveRuns as Y, resolveRunsInto as Z, resolveTextStyle as _, type ResolvedRun as a, runsToMarkdown as a0, runsToPlainText as a1, scriptMetrics as a2, scriptMetricsFor as a3, smallCapsScale as a4, smallCapsScaleFor as a5, smallCapsText as a6, toRuns as a7, transformRunTexts as a8, warnRtlWithoutEngine as a9, _resetBidiWarningForTests as aa, _resetLayoutCacheForTests as ab, type LayoutRunsOpts as b, type TextShaper as c, type TextPaint as d, type BidiReordering as e, type BidiResolver as f, DEFAULT_TEXT_STYLE as g, LAYOUT_CACHE_STRUCTURAL_LIMIT as h, LAYOUT_CACHE_VARIANT_LIMIT as i, type LaidOutCell as j, type LaidOutLineBox as k, type RunFlag as l, type RunGrammar as m, type RunMarker as n, type RunSourceMap as o, SCRIPT_METRICS as p, SMALL_CAPS_SCALE as q, type ScriptPreset as r, type ShapedCluster as s, type ShapedGlyph as t, type SmallCapsText as u, type TextAlign as v, type TextDirection as w, type TextTransform as x, type TransformedRunText as y, cachedLayoutRuns as z };
@@ -1,3 +1,3 @@
1
- export { a6 as _resetBidiWarningForTests, a7 as _resetLayoutCacheForTests } from './test-seams-D6uEFbAw.js';
1
+ export { aa as _resetBidiWarningForTests, ab as _resetLayoutCacheForTests } from './test-seams-B2R_EedN.js';
2
2
  import '@weasel-js/paint';
3
3
  import '@weasel-js/font';
@@ -1,3 +1,3 @@
1
- export { _resetBidiWarningForTests, _resetLayoutCacheForTests } from './chunk-5BJN6MC6.js';
1
+ export { _resetBidiWarningForTests, _resetLayoutCacheForTests } from './chunk-WUFANHTE.js';
2
2
  //# sourceMappingURL=test-seams.js.map
3
3
  //# sourceMappingURL=test-seams.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weasel-js/text",
3
- "version": "1.14.2",
3
+ "version": "1.15.1",
4
4
  "description": "Typography for weasel: styled runs, style resolution, kerned glyph layout, wrap and measurement. No scene graph, no React.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,9 +20,9 @@
20
20
  "./package.json": "./package.json"
21
21
  },
22
22
  "dependencies": {
23
- "@weasel-js/geom": "1.14.2",
24
- "@weasel-js/paint": "1.14.2",
25
- "@weasel-js/registry": "1.14.2"
23
+ "@weasel-js/geom": "1.15.1",
24
+ "@weasel-js/paint": "1.15.1",
25
+ "@weasel-js/registry": "1.15.1"
26
26
  },
27
27
  "scripts": {
28
28
  "test": "vitest run",
@@ -51,9 +51,9 @@
51
51
  "provenance": true
52
52
  },
53
53
  "devDependencies": {
54
- "@weasel-js/bidi": "1.14.2"
54
+ "@weasel-js/bidi": "1.15.1"
55
55
  },
56
56
  "peerDependencies": {
57
- "@weasel-js/font": "1.14.2"
57
+ "@weasel-js/font": "1.15.1"
58
58
  }
59
59
  }