@nebula-spatial/cad-loader 0.2.2 → 0.2.4

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.
@@ -5,7 +5,7 @@ export type FetchExternalVariantSidecarsOptions = {
5
5
  readonly requiredVariantIds: readonly number[];
6
6
  readonly fetchImpl?: typeof fetch;
7
7
  readonly signal?: AbortSignal;
8
- readonly concurrency?: number;
8
+ readonly onBuffer?: (variantId: number, buffer: ArrayBuffer) => void | Promise<void>;
9
9
  };
10
10
  export declare function fetchExternalVariantSidecars(options: FetchExternalVariantSidecarsOptions): Promise<{
11
11
  readonly buffers: ReadonlyMap<number, ArrayBuffer>;
@@ -43,7 +43,9 @@ export interface GeoLoaderPipelineAdapterInput {
43
43
  externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
44
44
  requiredExternalVariantIds?: ReadonlySet<number>;
45
45
  externalVariantGeometryFetchIds?: ReadonlySet<number>;
46
+ deferExternalVariantGeometry?: boolean;
46
47
  externalVariantDeltaOnly?: boolean;
48
+ cacheDocument?: boolean;
47
49
  }
48
50
  export interface GeoLoaderPipelineSession {
49
51
  completion: Promise<void>;
@@ -53,6 +55,12 @@ export interface GeoLoaderPipelineSession {
53
55
  dispose: () => void;
54
56
  }
55
57
  export interface GeoLoaderPipelineAdapter {
58
+ /**
59
+ * Reusable worker adapters expose this once the worker owns the document's
60
+ * main buffer. Builders may then pass the caller-owned buffer by reference;
61
+ * the adapter will omit it from the parse message and use its retained copy.
62
+ */
63
+ readonly mainBufferReuseReady?: boolean;
56
64
  start(input: GeoLoaderPipelineAdapterInput, emit: GeoLoaderPipelineEmit): GeoLoaderPipelineSession;
57
65
  }
58
66
  export interface RunGeoLoaderPipelineOptions {
@@ -62,6 +70,7 @@ export interface RunGeoLoaderPipelineOptions {
62
70
  signal?: AbortSignal;
63
71
  beforeTextAppend?: BeforeTextAppend;
64
72
  beforeFinalize?: () => void | Promise<void>;
73
+ onFirstRenderableAppend?: () => void;
65
74
  hiddenInstanceIds?: ReadonlySet<number>;
66
75
  keepTextsForHiddenInstances?: boolean;
67
76
  loadBlocks?: boolean;
@@ -71,7 +80,9 @@ export interface RunGeoLoaderPipelineOptions {
71
80
  externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
72
81
  requiredExternalVariantIds?: ReadonlySet<number>;
73
82
  externalVariantGeometryFetchIds?: ReadonlySet<number>;
83
+ deferExternalVariantGeometry?: boolean;
74
84
  externalVariantDeltaOnly?: boolean;
85
+ cacheDocument?: boolean;
75
86
  appendExternalVariantDelta?: boolean;
76
87
  onYield?: YieldCallback;
77
88
  scheduler?: Partial<FrameBudgetSchedulerOptions>;
@@ -3,5 +3,11 @@ export interface WorkerGeoLoaderAdapterOptions {
3
3
  workerUrl?: string | URL;
4
4
  workerFactory?: () => Worker;
5
5
  }
6
+ export interface DisposableGeoLoaderPipelineAdapter extends GeoLoaderPipelineAdapter {
7
+ /** True when a reusable worker owns the main buffer for the current document. */
8
+ readonly mainBufferReuseReady: boolean;
9
+ dispose(): void;
10
+ }
6
11
  export declare function canUsePrepareWorker(workerFactory?: () => Worker): boolean;
7
12
  export declare function createWorkerGeoLoaderAdapter(options?: WorkerGeoLoaderAdapterOptions): GeoLoaderPipelineAdapter;
13
+ export declare function createReusableWorkerGeoLoaderAdapter(options?: WorkerGeoLoaderAdapterOptions): DisposableGeoLoaderPipelineAdapter;
@@ -1,5 +1,6 @@
1
1
  import type { FrameBudgetSchedulerOptions } from './frame-budget-scheduler';
2
2
  import type { LoaderFlowControlOptions } from './flow-control';
3
+ import { type GeoLoaderPipelineAdapter } from './geo-loader-pipeline';
3
4
  import { GeoNode } from './geo-node';
4
5
  import type { TextEntity } from '../../shared/types';
5
6
  import type { ExternalVariantFetchSource } from '../geo-loader';
@@ -15,6 +16,7 @@ export interface BuildGeoNodeOptions {
15
16
  preferWorker?: boolean;
16
17
  workerUrl?: string | URL;
17
18
  workerFactory?: () => Worker;
19
+ workerAdapter?: GeoLoaderPipelineAdapter;
18
20
  keepTextsForHiddenInstances?: boolean;
19
21
  loadBlocks?: boolean;
20
22
  maxExpandedInstanceVertices?: number;
@@ -22,7 +24,10 @@ export interface BuildGeoNodeOptions {
22
24
  externalVariantBuffers?: ReadonlyMap<number, ArrayBuffer>;
23
25
  requiredExternalVariantIds?: ReadonlySet<number> | readonly number[];
24
26
  externalVariantGeometryFetchIds?: ReadonlySet<number> | readonly number[];
27
+ deferExternalVariantGeometry?: boolean;
25
28
  externalVariantDeltaOnly?: boolean;
29
+ cacheDocument?: boolean;
30
+ onFirstRenderableAppend?: () => void;
26
31
  }
27
32
  export declare function buildGeoNodeFromBuffer(node: GeoNode, buf: ArrayBuffer, onYield?: YieldCallback, options?: BuildGeoNodeOptions): Promise<void>;
28
33
  export declare function appendExternalVariantDeltaToGeoNode(node: GeoNode, buf: ArrayBuffer, onYield?: YieldCallback, options?: BuildGeoNodeOptions): Promise<void>;
@@ -5,7 +5,13 @@ import type { ExternalVariantFetchSource } from '../geo-loader';
5
5
  export type { GeometryKind, PreparedLayerChunk } from './geo-prepare';
6
6
  export interface GeoPrepareParseRequest {
7
7
  type: 'parse';
8
- buffer: ArrayBuffer;
8
+ /**
9
+ * Main DXB3 payload. Omitted when the worker already retained the document
10
+ * buffer from an earlier parse in the same document session.
11
+ */
12
+ buffer?: ArrayBuffer;
13
+ /** Use the main buffer retained by the worker instead of transferring one. */
14
+ useRetainedMainBuffer?: boolean;
9
15
  hiddenInstanceIds?: number[];
10
16
  keepTextsForHiddenInstances?: boolean;
11
17
  loadBlocks?: boolean;
@@ -20,6 +26,7 @@ export interface GeoPrepareParseRequest {
20
26
  requiredExternalVariantIds?: number[];
21
27
  externalVariantGeometryFetchIds?: number[];
22
28
  externalVariantDeltaOnly?: boolean;
29
+ cacheDocument?: boolean;
23
30
  }
24
31
  export interface GeoPrepareGrantMessage {
25
32
  type: 'grant';
@@ -80,6 +80,23 @@ export interface CadSessionDemandProgressEvent {
80
80
  readonly loaded: number;
81
81
  readonly settled: boolean;
82
82
  }
83
+ /** A monotonic start clock plus load milestones elapsed from session creation. */
84
+ export interface CadSessionLoadTiming {
85
+ readonly startedAtMs: number;
86
+ readonly mainBufferLoadedMs?: number;
87
+ readonly headerReadyMs?: number;
88
+ readonly initialSidecarFetchStartedMs?: number;
89
+ readonly firstRenderableReadyMs?: number;
90
+ readonly baseGeometryReadyMs?: number;
91
+ readonly initialContentReadyMs?: number;
92
+ readonly initialSidecarFetchSettledMs?: number;
93
+ readonly initialExternalContentReadyMs?: number;
94
+ readonly initialViewportSettledMs?: number;
95
+ readonly failedMs?: number;
96
+ readonly initialRequiredVariantCount: number;
97
+ readonly initialSidecarLoadedCount: number;
98
+ readonly initialSidecarBytes: number;
99
+ }
83
100
  export interface CadSessionPhaseChangeEvent {
84
101
  readonly phase: CadSessionPhase;
85
102
  }
@@ -91,6 +108,9 @@ export interface CadSessionEventMap {
91
108
  'content-appended': CadSessionContentAppendedEvent;
92
109
  'initial-content-ready': void;
93
110
  'demand-progress': CadSessionDemandProgressEvent;
111
+ 'load-timing': {
112
+ readonly timing: CadSessionLoadTiming;
113
+ };
94
114
  'phase-change': CadSessionPhaseChangeEvent;
95
115
  'non-fatal-error': CadSessionErrorEvent;
96
116
  'fatal-error': CadSessionErrorEvent;
@@ -124,6 +144,7 @@ export interface CadInsertUsageSummary {
124
144
  }
125
145
  export interface CadDocumentSession {
126
146
  readonly phase: CadSessionPhase;
147
+ readonly loadTiming: CadSessionLoadTiming;
127
148
  readonly headerReady: Promise<CadDocumentHeader>;
128
149
  readonly initialContentReady: Promise<void>;
129
150
  setViewportDemand(demand: CadViewportDemand): void;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Options accepted by Troika's global text builder configuration.
3
+ *
4
+ * This is intentionally a thin public surface over Troika. The configuration
5
+ * remains global to the module instance and must be supplied before the first
6
+ * font request. No defaults are applied here so an omitted configuration keeps
7
+ * Troika's original built-in behavior unchanged.
8
+ */
9
+ export interface CadTextBuilderOptions {
10
+ readonly defaultFontURL?: string;
11
+ readonly unicodeFontsURL?: string;
12
+ readonly sdfGlyphSize?: number;
13
+ readonly sdfMargin?: number;
14
+ readonly sdfExponent?: number;
15
+ readonly textureWidth?: number;
16
+ readonly useWorker?: boolean;
17
+ }
18
+ /**
19
+ * Configures the Troika text builder used by cad-loader.
20
+ *
21
+ * This function deliberately does not add its own lifecycle, retry, fallback,
22
+ * or per-viewer state. Troika remains responsible for its existing
23
+ * module-level, one-time configuration semantics.
24
+ */
25
+ export declare function configureCadTextBuilder(options: CadTextBuilderOptions): void;