@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,303 @@
1
+ import { EgretError } from '../EgretError.js';
2
+ const apply = Reflect.apply;
3
+ const freeze = Object.freeze;
4
+ const TypeFault = TypeError;
5
+ const RangeFault = RangeError;
6
+ const finite = Number.isFinite;
7
+ const safeInteger = Number.isSafeInteger;
8
+ const Lines = Array;
9
+ const charCodeAt = String.prototype.charCodeAt;
10
+ const regexpExec = RegExp.prototype.exec;
11
+ const providerPattern = /^[A-Za-z0-9._-]{1,64}$/;
12
+ const localePattern = /^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/;
13
+ const weakGet = WeakMap.prototype.get;
14
+ const weakSet = WeakMap.prototype.set;
15
+ const weakHas = WeakMap.prototype.has;
16
+ const weakDelete = WeakMap.prototype.delete;
17
+ const invocations = new WeakMap();
18
+ const failures = new WeakMap();
19
+ const snapshots = new WeakMap();
20
+ const summaries = new WeakMap();
21
+ const requests = new WeakMap();
22
+ function codeAt(text, index) {
23
+ return apply(charCodeAt, text, [index]);
24
+ }
25
+ function matches(pattern, text) {
26
+ const result = apply(regexpExec, pattern, [text]);
27
+ // JavaScript's $ can precede a terminal line break; the admitted subset consumes every code unit.
28
+ return result !== null && result[0].length === text.length;
29
+ }
30
+ function invocationState(value) {
31
+ const state = apply(weakGet, invocations, [value]);
32
+ if (state === undefined)
33
+ throw new TypeFault('Authentic private text invocation required');
34
+ return state;
35
+ }
36
+ function openInvocation(value) {
37
+ if (!invocationState(value).open)
38
+ throw new TypeFault('Private text invocation is closed');
39
+ }
40
+ export function createTextValueInvocation() {
41
+ const value = freeze({});
42
+ apply(weakSet, invocations, [value, { open: true }]);
43
+ return value;
44
+ }
45
+ export function closeTextValueInvocation(value) {
46
+ invocationState(value).open = false;
47
+ }
48
+ /** Only fresh first-party creation attaches a note; closed notes cannot be consumed. */
49
+ export function createTextValueFailure(invocation, code, cause) {
50
+ invocationState(invocation);
51
+ const error = freeze(new EgretError(code, { cause }));
52
+ const note = freeze({ code, error });
53
+ apply(weakSet, failures, [error, { invocation, note }]);
54
+ return error;
55
+ }
56
+ /** Exact active operation and one consumption; no instanceof/code/cause inspection. */
57
+ export function takeTextValueFailure(invocation, cause) {
58
+ const state = invocationState(invocation);
59
+ if (!state.open || typeof cause !== 'object' || cause === null)
60
+ return undefined;
61
+ const failure = apply(weakGet, failures, [cause]);
62
+ if (failure === undefined || failure.invocation !== invocation)
63
+ return undefined;
64
+ apply(weakDelete, failures, [cause]);
65
+ return failure.note;
66
+ }
67
+ function invalid(invocation, message) {
68
+ throw createTextValueFailure(invocation, 'TEXT_REQUEST_INVALID', new TypeFault(message));
69
+ }
70
+ function limit(invocation, message) {
71
+ throw createTextValueFailure(invocation, 'TEXT_REQUEST_LIMIT', new RangeFault(message));
72
+ }
73
+ /** Snapshot all ten fields first. The cache performs its post-read lifecycle check next. */
74
+ export function snapshotTextRasterRequest(input, invocation) {
75
+ openInvocation(invocation);
76
+ if (typeof input !== 'object' || input === null)
77
+ invalid(invocation, 'Text request must be a record');
78
+ let text, fontFamily, fontSize, fontWeight;
79
+ let fontStyle, lineHeight, locale, direction;
80
+ let density, fillColor;
81
+ try {
82
+ text = input.text;
83
+ fontFamily = input.fontFamily;
84
+ fontSize = input.fontSize;
85
+ fontWeight = input.fontWeight;
86
+ fontStyle = input.fontStyle;
87
+ lineHeight = input.lineHeight;
88
+ locale = input.locale;
89
+ direction = input.direction;
90
+ density = input.density;
91
+ fillColor = input.fillColor;
92
+ }
93
+ catch (cause) {
94
+ throw createTextValueFailure(invocation, 'TEXT_REQUEST_INVALID', cause);
95
+ }
96
+ // Native allocation faults stay outside the descriptor-read wrapper.
97
+ const value = freeze({});
98
+ apply(weakSet, snapshots, [
99
+ value,
100
+ { text, fontFamily, fontSize, fontWeight, fontStyle, lineHeight, locale, direction, density, fillColor }
101
+ ]);
102
+ return value;
103
+ }
104
+ function stringField(value, max, label, invocation) {
105
+ if (typeof value !== 'string')
106
+ invalid(invocation, label + ' must be a string');
107
+ if (value.length > max)
108
+ limit(invocation, label + ' code-unit limit');
109
+ return value;
110
+ }
111
+ function validateCharacters(text, allowLineBreaks, invocation) {
112
+ for (let i = 0; i < text.length; i++) {
113
+ const code = codeAt(text, i);
114
+ if ((code < 32 && !(allowLineBreaks && (code === 10 || code === 13))) ||
115
+ (code >= 0x7f && code <= 0x9f) ||
116
+ code === 0x2028 ||
117
+ code === 0x2029 ||
118
+ (code >= 0x202a && code <= 0x202e) ||
119
+ (code >= 0x2066 && code <= 0x2069)) {
120
+ invalid(invocation, 'Unsupported text control character');
121
+ }
122
+ if (code >= 0xd800 && code <= 0xdbff) {
123
+ const next = codeAt(text, i + 1);
124
+ if (!(next >= 0xdc00 && next <= 0xdfff))
125
+ invalid(invocation, 'Unpaired UTF-16 surrogate');
126
+ i++;
127
+ }
128
+ else if (code >= 0xdc00 && code <= 0xdfff)
129
+ invalid(invocation, 'Unpaired UTF-16 surrogate');
130
+ }
131
+ }
132
+ function numeric(value, min, max, integer, label, invocation) {
133
+ if (typeof value !== 'number')
134
+ invalid(invocation, label + ' must be numeric');
135
+ if (!finite(value) || value < min || value > max || (integer && !safeInteger(value))) {
136
+ invalid(invocation, label + ' range');
137
+ }
138
+ return value === 0 ? 0 : value;
139
+ }
140
+ function sourceLineCount(text, invocation) {
141
+ let count = 1;
142
+ for (let i = 0; i < text.length; i++) {
143
+ const code = codeAt(text, i);
144
+ if (code !== 10 && code !== 13)
145
+ continue;
146
+ if (code === 13 && codeAt(text, i + 1) === 10)
147
+ i++;
148
+ count++;
149
+ if (count > 64)
150
+ limit(invocation, 'Text source line limit');
151
+ }
152
+ return count;
153
+ }
154
+ /** No source-line array, serialized key or resource identity is created here. */
155
+ export function summarizeTextRasterRequest(snapshot, providerIdentity, fontGeneration, invocation) {
156
+ openInvocation(invocation);
157
+ const fields = apply(weakGet, snapshots, [snapshot]);
158
+ if (fields === undefined)
159
+ throw new TypeFault('Authentic private request snapshot required');
160
+ // These are already admitted cache scalars, not a new structural provider port.
161
+ if (typeof providerIdentity !== 'string' ||
162
+ !matches(providerPattern, providerIdentity) ||
163
+ !safeInteger(fontGeneration) ||
164
+ fontGeneration <= 0) {
165
+ throw new TypeFault('Admitted text provider identity and generation required');
166
+ }
167
+ const text = stringField(fields.text, 8192, 'Text source', invocation);
168
+ validateCharacters(text, true, invocation);
169
+ const lineCount = sourceLineCount(text, invocation);
170
+ const fontFamily = stringField(fields.fontFamily, 256, 'Font family', invocation);
171
+ if (fontFamily.length === 0)
172
+ invalid(invocation, 'Font family must be nonempty');
173
+ validateCharacters(fontFamily, false, invocation);
174
+ const fontSize = numeric(fields.fontSize, 1, 512, false, 'Font size', invocation);
175
+ const fontWeight = numeric(fields.fontWeight, 1, 1000, true, 'Font weight', invocation);
176
+ if (fields.fontStyle !== 'normal' && fields.fontStyle !== 'italic')
177
+ invalid(invocation, 'Font style');
178
+ const fontStyle = fields.fontStyle;
179
+ const lineHeight = numeric(fields.lineHeight, 1, 1024, false, 'Line height', invocation);
180
+ const locale = stringField(fields.locale, 64, 'Locale', invocation);
181
+ if (!matches(localePattern, locale))
182
+ invalid(invocation, 'Locale subset');
183
+ if (fields.direction !== 'ltr' && fields.direction !== 'rtl')
184
+ invalid(invocation, 'Text direction');
185
+ const direction = fields.direction;
186
+ const density = numeric(fields.density, 0.5, 4, false, 'Raster density', invocation);
187
+ const fillColor = numeric(fields.fillColor, 0, 0xffffff, true, 'Fill color', invocation);
188
+ const metadataBytes = 512 + 2 * (text.length + fontFamily.length + locale.length + providerIdentity.length) + 128 * lineCount;
189
+ const data = {
190
+ text,
191
+ fontFamily,
192
+ fontSize,
193
+ fontWeight,
194
+ fontStyle,
195
+ lineHeight,
196
+ locale,
197
+ direction,
198
+ density,
199
+ fillColor,
200
+ providerIdentity,
201
+ fontGeneration,
202
+ lineCount,
203
+ metadataBytes
204
+ };
205
+ const value = freeze({ sourceCodeUnits: text.length, lineCount, metadataBytes });
206
+ apply(weakSet, summaries, [value, data]);
207
+ return value;
208
+ }
209
+ /** Project validated field scalars without granting cache request/plan authority. */
210
+ export function createTextFieldRequestInput(summary, invocation) {
211
+ openInvocation(invocation);
212
+ const data = apply(weakGet, summaries, [summary]);
213
+ if (data === undefined)
214
+ throw new TypeFault('Authentic private request summary required');
215
+ // Plain validated scalars only: no cache-owned source-line array or plan identity.
216
+ return freeze({
217
+ text: data.text,
218
+ fontFamily: data.fontFamily,
219
+ fontSize: data.fontSize,
220
+ fontWeight: data.fontWeight,
221
+ fontStyle: data.fontStyle,
222
+ lineHeight: data.lineHeight,
223
+ locale: data.locale,
224
+ direction: data.direction,
225
+ density: data.density,
226
+ fillColor: data.fillColor
227
+ });
228
+ }
229
+ /** Call only after the cache commits the summary's exact generation metadata charge. */
230
+ export function createOwnedTextRasterRequest(summary, invocation) {
231
+ openInvocation(invocation);
232
+ const data = apply(weakGet, summaries, [summary]);
233
+ if (data === undefined)
234
+ throw new TypeFault('Authentic private request summary required');
235
+ const lines = new Lines(data.lineCount);
236
+ let line = 0, start = 0;
237
+ for (let i = 0; i < data.text.length; i++) {
238
+ const code = codeAt(data.text, i);
239
+ if (code !== 10 && code !== 13)
240
+ continue;
241
+ const end = i;
242
+ if (code === 13 && codeAt(data.text, i + 1) === 10)
243
+ i++;
244
+ const breakEnd = i + 1;
245
+ lines[line++] = freeze({ start, end, breakEnd });
246
+ start = breakEnd;
247
+ }
248
+ lines[line] = freeze({ start, end: data.text.length, breakEnd: data.text.length });
249
+ const sourceLines = freeze(lines);
250
+ const value = freeze({
251
+ text: data.text,
252
+ fontFamily: data.fontFamily,
253
+ fontSize: data.fontSize,
254
+ fontWeight: data.fontWeight,
255
+ fontStyle: data.fontStyle,
256
+ lineHeight: data.lineHeight,
257
+ locale: data.locale,
258
+ direction: data.direction,
259
+ density: data.density,
260
+ fillColor: data.fillColor,
261
+ profile: 'canvas-explicit-lines-v1',
262
+ providerIdentity: data.providerIdentity,
263
+ fontGeneration: data.fontGeneration,
264
+ sourceLines
265
+ });
266
+ apply(weakSet, requests, [value, { data, request: value }]);
267
+ return value;
268
+ }
269
+ export function isOwnedTextRasterRequest(value) {
270
+ return typeof value === 'object' && value !== null && apply(weakHas, requests, [value]);
271
+ }
272
+ export function requireOwnedTextRasterRequest(value, invocation) {
273
+ openInvocation(invocation);
274
+ const owned = typeof value === 'object' && value !== null
275
+ ? apply(weakGet, requests, [value])
276
+ : undefined;
277
+ if (owned === undefined)
278
+ invalid(invocation, 'Authentic owned text request required');
279
+ return owned.request;
280
+ }
281
+ /** Bounded route lookup compares authenticated normalized scalars without allocating a key. */
282
+ export function matchesTextRasterRequestSummary(request, summary, providerIdentity, fontGeneration) {
283
+ const owned = apply(weakGet, requests, [request]);
284
+ const candidate = apply(weakGet, summaries, [summary]);
285
+ if (owned === undefined || candidate === undefined)
286
+ throw new TypeFault('Authentic request and summary required');
287
+ const current = owned.data;
288
+ return (current.providerIdentity === providerIdentity &&
289
+ candidate.providerIdentity === providerIdentity &&
290
+ current.fontGeneration === fontGeneration &&
291
+ candidate.fontGeneration === fontGeneration &&
292
+ current.text === candidate.text &&
293
+ current.fontFamily === candidate.fontFamily &&
294
+ current.fontSize === candidate.fontSize &&
295
+ current.fontWeight === candidate.fontWeight &&
296
+ current.fontStyle === candidate.fontStyle &&
297
+ current.lineHeight === candidate.lineHeight &&
298
+ current.locale === candidate.locale &&
299
+ current.direction === candidate.direction &&
300
+ current.density === candidate.density &&
301
+ current.fillColor === candidate.fillColor);
302
+ }
303
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1,179 @@
1
+ import type { CancellationSignal, ImageData2D } from '@egret/contracts';
2
+ import type { AssetLease } from '../AssetLease.js';
3
+ import type { Texture } from '../Texture.js';
4
+ declare const requestBrand: unique symbol;
5
+ declare const planBrand: unique symbol;
6
+ declare const cacheBrand: unique symbol;
7
+ export interface TextRasterRequestInput {
8
+ readonly text: string;
9
+ readonly fontFamily: string;
10
+ readonly fontSize: number;
11
+ readonly fontWeight: number;
12
+ readonly fontStyle: 'normal' | 'italic';
13
+ readonly lineHeight: number;
14
+ readonly locale: string;
15
+ readonly direction: 'ltr' | 'rtl';
16
+ readonly density: number;
17
+ readonly fillColor: number;
18
+ }
19
+ /** UTF-16 ranges [start, end) omit a delimiter; [end, breakEnd) preserves it. */
20
+ export interface TextSourceLine {
21
+ readonly start: number;
22
+ readonly end: number;
23
+ readonly breakEnd: number;
24
+ }
25
+ /** Frozen cache-owned request; its private identity authenticates plan creation. */
26
+ export interface TextRasterRequest extends TextRasterRequestInput {
27
+ readonly [requestBrand]: true;
28
+ readonly profile: 'canvas-explicit-lines-v1';
29
+ readonly providerIdentity: string;
30
+ readonly fontGeneration: number;
31
+ readonly sourceLines: readonly TextSourceLine[];
32
+ }
33
+ export interface TextBounds2D {
34
+ readonly x: number;
35
+ readonly y: number;
36
+ readonly width: number;
37
+ readonly height: number;
38
+ }
39
+ /** Advance is nonnegative; signed baseline-relative ink may extend beyond the advance. */
40
+ export interface TextLineMetricsInput {
41
+ readonly advance: number;
42
+ readonly hasInk: boolean;
43
+ readonly inkLeft: number;
44
+ readonly inkTop: number;
45
+ readonly inkRight: number;
46
+ readonly inkBottom: number;
47
+ }
48
+ export interface TextPlanInput {
49
+ readonly baselineOffset: number;
50
+ readonly lines: readonly TextLineMetricsInput[];
51
+ }
52
+ export interface TextLineMetrics {
53
+ readonly source: TextSourceLine;
54
+ readonly advance: number;
55
+ readonly baselineY: number;
56
+ readonly inkBounds: TextBounds2D | undefined;
57
+ }
58
+ export interface TextRasterPlacement {
59
+ readonly pixelLeft: number;
60
+ readonly pixelTop: number;
61
+ readonly width: number;
62
+ readonly height: number;
63
+ readonly byteLength: number;
64
+ readonly density: number;
65
+ readonly x: number;
66
+ readonly y: number;
67
+ readonly logicalWidth: number;
68
+ readonly logicalHeight: number;
69
+ }
70
+ export interface TextRasterMetrics {
71
+ readonly logicalBounds: TextBounds2D;
72
+ readonly inkBounds: TextBounds2D | undefined;
73
+ readonly contentBounds: TextBounds2D;
74
+ readonly lines: readonly TextLineMetrics[];
75
+ readonly raster: TextRasterPlacement | undefined;
76
+ }
77
+ /** Frozen plan issued for this measure invocation; a matching shape supplies no authority. */
78
+ export interface TextRasterPlan {
79
+ readonly [planBrand]: true;
80
+ readonly request: TextRasterRequest;
81
+ readonly metrics: TextRasterMetrics;
82
+ }
83
+ export interface TextRasterLimits {
84
+ readonly maxSourceCodeUnits: 8192;
85
+ readonly maxLines: 64;
86
+ readonly maxFontFamilyCodeUnits: 256;
87
+ readonly maxLocaleCodeUnits: 64;
88
+ readonly maxProviderIdentityCodeUnits: 64;
89
+ readonly maxSourceEdge: 4096;
90
+ readonly maxSourcePixels: 1048576;
91
+ readonly maxMetricMagnitude: 1048576;
92
+ readonly antialiasGuardPixels: 2;
93
+ }
94
+ export interface TextMeasureContext {
95
+ readonly signal: CancellationSignal;
96
+ readonly fontGeneration: number;
97
+ readonly limits: TextRasterLimits;
98
+ readonly createPlan: (input: TextPlanInput) => TextRasterPlan;
99
+ }
100
+ export interface TextRasterContext {
101
+ readonly signal: CancellationSignal;
102
+ readonly fontGeneration: number;
103
+ readonly limits: TextRasterLimits;
104
+ readonly reservedImageBytes: number;
105
+ readonly reservedScratchBytes: number;
106
+ }
107
+ export interface TextRasterProvider {
108
+ readonly identity: string;
109
+ readonly profile: 'canvas-explicit-lines-v1';
110
+ /** Return this invocation's exact context.createPlan result. */
111
+ measure(request: TextRasterRequest, context: TextMeasureContext): Promise<TextRasterPlan>;
112
+ /** Runs after image/scratch reservation; return matching ImageData2D, or undefined for inkless work. */
113
+ rasterize(plan: TextRasterPlan, context: TextRasterContext): Promise<ImageData2D | undefined>;
114
+ /** Attempted once after measure and raster uses settle, including cancelled work. */
115
+ release(plan: TextRasterPlan): void;
116
+ }
117
+ /** Logical limits bound retained work and byte charges; physical memory is not measured. */
118
+ export interface TextRasterCacheOptions {
119
+ readonly provider: TextRasterProvider;
120
+ readonly maxGenerations?: number;
121
+ readonly maxPendingJobs?: number;
122
+ readonly maxWaiters?: number;
123
+ readonly maxCallerLeases?: number;
124
+ readonly maxResidentEntries?: number;
125
+ readonly maxMetadataBytes?: number;
126
+ readonly maxLogicalImageBytes?: number;
127
+ readonly maxPendingRasterBytes?: number;
128
+ }
129
+ export interface TextRasterAcquireOptions {
130
+ readonly signal?: CancellationSignal;
131
+ }
132
+ export type PreparedTextRaster = {
133
+ readonly kind: 'empty';
134
+ readonly request: TextRasterRequest;
135
+ readonly metrics: TextRasterMetrics;
136
+ } | {
137
+ readonly kind: 'image';
138
+ readonly request: TextRasterRequest;
139
+ readonly metrics: TextRasterMetrics;
140
+ readonly lease: AssetLease<Texture>;
141
+ };
142
+ /** Logical charges include retained and quarantined work, which may survive cache close. */
143
+ export interface TextRasterCacheStatus {
144
+ readonly closed: boolean;
145
+ readonly fontGeneration: number;
146
+ readonly occupiedSlots: number;
147
+ readonly currentGenerations: number;
148
+ readonly retiredGenerations: number;
149
+ readonly quarantinedGenerations: number;
150
+ readonly pendingJobs: number;
151
+ readonly pendingWaiters: number;
152
+ readonly callerLeaseSlots: number;
153
+ readonly activeCallerLeases: number;
154
+ readonly residentEntries: number;
155
+ readonly residentBytes: number;
156
+ readonly liveImageBytes: number;
157
+ readonly reservedImageBytes: number;
158
+ readonly pendingRasterBytes: number;
159
+ readonly quarantinedImageBytes: number;
160
+ readonly quarantinedRasterBytes: number;
161
+ readonly metadataBytes: number;
162
+ readonly idleWaiters: number;
163
+ readonly cleanupFailureCount: number;
164
+ readonly lateProviderFailureCount: number;
165
+ }
166
+ export interface TextRasterCache {
167
+ readonly [cacheBrand]: true;
168
+ readonly profile: 'canvas-explicit-lines-v1';
169
+ acquire(request: TextRasterRequestInput, options?: TextRasterAcquireOptions): Promise<PreparedTextRaster>;
170
+ invalidate(): void;
171
+ getStatus(): TextRasterCacheStatus;
172
+ /** Wait for outstanding work/delivery actors and report recorded cleanup failure.
173
+ * Caller/resident leases and quarantined charges may remain after settlement.
174
+ */
175
+ whenIdle(): Promise<void>;
176
+ dispose(): void;
177
+ }
178
+ export {};
179
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,21 @@
1
+ import type { Rectangle2D, TextureRegion2D } from '@egret/contracts';
2
+ import type { AssetLease } from './AssetLease.js';
3
+ import type { Texture } from './Texture.js';
4
+ import { Scope } from './Scope.js';
5
+ export interface TextFieldCommittedDisplay {
6
+ readonly contentBounds: Rectangle2D;
7
+ readonly raster: Rectangle2D | undefined;
8
+ readonly lease: AssetLease<Texture> | undefined;
9
+ readonly sourceRect: TextureRegion2D | undefined;
10
+ }
11
+ export interface TextFieldDisplayState {
12
+ readonly scope: Scope;
13
+ readonly committed: TextFieldCommittedDisplay | undefined;
14
+ }
15
+ /** Metadata only: default collectors never import the text cache or leaf class. */
16
+ export declare function hasTextFieldState(value: object): boolean;
17
+ export declare function readTextFieldState(value: object): TextFieldDisplayState | undefined;
18
+ export declare function writeTextFieldState(value: object, state: TextFieldDisplayState): void;
19
+ /** A same-name own getter or writable shadow cannot reopen a closing Scope. */
20
+ export declare function assertTextFieldScope(scope: Scope): void;
21
+ //# sourceMappingURL=textDisplayState.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { recordVisualChange, VISUAL_CONTENT, VISUAL_BINDING } from './displayVisualState.js';
2
+ import { Scope } from './Scope.js';
3
+ import { EgretError } from './EgretError.js';
4
+ const states = new WeakMap();
5
+ const readPublishedState = states.get.bind(states);
6
+ const APPLY = Reflect.apply;
7
+ const SCOPE_STATE = Object.getOwnPropertyDescriptor(Scope.prototype, 'state').get;
8
+ /** Metadata only: default collectors never import the text cache or leaf class. */
9
+ export function hasTextFieldState(value) {
10
+ return states.has(value);
11
+ }
12
+ export function readTextFieldState(value) {
13
+ return states.get(value);
14
+ }
15
+ export function writeTextFieldState(value, state) {
16
+ const changed = readPublishedState(value) !== state;
17
+ states.set(value, state);
18
+ // Desired requests stay separate; only committed display/clear publications arrive here.
19
+ if (changed)
20
+ recordVisualChange(value, VISUAL_CONTENT | VISUAL_BINDING);
21
+ }
22
+ /** A same-name own getter or writable shadow cannot reopen a closing Scope. */
23
+ export function assertTextFieldScope(scope) {
24
+ if (APPLY(SCOPE_STATE, scope, []) !== 'open')
25
+ throw new EgretError('SCOPE_CLOSED');
26
+ }
27
+ //# sourceMappingURL=textDisplayState.js.map
@@ -0,0 +1,43 @@
1
+ import type { Rectangle2D } from '@egret/contracts';
2
+ import { DisplayObjectContainer } from '../DisplayObjectContainer.js';
3
+ import type { DisplayObject } from '../DisplayObject.js';
4
+ import type { Stage } from '../Stage.js';
5
+ import { Scope } from '../Scope.js';
6
+ /** Internal cross-package assembly, never exposed by the Engine facade. */
7
+ export interface UiDisplayUpdate {
8
+ readonly wrapper: DisplayObjectContainer;
9
+ readonly children?: readonly DisplayObject[];
10
+ readonly x?: number;
11
+ readonly y?: number;
12
+ readonly visible?: boolean;
13
+ readonly clipRect?: Rectangle2D | undefined;
14
+ readonly hitArea?: Rectangle2D | undefined;
15
+ readonly touchEnabled?: boolean;
16
+ readonly touchChildren?: boolean;
17
+ }
18
+ export interface UiDisplayOperations {
19
+ createWrapper(scope: Scope): DisplayObjectContainer;
20
+ validateContent(content: DisplayObject, scope: Scope): void;
21
+ prepare(root: DisplayObjectContainer, updates: readonly UiDisplayUpdate[]): object;
22
+ commit(token: object): void;
23
+ detach(root: DisplayObjectContainer): void;
24
+ disposeWrapper(wrapper: DisplayObjectContainer): void;
25
+ assertStage(): void;
26
+ /** Authenticated root-only presentation; does not traverse/rebuild its content. */
27
+ presentRoot(root: DisplayObjectContainer, value: Readonly<{
28
+ x: number;
29
+ y: number;
30
+ visible: boolean;
31
+ interactive: boolean;
32
+ index?: number;
33
+ }>): void;
34
+ /** Lifetime revocation, like detach: remains legal while the owning Scope/Engine closes. */
35
+ releaseRoot(root: DisplayObjectContainer, value: Readonly<{
36
+ x: number;
37
+ y: number;
38
+ visible: boolean;
39
+ }>): void;
40
+ }
41
+ /** Create a single root publication authority over the original genuine Stage. */
42
+ export declare function createUiDisplayOperations(stage: Stage): UiDisplayOperations;
43
+ //# sourceMappingURL=displayCommit.d.ts.map