@aelionsdk/core 0.1.0-beta.1 → 1.1.0-rc.1
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
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@aelionsdk/core`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared time, diagnostics, JSON and resource-lifecycle primitives for
|
|
4
|
+
AelionSDK.
|
|
4
5
|
|
|
5
|
-
Install
|
|
6
|
+
## Install
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
```bash
|
|
9
|
+
npm install @aelionsdk/core@next
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`next` currently resolves to `1.1.0-rc.1`. Most applications receive these
|
|
13
|
+
types through `@aelionsdk/sdk`; direct use is intended for extensions and
|
|
14
|
+
custom engine hosts.
|
|
15
|
+
|
|
16
|
+
## Public surface
|
|
17
|
+
|
|
18
|
+
- integer-microsecond time and rational frame/sample conversion;
|
|
19
|
+
- `AelionError` and structured diagnostics;
|
|
20
|
+
- JSON value types;
|
|
21
|
+
- disposable and resource-tracking utilities.
|
|
22
|
+
|
|
23
|
+
Keep time values in integer microseconds at public boundaries, and preserve
|
|
24
|
+
diagnostic codes when wrapping errors so applications can recover
|
|
25
|
+
deterministically.
|
|
26
|
+
|
|
27
|
+
See the [time model](https://foyonaczy.github.io/AelionSDK/concepts/time-model/)
|
|
28
|
+
and [API reference](https://foyonaczy.github.io/AelionSDK/api/aelionsdk/core/overview/).
|
|
29
|
+
Licensed under MIT.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Diagnostic } from './diagnostic.js';
|
|
2
|
+
/** BCP-47 locale tag, e.g. `en` or `zh-CN`. */
|
|
3
|
+
export type DiagnosticLocale = string;
|
|
4
|
+
/**
|
|
5
|
+
* Localized message templates keyed by diagnostic `code` then locale. Templates
|
|
6
|
+
* interpolate `{key}` placeholders from the diagnostic's `details` object; a
|
|
7
|
+
* placeholder with no matching detail renders as an empty string.
|
|
8
|
+
*/
|
|
9
|
+
export type DiagnosticCatalog = Readonly<Record<string, Readonly<Record<DiagnosticLocale, string>>>>;
|
|
10
|
+
/**
|
|
11
|
+
* Return a copy of `diagnostic` whose `message` is the localized template for
|
|
12
|
+
* `locale`, or the original `diagnostic` unchanged when the catalog has no
|
|
13
|
+
* template for its `code`. The stable `code`, structured fields and
|
|
14
|
+
* `recoverable` flag are never altered, so callers can keep branching on the
|
|
15
|
+
* code while rendering a localized message.
|
|
16
|
+
*/
|
|
17
|
+
export declare function localizeDiagnostic<T extends Diagnostic>(diagnostic: T, catalog: DiagnosticCatalog, locale: DiagnosticLocale): T;
|
|
18
|
+
/**
|
|
19
|
+
* Localize every diagnostic in a result array. Unknown codes pass through with
|
|
20
|
+
* their original English message.
|
|
21
|
+
*/
|
|
22
|
+
export declare function localizeDiagnostics<T extends Diagnostic>(diagnostics: readonly T[], catalog: DiagnosticCatalog, locale: DiagnosticLocale): readonly T[];
|
|
23
|
+
/**
|
|
24
|
+
* English message templates for the most common documented diagnostic codes.
|
|
25
|
+
* Applications extend this with additional locales; unknown codes fall back to
|
|
26
|
+
* the original English `message`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const defaultDiagnosticCatalog: DiagnosticCatalog;
|
|
29
|
+
//# sourceMappingURL=diagnostic-localization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-localization.d.ts","sourceRoot":"","sources":["../src/diagnostic-localization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CACtC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,CAC3D,CAAC;AACF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,UAAU,EACrD,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,gBAAgB,GACvB,CAAC,CAYH;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EACtD,WAAW,EAAE,SAAS,CAAC,EAAE,EACzB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,gBAAgB,GACvB,SAAS,CAAC,EAAE,CAEd;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBAgBtC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a copy of `diagnostic` whose `message` is the localized template for
|
|
3
|
+
* `locale`, or the original `diagnostic` unchanged when the catalog has no
|
|
4
|
+
* template for its `code`. The stable `code`, structured fields and
|
|
5
|
+
* `recoverable` flag are never altered, so callers can keep branching on the
|
|
6
|
+
* code while rendering a localized message.
|
|
7
|
+
*/
|
|
8
|
+
export function localizeDiagnostic(diagnostic, catalog, locale) {
|
|
9
|
+
const template = catalog[diagnostic.code]?.[locale];
|
|
10
|
+
if (template === undefined)
|
|
11
|
+
return diagnostic;
|
|
12
|
+
const details = diagnostic.details;
|
|
13
|
+
const message = template.replace(/\{([a-zA-Z0-9_]+)\}/gu, (_, key) => {
|
|
14
|
+
const value = details?.[key];
|
|
15
|
+
// Interpolate primitives only; objects would render as '[object Object]'.
|
|
16
|
+
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'
|
|
17
|
+
? String(value)
|
|
18
|
+
: '';
|
|
19
|
+
});
|
|
20
|
+
return { ...diagnostic, message };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Localize every diagnostic in a result array. Unknown codes pass through with
|
|
24
|
+
* their original English message.
|
|
25
|
+
*/
|
|
26
|
+
export function localizeDiagnostics(diagnostics, catalog, locale) {
|
|
27
|
+
return diagnostics.map(diagnostic => localizeDiagnostic(diagnostic, catalog, locale));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* English message templates for the most common documented diagnostic codes.
|
|
31
|
+
* Applications extend this with additional locales; unknown codes fall back to
|
|
32
|
+
* the original English `message`.
|
|
33
|
+
*/
|
|
34
|
+
export const defaultDiagnosticCatalog = {
|
|
35
|
+
PROJECT_ENTITY_KEY_MISMATCH: {
|
|
36
|
+
en: '{collection} key {key} does not match entity id {id}',
|
|
37
|
+
},
|
|
38
|
+
PROJECT_REFERENCE_MISSING: { en: 'Reference {id} does not exist in {collection}' },
|
|
39
|
+
PROJECT_DUPLICATE_REFERENCE: { en: 'Duplicate reference {value}' },
|
|
40
|
+
PROJECT_HOST_MISMATCH: { en: '{entity} {id} belongs to another {host}' },
|
|
41
|
+
PROJECT_MATERIAL_ORPHAN: { en: 'Material instance {id} has no owner' },
|
|
42
|
+
PROJECT_IMAGE_SEQUENCE_FRAME_MISSING: {
|
|
43
|
+
en: 'Image sequence {id} references missing frame Asset {frameAssetId}',
|
|
44
|
+
},
|
|
45
|
+
PROJECT_IMAGE_SEQUENCE_FRAME_KIND_INVALID: {
|
|
46
|
+
en: 'Frame Asset {frameAssetId} of image sequence {id} must be an image Asset',
|
|
47
|
+
},
|
|
48
|
+
MEDIA_INPUT_INVALID: { en: 'Input media is unsupported or corrupt: {cause}' },
|
|
49
|
+
OPERATION_ABORTED: { en: '{operation} was aborted' },
|
|
50
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aelionsdk/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0-rc.1",
|
|
4
4
|
"description": "Core time, diagnostics and resource primitives for AelionSDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"!dist/.tsbuildinfo"
|
|
28
28
|
],
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=24 <25"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|