@egret/contracts 0.0.0-stage → 7.0.1-rc.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 (43) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +22 -2
  4. package/README.zh-CN.md +23 -0
  5. package/dist/CancellationSignal.d.ts +12 -0
  6. package/dist/CancellationSignal.js +2 -0
  7. package/dist/Diagnostic.d.ts +11 -0
  8. package/dist/Diagnostic.js +2 -0
  9. package/dist/Disposable.d.ts +11 -0
  10. package/dist/Disposable.js +2 -0
  11. package/dist/HostAdapter.d.ts +17 -0
  12. package/dist/HostAdapter.js +2 -0
  13. package/dist/ImageData2D.d.ts +43 -0
  14. package/dist/ImageData2D.js +129 -0
  15. package/dist/Point2D.d.ts +6 -0
  16. package/dist/Point2D.js +2 -0
  17. package/dist/ProjectFormat.generated.d.ts +129 -0
  18. package/dist/ProjectFormat.generated.js +4 -0
  19. package/dist/RenderFrame2D.d.ts +20 -0
  20. package/dist/RenderFrame2D.js +2 -0
  21. package/dist/ResourceManifest.d.ts +75 -0
  22. package/dist/ResourceManifest.js +2 -0
  23. package/dist/SharedGeometry2D.d.ts +27 -0
  24. package/dist/SharedGeometry2D.js +176 -0
  25. package/dist/SharedMaterial2D.d.ts +39 -0
  26. package/dist/SharedMaterial2D.js +179 -0
  27. package/dist/SharedRenderFrame2D.d.ts +107 -0
  28. package/dist/SharedRenderFrame2D.js +4 -0
  29. package/dist/TextureViewRegion2D.d.ts +20 -0
  30. package/dist/TextureViewRegion2D.js +2 -0
  31. package/dist/TexturedGeometry2D.d.ts +25 -0
  32. package/dist/TexturedGeometry2D.js +165 -0
  33. package/dist/index.d.ts +20 -0
  34. package/dist/index.js +6 -0
  35. package/dist/resources/fontArtifact.d.ts +7 -0
  36. package/dist/resources/fontArtifact.js +37 -0
  37. package/dist/resources/index.d.ts +4 -0
  38. package/dist/resources/index.js +4 -0
  39. package/dist/resources/manifestAdmission.d.ts +10 -0
  40. package/dist/resources/manifestAdmission.js +457 -0
  41. package/dist/resources/sha256.d.ts +3 -0
  42. package/dist/resources/sha256.js +111 -0
  43. package/package.json +25 -4
