@nice2dev/spatial-core 1.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.
Files changed (82) hide show
  1. package/README.md +160 -0
  2. package/dist/bim/index.d.ts +366 -0
  3. package/dist/bim/index.d.ts.map +1 -0
  4. package/dist/bim/index.js +60 -0
  5. package/dist/bim/index.js.map +1 -0
  6. package/dist/cad/index.d.ts +329 -0
  7. package/dist/cad/index.d.ts.map +1 -0
  8. package/dist/cad/index.js +124 -0
  9. package/dist/cad/index.js.map +1 -0
  10. package/dist/ecad/index.d.ts +316 -0
  11. package/dist/ecad/index.d.ts.map +1 -0
  12. package/dist/ecad/index.js +11 -0
  13. package/dist/ecad/index.js.map +1 -0
  14. package/dist/export/index.d.ts +93 -0
  15. package/dist/export/index.d.ts.map +1 -0
  16. package/dist/export/index.js +522 -0
  17. package/dist/export/index.js.map +1 -0
  18. package/dist/floor-plan/index.d.ts +248 -0
  19. package/dist/floor-plan/index.d.ts.map +1 -0
  20. package/dist/floor-plan/index.js +228 -0
  21. package/dist/floor-plan/index.js.map +1 -0
  22. package/dist/grid/index.d.ts +160 -0
  23. package/dist/grid/index.d.ts.map +1 -0
  24. package/dist/grid/index.js +319 -0
  25. package/dist/grid/index.js.map +1 -0
  26. package/dist/import/import.worker.d.ts +28 -0
  27. package/dist/import/import.worker.d.ts.map +1 -0
  28. package/dist/import/import.worker.js +52 -0
  29. package/dist/import/import.worker.js.map +1 -0
  30. package/dist/import/index.d.ts +111 -0
  31. package/dist/import/index.d.ts.map +1 -0
  32. package/dist/import/index.js +1092 -0
  33. package/dist/import/index.js.map +1 -0
  34. package/dist/import/workerImport.d.ts +56 -0
  35. package/dist/import/workerImport.d.ts.map +1 -0
  36. package/dist/import/workerImport.js +207 -0
  37. package/dist/import/workerImport.js.map +1 -0
  38. package/dist/index.d.ts +29 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +86 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/interior/index.d.ts +241 -0
  43. package/dist/interior/index.d.ts.map +1 -0
  44. package/dist/interior/index.js +101 -0
  45. package/dist/interior/index.js.map +1 -0
  46. package/dist/measurement/index.d.ts +186 -0
  47. package/dist/measurement/index.d.ts.map +1 -0
  48. package/dist/measurement/index.js +400 -0
  49. package/dist/measurement/index.js.map +1 -0
  50. package/dist/objects/index.d.ts +288 -0
  51. package/dist/objects/index.d.ts.map +1 -0
  52. package/dist/objects/index.js +463 -0
  53. package/dist/objects/index.js.map +1 -0
  54. package/dist/serialization/index.d.ts +421 -0
  55. package/dist/serialization/index.d.ts.map +1 -0
  56. package/dist/serialization/index.js +412 -0
  57. package/dist/serialization/index.js.map +1 -0
  58. package/dist/topology/index.d.ts +252 -0
  59. package/dist/topology/index.d.ts.map +1 -0
  60. package/dist/topology/index.js +525 -0
  61. package/dist/topology/index.js.map +1 -0
  62. package/dist/transitions/index.d.ts +141 -0
  63. package/dist/transitions/index.d.ts.map +1 -0
  64. package/dist/transitions/index.js +160 -0
  65. package/dist/transitions/index.js.map +1 -0
  66. package/dist/unified/index.d.ts +225 -0
  67. package/dist/unified/index.d.ts.map +1 -0
  68. package/dist/unified/index.js +474 -0
  69. package/dist/unified/index.js.map +1 -0
  70. package/dist/virtualization/QuadTree.d.ts +68 -0
  71. package/dist/virtualization/QuadTree.d.ts.map +1 -0
  72. package/dist/virtualization/QuadTree.js +228 -0
  73. package/dist/virtualization/QuadTree.js.map +1 -0
  74. package/dist/virtualization/ViewportCulling.d.ts +92 -0
  75. package/dist/virtualization/ViewportCulling.d.ts.map +1 -0
  76. package/dist/virtualization/ViewportCulling.js +123 -0
  77. package/dist/virtualization/ViewportCulling.js.map +1 -0
  78. package/dist/virtualization/index.d.ts +9 -0
  79. package/dist/virtualization/index.d.ts.map +1 -0
  80. package/dist/virtualization/index.js +9 -0
  81. package/dist/virtualization/index.js.map +1 -0
  82. package/package.json +64 -0
