zimjs 18.1.1 → 18.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "18.1.1",
3
+ "version": "18.1.2",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -770,7 +770,7 @@ RETURNS the modified Array
770
770
  if (zot(array)) return;
771
771
  if (!Array.isArray(array)) array = Object.values(arguments);
772
772
  var i = array.length, j, temp;
773
- if (i == 0) return array;
773
+ if (i <= 1) return array;
774
774
  if (different) {
775
775
  var sur = {};
776
776
  var arr = [];
@@ -48558,6 +48558,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
48558
48558
 
48559
48559
  content.cache(x, y, width, height);
48560
48560
 
48561
+
48561
48562
  if (data) {
48562
48563
  var image = content.cacheCanvas.toDataURL('image/' + type, quality);
48563
48564
  if (cached) {
@@ -57409,7 +57410,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
57409
57410
  var val;
57410
57411
  tar.zimObj = {};
57411
57412
  for (prop in obj) {
57412
- if (extraTypes.indexOf(prop) >= 0) val = obj[prop];
57413
+ if (extraTypes.indexOf(prop) >= 0) val = obj[prop];
57413
57414
  else val = zim.Pick.choose(obj[prop]);
57414
57415
  tar.zimObj[prop] = tar[prop];
57415
57416
 
@@ -89484,6 +89485,11 @@ keyOut(color, tolerance, replacement) - remove a certain color in the picture an
89484
89485
  the default tolerance is .1 - the higher the tolerance the less sensitive the keying process - so more colors will be removed similar to the provided color
89485
89486
  color and tolerance can be an array of colors and tolerances (or just one tolerance if all are the same)
89486
89487
  replacement (default clear) a color to replace the keyed out color with or an optional array to match the colors array if an array is used
89488
+ destroy() - remove image references and dispose
89489
+ normal dispose() on a Pic() will just dispose the specific container and cloned bitmap
89490
+ leaving the original HTML image reference and ZIM Bitmap so that more Pic objects can be made from the loaded image
89491
+ destroy() will dispose the original ZIM Bitmap and set references to the HTML image to null letting HTML clear the image from memory
89492
+
89487
89493
  Note: there is an outlineImage(pic, reverse) function that can be called to outline a DisplayObject - search docs for outlineImage
89488
89494
 
89489
89495
  ZIM 4TH adds all the methods listed under Container (see above), such as:
@@ -89546,7 +89552,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89546
89552
  if (inner.type == "Bitmap" || inner.type == "Image") {
89547
89553
  if (inner.type == "Bitmap") that.bitmap = inner.clone().addTo(that);
89548
89554
  else that.bitmap = inner.getChildAt(0).clone().addTo(that);
89549
- that.id = inner.id;
89555
+ that.id = that.bitmap.id = file;
89556
+ zogb(that.id)
89550
89557
  that.image = that.bitmap.image;
89551
89558
  that.src = that.bitmap.src;
89552
89559
  that.item = that.bitmap.item;
@@ -89559,7 +89566,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89559
89566
  } else {
89560
89567
  inner.on("complete", function () {
89561
89568
  that.bitmap = inner.getChildAt(0).clone().addTo(that);
89562
- that.id = inner.id;
89569
+ that.id = that.bitmap.id = file;
89563
89570
  that.setBounds(null); // resets size
89564
89571
  that.type = "Pic";
89565
89572
  if (that.commands) {
@@ -89577,6 +89584,26 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89577
89584
  if (that.stage) that.stage.update();
89578
89585
  });
89579
89586
  }
89587
+
89588
+ this.destroy = function() {
89589
+ if (this.id && this.bitmap) {
89590
+ this.image = this.bitmap.image = null;
89591
+ var frame;
89592
+ if (this.stage && this.stage.frame) frame = this.stage.frame;
89593
+ else frame = WW.zdf;
89594
+ if (frame && frame.assets) {
89595
+ if (frame.assets[this.id]) {
89596
+ if (frame.assets[this.id].dispose) frame.assets[this.id].dispose();
89597
+ delete frame.assets[this.id];
89598
+ }
89599
+ }
89600
+ if (zim.assets[this.id]) {
89601
+ if (zim.assets[this.id].dispose) zim.assets[this.id].dispose();
89602
+ delete zim.assets[this.id];
89603
+ }
89604
+ }
89605
+ this.dispose();
89606
+ }
89580
89607
 
89581
89608
  that.keyOut = function(color, tolerance, replacement) {
89582
89609
  if (that.type=="AC"&&WW.zdf) {WW.zdf.ac("keyOut", arguments, that); return that;}
@@ -98319,4 +98346,3 @@ export let Style = zim.Style;
98319
98346
  export let assets = zim.assets;
98320
98347
  export let assetIDs = zim.assetIDs;
98321
98348
  export let ZIMON = zim.ZIMON;
98322
-
@@ -3920,6 +3920,7 @@ declare namespace zim {
3920
3920
  constructor(config_or_file?: string, width?: number, height?: number, noCors?: boolean, style?: boolean, group?: string, inherit?: {})
3921
3921
  constructor(config: { file?: string, width?: number, height?: number, noCors?: boolean, style?: boolean, group?: string, inherit?: {} })
3922
3922
  keyOut(color?: string, tolerance?: number, replacement?: color): this
3923
+ destroy(): void
3923
3924
  readonly file: string
3924
3925
  readonly src: string
3925
3926
  readonly image: HTMLImageElement