@@ -0,0 +1,107 @@
1
+ import type { HostAdapter } from './HostAdapter.js';
2
+ import type { ImageData2D } from './ImageData2D.js';
3
+ import type { Matrix2D, Rectangle2D, ClipRectangle2D } from './RenderFrame2D.js';
4
+ import type { TexturedGeometry2D } from './TexturedGeometry2D.js';
5
+ import type { SharedGeometry2D } from './SharedGeometry2D.js';
6
+ import type { SharedMaterial2D } from './SharedMaterial2D.js';
7
+ import type { TextureViewRegion2D } from './TextureViewRegion2D.js';
8
+ export declare const SHARED_FRAME_PROFILE_2D = "egret.shared-frame2d/1";
9
+ export type SharedFrameProfile2D = typeof SHARED_FRAME_PROFILE_2D;
10
+ export type SharedOutputAlpha2D = 'premultiplied' | 'opaque';
11
+ export interface SharedFrameOptions2D {
12
+ readonly width: number;
13
+ readonly height: number;
14
+ readonly clearColor?: number;
15
+ readonly clearAlpha?: number;
16
+ readonly outputAlpha?: SharedOutputAlpha2D;
17
+ }
18
+ export interface SharedPage2D {
19
+ readonly source: ImageData2D;
20
+ readonly sourceRepresentation: 'egret.srgb-straight-rgba8/1';
21
+ readonly canonicalRepresentation: 'egret.alpha8-capped-srgb-pma8/1';
22
+ }
23
+ export interface SharedRegion2D extends TextureViewRegion2D {
24
+ readonly pageIndex: number;
25
+ }
26
+ export interface SharedDrawState2D {
27
+ readonly ordinal: number;
28
+ readonly occurrenceId: number;
29
+ readonly materialIndex: number;
30
+ readonly matrix: Matrix2D;
31
+ readonly opacity: number;
32
+ readonly clips: readonly ClipRectangle2D[];
33
+ }
34
+ export interface SharedRectangleCommand2D extends SharedDrawState2D {
35
+ readonly kind: 'rect';
36
+ readonly rect: Rectangle2D;
37
+ readonly fillColor: number;
38
+ readonly fillAlpha: number;
39
+ }
40
+ export interface SharedImageCommand2D extends SharedDrawState2D {
41
+ readonly kind: 'image';
42
+ readonly rect: Rectangle2D;
43
+ readonly regionIndex: number;
44
+ }
45
+ export interface SharedMeshCommand2D extends SharedDrawState2D {
46
+ readonly kind: 'mesh';
47
+ readonly regionIndex: number;
48
+ readonly geometryIndex: number;
49
+ }
50
+ /** Frozen effect inputs captured with the same frame and image ownership. */
51
+ export interface SharedEffect2D {
52
+ readonly blurRadius: number;
53
+ /** Egret's twenty numbers, applied to colour as it is seen after the blur. */
54
+ readonly colorMatrix?: readonly number[];
55
+ /** A glow or a hard outline from the alpha of the group, in logical pixels. */
56
+ readonly glow?: SharedGlow2D;
57
+ readonly maskPageIndex: number | undefined;
58
+ readonly maskRect: Rectangle2D | undefined;
59
+ readonly matrix: Matrix2D;
60
+ readonly clips: readonly ClipRectangle2D[];
61
+ }
62
+ export interface SharedGlow2D {
63
+ readonly kind: 'glow' | 'outline';
64
+ readonly color: number;
65
+ readonly alpha: number;
66
+ /** How far it spreads: the blur of a glow, the width of an outline. */
67
+ readonly spread: number;
68
+ readonly strength: number;
69
+ readonly inner: boolean;
70
+ readonly knockout: boolean;
71
+ readonly offsetX: number;
72
+ readonly offsetY: number;
73
+ }
74
+ export interface SharedBarrierCommand2D {
75
+ readonly effect?: SharedEffect2D;
76
+ readonly kind: 'barrier';
77
+ readonly ordinal: number;
78
+ readonly occurrenceId: number;
79
+ readonly boundaryId: number;
80
+ readonly reason: 'explicit-enter' | 'explicit-exit' | 'clip-enter' | 'clip-exit' | 'empty' | 'effect-enter' | 'effect-exit';
81
+ }
82
+ export type SharedRenderCommand2D = SharedRectangleCommand2D | SharedImageCommand2D | SharedMeshCommand2D | SharedBarrierCommand2D;
83
+ declare const sharedRenderFrame2DBrand: unique symbol;
84
+ export interface SharedRenderFrame2D {
85
+ readonly [sharedRenderFrame2DBrand]: true;
86
+ readonly profile: SharedFrameProfile2D;
87
+ readonly colorRecipe: 'egret.linear-srgb-pma/1';
88
+ readonly targetRepresentation: 'egret.srgb-pma8-target/1';
89
+ readonly outputRepresentation: 'egret.srgb-premultiplied-unorm8/1' | 'egret.srgb-opaque-unorm8/1';
90
+ readonly frameId: number;
91
+ readonly width: number;
92
+ readonly height: number;
93
+ readonly clearColor: number;
94
+ readonly clearAlpha: number;
95
+ readonly outputAlpha: SharedOutputAlpha2D;
96
+ readonly commands: readonly SharedRenderCommand2D[];
97
+ readonly pages: readonly SharedPage2D[];
98
+ readonly regions: readonly SharedRegion2D[];
99
+ readonly materials: readonly SharedMaterial2D[];
100
+ readonly geometries: readonly (TexturedGeometry2D | SharedGeometry2D)[];
101
+ }
102
+ export interface SharedRenderHostAdapter extends HostAdapter {
103
+ readonly sharedFrameProfile: SharedFrameProfile2D;
104
+ renderSharedFrame(frame: SharedRenderFrame2D): undefined;
105
+ }
106
+ export {};
107
+ //# sourceMappingURL=SharedRenderFrame2D.d.ts.map
@@ -0,0 +1,4 @@
1
+ // This erased shape is not frame authority. Only the Engine registers a fully
2
+ // captured immutable value; no public constructor or symbol can do so.
3
+ export const SHARED_FRAME_PROFILE_2D = 'egret.shared-frame2d/1';
4
+ //# sourceMappingURL=SharedRenderFrame2D.js.map
@@ -0,0 +1,20 @@
1
+ import type { TextureRegion2D } from './ImageData2D.js';
2
+ /** A packed page rectangle and its unrotated logical, top-left region. */
3
+ export interface TextureViewRegionInput2D {
4
+ readonly packed: TextureRegion2D;
5
+ readonly logicalWidth: number;
6
+ readonly logicalHeight: number;
7
+ readonly trimX: number;
8
+ readonly trimY: number;
9
+ readonly quarterTurn: 0 | 1 | 2 | 3;
10
+ }
11
+ /** Owned immutable metadata. Packed coordinates never stand in for logical size. */
12
+ export interface TextureViewRegion2D {
13
+ readonly packed: TextureRegion2D;
14
+ readonly logicalWidth: number;
15
+ readonly logicalHeight: number;
16
+ readonly trimX: number;
17
+ readonly trimY: number;
18
+ readonly quarterTurn: 0 | 1 | 2 | 3;
19
+ }
20
+ //# sourceMappingURL=TextureViewRegion2D.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TextureViewRegion2D.js.map
@@ -0,0 +1,25 @@
1
+ declare const texturedGeometry2DBrand: unique symbol;
2
+ export type TexturedFloatArray2D = Float32Array<ArrayBuffer> | Float64Array<ArrayBuffer>;
3
+ export type TexturedIndexArray2D = Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>;
4
+ export interface TexturedGeometry2DInput {
5
+ readonly positions: TexturedFloatArray2D;
6
+ readonly uvs: TexturedFloatArray2D;
7
+ readonly lightColors: TexturedFloatArray2D;
8
+ readonly indices: TexturedIndexArray2D;
9
+ }
10
+ /** Immutable CPU geometry identity; the brand grants no asset or GPU authority. */
11
+ export interface TexturedGeometry2D {
12
+ readonly [texturedGeometry2DBrand]: true;
13
+ readonly vertexCount: number;
14
+ readonly indexCount: number;
15
+ readonly triangleCount: number;
16
+ readonly logicalByteLength: number;
17
+ readonly positions: readonly number[];
18
+ readonly uvs: readonly number[];
19
+ readonly lightColors: readonly number[];
20
+ readonly indices: readonly number[];
21
+ }
22
+ export declare function createTexturedGeometry2D(input: TexturedGeometry2DInput): TexturedGeometry2D;
23
+ export declare function isTexturedGeometry2D(value: unknown): value is TexturedGeometry2D;
24
+ export {};
25
+ //# sourceMappingURL=TexturedGeometry2D.d.ts.map
@@ -0,0 +1,165 @@
1
+ // Capture normal-realm intrinsics before descriptor callbacks can replace them.
2
+ // Admission and copying do not read instance properties, iterators or species.
3
+ const Floats32 = Float32Array;
4
+ const Floats64 = Float64Array;
5
+ const Indices16 = Uint16Array;
6
+ const Indices32 = Uint32Array;
7
+ const Bytes = Uint8Array;
8
+ const Numbers = Array;
9
+ const apply = Reflect.apply;
10
+ const freeze = Object.freeze;
11
+ const defineProperty = Object.defineProperty;
12
+ const TypeFault = TypeError;
13
+ const RangeFault = RangeError;
14
+ const finite = Number.isFinite;
15
+ const integer = Number.isInteger;
16
+ const safeInteger = Number.isSafeInteger;
17
+ const typedArrayPrototype = Object.getPrototypeOf(Bytes.prototype);
18
+ const tagGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
19
+ const bufferGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, 'buffer').get;
20
+ const offsetGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, 'byteOffset').get;
21
+ const lengthGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, 'byteLength').get;
22
+ const bufferLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get;
23
+ const resizableGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'resizable')?.get;
24
+ const detachedGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'detached')?.get;
25
+ const setElements = typedArrayPrototype.set;
26
+ const weakHas = WeakMap.prototype.has;
27
+ const weakSet = WeakMap.prototype.set;
28
+ const owned = new WeakMap();
29
+ function read(source, key) {
30
+ try {
31
+ return source[key];
32
+ }
33
+ catch (cause) {
34
+ throw new TypeFault('Textured geometry descriptor read failed', { cause });
35
+ }
36
+ }
37
+ function floatBrand(value) {
38
+ const tag = apply(tagGetter, value, []);
39
+ if (tag !== 'Float32Array' && tag !== 'Float64Array')
40
+ throw new TypeFault('Textured geometry array brand is unsupported');
41
+ return tag;
42
+ }
43
+ function indexBrand(value) {
44
+ const tag = apply(tagGetter, value, []);
45
+ if (tag !== 'Uint16Array' && tag !== 'Uint32Array')
46
+ throw new TypeFault('Textured geometry array brand is unsupported');
47
+ return tag;
48
+ }
49
+ function elementLength(value, tag) {
50
+ const backing = apply(bufferGetter, value, []);
51
+ // This captured getter rejects SharedArrayBuffer, including cross realm.
52
+ // Native intrinsic faults escape intact rather than becoming policy errors.
53
+ apply(bufferLengthGetter, backing, []);
54
+ if (resizableGetter && apply(resizableGetter, backing, []))
55
+ throw new TypeFault('Textured geometry backing is unsupported');
56
+ if (detachedGetter) {
57
+ if (apply(detachedGetter, backing, []))
58
+ throw new TypeFault('Textured geometry backing is unsupported');
59
+ }
60
+ else {
61
+ // Reuse the established zero-length attachment check for older realms.
62
+ new Bytes(backing, 0, 0);
63
+ }
64
+ apply(offsetGetter, value, []);
65
+ const byteLength = apply(lengthGetter, value, []);
66
+ const elementBytes = tag === 'Float64Array' ? 8 : tag === 'Uint16Array' ? 2 : 4;
67
+ return byteLength / elementBytes;
68
+ }
69
+ function copyPayload(source, tag, length) {
70
+ const copy = tag === 'Float32Array'
71
+ ? new Floats32(length)
72
+ : tag === 'Float64Array'
73
+ ? new Floats64(length)
74
+ : tag === 'Uint16Array'
75
+ ? new Indices16(length)
76
+ : new Indices32(length);
77
+ // Native allocation/copy failures escape. TypedArray set reads only the
78
+ // intrinsic used range and cannot invoke the caller's iterator or species.
79
+ apply(setElements, copy, [source]);
80
+ return copy;
81
+ }
82
+ function canonical(source, length, kind, vertexCount) {
83
+ const result = new Numbers(length);
84
+ for (let index = 0; index < length; index++) {
85
+ const value = source[index];
86
+ if (!finite(value) ||
87
+ (kind === 'unit' && (value < 0 || value > 1)) ||
88
+ (kind === 'index' && (!integer(value) || value < 0 || value >= vertexCount))) {
89
+ throw new RangeFault('Textured geometry numeric range is invalid');
90
+ }
91
+ // Create own elements rather than invoking an inherited indexed setter.
92
+ // A null-prototype descriptor also excludes inherited get/set fields.
93
+ // Equality with zero converts both signed zeros to positive zero.
94
+ const descriptor = {
95
+ __proto__: null,
96
+ value: value === 0 ? 0 : value,
97
+ writable: true,
98
+ enumerable: true,
99
+ configurable: true
100
+ };
101
+ defineProperty(result, index, descriptor);
102
+ }
103
+ return freeze(result);
104
+ }
105
+ export function createTexturedGeometry2D(input) {
106
+ if (typeof input !== 'object' || input === null)
107
+ throw new TypeFault('Textured geometry descriptor must be an object');
108
+ // G1: finish all successful ordered reads before examining any field.
109
+ // Local staging makes descriptor reentry independent of this invocation.
110
+ const positionsInput = read(input, 'positions');
111
+ const uvsInput = read(input, 'uvs');
112
+ const lightColorsInput = read(input, 'lightColors');
113
+ const indicesInput = read(input, 'indices');
114
+ // G2 must finish for every field before G3 touches the first backing.
115
+ const positionsTag = floatBrand(positionsInput);
116
+ const uvsTag = floatBrand(uvsInput);
117
+ const lightColorsTag = floatBrand(lightColorsInput);
118
+ const indicesTag = indexBrand(indicesInput);
119
+ const positionsLength = elementLength(positionsInput, positionsTag);
120
+ const uvsLength = elementLength(uvsInput, uvsTag);
121
+ const lightColorsLength = elementLength(lightColorsInput, lightColorsTag);
122
+ const indicesLength = elementLength(indicesInput, indicesTag);
123
+ const vertexCount = positionsLength / 2;
124
+ const indexCount = indicesLength;
125
+ // G4: shape outranks capacity; both precede copies and canonical arrays.
126
+ if (!safeInteger(vertexCount) ||
127
+ !safeInteger(indexCount) ||
128
+ uvsLength !== positionsLength ||
129
+ lightColorsLength !== 4 * vertexCount ||
130
+ !((vertexCount === 0 && indexCount === 0) || (vertexCount >= 3 && indexCount >= 3 && indexCount % 3 === 0))) {
131
+ throw new RangeFault('Textured geometry array shape is invalid');
132
+ }
133
+ const logicalByteLength = 64 * vertexCount + 4 * indexCount;
134
+ if (vertexCount > 65536 || indexCount > 196608 || !safeInteger(logicalByteLength) || logicalByteLength > 4980736) {
135
+ throw new RangeFault('Textured geometry capacity exceeded');
136
+ }
137
+ // G5 completes every native copy before G6 examines any copied component.
138
+ const positionsCopy = copyPayload(positionsInput, positionsTag, positionsLength);
139
+ const uvsCopy = copyPayload(uvsInput, uvsTag, uvsLength);
140
+ const lightColorsCopy = copyPayload(lightColorsInput, lightColorsTag, lightColorsLength);
141
+ const indicesCopy = copyPayload(indicesInput, indicesTag, indicesLength);
142
+ const positions = canonical(positionsCopy, positionsLength, 'position', vertexCount);
143
+ const uvs = canonical(uvsCopy, uvsLength, 'unit', vertexCount);
144
+ const lightColors = canonical(lightColorsCopy, lightColorsLength, 'unit', vertexCount);
145
+ const indices = canonical(indicesCopy, indicesLength, 'index', vertexCount);
146
+ // Logical accounting describes canonical payload units, not physical heap
147
+ // usage or an allocation guarantee. Only the completed frozen value is owned.
148
+ const geometry = freeze({
149
+ vertexCount,
150
+ indexCount,
151
+ triangleCount: indexCount / 3,
152
+ logicalByteLength,
153
+ positions,
154
+ uvs,
155
+ lightColors,
156
+ indices
157
+ });
158
+ apply(weakSet, owned, [geometry, true]);
159
+ return geometry;
160
+ }
161
+ export function isTexturedGeometry2D(value) {
162
+ // WeakMap identity performs no property read, even on revoked Proxies.
163
+ return typeof value === 'object' && value !== null && apply(weakHas, owned, [value]);
164
+ }
165
+ //# sourceMappingURL=TexturedGeometry2D.js.map
@@ -0,0 +1,20 @@
1
+ export type { CancellationListener, CancellationSignal } from './CancellationSignal.js';
2
+ export type { Disposable, Releasable, ScopeValue } from './Disposable.js';
3
+ export type { Diagnostic, DiagnosticHandler } from './Diagnostic.js';
4
+ export type { HostAdapter } from './HostAdapter.js';
5
+ export type { Point2D } from './Point2D.js';
6
+ export type { Matrix2D, Rectangle2D, ClipRectangle2D } from './RenderFrame2D.js';
7
+ export { IMAGE_LIMITS_2D, createImageData2D, isImageData2D, copyImageData2DPixels } from './ImageData2D.js';
8
+ export type { ImageData2DInput, ImageData2D, TextureRegion2D } from './ImageData2D.js';
9
+ export { createTexturedGeometry2D, isTexturedGeometry2D } from './TexturedGeometry2D.js';
10
+ export type { TexturedFloatArray2D, TexturedIndexArray2D, TexturedGeometry2DInput, TexturedGeometry2D } from './TexturedGeometry2D.js';
11
+ export { createSharedMaterial2D, isSharedMaterial2D } from './SharedMaterial2D.js';
12
+ export type { SharedMaterialInput2D, SharedMaterial2D } from './SharedMaterial2D.js';
13
+ export { createSharedGeometry2D, isSharedGeometry2D } from './SharedGeometry2D.js';
14
+ export type { SharedFloatArray2D, SharedIndexArray2D, SharedGeometryInput2D, SharedGeometry2D } from './SharedGeometry2D.js';
15
+ export type { TextureViewRegionInput2D, TextureViewRegion2D } from './TextureViewRegion2D.js';
16
+ export { SHARED_FRAME_PROFILE_2D } from './SharedRenderFrame2D.js';
17
+ export type { SharedFrameProfile2D, SharedOutputAlpha2D, SharedFrameOptions2D, SharedPage2D, SharedRegion2D, SharedDrawState2D, SharedRectangleCommand2D, SharedImageCommand2D, SharedMeshCommand2D, SharedBarrierCommand2D, SharedRenderCommand2D, SharedRenderFrame2D, SharedRenderHostAdapter } from './SharedRenderFrame2D.js';
18
+ export type { ProjectId, EntityId, FileId, TransactionId, ProjectRevision, Sha256, JsonValue, JsonObject, ProjectVersionPins, ProjectReference, ProjectEntity, ProjectFileRole, ProjectFile, ProjectSnapshot, ProjectTransactionSource, ProjectTransactionScope, ProjectOperation, ProjectEditTransaction, ProjectRestoreTransaction, ProjectTransaction, ProjectHistory } from './ProjectFormat.generated.js';
19
+ export type { SharedEffect2D, SharedGlow2D } from './SharedRenderFrame2D.js';
20
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { IMAGE_LIMITS_2D, createImageData2D, isImageData2D, copyImageData2DPixels } from './ImageData2D.js';
2
+ export { createTexturedGeometry2D, isTexturedGeometry2D } from './TexturedGeometry2D.js';
3
+ export { createSharedMaterial2D, isSharedMaterial2D } from './SharedMaterial2D.js';
4
+ export { createSharedGeometry2D, isSharedGeometry2D } from './SharedGeometry2D.js';
5
+ export { SHARED_FRAME_PROFILE_2D } from './SharedRenderFrame2D.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ /** Bounded SFNT container admission; native decoding still owns glyph/font semantics. */
2
+ export declare function inspectFontArtifact(bytes: Uint8Array): Readonly<{
3
+ format: 'truetype' | 'opentype';
4
+ byteLength: number;
5
+ tables: number;
6
+ }>;
7
+ //# sourceMappingURL=fontArtifact.d.ts.map
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /** Bounded SFNT container admission; native decoding still owns glyph/font semantics. */
3
+ export function inspectFontArtifact(bytes) {
4
+ const typed = Object.getPrototypeOf(Uint8Array.prototype);
5
+ if (Reflect.apply(Object.getOwnPropertyDescriptor(typed, Symbol.toStringTag).get, bytes, []) !== 'Uint8Array')
6
+ throw new TypeError('FONT_ARTIFACT_STORAGE');
7
+ const get = (name) => Reflect.apply(Object.getOwnPropertyDescriptor(typed, name).get, bytes, []);
8
+ const buffer = get('buffer'), offset = get('byteOffset'), length = get('byteLength');
9
+ // Reject shared/resizable/detached storage before constructing a parser view.
10
+ Reflect.apply(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'byteLength').get, buffer, []);
11
+ const resizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'resizable')?.get;
12
+ if (resizable && Reflect.apply(resizable, buffer, []))
13
+ throw new TypeError('FONT_ARTIFACT_STORAGE');
14
+ if (length < 28 || length > 33554432)
15
+ throw new RangeError('FONT_ARTIFACT_LIMIT');
16
+ const data = new DataView(buffer, offset, length), signature = data.getUint32(0), tables = data.getUint16(4);
17
+ const format = signature === 0x00010000 ? 'truetype' : signature === 0x4f54544f ? 'opentype' : undefined;
18
+ if (!format || tables < 1 || tables > 256 || 12 + 16 * tables > length)
19
+ throw new TypeError('FONT_ARTIFACT_HEADER');
20
+ const tags = new Set();
21
+ for (let i = 0; i < tables; i++) {
22
+ const row = 12 + 16 * i, tag = data.getUint32(row), start = data.getUint32(row + 8), size = data.getUint32(row + 12);
23
+ if (tags.has(tag) || start < 12 + 16 * tables || start % 4 !== 0 || start > length || size > length - start)
24
+ throw new TypeError('FONT_ARTIFACT_TABLE');
25
+ tags.add(tag);
26
+ }
27
+ // These common tables are mandatory for this finite standalone-face profile.
28
+ for (const tag of [0x68656164, 0x6d617870, 0x636d6170, 0x68686561, 0x686d7478])
29
+ if (!tags.has(tag))
30
+ throw new TypeError('FONT_ARTIFACT_REQUIRED_TABLE');
31
+ if (format === 'truetype' && (!tags.has(0x676c7966) || !tags.has(0x6c6f6361)))
32
+ throw new TypeError('FONT_ARTIFACT_REQUIRED_TABLE');
33
+ if (format === 'opentype' && !tags.has(0x43464620) && !tags.has(0x43464632))
34
+ throw new TypeError('FONT_ARTIFACT_REQUIRED_TABLE');
35
+ return Object.freeze({ format, byteLength: length, tables });
36
+ }
37
+ //# sourceMappingURL=fontArtifact.js.map
@@ -0,0 +1,4 @@
1
+ export { validateResourceBuildPlanDescription, evaluateResourceBuildKeys, validateResourceBuildDescription, admitResourceManifest, buildResourceManifest, serializeResourceManifest, isAdmittedResourceManifest, getResourceManifestIdentityInputs } from './manifestAdmission.js';
2
+ export type { ResourceBuildSourceEntry, ResourceBuildPlanDescription, ResourceBuildKeyEntry, ResourceBuildKeyPlan, ResourceBuildEntry, ResourceBuildDescription, ResourceManifestEntry, AdmittedResourceManifest, ResourceManifestDiagnosticCode, ResourceManifestDiagnostic, ResourceManifestResult, ResourceManifestIdentityInputs } from '../ResourceManifest.js';
3
+ export { inspectFontArtifact } from './fontArtifact.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ export { validateResourceBuildPlanDescription, evaluateResourceBuildKeys, validateResourceBuildDescription, admitResourceManifest, buildResourceManifest, serializeResourceManifest, isAdmittedResourceManifest, getResourceManifestIdentityInputs } from './manifestAdmission.js';
3
+ export { inspectFontArtifact } from './fontArtifact.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ import type { AdmittedResourceManifest, ResourceBuildDescription, ResourceBuildPlanDescription, ResourceBuildKeyPlan, ResourceManifestIdentityInputs, ResourceManifestResult } from '../ResourceManifest.js';
2
+ export declare function validateResourceBuildPlanDescription(input: unknown): ResourceManifestResult<ResourceBuildPlanDescription>;
3
+ export declare function evaluateResourceBuildKeys(description: ResourceBuildPlanDescription): ResourceManifestResult<ResourceBuildKeyPlan>;
4
+ export declare function validateResourceBuildDescription(input: unknown): ResourceManifestResult<ResourceBuildDescription>;
5
+ export declare function buildResourceManifest(description: ResourceBuildDescription): ResourceManifestResult<AdmittedResourceManifest>;
6
+ export declare function admitResourceManifest(value: unknown): ResourceManifestResult<AdmittedResourceManifest>;
7
+ export declare function isAdmittedResourceManifest(value: unknown): value is AdmittedResourceManifest;
8
+ export declare function serializeResourceManifest(manifest: AdmittedResourceManifest): ResourceManifestResult<string>;
9
+ export declare function getResourceManifestIdentityInputs(manifest: AdmittedResourceManifest, id: string): ResourceManifestIdentityInputs;
10
+ //# sourceMappingURL=manifestAdmission.d.ts.map