@@ -0,0 +1,412 @@
1
+ /**
2
+ * Serialization — .nsp.json (NiceToDev Spatial Plan) format.
3
+ *
4
+ * Unified serialization format for all spatial documents:
5
+ * - Floor plans
6
+ * - Network topologies
7
+ * - CAD drawings
8
+ * - Interior designs
9
+ * - Game scenes
10
+ *
11
+ * @module @nice2dev/spatial-core/serialization
12
+ */
13
+ /* ================================================================
14
+ JSON SCHEMA
15
+ ================================================================ */
16
+ /** JSON Schema for .nsp.json validation. */
17
+ export const NSP_SCHEMA = {
18
+ $schema: 'http://json-schema.org/draft-07/schema#',
19
+ $id: 'https://nice2dev.com/schemas/nsp-v1.json',
20
+ title: 'NiceToDev Spatial Plan',
21
+ description: 'Unified format for floor plans, network topologies, CAD drawings, and spatial documents',
22
+ type: 'object',
23
+ required: ['version', 'type', 'metadata', 'floors', 'settings'],
24
+ properties: {
25
+ $schema: { type: 'string' },
26
+ version: {
27
+ type: 'string',
28
+ pattern: '^\\d+\\.\\d+\\.\\d+$',
29
+ },
30
+ type: {
31
+ type: 'string',
32
+ enum: ['floor-plan', 'network-topology', 'infrastructure', 'cad', 'interior', 'game-scene'],
33
+ },
34
+ metadata: {
35
+ type: 'object',
36
+ required: ['id', 'name', 'created', 'modified'],
37
+ properties: {
38
+ id: { type: 'string' },
39
+ name: { type: 'string' },
40
+ description: { type: 'string' },
41
+ author: { type: 'string' },
42
+ created: { type: 'string', format: 'date-time' },
43
+ modified: { type: 'string', format: 'date-time' },
44
+ tags: { type: 'array', items: { type: 'string' } },
45
+ thumbnail: { type: 'string' },
46
+ },
47
+ },
48
+ building: {
49
+ type: 'object',
50
+ properties: {
51
+ name: { type: 'string' },
52
+ address: { type: 'string' },
53
+ type: { type: 'string' },
54
+ totalArea: { type: 'number' },
55
+ floors: { type: 'integer' },
56
+ yearBuilt: { type: 'integer' },
57
+ coordinates: {
58
+ type: 'object',
59
+ properties: {
60
+ lat: { type: 'number' },
61
+ lng: { type: 'number' },
62
+ },
63
+ },
64
+ },
65
+ },
66
+ floors: {
67
+ type: 'array',
68
+ items: {
69
+ type: 'object',
70
+ required: ['id', 'name', 'level', 'bounds', 'layers'],
71
+ properties: {
72
+ id: { type: 'string' },
73
+ name: { type: 'string' },
74
+ level: { type: 'integer' },
75
+ elevation: { type: 'number' },
76
+ ceilingHeight: { type: 'number' },
77
+ bounds: {
78
+ type: 'object',
79
+ properties: {
80
+ x: { type: 'number' },
81
+ y: { type: 'number' },
82
+ width: { type: 'number' },
83
+ height: { type: 'number' },
84
+ },
85
+ },
86
+ layers: { type: 'array' },
87
+ },
88
+ },
89
+ },
90
+ settings: {
91
+ type: 'object',
92
+ properties: {
93
+ units: { type: 'string', enum: ['metric', 'imperial'] },
94
+ scale: { type: 'number' },
95
+ grid: { type: 'object' },
96
+ defaultWallHeight: { type: 'number' },
97
+ defaultWallThickness: { type: 'number' },
98
+ precision: { type: 'integer' },
99
+ },
100
+ },
101
+ },
102
+ };
103
+ /* ================================================================
104
+ SERIALIZATION
105
+ ================================================================ */
106
+ /**
107
+ * Serialize floor plan document to JSON string.
108
+ */
109
+ export function serialize(document, options = {}) {
110
+ const { pretty = false, includeSchema = true, excludeEmptyLayers = false, includeMetadata = true, } = options;
111
+ // Deep clone to avoid mutation
112
+ const output = JSON.parse(JSON.stringify(document));
113
+ // Add schema reference
114
+ if (includeSchema && !output.$schema) {
115
+ output.$schema = 'https://nice2dev.com/schemas/nsp-v1.json';
116
+ }
117
+ // Update modified timestamp
118
+ if (includeMetadata) {
119
+ output.metadata = output.metadata ?? {
120
+ id: '',
121
+ name: '',
122
+ created: new Date().toISOString(),
123
+ modified: new Date().toISOString(),
124
+ };
125
+ output.metadata.modified = new Date().toISOString();
126
+ }
127
+ // Filter empty layers if requested
128
+ if (excludeEmptyLayers) {
129
+ for (const floor of output.floors) {
130
+ floor.layers = floor.layers.filter((layer) => layer.objects.length > 0);
131
+ }
132
+ }
133
+ return pretty ? JSON.stringify(output, null, 2) : JSON.stringify(output);
134
+ }
135
+ /**
136
+ * Deserialize JSON string to floor plan document.
137
+ */
138
+ export function deserialize(json) {
139
+ try {
140
+ const data = JSON.parse(json);
141
+ const validation = validate(data);
142
+ if (!validation.valid) {
143
+ return {
144
+ success: false,
145
+ errors: validation.errors.map((e) => `${e.path}: ${e.message}`),
146
+ };
147
+ }
148
+ return {
149
+ success: true,
150
+ data,
151
+ warnings: validation.warnings.map((w) => w.message),
152
+ };
153
+ }
154
+ catch (error) {
155
+ return {
156
+ success: false,
157
+ errors: [`Invalid JSON: ${error.message}`],
158
+ };
159
+ }
160
+ }
161
+ /**
162
+ * Validate floor plan document against schema.
163
+ */
164
+ export function validate(document) {
165
+ const errors = [];
166
+ const warnings = [];
167
+ // Required fields
168
+ if (!document.version) {
169
+ errors.push({ path: 'version', message: 'Version is required', code: 'MISSING_VERSION' });
170
+ }
171
+ if (!document.type) {
172
+ errors.push({ path: 'type', message: 'Type is required', code: 'MISSING_TYPE' });
173
+ }
174
+ if (!document.metadata?.id) {
175
+ errors.push({ path: 'metadata.id', message: 'Metadata ID is required', code: 'MISSING_ID' });
176
+ }
177
+ if (!document.metadata?.name) {
178
+ errors.push({
179
+ path: 'metadata.name',
180
+ message: 'Metadata name is required',
181
+ code: 'MISSING_NAME',
182
+ });
183
+ }
184
+ if (!document.floors) {
185
+ errors.push({ path: 'floors', message: 'Floors array is required', code: 'MISSING_FLOORS' });
186
+ }
187
+ if (!document.settings) {
188
+ errors.push({
189
+ path: 'settings',
190
+ message: 'Settings object is required',
191
+ code: 'MISSING_SETTINGS',
192
+ });
193
+ }
194
+ // Version format
195
+ if (document.version && !/^\d+\.\d+\.\d+$/.test(document.version)) {
196
+ warnings.push({
197
+ path: 'version',
198
+ message: 'Version should be in semver format (x.y.z)',
199
+ code: 'INVALID_VERSION_FORMAT',
200
+ });
201
+ }
202
+ // Valid type
203
+ const validTypes = [
204
+ 'floor-plan',
205
+ 'network-topology',
206
+ 'infrastructure',
207
+ 'cad',
208
+ 'interior',
209
+ 'game-scene',
210
+ ];
211
+ if (document.type && !validTypes.includes(document.type)) {
212
+ errors.push({
213
+ path: 'type',
214
+ message: `Invalid type. Must be one of: ${validTypes.join(', ')}`,
215
+ code: 'INVALID_TYPE',
216
+ });
217
+ }
218
+ // Validate floors
219
+ if (document.floors) {
220
+ for (let i = 0; i < document.floors.length; i++) {
221
+ const floor = document.floors[i];
222
+ if (!floor.id) {
223
+ errors.push({
224
+ path: `floors[${i}].id`,
225
+ message: 'Floor ID is required',
226
+ code: 'MISSING_FLOOR_ID',
227
+ });
228
+ }
229
+ if (!floor.name) {
230
+ warnings.push({
231
+ path: `floors[${i}].name`,
232
+ message: 'Floor name is recommended',
233
+ code: 'MISSING_FLOOR_NAME',
234
+ });
235
+ }
236
+ // Check for duplicate IDs
237
+ const ids = new Set();
238
+ for (const layer of floor.layers || []) {
239
+ for (const obj of layer.objects || []) {
240
+ if (ids.has(obj.id)) {
241
+ errors.push({
242
+ path: `floors[${i}].objects`,
243
+ message: `Duplicate object ID: ${obj.id}`,
244
+ code: 'DUPLICATE_ID',
245
+ });
246
+ }
247
+ ids.add(obj.id);
248
+ }
249
+ }
250
+ }
251
+ }
252
+ return {
253
+ valid: errors.length === 0,
254
+ errors,
255
+ warnings,
256
+ };
257
+ }
258
+ /* ================================================================
259
+ IMPORT / EXPORT
260
+ ================================================================ */
261
+ /**
262
+ * Parse .nsp.json file.
263
+ */
264
+ export async function importNSP(file) {
265
+ try {
266
+ const text = await file.text();
267
+ return deserialize(text);
268
+ }
269
+ catch (error) {
270
+ return {
271
+ success: false,
272
+ errors: [`Failed to read file: ${error.message}`],
273
+ };
274
+ }
275
+ }
276
+ /**
277
+ * Create .nsp.json file blob.
278
+ */
279
+ export function exportNSP(document, options) {
280
+ const json = serialize(document, { pretty: true, ...options });
281
+ return new Blob([json], { type: 'application/json' });
282
+ }
283
+ /**
284
+ * Download .nsp.json file.
285
+ */
286
+ export function downloadNSP(document, filename = 'floor-plan.nsp.json', options) {
287
+ const blob = exportNSP(document, options);
288
+ const url = URL.createObjectURL(blob);
289
+ const a = globalThis.document.createElement('a');
290
+ a.href = url;
291
+ a.download = filename.endsWith('.nsp.json') ? filename : `${filename}.nsp.json`;
292
+ globalThis.document.body.appendChild(a);
293
+ a.click();
294
+ globalThis.document.body.removeChild(a);
295
+ URL.revokeObjectURL(url);
296
+ }
297
+ /* ================================================================
298
+ SVG EXPORT
299
+ ================================================================ */
300
+ /**
301
+ * Export floor to SVG.
302
+ */
303
+ export function exportFloorToSVG(floor, options = {}) {
304
+ const { width = floor.bounds.width, height = floor.bounds.height, scale = 1, background = '#ffffff', showGrid = true, showLabels = true, } = options;
305
+ const svgWidth = width * scale;
306
+ const svgHeight = height * scale;
307
+ let svg = `<?xml version="1.0" encoding="UTF-8"?>
308
+ <svg xmlns="http://www.w3.org/2000/svg"
309
+ width="${svgWidth}"
310
+ height="${svgHeight}"
311
+ viewBox="${floor.bounds.x} ${floor.bounds.y} ${width} ${height}">
312
+ <rect x="${floor.bounds.x}" y="${floor.bounds.y}" width="${width}" height="${height}" fill="${background}"/>
313
+ `;
314
+ // Grid
315
+ if (showGrid) {
316
+ svg += ` <defs>
317
+ <pattern id="grid" width="1" height="1" patternUnits="userSpaceOnUse">
318
+ <path d="M 1 0 L 0 0 0 1" fill="none" stroke="#e0e0e0" stroke-width="0.02"/>
319
+ </pattern>
320
+ </defs>
321
+ <rect x="${floor.bounds.x}" y="${floor.bounds.y}" width="${width}" height="${height}" fill="url(#grid)"/>
322
+ `;
323
+ }
324
+ // Render layers in order
325
+ for (const layer of floor.layers) {
326
+ if (!layer.visible) {
327
+ continue;
328
+ }
329
+ svg += ` <g id="layer-${layer.id}" opacity="${layer.opacity}">
330
+ `;
331
+ for (const obj of layer.objects) {
332
+ svg += renderObjectToSVG(obj, showLabels);
333
+ }
334
+ svg += ` </g>
335
+ `;
336
+ }
337
+ svg += '</svg>';
338
+ return svg;
339
+ }
340
+ /**
341
+ * Render a single object to SVG.
342
+ */
343
+ function renderObjectToSVG(obj, showLabels) {
344
+ const { bounds, name, type } = obj;
345
+ if (!bounds) {
346
+ return '';
347
+ }
348
+ let svg = '';
349
+ // Basic rectangle representation
350
+ svg += ` <rect x="${bounds.x}" y="${bounds.y}" width="${bounds.width}" height="${bounds.height}"
351
+ fill="#cccccc" stroke="#333333" stroke-width="0.05"
352
+ data-id="${obj.id}" data-type="${type}"/>
353
+ `;
354
+ // Label
355
+ if (showLabels && name) {
356
+ const cx = bounds.x + bounds.width / 2;
357
+ const cy = bounds.y + bounds.height / 2;
358
+ svg += ` <text x="${cx}" y="${cy}" text-anchor="middle" dominant-baseline="middle"
359
+ font-family="sans-serif" font-size="0.3" fill="#333333">${escapeXml(name)}</text>
360
+ `;
361
+ }
362
+ return svg;
363
+ }
364
+ /**
365
+ * Escape XML special characters.
366
+ */
367
+ function escapeXml(str) {
368
+ return str
369
+ .replace(/&/g, '&amp;')
370
+ .replace(/</g, '&lt;')
371
+ .replace(/>/g, '&gt;')
372
+ .replace(/"/g, '&quot;')
373
+ .replace(/'/g, '&apos;');
374
+ }
375
+ /** Version migrations. */
376
+ const MIGRATIONS = {
377
+ // Example: migrate from 0.9.x to 1.0.0
378
+ '0.9': (doc) => {
379
+ return {
380
+ ...doc,
381
+ version: '1.0.0',
382
+ };
383
+ },
384
+ };
385
+ /**
386
+ * Migrate document to latest version.
387
+ */
388
+ export function migrate(document) {
389
+ let current = document;
390
+ const currentVersion = document.version || '1.0.0';
391
+ const [major, minor] = currentVersion.split('.').map(Number);
392
+ // Apply migrations in order
393
+ for (const [version, migration] of Object.entries(MIGRATIONS)) {
394
+ const [migMajor, migMinor] = version.split('.').map(Number);
395
+ if (major < migMajor || (major === migMajor && minor < migMinor)) {
396
+ current = migration(current);
397
+ }
398
+ }
399
+ return current;
400
+ }
401
+ export default {
402
+ serialize,
403
+ deserialize,
404
+ validate,
405
+ importNSP,
406
+ exportNSP,
407
+ downloadNSP,
408
+ exportFloorToSVG,
409
+ migrate,
410
+ NSP_SCHEMA,
411
+ };
412
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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SACjB,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,QAA2B;IACjD,IAAI,OAAO,GAAG,QAAQ,CAAC;IACvB,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC;IACnD,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE7D,4BAA4B;IAC5B,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAI,KAAK,GAAG,QAAQ,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,QAAQ,CAAC,EAAE,CAAC;YACjE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,eAAe;IACb,SAAS;IACT,WAAW;IACX,QAAQ;IACR,SAAS;IACT,SAAS;IACT,WAAW;IACX,gBAAgB;IAChB,OAAO;IACP,UAAU;CACX,CAAC"}
@@ -0,0 +1,252 @@
1
+ /**
2
+ * Topology Layer — Network topology overlay for floor plans.
3
+ *
4
+ * Provides:
5
+ * - Device connections (cables, wireless links)
6
+ * - Network paths and routing
7
+ * - Cable routing with pathfinding
8
+ * - VLAN visualization
9
+ * - Signal strength / coverage areas
10
+ *
11
+ * @module @nice2dev/spatial-core/topology
12
+ */
13
+ import type { Point2D, BoundingBox } from '../grid';
14
+ /** Connection medium type. */
15
+ export type ConnectionMedium = 'ethernet-cat5' | 'ethernet-cat6' | 'ethernet-cat6a' | 'ethernet-cat7' | 'fiber-single' | 'fiber-multi' | 'coax' | 'power-line' | 'wifi-2.4ghz' | 'wifi-5ghz' | 'wifi-6ghz' | 'bluetooth' | 'zigbee' | 'z-wave' | 'thread' | 'matter' | 'lora' | 'cellular-4g' | 'cellular-5g' | 'serial' | 'usb' | 'hdmi' | 'displayport' | 'custom';
16
+ /** Connection status. */
17
+ export type ConnectionStatus = 'active' | 'inactive' | 'error' | 'degraded' | 'unknown';
18
+ /** Network connection between two devices. */
19
+ export interface TopologyConnection {
20
+ id: string;
21
+ /** Source device ID. */
22
+ sourceId: string;
23
+ /** Source port/interface name. */
24
+ sourcePort?: string;
25
+ /** Target device ID. */
26
+ targetId: string;
27
+ /** Target port/interface name. */
28
+ targetPort?: string;
29
+ /** Connection medium. */
30
+ medium: ConnectionMedium;
31
+ /** Cable/path waypoints (for non-straight routes). */
32
+ waypoints: Point2D[];
33
+ /** Connection status. */
34
+ status: ConnectionStatus;
35
+ /** Bandwidth in Mbps (null for wireless). */
36
+ bandwidth?: number;
37
+ /** Latency in ms. */
38
+ latency?: number;
39
+ /** Signal strength in dBm (for wireless). */
40
+ signalStrength?: number;
41
+ /** VLAN ID. */
42
+ vlanId?: number;
43
+ /** Cable label/ID. */
44
+ cableLabel?: string;
45
+ /** Cable length in meters. */
46
+ cableLength?: number;
47
+ /** Color for visualization. */
48
+ color?: string;
49
+ /** Line style. */
50
+ lineStyle?: 'solid' | 'dashed' | 'dotted';
51
+ /** Line width in pixels. */
52
+ lineWidth?: number;
53
+ /** Custom metadata. */
54
+ metadata?: Record<string, unknown>;
55
+ }
56
+ /** Network path (route between two endpoints). */
57
+ export interface NetworkPath {
58
+ id: string;
59
+ /** Start device ID. */
60
+ startDeviceId: string;
61
+ /** End device ID. */
62
+ endDeviceId: string;
63
+ /** Ordered list of connection IDs forming the path. */
64
+ connectionIds: string[];
65
+ /** Total latency (sum of all connections). */
66
+ totalLatency: number;
67
+ /** Bottleneck bandwidth (minimum of all connections). */
68
+ bottleneckBandwidth: number;
69
+ /** Path status (worst of all connections). */
70
+ status: ConnectionStatus;
71
+ /** Is this the primary path? */
72
+ isPrimary: boolean;
73
+ /** Path color for visualization. */
74
+ color?: string;
75
+ }
76
+ /** Cable route segment (for conduit/tray visualization). */
77
+ export interface CableRoute {
78
+ id: string;
79
+ /** Route type. */
80
+ type: 'conduit' | 'tray' | 'raceway' | 'underground' | 'aerial' | 'wall' | 'ceiling' | 'floor';
81
+ /** Route path points. */
82
+ path: Point2D[];
83
+ /** Route width in cm. */
84
+ width: number;
85
+ /** Capacity (number of cables). */
86
+ capacity: number;
87
+ /** Current fill (number of cables). */
88
+ currentFill: number;
89
+ /** Cables in this route. */
90
+ connectionIds: string[];
91
+ /** Color for visualization. */
92
+ color?: string;
93
+ }
94
+ /** VLAN definition. */
95
+ export interface VLAN {
96
+ id: number;
97
+ name: string;
98
+ description?: string;
99
+ /** Color for visualization. */
100
+ color: string;
101
+ /** Devices in this VLAN. */
102
+ deviceIds: string[];
103
+ /** IP subnet (CIDR notation). */
104
+ subnet?: string;
105
+ /** Gateway IP. */
106
+ gateway?: string;
107
+ /** DHCP enabled. */
108
+ dhcpEnabled?: boolean;
109
+ }
110
+ /** Network zone (security/functional grouping). */
111
+ export interface NetworkZone {
112
+ id: string;
113
+ name: string;
114
+ type: 'dmz' | 'lan' | 'wan' | 'guest' | 'iot' | 'management' | 'voip' | 'storage' | 'custom';
115
+ /** Zone boundary polygon. */
116
+ boundary: Point2D[];
117
+ /** Floor ID. */
118
+ floorId: string;
119
+ /** VLANs in this zone. */
120
+ vlanIds: number[];
121
+ /** Security level (0-10). */
122
+ securityLevel: number;
123
+ /** Color for visualization. */
124
+ color: string;
125
+ /** Firewall rules applied. */
126
+ firewallRules?: string[];
127
+ }
128
+ /** Wireless coverage area. */
129
+ export interface WirelessCoverage {
130
+ id: string;
131
+ /** Access point device ID. */
132
+ accessPointId: string;
133
+ /** Frequency band. */
134
+ band: '2.4ghz' | '5ghz' | '6ghz';
135
+ /** Coverage polygon (signal strength boundary). */
136
+ coveragePolygon: Point2D[];
137
+ /** Signal strength at boundary (dBm). */
138
+ boundarySignalStrength: number;
139
+ /** Estimated max range in meters. */
140
+ maxRange: number;
141
+ /** Channel number. */
142
+ channel?: number;
143
+ /** Transmit power in dBm. */
144
+ txPower?: number;
145
+ /** Color gradient for heatmap. */
146
+ colorGradient?: string[];
147
+ }
148
+ /** Signal measurement point. */
149
+ export interface SignalMeasurement {
150
+ id: string;
151
+ /** Position. */
152
+ position: Point2D;
153
+ /** Access point ID. */
154
+ accessPointId: string;
155
+ /** Signal strength in dBm. */
156
+ signalStrength: number;
157
+ /** Noise level in dBm. */
158
+ noiseLevel?: number;
159
+ /** SNR in dB. */
160
+ snr?: number;
161
+ /** Timestamp. */
162
+ timestamp: string;
163
+ }
164
+ /** Complete network topology layer. */
165
+ export interface TopologyLayer {
166
+ id: string;
167
+ /** Floor ID this topology belongs to. */
168
+ floorId: string;
169
+ /** Network devices (references to spatial objects). */
170
+ deviceIds: string[];
171
+ /** Connections between devices. */
172
+ connections: TopologyConnection[];
173
+ /** Cable routes. */
174
+ cableRoutes: CableRoute[];
175
+ /** VLANs. */
176
+ vlans: VLAN[];
177
+ /** Network zones. */
178
+ zones: NetworkZone[];
179
+ /** Wireless coverage areas. */
180
+ wirelessCoverage: WirelessCoverage[];
181
+ /** Signal measurements (for heatmaps). */
182
+ measurements: SignalMeasurement[];
183
+ /** Computed network paths. */
184
+ paths: NetworkPath[];
185
+ }
186
+ /**
187
+ * Create a new network connection.
188
+ */
189
+ export declare function createConnection(sourceId: string, targetId: string, medium: ConnectionMedium, options?: Partial<TopologyConnection>): TopologyConnection;
190
+ /**
191
+ * Create empty topology layer.
192
+ */
193
+ export declare function createTopologyLayer(floorId: string): TopologyLayer;
194
+ /**
195
+ * Check if medium is wireless.
196
+ */
197
+ export declare function isWireless(medium: ConnectionMedium): boolean;
198
+ /**
199
+ * Get default color for connection medium.
200
+ */
201
+ export declare function getDefaultConnectionColor(medium: ConnectionMedium): string;
202
+ /**
203
+ * Get bandwidth for connection medium (typical max).
204
+ */
205
+ export declare function getTypicalBandwidth(medium: ConnectionMedium): number | null;
206
+ /**
207
+ * Build adjacency graph from connections.
208
+ */
209
+ export declare function buildAdjacencyGraph(connections: TopologyConnection[]): Map<string, Array<{
210
+ deviceId: string;
211
+ connection: TopologyConnection;
212
+ }>>;
213
+ /**
214
+ * Find shortest path between two devices (Dijkstra).
215
+ */
216
+ export declare function findShortestPath(connections: TopologyConnection[], startDeviceId: string, endDeviceId: string, metric?: 'latency' | 'hops' | 'bandwidth'): NetworkPath | null;
217
+ /**
218
+ * Find all paths between two devices (for redundancy analysis).
219
+ */
220
+ export declare function findAllPaths(connections: TopologyConnection[], startDeviceId: string, endDeviceId: string, maxPaths?: number): NetworkPath[];
221
+ /**
222
+ * Calculate optimal cable route avoiding obstacles.
223
+ * Uses A* pathfinding on a grid.
224
+ */
225
+ export declare function calculateCableRoute(start: Point2D, end: Point2D, obstacles: BoundingBox[], gridSize?: number): Point2D[];
226
+ /**
227
+ * Estimate wireless coverage area.
228
+ * Simple model based on distance and obstacles.
229
+ */
230
+ export declare function estimateWirelessCoverage(accessPointPosition: Point2D, txPower: number, band: '2.4ghz' | '5ghz' | '6ghz', _walls: Array<{
231
+ start: Point2D;
232
+ end: Point2D;
233
+ thickness: number;
234
+ }>, boundaryThreshold?: number): WirelessCoverage;
235
+ /**
236
+ * Generate SVG path for a connection with waypoints.
237
+ */
238
+ export declare function connectionToSVGPath(startPos: Point2D, endPos: Point2D, waypoints: Point2D[], curved?: boolean): string;
239
+ /**
240
+ * Generate gradient ID for signal strength visualization.
241
+ */
242
+ export declare function getSignalGradientId(signalStrength: number): string;
243
+ /**
244
+ * Calculate connection statistics for a device.
245
+ */
246
+ export declare function getDeviceConnectionStats(deviceId: string, connections: TopologyConnection[]): {
247
+ totalConnections: number;
248
+ activeConnections: number;
249
+ totalBandwidth: number;
250
+ averageLatency: number;
251
+ };
252
+ //# sourceMappingURL=index.d.ts.map