ducjs 4.0.4 → 4.2.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 (122) hide show
  1. package/dist/duc_locator_wasm.d.ts +48 -0
  2. package/dist/duc_locator_wasm.js +296 -0
  3. package/dist/duc_locator_wasm_bg.wasm +0 -0
  4. package/dist/duc_locator_wasm_bg.wasm.d.ts +13 -0
  5. package/dist/ducjs_wasi.wasm +0 -0
  6. package/dist/ducjs_wasm.d.ts +14 -2
  7. package/dist/ducjs_wasm.js +96 -8
  8. package/dist/ducjs_wasm_bg.wasm +0 -0
  9. package/dist/ducjs_wasm_bg.wasm.d.ts +6 -2
  10. package/dist/index.d.ts +4 -1
  11. package/dist/index.js +4 -1
  12. package/dist/locator-runtime.d.ts +4 -0
  13. package/dist/locator-runtime.js +7 -0
  14. package/dist/restore/index.d.ts +1 -0
  15. package/dist/restore/index.js +1 -0
  16. package/dist/restore/restoreDataState.d.ts +13 -24
  17. package/dist/restore/restoreDataState.js +49 -83
  18. package/dist/restore/restoreElements.d.ts +10 -15
  19. package/dist/restore/restoreElements.js +128 -125
  20. package/dist/restore/updateModelCode.d.ts +11 -0
  21. package/dist/restore/updateModelCode.js +63 -0
  22. package/dist/thumbnails/bounds.d.ts +21 -0
  23. package/dist/thumbnails/bounds.js +84 -0
  24. package/dist/thumbnails/browserRunner.d.ts +60 -0
  25. package/dist/thumbnails/browserRunner.js +446 -0
  26. package/dist/thumbnails/cameraPresets.d.ts +47 -0
  27. package/dist/thumbnails/cameraPresets.js +222 -0
  28. package/dist/thumbnails/cli.d.ts +2 -0
  29. package/dist/thumbnails/cli.js +102 -0
  30. package/dist/thumbnails/index.d.ts +11 -0
  31. package/dist/thumbnails/index.js +11 -0
  32. package/dist/thumbnails/lib/clientBundle.min.js +10427 -0
  33. package/dist/thumbnails/lib/clientEntry.d.ts +3 -0
  34. package/dist/thumbnails/lib/clientEntry.js +8 -0
  35. package/dist/thumbnails/lib/clippingUtils.d.ts +10 -0
  36. package/dist/thumbnails/lib/clippingUtils.js +3 -0
  37. package/dist/thumbnails/lib/defaultModelColor.d.ts +3 -0
  38. package/dist/thumbnails/lib/defaultModelColor.js +22 -0
  39. package/dist/thumbnails/lib/index.d.ts +12 -0
  40. package/dist/thumbnails/lib/index.js +12 -0
  41. package/dist/thumbnails/lib/mapViewerStateToOptions.d.ts +34 -0
  42. package/dist/thumbnails/lib/mapViewerStateToOptions.js +69 -0
  43. package/dist/thumbnails/lib/offscreen-dxf-thumbnail.d.ts +16 -0
  44. package/dist/thumbnails/lib/offscreen-dxf-thumbnail.js +173 -0
  45. package/dist/thumbnails/lib/offscreen-model-thumbnail.d.ts +16 -0
  46. package/dist/thumbnails/lib/offscreen-model-thumbnail.js +209 -0
  47. package/dist/thumbnails/lib/parametricClip.d.ts +18 -0
  48. package/dist/thumbnails/lib/parametricClip.js +177 -0
  49. package/dist/thumbnails/lib/parametricShapes.d.ts +1 -0
  50. package/dist/thumbnails/lib/parametricShapes.js +75 -0
  51. package/dist/thumbnails/lib/parametricViewerState.d.ts +26 -0
  52. package/dist/thumbnails/lib/parametricViewerState.js +198 -0
  53. package/dist/thumbnails/lib/thumbnail-camera-fit.d.ts +6 -0
  54. package/dist/thumbnails/lib/thumbnail-camera-fit.js +292 -0
  55. package/dist/thumbnails/lib/thumbnail-capture.d.ts +23 -0
  56. package/dist/thumbnails/lib/thumbnail-capture.js +161 -0
  57. package/dist/thumbnails/lib/thumbnail-visibility.d.ts +12 -0
  58. package/dist/thumbnails/lib/thumbnail-visibility.js +97 -0
  59. package/dist/thumbnails/lib/viewerGrid.d.ts +13 -0
  60. package/dist/thumbnails/lib/viewerGrid.js +57 -0
  61. package/dist/thumbnails/modelCache.d.ts +56 -0
  62. package/dist/thumbnails/modelCache.js +165 -0
  63. package/dist/thumbnails/modelOutputArtifact.d.ts +19 -0
  64. package/dist/thumbnails/modelOutputArtifact.js +87 -0
  65. package/dist/thumbnails/render.d.ts +45 -0
  66. package/dist/thumbnails/render.js +162 -0
  67. package/dist/thumbnails/templates.d.ts +16 -0
  68. package/dist/thumbnails/templates.js +786 -0
  69. package/dist/thumbnails/tessellator.d.ts +33 -0
  70. package/dist/thumbnails/tessellator.js +349 -0
  71. package/dist/thumbnails/types.d.ts +233 -0
  72. package/dist/thumbnails/types.js +1 -0
  73. package/dist/thumbnails/worker.d.ts +10 -0
  74. package/dist/thumbnails/worker.js +119 -0
  75. package/dist/transform.d.ts +1 -1
  76. package/dist/transform.js +20 -22
  77. package/dist/types/elements/index.d.ts +22 -28
  78. package/dist/types/elements/index.js +0 -1
  79. package/dist/types/geometry.types.d.ts +5 -5
  80. package/dist/types/index.d.ts +13 -59
  81. package/dist/types/index.js +0 -1
  82. package/dist/types/issues.types.d.ts +1 -2
  83. package/dist/utils/bounds.d.ts +10 -11
  84. package/dist/utils/bounds.js +105 -84
  85. package/dist/utils/constants.d.ts +5 -7
  86. package/dist/utils/constants.js +10 -15
  87. package/dist/utils/elements/freedrawElement.js +6 -3
  88. package/dist/utils/elements/index.d.ts +2 -6
  89. package/dist/utils/elements/index.js +4 -9
  90. package/dist/utils/elements/linearElement.d.ts +12 -14
  91. package/dist/utils/elements/linearElement.js +81 -66
  92. package/dist/utils/elements/newElement.d.ts +37 -22
  93. package/dist/utils/elements/newElement.js +70 -64
  94. package/dist/utils/elements/textElement.d.ts +34 -35
  95. package/dist/utils/elements/textElement.js +79 -83
  96. package/dist/utils/index.d.ts +1 -1
  97. package/dist/utils/index.js +1 -1
  98. package/dist/utils/locator.d.ts +43 -0
  99. package/dist/utils/locator.js +112 -0
  100. package/dist/utils/math/bbox.d.ts +1 -2
  101. package/dist/utils/math/geometry.js +5 -4
  102. package/dist/utils/math/index.d.ts +13 -17
  103. package/dist/utils/math/index.js +53 -41
  104. package/dist/utils/math/random.js +7 -2
  105. package/dist/utils/normalize.d.ts +5 -5
  106. package/dist/utils/normalize.js +15 -10
  107. package/dist/utils/shape.d.ts +3 -4
  108. package/dist/utils/shape.js +64 -48
  109. package/dist/utils/state/index.d.ts +3 -4
  110. package/dist/utils/state/index.js +8 -23
  111. package/dist/wasi.js +38 -12
  112. package/package.json +23 -9
  113. package/dist/technical/index.d.ts +0 -2
  114. package/dist/technical/index.js +0 -2
  115. package/dist/technical/measurements.d.ts +0 -31
  116. package/dist/technical/measurements.js +0 -64
  117. package/dist/technical/scopes.d.ts +0 -261
  118. package/dist/technical/scopes.js +0 -676
  119. package/dist/types/typeChecks.d.ts +0 -5
  120. package/dist/types/typeChecks.js +0 -10
  121. package/dist/utils/traverse.d.ts +0 -30
  122. package/dist/utils/traverse.js +0 -124
