@egret/runtime 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 (155) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +70 -2
  4. package/README.zh-CN.md +71 -0
  5. package/dist/AssetLease.d.ts +23 -0
  6. package/dist/AssetLease.js +69 -0
  7. package/dist/AssetManager.d.ts +56 -0
  8. package/dist/AssetManager.js +451 -0
  9. package/dist/AssetRef.d.ts +20 -0
  10. package/dist/AssetRef.js +32 -0
  11. package/dist/Bitmap.d.ts +40 -0
  12. package/dist/Bitmap.js +545 -0
  13. package/dist/ByteReader.d.ts +30 -0
  14. package/dist/ByteReader.js +177 -0
  15. package/dist/ByteWriter.d.ts +29 -0
  16. package/dist/ByteWriter.js +180 -0
  17. package/dist/CancellationController.d.ts +10 -0
  18. package/dist/CancellationController.js +66 -0
  19. package/dist/DisplayObject.d.ts +89 -0
  20. package/dist/DisplayObject.js +340 -0
  21. package/dist/DisplayObjectContainer.d.ts +28 -0
  22. package/dist/DisplayObjectContainer.js +226 -0
  23. package/dist/EgretError.d.ts +11 -0
  24. package/dist/EgretError.js +36 -0
  25. package/dist/Event.d.ts +45 -0
  26. package/dist/Event.js +84 -0
  27. package/dist/EventDispatcher.d.ts +24 -0
  28. package/dist/EventDispatcher.js +178 -0
  29. package/dist/Graphics.d.ts +106 -0
  30. package/dist/Graphics.js +504 -0
  31. package/dist/Mesh2D.d.ts +27 -0
  32. package/dist/Mesh2D.js +200 -0
  33. package/dist/NineSliceBitmap.d.ts +24 -0
  34. package/dist/NineSliceBitmap.js +164 -0
  35. package/dist/NineSliceGeometry2D.d.ts +18 -0
  36. package/dist/NineSliceGeometry2D.js +126 -0
  37. package/dist/Scope.d.ts +18 -0
  38. package/dist/Scope.js +133 -0
  39. package/dist/SequencePlayer.d.ts +12 -0
  40. package/dist/SequencePlayer.js +69 -0
  41. package/dist/Sprite.d.ts +8 -0
  42. package/dist/Sprite.js +12 -0
  43. package/dist/Stage.d.ts +14 -0
  44. package/dist/Stage.js +31 -0
  45. package/dist/Texture.d.ts +29 -0
  46. package/dist/Texture.js +177 -0
  47. package/dist/assetManagerOwnerState.d.ts +36 -0
  48. package/dist/assetManagerOwnerState.js +115 -0
  49. package/dist/assetState.d.ts +44 -0
  50. package/dist/assetState.js +2 -0
  51. package/dist/atlasFrameLayout.d.ts +21 -0
  52. package/dist/atlasFrameLayout.js +48 -0
  53. package/dist/bitmapDisplayState.d.ts +24 -0
  54. package/dist/bitmapDisplayState.js +22 -0
  55. package/dist/coordinateInverse.d.ts +4 -0
  56. package/dist/coordinateInverse.js +107 -0
  57. package/dist/diagnostics.d.ts +4 -0
  58. package/dist/diagnostics.js +13 -0
  59. package/dist/displayBounds.d.ts +9 -0
  60. package/dist/displayBounds.js +181 -0
  61. package/dist/displayCoordinates.d.ts +8 -0
  62. package/dist/displayCoordinates.js +81 -0
  63. package/dist/displayHitState.d.ts +18 -0
  64. package/dist/displayHitState.js +97 -0
  65. package/dist/displayHitTest.d.ts +8 -0
  66. package/dist/displayHitTest.js +219 -0
  67. package/dist/displayInputOperations.d.ts +12 -0
  68. package/dist/displayInputOperations.js +71 -0
  69. package/dist/displayTransform.d.ts +5 -0
  70. package/dist/displayTransform.js +38 -0
  71. package/dist/displayTreeState.d.ts +90 -0
  72. package/dist/displayTreeState.js +450 -0
  73. package/dist/displayVisualState.d.ts +74 -0
  74. package/dist/displayVisualState.js +140 -0
  75. package/dist/errorHelp.d.ts +14 -0
  76. package/dist/errorHelp.js +432 -0
  77. package/dist/errorHelpZh.d.ts +5 -0
  78. package/dist/errorHelpZh.js +340 -0
  79. package/dist/graphicsFill.d.ts +37 -0
  80. package/dist/graphicsFill.js +302 -0
  81. package/dist/graphicsShape.d.ts +144 -0
  82. package/dist/graphicsShape.js +755 -0
  83. package/dist/index.d.ts +50 -0
  84. package/dist/index.js +28 -0
  85. package/dist/input/PointerRouter.d.ts +4 -0
  86. package/dist/input/PointerRouter.js +453 -0
  87. package/dist/input/index.d.ts +3 -0
  88. package/dist/input/index.js +3 -0
  89. package/dist/input/types.d.ts +58 -0
  90. package/dist/input/types.js +3 -0
  91. package/dist/meshCaptureSnapshot.d.ts +5 -0
  92. package/dist/meshCaptureSnapshot.js +13 -0
  93. package/dist/meshDisplayState.d.ts +18 -0
  94. package/dist/meshDisplayState.js +21 -0
  95. package/dist/ownership.d.ts +75 -0
  96. package/dist/ownership.js +157 -0
  97. package/dist/paragraph/Paragraph.d.ts +13 -0
  98. package/dist/paragraph/Paragraph.js +193 -0
  99. package/dist/paragraph/ParagraphCache.d.ts +5 -0
  100. package/dist/paragraph/ParagraphCache.js +354 -0
  101. package/dist/paragraph/geometry.d.ts +4 -0
  102. package/dist/paragraph/geometry.js +180 -0
  103. package/dist/paragraph/index.d.ts +3 -0
  104. package/dist/paragraph/index.js +3 -0
  105. package/dist/paragraph/request.d.ts +6 -0
  106. package/dist/paragraph/request.js +191 -0
  107. package/dist/paragraph/types.d.ts +183 -0
  108. package/dist/paragraph/types.js +2 -0
  109. package/dist/preparedDisplaySubtree.d.ts +7 -0
  110. package/dist/preparedDisplaySubtree.js +205 -0
  111. package/dist/renderEffect.d.ts +47 -0
  112. package/dist/renderEffect.js +87 -0
  113. package/dist/sequenceClip.d.ts +42 -0
  114. package/dist/sequenceClip.js +196 -0
  115. package/dist/sharedFrameCapture.d.ts +24 -0
  116. package/dist/sharedFrameCapture.js +1069 -0
  117. package/dist/spriteSheet.d.ts +34 -0
  118. package/dist/spriteSheet.js +321 -0
  119. package/dist/srgbBytes.d.ts +3 -0
  120. package/dist/srgbBytes.js +64 -0
  121. package/dist/text/TextField.d.ts +13 -0
  122. package/dist/text/TextField.js +261 -0
  123. package/dist/text/TextRasterCache.d.ts +5 -0
  124. package/dist/text/TextRasterCache.js +1191 -0
  125. package/dist/text/budget.d.ts +51 -0
  126. package/dist/text/budget.js +116 -0
  127. package/dist/text/index.d.ts +4 -0
  128. package/dist/text/index.js +3 -0
  129. package/dist/text/plan.d.ts +16 -0
  130. package/dist/text/plan.js +238 -0
  131. package/dist/text/request.d.ts +44 -0
  132. package/dist/text/request.js +303 -0
  133. package/dist/text/types.d.ts +179 -0
  134. package/dist/text/types.js +2 -0
  135. package/dist/textDisplayState.d.ts +21 -0
  136. package/dist/textDisplayState.js +27 -0
  137. package/dist/ui/displayCommit.d.ts +43 -0
  138. package/dist/ui/displayCommit.js +376 -0
  139. package/dist/ui/editing.d.ts +3 -0
  140. package/dist/ui/editing.js +3 -0
  141. package/dist/ui/heightIndex.d.ts +35 -0
  142. package/dist/ui/heightIndex.js +295 -0
  143. package/dist/ui/index.d.ts +6 -0
  144. package/dist/ui/index.js +6 -0
  145. package/dist/ui/layout.d.ts +9 -0
  146. package/dist/ui/layout.js +349 -0
  147. package/dist/ui/managedState.d.ts +12 -0
  148. package/dist/ui/managedState.js +44 -0
  149. package/dist/ui/textEditState.d.ts +4 -0
  150. package/dist/ui/textEditState.js +206 -0
  151. package/dist/ui/textEditTypes.d.ts +48 -0
  152. package/dist/ui/textEditTypes.js +2 -0
  153. package/dist/ui/types.d.ts +99 -0
  154. package/dist/ui/types.js +2 -0
  155. package/package.json +44 -4
