zimjs 18.1.1 → 18.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "18.1.1",
3
+ "version": "18.1.3",
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 = [];
@@ -27659,7 +27659,7 @@ content - (default " ") optional content to be centered in one of three formats:
27659
27659
  header - a ZIM DisplayObject for the top of the content
27660
27660
  message - text that will put into a ZIM Label - default darker - see color property
27661
27661
  display - a ZIM DisplayObject for beneath the message
27662
- buttons - an array of ZIM Button objects or configuration objects {} as follows:
27662
+ buttons - an array of ZIM Button objects or configuration objects {} as follows:
27663
27663
  {label, color, rollColor, backgroundColor, rollBackgroundColor, call}
27664
27664
  with call being a callback function for when the button is pressed
27665
27665
  buttonScale - the scale for the buttons
@@ -28270,7 +28270,7 @@ content - (default null) optional content to be centered in one of three formats
28270
28270
  header - a ZIM DisplayObject for the top of the content
28271
28271
  message - text that will put into a ZIM Label - default color white - see color property
28272
28272
  display - a ZIM DisplayObject for beneath the message
28273
- buttons - an array of ZIM Button objects or configuration objects {} as follows:
28273
+ buttons - an array of ZIM Button objects or configuration objects {} as follows:
28274
28274
  {label, color, rollColor, backgroundColor, rollBackgroundColor, call}
28275
28275
  with call being a callback function for when the button is pressed
28276
28276
  buttonScale - the scale for the buttons
@@ -28799,7 +28799,7 @@ content - (default null) optional content to be centered in one of three formats
28799
28799
  header - a ZIM DisplayObject for the top of the content
28800
28800
  message - text that will put into a ZIM Label - default color white - see color property
28801
28801
  display - a ZIM DisplayObject for beneath the message
28802
- buttons - an array of ZIM Button objects or configuration objects {} as follows:
28802
+ buttons - an array of ZIM Button objects or configuration objects {} as follows:
28803
28803
  {label, color, rollColor, backgroundColor, rollBackgroundColor, call}
28804
28804
  with call being a callback function for when the button is pressed
28805
28805
  buttonScale - the scale for the buttons
@@ -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,7 @@ 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;
89550
89556
  that.image = that.bitmap.image;
89551
89557
  that.src = that.bitmap.src;
89552
89558
  that.item = that.bitmap.item;
@@ -89559,7 +89565,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89559
89565
  } else {
89560
89566
  inner.on("complete", function () {
89561
89567
  that.bitmap = inner.getChildAt(0).clone().addTo(that);
89562
- that.id = inner.id;
89568
+ that.id = that.bitmap.id = file;
89563
89569
  that.setBounds(null); // resets size
89564
89570
  that.type = "Pic";
89565
89571
  if (that.commands) {
@@ -89577,6 +89583,26 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
89577
89583
  if (that.stage) that.stage.update();
89578
89584
  });
89579
89585
  }
89586
+
89587
+ this.destroy = function() {
89588
+ if (this.id && this.bitmap) {
89589
+ this.image = this.bitmap.image = null;
89590
+ var frame;
89591
+ if (this.stage && this.stage.frame) frame = this.stage.frame;
89592
+ else frame = WW.zdf;
89593
+ if (frame && frame.assets) {
89594
+ if (frame.assets[this.id]) {
89595
+ if (frame.assets[this.id].dispose) frame.assets[this.id].dispose();
89596
+ delete frame.assets[this.id];
89597
+ }
89598
+ }
89599
+ if (zim.assets[this.id]) {
89600
+ if (zim.assets[this.id].dispose) zim.assets[this.id].dispose();
89601
+ delete zim.assets[this.id];
89602
+ }
89603
+ }
89604
+ this.dispose();
89605
+ }
89580
89606
 
89581
89607
  that.keyOut = function(color, tolerance, replacement) {
89582
89608
  if (that.type=="AC"&&WW.zdf) {WW.zdf.ac("keyOut", arguments, that); return that;}
@@ -92224,15 +92250,19 @@ RETURNS - a Label if a string or number is passed as content, a Container if a c
92224
92250
  var buts = new zim.Container().loc(0,obj.height+(data.header||data.message||data.display?spacingV:0),obj);
92225
92251
  for (var bb=0; bb<data.buttons.length; bb++) {
92226
92252
  var bd = data.buttons[bb];
92227
- var call = bd.call||function(){};
92228
- if (!bd.button) bd.button = new zim.Button({
92229
- width:bd.width,
92230
- label:bd.label,
92231
- backgroundColor:bd.backgroundColor||bd.bgColor,
92232
- color:bd.color,
92233
- rollBackgroundColor:bd.rollBackgroundColor||bd.rollBgColor,
92234
- rollColor:bd.rollColor
92235
- });
92253
+ var call = bd.call||function(){};
92254
+ if (bd.type != "Button") {
92255
+ bd.button = new zim.Button({
92256
+ width:bd.width,
92257
+ label:bd.label,
92258
+ backgroundColor:bd.backgroundColor||bd.bgColor,
92259
+ color:bd.color,
92260
+ rollBackgroundColor:bd.rollBackgroundColor||bd.rollBgColor,
92261
+ rollColor:bd.rollColor
92262
+ });
92263
+ } else {
92264
+ bd.button = bd;
92265
+ }
92236
92266
  bd.button.call = call;
92237
92267
  bd.button.sca(data.buttonScale).loc((bb==0?0:buts.width+spacingH),0,buts).tap(function(e){e.target.call(e.target)});
92238
92268
  }
@@ -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