@octostar/map-component 0.2.21 → 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.cjs +7285 -6492
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +7285 -6492
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/drawing-toolbar.d.ts +4 -6
- package/dist/types/components/drawing-toolbar.d.ts.map +1 -1
- package/dist/types/components/layers-panel.d.ts +7 -1
- package/dist/types/components/layers-panel.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/basemap-list.d.ts +15 -6
- package/dist/types/lib/basemap-list.d.ts.map +1 -1
- package/dist/types/lib/custom-layer-stack.d.ts +41 -0
- package/dist/types/lib/custom-layer-stack.d.ts.map +1 -0
- package/dist/types/lib/frame-yield.d.ts +22 -0
- package/dist/types/lib/frame-yield.d.ts.map +1 -0
- package/dist/types/lib/map-editor-api.d.ts +94 -47
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/dist/types/lib/map-endpoints.d.ts +71 -0
- package/dist/types/lib/map-endpoints.d.ts.map +1 -0
- package/dist/types/lib/paint-feature.d.ts +15 -0
- package/dist/types/lib/paint-feature.d.ts.map +1 -1
- package/dist/types/lib/shard-constants.d.ts +52 -0
- package/dist/types/lib/shard-constants.d.ts.map +1 -0
- package/dist/types/lib/shard-fingerprint.d.ts +35 -0
- package/dist/types/lib/shard-fingerprint.d.ts.map +1 -0
- package/dist/types/lib/shard-pipeline.d.ts +49 -0
- package/dist/types/lib/shard-pipeline.d.ts.map +1 -0
- package/dist/types/lib/shard-registry.d.ts +106 -0
- package/dist/types/lib/shard-registry.d.ts.map +1 -0
- package/package.json +1 -1
- package/vite-plugin.d.mts +2 -0
- package/vite-plugin.mjs +42 -8
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Layer } from '@/components/layers-panel';
|
|
2
|
+
/**
|
|
3
|
+
* Features per shard source for large read-only layers.
|
|
4
|
+
*
|
|
5
|
+
* Measured on the `/perf-apply` harness, 200k styled points, 12 style layers,
|
|
6
|
+
* MapLibre 5.15, headed Chromium, slim render payload:
|
|
7
|
+
*
|
|
8
|
+
* | approach | worst main task | first paint | all tiles |
|
|
9
|
+
* |-----------------------------------|-----------------|-------------|-----------|
|
|
10
|
+
* | one `setData` | 725-1239 ms | after call | 4.4-7.7 s |
|
|
11
|
+
* | `updateData` 10k batches | 211-345 ms | - | 7.8-9.0 s |
|
|
12
|
+
* | sharded 10k, one `setData` each | 26-36 ms, no long tasks | 45 ms | 3.2-3.5 s |
|
|
13
|
+
*
|
|
14
|
+
* `updateData` loses because MapLibre's per-round `shouldReloadTile` scan and
|
|
15
|
+
* diff GC run on the main thread over the COALESCED round, not the batch, and
|
|
16
|
+
* neither is reachable from the public API. At 10k the fat payload still cost
|
|
17
|
+
* ~80 ms per shard, so the size is only safe together with the slim payload.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_READ_ONLY_SHARD_SIZE = 10000;
|
|
20
|
+
/**
|
|
21
|
+
* Read-only layers above the shard size paint through shard sources.
|
|
22
|
+
*
|
|
23
|
+
* Trace-enabled layers are excluded: the trace timeline diff
|
|
24
|
+
* (`trace-timeline.ts`) updates trace points through one source, and routing
|
|
25
|
+
* those updates to the owning shard is TEAM-7583's rewrite. Enabling trace on
|
|
26
|
+
* a sharded layer un-shards it on the next full sync; disabling re-shards it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isShardEligible(layer: Pick<Layer, 'readOnly' | 'traceConfig'>, featureCount: number, shardSize: number): boolean;
|
|
29
|
+
export interface ShardRange {
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Contiguous `[start, end)` slices of `count` features. `shardSize` must be a
|
|
35
|
+
* positive finite integer; `Infinity` never reaches here, eligibility fails first.
|
|
36
|
+
*/
|
|
37
|
+
export declare function shardRanges(count: number, shardSize: number): ShardRange[];
|
|
38
|
+
export declare function shardSourceId(layerId: string, index: number): string;
|
|
39
|
+
/**
|
|
40
|
+
* Inverse of `shardSourceId`. Splits on the LAST `:` so layer ids that
|
|
41
|
+
* themselves contain `:` round-trip.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseShardSourceId(sourceId: string): {
|
|
44
|
+
layerId: string;
|
|
45
|
+
index: number;
|
|
46
|
+
} | null;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve the `readOnlyShardSize` prop, mirroring `resolveFeatureCap`:
|
|
49
|
+
* `Infinity` disables sharding, anything unusable warns once and falls back.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveShardSize(value: number | undefined): number;
|
|
52
|
+
//# sourceMappingURL=shard-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shard-constants.d.ts","sourceRoot":"","sources":["../../../client/src/lib/shard-constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAAC,EAC9C,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAKT;AAOD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAO1E;AAID,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAS9F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAWlE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Layer } from '@/components/layers-panel';
|
|
2
|
+
/**
|
|
3
|
+
* Everything a shard pass reads that would change what it paints.
|
|
4
|
+
*
|
|
5
|
+
* The full sync runs on every `layers` identity change — including the one
|
|
6
|
+
* that clears `importing` at the end of a pass. Without a skip, completion →
|
|
7
|
+
* `setLayers` → full sync → new pass → completion loops forever, and every
|
|
8
|
+
* unrelated panel action would repaint the whole layer. So a pass records the
|
|
9
|
+
* inputs it painted from, and the next sync compares: equal means the shards
|
|
10
|
+
* on screen are already correct and only selection/timeline state needs
|
|
11
|
+
* reconciling through the fast paths.
|
|
12
|
+
*
|
|
13
|
+
* Selection and timeline are deliberately absent: they are reconciled per
|
|
14
|
+
* shard by the fast-path diffs, not by repainting.
|
|
15
|
+
*/
|
|
16
|
+
export interface ShardFingerprint {
|
|
17
|
+
/** By identity — `readOnlyFeatures` arrays are copy-on-write, so a new array means new content. */
|
|
18
|
+
features: readonly GeoJSON.Feature[];
|
|
19
|
+
visualConfig: Layer['visualConfig'];
|
|
20
|
+
heatmapConfig: Layer['heatmapConfig'];
|
|
21
|
+
clusterConfig: Layer['clusterConfig'];
|
|
22
|
+
altitudeDisplayMode: Layer['altitudeDisplayMode'];
|
|
23
|
+
hasAltitudeData: Layer['hasAltitudeData'];
|
|
24
|
+
/** `enableSelection || enableDrawing`: selection styling is inert without one. */
|
|
25
|
+
selectionEnabled: boolean;
|
|
26
|
+
shardSize: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function buildShardFingerprint(layer: Layer, features: readonly GeoJSON.Feature[], selectionEnabled: boolean, shardSize: number): ShardFingerprint;
|
|
29
|
+
/**
|
|
30
|
+
* Field-wise `Object.is`. The config objects are compared by reference: the
|
|
31
|
+
* panel handlers replace them rather than mutating, so a reference change is
|
|
32
|
+
* the signal that something was edited.
|
|
33
|
+
*/
|
|
34
|
+
export declare function shardFingerprintsEqual(a: ShardFingerprint | null | undefined, b: ShardFingerprint | null | undefined): boolean;
|
|
35
|
+
//# sourceMappingURL=shard-fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shard-fingerprint.d.ts","sourceRoot":"","sources":["../../../client/src/lib/shard-fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mGAAmG;IACnG,QAAQ,EAAE,SAAS,OAAO,CAAC,OAAO,EAAE,CAAC;IACrC,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACpC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACtC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACtC,mBAAmB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAClD,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C,kFAAkF;IAClF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,SAAS,OAAO,CAAC,OAAO,EAAE,EACpC,gBAAgB,EAAE,OAAO,EACzB,SAAS,EAAE,MAAM,GAChB,gBAAgB,CAWlB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,EACtC,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GACrC,OAAO,CAYT"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Layer } from '@/components/layers-panel';
|
|
2
|
+
import { type CustomLayerRole } from './custom-layer-stack';
|
|
3
|
+
import { type PaintContext } from './paint-feature';
|
|
4
|
+
import { type SelectionPaintCache } from './selection-diff';
|
|
5
|
+
/** The MapLibre side of a pass, so the pass itself stays testable in node. */
|
|
6
|
+
export interface ShardHost {
|
|
7
|
+
/**
|
|
8
|
+
* `setData` on the shard source, creating source and style stack when absent
|
|
9
|
+
* or when the geometry roles changed.
|
|
10
|
+
*/
|
|
11
|
+
paintShard(index: number, roles: readonly CustomLayerRole[], data: GeoJSON.FeatureCollection): void;
|
|
12
|
+
/** Remove shards at or beyond `index` — the layer's feature count shrank. */
|
|
13
|
+
dropShardsFrom(index: number): void;
|
|
14
|
+
}
|
|
15
|
+
export interface ShardPassInput {
|
|
16
|
+
layer: Layer;
|
|
17
|
+
/** `readOnlyFeatures.get(layer.id)`, by identity — never mutated here. */
|
|
18
|
+
features: readonly GeoJSON.Feature[];
|
|
19
|
+
shardSize: number;
|
|
20
|
+
/**
|
|
21
|
+
* Built per shard, not once per pass: a pass spans ~20 frames and the
|
|
22
|
+
* selection or timeline can change meanwhile, so each shard paints with the
|
|
23
|
+
* state current when its turn comes.
|
|
24
|
+
*/
|
|
25
|
+
contextForShard: () => PaintContext;
|
|
26
|
+
host: ShardHost;
|
|
27
|
+
yieldFrame: () => Promise<void>;
|
|
28
|
+
/** Generation check: false once a newer pass (or teardown) supersedes this one. */
|
|
29
|
+
isCurrent: () => boolean;
|
|
30
|
+
onShardPainted?: (index: number, cache: SelectionPaintCache, arrowLines: GeoJSON.Feature[]) => void;
|
|
31
|
+
onProgress?: (painted: number, total: number) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface ShardPassResult {
|
|
34
|
+
completed: boolean;
|
|
35
|
+
shardCount: number;
|
|
36
|
+
caches: SelectionPaintCache[];
|
|
37
|
+
arrowLines: GeoJSON.Feature[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Paint one large read-only layer through its shard sources, one shard per
|
|
41
|
+
* animation frame.
|
|
42
|
+
*
|
|
43
|
+
* The invariant this exists to hold: no MapLibre call ever carries more than
|
|
44
|
+
* one shard, so the worst main-thread task is one 10k `setData` (~30 ms)
|
|
45
|
+
* instead of one 200k `setData` (~1 s). See `shard-constants.ts` for the
|
|
46
|
+
* measurements.
|
|
47
|
+
*/
|
|
48
|
+
export declare function runShardPass(input: ShardPassInput): Promise<ShardPassResult>;
|
|
49
|
+
//# sourceMappingURL=shard-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shard-pipeline.d.ts","sourceRoot":"","sources":["../../../client/src/lib/shard-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAC;AAG1B,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,eAAe,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IACpG,6EAA6E;IAC7E,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,0EAA0E;IAC1E,QAAQ,EAAE,SAAS,OAAO,CAAC,OAAO,EAAE,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,EAAE,MAAM,YAAY,CAAC;IACpC,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,mFAAmF;IACnF,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC;IACpG,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CA8ClF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { LayerSpecification, SourceSpecification } from 'maplibre-gl';
|
|
2
|
+
import { type CustomLayerRole } from './custom-layer-stack';
|
|
3
|
+
import { type SelectionPaintCache, type UpdatableGeoJSONSource } from './selection-diff';
|
|
4
|
+
import type { ShardHost } from './shard-pipeline';
|
|
5
|
+
/** The slice of the MapLibre style the registry drives, so it tests in node. */
|
|
6
|
+
export interface StyleHost {
|
|
7
|
+
getSource(id: string): unknown | undefined;
|
|
8
|
+
addSource(id: string, spec: SourceSpecification): void;
|
|
9
|
+
removeSource(id: string): void;
|
|
10
|
+
getLayer(id: string): unknown | undefined;
|
|
11
|
+
addLayer(spec: LayerSpecification, beforeId?: string): void;
|
|
12
|
+
removeLayer(id: string): void;
|
|
13
|
+
setLayoutProperty(id: string, name: string, value: unknown): void;
|
|
14
|
+
setData(sourceId: string, data: GeoJSON.FeatureCollection): void;
|
|
15
|
+
}
|
|
16
|
+
export interface ShardStack {
|
|
17
|
+
sourceId: string;
|
|
18
|
+
layerIds: string[];
|
|
19
|
+
roles: CustomLayerRole[];
|
|
20
|
+
}
|
|
21
|
+
export interface ShardLayerState {
|
|
22
|
+
layerId: string;
|
|
23
|
+
stacks: ShardStack[];
|
|
24
|
+
/** Index-aligned with `stacks`; sparse while a pass is still landing. */
|
|
25
|
+
caches: Array<SelectionPaintCache | undefined>;
|
|
26
|
+
fingerprint: unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Paint inputs of the pass currently landing, or null. A sync that changes
|
|
29
|
+
* nothing this layer paints from (a rename, another layer's toggle) compares
|
|
30
|
+
* against it and leaves the running pass alone instead of restarting it.
|
|
31
|
+
*/
|
|
32
|
+
inFlightFingerprint: unknown;
|
|
33
|
+
generation: number;
|
|
34
|
+
visible: boolean;
|
|
35
|
+
/** Styled arrow lines the last completed pass painted; the overlays render them with the shared source's. */
|
|
36
|
+
arrowLines: GeoJSON.Feature[];
|
|
37
|
+
}
|
|
38
|
+
export interface ShardRegistryHooks {
|
|
39
|
+
/** The canvas binds its hover/cursor handlers to the new layer ids. */
|
|
40
|
+
onLayersAdded(layerIds: string[]): void;
|
|
41
|
+
/** Called BEFORE the layers go away, so handlers unbind while the ids still exist. */
|
|
42
|
+
onLayersRemoving(layerIds: string[]): void;
|
|
43
|
+
/** `lastLabelVisibility`, so a shard born into a dense viewport is not the one layer that labels. */
|
|
44
|
+
labelsVisible(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* A source and its style-layer stack were just added. The canvas moves the
|
|
47
|
+
* given label layers ahead of the basemap symbols here, the way it does for
|
|
48
|
+
* the shared stack on every basemap load: MapLibre runs label collision in
|
|
49
|
+
* painter order, so a label layer left behind the basemap text loses to it.
|
|
50
|
+
* Only the new stack's label ids are passed, so a pass costs one move per
|
|
51
|
+
* shard rather than re-moving every earlier shard's labels each time.
|
|
52
|
+
*/
|
|
53
|
+
onStackCreated?(labelLayerIds: string[]): void;
|
|
54
|
+
}
|
|
55
|
+
export interface ShardRegistry {
|
|
56
|
+
registerShared(layerIds: string[]): void;
|
|
57
|
+
state(layerId: string): ShardLayerState | undefined;
|
|
58
|
+
ensure(layerId: string): ShardLayerState;
|
|
59
|
+
/** A `ShardHost` bound to one layer, for `runShardPass`. */
|
|
60
|
+
hostFor(layerId: string): ShardHost;
|
|
61
|
+
setVisible(layerId: string, visible: boolean): void;
|
|
62
|
+
/** Drop every source, layer and the state for a layer; a pass in flight stops at its next shard. */
|
|
63
|
+
remove(layerId: string): void;
|
|
64
|
+
/** Every layer id the registry holds state for, live or not. */
|
|
65
|
+
trackedLayerIds(): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Arrow lines of the sharded layers `isVisible` accepts, for the heads/labels
|
|
68
|
+
* overlays. Visibility comes from the caller's layer records, not the registry:
|
|
69
|
+
* the full sync reads this before it tells the registry about a hide.
|
|
70
|
+
*/
|
|
71
|
+
arrowLines(isVisible: (layerId: string) => boolean): GeoJSON.Feature[];
|
|
72
|
+
/** Ids of every live source the registry owns, shards only. */
|
|
73
|
+
shardSourceIds(): string[];
|
|
74
|
+
/** `visibleLayersOnly` leaves out shards of hidden layers: the auto-label effect must not turn a hidden layer's labels back on. */
|
|
75
|
+
labelLayerIds(kind: 'unpinned' | 'pinned' | 'all', opts?: {
|
|
76
|
+
visibleLayersOnly?: boolean;
|
|
77
|
+
}): string[];
|
|
78
|
+
/** What the click / hover / context-menu queries pass to `queryRenderedFeatures`. */
|
|
79
|
+
interactiveLayerIds(): string[];
|
|
80
|
+
/** The source for a shard index, for the per-shard fast-path diffs. */
|
|
81
|
+
sourceFor(layerId: string, index: number): unknown | undefined;
|
|
82
|
+
sourceById(sourceId: string): unknown | undefined;
|
|
83
|
+
/** Visit every shard that has been painted; stops at the first false. */
|
|
84
|
+
everyPaintedShard(visit: (cache: SelectionPaintCache, sourceId: string) => boolean): boolean;
|
|
85
|
+
}
|
|
86
|
+
export declare function createShardRegistry(host: StyleHost, hooks: ShardRegistryHooks): ShardRegistry;
|
|
87
|
+
/**
|
|
88
|
+
* Bring one layer's painted shards up to date with the current selection and
|
|
89
|
+
* timeline state without repainting them, for a pass the fingerprint skipped.
|
|
90
|
+
*
|
|
91
|
+
* Returns false when any shard cannot be diffed (no cache yet, duplicate ids,
|
|
92
|
+
* missing source), so the caller repaints instead. Shards a pass has not
|
|
93
|
+
* reached yet have no cache and are skipped: they paint with the current state
|
|
94
|
+
* when their turn comes.
|
|
95
|
+
*/
|
|
96
|
+
export declare function reconcileShardCaches(registry: ShardRegistry, layerId: string, expectedShards: number, selectedIds: ReadonlySet<string>, visibleIds: ReadonlySet<string> | null): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Run a fast-path diff over every painted shard of every layer.
|
|
99
|
+
*
|
|
100
|
+
* Returns false as soon as one shard cannot be diffed, so the caller falls
|
|
101
|
+
* back to a full sync — matching how the shared cache already behaves. A shard
|
|
102
|
+
* a pass has not painted yet has no cache and is skipped: it picks the current
|
|
103
|
+
* state up when its turn comes.
|
|
104
|
+
*/
|
|
105
|
+
export declare function forEachShardCache(registry: ShardRegistry | null, apply: (cache: SelectionPaintCache, source: UpdatableGeoJSONSource) => boolean): boolean;
|
|
106
|
+
//# sourceMappingURL=shard-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shard-registry.d.ts","sourceRoot":"","sources":["../../../client/src/lib/shard-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAGL,KAAK,eAAe,EAIrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SA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AC,KAAK,EAAE,CAAC,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC;CAC9F;AAOD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAgN7F;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,EACvB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,GACrC,OAAO,CAaT;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,aAAa,GAAG,IAAI,EAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,sBAAsB,KAAK,OAAO,GAC7E,OAAO,CAOT"}
|
package/package.json
CHANGED
package/vite-plugin.d.mts
CHANGED
package/vite-plugin.mjs
CHANGED
|
@@ -9,6 +9,18 @@ const FONT_VARIANTS = fs.existsSync(fontsDir)
|
|
|
9
9
|
? fs.readdirSync(fontsDir).filter(f => fs.statSync(join(fontsDir, f)).isDirectory())
|
|
10
10
|
: [];
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Font stacks the component's own label layers request. Static hosting can't
|
|
14
|
+
* resolve composite stacks the way the dev middleware does, so the build
|
|
15
|
+
* emits each of these as a copy of its resolved Noto Sans variant.
|
|
16
|
+
*/
|
|
17
|
+
export const COMPONENT_FONT_STACKS = [
|
|
18
|
+
'Montserrat Regular,Noto Sans Regular',
|
|
19
|
+
'Montserrat Medium,Noto Sans Regular',
|
|
20
|
+
'Montserrat SemiBold,Noto Sans Regular',
|
|
21
|
+
'Open Sans Bold,Arial Unicode MS Bold',
|
|
22
|
+
];
|
|
23
|
+
|
|
12
24
|
/**
|
|
13
25
|
* Map a composite font stack (e.g. "Montserrat Regular,Open Sans Regular,Noto Sans Regular")
|
|
14
26
|
* to the best locally available Noto Sans variant by inspecting keywords in the stack.
|
|
@@ -50,12 +62,35 @@ function fontsMiddleware(req, res, next) {
|
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
|
|
65
|
+
/** Every glyph file the build emits, keyed by its path under `fonts/`. */
|
|
66
|
+
export function fontAssets() {
|
|
67
|
+
const assets = [];
|
|
68
|
+
const addStack = (stack, variant) => {
|
|
69
|
+
for (const rangeFile of fs.readdirSync(join(fontsDir, variant))) {
|
|
70
|
+
if (!rangeFile.endsWith('.pbf')) continue;
|
|
71
|
+
assets.push({ fileName: `fonts/${stack}/${rangeFile}`, source: fs.readFileSync(join(fontsDir, variant, rangeFile)) });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
for (const variant of FONT_VARIANTS) addStack(variant, variant);
|
|
75
|
+
for (const stack of COMPONENT_FONT_STACKS) addStack(stack, resolveFontStack(stack));
|
|
76
|
+
return assets;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function mountFonts(server) {
|
|
80
|
+
server.middlewares.use('/fonts', fontsMiddleware);
|
|
81
|
+
const base = server.config.base;
|
|
82
|
+
if (base && base !== '/') server.middlewares.use(`${base.replace(/\/$/, '')}/fonts`, fontsMiddleware);
|
|
83
|
+
}
|
|
84
|
+
|
|
53
85
|
/**
|
|
54
|
-
* Vite plugin that
|
|
55
|
-
*
|
|
86
|
+
* Vite plugin that makes the map component's bundled glyph fonts available
|
|
87
|
+
* to the host app: served at `/fonts/` and `<base>fonts/` in dev and preview,
|
|
88
|
+
* and emitted into the build output as `<outDir>/fonts/`, so production
|
|
89
|
+
* serves them from `<base>fonts/` alongside the rest of the bundle.
|
|
56
90
|
*
|
|
57
91
|
* Composite font stacks from tile styles (e.g. "Montserrat Regular,Open Sans Regular")
|
|
58
|
-
* are
|
|
92
|
+
* are mapped to the bundled Noto Sans variants by the dev middleware; the
|
|
93
|
+
* build emits the stacks the component itself uses (COMPONENT_FONT_STACKS).
|
|
59
94
|
*
|
|
60
95
|
* Usage:
|
|
61
96
|
* import { mapFontsPlugin } from '@octostar/map-component/vite';
|
|
@@ -64,11 +99,10 @@ function fontsMiddleware(req, res, next) {
|
|
|
64
99
|
export function mapFontsPlugin() {
|
|
65
100
|
return {
|
|
66
101
|
name: 'octostar-map-fonts',
|
|
67
|
-
configureServer
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
server.middlewares.use('/fonts', fontsMiddleware);
|
|
102
|
+
configureServer: mountFonts,
|
|
103
|
+
configurePreviewServer: mountFonts,
|
|
104
|
+
generateBundle() {
|
|
105
|
+
for (const { fileName, source } of fontAssets()) this.emitFile({ type: 'asset', fileName, source });
|
|
72
106
|
},
|
|
73
107
|
};
|
|
74
108
|
}
|