@pacem/pacem-foundation 2.0.0-abel → 2.0.0-babbage

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.
@@ -7435,7 +7435,7 @@
7435
7435
  {
7436
7436
  "kind": "Method",
7437
7437
  "canonicalReference": "@pacem/pacem-foundation!Imaging.resizeImage:member(1)",
7438
- "docComment": "/**\n * Resizes an image to the given target size, drawing it onto an offscreen canvas.\n *\n * @param img - Source image, either as a `Blob` or a URL to fetch it from.\n *\n * @param width - Target width, in pixels.\n *\n * @param height - Target height, in pixels.\n *\n * @param options - Resize/encoding options (fit mode, alignment, quality, output type, background).\n *\n * @returns A promise resolving with the resized image as a `Blob`.\n */\n",
7438
+ "docComment": "/**\n * Resizes an image to the given target size, drawing it onto an offscreen canvas.\n *\n * @param img - Source image: a `Blob`, a URL to fetch it from, or an already drawable {@link ImagingSource}.\n *\n * @param width - Target width, in pixels.\n *\n * @param height - Target height, in pixels.\n *\n * @param options - Resize/encoding options (fit mode, alignment, quality, output type, background).\n *\n * @returns A promise resolving with the resized image as a `Blob`.\n */\n",
7439
7439
  "excerptTokens": [
7440
7440
  {
7441
7441
  "kind": "Content",
@@ -7654,6 +7654,118 @@
7654
7654
  "isOptional": false,
7655
7655
  "isAbstract": false,
7656
7656
  "name": "resizeImage"
7657
+ },
7658
+ {
7659
+ "kind": "Method",
7660
+ "canonicalReference": "@pacem/pacem-foundation!Imaging.resizeImage:member(3)",
7661
+ "docComment": "",
7662
+ "excerptTokens": [
7663
+ {
7664
+ "kind": "Content",
7665
+ "text": "static resizeImage(img: "
7666
+ },
7667
+ {
7668
+ "kind": "Reference",
7669
+ "text": "ImagingSource",
7670
+ "canonicalReference": "@pacem/pacem-foundation!ImagingSource:type"
7671
+ },
7672
+ {
7673
+ "kind": "Content",
7674
+ "text": ", width: "
7675
+ },
7676
+ {
7677
+ "kind": "Content",
7678
+ "text": "number"
7679
+ },
7680
+ {
7681
+ "kind": "Content",
7682
+ "text": ", height: "
7683
+ },
7684
+ {
7685
+ "kind": "Content",
7686
+ "text": "number"
7687
+ },
7688
+ {
7689
+ "kind": "Content",
7690
+ "text": ", options?: "
7691
+ },
7692
+ {
7693
+ "kind": "Reference",
7694
+ "text": "ImagingResizeOptions",
7695
+ "canonicalReference": "@pacem/pacem-foundation!ImagingResizeOptions:type"
7696
+ },
7697
+ {
7698
+ "kind": "Content",
7699
+ "text": "): "
7700
+ },
7701
+ {
7702
+ "kind": "Reference",
7703
+ "text": "Promise",
7704
+ "canonicalReference": "!Promise:interface"
7705
+ },
7706
+ {
7707
+ "kind": "Content",
7708
+ "text": "<"
7709
+ },
7710
+ {
7711
+ "kind": "Reference",
7712
+ "text": "Blob",
7713
+ "canonicalReference": "!Blob:interface"
7714
+ },
7715
+ {
7716
+ "kind": "Content",
7717
+ "text": ">"
7718
+ },
7719
+ {
7720
+ "kind": "Content",
7721
+ "text": ";"
7722
+ }
7723
+ ],
7724
+ "isStatic": true,
7725
+ "returnTypeTokenRange": {
7726
+ "startIndex": 9,
7727
+ "endIndex": 13
7728
+ },
7729
+ "releaseTag": "Public",
7730
+ "isProtected": false,
7731
+ "overloadIndex": 3,
7732
+ "parameters": [
7733
+ {
7734
+ "parameterName": "img",
7735
+ "parameterTypeTokenRange": {
7736
+ "startIndex": 1,
7737
+ "endIndex": 2
7738
+ },
7739
+ "isOptional": false
7740
+ },
7741
+ {
7742
+ "parameterName": "width",
7743
+ "parameterTypeTokenRange": {
7744
+ "startIndex": 3,
7745
+ "endIndex": 4
7746
+ },
7747
+ "isOptional": false
7748
+ },
7749
+ {
7750
+ "parameterName": "height",
7751
+ "parameterTypeTokenRange": {
7752
+ "startIndex": 5,
7753
+ "endIndex": 6
7754
+ },
7755
+ "isOptional": false
7756
+ },
7757
+ {
7758
+ "parameterName": "options",
7759
+ "parameterTypeTokenRange": {
7760
+ "startIndex": 7,
7761
+ "endIndex": 8
7762
+ },
7763
+ "isOptional": true
7764
+ }
7765
+ ],
7766
+ "isOptional": false,
7767
+ "isAbstract": false,
7768
+ "name": "resizeImage"
7657
7769
  }
7658
7770
  ],
7659
7771
  "implementsTokenRanges": []
@@ -7684,6 +7796,37 @@
7684
7796
  "endIndex": 2
7685
7797
  }
7686
7798
  },
