@egret/runtime 7.0.1-rc.3 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,12 @@ import type { AssetRef, AssetType } from "./AssetRef.js";
4
4
  import type { EngineContext } from "./ownership.js";
5
5
  import type { AssetLoadContext } from "./assetState.js";
6
6
  export type { AssetLoadContext } from "./assetState.js";
7
+ /** Loads the value an asset reference names, and disposes of it when it is no longer held. */
7
8
  export interface AssetProvider<T> {
8
9
  load(ref: AssetRef<T>, context: AssetLoadContext): Promise<T>;
9
10
  dispose(value: T): void;
10
11
  }
12
+ /** Options of one acquisition: a signal that cancels it. */
11
13
  export interface AssetAcquireOptions {
12
14
  readonly signal?: CancellationSignal;
13
15
  }
@@ -10,6 +10,7 @@ export interface AssetRef<T> {
10
10
  readonly type: AssetType<T>;
11
11
  readonly id: string;
12
12
  }
13
+ /** Makes an asset type from a name and a check that a loaded value is of that type. */
13
14
  export declare function createAssetType<T>(name: string, is: (value: unknown) => value is T): AssetType<T>;
14
15
  /** Keep the caller's valid ID byte-for-byte; whitespace is not normalization. */
15
16
  export declare function createAssetRef<T>(type: AssetType<T>, id: string): AssetRef<T>;
package/dist/AssetRef.js CHANGED
@@ -4,6 +4,7 @@ const references = new WeakSet();
4
4
  function validIdentity(value) {
5
5
  return typeof value === "string" && value.trim().length !== 0;
6
6
  }
