@carbonenginejs/runtime-utils 0.1.0 → 0.1.2
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.
- package/README.md +21 -7
- package/THIRD-PARTY-NOTICES.md +30 -4
- package/docs/README.md +10 -7
- package/docs/architecture.md +7 -6
- package/docs/concepts/foundation-consolidation.md +20 -21
- package/docs/const-kb.md +18 -11
- package/docs/core-types/DECORATOR-TODOS.md +1 -1
- package/docs/reference/api.md +43 -1
- package/docs/reference/classes/README.md +20 -0
- package/package.json +8 -1
- package/src/constants/index.js +1 -0
- package/src/constants/trinity.js +13 -0
- package/src/errors/CjsError.js +286 -0
- package/src/errors/index.js +5 -0
- package/src/index.js +4 -0
- package/src/is.js +71 -9
- package/src/mesh.js +37 -7
- package/src/model/CjsModel.js +61 -16
- package/src/object.js +39 -0
- package/src/path.js +32 -0
- package/src/schema/CjsSchema.js +416 -297
- package/src/vec3.js +16 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Browser-safe foundations shared across CarbonEngineJS packages.
|
|
|
5
5
|
The package owns:
|
|
6
6
|
|
|
7
7
|
- neutral arrays, bytes, compression, JSON, lookup, paths, text, predicates,
|
|
8
|
-
and
|
|
8
|
+
validation, and structured operational errors;
|
|
9
9
|
- scalar, vector, quaternion, matrix, geometry, mesh, tangent, curve, and
|
|
10
10
|
noise math;
|
|
11
11
|
- shared media, graphics, render-context, audio, shader, D3D, and WebGPU
|
|
@@ -13,8 +13,9 @@ The package owns:
|
|
|
13
13
|
- Carbon type descriptors, schema metadata, models, lifecycle state,
|
|
14
14
|
documents, hydration, and dehydration.
|
|
15
15
|
|
|
16
|
-
Browser
|
|
17
|
-
|
|
16
|
+
Browser-client ownership is planned for `@carbonenginejs/tools-browser`; that
|
|
17
|
+
package is not currently released. Node automation belongs in
|
|
18
|
+
`@carbonenginejs/tools-core`.
|
|
18
19
|
|
|
19
20
|
## Install
|
|
20
21
|
|
|
@@ -28,15 +29,28 @@ Prefer direct subpaths so unrelated families are not initialized:
|
|
|
28
29
|
|
|
29
30
|
```js
|
|
30
31
|
import { normalizePath } from "@carbonenginejs/runtime-utils/path";
|
|
32
|
+
import { CjsError } from "@carbonenginejs/runtime-utils/errors";
|
|
31
33
|
import { cross, normalize } from "@carbonenginejs/runtime-utils/vec3";
|
|
32
34
|
import { PixelFormat } from "@carbonenginejs/runtime-utils/graphics";
|
|
33
35
|
import { CjsSchema } from "@carbonenginejs/runtime-utils/schema";
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
Former
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
Former package imports map as follows:
|
|
39
|
+
|
|
40
|
+
- `@carbonenginejs/core-math` becomes
|
|
41
|
+
`@carbonenginejs/runtime-utils/math`;
|
|
42
|
+
- `@carbonenginejs/core-math/<subpath>` becomes
|
|
43
|
+
`@carbonenginejs/runtime-utils/<subpath>`;
|
|
44
|
+
- `@carbonenginejs/runtime-const` becomes
|
|
45
|
+
`@carbonenginejs/runtime-utils/const`;
|
|
46
|
+
- `@carbonenginejs/runtime-const/<subpath>` becomes
|
|
47
|
+
`@carbonenginejs/runtime-utils/<subpath>`;
|
|
48
|
+
- `@carbonenginejs/core-types/<subpath>` becomes the matching
|
|
49
|
+
`@carbonenginejs/runtime-utils/<subpath>`; replace former root imports with
|
|
50
|
+
the direct type/model/document subpaths they use.
|
|
51
|
+
|
|
52
|
+
Carbon type and model primitives use `/types`, `/schema`, `/model`,
|
|
53
|
+
`/document`, `/hydration`, and `/lifecycle`.
|
|
40
54
|
|
|
41
55
|
The root export is intentionally limited to common neutral utilities, math,
|
|
42
56
|
and non-conflicting constants. Import Carbon type/model/document families from
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -15,6 +15,10 @@ Most container modules in `src` were extracted from ccpwgl's
|
|
|
15
15
|
imports. The code remains MIT-licensed under the CarbonEngineJS/ccpwgl project
|
|
16
16
|
license.
|
|
17
17
|
|
|
18
|
+
- Project: <https://github.com/cppctamber/ccpwgl2>
|
|
19
|
+
- Copyright: 2020 ccpgames rawrafox cppctamber
|
|
20
|
+
- License: MIT; terms reproduced below
|
|
21
|
+
|
|
18
22
|
## Mapbox earcut helper
|
|
19
23
|
|
|
20
24
|
`src/geometry/helpers/earcut.js` is an embedded copy of an Earcut-style
|
|
@@ -24,11 +28,14 @@ triangulation helper from the ccpwgl math tree.
|
|
|
24
28
|
- License: ISC
|
|
25
29
|
- Local license copy: `src/geometry/helpers/LICENSE`
|
|
26
30
|
|
|
27
|
-
## Three.js-derived geometry
|
|
31
|
+
## Three.js-derived geometry helpers
|
|
32
|
+
|
|
33
|
+
Math and geometry helpers in the extracted ccpwgl tree retain source comments
|
|
34
|
+
attributing conversions to Three.js authors.
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
- Project: <https://github.com/mrdoob/three.js>
|
|
37
|
+
- Copyright: 2010-2026 three.js authors
|
|
38
|
+
- License: MIT; terms reproduced below
|
|
32
39
|
|
|
33
40
|
## Fenris Creations / CCP Games tangent behavior
|
|
34
41
|
|
|
@@ -36,3 +43,22 @@ be reviewed before expanding the public geometry surface.
|
|
|
36
43
|
derived from observed EVE/Carbon shader behavior and generated test vectors.
|
|
37
44
|
No Fenris Creations (CCP Games) shader source, tools, or assets are included.
|
|
38
45
|
|
|
46
|
+
## MIT terms for ccpwgl and Three.js material
|
|
47
|
+
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
49
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
50
|
+
the Software without restriction, including without limitation the rights to
|
|
51
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
52
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
53
|
+
subject to the following conditions:
|
|
54
|
+
|
|
55
|
+
The above copyright notices and this permission notice shall be included in all
|
|
56
|
+
copies or substantial portions of the Software.
|
|
57
|
+
|
|
58
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
59
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
60
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
61
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
62
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
63
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
64
|
+
SOFTWARE.
|
package/docs/README.md
CHANGED
|
@@ -25,16 +25,19 @@ Use `runtime-utils` when code:
|
|
|
25
25
|
- can remain independent of every other CarbonEngineJS package.
|
|
26
26
|
|
|
27
27
|
Do not use it merely as a convenient home for code without an owner.
|
|
28
|
-
Browser-facing demos, clients, inspectors, and usable application helpers
|
|
29
|
-
|
|
28
|
+
Browser-facing demos, clients, inspectors, and usable application helpers have
|
|
29
|
+
the planned owner `@carbonenginejs/tools-browser`; that package is not
|
|
30
|
+
currently released.
|
|
30
31
|
|
|
31
32
|
## Where it fits
|
|
32
33
|
|
|
33
34
|
The package has no organization dependencies. It uses `gl-matrix` for the math
|
|
34
35
|
families; its subpaths remain side-effect-free and independently importable.
|
|
36
|
+
The `/errors` family supplies coded operational failures without defining
|
|
37
|
+
logging, transport, HTTP, or retry policy.
|
|
35
38
|
|
|
36
39
|
```text
|
|
37
|
-
runtime libraries tools-browser
|
|
40
|
+
runtime libraries tools-browser (planned; unreleased)
|
|
38
41
|
\ /
|
|
39
42
|
\ /
|
|
40
43
|
v v
|
|
@@ -44,9 +47,9 @@ runtime libraries tools-browser
|
|
|
44
47
|
Web-standard platform APIs
|
|
45
48
|
```
|
|
46
49
|
|
|
47
|
-
Runtime packages
|
|
48
|
-
constant, type, schema, model,
|
|
49
|
-
consolidated here.
|
|
50
|
+
Runtime packages consume this foundation directly. The planned, unreleased
|
|
51
|
+
`tools-browser` package will do the same. Math, constant, type, schema, model,
|
|
52
|
+
document, hydration, and lifecycle ownership is consolidated here.
|
|
50
53
|
|
|
51
54
|
## Start here
|
|
52
55
|
|
|
@@ -75,7 +78,7 @@ import { asUint8Array } from "@carbonenginejs/runtime-utils/bytes";
|
|
|
75
78
|
- [Class reference](reference/classes/README.md) catalogs maintained Carbon
|
|
76
79
|
foundation classes.
|
|
77
80
|
- [Foundation consolidation](concepts/foundation-consolidation.md) records the
|
|
78
|
-
implemented ownership move and
|
|
81
|
+
implemented ownership move and consumer migration map.
|
|
79
82
|
|
|
80
83
|
The Carbon type/model/document guide is retained under
|
|
81
84
|
[core-types/README.md](core-types/README.md) with updated package paths.
|
package/docs/architecture.md
CHANGED
|
@@ -30,7 +30,7 @@ organization dependency cycles.
|
|
|
30
30
|
## Dependency direction
|
|
31
31
|
|
|
32
32
|
```text
|
|
33
|
-
runtime-* packages tools-browser
|
|
33
|
+
runtime-* packages tools-browser (planned; unreleased)
|
|
34
34
|
\ /
|
|
35
35
|
\ /
|
|
36
36
|
v v
|
|
@@ -55,15 +55,16 @@ Code belongs in `runtime-utils` only when all of these are true:
|
|
|
55
55
|
5. Owning it here reduces duplicated foundation behavior rather than merely
|
|
56
56
|
shortening an import.
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
With foundation consolidation complete, new responsibilities should be
|
|
59
|
+
uncommon. Additions require a demonstrated cross-package need and a clear
|
|
60
|
+
subpath owner.
|
|
61
61
|
|
|
62
62
|
## Current ownership
|
|
63
63
|
|
|
64
64
|
The implemented package currently owns:
|
|
65
65
|
|
|
66
66
|
- neutral array, byte, text, JSON, lookup, and path mechanics;
|
|
67
|
+
- structured operational errors without logging or transport policy;
|
|
67
68
|
- shared `isSomething` predicates and small validation assertions;
|
|
68
69
|
- browser-standard gzip decompression helpers;
|
|
69
70
|
- scalar, vector, quaternion, matrix, geometry, mesh, tangent, noise, and curve
|
|
@@ -78,8 +79,8 @@ The [API reference](reference/api.md) is the exact current inventory.
|
|
|
78
79
|
## Ownership elsewhere
|
|
79
80
|
|
|
80
81
|
- Browser-facing demos, clients, remote readers, inspectors, integration
|
|
81
|
-
helpers, and usable reference implementations
|
|
82
|
-
`@carbonenginejs/tools-browser
|
|
82
|
+
helpers, and usable reference implementations have the planned owner
|
|
83
|
+
`@carbonenginejs/tools-browser`, which is not currently released.
|
|
83
84
|
- Node filesystems, caches, credentials, servers, command-line interfaces, and
|
|
84
85
|
build orchestration belong in `@carbonenginejs/tools-core`.
|
|
85
86
|
- Runtime graph objects and domain readers belong in their owning
|
|
@@ -7,9 +7,8 @@ Summary: Records the consolidated math, constant, and type-system ownership and
|
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
libraries.
|
|
10
|
+
`runtime-utils` is the single stable, browser-safe foundation commonly
|
|
11
|
+
consumed by CarbonEngineJS runtime libraries.
|
|
13
12
|
|
|
14
13
|
The surviving repository now contains the former utility, math, constant, and
|
|
15
14
|
Carbon type-system implementations. Their inherited test suites run together,
|
|
@@ -23,7 +22,7 @@ models, documents, lifecycle, hydration, and dehydration.
|
|
|
23
22
|
|
|
24
23
|
## Implemented layout
|
|
25
24
|
|
|
26
|
-
The families
|
|
25
|
+
The moved families map directly enough to preserve useful imports:
|
|
27
26
|
|
|
28
27
|
| Moved family | `runtime-utils` family |
|
|
29
28
|
| --- | --- |
|
|
@@ -47,29 +46,29 @@ There is one curated `runtime-utils/is` surface:
|
|
|
47
46
|
- generally useful structural checks belong here;
|
|
48
47
|
- vector and matrix checks join only with explicit math semantics;
|
|
49
48
|
- domain checks remain with their domain package;
|
|
50
|
-
- browser-specific checks remain
|
|
49
|
+
- browser-specific checks remain outside this package; their planned,
|
|
50
|
+
unreleased owner is `tools-browser`;
|
|
51
51
|
- established core predicate behavior wins wherever old names overlap.
|
|
52
52
|
|
|
53
53
|
The goal is a useful shared predicate library, not a reduced compatibility
|
|
54
54
|
snapshot.
|
|
55
55
|
|
|
56
|
-
## Migration
|
|
56
|
+
## Migration map
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
verified external consumer that cannot migrate during the coordinated release.
|
|
58
|
+
| Former import | Current import |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `@carbonenginejs/core-math` | `@carbonenginejs/runtime-utils/math` |
|
|
61
|
+
| `@carbonenginejs/core-math/<subpath>` | `@carbonenginejs/runtime-utils/<subpath>` |
|
|
62
|
+
| `@carbonenginejs/runtime-const` | `@carbonenginejs/runtime-utils/const` |
|
|
63
|
+
| `@carbonenginejs/runtime-const/<subpath>` | `@carbonenginejs/runtime-utils/<subpath>` |
|
|
64
|
+
| `@carbonenginejs/core-types/<subpath>` | The matching `@carbonenginejs/runtime-utils/<subpath>` |
|
|
65
|
+
| `@carbonenginejs/core-types` | The direct runtime-utils type/model/document subpaths used by the consumer |
|
|
66
|
+
|
|
67
|
+
The former package names are predecessor identities, not compatibility
|
|
68
|
+
packages; maintained source lives here. The one deliberate API correction is
|
|
69
|
+
scalar Hermite interpolation:
|
|
70
|
+
use `cubicHermite` or `cubicHermiteDerivative` with argument order
|
|
71
|
+
`(startValue, startTangent, endValue, endTangent, amount)`.
|
|
73
72
|
|
|
74
73
|
## Stability target
|
|
75
74
|
|
package/docs/const-kb.md
CHANGED
|
@@ -11,7 +11,9 @@ Summary: Defines ownership and dependency rules for shared constant vocabularies
|
|
|
11
11
|
|
|
12
12
|
This package provides stable constants that can be shared by:
|
|
13
13
|
|
|
14
|
-
- `
|
|
14
|
+
- `runtime-resource/formats/*` readers when emitting GPU-free semantic
|
|
15
|
+
payloads.
|
|
16
|
+
- maintained standalone shader-format packages.
|
|
15
17
|
- `runtime-resource` when interpreting payloads and resource intent.
|
|
16
18
|
- `engine-*` packages when mapping payloads to backend APIs.
|
|
17
19
|
- tools and tests that need canonical media, graphics, audio, shader, D3D, or
|
|
@@ -26,13 +28,14 @@ This package provides stable constants that can be shared by:
|
|
|
26
28
|
- numeric mirrors of external enums where useful, such as DXGI/D3D values.
|
|
27
29
|
- mapping tables between shared constants and backend constants.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
The constant families do not own:
|
|
30
32
|
|
|
31
33
|
- resource lifecycle, cache, source reads, or loader dispatch.
|
|
32
34
|
- format parsing or byte decoding.
|
|
33
35
|
- format-container internals such as DDS header offsets, FOURCC parsing,
|
|
34
36
|
PNG chunk handling, WAV chunk layouts, or MP4 box parsing.
|
|
35
|
-
- class hydration or runtime object population
|
|
37
|
+
- class hydration or runtime object population, which are separate
|
|
38
|
+
runtime-utils families.
|
|
36
39
|
- WebGPU/WebGL resource creation.
|
|
37
40
|
|
|
38
41
|
## Dependency Rule
|
|
@@ -42,14 +45,15 @@ This package provides stable constants that can be shared by:
|
|
|
42
45
|
Preferred direction:
|
|
43
46
|
|
|
44
47
|
```text
|
|
45
|
-
|
|
48
|
+
runtime-resource/formats/* may emit matching strings, imports runtime-utils
|
|
49
|
+
shader format-* may emit matching strings, import runtime-utils
|
|
46
50
|
runtime-resource may import/re-export runtime-utils
|
|
47
51
|
engine-* imports runtime-utils for backend mapping
|
|
48
52
|
runtime-utils imports no runtime-resource or engine packages
|
|
49
53
|
```
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
match this package's constants.
|
|
55
|
+
Maintained shader format packages may remain standalone while emitting plain
|
|
56
|
+
strings that match this package's constants.
|
|
53
57
|
|
|
54
58
|
## Initial Domains
|
|
55
59
|
|
|
@@ -62,18 +66,21 @@ match this package's constants.
|
|
|
62
66
|
|
|
63
67
|
## Format-Specific Constants
|
|
64
68
|
|
|
65
|
-
Container-specific constants live with their
|
|
69
|
+
Container-specific constants live with their maintained reader.
|
|
66
70
|
|
|
67
71
|
Examples:
|
|
68
72
|
|
|
69
73
|
- DDS magic numbers, header offsets, pixel format flags, caps bits, FOURCC
|
|
70
|
-
values, and DX10 header parsing belong to
|
|
71
|
-
-
|
|
72
|
-
-
|
|
74
|
+
values, and DX10 header parsing belong to
|
|
75
|
+
`@carbonenginejs/runtime-resource/formats/dds`.
|
|
76
|
+
- PNG chunk names and filter ids belong to
|
|
77
|
+
`@carbonenginejs/runtime-resource/formats/png`.
|
|
78
|
+
- WAV RIFF chunk ids belong to
|
|
79
|
+
`@carbonenginejs/runtime-resource/formats/wav`.
|
|
73
80
|
|
|
74
81
|
`runtime-utils` may still expose general constants that those formats reference,
|
|
75
82
|
such as canonical `PixelFormat` strings or generic `DxgiFormat` numeric enum
|
|
76
|
-
values.
|
|
83
|
+
values. Parser-specific interpretation remains in the maintained reader.
|
|
77
84
|
|
|
78
85
|
## Payload Example
|
|
79
86
|
|
|
@@ -12,7 +12,7 @@ No missing decorator primitive is currently confirmed. `@type`, `@io`,
|
|
|
12
12
|
`CjsModel.SetValues` adds declared `@io.flag`/`@io.rebuild` consequences at
|
|
13
13
|
write time.
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Open work
|
|
16
16
|
|
|
17
17
|
- [ ] Decide how a concrete Blue class declares an inherited Carbon method
|
|
18
18
|
without adding a forwarding wrapper. `CjsSchema.decorateMethod` can already
|
package/docs/reference/api.md
CHANGED
|
@@ -35,12 +35,13 @@ import { encodeUtf8 } from "@carbonenginejs/runtime-utils/text";
|
|
|
35
35
|
| [`./arrays`](../../src/arrays.js) | Normalizes nullable values and mutates writable array-like targets. | `toArray`, `copyArrayLike`, `fillArrayLike` |
|
|
36
36
|
| [`./bytes`](../../src/bytes.js) | Creates byte views, owned copies, exact buffers, and prefix checks. | `asUint8Array`, `copyBytes`, `toArrayBuffer`, `hasBytePrefix` |
|
|
37
37
|
| [`./compression`](../../src/compression.js) | Detects and decompresses gzip through Web-standard streams. | `isGzip`, `decompressBytes`, `decompressGzip`, `decompressGzipIfNeeded` |
|
|
38
|
+
| [`./errors`](../../src/errors/index.js) | Represents coded operational failures and Web-compatible cancellation without logging or transport policy. | `CjsError`, `CjsCancellationError`, `CJS_OPERATION_CANCELLED` |
|
|
38
39
|
| [`./is`](../../src/is.js) | Provides shared literal-boolean value predicates. | `isTypedArray`, `isArrayLike`, `isFunction`, `isNullish`, `isObject`, `isObjectLike`, `isPlainObject`, `isPromiseLike` |
|
|
39
40
|
| [`./json`](../../src/json.js) | Encodes and decodes JSON with explicit UTF-8 behavior. | `encodeJson`, `decodeJson` |
|
|
40
41
|
| [`./lookup`](../../src/lookup.js) | Supplies stable string ordering and duplicate-safe map construction. | `compareCodeUnits`, `sortStrings`, `indexBy` |
|
|
41
42
|
| [`./math`](../../src/math/index.js) | Aggregates scalar and container math. | Scalar exports plus math namespaces. |
|
|
42
43
|
| [`./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
|
|
44
|
+
| [`./path`](../../src/path.js) | Normalizes generic and case-insensitive resource paths without filesystem access or dot-segment resolution. | `normalizePath`, `normalizeResourcePath`, `getResourceExtension`, `normalizeResourceExtension` |
|
|
44
45
|
| [`./text`](../../src/text.js) | Encodes and decodes UTF-8 through Web-standard codecs. | `encodeUtf8`, `decodeUtf8` |
|
|
45
46
|
| [`./validation`](../../src/validation.js) | Provides small labelled assertions for shared input contracts. | `isPlainObject`, `assertPlainObject`, `assertNonEmptyString`, `assertSupportedVersion` |
|
|
46
47
|
|
|
@@ -56,6 +57,47 @@ available. `render-context` stays out of the root because its numeric
|
|
|
56
57
|
Carbon foundation families use `./types`, `./schema`, `./model`,
|
|
57
58
|
`./document`, `./hydration`, and `./lifecycle`.
|
|
58
59
|
|
|
60
|
+
## Operational error contract
|
|
61
|
+
|
|
62
|
+
`CjsError` represents an operation that failed after valid input reached a
|
|
63
|
+
runtime boundary. Package owners define their own stable uppercase `CJS_*`
|
|
64
|
+
codes; this family does not maintain a central code registry.
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import { CjsError } from "@carbonenginejs/runtime-utils/errors";
|
|
68
|
+
|
|
69
|
+
throw new CjsError(
|
|
70
|
+
"CJS_EXAMPLE_PROVIDER_FAILED",
|
|
71
|
+
"The example provider could not resolve the requested item.",
|
|
72
|
+
{
|
|
73
|
+
cause,
|
|
74
|
+
details: {
|
|
75
|
+
itemId,
|
|
76
|
+
provider
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The optional `cause` retains its original identity. Optional `details` must be
|
|
83
|
+
a plain record containing JSON-safe values; the constructor clones and deeply
|
|
84
|
+
freezes it. It does not redact details, so callers must exclude credentials,
|
|
85
|
+
private payloads, and other sensitive values.
|
|
86
|
+
|
|
87
|
+
Use native `TypeError`, `RangeError`, and `SyntaxError` for programmer-contract
|
|
88
|
+
violations. An expected `Find*` miss may return `null`; use a coded operational
|
|
89
|
+
error when acquisition, provider, state, or resolution work actually fails.
|
|
90
|
+
Native `AggregateError` remains the aggregate mechanism.
|
|
91
|
+
|
|
92
|
+
`CjsCancellationError` has stable code `CJS_OPERATION_CANCELLED`, uses the
|
|
93
|
+
Web-compatible name `AbortError`, and accepts the same cause/details options.
|
|
94
|
+
`CjsCancellationError.is(error)` also recognizes platform abort errors.
|
|
95
|
+
`CjsError.hasCode(error, code)` works with both `CjsError` and legacy errors
|
|
96
|
+
that expose a stable `code`.
|
|
97
|
+
|
|
98
|
+
These classes do not log, serialize, choose HTTP status, prescribe retries, or
|
|
99
|
+
translate errors for user interfaces.
|
|
100
|
+
|
|
59
101
|
## Environment contract
|
|
60
102
|
|
|
61
103
|
The source uses standard ECMAScript and browser APIs. Compression requires
|
|
@@ -5,6 +5,26 @@ Scope: `@carbonenginejs/runtime-utils` class exports
|
|
|
5
5
|
Audience: Runtime authors and integrators
|
|
6
6
|
Summary: Catalogs maintained named classes in the consolidated runtime foundation.
|
|
7
7
|
|
|
8
|
+
<!-- class:CjsError -->
|
|
9
|
+
## `CjsError`
|
|
10
|
+
|
|
11
|
+
Represents one structured operational failure with a stable CarbonEngineJS code.
|
|
12
|
+
|
|
13
|
+
- Export: `@carbonenginejs/runtime-utils/errors`
|
|
14
|
+
- Source: `src/errors/CjsError.js`
|
|
15
|
+
- Visibility: Public
|
|
16
|
+
- Kind: CarbonEngineJS
|
|
17
|
+
|
|
18
|
+
<!-- class:CjsCancellationError -->
|
|
19
|
+
## `CjsCancellationError`
|
|
20
|
+
|
|
21
|
+
Represents one cancelled operation using Web-compatible abort identity.
|
|
22
|
+
|
|
23
|
+
- Export: `@carbonenginejs/runtime-utils/errors`
|
|
24
|
+
- Source: `src/errors/CjsError.js`
|
|
25
|
+
- Visibility: Public
|
|
26
|
+
- Kind: CarbonEngineJS
|
|
27
|
+
|
|
8
28
|
<!-- class:CjsCarbonDocument -->
|
|
9
29
|
## `CjsCarbonDocument`
|
|
10
30
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbonenginejs/runtime-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Browser-safe shared utilities, math, constants, Carbon types, schemas, documents, and runtime model primitives.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"./bytes": "./src/bytes.js",
|
|
11
11
|
"./compression": "./src/compression.js",
|
|
12
12
|
"./const": "./src/constants/index.js",
|
|
13
|
+
"./const/trinity": "./src/constants/trinity.js",
|
|
13
14
|
"./const/media": "./src/media/index.js",
|
|
14
15
|
"./const/graphics": "./src/graphics/index.js",
|
|
15
16
|
"./const/render-context": "./src/renderContext/index.js",
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
"./d3d": "./src/d3d/index.js",
|
|
26
27
|
"./webgpu": "./src/webgpu/index.js",
|
|
27
28
|
"./document": "./src/document/index.js",
|
|
29
|
+
"./errors": "./src/errors/index.js",
|
|
28
30
|
"./hydration": "./src/document/hydrationAdapter.js",
|
|
29
31
|
"./lifecycle": "./src/lifecycle/index.js",
|
|
30
32
|
"./schema": "./src/schema/index.js",
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
"./is": "./src/is.js",
|
|
34
36
|
"./json": "./src/json.js",
|
|
35
37
|
"./lookup": "./src/lookup.js",
|
|
38
|
+
"./object": "./src/object.js",
|
|
36
39
|
"./math": "./src/math/index.js",
|
|
37
40
|
"./math/scalar": "./src/math/scalar.js",
|
|
38
41
|
"./math/num": "./src/num.js",
|
|
@@ -99,6 +102,7 @@
|
|
|
99
102
|
"constants",
|
|
100
103
|
"schema",
|
|
101
104
|
"types",
|
|
105
|
+
"errors",
|
|
102
106
|
"geometry",
|
|
103
107
|
"tangent",
|
|
104
108
|
"browser"
|
|
@@ -128,5 +132,8 @@
|
|
|
128
132
|
},
|
|
129
133
|
"publishConfig": {
|
|
130
134
|
"access": "public"
|
|
135
|
+
},
|
|
136
|
+
"overrides": {
|
|
137
|
+
"brace-expansion": "^5.0.8"
|
|
131
138
|
}
|
|
132
139
|
}
|
package/src/constants/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Source: trinity/trinity/Resources/Tr2LodResource.h
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared Trinity level-of-detail values.
|
|
5
|
+
*/
|
|
6
|
+
export const Tr2Lod = Object.freeze({
|
|
7
|
+
TR2_LOD_UNSPECIFIED: -1,
|
|
8
|
+
TR2_LOD_LOW: 0,
|
|
9
|
+
TR2_LOD_MEDIUM: 1,
|
|
10
|
+
TR2_LOD_HIGH: 2,
|
|
11
|
+
TR2_LOD_ULTRA: 3,
|
|
12
|
+
TR2_LOD_COUNT: 4
|
|
13
|
+
});
|