three-text 0.2.18 → 0.3.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.
package/dist/index.d.ts CHANGED
@@ -5,6 +5,21 @@ interface HyphenationTrieNode {
5
5
  };
6
6
  }
7
7
 
8
+ interface CacheStats {
9
+ size: number;
10
+ }
11
+ declare class Cache<K, V> {
12
+ private cache;
13
+ get(key: K): V | undefined;
14
+ has(key: K): boolean;
15
+ set(key: K, value: V): void;
16
+ delete(key: K): boolean;
17
+ clear(): void;
18
+ get size(): number;
19
+ keys(): K[];
20
+ getStats(): CacheStats;
21
+ }
22
+
8
23
  interface BoundingBox {
9
24
  min: {
10
25
  x: number;
@@ -212,6 +227,8 @@ interface TextGeometryInfo {
212
227
  glyphCenter: Float32Array;
213
228
  glyphIndex: Float32Array;
214
229
  glyphLineIndex: Float32Array;
230
+ glyphProgress: Float32Array;
231
+ glyphBaselineY: Float32Array;
215
232
  };
216
233
  glyphs: GlyphGeometryInfo[];
217
234
  planeBounds: BoundingBox;
@@ -221,13 +238,16 @@ interface TextGeometryInfo {
221
238
  pointsRemovedByVisvalingam: number;
222
239
  pointsRemovedByColinear: number;
223
240
  originalPointCount: number;
224
- };
241
+ } & Partial<CacheStats & {
242
+ hitRate: number;
243
+ memoryUsageMB: number;
244
+ }>;
225
245
  query(options: TextQueryOptions): TextRange[];
226
246
  coloredRanges?: ColoredRange[];
227
247
  }
228
248
  interface TextHandle extends TextGeometryInfo {
229
249
  getLoadedFont(): LoadedFont | undefined;
230
- getCacheStatistics(): any;
250
+ getCacheSize(): number;
231
251
  clearCache(): void;
232
252
  measureTextWidth(text: string, letterSpacing?: number): number;
233
253
  update(options: Partial<TextOptions>): Promise<TextHandle>;
@@ -266,12 +286,12 @@ interface ColoredRange {
266
286
  }
267
287
  interface TextOptions {
268
288
  text: string;
269
- font?: string | ArrayBuffer;
289
+ font: string | ArrayBuffer;
270
290
  size?: number;
271
291
  depth?: number;
272
292
  lineHeight?: number;
273
293
  letterSpacing?: number;
274
- separateGlyphsWithAttributes?: boolean;
294
+ perGlyphAttributes?: boolean;
275
295
  fontVariations?: {
276
296
  [key: string]: number;
277
297
  };
@@ -367,14 +387,10 @@ declare class Text {
367
387
  getFontMetrics(): FontMetrics;
368
388
  static preloadPatterns(languages: string[], patternsPath?: string): Promise<void>;
369
389
  static registerPattern(language: string, pattern: HyphenationTrieNode): void;
370
- static clearFontCache(): void;
371
390
  static setMaxFontCacheMemoryMB(limitMB: number): void;
372
391
  getLoadedFont(): LoadedFont | undefined;
373
392
  measureTextWidth(text: string, letterSpacing?: number): number;
374
- getCacheStatistics(): (CacheStats & {
375
- hitRate: number;
376
- memoryUsageMB: number;
377
- }) | null;
393
+ getCacheSize(): number;
378
394
  clearCache(): void;
379
395
  private createGlyphAttributes;
380
396
  private resetHelpers;
@@ -436,46 +452,7 @@ declare class FontMetadataExtractor {
436
452
  static getFontMetrics(metrics: ExtractedMetrics): FontMetrics;
437
453
  }
438
454
 
439
- interface LRUCacheOptions<K, V> {
440
- maxEntries?: number;
441
- maxMemoryBytes?: number;
442
- calculateSize?: (value: V) => number;
443
- onEvict?: (key: K, value: V) => void;
444
- }
445
- interface CacheStats {
446
- hits: number;
447
- misses: number;
448
- evictions: number;
449
- size: number;
450
- memoryUsage: number;
451
- }
452
- declare class LRUCache<K, V> {
453
- private cache;
454
- private head;
455
- private tail;
456
- private stats;
457
- private options;
458
- constructor(options?: LRUCacheOptions<K, V>);
459
- get(key: K): V | undefined;
460
- has(key: K): boolean;
461
- set(key: K, value: V): void;
462
- delete(key: K): boolean;
463
- clear(): void;
464
- getStats(): CacheStats & {
465
- hitRate: number;
466
- memoryUsageMB: number;
467
- };
468
- keys(): K[];
469
- get size(): number;
470
- private evictIfNeeded;
471
- private evictTail;
472
- private addToHead;
473
- private removeNode;
474
- private removeTail;
475
- private moveToHead;
476
- }
477
-
478
- declare const globalGlyphCache: LRUCache<string, GlyphData>;
479
- declare function createGlyphCache(maxCacheSizeMB?: number): LRUCache<string, GlyphData>;
455
+ declare const globalGlyphCache: Cache<string, GlyphData>;
456
+ declare function createGlyphCache(): Cache<string, GlyphData>;
480
457
 
481
458
  export { CacheStats, ColorByRange, ColorOptions, ColoredRange, CurveFidelityConfig, DEFAULT_CURVE_FIDELITY, ExtractedMetrics, FontMetadataExtractor, FontMetrics, GeometryOptimizationOptions, GlyphData, GlyphGeometryInfo, HarfBuzzAPI, HarfBuzzBlob, HarfBuzzBuffer, HarfBuzzFace, HarfBuzzFont, HarfBuzzInstance, HarfBuzzModule, HyphenationPatternsMap, HyphenationTrieNode, LayoutOptions, LineInfo, LoadedFont, PathInfo, ProcessedGeometry, Text, TextAlign, TextDirection, TextGeometryInfo, TextHandle, TextOptions, TextQueryOptions, TextRange, Triangles, VariationAxis, VerticalMetrics, createGlyphCache, globalGlyphCache };