@@ -0,0 +1,177 @@
1
+ export const BYTE_READER_LIMITS = Object.freeze({ maxBytes: 16777216 });
2
+ // Capture intrinsic operations, rather than consulting source properties,
3
+ // iterators, constructors or species during admission and interpretation.
4
+ const Bytes = Uint8Array;
5
+ const View = DataView;
6
+ const apply = Reflect.apply;
7
+ const TypeFault = TypeError;
8
+ const RangeFault = RangeError;
9
+ const safeInteger = Number.isSafeInteger;
10
+ const typedArrayPrototype = Object.getPrototypeOf(Bytes.prototype);
11
+ const tagGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
12
+ const bufferGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
13
+ const lengthGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength").get;
14
+ const bufferLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
15
+ const resizableGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
16
+ const detachedGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "detached")?.get;
17
+ const setBytes = typedArrayPrototype.set;
18
+ const weakGet = WeakMap.prototype.get;
19
+ const weakSet = WeakMap.prototype.set;
20
+ const signedByte = View.prototype.getInt8;
21
+ const unsignedByte = View.prototype.getUint8;
22
+ const signedShort = View.prototype.getInt16;
23
+ const unsignedShort = View.prototype.getUint16;
24
+ const signedInt = View.prototype.getInt32;
25
+ const unsignedInt = View.prototype.getUint32;
26
+ const float = View.prototype.getFloat32;
27
+ const double = View.prototype.getFloat64;
28
+ const states = new WeakMap();
29
+ function stateOf(receiver) {
30
+ // Weak identity lookup invokes no properties or traps on forged receivers.
31
+ const state = apply(weakGet, states, [receiver]);
32
+ if (state === undefined)
33
+ throw new TypeFault("ByteReader receiver is not authentic");
34
+ return state;
35
+ }
36
+ function openState(receiver) {
37
+ const state = stateOf(receiver);
38
+ if (state.disposed)
39
+ throw new TypeFault("ByteReader is disposed");
40
+ return state;
41
+ }
42
+ function byteOrder(value) {
43
+ if (value !== "bigEndian" && value !== "littleEndian")
44
+ throw new TypeFault("Unsupported byte order");
45
+ return value;
46
+ }
47
+ function integer(value) {
48
+ if (typeof value !== "number")
49
+ throw new TypeFault("Byte position or count must be numeric");
50
+ if (!safeInteger(value) || value < 0)
51
+ throw new RangeFault("Byte position or count must be a nonnegative safe integer");
52
+ return value === 0 ? 0 : value;
53
+ }
54
+ function requireAvailable(state, count) {
55
+ if (count > state.length - state.position)
56
+ throw new RangeFault("Insufficient bytes");
57
+ }
58
+ function readScalar(receiver, width, operation) {
59
+ const state = openState(receiver);
60
+ requireAvailable(state, width);
61
+ const position = state.position;
62
+ const value = apply(operation, state.view, [position, state.endian === "littleEndian"]);
63
+ // A native interpretation failure escapes intact before the cursor commits.
64
+ state.position = position + width;
65
+ return value;
66
+ }
67
+ /** Read-only owned binary snapshot. Explicit Scope.use() can own its lifetime. */
68
+ export class ByteReader {
69
+ constructor(source, endian = "bigEndian") {
70
+ if (apply(tagGetter, source, []) !== "Uint8Array")
71
+ throw new TypeFault("Source must be intrinsic Uint8Array");
72
+ const backing = apply(bufferGetter, source, []);
73
+ // Ordinary ArrayBuffer branding rejects shared storage across realms too.
74
+ apply(bufferLengthGetter, backing, []);
75
+ if (resizableGetter && apply(resizableGetter, backing, []))
76
+ throw new TypeFault("Resizable source backing is unsupported");
77
+ if (detachedGetter) {
78
+ if (apply(detachedGetter, backing, []))
79
+ throw new TypeFault("Detached source backing is unsupported");
80
+ }
81
+ else {
82
+ // A zero-payload intrinsic view still distinguishes detached empty input.
83
+ new Bytes(backing, 0, 0);
84
+ }
85
+ const order = byteOrder(endian);
86
+ const length = apply(lengthGetter, source, []);
87
+ if (length > BYTE_READER_LIMITS.maxBytes)
88
+ throw new RangeFault("ByteReader source capacity exceeded");
89
+ // All admission checks precede owned payload allocation. Native bulk copy
90
+ // reads the intrinsic selected range even on subclasses/offset views.
91
+ const bytes = new Bytes(length);
92
+ apply(setBytes, bytes, [source]);
93
+ const view = new View(apply(bufferGetter, bytes, []));
94
+ apply(weakSet, states, [this, { bytes, view, length, position: 0, endian: order, disposed: false }]);
95
+ }
96
+ get length() {
97
+ return stateOf(this).length;
98
+ }
99
+ get position() {
100
+ return stateOf(this).position;
101
+ }
102
+ get bytesAvailable() {
103
+ const state = stateOf(this);
104
+ return state.length - state.position;
105
+ }
106
+ get disposed() {
107
+ return stateOf(this).disposed;
108
+ }
109
+ get endian() {
110
+ return stateOf(this).endian;
111
+ }
112
+ set endian(value) {
113
+ const state = openState(this);
114
+ state.endian = byteOrder(value);
115
+ }
116
+ seek(position) {
117
+ const state = openState(this);
118
+ const next = integer(position);
119
+ if (next > state.length)
120
+ throw new RangeFault("Position exceeds reader length");
121
+ state.position = next;
122
+ }
123
+ skip(count) {
124
+ const state = openState(this);
125
+ const width = integer(count);
126
+ requireAvailable(state, width);
127
+ state.position += width;
128
+ }
129
+ readByte() {
130
+ return readScalar(this, 1, signedByte);
131
+ }
132
+ readUnsignedByte() {
133
+ return readScalar(this, 1, unsignedByte);
134
+ }
135
+ readShort() {
136
+ return readScalar(this, 2, signedShort);
137
+ }
138
+ readUnsignedShort() {
139
+ return readScalar(this, 2, unsignedShort);
140
+ }
141
+ readInt() {
142
+ return readScalar(this, 4, signedInt);
143
+ }
144
+ readUnsignedInt() {
145
+ return readScalar(this, 4, unsignedInt);
146
+ }
147
+ readFloat() {
148
+ return readScalar(this, 4, float);
149
+ }
150
+ readDouble() {
151
+ return readScalar(this, 8, double);
152
+ }
153
+ readBytes(count) {
154
+ const state = openState(this);
155
+ const width = count === undefined ? state.length - state.position : integer(count);
156
+ requireAvailable(state, width);
157
+ const position = state.position;
158
+ const result = new Bytes(width);
159
+ const selected = new Bytes(apply(bufferGetter, state.bytes, []), position, width);
160
+ apply(setBytes, result, [selected]);
161
+ // Fresh output owns its buffer; allocation/copy must finish before commit.
162
+ state.position = position + width;
163
+ return result;
164
+ }
165
+ /** Terminal release drops both storage references without claiming zeroization. */
166
+ dispose() {
167
+ const state = stateOf(this);
168
+ if (state.disposed)
169
+ return;
170
+ state.disposed = true;
171
+ state.bytes = undefined;
172
+ state.view = undefined;
173
+ state.length = 0;
174
+ state.position = 0;
175
+ }
176
+ }
177
+ //# sourceMappingURL=ByteReader.js.map
@@ -0,0 +1,29 @@
1
+ import type { Disposable } from "@egret/contracts";
2
+ import type { ByteOrder } from "./ByteReader.js";
3
+ export declare const BYTE_WRITER_LIMITS: Readonly<{
4
+ readonly maxBytes: 16777216;
5
+ }>;
6
+ /** Fixed-capacity owned binary appends. Scope.use() can own the writer's lifetime. */
7
+ export declare class ByteWriter implements Disposable {
8
+ private readonly byteWriterBrand;
9
+ constructor(capacity: number, endian?: ByteOrder);
10
+ get capacity(): number;
11
+ get length(): number;
12
+ get remainingCapacity(): number;
13
+ get disposed(): boolean;
14
+ get endian(): ByteOrder;
15
+ set endian(value: ByteOrder);
16
+ writeByte(value: number): void;
17
+ writeUnsignedByte(value: number): void;
18
+ writeShort(value: number): void;
19
+ writeUnsignedShort(value: number): void;
20
+ writeInt(value: number): void;
21
+ writeUnsignedInt(value: number): void;
22
+ writeFloat(value: number): void;
23
+ writeDouble(value: number): void;
24
+ writeBytes(source: Uint8Array<ArrayBuffer>): void;
25
+ toUint8Array(): Uint8Array<ArrayBuffer>;
26
+ /** Terminal release drops storage references; prior snapshots stay independent. */
27
+ dispose(): void;
28
+ }
29
+ //# sourceMappingURL=ByteWriter.d.ts.map
@@ -0,0 +1,180 @@
1
+ export const BYTE_WRITER_LIMITS = Object.freeze({ maxBytes: 16777216 });
2
+ // Capture native slot access and writes once. Caller properties, iterators and
3
+ // species do not participate in admission, append or snapshot ownership.
4
+ const Bytes = Uint8Array;
5
+ const View = DataView;
6
+ const apply = Reflect.apply;
7
+ const TypeFault = TypeError;
8
+ const RangeFault = RangeError;
9
+ const safeInteger = Number.isSafeInteger;
10
+ const typedArrayPrototype = Object.getPrototypeOf(Bytes.prototype);
11
+ const tagGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
12
+ const bufferGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
13
+ const lengthGetter = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteLength").get;
14
+ const bufferLengthGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
15
+ const resizableGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
16
+ const detachedGetter = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "detached")?.get;
17
+ const setBytes = typedArrayPrototype.set;
18
+ const weakGet = WeakMap.prototype.get;
19
+ const weakSet = WeakMap.prototype.set;
20
+ const signedByte = View.prototype.setInt8;
21
+ const unsignedByte = View.prototype.setUint8;
22
+ const signedShort = View.prototype.setInt16;
23
+ const unsignedShort = View.prototype.setUint16;
24
+ const signedInt = View.prototype.setInt32;
25
+ const unsignedInt = View.prototype.setUint32;
26
+ const float = View.prototype.setFloat32;
27
+ const double = View.prototype.setFloat64;
28
+ const states = new WeakMap();
29
+ function stateOf(receiver) {
30
+ // Private identity lookup authenticates without reading receiver properties.
31
+ const state = apply(weakGet, states, [receiver]);
32
+ if (state === undefined)
33
+ throw new TypeFault("ByteWriter receiver is not authentic");
34
+ return state;
35
+ }
36
+ function openState(receiver) {
37
+ const state = stateOf(receiver);
38
+ if (state.disposed)
39
+ throw new TypeFault("ByteWriter is disposed");
40
+ return state;
41
+ }
42
+ function byteOrder(value) {
43
+ if (value !== "bigEndian" && value !== "littleEndian")
44
+ throw new TypeFault("Unsupported byte order");
45
+ return value;
46
+ }
47
+ function capacityValue(value) {
48
+ if (typeof value !== "number")
49
+ throw new TypeFault("ByteWriter capacity must be numeric");
50
+ if (!safeInteger(value) || value < 0)
51
+ throw new RangeFault("Capacity must be a nonnegative safe integer");
52
+ return value === 0 ? 0 : value;
53
+ }
54
+ function requireCapacity(state, width) {
55
+ if (width > state.capacity - state.length)
56
+ throw new RangeFault("Insufficient remaining capacity");
57
+ }
58
+ function appendScalar(receiver, value, width, operation, minimum, maximum) {
59
+ const state = openState(receiver);
60
+ if (typeof value !== "number")
61
+ throw new TypeFault("Scalar value must be numeric");
62
+ if (minimum !== undefined && (!safeInteger(value) || value < minimum || value > maximum)) {
63
+ throw new RangeFault("Integer value is outside its byte domain");
64
+ }
65
+ // Domain refusal wins over capacity refusal. Native IEEE conversion handles
66
+ // every admitted floating number, including signed zero, NaN and infinity.
67
+ requireCapacity(state, width);
68
+ const offset = state.length;
69
+ apply(operation, state.view, [offset, value, state.endian === "littleEndian"]);
70
+ // A faithful native write may throw after touching the uncommitted tail.
71
+ // Publish length only on success; snapshots never expose that failed tail.
72
+ state.length = offset + width;
73
+ }
74
+ function sourceLength(source) {
75
+ if (apply(tagGetter, source, []) !== "Uint8Array")
76
+ throw new TypeFault("Source must be intrinsic Uint8Array");
77
+ const backing = apply(bufferGetter, source, []);
78
+ // The ordinary-buffer intrinsic also rejects cross-realm shared backing.
79
+ apply(bufferLengthGetter, backing, []);
80
+ if (resizableGetter && apply(resizableGetter, backing, []))
81
+ throw new TypeFault("Resizable source backing is unsupported");
82
+ if (detachedGetter) {
83
+ if (apply(detachedGetter, backing, []))
84
+ throw new TypeFault("Detached source backing is unsupported");
85
+ }
86
+ else {
87
+ // A zero-length view probes attachment even for an empty selected source.
88
+ new Bytes(backing, 0, 0);
89
+ }
90
+ return apply(lengthGetter, source, []);
91
+ }
92
+ /** Fixed-capacity owned binary appends. Scope.use() can own the writer's lifetime. */
93
+ export class ByteWriter {
94
+ constructor(capacity, endian = "bigEndian") {
95
+ // Preserve capacity-domain -> order -> ceiling -> allocation precedence.
96
+ const size = capacityValue(capacity);
97
+ const order = byteOrder(endian);
98
+ if (size > BYTE_WRITER_LIMITS.maxBytes)
99
+ throw new RangeFault("ByteWriter capacity exceeded");
100
+ const bytes = new Bytes(size);
101
+ const view = new View(apply(bufferGetter, bytes, []));
102
+ // Failed construction publishes no state; intrinsic faults escape intact.
103
+ apply(weakSet, states, [this, { bytes, view, capacity: size, length: 0, endian: order, disposed: false }]);
104
+ }
105
+ get capacity() {
106
+ return stateOf(this).capacity;
107
+ }
108
+ get length() {
109
+ return stateOf(this).length;
110
+ }
111
+ get remainingCapacity() {
112
+ const state = stateOf(this);
113
+ return state.capacity - state.length;
114
+ }
115
+ get disposed() {
116
+ return stateOf(this).disposed;
117
+ }
118
+ get endian() {
119
+ return stateOf(this).endian;
120
+ }
121
+ set endian(value) {
122
+ const state = openState(this);
123
+ state.endian = byteOrder(value);
124
+ }
125
+ writeByte(value) {
126
+ appendScalar(this, value, 1, signedByte, -128, 127);
127
+ }
128
+ writeUnsignedByte(value) {
129
+ appendScalar(this, value, 1, unsignedByte, 0, 255);
130
+ }
131
+ writeShort(value) {
132
+ appendScalar(this, value, 2, signedShort, -32768, 32767);
133
+ }
134
+ writeUnsignedShort(value) {
135
+ appendScalar(this, value, 2, unsignedShort, 0, 65535);
136
+ }
137
+ writeInt(value) {
138
+ appendScalar(this, value, 4, signedInt, -2147483648, 2147483647);
139
+ }
140
+ writeUnsignedInt(value) {
141
+ appendScalar(this, value, 4, unsignedInt, 0, 4294967295);
142
+ }
143
+ writeFloat(value) {
144
+ appendScalar(this, value, 4, float);
145
+ }
146
+ writeDouble(value) {
147
+ appendScalar(this, value, 8, double);
148
+ }
149
+ writeBytes(source) {
150
+ const state = openState(this);
151
+ const width = sourceLength(source);
152
+ requireCapacity(state, width);
153
+ const offset = state.length;
154
+ // Native set uses the selected intrinsic range without a second payload
155
+ // allocation, caller getters, iteration or species-dependent conversion.
156
+ apply(setBytes, state.bytes, [source, offset]);
157
+ state.length = offset + width;
158
+ }
159
+ toUint8Array() {
160
+ const state = openState(this);
161
+ const result = new Bytes(state.length);
162
+ const committed = new Bytes(apply(bufferGetter, state.bytes, []), 0, state.length);
163
+ // Only the committed prefix is copied into fresh, tightly backed storage.
164
+ // Allocation/copy failure changes no writer state or published snapshot.
165
+ apply(setBytes, result, [committed]);
166
+ return result;
167
+ }
168
+ /** Terminal release drops storage references; prior snapshots stay independent. */
169
+ dispose() {
170
+ const state = stateOf(this);
171
+ if (state.disposed)
172
+ return;
173
+ state.disposed = true;
174
+ state.bytes = undefined;
175
+ state.view = undefined;
176
+ state.capacity = 0;
177
+ state.length = 0;
178
+ }
179
+ }
180
+ //# sourceMappingURL=ByteWriter.js.map
@@ -0,0 +1,10 @@
1
+ import type { CancellationSignal, DiagnosticHandler } from "@egret/contracts";
2
+ /** Owns the mutable signal; consumers receive the read-only cancellation port. */
3
+ export declare class CancellationController {
4
+ private readonly mutableSignal;
5
+ private readonly onDiagnostic;
6
+ readonly signal: CancellationSignal;
7
+ constructor(onDiagnostic?: DiagnosticHandler);
8
+ abort(reason?: unknown): void;
9
+ }
10
+ //# sourceMappingURL=CancellationController.d.ts.map
@@ -0,0 +1,66 @@
1
+ import { reportDiagnostic } from "./diagnostics.js";
2
+ class Signal {
3
+ cancelled = false;
4
+ cancellationReason = undefined;
5
+ subscriptions = new Map();
6
+ get aborted() {
7
+ return this.cancelled;
8
+ }
9
+ get reason() {
10
+ return this.cancellationReason;
11
+ }
12
+ addEventListener(_type, listener, options = {}) {
13
+ if (this.cancelled || this.subscriptions.has(listener))
14
+ return;
15
+ this.subscriptions.set(listener, { listener, once: options.once ?? false, active: true });
16
+ }
17
+ removeEventListener(_type, listener) {
18
+ const subscription = this.subscriptions.get(listener);
19
+ if (subscription === undefined)
20
+ return;
21
+ subscription.active = false;
22
+ this.subscriptions.delete(listener);
23
+ }
24
+ abort(reason, onDiagnostic) {
25
+ if (this.cancelled)
26
+ return;
27
+ this.cancelled = true;
28
+ this.cancellationReason = reason;
29
+ // Snapshot listeners; removals take effect through active flags during callbacks.
30
+ const candidates = [...this.subscriptions.values()];
31
+ for (const candidate of candidates) {
32
+ if (!candidate.active)
33
+ continue;
34
+ if (candidate.once) {
35
+ // Retire internally before callbacks; public removal is replaceable.
36
+ candidate.active = false;
37
+ this.subscriptions.delete(candidate.listener);
38
+ }
39
+ try {
40
+ candidate.listener();
41
+ }
42
+ catch (cause) {
43
+ reportDiagnostic(onDiagnostic, {
44
+ code: "CANCELLATION_LISTENER_FAILED",
45
+ phase: "cancellation",
46
+ severity: "error",
47
+ cause
48
+ });
49
+ }
50
+ }
51
+ this.subscriptions.clear();
52
+ }
53
+ }
54
+ /** Owns the mutable signal; consumers receive the read-only cancellation port. */
55
+ export class CancellationController {
56
+ mutableSignal = new Signal();
57
+ onDiagnostic;
58
+ signal = this.mutableSignal;
59
+ constructor(onDiagnostic) {
60
+ this.onDiagnostic = onDiagnostic;
61
+ }
62
+ abort(reason) {
63
+ this.mutableSignal.abort(reason, this.onDiagnostic);
64
+ }
65
+ }
66
+ //# sourceMappingURL=CancellationController.js.map
@@ -0,0 +1,89 @@
1
+ import type { RenderEffect2D } from './renderEffect.js';
2
+ import type { Point2D, Rectangle2D, SharedMaterial2D } from '@egret/contracts';
3
+ import type { BoundsQueryOptions } from './displayBounds.js';
4
+ import type { CoordinateQueryOptions } from './displayCoordinates.js';
5
+ import { EventDispatcher } from './EventDispatcher.js';
6
+ import { ASSERT_ATTACHABLE, ASSERT_BINDABLE, OWNERSHIP_CHILDREN } from './ownership.js';
7
+ import type { DisplayObjectContainer } from './DisplayObjectContainer.js';
8
+ /** A live display node; detach and terminal dispose are separate operations. */
9
+ export declare class DisplayObject extends EventDispatcher {
10
+ constructor();
11
+ /** Explicit input regions are separate from rendering content and opacity. */
12
+ get touchEnabled(): boolean;
13
+ set touchEnabled(value: boolean);
14
+ get hitArea(): Rectangle2D | undefined;
15
+ set hitArea(value: Rectangle2D | undefined);
16
+ get x(): number;
17
+ set x(value: number);
18
+ get y(): number;
19
+ set y(value: number);
20
+ /** Local pivot in logical pixels; finite values are stored without coercion. */
21
+ get anchorOffsetX(): number;
22
+ set anchorOffsetX(value: number);
23
+ /** The pivot remains readable after disposal; writes obey node/Engine life. */
24
+ get anchorOffsetY(): number;
25
+ set anchorOffsetY(value: number);
26
+ get scaleX(): number;
27
+ set scaleX(value: number);
28
+ get scaleY(): number;
29
+ set scaleY(value: number);
30
+ get rotation(): number;
31
+ set rotation(value: number);
32
+ /** Degrees by which the y axis is turned beyond the rotation, so that upright lines lean. 0 unless set. */
33
+ get skewX(): number;
34
+ set skewX(value: number);
35
+ /** Degrees by which the x axis is turned beyond the rotation, so that level lines slope. 0 unless set. */
36
+ get skewY(): number;
37
+ set skewY(value: number);
38
+ /** A name the application gives the object, for `getChildByName`. Empty unless set; it changes nothing that is drawn. */
39
+ get name(): string;
40
+ set name(value: string);
41
+ /**
42
+ * The width the object takes on its parent: the width of what it and its children draw, in its own units, times its
43
+ * scaleX without the sign. Setting it sets scaleX, keeping its sign, so that the width becomes the value; an object
44
+ * that draws nothing has no width to scale and refuses any but 0.
45
+ */
46
+ get width(): number;
47
+ set width(value: number);
48
+ /** As `width`, down the object and with scaleY. */
49
+ get height(): number;
50
+ set height(value: number);
51
+ get alpha(): number;
52
+ set alpha(value: number);
53
+ get visible(): boolean;
54
+ set visible(value: boolean);
55
+ /** A complete material value overrides the nearest inherited value. */
56
+ get sharedMaterial(): SharedMaterial2D | null;
57
+ set sharedMaterial(value: SharedMaterial2D | null);
58
+ /**
59
+ * How what this object and its children draw is combined with what is under it, by Egret's names: `add` brightens,
60
+ * `multiply` darkens, `screen` lightens softly and `erase` takes away by its alpha. It is the blend of `sharedMaterial`:
61
+ * setting it keeps the material's tints and replaces only its blend, and a child with a material of its own keeps that.
62
+ */
63
+ get blendMode(): 'normal' | 'add' | 'multiply' | 'screen' | 'erase';
64
+ set blendMode(value: 'normal' | 'add' | 'multiply' | 'screen' | 'erase');
65
+ /** Shared backends execute effects; legacy captures explicitly refuse them. */
66
+ get renderEffect(): RenderEffect2D | undefined;
67
+ set renderEffect(value: RenderEffect2D | undefined);
68
+ /** An ordering boundary is metadata, not another display or resource owner. */
69
+ get renderBoundary(): 'none' | 'isolate';
70
+ set renderBoundary(value: 'none' | 'isolate');
71
+ get clipRect(): Rectangle2D | undefined;
72
+ set clipRect(value: Rectangle2D | undefined);
73
+ get parent(): DisplayObjectContainer | undefined;
74
+ get isDisposed(): boolean;
75
+ /** Map logical coordinates through the actual root, including its transform. */
76
+ localToGlobal(localX?: number, localY?: number, options?: CoordinateQueryOptions): Point2D;
77
+ /** Solve the stored world matrix and return one owned, frozen point. */
78
+ globalToLocal(globalX?: number, globalY?: number, options?: CoordinateQueryOptions): Point2D;
79
+ /** Measure descendant-transformed content in this node's local coordinates. */
80
+ getBounds(options?: BoundsQueryOptions): Rectangle2D;
81
+ protected assertUsable(): void;
82
+ protected eventParent(): EventDispatcher | undefined;
83
+ [ASSERT_BINDABLE](): void;
84
+ [ASSERT_ATTACHABLE](): void;
85
+ [OWNERSHIP_CHILDREN](): readonly object[];
86
+ /** Mark terminal before removing listeners, so callback reentry sees disposal. */
87
+ dispose(): void;
88
+ }
89
+ //# sourceMappingURL=DisplayObject.d.ts.map