@hyperframes/core 0.7.110 → 0.7.111

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.
@@ -1,3 +1,4 @@
1
1
  export { fitTextFontSize } from "./fitTextFontSize.js";
2
2
  export type { FitTextOptions, FitTextResult } from "./fitTextFontSize.js";
3
+ export { pretext } from "./pretext.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export { fitTextFontSize } from "./fitTextFontSize.js";
2
+ export { pretext } from "./pretext.js";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { layout, measureLineStats, measureNaturalWidth, prepare, prepareWithSegments } from "@chenglou/pretext";
2
+ /**
3
+ * The text measurement surface exposed to compositions as
4
+ * `window.__hyperframes.pretext`.
5
+ *
6
+ * Measuring text by writing it into the DOM and reading it back forces a
7
+ * reflow, which is both slow per frame and a determinism risk (the value
8
+ * depends on when you read it). These measure off a canvas instead, so a
9
+ * composition can size a container, pick a font size, or decide a line break
10
+ * at any frame without disturbing layout. `fitTextFontSize` is itself built on
11
+ * `prepare` + `layout`.
12
+ *
13
+ * Note the split, because it decides where you call these: `prepare` (and
14
+ * `prepareWithSegments`) does the real font measurement and needs a canvas, so
15
+ * it only works in a browser, not in Node. Everything downstream of a prepared
16
+ * string is arithmetic and is cheap enough to run per frame.
17
+ *
18
+ * Deliberately omitted from this surface:
19
+ * - `clearCache` and `setLocale` mutate process-global state. A composition
20
+ * calling either would change how *other* compositions measure, which breaks
21
+ * the guarantee that the same file renders the same video every time.
22
+ * Withholding `clearCache` does not strand memory: the cache is keyed by
23
+ * (segment, font) where segments come from `Intl.Segmenter` at word
24
+ * granularity, so it grows with the number of distinct *words* a composition
25
+ * renders, not with frames. A counter or typewriter re-measuring every frame
26
+ * reuses the same entries. Only genuinely new words allocate, which bounds it
27
+ * at a composition's vocabulary.
28
+ * - The incremental cursor API (`layoutNextLine`, `walkLineRanges`, and
29
+ * friends) has no caller yet. Add it when something needs it.
30
+ *
31
+ * @see packages/core/src/runtime/entry.ts for where this is attached.
32
+ */
33
+ export declare const pretext: {
34
+ /** Measure a string for a CSS font (e.g. `"700 48px Inter"`). */
35
+ readonly prepare: typeof prepare;
36
+ /** Line count and total height for a prepared string at a given width. */
37
+ readonly layout: typeof layout;
38
+ /** Like `prepare`, but retains segments so widths can be measured. */
39
+ readonly prepareWithSegments: typeof prepareWithSegments;
40
+ /** Line count plus `maxLineWidth` — the widest rendered line. */
41
+ readonly measureLineStats: typeof measureLineStats;
42
+ /** Width the string would occupy on a single unwrapped line. */
43
+ readonly measureNaturalWidth: typeof measureNaturalWidth;
44
+ };
45
+ //# sourceMappingURL=pretext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pretext.d.ts","sourceRoot":"","sources":["../../src/text/pretext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,OAAO;IAClB,iEAAiE;;IAEjE,0EAA0E;;IAE1E,sEAAsE;;IAEtE,iEAAiE;;IAEjE,gEAAgE;;CAExD,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { layout, measureLineStats, measureNaturalWidth, prepare, prepareWithSegments, } from "@chenglou/pretext";
2
+ /**
3
+ * The text measurement surface exposed to compositions as
4
+ * `window.__hyperframes.pretext`.
5
+ *
6
+ * Measuring text by writing it into the DOM and reading it back forces a
7
+ * reflow, which is both slow per frame and a determinism risk (the value
8
+ * depends on when you read it). These measure off a canvas instead, so a
9
+ * composition can size a container, pick a font size, or decide a line break
10
+ * at any frame without disturbing layout. `fitTextFontSize` is itself built on
11
+ * `prepare` + `layout`.
12
+ *
13
+ * Note the split, because it decides where you call these: `prepare` (and
14
+ * `prepareWithSegments`) does the real font measurement and needs a canvas, so
15
+ * it only works in a browser, not in Node. Everything downstream of a prepared
16
+ * string is arithmetic and is cheap enough to run per frame.
17
+ *
18
+ * Deliberately omitted from this surface:
19
+ * - `clearCache` and `setLocale` mutate process-global state. A composition
20
+ * calling either would change how *other* compositions measure, which breaks
21
+ * the guarantee that the same file renders the same video every time.
22
+ * Withholding `clearCache` does not strand memory: the cache is keyed by
23
+ * (segment, font) where segments come from `Intl.Segmenter` at word
24
+ * granularity, so it grows with the number of distinct *words* a composition
25
+ * renders, not with frames. A counter or typewriter re-measuring every frame
26
+ * reuses the same entries. Only genuinely new words allocate, which bounds it
27
+ * at a composition's vocabulary.
28
+ * - The incremental cursor API (`layoutNextLine`, `walkLineRanges`, and
29
+ * friends) has no caller yet. Add it when something needs it.
30
+ *
31
+ * @see packages/core/src/runtime/entry.ts for where this is attached.
32
+ */
33
+ export const pretext = {
34
+ /** Measure a string for a CSS font (e.g. `"700 48px Inter"`). */
35
+ prepare,
36
+ /** Line count and total height for a prepared string at a given width. */
37
+ layout,
38
+ /** Like `prepare`, but retains segments so widths can be measured. */
39
+ prepareWithSegments,
40
+ /** Line count plus `maxLineWidth` — the widest rendered line. */
41
+ measureLineStats,
42
+ /** Width the string would occupy on a single unwrapped line. */
43
+ measureNaturalWidth,
44
+ };
45
+ //# sourceMappingURL=pretext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pretext.js","sourceRoot":"","sources":["../../src/text/pretext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,iEAAiE;IACjE,OAAO;IACP,0EAA0E;IAC1E,MAAM;IACN,sEAAsE;IACtE,mBAAmB;IACnB,iEAAiE;IACjE,gBAAgB;IAChB,gEAAgE;IAChE,mBAAmB;CACX,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.7.110",
3
+ "version": "0.7.111",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -266,9 +266,9 @@
266
266
  "bpm-detective": "^2.0.5",
267
267
  "linkedom": "^0.18.12",
268
268
  "postcss": "^8.5.8",
269
- "@hyperframes/lint": "0.7.110",
270
- "@hyperframes/studio-server": "0.7.110",
271
- "@hyperframes/parsers": "0.7.110"
269
+ "@hyperframes/parsers": "0.7.111",
270
+ "@hyperframes/lint": "0.7.111",
271
+ "@hyperframes/studio-server": "0.7.111"
272
272
  },
273
273
  "devDependencies": {
274
274
  "@types/jsdom": "^28.0.0",