@itwin/saved-views-react 0.1.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.
Files changed (77) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +131 -0
  3. package/lib/LayeredDropdownMenu/LayeredDropdownMenu.css +11 -0
  4. package/lib/LayeredDropdownMenu/LayeredDropdownMenu.d.ts +39 -0
  5. package/lib/LayeredDropdownMenu/LayeredDropdownMenu.js +53 -0
  6. package/lib/SavedView.d.ts +18 -0
  7. package/lib/SavedView.js +1 -0
  8. package/lib/SavedViewTile/SavedViewOptions.css +26 -0
  9. package/lib/SavedViewTile/SavedViewOptions.d.ts +139 -0
  10. package/lib/SavedViewTile/SavedViewOptions.js +173 -0
  11. package/lib/SavedViewTile/SavedViewTile.css +89 -0
  12. package/lib/SavedViewTile/SavedViewTile.d.ts +55 -0
  13. package/lib/SavedViewTile/SavedViewTile.js +110 -0
  14. package/lib/SavedViewTile/SavedViewTileContext.d.ts +14 -0
  15. package/lib/SavedViewTile/SavedViewTileContext.js +20 -0
  16. package/lib/SavedViewsClient/ITwinSavedViewsClient.d.ts +30 -0
  17. package/lib/SavedViewsClient/ITwinSavedViewsClient.js +132 -0
  18. package/lib/SavedViewsClient/SavedViewsClient.d.ts +72 -0
  19. package/lib/SavedViewsClient/SavedViewsClient.js +1 -0
  20. package/lib/SavedViewsContext.d.ts +13 -0
  21. package/lib/SavedViewsContext.js +38 -0
  22. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupOptions.d.ts +9 -0
  23. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupOptions.js +14 -0
  24. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTile.d.ts +14 -0
  25. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTile.js +37 -0
  26. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTileContext.d.ts +14 -0
  27. package/lib/SavedViewsWidget/SavedViewGroupTile/SavedViewGroupTileContext.js +20 -0
  28. package/lib/SavedViewsWidget/SavedViewsExpandableBlockWidget.css +50 -0
  29. package/lib/SavedViewsWidget/SavedViewsExpandableBlockWidget.d.ts +36 -0
  30. package/lib/SavedViewsWidget/SavedViewsExpandableBlockWidget.js +36 -0
  31. package/lib/SavedViewsWidget/SavedViewsFolderWidget.d.ts +14 -0
  32. package/lib/SavedViewsWidget/SavedViewsFolderWidget.js +60 -0
  33. package/lib/StickyExpandableBlock/StickyExpandableBlock.css +20 -0
  34. package/lib/StickyExpandableBlock/StickyExpandableBlock.d.ts +29 -0
  35. package/lib/StickyExpandableBlock/StickyExpandableBlock.js +63 -0
  36. package/lib/TileGrid/TileGrid.css +28 -0
  37. package/lib/TileGrid/TileGrid.d.ts +48 -0
  38. package/lib/TileGrid/TileGrid.js +32 -0
  39. package/lib/api/clients/IModelQueryClient.d.ts +10 -0
  40. package/lib/api/clients/IModelQueryClient.js +45 -0
  41. package/lib/api/clients/ISavedViewsClient.d.ts +9 -0
  42. package/lib/api/clients/ISavedViewsClient.js +16 -0
  43. package/lib/api/utilities/SavedViewTypes.d.ts +48 -0
  44. package/lib/api/utilities/SavedViewTypes.js +1 -0
  45. package/lib/api/utilities/translation/ModelsAndCategoriesHelper.d.ts +3 -0
  46. package/lib/api/utilities/translation/ModelsAndCategoriesHelper.js +57 -0
  47. package/lib/api/utilities/translation/RgbColor.d.ts +29 -0
  48. package/lib/api/utilities/translation/RgbColor.js +1 -0
  49. package/lib/api/utilities/translation/SavedViewTranslation.d.ts +22 -0
  50. package/lib/api/utilities/translation/SavedViewTranslation.js +246 -0
  51. package/lib/api/utilities/translation/SavedViewsExtensionHandlers.d.ts +13 -0
  52. package/lib/api/utilities/translation/SavedViewsExtensionHandlers.js +42 -0
  53. package/lib/api/utilities/translation/clipVectorsExtractor.d.ts +5 -0
  54. package/lib/api/utilities/translation/clipVectorsExtractor.js +56 -0
  55. package/lib/api/utilities/translation/displayStyleExtractor.d.ts +17 -0
  56. package/lib/api/utilities/translation/displayStyleExtractor.js +499 -0
  57. package/lib/api/utilities/translation/extensionExtractor.d.ts +18 -0
  58. package/lib/api/utilities/translation/extensionExtractor.js +79 -0
  59. package/lib/api/utilities/translation/extractionUtilities.d.ts +209 -0
  60. package/lib/api/utilities/translation/extractionUtilities.js +515 -0
  61. package/lib/api/utilities/translation/urlConverter.d.ts +7 -0
  62. package/lib/api/utilities/translation/urlConverter.js +42 -0
  63. package/lib/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.d.ts +35 -0
  64. package/lib/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.js +298 -0
  65. package/lib/experimental.d.ts +4 -0
  66. package/lib/experimental.js +8 -0
  67. package/lib/index.d.ts +12 -0
  68. package/lib/index.js +14 -0
  69. package/lib/localization.d.ts +52 -0
  70. package/lib/localization.js +51 -0
  71. package/lib/ui/viewlist/ModelCategoryOverrideProvider.d.ts +31 -0
  72. package/lib/ui/viewlist/ModelCategoryOverrideProvider.js +88 -0
  73. package/lib/useSavedViews.d.ts +52 -0
  74. package/lib/useSavedViews.js +514 -0
  75. package/lib/utils.d.ts +1 -0
  76. package/lib/utils.js +7 -0
  77. package/package.json +75 -0