@@ -1,10 +0,0 @@
1
- /**
2
- * Type guard to check if an object is a PrecisionValue
3
- */
4
- export const isPrecisionValue = (obj) => {
5
- return obj !== null &&
6
- typeof obj === 'object' &&
7
- typeof obj.value === 'number' &&
8
- typeof obj.scoped === 'number' &&
9
- Object.keys(obj).length === 2;
10
- };
@@ -1,30 +0,0 @@
1
- import { Scope } from "../types";
2
- /**
3
- * Recursively traverses and updates all PrecisionValue fields in an object
4
- * If providedScope is not specified, it will be detected from the data:
5
- * - Uses 'scope' or 'mainScope' fields at the root level
6
- * - For elements in arrays with their own 'scope' field, uses that element's scope
7
- *
8
- * This function is particularly useful for converting DUC data between different
9
- * measurement scopes, such as when elements need to be converted from their
10
- * original scope to a target scope (e.g., 'mm' to 'in').
11
- *
12
- * When processing arrays of elements (e.g., an 'elements' array), each element
13
- * will be processed using its individual scope if available, falling back to
14
- * the provided or detected scope.
15
- *
16
- * @param obj - The object to traverse and update
17
- * @param targetScope - The target scope to convert PrecisionValues to
18
- * @param providedScope - Optional scope to use if none can be detected
19
- * @param visited - Internal WeakSet to prevent circular references
20
- * @param detectedScope - Internally tracked scope for the current level
21
- */
22
- export declare const traverseAndUpdatePrecisionValues: (obj: any, targetScope: Scope, providedScope?: Scope, visited?: WeakSet<WeakKey>, detectedScope?: Scope) => any;
23
- /**
24
- * Traverses an object and normalizes it for serialization in `targetScope`.
25
- *
26
- * - Converts all PrecisionValue fields so `scoped` is in `targetScope`
27
- * - Rewrites PrecisionValue `value` from the computed `scoped` value
28
- * - Rewrites `scope` / `mainScope` string fields to `targetScope`
29
- */
30
- export declare const normalizeForSerializationScope: <T>(obj: T, targetScope: Scope, providedScope?: Scope) => T;
@@ -1,124 +0,0 @@
1
- import { getPrecisionValueFromRaw } from "../technical";
2
- import { isPrecisionValue } from "../types/typeChecks";
3
- /**
4
- * Recursively traverses and updates all PrecisionValue fields in an object
5
- * If providedScope is not specified, it will be detected from the data:
6
- * - Uses 'scope' or 'mainScope' fields at the root level
7
- * - For elements in arrays with their own 'scope' field, uses that element's scope
8
- *
9
- * This function is particularly useful for converting DUC data between different
10
- * measurement scopes, such as when elements need to be converted from their
11
- * original scope to a target scope (e.g., 'mm' to 'in').
12
- *
13
- * When processing arrays of elements (e.g., an 'elements' array), each element
14
- * will be processed using its individual scope if available, falling back to
15
- * the provided or detected scope.
16
- *
17
- * @param obj - The object to traverse and update
18
- * @param targetScope - The target scope to convert PrecisionValues to
19
- * @param providedScope - Optional scope to use if none can be detected
20
- * @param visited - Internal WeakSet to prevent circular references
21
- * @param detectedScope - Internally tracked scope for the current level
22
- */
23
- export const traverseAndUpdatePrecisionValues = (obj, targetScope, providedScope, visited = new WeakSet(), detectedScope) => {
24
- // Handle null/undefined
25
- if (obj == null)
26
- return obj;
27
- // Handle primitives
28
- if (typeof obj !== 'object')
29
- return obj;
30
- // Prevent circular references
31
- if (visited.has(obj))
32
- return obj;
33
- visited.add(obj);
34
- // Determine the scope to use for this level
35
- let currentScope = providedScope || detectedScope;
36
- // If no scope is determined yet, try to detect it from the current object
37
- if (!currentScope && !Array.isArray(obj)) {
38
- if (obj.scope && typeof obj.scope === 'string') {
39
- currentScope = obj.scope;
40
- }
41
- else if (obj.mainScope && typeof obj.mainScope === 'string') {
42
- currentScope = obj.mainScope;
43
- }
44
- }
45
- // Check if this is a PrecisionValue
46
- if (isPrecisionValue(obj)) {
47
- if (!currentScope) {
48
- throw new Error('No scope could be determined for PrecisionValue conversion');
49
- }
50
- return getPrecisionValueFromRaw(obj.value, currentScope, targetScope);
51
- }
52
- // Handle arrays - special case for elements with their own scope
53
- if (Array.isArray(obj)) {
54
- const newArray = new Array(obj.length);
55
- for (let i = 0; i < obj.length; i++) {
56
- const element = obj[i];
57
- let elementScope = currentScope;
58
- // Check if this array element has its own scope field (for DucElement types)
59
- // This handles arrays of elements where each element can have its own scope
60
- if (element && typeof element === 'object' && !Array.isArray(element)) {
61
- // Use the 'in' operator to safely check for the scope property
62
- if ('scope' in element && element.scope && typeof element.scope === 'string') {
63
- elementScope = element.scope;
64
- }
65
- }
66
- // If the element is a special object (not plain Object), return it as-is
67
- if (element && typeof element === 'object' && element.constructor !== Object && !Array.isArray(element)) {
68
- newArray[i] = element;
69
- }
70
- else {
71
- newArray[i] = traverseAndUpdatePrecisionValues(element, targetScope, elementScope, visited);
72
- }
73
- }
74
- return newArray;
75
- }
76
- // Handle objects - create a new object with updated values
77
- if (obj.constructor !== Object) {
78
- return obj;
79
- }
80
- const result = {};
81
- for (const key in obj) {
82
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
83
- result[key] = traverseAndUpdatePrecisionValues(obj[key], targetScope, providedScope, visited, currentScope);
84
- }
85
- }
86
- return result;
87
- };
88
- /**
89
- * Traverses an object and normalizes it for serialization in `targetScope`.
90
- *
91
- * - Converts all PrecisionValue fields so `scoped` is in `targetScope`
92
- * - Rewrites PrecisionValue `value` from the computed `scoped` value
93
- * - Rewrites `scope` / `mainScope` string fields to `targetScope`
94
- */
95
- export const normalizeForSerializationScope = (obj, targetScope, providedScope) => {
96
- const converted = traverseAndUpdatePrecisionValues(obj, targetScope, providedScope);
97
- return rewriteScopeAndPrecisionValues(converted, targetScope);
98
- };
99
- const rewriteScopeAndPrecisionValues = (obj, targetScope, visited = new WeakSet()) => {
100
- if (obj == null || typeof obj !== "object")
101
- return obj;
102
- if (isPrecisionValue(obj)) {
103
- return Object.assign(Object.assign({}, obj), { value: obj.scoped });
104
- }
105
- if (Array.isArray(obj)) {
106
- return obj.map((item) => rewriteScopeAndPrecisionValues(item, targetScope, visited));
107
- }
108
- if (visited.has(obj))
109
- return obj;
110
- visited.add(obj);
111
- if (obj.constructor !== Object) {
112
- return obj;
113
- }
114
- const result = {};
115
- for (const [key, value] of Object.entries(obj)) {
116
- if ((key === "scope" || key === "mainScope") &&
117
- typeof value === "string") {
118
- result[key] = targetScope;
119
- continue;
120
- }
121
- result[key] = rewriteScopeAndPrecisionValues(value, targetScope, visited);
122
- }
123
- return result;
124
- };