@maptalks/vt 0.98.0 → 0.100.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @maptalks/vt v0.98.0
2
+ * @maptalks/vt v0.100.0
3
3
  * LICENSE : undefined
4
4
  * (c) 2016-2024 maptalks.org
5
5
  */
@@ -159,6 +159,7 @@ declare class VectorTileLayer extends maptalks.TileLayer {
159
159
  */
160
160
  getFeatureState(source: any): unknown;
161
161
  protected _prepareOptions(): void;
162
+ forceReload(): this;
162
163
  onWorkerReady(): void;
163
164
  /**
164
165
  * 更新图层配置。
@@ -466,7 +467,7 @@ declare class MapboxVectorTileLayer extends VectorTileLayer {
466
467
  declare class GeoJSONVectorTileLayer extends VectorTileLayer {
467
468
  options: GeoJSONVectorTileLayerOptionsType;
468
469
  features: Record<string, any>;
469
- constructor(id: string, options: GeoJSONVectorTileLayerOptionsType);
470
+ constructor(id: string, options: GeoJSONVectorTileLayerParamOptionsType);
470
471
  onAdd(): void;
471
472
  protected _prepareOptions(): void;
472
473
  getWorkerOptions(): Record<string, any>;
@@ -477,9 +478,11 @@ declare class GeoJSONVectorTileLayer extends VectorTileLayer {
477
478
  getTileUrl(x: number, y: number, z: number): string;
478
479
  getFeature(id: string): any;
479
480
  static fromJSON(layerJSON: LayerJSONType): GeoJSONVectorTileLayer | null;
481
+ getGeometryById(id: number): any;
480
482
  }
481
483
 
482
- type GeoJSONVectorTileLayerOptionsType = {
484
+ type OmitUrlTemplate = Omit<VectorTileLayerOptionsType, 'urlTemplate'>;
485
+ type OptionsType = {
483
486
  features?: string;
484
487
  tileBuffer?: number;
485
488
  extent?: number;
@@ -489,7 +492,132 @@ type GeoJSONVectorTileLayerOptionsType = {
489
492
  generateOMBB?: boolean;
490
493
  data?: any;
491
494
  convertFn?: (data: any) => any;
492
- } & VectorTileLayerOptionsType;
495
+ };
496
+ type GeoJSONVectorTileLayerParamOptionsType = OptionsType & OmitUrlTemplate;
497
+ type GeoJSONVectorTileLayerOptionsType = OptionsType & VectorTileLayerOptionsType;
498
+
499
+ /**
500
+ * from mapbox-gl-js
501
+ * A [least-recently-used cache](http://en.wikipedia.org/wiki/Cache_algorithms)
502
+ * with hash lookup made possible by keeping a list of keys in parallel to
503
+ * an array of dictionary of values
504
+ *
505
+ * @public
506
+ */
507
+ declare class LRUCache {
508
+ /**
509
+ * @param {number} max number of permitted values
510
+ * @param {Function} onRemove callback called with items when they expire
511
+ */
512
+ constructor(max: number);
513
+ max: number;
514
+ /**
515
+ * Clear the cache
516
+ *
517
+ * @returns {LRUCache} this cache
518
+ */
519
+ reset(): LRUCache;
520
+ data: {};
521
+ order: any[];
522
+ clear(): void;
523
+ /**
524
+ * Add a key, value combination to the cache, trimming its size if this pushes
525
+ * it over max length.
526
+ *
527
+ * @param {string} key lookup key for the item
528
+ * @param {*} data any value
529
+ *
530
+ * @returns {LRUCache} this cache
531
+ */
532
+ add(key: string, data: any): LRUCache;
533
+ /**
534
+ * Determine whether the value attached to `key` is present
535
+ *
536
+ * @param {String} key the key to be looked-up
537
+ * @returns {Boolean} whether the cache has this value
538
+ */
539
+ has(key: string): boolean;
540
+ /**
541
+ * List all keys in the cache
542
+ *
543
+ * @returns {Array<string>} an array of keys in this cache.
544
+ */
545
+ keys(): Array<string>;
546
+ /**
547
+ * Get the value attached to a specific key and remove data from cache.
548
+ * If the key is not found, returns `null`
549
+ *
550
+ * @param {string} key the key to look up
551
+ * @returns {*} the data, or null if it isn't found
552
+ */
553
+ getAndRemove(key: string): any;
554
+ /**
555
+ * Get the value attached to a specific key without removing data
556
+ * from the cache. If the key is not found, returns `null`
557
+ *
558
+ * @param {string} key the key to look up
559
+ * @returns {*} the data, or null if it isn't found
560
+ */
561
+ get(key: string): any;
562
+ /**
563
+ * Remove a key/value combination from the cache.
564
+ *
565
+ * @param {string} key the key for the pair to delete
566
+ * @returns {LRUCache} this cache
567
+ */
568
+ remove(key: string): LRUCache;
569
+ /**
570
+ * Change the max size of the cache.
571
+ *
572
+ * @param {number} max the max size of the cache
573
+ * @returns {LRUCache} this cache
574
+ */
575
+ setMaxSize(max: number): LRUCache;
576
+ }
577
+ //# sourceMappingURL=LRUCache.d.ts.map
578
+
579
+ declare class GlyphRequestor {
580
+ constructor(framer: any, limit: number, isCompactChars: any, sdfURL: any);
581
+ entries: {};
582
+ _cachedFont: {};
583
+ _cache: LRUCache;
584
+ _framer: any;
585
+ _limit: number;
586
+ _isCompactChars: any;
587
+ _sdfURL: any;
588
+ _isValidSDFURL(url: any): boolean;
589
+ getGlyphs(glyphs: any, cb: any): void;
590
+ _requestRemoteSDF(glyphs: any, cb: any): void;
591
+ _requestGlyph(): Promise<any>;
592
+ _tinySDF(entry: any, fonts: any, charCode: any, isCharsCompact: any): {
593
+ charCode: any;
594
+ bitmap: {
595
+ width: number;
596
+ height: number;
597
+ data: any;
598
+ };
599
+ metrics: {
600
+ width: number;
601
+ height: number;
602
+ left: number;
603
+ top: number;
604
+ advance: number;
605
+ };
606
+ };
607
+ }
608
+
609
+ declare class IconRequestor {
610
+ constructor(options: any);
611
+ options: any;
612
+ _requesting: {};
613
+ _cache: LRUCache;
614
+ ctx: CanvasRenderingContext2D;
615
+ getIcons(icons: any, cb: any): void;
616
+ _hasCache(url: any, width: any, height: any): boolean;
617
+ _addCache(url: any, data: any, width: any, height: any): void;
618
+ _getCache(url: any, size: any): any;
619
+ _ensureMaxSize(url: any, size: any): void;
620
+ }
493
621
 
494
622
  declare const WorkerConnection_base: {
495
623
  new (workerKey: string): {
@@ -533,8 +661,8 @@ declare class WorkerConnection extends WorkerConnection_base {
533
661
  _workerLayerId: string;
534
662
  _isDedicated: boolean;
535
663
  _dedicatedVTWorkers: {};
536
- _iconRequestor: any;
537
- _glyphRequestor: any;
664
+ _iconRequestor: IconRequestor;
665
+ _glyphRequestor: GlyphRequestor;
538
666
  initialize(cb: any): void;
539
667
  addLayer(cb: any): void;
540
668
  abortTile(url: any, cb: any): void;
@@ -596,6 +724,7 @@ declare class TileStencilRenderer {
596
724
  declare class VectorTileLayerRenderer extends maptalks.renderer.TileLayerCanvasRenderer {
597
725
  constructor(layer: any);
598
726
  supportRenderMode(): boolean;
727
+ _workerCacheIndex: number;
599
728
  ready: boolean;
600
729
  _styleCounter: number;
601
730
  _requestingMVT: {};
@@ -633,6 +762,7 @@ declare class VectorTileLayerRenderer extends maptalks.renderer.TileLayerCanvasR
633
762
  };
634
763
  _prepareWorker(): void;
635
764
  _workerConn: WorkerConnection;
765
+ _incrWorkerCacheIndex(): void;
636
766
  checkResources(): any[];
637
767
  _drawTiles(tiles: any, parentTiles: any, childTiles: any, placeholders: any, context: any): void;
638
768
  _deletePrevPlugins(): void;
@@ -670,6 +800,7 @@ declare class VectorTileLayerRenderer extends maptalks.renderer.TileLayerCanvasR
670
800
  features: any[];
671
801
  }[];
672
802
  _onReceiveMVTData(url: any, err: any, data: any): void;
803
+ _receivedTileExtent: any;
673
804
  _parseTileData(styleType: any, i: any, pluginData: any, features: any): {
674
805
  isUpdated: boolean;
675
806
  layer: {
@@ -691,7 +822,7 @@ declare class VectorTileLayerRenderer extends maptalks.renderer.TileLayerCanvasR
691
822
  _endFrame(timestamp: any): void;
692
823
  getPolygonOffsetCount(): number;
693
824
  _drawDebug(): void;
694
- _isVisitable(plugin: any): true | 0 | 1 | 2;
825
+ _isVisitable(plugin: any): true | 1 | 2 | 0;
695
826
  _getPluginContext(plugin: any, polygonOffsetIndex: any, cameraPosition: any, timestamp: any): {
696
827
  regl: any;
697
828
  layer: any;
@@ -820,7 +951,7 @@ declare class Vector3DLayer extends maptalks.OverlayLayer {
820
951
  * 获取图层的polygonOffsetCount
821
952
  * 用于GroupGLLayer全局管理polygonOffset
822
953
  */
823
- getPolygonOffsetCount(): 0 | 1;
954
+ getPolygonOffsetCount(): 1 | 0;
824
955
  /**
825
956
  * 获取图层的polygonOffset
826
957
  * 用于GroupGLLayer全局管理polygonOffset