@vyaz/core 0.0.9 → 0.0.10

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.
@@ -22,6 +22,12 @@ export declare class FontMetricsProvider implements IFontMetricsProvider {
22
22
  private cache;
23
23
  private metricsCache;
24
24
  private mode;
25
+ /** Set of in-flight registerFont() promises for race-condition guarding */
26
+ private pendingRegistrations;
27
+ private _measureCanvas;
28
+ private _measureCtx;
29
+ /** Get or create a reusable canvas context for Canvas TextMetrics. */
30
+ private _getMeasureContext;
25
31
  setMode(mode: 'browser' | 'office'): void;
26
32
  getMode(): 'browser' | 'office';
27
33
  /**
@@ -31,6 +37,9 @@ export declare class FontMetricsProvider implements IFontMetricsProvider {
31
37
  * In the browser the caller must provide font bytes (e.g. fetched via
32
38
  * `getFontBuffer()` from `../utils/font.js`).
33
39
  *
40
+ * Tracks pending registrations to detect race conditions where
41
+ * getMetrics() is called before registration completes.
42
+ *
34
43
  * @param source Font file bytes (ArrayBuffer / Uint8Array), or a URL string
35
44
  * @param sourcePath Optional filesystem path (used for @napi-rs/canvas in Node.js)
36
45
  */
@@ -38,6 +47,13 @@ export declare class FontMetricsProvider implements IFontMetricsProvider {
38
47
  weight?: string;
39
48
  style?: string;
40
49
  }, source: string | ArrayBuffer | Uint8Array, sourcePath?: string): Promise<void>;
50
+ /** Internal registration logic — not tracked, exposed for direct use if needed. */
51
+ private _registerFontInternal;
52
+ /**
53
+ * Wait for all in-flight font registrations to complete.
54
+ * Useful after a batch of registerFont() calls before layout.
55
+ */
56
+ waitForPendingRegistrations(): Promise<void>;
41
57
  /**
42
58
  * Get font engine FontFace object for per-character calculations.
43
59
  * Returns undefined if font is not registered.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyaz/core",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",