@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,421 @@
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
+ import type { FloorPlanDocument, Floor } from '../floor-plan/index';
14
+ /** Serialization options. */
15
+ export interface SerializationOptions {
16
+ /** Pretty print JSON (default: false). */
17
+ pretty?: boolean;
18
+ /** Include $schema reference (default: true). */
19
+ includeSchema?: boolean;
20
+ /** Compress object IDs (default: false). */
21
+ compressIds?: boolean;
22
+ /** Exclude empty layers (default: false). */
23
+ excludeEmptyLayers?: boolean;
24
+ /** Include metadata (default: true). */
25
+ includeMetadata?: boolean;
26
+ }
27
+ /** Validation result. */
28
+ export interface ValidationResult {
29
+ valid: boolean;
30
+ errors: ValidationError[];
31
+ warnings: ValidationWarning[];
32
+ }
33
+ /** Validation error. */
34
+ export interface ValidationError {
35
+ path: string;
36
+ message: string;
37
+ code: string;
38
+ }
39
+ /** Validation warning. */
40
+ export interface ValidationWarning {
41
+ path: string;
42
+ message: string;
43
+ code: string;
44
+ }
45
+ /** Import result. */
46
+ export interface ImportResult<T> {
47
+ success: boolean;
48
+ data?: T;
49
+ errors?: string[];
50
+ warnings?: string[];
51
+ }
52
+ /** Export format. */
53
+ export type ExportFormat = 'nsp' | 'svg' | 'png' | 'pdf' | 'dxf' | 'geojson' | 'ifc';
54
+ /** JSON Schema for .nsp.json validation. */
55
+ export declare const NSP_SCHEMA: {
56
+ $schema: string;
57
+ $id: string;
58
+ title: string;
59
+ description: string;
60
+ type: string;
61
+ required: string[];
62
+ properties: {
63
+ $schema: {
64
+ type: string;
65
+ };
66
+ version: {
67
+ type: string;
68
+ pattern: string;
69
+ };
70
+ type: {
71
+ type: string;
72
+ enum: string[];
73
+ };
74
+ metadata: {
75
+ type: string;
76
+ required: string[];
77
+ properties: {
78
+ id: {
79
+ type: string;
80
+ };
81
+ name: {
82
+ type: string;
83
+ };
84
+ description: {
85
+ type: string;
86
+ };
87
+ author: {
88
+ type: string;
89
+ };
90
+ created: {
91
+ type: string;
92
+ format: string;
93
+ };
94
+ modified: {
95
+ type: string;
96
+ format: string;
97
+ };
98
+ tags: {
99
+ type: string;
100
+ items: {
101
+ type: string;
102
+ };
103
+ };
104
+ thumbnail: {
105
+ type: string;
106
+ };
107
+ };
108
+ };
109
+ building: {
110
+ type: string;
111
+ properties: {
112
+ name: {
113
+ type: string;
114
+ };
115
+ address: {
116
+ type: string;
117
+ };
118
+ type: {
119
+ type: string;
120
+ };
121
+ totalArea: {
122
+ type: string;
123
+ };
124
+ floors: {
125
+ type: string;
126
+ };
127
+ yearBuilt: {
128
+ type: string;
129
+ };
130
+ coordinates: {
131
+ type: string;
132
+ properties: {
133
+ lat: {
134
+ type: string;
135
+ };
136
+ lng: {
137
+ type: string;
138
+ };
139
+ };
140
+ };
141
+ };
142
+ };
143
+ floors: {
144
+ type: string;
145
+ items: {
146
+ type: string;
147
+ required: string[];
148
+ properties: {
149
+ id: {
150
+ type: string;
151
+ };
152
+ name: {
153
+ type: string;
154
+ };
155
+ level: {
156
+ type: string;
157
+ };
158
+ elevation: {
159
+ type: string;
160
+ };
161
+ ceilingHeight: {
162
+ type: string;
163
+ };
164
+ bounds: {
165
+ type: string;
166
+ properties: {
167
+ x: {
168
+ type: string;
169
+ };
170
+ y: {
171
+ type: string;
172
+ };
173
+ width: {
174
+ type: string;
175
+ };
176
+ height: {
177
+ type: string;
178
+ };
179
+ };
180
+ };
181
+ layers: {
182
+ type: string;
183
+ };
184
+ };
185
+ };
186
+ };
187
+ settings: {
188
+ type: string;
189
+ properties: {
190
+ units: {
191
+ type: string;
192
+ enum: string[];
193
+ };
194
+ scale: {
195
+ type: string;
196
+ };
197
+ grid: {
198
+ type: string;
199
+ };
200
+ defaultWallHeight: {
201
+ type: string;
202
+ };
203
+ defaultWallThickness: {
204
+ type: string;
205
+ };
206
+ precision: {
207
+ type: string;
208
+ };
209
+ };
210
+ };
211
+ };
212
+ };
213
+ /**
214
+ * Serialize floor plan document to JSON string.
215
+ */
216
+ export declare function serialize(document: FloorPlanDocument, options?: SerializationOptions): string;
217
+ /**
218
+ * Deserialize JSON string to floor plan document.
219
+ */
220
+ export declare function deserialize(json: string): ImportResult<FloorPlanDocument>;
221
+ /**
222
+ * Validate floor plan document against schema.
223
+ */
224
+ export declare function validate(document: FloorPlanDocument): ValidationResult;
225
+ /**
226
+ * Parse .nsp.json file.
227
+ */
228
+ export declare function importNSP(file: File | Blob): Promise<ImportResult<FloorPlanDocument>>;
229
+ /**
230
+ * Create .nsp.json file blob.
231
+ */
232
+ export declare function exportNSP(document: FloorPlanDocument, options?: SerializationOptions): Blob;
233
+ /**
234
+ * Download .nsp.json file.
235
+ */
236
+ export declare function downloadNSP(document: FloorPlanDocument, filename?: string, options?: SerializationOptions): void;
237
+ /**
238
+ * Export floor to SVG.
239
+ */
240
+ export declare function exportFloorToSVG(floor: Floor, options?: {
241
+ width?: number;
242
+ height?: number;
243
+ scale?: number;
244
+ background?: string;
245
+ showGrid?: boolean;
246
+ showLabels?: boolean;
247
+ }): string;
248
+ /**
249
+ * Migrate document to latest version.
250
+ */
251
+ export declare function migrate(document: FloorPlanDocument): FloorPlanDocument;
252
+ declare const _default: {
253
+ serialize: typeof serialize;
254
+ deserialize: typeof deserialize;
255
+ validate: typeof validate;
256
+ importNSP: typeof importNSP;
257
+ exportNSP: typeof exportNSP;
258
+ downloadNSP: typeof downloadNSP;
259
+ exportFloorToSVG: typeof exportFloorToSVG;
260
+ migrate: typeof migrate;
261
+ NSP_SCHEMA: {
262
+ $schema: string;
263
+ $id: string;
264
+ title: string;
265
+ description: string;
266
+ type: string;
267
+ required: string[];
268
+ properties: {
269
+ $schema: {
270
+ type: string;
271
+ };
272
+ version: {
273
+ type: string;
274
+ pattern: string;
275
+ };
276
+ type: {
277
+ type: string;
278
+ enum: string[];
279
+ };
280
+ metadata: {
281
+ type: string;
282
+ required: string[];
283
+ properties: {
284
+ id: {
285
+ type: string;
286
+ };
287
+ name: {
288
+ type: string;
289
+ };
290
+ description: {
291
+ type: string;
292
+ };
293
+ author: {
294
+ type: string;
295
+ };
296
+ created: {
297
+ type: string;
298
+ format: string;
299
+ };
300
+ modified: {
301
+ type: string;
302
+ format: string;
303
+ };
304
+ tags: {
305
+ type: string;
306
+ items: {
307
+ type: string;
308
+ };
309
+ };
310
+ thumbnail: {
311
+ type: string;
312
+ };
313
+ };
314
+ };
315
+ building: {
316
+ type: string;
317
+ properties: {
318
+ name: {
319
+ type: string;
320
+ };
321
+ address: {
322
+ type: string;
323
+ };
324
+ type: {
325
+ type: string;
326
+ };
327
+ totalArea: {
328
+ type: string;
329
+ };
330
+ floors: {
331
+ type: string;
332
+ };
333
+ yearBuilt: {
334
+ type: string;
335
+ };
336
+ coordinates: {
337
+ type: string;
338
+ properties: {
339
+ lat: {
340
+ type: string;
341
+ };
342
+ lng: {
343
+ type: string;
344
+ };
345
+ };
346
+ };
347
+ };
348
+ };
349
+ floors: {
350
+ type: string;
351
+ items: {
352
+ type: string;
353
+ required: string[];
354
+ properties: {
355
+ id: {
356
+ type: string;
357
+ };
358
+ name: {
359
+ type: string;
360
+ };
361
+ level: {
362
+ type: string;
363
+ };
364
+ elevation: {
365
+ type: string;
366
+ };
367
+ ceilingHeight: {
368
+ type: string;
369
+ };
370
+ bounds: {
371
+ type: string;
372
+ properties: {
373
+ x: {
374
+ type: string;
375
+ };
376
+ y: {
377
+ type: string;
378
+ };
379
+ width: {
380
+ type: string;
381
+ };
382
+ height: {
383
+ type: string;
384
+ };
385
+ };
386
+ };
387
+ layers: {
388
+ type: string;
389
+ };
390
+ };
391
+ };
392
+ };
393
+ settings: {
394
+ type: string;
395
+ properties: {
396
+ units: {
397
+ type: string;
398
+ enum: string[];
399
+ };
400
+ scale: {
401
+ type: string;
402
+ };
403
+ grid: {
404
+ type: string;
405
+ };
406
+ defaultWallHeight: {
407
+ type: string;
408
+ };
409
+ defaultWallThickness: {
410
+ type: string;
411
+ };
412
+ precision: {
413
+ type: string;
414
+ };
415
+ };
416
+ };
417
+ };
418
+ };
419
+ };
420
+ export default _default;
421
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAOpE,6BAA6B;AAC7B,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wCAAwC;IACxC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,yBAAyB;AACzB,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,wBAAwB;AACxB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,0BAA0B;AAC1B,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAqB;AACrB,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CA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