@holoscript/std 2.1.0 → 6.0.3

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 (159) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +197 -0
  4. package/dist/__tests__/EconomicPrimitives.test.d.ts +2 -0
  5. package/dist/__tests__/EconomicPrimitives.test.d.ts.map +1 -0
  6. package/dist/__tests__/EconomicTraits.test.d.ts +2 -0
  7. package/dist/__tests__/EconomicTraits.test.d.ts.map +1 -0
  8. package/dist/__tests__/SimulationLabPrimitives.test.d.ts +2 -0
  9. package/dist/__tests__/SimulationLabPrimitives.test.d.ts.map +1 -0
  10. package/dist/__tests__/collections.test.d.ts +2 -0
  11. package/dist/__tests__/collections.test.d.ts.map +1 -0
  12. package/dist/__tests__/events.test.d.ts +2 -0
  13. package/dist/__tests__/events.test.d.ts.map +1 -0
  14. package/dist/__tests__/index.test.d.ts +2 -0
  15. package/dist/__tests__/index.test.d.ts.map +1 -0
  16. package/dist/__tests__/materials.test.d.ts +2 -0
  17. package/dist/__tests__/materials.test.d.ts.map +1 -0
  18. package/dist/__tests__/math.test.d.ts +2 -0
  19. package/dist/__tests__/math.test.d.ts.map +1 -0
  20. package/dist/__tests__/physics.test.d.ts +2 -0
  21. package/dist/__tests__/physics.test.d.ts.map +1 -0
  22. package/dist/__tests__/spatial.test.d.ts +2 -0
  23. package/dist/__tests__/spatial.test.d.ts.map +1 -0
  24. package/dist/__tests__/standard-library-fundamentals.test.d.ts +2 -0
  25. package/dist/__tests__/standard-library-fundamentals.test.d.ts.map +1 -0
  26. package/dist/__tests__/string-and-time-utilities.test.d.ts +2 -0
  27. package/dist/__tests__/string-and-time-utilities.test.d.ts.map +1 -0
  28. package/dist/__tests__/string-decoupled.test.d.ts +2 -0
  29. package/dist/__tests__/string-decoupled.test.d.ts.map +1 -0
  30. package/dist/__tests__/string.test.d.ts +2 -0
  31. package/dist/__tests__/string.test.d.ts.map +1 -0
  32. package/dist/__tests__/time.test.d.ts +2 -0
  33. package/dist/__tests__/time.test.d.ts.map +1 -0
  34. package/dist/chunk-7HVUYGPS.js +679 -0
  35. package/dist/chunk-7HVUYGPS.js.map +1 -0
  36. package/dist/chunk-P4O3WNG2.js +287 -0
  37. package/dist/chunk-P4O3WNG2.js.map +1 -0
  38. package/dist/chunk-PFX2JM4X.js +683 -0
  39. package/dist/chunk-PFX2JM4X.js.map +1 -0
  40. package/dist/chunk-W2Q3LUCM.js +348 -0
  41. package/dist/chunk-W2Q3LUCM.js.map +1 -0
  42. package/dist/chunk-WS6W35YC.js +443 -0
  43. package/dist/chunk-WS6W35YC.js.map +1 -0
  44. package/dist/chunk-ZXVZAQCZ.js +470 -0
  45. package/dist/chunk-ZXVZAQCZ.js.map +1 -0
  46. package/dist/collections.cjs +715 -0
  47. package/dist/collections.cjs.map +1 -0
  48. package/dist/collections.d.ts.map +1 -1
  49. package/dist/collections.js +16 -719
  50. package/dist/collections.js.map +1 -1
  51. package/dist/events.d.ts +32 -0
  52. package/dist/events.d.ts.map +1 -0
  53. package/dist/index.cjs +4101 -0
  54. package/dist/index.cjs.map +1 -0
  55. package/dist/index.d.ts +21 -9
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +1270 -157
  58. package/dist/index.js.map +1 -1
  59. package/dist/materials.d.ts +50 -0
  60. package/dist/materials.d.ts.map +1 -0
  61. package/dist/math.cjs +591 -0
  62. package/dist/math.cjs.map +1 -0
  63. package/dist/math.d.ts.map +1 -1
  64. package/dist/math.js +51 -537
  65. package/dist/math.js.map +1 -1
  66. package/dist/physics.d.ts +59 -0
  67. package/dist/physics.d.ts.map +1 -0
  68. package/dist/spatial.d.ts +82 -0
  69. package/dist/spatial.d.ts.map +1 -0
  70. package/dist/string.basic.test.d.ts +5 -0
  71. package/dist/string.basic.test.d.ts.map +1 -0
  72. package/dist/string.cjs +422 -0
  73. package/dist/string.cjs.map +1 -0
  74. package/dist/string.d.ts +5 -1
  75. package/dist/string.d.ts.map +1 -1
  76. package/dist/string.js +106 -442
  77. package/dist/string.js.map +1 -1
  78. package/dist/string.test.d.ts +5 -0
  79. package/dist/string.test.d.ts.map +1 -0
  80. package/dist/time.cjs +512 -0
  81. package/dist/time.cjs.map +1 -0
  82. package/dist/time.d.ts.map +1 -1
  83. package/dist/time.js +41 -528
  84. package/dist/time.js.map +1 -1
  85. package/dist/traits/ARTraits.d.ts +14 -0
  86. package/dist/traits/ARTraits.d.ts.map +1 -0
  87. package/dist/traits/EconomicPrimitives.cjs +335 -0
  88. package/dist/traits/EconomicPrimitives.cjs.map +1 -0
  89. package/dist/traits/EconomicPrimitives.d.ts +345 -0
  90. package/dist/traits/EconomicPrimitives.d.ts.map +1 -0
  91. package/dist/traits/EconomicPrimitives.js +55 -0
  92. package/dist/traits/EconomicPrimitives.js.map +1 -0
  93. package/dist/traits/EconomicTraits.cjs +471 -0
  94. package/dist/traits/EconomicTraits.cjs.map +1 -0
  95. package/dist/traits/EconomicTraits.d.ts +71 -0
  96. package/dist/traits/EconomicTraits.d.ts.map +1 -0
  97. package/dist/traits/EconomicTraits.js +17 -0
  98. package/dist/traits/EconomicTraits.js.map +1 -0
  99. package/dist/traits/IoTTraits.d.ts +14 -0
  100. package/dist/traits/IoTTraits.d.ts.map +1 -0
  101. package/dist/traits/SimulationLabPrimitives.d.ts +187 -0
  102. package/dist/traits/SimulationLabPrimitives.d.ts.map +1 -0
  103. package/dist/traits/SimulationLabTraits.d.ts +42 -0
  104. package/dist/traits/SimulationLabTraits.d.ts.map +1 -0
  105. package/dist/traits/VRRTraits.d.ts +150 -0
  106. package/dist/traits/VRRTraits.d.ts.map +1 -0
  107. package/dist/traits/__tests__/ARTraits.test.d.ts +2 -0
  108. package/dist/traits/__tests__/ARTraits.test.d.ts.map +1 -0
  109. package/dist/traits/__tests__/EconomicPrimitives.test.d.ts +2 -0
  110. package/dist/traits/__tests__/EconomicPrimitives.test.d.ts.map +1 -0
  111. package/dist/traits/__tests__/EconomicTraits.test.d.ts +2 -0
  112. package/dist/traits/__tests__/EconomicTraits.test.d.ts.map +1 -0
  113. package/dist/types.d.ts +9 -0
  114. package/dist/types.d.ts.map +1 -1
  115. package/error-utf8.log +6 -0
  116. package/error.log +0 -0
  117. package/package.json +42 -19
  118. package/src/__tests__/EconomicPrimitives.test.ts +690 -0
  119. package/src/__tests__/EconomicTraits.test.ts +425 -0
  120. package/src/__tests__/SimulationLabPrimitives.test.ts +415 -0
  121. package/src/__tests__/collections.test.ts +182 -0
  122. package/src/__tests__/events.test.ts +135 -0
  123. package/src/__tests__/index.test.ts +14 -0
  124. package/src/__tests__/materials.test.ts +84 -0
  125. package/src/__tests__/math.test.ts +246 -0
  126. package/src/__tests__/physics.test.ts +83 -0
  127. package/src/__tests__/spatial.test.ts +333 -0
  128. package/src/__tests__/standard-library-fundamentals.test.ts +1301 -0
  129. package/src/__tests__/string-and-time-utilities.test.ts +1070 -0
  130. package/src/__tests__/string-decoupled.test.ts +14 -0
  131. package/src/__tests__/string.test.ts +164 -0
  132. package/src/__tests__/time.test.ts +110 -0
  133. package/src/collections.ts +8 -2
  134. package/src/events.ts +88 -0
  135. package/src/index.ts +161 -11
  136. package/src/materials.ts +109 -0
  137. package/src/math.ts +30 -14
  138. package/src/physics.ts +141 -0
  139. package/src/spatial.ts +320 -0
  140. package/src/string.basic.test.ts +14 -0
  141. package/src/string.test.ts +335 -0
  142. package/src/string.ts +45 -13
  143. package/src/time.ts +10 -11
  144. package/src/traits/ARTraits.ts +103 -0
  145. package/src/traits/EconomicPrimitives.ts +755 -0
  146. package/src/traits/EconomicTraits.ts +552 -0
  147. package/src/traits/IoTTraits.ts +102 -0
  148. package/src/traits/SimulationLabPrimitives.ts +650 -0
  149. package/src/traits/SimulationLabTraits.ts +191 -0
  150. package/src/traits/VRRTraits.ts +326 -0
  151. package/src/traits/__tests__/ARTraits.test.ts +14 -0
  152. package/src/traits/__tests__/EconomicPrimitives.test.ts +14 -0
  153. package/src/traits/__tests__/EconomicTraits.test.ts +14 -0
  154. package/src/types.ts +47 -12
  155. package/std_error.log +5 -0
  156. package/tsup.config.ts +17 -0
  157. package/vitest.config.ts +10 -0
  158. package/dist/types.js +0 -198
  159. package/dist/types.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @holoscript/std