@@ -0,0 +1,499 @@
1
+ import { applyExtraction, extractArray, extractArrayConditionally, extractBoolean, extractColor, extractColorLegacy, extractConditionally, extractNumber, extractNumberOrBool, extractObject, extractPlainTypedMap, extractRGB, extractSimpleArray, extractString, extractStringOrArray, extractStringOrNumber, extractStringOrNumberArray, isAnyColorFormat, simpleTypeOf, } from "./extractionUtilities.js";
2
+ const viewFlagMappings = [
3
+ extractNumber("renderMode"),
4
+ extractBoolean("noConstructions", "noConstruct"),
5
+ extractBoolean("noDimensions", "noDim"),
6
+ extractBoolean("noPattern"),
7
+ extractBoolean("noWeight"),
8
+ extractBoolean("noStyle"),
9
+ extractBoolean("noTransparency", "noTransp"),
10
+ extractBoolean("noFill"),
11
+ extractBoolean("noTexture"),
12
+ extractBoolean("noMaterial"),
13
+ extractBoolean("visibleEdges", "visEdges"),
14
+ extractBoolean("hiddenEdges", "hidEdges"),
15
+ extractBoolean("shadows"),
16
+ extractBoolean("clipVolume", "clipVol"),
17
+ extractBoolean("monochrome"),
18
+ extractBoolean("backgroundMap"),
19
+ extractBoolean("ambientOcclusion"),
20
+ ];
21
+ const viewFlagLegacyMappings = [
22
+ extractNumber("renderMode"),
23
+ extractBoolean("noConstruct", "noConstructions"),
24
+ extractBoolean("noDim", "noDimensions"),
25
+ extractBoolean("noPattern"),
26
+ extractBoolean("noWeight"),
27
+ extractBoolean("noStyle"),
28
+ extractBoolean("noTransp", "noTransparency"),
29
+ extractBoolean("noFill"),
30
+ extractBoolean("noTexture"),
31
+ extractBoolean("noMaterial"),
32
+ extractBoolean("visEdges", "visibleEdges"),
33
+ extractBoolean("hidEdges", "hiddenEdges"),
34
+ extractBoolean("shadows"),
35
+ extractBoolean("clipVol", "clipVolume"),
36
+ extractBoolean("monochrome"),
37
+ extractBoolean("backgroundMap"),
38
+ extractBoolean("ambientOcclusion"),
39
+ ];
40
+ const planarClipMaskMappings = [
41
+ extractNumber("mode"),
42
+ extractString("modelIds"),
43
+ extractString("subCategoryOrElementIds"),
44
+ extractNumber("priority"),
45
+ extractNumber("transparency"),
46
+ extractBoolean("invert"),
47
+ ];
48
+ const displayStylePlanarClipMaskMappings = [
49
+ ...planarClipMaskMappings,
50
+ extractString("modelId"),
51
+ ];
52
+ const backgroundMapMappings = [
53
+ extractNumber("groundBias"),
54
+ extractNumberOrBool("transparency"),
55
+ extractBoolean("useDepthBuffer"),
56
+ extractBoolean("applyTerrain"),
57
+ extractObject([
58
+ extractString("providerName"),
59
+ extractNumber("exaggeration"),
60
+ extractBoolean("applyLighting"),
61
+ extractNumber("heightOrigin"),
62
+ extractNumber("heightOriginMode"),
63
+ ], "terrainSettings"),
64
+ extractNumber("globeMode"),
65
+ extractBoolean("nonLocatable"),
66
+ extractObject(planarClipMaskMappings, "planarClipMask"),
67
+ ];
68
+ const displayStyleSubCategoryMappings = [
69
+ extractString("subCategory"),
70
+ extractColor("color"),
71
+ extractColor("fill"),
72
+ extractBoolean("invisible"),
73
+ extractNumber("weight"),
74
+ extractString("style"),
75
+ extractNumber("priority"),
76
+ extractString("material"),
77
+ extractNumber("transp", "transparency"),
78
+ extractNumber("transpFill", "transparencyFill"),
79
+ ];
80
+ export const featureAppearanceMappings = [
81
+ extractRGB("rgb"),
82
+ extractNumber("weight"),
83
+ extractNumber("transparency"),
84
+ extractNumber("linePixels"),
85
+ extractBoolean("ignoresMaterial"),
86
+ extractBoolean("nonLocatable"),
87
+ extractBoolean("emphasized"),
88
+ ];
89
+ export const featureAppearanceLegacyMappings = [
90
+ extractColorLegacy("rgb"),
91
+ extractNumber("weight"),
92
+ extractNumber("transparency"),
93
+ extractNumber("linePixels"),
94
+ extractBoolean("ignoresMaterial"),
95
+ extractBoolean("nonLocatable"),
96
+ extractBoolean("emphasized"),
97
+ ];
98
+ const displayStyleModelAppearanceMappings = [
99
+ ...featureAppearanceMappings,
100
+ extractString("modelId"),
101
+ ];
102
+ const displayStyleModelAppearanceLegacyMappings = [...featureAppearanceLegacyMappings, extractString("modelId")];
103
+ const contextRealityModelsMappings = [
104
+ extractObject([
105
+ extractString("provider"),
106
+ extractString("format"),
107
+ extractString("id"),
108
+ extractString("iTwinId"),
109
+ ], "rdSourceKey", "realityDataSourceKey"),
110
+ extractString("tilesetUrl"),
111
+ extractString("realityDataId"),
112
+ extractString("name"),
113
+ extractString("description"),
114
+ extractArray([
115
+ extractString("modelId"),
116
+ extractNumber("expand"),
117
+ extractObject([
118
+ extractNumber("inside"),
119
+ extractNumber("outside"),
120
+ extractBoolean("isVolumeClassifier"),
121
+ ], "flags"),
122
+ extractString("name"),
123
+ extractBoolean("isActive"),
124
+ ], "classifiers"),
125
+ extractObject(planarClipMaskMappings, "planarClipMask"),
126
+ extractObject(featureAppearanceMappings, "appearanceOverrides"),
127
+ ];
128
+ const contextRealityModelsLegacyMappings = [
129
+ extractObject([
130
+ extractString("provider"),
131
+ extractString("format"),
132
+ extractString("id"),
133
+ extractString("iTwinId"),
134
+ ], "rdSourceKey", "realityDataSourceKey"),
135
+ extractString("tilesetUrl"),
136
+ extractString("realityDataId"),
137
+ extractString("name"),
138
+ extractString("description"),
139
+ extractArray([
140
+ extractString("modelId"),
141
+ extractNumber("expand"),
142
+ extractObject([
143
+ extractNumber("inside"),
144
+ extractNumber("outside"),
145
+ extractBoolean("isVolumeClassifier"),
146
+ ], "flags"),
147
+ extractString("name"),
148
+ extractBoolean("isActive"),
149
+ ], "classifiers"),
150
+ extractObject(planarClipMaskMappings, "planarClipMask"),
151
+ extractObject(featureAppearanceLegacyMappings, "appearanceOverrides"),
152
+ ];
153
+ const commonMapLayerPropsMapping = [
154
+ extractBoolean("visible"),
155
+ extractString("name"),
156
+ extractNumber("transparency"),
157
+ extractBoolean("transparentBackground"),
158
+ ];
159
+ const mapSubLayerMappings = [
160
+ extractString("name"),
161
+ extractString("title"),
162
+ extractBoolean("visible"),
163
+ extractStringOrNumber("id"),
164
+ extractStringOrNumber("parent"),
165
+ extractStringOrNumberArray("children"),
166
+ ];
167
+ const imageMapLayerPropsMapping = [
168
+ ...commonMapLayerPropsMapping,
169
+ extractString("url"),
170
+ extractString("formatId"),
171
+ extractArray(mapSubLayerMappings, "subLayers"),
172
+ ];
173
+ const baseMapLayerPropsMapping = [
174
+ ...imageMapLayerPropsMapping,
175
+ extractObject([extractString("name"), extractNumber("type")], "provider"),
176
+ ];
177
+ const modelMapLayerPropsMapping = [
178
+ ...commonMapLayerPropsMapping,
179
+ extractString("modelId"),
180
+ ];
181
+ const mapImageryMapping = [
182
+ extractConditionally([
183
+ {
184
+ discriminator: isAnyColorFormat,
185
+ mappings: extractColor,
186
+ },
187
+ {
188
+ discriminator: "url",
189
+ mappings: baseMapLayerPropsMapping,
190
+ },
191
+ ], "backgroundBase"),
192
+ extractArrayConditionally([
193
+ {
194
+ discriminator: "modelId",
195
+ mappings: modelMapLayerPropsMapping,
196
+ },
197
+ {
198
+ discriminator: "url",
199
+ mappings: imageMapLayerPropsMapping,
200
+ },
201
+ ], "backgroundLayers"),
202
+ extractArrayConditionally([
203
+ {
204
+ discriminator: "modelId",
205
+ mappings: modelMapLayerPropsMapping,
206
+ },
207
+ {
208
+ discriminator: "url",
209
+ mappings: imageMapLayerPropsMapping,
210
+ },
211
+ ], "overlayLayers"),
212
+ ];
213
+ const viewFlagOverridesMapping = [
214
+ extractNumber("renderMode"),
215
+ extractBoolean("dimensions"),
216
+ extractBoolean("patterns"),
217
+ extractBoolean("weights"),
218
+ extractBoolean("styles"),
219
+ extractBoolean("transparency"),
220
+ extractBoolean("fill"),
221
+ extractBoolean("textures"),
222
+ extractBoolean("materials"),
223
+ extractBoolean("acs"),
224
+ extractBoolean("grid"),
225
+ extractBoolean("visibleEdges"),
226
+ extractBoolean("hiddenEdges"),
227
+ extractBoolean("shadows"),
228
+ extractBoolean("clipVolume"),
229
+ extractBoolean("constructions"),
230
+ extractBoolean("constructions"),
231
+ extractBoolean("backgroundMap"),
232
+ extractBoolean("ambientOcclusion"),
233
+ extractBoolean("wiremesh"),
234
+ extractBoolean("lighting"),
235
+ ];
236
+ const hiddenLineStyleMappings = [
237
+ extractBoolean("overrideColor", "ovrColor"),
238
+ extractColor("color"),
239
+ extractNumber("pattern"),
240
+ extractNumber("width"),
241
+ ];
242
+ const hiddenLineStyleLegacyMappings = [
243
+ extractBoolean("ovrColor", "overrideColor"),
244
+ extractColorLegacy("color"),
245
+ extractNumber("pattern"),
246
+ extractNumber("width"),
247
+ ];
248
+ const hiddenLineSettingsMappings = [
249
+ extractObject(hiddenLineStyleMappings, "visible"),
250
+ extractObject(hiddenLineStyleMappings, "hidden"),
251
+ extractNumber("transparencyThreshold", "transThreshold"),
252
+ ];
253
+ const hiddenLineSettingsLegacyMappings = [
254
+ extractObject(hiddenLineStyleLegacyMappings, "visible"),
255
+ extractObject(hiddenLineStyleLegacyMappings, "hidden"),
256
+ extractNumber("transThreshold", "transparencyThreshold"),
257
+ ];
258
+ const cutStyleMappings = [
259
+ extractObject(viewFlagOverridesMapping, "viewflags"),
260
+ extractObject(hiddenLineSettingsMappings, "hiddenLine"),
261
+ extractObject(featureAppearanceMappings, "appearance"),
262
+ ];
263
+ const cutStyleLegacyMappings = [
264
+ extractObject(viewFlagOverridesMapping, "viewflags"),
265
+ extractObject(hiddenLineSettingsLegacyMappings, "hiddenLine"),
266
+ extractObject(featureAppearanceLegacyMappings, "appearance"),
267
+ ];
268
+ const clipStyleIntersectionMappings = [
269
+ extractRGB("color"),
270
+ extractNumber("width"),
271
+ ];
272
+ const clipStyleIntersectionLegacyMappings = [
273
+ extractColorLegacy("color"),
274
+ extractNumber("width"),
275
+ ];
276
+ const clipStyleMappings = [
277
+ extractBoolean("produceCutGeometry"),
278
+ extractObject(cutStyleMappings, "cutStyle"),
279
+ extractRGB("insideColor"),
280
+ extractRGB("outsideColor"),
281
+ extractBoolean("colorizeIntersection"),
282
+ extractObject(clipStyleIntersectionMappings, "intersectionStyle"),
283
+ ];
284
+ const clipStyleLegacyMappings = [
285
+ extractBoolean("produceCutGeometry"),
286
+ extractObject(cutStyleLegacyMappings, "cutStyle"),
287
+ extractColorLegacy("insideColor"),
288
+ extractColorLegacy("outsideColor"),
289
+ extractBoolean("colorizeIntersection"),
290
+ extractObject(clipStyleIntersectionLegacyMappings, "intersectionStyle"),
291
+ ];
292
+ const displayStylesMapping = [
293
+ extractObject(viewFlagMappings, "viewflags"),
294
+ extractColor("backgroundColor"),
295
+ extractColor("monochromeColor"),
296
+ extractNumber("monochromeMode"),
297
+ extractString("renderTimeline"),
298
+ extractNumber("timePoint"),
299
+ extractArray(displayStyleSubCategoryMappings, "subCategoryOverrides", "subCategoryOvr"),
300
+ extractObject(backgroundMapMappings, "backgroundMap"),
301
+ extractArray(contextRealityModelsMappings, "contextRealityModels"),
302
+ extractStringOrArray("excludedElements"),
303
+ extractObject(mapImageryMapping, "mapImagery"),
304
+ extractArray(displayStyleModelAppearanceMappings, "modelOverrides", "modelOvr"),
305
+ extractObject(clipStyleMappings, "clipStyle"),
306
+ extractArray(displayStylePlanarClipMaskMappings, "planarClipOverrides", "planarClipOvr"),
307
+ ];
308
+ const displayStylesLegacyMapping = [
309
+ extractObject(viewFlagLegacyMappings, "viewflags"),
310
+ extractColorLegacy("backgroundColor"),
311
+ extractColorLegacy("monochromeColor"),
312
+ extractNumber("monochromeMode"),
313
+ extractString("renderTimeline"),
314
+ extractNumber("timePoint"),
315
+ extractArray(displayStyleSubCategoryMappings, "subCategoryOvr", "subCategoryOverrides"),
316
+ extractObject(backgroundMapMappings, "backgroundMap"),
317
+ extractArray(contextRealityModelsLegacyMappings, "contextRealityModels"),
318
+ extractStringOrArray("excludedElements"),
319
+ extractObject(mapImageryMapping, "mapImagery"),
320
+ extractArray(displayStyleModelAppearanceLegacyMappings, "modelOvr", "modelOverrides"),
321
+ extractObject(clipStyleLegacyMappings, "clipStyle"),
322
+ extractArray(displayStylePlanarClipMaskMappings, "planarClipOvr", "planarClipOverrides"),
323
+ ];
324
+ const environmentMappings = [
325
+ extractObject([
326
+ extractBoolean("display"),
327
+ extractNumber("elevation"),
328
+ extractColor("aboveColor"),
329
+ extractColor("belowColor"),
330
+ ], "ground"),
331
+ extractObject([
332
+ extractBoolean("display"),
333
+ extractBoolean("twoColor"),
334
+ extractColor("skyColor"),
335
+ extractColor("groundColor"),
336
+ extractColor("zenithColor"),
337
+ extractColor("nadirColor"),
338
+ extractNumber("skyExponent"),
339
+ extractNumber("groundExponent"),
340
+ extractObject([
341
+ extractNumber("type"),
342
+ extractString("texture"),
343
+ extractObject([
344
+ extractString("front"),
345
+ extractString("back"),
346
+ extractString("top"),
347
+ extractString("bottom"),
348
+ extractString("right"),
349
+ extractString("left"),
350
+ ], "textures"),
351
+ ], "image"),
352
+ ], "sky"),
353
+ ];
354
+ const environmentLegacyMappings = [
355
+ extractObject([
356
+ extractBoolean("display"),
357
+ extractNumber("elevation"),
358
+ extractColorLegacy("aboveColor"),
359
+ extractColorLegacy("belowColor"),
360
+ ], "ground"),
361
+ extractObject([
362
+ extractBoolean("display"),
363
+ extractBoolean("twoColor"),
364
+ extractColorLegacy("skyColor"),
365
+ extractColorLegacy("groundColor"),
366
+ extractColorLegacy("zenithColor"),
367
+ extractColorLegacy("nadirColor"),
368
+ extractNumber("skyExponent"),
369
+ extractNumber("groundExponent"),
370
+ extractObject([
371
+ extractNumber("type"),
372
+ extractString("texture"),
373
+ extractObject([
374
+ extractString("front"),
375
+ extractString("back"),
376
+ extractString("top"),
377
+ extractString("bottom"),
378
+ extractString("right"),
379
+ extractString("left"),
380
+ ], "textures"),
381
+ ], "image"),
382
+ ], "sky"),
383
+ ];
384
+ const ambientOcclusionMappings = [
385
+ extractNumber("bias"),
386
+ extractNumber("zLengthCap"),
387
+ extractNumber("maxDistance"),
388
+ extractNumber("intensity"),
389
+ extractNumber("texelStepSize"),
390
+ extractNumber("blurDelta"),
391
+ extractNumber("blurSigma"),
392
+ extractNumber("blurTexelStepSize"),
393
+ ];
394
+ const solarShadowMappings = [
395
+ extractColor("color"),
396
+ ];
397
+ const lightsMappings = [
398
+ extractObject([extractNumber("intensity")], "portrait"),
399
+ extractObject([
400
+ extractNumber("intensity"),
401
+ extractSimpleArray(simpleTypeOf("number"), "direction"),
402
+ extractBoolean("alwaysEnabled"),
403
+ extractNumber("timePoint"),
404
+ ], "solar"),
405
+ extractObject([
406
+ extractColor("upperColor"),
407
+ extractColor("lowerColor"),
408
+ extractNumber("intensity"),
409
+ ], "hemisphere"),
410
+ extractObject([extractColor("color"), extractNumber("intensity")], "ambient"),
411
+ extractNumber("specularIntensity"),
412
+ extractNumber("numCels"),
413
+ extractObject([extractNumber("intensity"), extractBoolean("invert")], "fresnel"),
414
+ ];
415
+ const planProjectionSettingsMappings = [
416
+ extractNumber("elevation"),
417
+ extractNumber("transparency"),
418
+ extractBoolean("overlay"),
419
+ extractBoolean("enforceDisplayPriority"),
420
+ ];
421
+ const displayStyle3dMapping = [
422
+ ...displayStylesMapping,
423
+ extractObject(environmentMappings, "environment"),
424
+ extractObject(ambientOcclusionMappings, "ambientOcclusion", "ao"),
425
+ extractObject(solarShadowMappings, "solarShadows"),
426
+ extractObject(lightsMappings, "lights"),
427
+ extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"),
428
+ ];
429
+ const displayStyle3dLegacyMapping = [
430
+ ...displayStylesLegacyMapping,
431
+ extractObject(environmentLegacyMappings, "environment"),
432
+ extractObject(ambientOcclusionMappings, "ambientOcclusion", "ao"),
433
+ extractObject(solarShadowMappings, "solarShadows"),
434
+ extractObject(lightsMappings, "lights"),
435
+ extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"),
436
+ ];
437
+ /**
438
+ * Extracts the display style from a legacy view displayStyle field
439
+ * And transforms it into our schema
440
+ * @param data
441
+ * @param viewState
442
+ */
443
+ export const extractDisplayStyle = (data, viewState) => {
444
+ let styles;
445
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
446
+ const output = {};
447
+ if ("displayStyle" in data) {
448
+ styles = data.displayStyle;
449
+ applyExtraction(styles, output, displayStylesMapping);
450
+ }
451
+ if ("displayStyleProps" in data) {
452
+ styles = data.displayStyleProps.jsonProperties?.styles;
453
+ applyExtraction(styles, output, displayStylesLegacyMapping);
454
+ }
455
+ if (styles === undefined) {
456
+ return undefined;
457
+ }
458
+ if (viewState) {
459
+ appendAcsAndGridViewFlagsToOutput(viewState, output);
460
+ }
461
+ return output;
462
+ };
463
+ /**
464
+ * Extracts the display style 3d from a legacy view displayStyle field
465
+ * And transforms it into our schema
466
+ * @param data
467
+ */
468
+ export const extractDisplayStyle3d = (data) => {
469
+ let styles;
470
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
471
+ const output = {};
472
+ if ("displayStyle" in data) {
473
+ styles = data.displayStyle;
474
+ applyExtraction(styles, output, displayStyle3dMapping);
475
+ }
476
+ if ("displayStyleProps" in data) {
477
+ styles = data.displayStyleProps.jsonProperties?.styles;
478
+ applyExtraction(styles, output, displayStyle3dLegacyMapping);
479
+ }
480
+ if (styles === undefined) {
481
+ return undefined;
482
+ }
483
+ return output;
484
+ };
485
+ function appendAcsAndGridViewFlagsToOutput(drawingViewState,
486
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
487
+ output) {
488
+ output.viewflags.acs = false;
489
+ output.viewflags.grid = true;
490
+ if (drawingViewState.auxiliaryCoordinateSystem) {
491
+ output.viewflags.acs = true;
492
+ }
493
+ const gridOrient = drawingViewState.getGridOrientation();
494
+ const gridSpacing = drawingViewState.getGridOrientation();
495
+ const gridPerRef = drawingViewState.getGridsPerRef();
496
+ if (!gridOrient || !gridSpacing || !gridPerRef) {
497
+ output.viewflags.grid = false;
498
+ }
499
+ }
@@ -0,0 +1,18 @@
1
+ import { type EmphasizeElementsProps } from "@itwin/core-common";
2
+ import { ModelCategoryOverrideProviderProps } from "../../../ui/viewlist/ModelCategoryOverrideProvider.js";
3
+ import type { PerModelCategoryVisibilityProps } from "../SavedViewTypes.js";
4
+ /**
5
+ * Extracts the EmphasizeElementsProps from string data in an extension
6
+ * @param extensionData
7
+ */
8
+ export declare const extractEmphasizeElements: (extensionData: string) => EmphasizeElementsProps | undefined;
9
+ /**
10
+ * Extracts array of PerModelCategoryVisibilityProps from string data in an extension
11
+ * @param extensionData
12
+ */
13
+ export declare const extractPerModelCategoryVisibility: (extensionData: string) => PerModelCategoryVisibilityProps[];
14
+ /**
15
+ * Extracts the VisibilityOverrideProps (ie ModelCategoryOverrideProviderProps) from string data in an extension
16
+ * @param extensionData
17
+ */
18
+ export declare const extractVisibilityOverride: (extensionData: string) => ModelCategoryOverrideProviderProps | undefined;
@@ -0,0 +1,79 @@
1
+ import { featureAppearanceMappings } from "./displayStyleExtractor.js";
2
+ import { applyExtraction, extractArray, extractBoolean, extractColor, extractNumber, extractObject, extractSimpleArray, extractString, simpleTypeOf, } from "./extractionUtilities.js";
3
+ /** Appearance Override type for EmphasizeElements */
4
+ const appearanceOverrideEmphElemMappings = [
5
+ extractNumber("overrideType"), // an enum
6
+ extractColor("color"),
7
+ extractSimpleArray(simpleTypeOf("string"), "ids"),
8
+ ];
9
+ /** Appearance Override type for VisibilityOverrides (ie ModelCategoryOverrideProviderProps) */
10
+ const appearanceOverrideVisibOvrMappings = [
11
+ extractSimpleArray(simpleTypeOf("string"), "ids"),
12
+ extractObject(featureAppearanceMappings, "app"),
13
+ ];
14
+ const emphasizeElementsMapping = [
15
+ extractSimpleArray(simpleTypeOf("string"), "neverDrawn"),
16
+ extractSimpleArray(simpleTypeOf("string"), "alwaysDrawn"),
17
+ extractBoolean("isAlwaysDrawnExclusive"),
18
+ extractSimpleArray(simpleTypeOf("string"), "alwaysDrawnExclusiveEmphasized"),
19
+ extractObject(featureAppearanceMappings, "defaultAppearance"),
20
+ extractArray(appearanceOverrideEmphElemMappings, "appearanceOverride"),
21
+ extractBoolean("wantEmphasis"),
22
+ extractObject(featureAppearanceMappings, "unanimatedAppearance"),
23
+ ];
24
+ const perModelCategoryVisibilityMapping = [
25
+ extractString("modelId"),
26
+ extractString("categoryId"),
27
+ extractBoolean("visible"),
28
+ ];
29
+ const visibilityOverrideMapping = [
30
+ extractArray(appearanceOverrideVisibOvrMappings, "subCategoryOverrides"),
31
+ extractArray(appearanceOverrideVisibOvrMappings, "modelOverrides"),
32
+ extractObject(appearanceOverrideVisibOvrMappings, "catEmphasizeOverride"),
33
+ extractObject(appearanceOverrideVisibOvrMappings, "modelEmphasizeOverride"),
34
+ ];
35
+ /**
36
+ * Extracts the EmphasizeElementsProps from string data in an extension
37
+ * @param extensionData
38
+ */
39
+ export const extractEmphasizeElements = (extensionData) => {
40
+ const dataObj = JSON.parse(extensionData);
41
+ if (dataObj === undefined || dataObj.emphasizeElementsProps === undefined) {
42
+ return undefined;
43
+ }
44
+ const output = {};
45
+ applyExtraction(dataObj.emphasizeElementsProps, output, emphasizeElementsMapping);
46
+ return output;
47
+ };
48
+ /**
49
+ * Extracts array of PerModelCategoryVisibilityProps from string data in an extension
50
+ * @param extensionData
51
+ */
52
+ export const extractPerModelCategoryVisibility = (extensionData) => {
53
+ const dataObjArray = JSON.parse(extensionData);
54
+ if (dataObjArray === undefined ||
55
+ dataObjArray.perModelCategoryVisibilityProps === undefined) {
56
+ return [];
57
+ }
58
+ const outputArray = [];
59
+ for (const dataObj of dataObjArray.perModelCategoryVisibilityProps) {
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ const output = {};
62
+ applyExtraction(dataObj, output, perModelCategoryVisibilityMapping);
63
+ outputArray.push(output);
64
+ }
65
+ return outputArray;
66
+ };
67
+ /**
68
+ * Extracts the VisibilityOverrideProps (ie ModelCategoryOverrideProviderProps) from string data in an extension
69
+ * @param extensionData
70
+ */
71
+ export const extractVisibilityOverride = (extensionData) => {
72
+ const dataObj = JSON.parse(extensionData);
73
+ if (dataObj === undefined || dataObj.visibilityOverrideProps === undefined) {
74
+ return undefined;
75
+ }
76
+ const output = {};
77
+ applyExtraction(dataObj.visibilityOverrideProps, output, visibilityOverrideMapping);
78
+ return output;
79
+ };