@carbonenginejs/runtime-utils 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 (101) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +23 -0
  3. package/README.md +56 -0
  4. package/THIRD-PARTY-NOTICES.md +38 -0
  5. package/docs/README.md +81 -0
  6. package/docs/architecture.md +101 -0
  7. package/docs/concepts/foundation-consolidation.md +86 -0
  8. package/docs/const-kb.md +92 -0
  9. package/docs/core-types/DECORATOR-TODOS.md +25 -0
  10. package/docs/core-types/README.md +203 -0
  11. package/docs/reference/api.md +70 -0
  12. package/docs/reference/classes/README.md +115 -0
  13. package/package.json +132 -0
  14. package/src/arrays.js +5 -0
  15. package/src/audio/audioFormats.js +34 -0
  16. package/src/audio/index.js +1 -0
  17. package/src/box3.js +1385 -0
  18. package/src/bytes.js +56 -0
  19. package/src/compression.js +56 -0
  20. package/src/constants/index.js +6 -0
  21. package/src/constants.js +15 -0
  22. package/src/curve.js +419 -0
  23. package/src/d3d/dxgiFormats.js +46 -0
  24. package/src/d3d/index.js +2 -0
  25. package/src/d3d/primitiveTopology.js +11 -0
  26. package/src/document/CjsCarbonDocument.js +212 -0
  27. package/src/document/CjsClassRegistry.js +373 -0
  28. package/src/document/CjsDocumentDehydrator.js +142 -0
  29. package/src/document/CjsDocumentHydrator.js +156 -0
  30. package/src/document/CjsStructRegistry.js +348 -0
  31. package/src/document/hydrationAdapter.js +129 -0
  32. package/src/document/index.js +6 -0
  33. package/src/geometry/box.js +137 -0
  34. package/src/geometry/cylinder.js +244 -0
  35. package/src/geometry/helpers/LICENSE +15 -0
  36. package/src/geometry/helpers/earcut.js +766 -0
  37. package/src/geometry/helpers/misc.js +103 -0
  38. package/src/geometry/index.js +8 -0
  39. package/src/geometry/json.js +165 -0
  40. package/src/geometry/lathe.js +172 -0
  41. package/src/geometry/octahedron.js +0 -0
  42. package/src/geometry/plane.js +81 -0
  43. package/src/geometry/shape.js +95 -0
  44. package/src/geometry/sphere.js +123 -0
  45. package/src/geometry/torus.js +96 -0
  46. package/src/graphics/colorSpaces.js +22 -0
  47. package/src/graphics/index.js +4 -0
  48. package/src/graphics/pixelFormats.js +158 -0
  49. package/src/graphics/textureDimensions.js +22 -0
  50. package/src/graphics/trinityEnums.js +87 -0
  51. package/src/index.js +58 -0
  52. package/src/is.js +524 -0
  53. package/src/json.js +23 -0
  54. package/src/lifecycle/CjsLifecycleState.js +77 -0
  55. package/src/lifecycle/index.js +1 -0
  56. package/src/lne3.js +497 -0
  57. package/src/lookup.js +48 -0
  58. package/src/mat3.js +131 -0
  59. package/src/mat4.js +699 -0
  60. package/src/math/index.js +25 -0
  61. package/src/math/scalar.js +63 -0
  62. package/src/media/index.js +1 -0
  63. package/src/media/mediaTypes.js +50 -0
  64. package/src/mesh.js +394 -0
  65. package/src/model/CjsEventEmitter.js +333 -0
  66. package/src/model/CjsModel.js +1544 -0
  67. package/src/model/CjsModelState.js +72 -0
  68. package/src/model/index.js +4 -0
  69. package/src/model/sourceRecordUtils.js +54 -0
  70. package/src/noise.js +310 -0
  71. package/src/num.js +827 -0
  72. package/src/path.js +21 -0
  73. package/src/pln.js +762 -0
  74. package/src/pool.js +160 -0
  75. package/src/quat.js +144 -0
  76. package/src/ray3.js +1085 -0
  77. package/src/renderContext/formats.js +145 -0
  78. package/src/renderContext/index.js +5 -0
  79. package/src/renderContext/presentation.js +125 -0
  80. package/src/renderContext/resources.js +27 -0
  81. package/src/renderContext/upscaling.js +22 -0
  82. package/src/renderContext/window.js +20 -0
  83. package/src/runtime/CjsRuntimeState.js +50 -0
  84. package/src/schema/CjsSchema.js +1009 -0
  85. package/src/schema/index.js +17 -0
  86. package/src/shader/index.js +1 -0
  87. package/src/shader/shaderStages.js +37 -0
  88. package/src/sph3.js +754 -0
  89. package/src/tangent.js +288 -0
  90. package/src/text.js +40 -0
  91. package/src/tri3.js +650 -0
  92. package/src/types/carbonTypes.js +635 -0
  93. package/src/types/index.js +2 -0
  94. package/src/utils.js +58 -0
  95. package/src/validation.js +46 -0
  96. package/src/vec2.js +229 -0
  97. package/src/vec3.js +1172 -0
  98. package/src/vec4.js +347 -0
  99. package/src/vertex.js +108 -0
  100. package/src/webgpu/index.js +1 -0
  101. package/src/webgpu/textureFormats.js +121 -0