7
+ /** Makes an asset type from a name and a check that a loaded value is of that type. */
7
8
  export function createAssetType(name, is) {
8
9
  if (!validIdentity(name) || typeof is !== "function")
9
10
  throw new EgretError("ASSET_TYPE_INVALID");
@@ -1,5 +1,7 @@
1
1
  import type { Disposable } from "@egret/contracts";
2
+ /** The order of the bytes of a multi-byte number. */
2
3
  export type ByteOrder = "bigEndian" | "littleEndian";
4
+ /** The largest snapshot a ByteReader reads, in bytes. */
3
5
  export declare const BYTE_READER_LIMITS: Readonly<{
4
6
  readonly maxBytes: 16777216;
5
7
  }>;
@@ -1,3 +1,4 @@
1
+ /** The largest snapshot a ByteReader reads, in bytes. */
1
2
  export const BYTE_READER_LIMITS = Object.freeze({ maxBytes: 16777216 });
2
3
  // Capture intrinsic operations, rather than consulting source properties,
3
4
  // iterators, constructors or species during admission and interpretation.
@@ -1,5 +1,6 @@
1
1
  import type { Disposable } from "@egret/contracts";
2
2
  import type { ByteOrder } from "./ByteReader.js";
3
+ /** The largest capacity a ByteWriter has, in bytes. */
3
4
  export declare const BYTE_WRITER_LIMITS: Readonly<{
4
5
  readonly maxBytes: 16777216;
5
6
  }>;
@@ -1,3 +1,4 @@
1
+ /** The largest capacity a ByteWriter has, in bytes. */
1
2
  export const BYTE_WRITER_LIMITS = Object.freeze({ maxBytes: 16777216 });
2
3
  // Capture native slot access and writes once. Caller properties, iterators and
3
4
  // species do not participate in admission, append or snapshot ownership.
@@ -65,6 +65,14 @@ export declare class DisplayObject extends EventDispatcher {
65
65
  /** Shared backends execute effects; legacy captures explicitly refuse them. */
66
66
  get renderEffect(): RenderEffect2D | undefined;
67
67
  set renderEffect(value: RenderEffect2D | undefined);
68
+ /**
69
+ * Egret's `mask`. A display object masks this one with its Graphics, as `renderEffect = { shapeMask }`, and is not
70
+ * drawn while it masks; a rectangle in this object's own units clips it, as `clipRect`. `undefined` or `null` takes
71
+ * either away. Reading it gives the shape mask, else the clip rectangle. Setting a shape mask keeps the effect's other
72
+ * parts and replaces an image mask.
73
+ */
74
+ get mask(): DisplayObject | Rectangle2D | undefined;
75
+ set mask(value: DisplayObject | Rectangle2D | null | undefined);
68
76
  /** An ordering boundary is metadata, not another display or resource owner. */
69
77
  get renderBoundary(): 'none' | 'isolate';
70
78
  set renderBoundary(value: 'none' | 'isolate');
@@ -8,7 +8,7 @@ import { EgretError } from './EgretError.js';
8
8
  import { assertVisualMutable, copyRect, alphaOf, finite, invalidDisplayValue, registerVisual, visualOf, readAnchorOffset, writeAnchorOffset, recordVisualChange, VISUAL_TRANSFORM, VISUAL_APPEARANCE } from './displayVisualState.js';
9
9
  import { EventDispatcher } from './EventDispatcher.js';
10
10
  import { ASSERT_ATTACHABLE, ASSERT_BINDABLE, OWNERSHIP_CHILDREN } from './ownership.js';
11
- import { assertLive, isTerminated, parentOf, registerNode, terminateNode } from './displayTreeState.js';
11
+ import { assertLive, isDisplayNode, isTerminated, parentOf, registerNode, terminateNode } from './displayTreeState.js';
12
12
  /** Egret's names of blend modes, and the blends of the shared material they are. */
13
13
  const BLENDS = Object.freeze({
14
14
  normal: 'normal',
@@ -250,7 +250,8 @@ export class DisplayObject extends EventDispatcher {
250
250
  addressV: base?.addressV,
251
251
  regionIsolation: base?.regionIsolation,
252
252
  minFilter: base?.minFilter,
253
- magFilter: base?.magFilter
253
+ magFilter: base?.magFilter,
254
+ mipmapFilter: base?.mipmapFilter
254
255
  });
255
256
  state.sharedMaterial = next;
256
257
  recordVisualChange(this, VISUAL_APPEARANCE);
@@ -262,6 +263,31 @@ export class DisplayObject extends EventDispatcher {
262
263
  set renderEffect(value) {
263
264
  setRenderEffect(this, value);
264
265
  }
266
+ /**
267
+ * Egret's `mask`. A display object masks this one with its Graphics, as `renderEffect = { shapeMask }`, and is not
268
+ * drawn while it masks; a rectangle in this object's own units clips it, as `clipRect`. `undefined` or `null` takes
269
+ * either away. Reading it gives the shape mask, else the clip rectangle. Setting a shape mask keeps the effect's other
270
+ * parts and replaces an image mask.
271
+ */
272
+ get mask() {
273
+ return visualOf(this).renderEffect?.shapeMask ?? visualOf(this).clipRect;
274
+ }
275
+ set mask(value) {
276
+ assertVisualMutable(this);
277
+ const effect = visualOf(this).renderEffect;
278
+ const { alphaMask: _image, maskRect: _area, shapeMask: _shape, ...rest } = effect ?? {};
279
+ const others = effect === undefined ? undefined : rest;
280
+ if (value !== null && value !== undefined && isDisplayNode(value)) {
281
+ setRenderEffect(this, { ...others, shapeMask: value });
282
+ this.clipRect = undefined;
283
+ return;
284
+ }
285
+ if (effect?.shapeMask !== undefined) {
286
+ const kept = others !== undefined && Object.entries(others).some(([key, v]) => key !== 'blurRadius' || v !== 0);
287
+ setRenderEffect(this, kept ? others : undefined);
288
+ }
289
+ this.clipRect = value === null || value === undefined ? undefined : value;
290
+ }
265
291
  /** An ordering boundary is metadata, not another display or resource owner. */
266
292
  get renderBoundary() {
267
293
  return visualOf(this).renderBoundary;
@@ -1,3 +1,4 @@
1
+ /** What an EgretError can carry besides its code: the error or value that caused it. */
1
2
  export interface EgretErrorOptions {
2
3
  readonly cause?: unknown;
3
4
  readonly cleanupErrors?: readonly unknown[];
package/dist/Event.d.ts CHANGED
@@ -7,12 +7,14 @@ export interface EventType<T> {
7
7
  readonly cancelable: boolean;
8
8
  readonly [PAYLOAD_TYPE]?: (payload: T) => T;
9
9
  }
10
+ /** How events of a type travel: whether they bubble and whether they can be cancelled. */
10
11
  export interface EventTypeOptions {
11
12
  readonly bubbles?: boolean;
12
13
  readonly cancelable?: boolean;
13
14
  }
14
15
  /** Matching uses descriptor object identity; equal key strings do not alias types. */
15
16
  export declare function createEventType<T>(key: string, options?: EventTypeOptions): EventType<T>;
17
+ /** Where an event is on its way: going down to its target, at it, or coming back up. */
16
18
  export type EventPhase = "capturing" | "atTarget" | "bubbling";
17
19
  interface DispatchState {
18
20
  active: boolean;
@@ -62,6 +62,16 @@ export declare class Graphics {
62
62
  * square is where it is.
63
63
  */
64
64
  beginGradientFill(type: "linear" | "radial", colors: readonly number[], alphas: readonly number[], ratios: readonly number[], matrix?: GradientBoxMatrix): this;
65
+ /**
66
+ * Gives the line set by `lineStyle` a gradient instead of its colour, as older code gives it: the arguments of
67
+ * `beginGradientFill`. Its width, ends, corners and dashes stay; its colours and alphas are the gradient's. It does
68
+ * nothing while there is no line, and the next `lineStyle` ends it.
69
+ */
70
+ lineGradientStyle(type: "linear" | "radial", colors: readonly number[], alphas: readonly number[], ratios: readonly number[], matrix?: GradientBoxMatrix): this;
71
+ /** Gives the line a gradient along the line from one point to another, as `beginLinearGradientFill` gives a fill. */
72
+ lineLinearGradientStyle(x0: number, y0: number, x1: number, y1: number, stops: readonly GradientColorStop[]): this;
73
+ /** Gives the line a gradient from a centre outwards, as `beginRadialGradientFill` gives a fill. */
74
+ lineRadialGradientStyle(x: number, y: number, radius: number, stops: readonly GradientColorStop[], radiusY?: number): this;
65
75
  drawRect(x: number, y: number, width: number, height: number): this;
66
76
  drawCircle(x: number, y: number, radius: number): this;
67
77
  /** An ellipse inside the rectangle of this corner and size. */
@@ -89,6 +99,7 @@ export declare class Graphics {
89
99
  */
90
100
  beginBitmapFill(lease: AssetLease<Texture>, matrix?: GradientBoxMatrix, repeat?: boolean): this;
91
101
  private gradient;
102
+ private lineGradient;
92
103
  private paintRequired;
93
104
  /** The node's triangles, begun with the rectangles it has drawn so far. */
94
105
  private shape;
package/dist/Graphics.js CHANGED
@@ -95,37 +95,12 @@ export class Graphics {
95
95
  /** A fill whose colour runs along the line from one point to another, and stays the end colours beyond them. */
96
96
  beginLinearGradientFill(x0, y0, x1, y1, stops) {
97
97
  assertVisualMutable(this.owner);
98
- numbers(x0, y0, x1, y1);
99
- const dx = x1 - x0, dy = y1 - y0, square = dx * dx + dy * dy;
100
- if (!(square > 0) || !finite(1 / square))
101
- throw invalid();
102
- return this.gradient({
103
- radial: false,
104
- a: dx / square,
105
- c: dy / square,
106
- tx: -(x0 * dx + y0 * dy) / square,
107
- b: 0,
108
- d: 0,
109
- ty: 0,
110
- stops: gradientStops(stops)
111
- });
98
+ return this.gradient(linearGradient(x0, y0, x1, y1, stops));
112
99
  }
113
100
  /** A fill whose colour runs from a centre out to a circle, or to an ellipse when `radiusY` is given, and stays the last colour beyond it. */
114
101
  beginRadialGradientFill(x, y, radius, stops, radiusY = radius) {
115
102
  assertVisualMutable(this.owner);
116
- numbers(x, y, radius, radiusY);
117
- if (!(radius > 0) || !(radiusY > 0) || !finite(1 / radius) || !finite(1 / radiusY))
118
- throw invalid();
119
- return this.gradient({
120
- radial: true,
121
- a: 1 / radius,
122
- c: 0,
123
- tx: -x / radius,
124
- b: 0,
125
- d: 1 / radiusY,
126
- ty: -y / radiusY,
127
- stops: gradientStops(stops)
128
- });
103
+ return this.gradient(radialGradient(x, y, radius, stops, radiusY));
129
104
  }
130
105
  /**
131
106
  * A gradient fill as older code gives it: "linear" or "radial", colours, alphas, ratios from 0 to 255, and a matrix
@@ -134,46 +109,26 @@ export class Graphics {
134
109
  */
135
110
  beginGradientFill(type, colors, alphas, ratios, matrix) {
136
111
  assertVisualMutable(this.owner);
137
- if ((type !== "linear" && type !== "radial") ||
138
- !Array.isArray(colors) ||
139
- !Array.isArray(alphas) ||
140
- !Array.isArray(ratios) ||
141
- colors.length !== alphas.length ||
142
- colors.length !== ratios.length)
143
- throw invalid();
144
- const m = matrix ?? { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
145
- if (typeof m !== "object" || m === null)
146
- throw invalid();
147
- numbers(m.a, m.b, m.c, m.d, m.tx, m.ty);
148
- for (const ratio of ratios)
149
- if (!finite(ratio) || ratio < 0 || ratio > 255)
150
- throw invalid();
151
- const det = m.a * m.d - m.b * m.c, stops = gradientStops(colors.map((value, i) => ({ offset: ratios[i] / 255, color: value, alpha: alphas[i] })));
152
- if (det === 0 || !finite(1 / det))
153
- throw invalid();
154
- // The node's point in the square's units, then along the square for a linear gradient or out from its centre for a radial one.
155
- const ia = m.d / det, ic = -m.c / det, itx = (m.c * m.ty - m.d * m.tx) / det, ib = -m.b / det, id = m.a / det, ity = (m.b * m.tx - m.a * m.ty) / det;
156
- if (type === "linear")
157
- return this.gradient({
158
- radial: false,
159
- a: ia / 1638.4,
160
- c: ic / 1638.4,
161
- tx: itx / 1638.4 + 0.5,
162
- b: 0,
163
- d: 0,
164
- ty: 0,
165
- stops
166
- });
167
- return this.gradient({
168
- radial: true,
169
- a: ia / 819.2,
170
- c: ic / 819.2,
171
- tx: itx / 819.2,
172
- b: ib / 819.2,
173
- d: id / 819.2,
174
- ty: ity / 819.2,
175
- stops
176
- });
112
+ return this.gradient(legacyGradient(type, colors, alphas, ratios, matrix));
113
+ }
114
+ /**
115
+ * Gives the line set by `lineStyle` a gradient instead of its colour, as older code gives it: the arguments of
116
+ * `beginGradientFill`. Its width, ends, corners and dashes stay; its colours and alphas are the gradient's. It does
117
+ * nothing while there is no line, and the next `lineStyle` ends it.
118
+ */
119
+ lineGradientStyle(type, colors, alphas, ratios, matrix) {
120
+ assertVisualMutable(this.owner);
121
+ return this.lineGradient(legacyGradient(type, colors, alphas, ratios, matrix));
122
+ }
123
+ /** Gives the line a gradient along the line from one point to another, as `beginLinearGradientFill` gives a fill. */
124
+ lineLinearGradientStyle(x0, y0, x1, y1, stops) {
125
+ assertVisualMutable(this.owner);
126
+ return this.lineGradient(linearGradient(x0, y0, x1, y1, stops));
127
+ }
128
+ /** Gives the line a gradient from a centre outwards, as `beginRadialGradientFill` gives a fill. */
129
+ lineRadialGradientStyle(x, y, radius, stops, radiusY = radius) {
130
+ assertVisualMutable(this.owner);
131
+ return this.lineGradient(radialGradient(x, y, radius, stops, radiusY));
177
132
  }
178
133
  drawRect(x, y, width, height) {
179
134
  assertVisualMutable(this.owner);
@@ -324,14 +279,20 @@ export class Graphics {
324
279
  return this;
325
280
  }
326
281
  gradient(gradient) {
327
- for (const value of [gradient.a, gradient.b, gradient.c, gradient.d, gradient.tx, gradient.ty])
328
- if (!finite(value))
329
- throw invalid();
330
282
  this.finishPath();
331
283
  const first = gradient.stops[0];
332
284
  this.fill = { color: first.color, alpha: first.alpha, gradient };
333
285
  return this;
334
286
  }
287
+ lineGradient(gradient) {
288
+ const line = this.line;
289
+ if (line === undefined)
290
+ return this;
291
+ this.finishPath();
292
+ const first = gradient.stops[0];
293
+ this.line = { ...line, color: first.color, alpha: first.alpha, gradient };
294
+ return this;
295
+ }
335
296
  paintRequired() {
336
297
  if (this.fill === undefined && this.line === undefined)
337
298
  throw new EgretError("GRAPHICS_FILL_REQUIRED");
@@ -484,6 +445,89 @@ export class Graphics {
484
445
  return this;
485
446
  }
486
447
  }
448
+ /** A gradient along the line from one point to another. */
449
+ function linearGradient(x0, y0, x1, y1, stops) {
450
+ numbers(x0, y0, x1, y1);
451
+ const dx = x1 - x0, dy = y1 - y0, square = dx * dx + dy * dy;
452
+ if (!(square > 0) || !finite(1 / square))
453
+ throw invalid();
454
+ return checked({
455
+ radial: false,
456
+ a: dx / square,
457
+ c: dy / square,
458
+ tx: -(x0 * dx + y0 * dy) / square,
459
+ b: 0,
460
+ d: 0,
461
+ ty: 0,
462
+ stops: gradientStops(stops)
463
+ });
464
+ }
465
+ /** A gradient from a centre out to a circle, or to an ellipse of the two radii. */
466
+ function radialGradient(x, y, radius, stops, radiusY) {
467
+ numbers(x, y, radius, radiusY);
468
+ if (!(radius > 0) || !(radiusY > 0) || !finite(1 / radius) || !finite(1 / radiusY))
469
+ throw invalid();
470
+ return checked({
471
+ radial: true,
472
+ a: 1 / radius,
473
+ c: 0,
474
+ tx: -x / radius,
475
+ b: 0,
476
+ d: 1 / radiusY,
477
+ ty: -y / radiusY,
478
+ stops: gradientStops(stops)
479
+ });
480
+ }
481
+ /** A gradient as older code gives it, its square of 1638.4 units placed by the matrix. */
482
+ function legacyGradient(type, colors, alphas, ratios, matrix) {
483
+ if ((type !== "linear" && type !== "radial") ||
484
+ !Array.isArray(colors) ||
485
+ !Array.isArray(alphas) ||
486
+ !Array.isArray(ratios) ||
487
+ colors.length !== alphas.length ||
488
+ colors.length !== ratios.length)
489
+ throw invalid();
490
+ const m = matrix ?? { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
491
+ if (typeof m !== "object" || m === null)
492
+ throw invalid();
493
+ numbers(m.a, m.b, m.c, m.d, m.tx, m.ty);
494
+ for (const ratio of ratios)
495
+ if (!finite(ratio) || ratio < 0 || ratio > 255)
496
+ throw invalid();
497
+ const det = m.a * m.d - m.b * m.c, stops = gradientStops(colors.map((value, i) => ({ offset: ratios[i] / 255, color: value, alpha: alphas[i] })));
498
+ if (det === 0 || !finite(1 / det))
499
+ throw invalid();
500
+ // The node's point in the square's units, then along the square for a linear gradient or out from its centre for a radial one.
501
+ const ia = m.d / det, ic = -m.c / det, itx = (m.c * m.ty - m.d * m.tx) / det, ib = -m.b / det, id = m.a / det, ity = (m.b * m.tx - m.a * m.ty) / det;
502
+ if (type === "linear")
503
+ return checked({
504
+ radial: false,
505
+ a: ia / 1638.4,
506
+ c: ic / 1638.4,
507
+ tx: itx / 1638.4 + 0.5,
508
+ b: 0,
509
+ d: 0,
510
+ ty: 0,
511
+ stops
512
+ });
513
+ return checked({
514
+ radial: true,
515
+ a: ia / 819.2,
516
+ c: ic / 819.2,
517
+ tx: itx / 819.2,
518
+ b: ib / 819.2,
519
+ d: id / 819.2,
520
+ ty: ity / 819.2,
521
+ stops
522
+ });
523
+ }
524
+ /** A gradient whose map is of finite numbers. */
525
+ function checked(gradient) {
526
+ for (const value of [gradient.a, gradient.b, gradient.c, gradient.d, gradient.tx, gradient.ty])
527
+ if (!finite(value))
528
+ throw invalid();
529
+ return gradient;
530
+ }
487
531
  /** Two to sixteen colours in order of their places, as a gradient keeps them. */
488
532
  function gradientStops(stops) {
489
533
  if (!Array.isArray(stops) || stops.length < 2 || stops.length > GRAPHICS_SHAPE_LIMITS.maxGradientStops)
@@ -6,6 +6,7 @@ export interface NineSliceInsets2D {
6
6
  readonly right: number;
7
7
  readonly bottom: number;
8
8
  }
9
+ /** The size of a nine-slice picture, the size to stretch it to, and the insets whose corners are not stretched. */
9
10
  export interface NineSliceGeometry2DOptions {
10
11
  readonly sourceWidth: number;
11
12
  readonly sourceHeight: number;
package/dist/Scope.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { CancellationSignal, ScopeValue } from "@egret/contracts";
2
2
  import type { EngineContext } from "./ownership.js";
3
+ /** Whether a scope is open, disposing what it owns, or closed. */
3
4
  export type ScopeState = "open" | "closing" | "closed";
4
5
  export declare let createScope: (engine: EngineContext, onClosed: (scope: Scope) => void) => Scope;
5
6
  /** Runtime-private identity for owner-chain lifetime validation. */
package/dist/Texture.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare class Texture {
12
12
  /** Drop only the wrapper reference; saved image values keep their own pixels. */
13
13
  dispose(): void;
14
14
  }
15
+ /** A texture of a whole image or of a rectangle of it. */
15
16
  export declare function createTexture(image: ImageData2D, sourceRect?: TextureRegion2D): Texture;
16
17
  /** Create an explicit logical view over an authentic straight CPU image. */
17
18
  export declare function createTextureView(image: ImageData2D, region: TextureViewRegionInput2D): Texture;
package/dist/Texture.js CHANGED
@@ -143,6 +143,7 @@ export class Texture {
143
143
  ]);
144
144
  }
145
145
  }
146
+ /** A texture of a whole image or of a rectangle of it. */
146
147
  export function createTexture(image, sourceRect) {
147
148
  if (!isImageData2D(image))
148
149
  throw new EgretError("TEXTURE_IMAGE_INVALID", { cause: new TypeError("Authentic ImageData2D required") });
@@ -7,6 +7,7 @@ export interface ProviderBinding {
7
7
  readonly load: (ref: AssetRef<never>, context: AssetLoadContext) => Promise<unknown>;
8
8
  readonly dispose: (value: unknown) => void;
9
9
  }
10
+ /** What a provider is given with each load: the signal that tells it the load is no longer wanted. */
10
11
  export interface AssetLoadContext {
11
12
  readonly signal: CancellationSignal;
12
13
  readonly resourceGeneration: number;
@@ -30,6 +30,8 @@ export interface VisualState {
30
30
  sharedMaterial: SharedMaterial2D | null;
31
31
  renderBoundary: "none" | "isolate";
32
32
  renderEffect: RenderEffect2D | undefined;
33
+ /** How many nodes take this one as their shape mask. While any do, it is not drawn, as Egret hid a mask. */
34
+ maskUses: number;
33
35
  clipRect: Rectangle2D | undefined;
34
36
  primitives: Primitive[];
35
37
  /** What the node draws besides filled rectangles: triangles and a path, which Graphics alone writes. */
@@ -65,6 +65,7 @@ export function registerVisual(node) {
65
65
  anchorOffsetY: 0,
66
66
  visible: true,
67
67
  renderEffect: undefined,
68
+ maskUses: 0,
68
69
  sharedMaterial: null,
69
70
  renderBoundary: "none",
70
71
  clipRect: undefined,
@@ -5,6 +5,7 @@ export type ErrorLanguage = 'en' | 'zh';
5
5
  * error is the same in every language.
6
6
  */
7
7
  export declare function setErrorLanguage(value: ErrorLanguage): void;
8
+ /** The language error messages are written in. */
8
9
  export declare function getErrorLanguage(): ErrorLanguage;
9
10
  /**
10
11
  * A sentence for an error code: what went wrong and, for the codes a game meets most, what to do. It is in the
package/dist/errorHelp.js CHANGED
@@ -90,6 +90,7 @@ const AREAS = [
90
90
  ['TEXT_PLAN', 'a text plan'],
91
91
  ['TEXT', 'text'],
92
92
  ['TILEMAP', 'a tile map'],
93
+ ['TIMER', 'a timer'],
93
94
  ['TWEEN', 'a tween'],
94
95
  ['UI_CONTROL', 'a UI control'],
95
96
  ['UI_KEYBOARD', 'UI keyboard navigation'],
@@ -259,6 +260,7 @@ const WRITTEN = {
259
260
  UI_LAYER_MANAGER_OWNED: 'This Engine already has a UI layer manager. An Engine has one.',
260
261
  UI_LAYER_ROOT_OWNED: 'This UI root already belongs to a layer.',
261
262
  UI_LAYOUT_UNSTABLE: 'The layout of the UI did not settle in eight rounds: a size keeps changing something it depends on.',
263
+ UI_CONTENT_INVALID: 'What a UI leaf or row gave as its content cannot be shown there. The leaf or row, and the reason, are in cause.',
262
264
  UI_ROW_NOT_REALIZED: 'The row is not on screen now, so there is nothing of it to act on. Scroll it into view first.',
263
265
  UI_ROW_RETAINED: 'A row that is in use was removed from its list or changed under it.',
264
266
  UI_SEMANTICS_DESCRIPTION: 'A field of a UI semantics entry is not valid. The entry and the field are in cause.',
@@ -383,6 +385,7 @@ export function setErrorLanguage(value) {
383
385
  throw new TypeError('The language of errors is "en" or "zh".');
384
386
  language = value;
385
387
  }
388
+ /** The language error messages are written in. */
386
389
  export function getErrorLanguage() {
387
390
  return language;
388
391
  }
@@ -89,6 +89,7 @@ export const ZH_AREAS = [
89
89
  ['TEXT_PLAN', '文本计划'],
90
90
  ['TEXT', '文本'],
91
91
  ['TILEMAP', '瓦片地图'],
92
+ ['TIMER', '计时器'],
92
93
  ['TWEEN', '缓动'],
93
94
  ['UI_CONTROL', 'UI 控件'],
94
95
  ['UI_KEYBOARD', 'UI 键盘导航'],
@@ -240,6 +241,7 @@ export const ZH_WRITTEN = {
240
241
  UI_LAYER_MANAGER_OWNED: '这个 Engine 已经有一个 UI 层管理器。一个 Engine 只有一个。',
241
242
  UI_LAYER_ROOT_OWNED: '这个 UI 根已经属于某个层。',
242
243
  UI_LAYOUT_UNSTABLE: 'UI 的布局经过八轮仍未稳定:某个尺寸一直在改变它所依赖的东西。',
244
+ UI_CONTENT_INVALID: 'UI 叶子或行给出的内容不能放在那里。是哪个叶子或行、原因是什么,见 cause。',
243
245
  UI_ROW_NOT_REALIZED: '该行现在不在屏幕上,没有可以操作的对象。请先把它滚动到可见范围。',
244
246
  UI_ROW_RETAINED: '一个正在使用的行被从列表中移除,或者在使用期间被改动了。',
245
247
  UI_SEMANTICS_DESCRIPTION: 'UI 语义条目的某个字段无效。条目和字段在 cause 中。',