@swf2es/player-hosts 0.1.7 → 0.1.8

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.
@@ -65,9 +65,10 @@ export class TextObject extends DisplayObject {
65
65
  embedFonts = false;
66
66
  autoSize = "none";
67
67
  /**
68
- * A script set the size of a field that fits itself: as in Flash, the fit
69
- * waits for its size to be asked, its transform to change or the frame to
70
- * be drawn, and a wordWrap set meanwhile wraps at the size set (adl).
68
+ * A script set the size or the autoSize of a field that fits itself: as
69
+ * in Flash, the fit waits for its size to be asked, its transform to
70
+ * change or the frame to be drawn, and a wordWrap set meanwhile wraps at
71
+ * the size the field has (adl).
71
72
  */
72
73
  fitPending = false;
73
74
  selectable = true;
@@ -201,24 +202,24 @@ export class TextObject extends DisplayObject {
201
202
  this.height = height;
202
203
  this.invalidate(CONTENT);
203
204
  }
204
- /** A script set its size: under autoSize, the fit waits (fitPending). */
205
- sizeSet() {
206
- if (this.autoSize !== "none") {
205
+ /** A script set its size or its autoSize: under autoSize, the fit waits (fitPending). */
206
+ deferFit() {
207
+ if (this.autoSize !== "none" && !this.fitPending) {
207
208
  this.fitPending = true;
208
209
  pendingFits.add(this);
209
210
  }
210
211
  }
211
- /** The fit a set size left pending, applied: its size asked, its transform changed, the frame drawn. */
212
+ /**
213
+ * The fit left pending, applied: as its position, size or bounds are
214
+ * asked, its transform is set, or the frame is drawn; not as its scale,
215
+ * its rotation or its text metrics are asked, or its alpha set (adl).
216
+ */
212
217
  settle() {
213
218
  if (this.fitPending) {
214
219
  this.fitPending = false;
215
220
  this.fit();
216
221
  }
217
222
  }
218
- touch() {
219
- super.touch();
220
- this.settle();
221
- }
222
223
  /** The text, \r between its lines. */
223
224
  get text() {
224
225
  return this.model.text;
@@ -144,6 +144,10 @@ function spriteOnly(traits) {
144
144
  }
145
145
  /** Move a display object, by a copy of its matrix, and have it drawn again. */
146
146
  function transform(d, change) {
147
+ // A field's pending fit first, so that what is set is where it stays.
148
+ if (d instanceof TextObject) {
149
+ d.settle();
150
+ }
147
151
  const m = { ...d.matrix };
148
152
  change(m);
149
153
  d.matrix = m;
@@ -191,6 +195,10 @@ export function displayObjectNatives(s) {
191
195
  }
192
196
  }
193
197
  get x() {
198
+ // A field's pending fit moves a centred or right-aligned one (adl).
199
+ if (this.$display instanceof TextObject) {
200
+ this.$display.settle();
201
+ }
194
202
  return withOffset(this.$display.matrix.tx, fieldOffset(this.$display)[0]);
195
203
  }
196
204
  // A NaN position is 0, as Flash has it (the corpus's `displayobject_invalid_floats`), and
@@ -207,6 +215,9 @@ export function displayObjectNatives(s) {
207
215
  });
208
216
  }
209
217
  get y() {
218
+ if (this.$display instanceof TextObject) {
219
+ this.$display.settle();
220
+ }
210
221
  return withOffset(this.$display.matrix.ty, fieldOffset(this.$display)[1]);
211
222
  }
212
223
  set y(v) {
@@ -340,7 +351,7 @@ export function displayObjectNatives(s) {
340
351
  if (d instanceof TextObject) {
341
352
  d.width = value / (Math.abs(d.scaleX) || 1);
342
353
  d.invalidate(CONTENT);
343
- d.sizeSet();
354
+ d.deferFit();
344
355
  return;
345
356
  }
346
357
  const r = bounds(d, true);
@@ -375,7 +386,7 @@ export function displayObjectNatives(s) {
375
386
  if (d instanceof TextObject) {
376
387
  d.height = value / (Math.abs(d.scaleY) || 1);
377
388
  d.invalidate(CONTENT);
378
- d.sizeSet();
389
+ d.deferFit();
379
390
  return;
380
391
  }
381
392
  const r = bounds(d, true);
@@ -342,7 +342,8 @@ export function textFieldNatives(s) {
342
342
  }
343
343
  set autoSize(v) {
344
344
  this.$display.autoSize = choice(v, ["none", "left", "right", "center"], "autoSize");
345
- this.$display.fit();
345
+ // Its fit waits for its size to be asked, or the frame, as one a set width leaves (adl).
346
+ this.$display.deferFit();
346
347
  }
347
348
  get antiAliasType() {
348
349
  return this.$display.antiAliasType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swf2es/player-hosts",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Optional Node and WebSocket transports, worker threads, an IndexedDB module cache and precompiled modules for the swf2es player",
5
5
  "keywords": [
6
6
  "swf",
@@ -60,6 +60,6 @@
60
60
  "LICENSE.third-party"
61
61
  ],
62
62
  "dependencies": {
63
- "@swf2es/player": "0.1.7"
63
+ "@swf2es/player": "0.1.8"
64
64
  }
65
65
  }