@@ -0,0 +1,203 @@
1
+ # @carbonenginejs/runtime-utils
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-utils` Carbon type and model families
5
+ Audience: Runtime authors and integrators
6
+ Summary: Explains Carbon type descriptors, schemas, models, lifecycle state, documents, and hydration.
7
+
8
+ Shared CarbonEngineJS type, schema, document, hydration, and runtime model
9
+ helpers.
10
+
11
+ This package is the common contract for packages that read, write, or generate
12
+ CarbonEngineJS data. Format packages can stop at plain JSON or a neutral
13
+ `CjsCarbonDocument`; runtime packages can opt into registered classes and
14
+ `CjsModel` when they want live objects.
15
+
16
+ ## Install
17
+
18
+ ```sh
19
+ npm install @carbonenginejs/runtime-utils
20
+ ```
21
+
22
+ ## What It Owns
23
+
24
+ - `document`: neutral `CjsCarbonDocument`, class/struct registries, hydration,
25
+ and dehydration.
26
+ - `hydration`: adapter seam for construction, value application, and finalize
27
+ behavior.
28
+ - `schema`: decorators, class/field/method metadata, the direct
29
+ name-to-constructor map, enum registration, Carbon-method provenance, and
30
+ component metadata helpers.
31
+ - `types`: Carbon type descriptors, defaults, coercion, cloning, and export
32
+ helpers.
33
+ - `model`: `CjsModel`, `CjsEventEmitter`, model dirty state, traversal helpers,
34
+ and source-record utilities.
35
+
36
+ Generated enums and generated class catalogs should live in schema or generated
37
+ runtime packages, not in this foundational package.
38
+
39
+ ## Hydration Contract
40
+
41
+ `runtime-utils` does not impose a runtime lifecycle on callers. The hydrator only
42
+ guarantees ordering:
43
+
44
+ 1. `construct`
45
+ 2. `applyValues`
46
+ 3. `finalize`
47
+
48
+ The default behavior is intentionally minimal: construction through
49
+ `CjsSchema.GetConstructor(name)`, `Object.assign` for values, and no finalize
50
+ step. Callers opt into stricter population rules by supplying an adapter.
51
+
52
+ Use `createLifecycleAdapter()` when your runtime classes follow a
53
+ `SetValues`-style contract. `Initialize` is optional; disable it explicitly
54
+ when a project only wants `SetValues`.
55
+
56
+ ## Usage
57
+
58
+ ### Hydrate a neutral document into runtime classes
59
+
60
+ ```js
61
+ import {
62
+ CjsCarbonDocument,
63
+ CjsClassRegistry,
64
+ CjsDocumentHydrator
65
+ } from "@carbonenginejs/runtime-utils/document";
66
+ import { createLifecycleAdapter } from "@carbonenginejs/runtime-utils/hydration";
67
+ import { CjsModel } from "@carbonenginejs/runtime-utils/model";
68
+ import { CjsSchema } from "@carbonenginejs/runtime-utils/schema";
69
+
70
+ class DemoNode extends CjsModel
71
+ {
72
+ position = [0, 0, 0];
73
+ }
74
+
75
+ CjsSchema.define(DemoNode, {
76
+ className: "DemoNode",
77
+ alias: "LegacyDemoNode",
78
+ fields: [{
79
+ name: "position",
80
+ type: { kind: "vec3" },
81
+ io: {
82
+ read: true,
83
+ write: true,
84
+ persist: true,
85
+ notify: true
86
+ }
87
+ }]
88
+ });
89
+
90
+ const document = CjsCarbonDocument.create({
91
+ format: "example",
92
+ roots: [{ ref: { $ref: 1 } }],
93
+ nodes: [{
94
+ id: 1,
95
+ kind: "DemoNode",
96
+ fields: { position: [1, 2, 3] }
97
+ }]
98
+ });
99
+
100
+ const registry = CjsClassRegistry.fromMaps({
101
+ constructors: { DemoNode }
102
+ });
103
+
104
+ const adapter = createLifecycleAdapter({ initialize: false });
105
+ const { root } = CjsDocumentHydrator.hydrate(document, { registry, adapter });
106
+ ```
107
+
108
+ `CjsSchema` stores constructors in one direct name-to-constructor map.
109
+ `CjsSchema.define` registers the explicit `className` and each alias as keys;
110
+ manual code can use `CjsSchema.SetConstructor(name, Constructor)`. A supplied
111
+ scoped registry replaces the default constructor lookup and must implement
112
+ `GetConstructor(name)`.
113
+
114
+ ### Model references, value structs, and raw inline values
115
+
116
+ Use `type.model("ClassName")` for reference-shaped fields that hydrate through
117
+ the registered `CjsModel` constructor map. Legacy `type.objectRef` remains
118
+ supported while runtime packages migrate.
119
+
120
+ Use `type.struct("ClassName")` for a registered model with value semantics. If
121
+ the owner constructor installs a struct instance, `SetValues` populates that
122
+ instance in place instead of storing the incoming model by reference. This
123
+ keeps constructor-owned identity and mutable math buffers stable.
124
+
125
+ Opaque native payloads must not trigger model construction. Use
126
+ `type.rawStruct("NativeType")`; it records the canonical `rawStruct`
127
+ descriptor and keeps plain object values non-constructing.
128
+
129
+ ### Work with schema-backed runtime models directly
130
+
131
+ ```js
132
+ const node = DemoNode.from({ position: [1, 2, 3] });
133
+
134
+ node.OnEvent("modified", (_target, payload) => {
135
+ console.log([...payload.properties]);
136
+ });
137
+
138
+ node.SetValues({ position: [4, 5, 6] });
139
+ node.Merge([{ position: [7, 8, 9] }, { position: [10, 11, 12] }]);
140
+
141
+ const copy = new DemoNode();
142
+ CjsModel.copy(copy, node, { markDirty: false });
143
+ const plain = node.GetValues();
144
+ ```
145
+
146
+ `CjsModel` is evented, tracks dirty/update state explicitly, and uses schema
147
+ metadata as its field contract. Every model class requires an explicit, stable
148
+ `CjsSchema` `className`; runtime type identity never falls back to
149
+ `Constructor.name`, which is not stable under minification.
150
+
151
+ `Merge`/`merge` accept an ordered array of raw value bags or model instances,
152
+ deep-merge them, and apply the final bag through one `CjsModel.set` update cycle.
153
+ They return the same changed-set, boolean, or `false` result as `SetValues`.
154
+ `Copy`/`copy` instead require an instantiated
155
+ `CjsModel` source and forward the supplied `SetValues` options.
156
+
157
+ ### Hide inherited schema fields
158
+
159
+ Carbon Blue surfaces are defined per class, so a real JavaScript subclass may
160
+ persist fewer fields than its parent. Use the class-level
161
+ `schema.hideInherited()` decorator to remove named inherited fields from only
162
+ that class's schema surface:
163
+
164
+ ```js
165
+ import { schema, type } from "@carbonenginejs/runtime-utils/schema";
166
+
167
+ @type.define({ className: "ExampleBucket", family: "example" })
168
+ @schema.hideInherited(["distribution", "descriptor", "offset"])
169
+ export class ExampleBucket extends ExamplePlacement
170
+ {
171
+ }
172
+ ```
173
+
174
+ Hidden fields are omitted from schema introspection, `GetValues`, document
175
+ dehydration, and every export option. `SetValues` and document hydration
176
+ silently ignore them, matching `SetValues`' existing unknown-field behavior.
177
+ The JavaScript properties, accessors, inheritance, and `instanceof` behavior
178
+ are unchanged.
179
+
180
+ Hides pass to descendants and may be extended by another
181
+ `schema.hideInherited()` decorator. There is deliberately no unhide operation.
182
+ Naming a field that the parent schema does not expose throws during class
183
+ registration.
184
+
185
+ Each model owns one non-enumerable `__state` object. Model-owned
186
+ `__state.dirty` tracks broad, property, and notification invalidation;
187
+ `__state.rebuild` is an independent `Set` of deferred work; and
188
+ `__state.updating` plus `__state.suppressEvents` coordinate update processing.
189
+ The event emitter adds `__state.events` only while listeners exist. A lifecycle
190
+ manager may install `__state.lifecycle` with `initializeLifecycleState()`;
191
+ without it, the object remains ordinarily alive and unmanaged. Dirty
192
+ consumption and clearing do not modify rebuild or lifecycle state.
193
+
194
+ ## Subpaths
195
+
196
+ ```js
197
+ import { CjsCarbonDocument, CjsDocumentHydrator } from "@carbonenginejs/runtime-utils/document";
198
+ import { createLifecycleAdapter } from "@carbonenginejs/runtime-utils/hydration";
199
+ import { CjsLifecycleState } from "@carbonenginejs/runtime-utils/lifecycle";
200
+ import { CjsSchema, type, io, carbon, components } from "@carbonenginejs/runtime-utils/schema";
201
+ import { CjsModel, CjsEventEmitter, CjsModelState } from "@carbonenginejs/runtime-utils/model";
202
+ import { CARBON_TYPE, normalizeCarbonValue } from "@carbonenginejs/runtime-utils/types";
203
+ ```
@@ -0,0 +1,70 @@
1
+ # Runtime utilities API
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-utils` version 0.1
5
+ Audience: Library users and runtime authors
6
+ Summary: Lists the consolidated public API families and utility primitives.
7
+
8
+ ## Import contract
9
+
10
+ The package root re-exports neutral utilities, math namespaces, and
11
+ non-conflicting constants. Type, schema, model, document, hydration, and
12
+ lifecycle APIs remain direct-subpath only.
13
+
14
+ ```js
15
+ import {
16
+ asUint8Array,
17
+ encodeJson,
18
+ isArrayLike,
19
+ normalizePath
20
+ } from "@carbonenginejs/runtime-utils";
21
+ ```
22
+
23
+ Every documented subpath can also be imported independently. Subpath imports
24
+ make a narrow dependency explicit:
25
+
26
+ ```js
27
+ import { encodeUtf8 } from "@carbonenginejs/runtime-utils/text";
28
+ ```
29
+
30
+ ## Current exports
31
+
32
+ | Subpath | Purpose | Exports |
33
+ | --- | --- | --- |
34
+ | `.` | Neutral utilities, math namespaces/scalars, and non-conflicting constants. | Common root surface. |
35
+ | [`./arrays`](../../src/arrays.js) | Normalizes nullable values and mutates writable array-like targets. | `toArray`, `copyArrayLike`, `fillArrayLike` |
36
+ | [`./bytes`](../../src/bytes.js) | Creates byte views, owned copies, exact buffers, and prefix checks. | `asUint8Array`, `copyBytes`, `toArrayBuffer`, `hasBytePrefix` |
37
+ | [`./compression`](../../src/compression.js) | Detects and decompresses gzip through Web-standard streams. | `isGzip`, `decompressBytes`, `decompressGzip`, `decompressGzipIfNeeded` |
38
+ | [`./is`](../../src/is.js) | Provides shared literal-boolean value predicates. | `isTypedArray`, `isArrayLike`, `isFunction`, `isNullish`, `isObject`, `isObjectLike`, `isPlainObject`, `isPromiseLike` |
39
+ | [`./json`](../../src/json.js) | Encodes and decodes JSON with explicit UTF-8 behavior. | `encodeJson`, `decodeJson` |
40
+ | [`./lookup`](../../src/lookup.js) | Supplies stable string ordering and duplicate-safe map construction. | `compareCodeUnits`, `sortStrings`, `indexBy` |
41
+ | [`./math`](../../src/math/index.js) | Aggregates scalar and container math. | Scalar exports plus math namespaces. |
42
+ | [`./math/scalar`](../../src/math/scalar.js) | Supplies scalar limits, interpolation, angle conversion, wrapping, and smooth steps. | `defaultEpsilon`, `tau`, `clamp`, `saturate`, `lerp`, `approximatelyEqual`, `degreesToRadians`, `radiansToDegrees`, `wrapDegrees`, `wrapRadians`, `cubicHermite`, `cubicHermiteDerivative`, `smoothStep`, `smootherStep` |
43
+ | [`./path`](../../src/path.js) | Normalizes slash direction without filesystem access or dot-segment resolution. | `normalizePath` |
44
+ | [`./text`](../../src/text.js) | Encodes and decodes UTF-8 through Web-standard codecs. | `encodeUtf8`, `decodeUtf8` |
45
+ | [`./validation`](../../src/validation.js) | Provides small labelled assertions for shared input contracts. | `isPlainObject`, `assertPlainObject`, `assertNonEmptyString`, `assertSupportedVersion` |
46
+
47
+ Math containers retain top-level subpaths such as `./num`, `./vec2`, `./vec3`,
48
+ `./vec4`, `./quat`, `./mat3`, `./mat4`, `./geometry`, `./mesh`, and
49
+ `./tangent`. Matching `./math/*` aliases are also exported.
50
+
51
+ Constant families use `./media`, `./graphics`, `./render-context`, `./audio`,
52
+ `./shader`, `./d3d`, and `./webgpu`; matching `./const/*` aliases are
53
+ available. `render-context` stays out of the root because its numeric
54
+ `PixelFormat` intentionally differs from graphics' string vocabulary.
55
+
56
+ Carbon foundation families use `./types`, `./schema`, `./model`,
57
+ `./document`, `./hydration`, and `./lifecycle`.
58
+
59
+ ## Environment contract
60
+
61
+ The source uses standard ECMAScript and browser APIs. Compression requires
62
+ `DecompressionStream` and `Response`; text helpers require `TextEncoder` and
63
+ `TextDecoder`. When an API is unavailable, the relevant helper reports an
64
+ explicit unsupported-environment error rather than importing a Node fallback.
65
+
66
+ ## Detailed family references
67
+
68
+ See the package README, the retained
69
+ [Carbon type/model guide](../core-types/README.md), and the source-backed
70
+ subpath tests for the complete per-family surface.
@@ -0,0 +1,115 @@
1
+ # Runtime-utils class reference
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-utils` class exports
5
+ Audience: Runtime authors and integrators
6
+ Summary: Catalogs maintained named classes in the consolidated runtime foundation.
7
+
8
+ <!-- class:CjsCarbonDocument -->
9
+ ## `CjsCarbonDocument`
10
+
11
+ Represents one neutral Carbon document graph for hydration and dehydration.
12
+
13
+ - Export: `@carbonenginejs/runtime-utils/document`
14
+ - Source: `src/document/CjsCarbonDocument.js`
15
+ - Visibility: Public
16
+ - Kind: CarbonEngineJS
17
+
18
+ <!-- class:CjsClassRegistry -->
19
+ ## `CjsClassRegistry`
20
+
21
+ Maps serialized Carbon class names to explicit runtime constructors.
22
+
23
+ - Export: `@carbonenginejs/runtime-utils/document`
24
+ - Source: `src/document/CjsClassRegistry.js`
25
+ - Visibility: Public
26
+ - Kind: CarbonEngineJS
27
+
28
+ <!-- class:CjsDocumentDehydrator -->
29
+ ## `CjsDocumentDehydrator`
30
+
31
+ Converts runtime object graphs into neutral Carbon documents.
32
+
33
+ - Export: `@carbonenginejs/runtime-utils/document`
34
+ - Source: `src/document/CjsDocumentDehydrator.js`
35
+ - Visibility: Public
36
+ - Kind: CarbonEngineJS
37
+
38
+ <!-- class:CjsDocumentHydrator -->
39
+ ## `CjsDocumentHydrator`
40
+
41
+ Constructs runtime object graphs from neutral Carbon documents.
42
+
43
+ - Export: `@carbonenginejs/runtime-utils/document`
44
+ - Source: `src/document/CjsDocumentHydrator.js`
45
+ - Visibility: Public
46
+ - Kind: CarbonEngineJS
47
+
48
+ <!-- class:CjsStructRegistry -->
49
+ ## `CjsStructRegistry`
50
+
51
+ Maps serialized Carbon struct names to explicit constructors and layouts.
52
+
53
+ - Export: `@carbonenginejs/runtime-utils/document`
54
+ - Source: `src/document/CjsStructRegistry.js`
55
+ - Visibility: Public
56
+ - Kind: CarbonEngineJS
57
+
58
+ <!-- class:CjsLifecycleState -->
59
+ ## `CjsLifecycleState`
60
+
61
+ Inspectable lifecycle state shared by participating runtime objects.
62
+
63
+ - Export: `@carbonenginejs/runtime-utils/lifecycle`
64
+ - Source: `src/lifecycle/CjsLifecycleState.js`
65
+ - Visibility: Public
66
+ - Kind: CarbonEngineJS
67
+
68
+ <!-- class:CjsEventEmitter -->
69
+ ## `CjsEventEmitter`
70
+
71
+ Minimal event emitter with lowercase exact-name dispatch.
72
+
73
+ - Export: `@carbonenginejs/runtime-utils/model`
74
+ - Source: `src/model/CjsEventEmitter.js`
75
+ - Visibility: Public
76
+ - Kind: CarbonEngineJS
77
+
78
+ <!-- class:CjsModel -->
79
+ ## `CjsModel`
80
+
81
+ Shared base for schema-backed CarbonEngineJS runtime classes.
82
+
83
+ - Export: `@carbonenginejs/runtime-utils/model`
84
+ - Source: `src/model/CjsModel.js`
85
+ - Visibility: Public
86
+ - Kind: CarbonEngineJS
87
+
88
+ <!-- class:CjsPendingReference -->
89
+ ## `CjsPendingReference`
90
+
91
+ Represents one unresolved model reference during a single import operation.
92
+
93
+ - Source: `src/model/CjsModel.js`
94
+ - Visibility: Internal
95
+ - Kind: CarbonEngineJS
96
+
97
+ <!-- class:CjsModelState -->
98
+ ## `CjsModelState`
99
+
100
+ Per-model runtime state.
101
+
102
+ - Export: `@carbonenginejs/runtime-utils/model`
103
+ - Source: `src/model/CjsModelState.js`
104
+ - Visibility: Public
105
+ - Kind: CarbonEngineJS
106
+
107
+ <!-- class:CjsSchema -->
108
+ ## `CjsSchema`
109
+
110
+ Reusable schema/decorator metadata surface.
111
+
112
+ - Export: `@carbonenginejs/runtime-utils/schema`
113
+ - Source: `src/schema/CjsSchema.js`
114
+ - Visibility: Public
115
+ - Kind: CarbonEngineJS
package/package.json ADDED
@@ -0,0 +1,132 @@
1
+ {
2
+ "name": "@carbonenginejs/runtime-utils",
3
+ "version": "0.1.0",
4
+ "description": "Browser-safe shared utilities, math, constants, Carbon types, schemas, documents, and runtime model primitives.",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js",
9
+ "./arrays": "./src/arrays.js",
10
+ "./bytes": "./src/bytes.js",
11
+ "./compression": "./src/compression.js",
12
+ "./const": "./src/constants/index.js",
13
+ "./const/media": "./src/media/index.js",
14
+ "./const/graphics": "./src/graphics/index.js",
15
+ "./const/render-context": "./src/renderContext/index.js",
16
+ "./const/audio": "./src/audio/index.js",
17
+ "./const/shader": "./src/shader/index.js",
18
+ "./const/d3d": "./src/d3d/index.js",
19
+ "./const/webgpu": "./src/webgpu/index.js",
20
+ "./media": "./src/media/index.js",
21
+ "./graphics": "./src/graphics/index.js",
22
+ "./render-context": "./src/renderContext/index.js",
23
+ "./audio": "./src/audio/index.js",
24
+ "./shader": "./src/shader/index.js",
25
+ "./d3d": "./src/d3d/index.js",
26
+ "./webgpu": "./src/webgpu/index.js",
27
+ "./document": "./src/document/index.js",
28
+ "./hydration": "./src/document/hydrationAdapter.js",
29
+ "./lifecycle": "./src/lifecycle/index.js",
30
+ "./schema": "./src/schema/index.js",
31
+ "./types": "./src/types/index.js",
32
+ "./model": "./src/model/index.js",
33
+ "./is": "./src/is.js",
34
+ "./json": "./src/json.js",
35
+ "./lookup": "./src/lookup.js",
36
+ "./math": "./src/math/index.js",
37
+ "./math/scalar": "./src/math/scalar.js",
38
+ "./math/num": "./src/num.js",
39
+ "./math/vec2": "./src/vec2.js",
40
+ "./math/vec3": "./src/vec3.js",
41
+ "./math/vec4": "./src/vec4.js",
42
+ "./math/quat": "./src/quat.js",
43
+ "./math/mat3": "./src/mat3.js",
44
+ "./math/mat4": "./src/mat4.js",
45
+ "./math/box3": "./src/box3.js",
46
+ "./math/tri3": "./src/tri3.js",
47
+ "./math/lne3": "./src/lne3.js",
48
+ "./math/pln": "./src/pln.js",
49
+ "./math/ray3": "./src/ray3.js",
50
+ "./math/sph3": "./src/sph3.js",
51
+ "./math/pool": "./src/pool.js",
52
+ "./math/utils": "./src/utils.js",
53
+ "./math/noise": "./src/noise.js",
54
+ "./math/curve": "./src/curve.js",
55
+ "./math/vertex": "./src/vertex.js",
56
+ "./math/mesh": "./src/mesh.js",
57
+ "./math/tangent": "./src/tangent.js",
58
+ "./math/geometry": "./src/geometry/index.js",
59
+ "./num": "./src/num.js",
60
+ "./vec2": "./src/vec2.js",
61
+ "./vec3": "./src/vec3.js",
62
+ "./vec4": "./src/vec4.js",
63
+ "./quat": "./src/quat.js",
64
+ "./mat3": "./src/mat3.js",
65
+ "./mat4": "./src/mat4.js",
66
+ "./box3": "./src/box3.js",
67
+ "./tri3": "./src/tri3.js",
68
+ "./lne3": "./src/lne3.js",
69
+ "./pln": "./src/pln.js",
70
+ "./ray3": "./src/ray3.js",
71
+ "./sph3": "./src/sph3.js",
72
+ "./pool": "./src/pool.js",
73
+ "./utils": "./src/utils.js",
74
+ "./noise": "./src/noise.js",
75
+ "./curve": "./src/curve.js",
76
+ "./vertex": "./src/vertex.js",
77
+ "./mesh": "./src/mesh.js",
78
+ "./tangent": "./src/tangent.js",
79
+ "./geometry": "./src/geometry/index.js",
80
+ "./path": "./src/path.js",
81
+ "./text": "./src/text.js",
82
+ "./validation": "./src/validation.js"
83
+ },
84
+ "sideEffects": false,
85
+ "engines": {
86
+ "node": ">=18"
87
+ },
88
+ "scripts": {
89
+ "test": "node --test",
90
+ "lint": "eslint --ext .js,.mjs src test",
91
+ "lint:fix": "eslint --fix --ext .js,.mjs src test",
92
+ "check": "npm run lint && npm test"
93
+ },
94
+ "keywords": [
95
+ "carbonenginejs",
96
+ "runtime",
97
+ "utilities",
98
+ "gl-matrix",
99
+ "constants",
100
+ "schema",
101
+ "types",
102
+ "geometry",
103
+ "tangent",
104
+ "browser"
105
+ ],
106
+ "files": [
107
+ "src",
108
+ "docs",
109
+ "README.md",
110
+ "LICENSE",
111
+ "NOTICE",
112
+ "THIRD-PARTY-NOTICES.md"
113
+ ],
114
+ "license": "MIT",
115
+ "dependencies": {
116
+ "gl-matrix": "^3.4.4"
117
+ },
118
+ "devDependencies": {
119
+ "eslint": "^8.57.1"
120
+ },
121
+ "repository": {
122
+ "type": "git",
123
+ "url": "git+https://github.com/carbonenginejs/runtime-utils.git"
124
+ },
125
+ "homepage": "https://github.com/carbonenginejs/runtime-utils#readme",
126
+ "bugs": {
127
+ "url": "https://github.com/carbonenginejs/runtime-utils/issues"
128
+ },
129
+ "publishConfig": {
130
+ "access": "public"
131
+ }
132
+ }
package/src/arrays.js ADDED
@@ -0,0 +1,5 @@
1
+ export {
2
+ toArray,
3
+ copyArrayLike,
4
+ fillArrayLike
5
+ } from "./utils.js";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Canonical audio sample format tokens.
3
+ */
4
+ export const AudioSampleFormat = Object.freeze({
5
+ UNKNOWN: "unknown",
6
+ U8: "u8",
7
+ S16: "s16",
8
+ S24: "s24",
9
+ S32: "s32",
10
+ F32: "f32",
11
+ F64: "f64"
12
+ });
13
+
14
+ /**
15
+ * Canonical audio channel layout tokens.
16
+ */
17
+ export const AudioChannelLayout = Object.freeze({
18
+ UNKNOWN: "unknown",
19
+ MONO: "mono",
20
+ STEREO: "stereo",
21
+ SURROUND_5_1: "5.1",
22
+ SURROUND_7_1: "7.1"
23
+ });
24
+
25
+ /**
26
+ * Normalize an audio sample format token.
27
+ *
28
+ * @param {string} format Audio sample format token.
29
+ * @returns {string} Canonical lowercase token.
30
+ */
31
+ export function normalizeAudioSampleFormat(format)
32
+ {
33
+ return format ? String(format).trim().toLowerCase() : AudioSampleFormat.UNKNOWN;
34
+ }
@@ -0,0 +1 @@
1
+ export * from "./audioFormats.js";