2
+
3
+ ## 6.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - chore(deps): updated internal dependencies representing workspace minor and security package bumps.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 HoloScript Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # @holoscript/std
2
+
3
+ HoloScript Standard Library - Core types and utilities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @holoscript/std
9
+ ```
10
+
11
+ ## Entry Points
12
+
13
+ | Import | Description |
14
+ | ----------------------------- | ------------------------ |
15
+ | `@holoscript/std` | All utilities |
16
+ | `@holoscript/std/math` | Math & vector operations |
17
+ | `@holoscript/std/collections` | Immutable collections |
18
+ | `@holoscript/std/string` | String manipulation |
19
+ | `@holoscript/std/time` | Timers & scheduling |
20
+
21
+ ## Core Types
22
+
23
+ Spatial and graphical primitives used throughout HoloScript:
24
+
25
+ ```typescript
26
+ import { vec3, quat, rgb, transform, aabb, ray } from '@holoscript/std';
27
+
28
+ const position = vec3(0, 1, -2);
29
+ const rotation = quat(0, 0, 0, 1);
30
+ const color = rgb(0.2, 0.5, 1.0);
31
+ const t = transform(position, rotation, vec3(1, 1, 1));
32
+ const bounds = aabb(vec3(-1, -1, -1), vec3(1, 1, 1));
33
+ ```
34
+
35
+ **Type definitions:** `Vec2`, `Vec3`, `Vec4`, `Quat`, `Transform`, `EulerAngles`, `ColorRGB`, `ColorRGBA`, `ColorHSL`, `AABB`, `BoundingSphere`, `Ray`, `RaycastHit`
36
+
37
+ **Utility types:** `Nullable<T>`, `Optional<T>`, `DeepPartial<T>`
38
+
39
+ ## Math
40
+
41
+ ```typescript
42
+ import {
43
+ lerp,
44
+ clamp,
45
+ remap,
46
+ smoothstep,
47
+ vec3Math,
48
+ quatMath,
49
+ noise,
50
+ random,
51
+ } from '@holoscript/std/math';
52
+
53
+ // Interpolation
54
+ lerp(0, 100, 0.5); // 50
55
+ remap(0.5, 0, 1, -10, 10); // 0
56
+ smoothstep(0, 1, 0.3);
57
+
58
+ // Vector math
59
+ const forward = vec3Math.forward(); // { x: 0, y: 0, z: 1 }
60
+ const dir = vec3Math.normalize(vec3Math.sub(target, origin));
61
+ const d = vec3Math.distance(a, b);
62
+
63
+ // Quaternion math
64
+ const q = quatMath.fromEuler({ pitch: 0, yaw: 90, roll: 0 });
65
+ const rotated = quatMath.rotateVec3(q, forward);
66
+
67
+ // Noise
68
+ noise.perlin2d(x, y);
69
+ noise.fbm(x, y, z, 4, 2.0, 0.5);
70
+ noise.worley(x, y, z);
71
+
72
+ // Random
73
+ random.range(1, 10);
74
+ random.insideUnitSphere();
75
+ const rng = random.seeded(42);
76
+ ```
77
+
78
+ **Constants:** `PI`, `TAU`, `HALF_PI`, `DEG_TO_RAD`, `RAD_TO_DEG`, `EPSILON`
79
+
80
+ **Additional:** `vec2Math`, `aabbMath` (contains/intersects/merge)
81
+
82
+ ## Collections
83
+
84
+ Immutable, functional collection classes:
85
+
86
+ ```typescript
87
+ import { List, HoloMap, HoloSet, SpatialGrid, PriorityQueue } from '@holoscript/std/collections';
88
+
89
+ // List - immutable array with rich API
90
+ const items = List.of(3, 1, 4, 1, 5);
91
+ items
92
+ .sort()
93
+ .unique()
94
+ .map((x) => x * 2)
95
+ .filter((x) => x > 4);
96
+ items.groupBy((x) => (x % 2 === 0 ? 'even' : 'odd'));
97
+ List.range(0, 100, 5); // [0, 5, 10, ..., 95]
98
+
99
+ // HoloMap - immutable key-value store
100
+ const scores = HoloMap.of(['alice', 100], ['bob', 85]);
101
+ scores.set('carol', 92).filter((k, v) => v > 90);
102
+
103
+ // HoloSet - immutable set with set operations
104
+ const a = HoloSet.of(1, 2, 3);
105
+ const b = HoloSet.of(2, 3, 4);
106
+ a.union(b); // {1, 2, 3, 4}
107
+ a.intersection(b); // {2, 3}
108
+
109
+ // SpatialGrid - spatial partitioning
110
+ const grid = new SpatialGrid(10);
111
+ grid.insert(vec3(5, 0, 5), entity);
112
+ const nearby = grid.query(vec3(6, 0, 6), 15);
113
+
114
+ // PriorityQueue
115
+ const pq = PriorityQueue.minHeap();
116
+ pq.enqueue('urgent', 1);
117
+ pq.enqueue('later', 10);
118
+ pq.dequeue(); // 'urgent'
119
+ ```
120
+
121
+ ## String
122
+
123
+ 80+ string utilities:
124
+
125
+ ```typescript
126
+ import { camelCase, slugify, truncate, levenshtein, format, uuid } from '@holoscript/std/string';
127
+
128
+ camelCase('hello-world'); // 'helloWorld'
129
+ slugify('Hello World!'); // 'hello-world'
130
+ truncate('long text...', 8); // 'long ...'
131
+ levenshtein('kitten', 'sitting'); // 3
132
+ format('{name} has {n} items', { name: 'Alice', n: 5 });
133
+ uuid(); // 'a1b2c3d4-...'
134
+ ```
135
+
136
+ **Categories:** case conversion, padding/truncation, validation (`isBlank`, `isNumeric`), encoding (`escapeHtml`, `escapeRegex`), formatting (`formatBytes`, `formatDuration`), splitting (`lines`, `words`)
137
+
138
+ ## Time
139
+
140
+ Timers, scheduling, and async control:
141
+
142
+ ```typescript
143
+ import {
144
+ sleep,
145
+ debounce,
146
+ throttle,
147
+ measure,
148
+ retry,
149
+ Stopwatch,
150
+ CountdownTimer,
151
+ FrameTimer,
152
+ dateTime,
153
+ } from '@holoscript/std/time';
154
+
155
+ await sleep(1000);
156
+ const elapsed = await measure(async () => {
157
+ /* work */
158
+ });
159
+
160
+ const sw = new Stopwatch();
161
+ sw.start();
162
+ // ... work ...
163
+ sw.lap();
164
+ console.log(sw.elapsed);
165
+
166
+ const countdown = new CountdownTimer(60000, {
167
+ onTick: (remaining) => updateUI(remaining),
168
+ onComplete: () => console.log('done!'),
169
+ });
170
+ countdown.start();
171
+
172
+ const frame = new FrameTimer();
173
+ function loop() {
174
+ frame.update();
175
+ console.log(frame.delta, frame.currentFps);
176
+ requestAnimationFrame(loop);
177
+ }
178
+
179
+ await retry(fetchData, { maxRetries: 3, baseDelay: 1000 });
180
+
181
+ dateTime.format(new Date(), 'YYYY-MM-DD HH:mm');
182
+ ```
183
+
184
+ ## General Utilities
185
+
186
+ ```typescript
187
+ import { assert, clone, equals, pipe, compose } from '@holoscript/std';
188
+
189
+ assert(x > 0, 'x must be positive');
190
+ const copy = clone(deepObject);
191
+ equals({ a: 1 }, { a: 1 }); // true
192
+ pipe(5, double, addOne, toString); // '11'
193
+ ```
194
+
195
+ ## License
196
+
197
+ MIT
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EconomicPrimitives.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EconomicPrimitives.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/EconomicPrimitives.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EconomicTraits.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EconomicTraits.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/EconomicTraits.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SimulationLabPrimitives.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimulationLabPrimitives.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/SimulationLabPrimitives.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=collections.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/collections.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=events.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/events.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=materials.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materials.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/materials.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=math.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/math.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=physics.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physics.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/physics.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=spatial.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spatial.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/spatial.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=standard-library-fundamentals.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard-library-fundamentals.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/standard-library-fundamentals.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=string-and-time-utilities.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-and-time-utilities.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/string-and-time-utilities.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=string-decoupled.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-decoupled.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/string-decoupled.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=string.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/string.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=time.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/time.test.ts"],"names":[],"mappings":""}