7799
+ {
7800
+ "kind": "TypeAlias",
7801
+ "canonicalReference": "@pacem/pacem-foundation!ImagingSource:type",
7802
+ "docComment": "/**\n * An already drawable image source exposing its size (e.g. an `ImageBitmap`, an `OffscreenCanvas` or, where a DOM is available, an `HTMLImageElement`). Use it for formats `createImageBitmap` can't decode, such as SVG: load the image into an `HTMLImageElement` and pass that.\n */\n",
7803
+ "excerptTokens": [
7804
+ {
7805
+ "kind": "Content",
7806
+ "text": "export declare type ImagingSource = "
7807
+ },
7808
+ {
7809
+ "kind": "Reference",
7810
+ "text": "CanvasImageSource",
7811
+ "canonicalReference": "!CanvasImageSource:type"
7812
+ },
7813
+ {
7814
+ "kind": "Content",
7815
+ "text": " & {\n width: number;\n height: number;\n}"
7816
+ },
7817
+ {
7818
+ "kind": "Content",
7819
+ "text": ";"
7820
+ }
7821
+ ],
7822
+ "fileUrlPath": "dist/types/imaging.d.ts",
7823
+ "releaseTag": "Public",
7824
+ "name": "ImagingSource",
7825
+ "typeTokenRange": {
7826
+ "startIndex": 1,
7827
+ "endIndex": 3
7828
+ }
7829
+ },
7687
7830
  {
7688
7831
  "kind": "Class",
7689
7832
  "canonicalReference": "@pacem/pacem-foundation!Keys:class",
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/blobs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/dates.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/geom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -31,11 +31,8 @@ export class Imaging {
31
31
  if (width <= 0 || height <= 0 || isNaN(width) || isNaN(height)) {
32
32
  throw new Error('Invalid target size');
33
33
  }
34
- if (typeof img === 'string') {
35
- img = await Imaging.loadImage(img);
36
- }
37
- const el = await self.createImageBitmap(img);
38
- const origWidth = el.width, origHeight = el.height;
34
+ const el = await Imaging._toDrawable(img);
35
+ const origWidth = el.width || width, origHeight = el.height || height;
39
36
  const cnv = new OffscreenCanvas(origWidth, origHeight);
40
37
  const ctx = cnv.getContext('2d');
41
38
  ctx.imageSmoothingEnabled =
@@ -57,5 +54,15 @@ export class Imaging {
57
54
  const retval = await cnv.convertToBlob({ quality, type });
58
55
  return retval;
59
56
  }
57
+ /** Turns a URL or a `Blob` into a drawable source, while passing an already drawable source through untouched. */
58
+ static async _toDrawable(img) {
59
+ if (typeof img === 'string') {
60
+ img = await Imaging.loadImage(img);
61
+ }
62
+ if (!(img instanceof Blob)) {
63
+ return img;
64
+ }
65
+ return await self.createImageBitmap(img);
66
+ }
60
67
  }
61
68
  // }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/dist/esm/rect.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-foundation v2.0.0-abel (https://js.pacem.it)
2
+ * @pacem/pacem-foundation v2.0.0-babbage (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "types": "./typings/index.d.ts"
26
26
  }
27
27
  },
28
- "version": "2.0.0-abel",
28
+ "version": "2.0.0-babbage",
29
29
  "author": {
30
30
  "name": "Pacem",
31
31
  "url": "https://pacem.it"
@@ -438,7 +438,7 @@ export declare class Imaging {
438
438
  static loadImage(url: string): Promise<Blob>;
439
439
  /**
440
440
  * Resizes an image to the given target size, drawing it onto an offscreen canvas.
441
- * @param img Source image, either as a `Blob` or a URL to fetch it from.
441
+ * @param img Source image: a `Blob`, a URL to fetch it from, or an already drawable {@link ImagingSource}.
442
442
  * @param width Target width, in pixels.
443
443
  * @param height Target height, in pixels.
444
444
  * @param options Resize/encoding options (fit mode, alignment, quality, output type, background).
@@ -446,6 +446,9 @@ export declare class Imaging {
446
446
  */
447
447
  static resizeImage(img: Blob, width: number, height: number, options?: ImagingResizeOptions): Promise<Blob>;
448
448
  static resizeImage(img: string, width: number, height: number, options?: ImagingResizeOptions): Promise<Blob>;
449
+ static resizeImage(img: ImagingSource, width: number, height: number, options?: ImagingResizeOptions): Promise<Blob>;
450
+ /** Turns a URL or a `Blob` into a drawable source, while passing an already drawable source through untouched. */
451
+ private static _toDrawable;
449
452
  }
450
453
 
451
454
  /** Options controlling how {@link Imaging.resizeImage} fits and encodes the resized image. */
@@ -464,6 +467,15 @@ export declare type ImagingResizeOptions = {
464
467
  background?: string;
465
468
  };
466
469
 
470
+ /**
471
+ * An already drawable image source exposing its size (e.g. an `ImageBitmap`, an `OffscreenCanvas` or, where a DOM is available, an `HTMLImageElement`).
472
+ * Use it for formats `createImageBitmap` can't decode, such as SVG: load the image into an `HTMLImageElement` and pass that.
473
+ */
474
+ export declare type ImagingSource = CanvasImageSource & {
475
+ width: number;
476
+ height: number;
477
+ };
478
+
467
479
  /**
468
480
  * JavaScript vocabulary, TypeScript superset: comments (JSDoc as `doc-comment`), strings, template literals with nested
469
481
  * `${…}` expressions, regular expression literals (told from divisions by the previous significant token), numbers
@@ -1148,6 +1160,7 @@ declare global {
1148
1160
  Hsla,
1149
1161
  Imaging,
1150
1162
  ImagingResizeOptions,
1163
+ ImagingSource,
1151
1164
  Keys,
1152
1165
  Matrix2D,
1153
1166
  NullChecker,