@edifice.io/react 2.5.17 → 2.5.18-develop-enabling.20260504105750

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.
Files changed (74) hide show
  1. package/dist/components/Card/Card.js +1 -1
  2. package/dist/components/Combobox/Combobox.js +1 -1
  3. package/dist/components/Dropdown/Dropdown.d.ts +7 -3
  4. package/dist/components/Dropdown/Dropdown.js +22 -7
  5. package/dist/components/Dropdown/DropdownCheckboxItem.d.ts +6 -1
  6. package/dist/components/Dropdown/DropdownCheckboxItem.js +11 -6
  7. package/dist/components/Dropdown/DropdownContext.d.ts +5 -0
  8. package/dist/components/Dropdown/DropdownItem.d.ts +6 -1
  9. package/dist/components/Dropdown/DropdownItem.js +10 -5
  10. package/dist/components/Dropdown/DropdownItemHidden.d.ts +12 -0
  11. package/dist/components/Dropdown/DropdownItemHidden.js +19 -0
  12. package/dist/components/Dropdown/DropdownRadioItem.d.ts +6 -1
  13. package/dist/components/Dropdown/DropdownRadioItem.js +11 -6
  14. package/dist/components/Dropdown/DropdownSearchInput.d.ts +20 -0
  15. package/dist/components/Dropdown/DropdownSearchInput.js +25 -0
  16. package/dist/components/Dropdown/useDropdownItemFilter.d.ts +12 -0
  17. package/dist/components/Dropdown/useDropdownItemFilter.js +19 -0
  18. package/dist/components/Form/FormControl.js +1 -1
  19. package/dist/components/Layout/components/WidgetApps.js +1 -1
  20. package/dist/components/Modal/Modal.js +1 -1
  21. package/dist/components/Pagination/Pagination.d.ts +17 -0
  22. package/dist/components/Pagination/Pagination.js +14 -0
  23. package/dist/components/Pagination/index.d.ts +1 -0
  24. package/dist/components/PreventPropagation/PreventPropagation.js +1 -1
  25. package/dist/components/PromotionCard/PromotionCard.js +1 -1
  26. package/dist/components/SearchBar/SearchBar.d.ts +2 -2
  27. package/dist/components/Table/components/Table.js +1 -1
  28. package/dist/components/index.d.ts +1 -0
  29. package/dist/hooks/useConf/useConf.d.ts +1 -1
  30. package/dist/hooks/useDropdown/useDropdown.js +9 -8
  31. package/dist/hooks/useSession/useSession.d.ts +1 -1
  32. package/dist/hooks/useThumbnail/useThumbnail.d.ts +1 -1
  33. package/dist/hooks/useThumbnail/useThumbnail.js +5 -1
  34. package/dist/hooks/useUpload/useUpload.js +2 -5
  35. package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.d.ts +12 -0
  36. package/dist/hooks/useWorkspaceFolders/useWorkspaceFolders.js +1 -1
  37. package/dist/hooks/useZendeskGuide/useZendeskGuide.js +1 -1
  38. package/dist/icons-apps.js +136 -134
  39. package/dist/index.js +2 -0
  40. package/dist/modules/editor/components/Editor/EditorPreview.js +1 -1
  41. package/dist/modules/icons/components/apps/IconLivretScolaire.d.ts +7 -0
  42. package/dist/modules/icons/components/apps/IconLivretScolaire.js +13 -0
  43. package/dist/modules/icons/components/apps/index.d.ts +1 -0
  44. package/dist/modules/modals/ResourceModal/ResourceModal.d.ts +1 -1
  45. package/dist/modules/modals/ResourceModal/ResourceModal.js +1 -1
  46. package/dist/modules/modals/ResourceModal/hooks/useUpdateMutation.d.ts +1 -1
  47. package/dist/modules/modals/ShareModal/ShareResources.d.ts +4 -53
  48. package/dist/modules/modals/ShareModal/apps/ShareBlog.d.ts +1 -1
  49. package/dist/modules/modals/ShareModal/hooks/useShareBookmark.js +2 -1
  50. package/dist/modules/modals/ShareModal/hooks/useShareMutation.d.ts +1 -1
  51. package/dist/modules/multimedia/ImageEditor/components/ImageEditor.js +24 -10
  52. package/dist/modules/multimedia/ImageEditor/effects/blur.d.ts +7 -5
  53. package/dist/modules/multimedia/ImageEditor/effects/blur.js +26 -18
  54. package/dist/modules/multimedia/ImageEditor/effects/constants.d.ts +2 -0
  55. package/dist/modules/multimedia/ImageEditor/effects/constants.js +4 -0
  56. package/dist/modules/multimedia/ImageEditor/effects/crop.d.ts +4 -5
  57. package/dist/modules/multimedia/ImageEditor/effects/crop.js +42 -26
  58. package/dist/modules/multimedia/ImageEditor/effects/misc.d.ts +10 -16
  59. package/dist/modules/multimedia/ImageEditor/effects/misc.js +27 -12
  60. package/dist/modules/multimedia/ImageEditor/effects/resize.d.ts +3 -7
  61. package/dist/modules/multimedia/ImageEditor/effects/resize.js +31 -22
  62. package/dist/modules/multimedia/ImageEditor/effects/rotate.js +2 -3
  63. package/dist/modules/multimedia/ImageEditor/hooks/useHistoryTool.js +40 -41
  64. package/dist/modules/multimedia/ImageEditor/hooks/useImageEditor.d.ts +1 -1
  65. package/dist/modules/multimedia/ImageEditor/hooks/useImageEditor.js +9 -3
  66. package/dist/modules/multimedia/ImageEditor/hooks/useImageEffects.js +4 -1
  67. package/dist/modules/multimedia/LinkerCard/LinkerCard._.d.ts +1 -1
  68. package/dist/modules/multimedia/MediaLibrary/MediaLibrary.js +1 -0
  69. package/dist/modules/multimedia/UploadCard/UploadCard._.d.ts +1 -1
  70. package/dist/modules/multimedia/UploadFiles/UploadFiles.js +4 -4
  71. package/dist/providers/EdificeClientProvider/EdificeClientProvider.context.d.ts +1 -1
  72. package/dist/utilities/react-query/react-query-utils.d.ts +1 -1
  73. package/package.json +52 -53
  74. package/dist/modules/multimedia/FileCard/FileCard._.d.ts +0 -17
@@ -1,18 +1,20 @@
1
1
  import * as PIXI from 'pixi.js';
2
2
  /**
3
- * This function start the blur controler
3
+ * This function starts the blur controller:
4
4
  * - drawing cursor
5
5
  * - listening mouse move to move cursor
6
- * - listening
6
+ * - listening pointer events to apply blur
7
7
  *
8
- * @param application
9
- * @param param1
8
+ * @param application The PIXI.Application context
9
+ * @param spriteName The name of the sprite identifying the original image
10
10
  */
11
11
  export declare function start(application: PIXI.Application, { spriteName }: {
12
12
  spriteName: string;
13
13
  }): void;
14
14
  /**
15
- * This function remove cursor and all mouse event listeners
15
+ * This function removes cursor and all mouse event listeners.
16
+ * The blur layer is kept on stage so it gets captured by toBlob/generateTexture
17
+ * when the image is saved or another operation is applied.
16
18
  *
17
19
  * @param application the PIXI.Application context
18
20
  */
@@ -1,45 +1,53 @@
1
1
  import * as PIXI from "pixi.js";
2
2
  import { aggregate } from "../utilities/aggregate.js";
3
+ import { BLUR_LAYER_NAME } from "./constants.js";
3
4
  import { getApplicationScale } from "./misc.js";
4
5
  const BRUSH_SIZE = 20, DEBOUNCE = 50, CURSOR_NAME = "BRUSH_CURSOR";
6
+ function getOrCreateBlurLayer(application) {
7
+ let layer = application.stage.getChildByLabel(BLUR_LAYER_NAME);
8
+ return layer || (layer = new PIXI.Container(), layer.label = BLUR_LAYER_NAME, application.stage.addChild(layer)), layer;
9
+ }
5
10
  function drawBrush(points, scale) {
6
11
  const container = new PIXI.Graphics();
7
12
  for (const point of points)
8
- point && (container.beginFill(16777215, 1), container.drawCircle(point.x, point.y, BRUSH_SIZE / scale), container.lineStyle(0), container.endFill());
13
+ point && (container.circle(point.x, point.y, BRUSH_SIZE / scale), container.fill({
14
+ color: 16777215,
15
+ alpha: 1
16
+ }));
9
17
  return container;
10
18
  }
11
19
  function drawBlurListener(application, {
12
20
  spriteName
13
21
  }) {
14
22
  return aggregate(DEBOUNCE, (event) => application.stage.toLocal(event.global), (points) => {
15
- const child = application.stage.getChildByName(spriteName), scale = getApplicationScale(application);
16
- if (child == null) return;
17
- const newSprite = new PIXI.Sprite(child.texture);
18
- newSprite.filters = [
19
- new PIXI.BlurFilter(
20
- 8,
21
- // PIXI Default value for strength of the blur effect
22
- 4,
23
- // Quality of the blur effect depending on the scale (4 is the PIXI default value)
24
- Math.min(scale, 1)
25
- )
26
- // Resolution of the blur effect depending on the scale
27
- ], newSprite.width = child.width, newSprite.height = child.height, newSprite.scale = new PIXI.Point(1, 1), newSprite.anchor = child.anchor, newSprite.mask = drawBrush(points, scale), child.addChild(newSprite);
23
+ const child = application.stage.getChildByLabel(spriteName), scale = getApplicationScale(application);
24
+ if (!child) return;
25
+ const sprite = child, newSprite = new PIXI.Sprite(sprite.texture);
26
+ newSprite.filters = [new PIXI.BlurFilter({
27
+ strength: 8,
28
+ quality: Math.min(Math.round(4 * scale), 4),
29
+ resolution: Math.min(scale, 1)
30
+ })], newSprite.width = sprite.width, newSprite.height = sprite.height, newSprite.scale = new PIXI.Point(1, 1), newSprite.anchor = sprite.anchor;
31
+ const blurLayer = getOrCreateBlurLayer(application), brushMask = drawBrush(points, scale);
32
+ blurLayer.addChild(brushMask), newSprite.mask = brushMask, blurLayer.addChild(newSprite);
28
33
  });
29
34
  }
30
35
  function drawCursor(application) {
31
36
  removeCursor(application);
32
37
  const scale = getApplicationScale(application), circle = new PIXI.Graphics();
33
- return circle.lineStyle(Math.max(1, 1 / scale), 16711680), circle.drawCircle(0, 0, BRUSH_SIZE / scale), circle.endFill(), circle.name = CURSOR_NAME, application.stage.addChild(circle), circle;
38
+ return circle.circle(0, 0, BRUSH_SIZE / scale), circle.stroke({
39
+ width: Math.max(1, 1 / scale),
40
+ color: 16711680
41
+ }), circle.label = CURSOR_NAME, application.stage.addChild(circle), circle;
34
42
  }
35
43
  function removeCursor(application) {
36
- const child = application.stage.getChildByName(CURSOR_NAME);
44
+ const child = application.stage.getChildByLabel(CURSOR_NAME);
37
45
  child && child.removeFromParent();
38
46
  }
39
47
  function moveCursorListener(application) {
40
48
  return (event) => {
41
49
  if (!application) return;
42
- const point = application.stage.toLocal(event.global), child = application.stage.getChildByName(CURSOR_NAME, !0);
50
+ const point = application.stage.toLocal(event.global), child = application.stage.getChildByLabel(CURSOR_NAME, !0);
43
51
  child && (child.position.x = point.x, child.position.y = point.y);
44
52
  };
45
53
  }
@@ -53,7 +61,7 @@ function start(application, {
53
61
  spriteName
54
62
  });
55
63
  application.stage.on("pointerdown", () => {
56
- application.stage.on("pointermove", blurListener);
64
+ application.stage.off("pointermove", blurListener), application.stage.on("pointermove", blurListener);
57
65
  });
58
66
  const stopListening = () => {
59
67
  var _a;
@@ -0,0 +1,2 @@
1
+ /** Label used for the blur layer Container in the stage */
2
+ export declare const BLUR_LAYER_NAME = "BLUR_LAYER";
@@ -0,0 +1,4 @@
1
+ const BLUR_LAYER_NAME = "BLUR_LAYER";
2
+ export {
3
+ BLUR_LAYER_NAME
4
+ };
@@ -7,7 +7,7 @@ export type CornerType = 'TOP_LEFT' | 'TOP_RIGHT' | 'BOTTOM_LEFT' | 'BOTTOM_RIGH
7
7
  * - A mask applied to the original image
8
8
  *
9
9
  * @param application The PIXI.Application context
10
- * @param {spriteName:string} {spriteName} The sprite name identifying the original image
10
+ * @param spriteName The sprite name identifying the original image
11
11
  */
12
12
  export declare function start(application: PIXI.Application, { spriteName }: {
13
13
  spriteName: string;
@@ -19,10 +19,9 @@ export declare function start(application: PIXI.Application, { spriteName }: {
19
19
  */
20
20
  export declare function stop(application: PIXI.Application): void;
21
21
  /**
22
- * This function apply a crop to the imageSrc and return the result as a PIXI.Sprite object
22
+ * This function applies a crop and returns the result as a PIXI.Sprite object
23
23
  *
24
- * @param application
25
- * @param imageSrc a string URI of the image to crop
26
- * @returns a PIXI.Sprite with a imageSrc cropped or undefined if the image has not been cropped
24
+ * @param application The PIXI.Application context
25
+ * @returns a PIXI.Sprite with the cropped image or undefined if no crop area was defined
27
26
  */
28
27
  export declare function save(application: PIXI.Application): PIXI.Sprite | undefined;
@@ -8,17 +8,25 @@ function drawBackground(application, {
8
8
  spriteName
9
9
  }) {
10
10
  removeBackground(application);
11
- const sprite = application.stage.getChildByName(spriteName);
12
- if (sprite == null) return;
13
- const spriteBounds = sprite.getBounds(), stageTexture = application.renderer.generateTexture(application.stage).clone(), clonedStage = new PIXI.Sprite(stageTexture);
11
+ const sprite = application.stage.getChildByLabel(spriteName);
12
+ if (!sprite) return;
13
+ const spriteBounds = sprite.getBounds(), stageTexture = application.renderer.generateTexture(application.stage), clonedStage = new PIXI.Sprite(stageTexture);
14
14
  clonedStage.height = spriteBounds.height, clonedStage.width = spriteBounds.width, clonedStage.position = new PIXI.Point(0, 0);
15
- const background = new PIXI.Graphics();
16
- background.beginFill(16777215, 0.5), background.drawRect(0, 0, spriteBounds.width, spriteBounds.height), background.endFill(), background.name = CROP_BACKGROUND_NAME, background.position = new PIXI.Point(spriteBounds.x, spriteBounds.y);
15
+ const background = new PIXI.Container();
16
+ background.label = CROP_BACKGROUND_NAME, background.position = new PIXI.Point(spriteBounds.x, spriteBounds.y);
17
+ const backdrop = new PIXI.Graphics();
18
+ backdrop.rect(0, 0, spriteBounds.width, spriteBounds.height), backdrop.fill({
19
+ color: 16777215,
20
+ alpha: 0.5
21
+ });
17
22
  const rectMask = new PIXI.Graphics();
18
- rectMask.beginFill(0, 1), rectMask.drawRect(0, 0, spriteBounds.width - 2 * PADDING, spriteBounds.height - 2 * PADDING), rectMask.endFill(), rectMask.position = new PIXI.Point(PADDING, PADDING), rectMask.name = CROP_MASK_NAME, clonedStage.mask = rectMask, application.stage.addChild(background), background.addChild(rectMask), background.addChild(clonedStage);
23
+ rectMask.rect(0, 0, spriteBounds.width - 2 * PADDING, spriteBounds.height - 2 * PADDING), rectMask.fill({
24
+ color: 0,
25
+ alpha: 1
26
+ }), rectMask.position = new PIXI.Point(PADDING, PADDING), rectMask.label = CROP_MASK_NAME, clonedStage.mask = rectMask, application.stage.addChild(background), background.addChild(backdrop), background.addChild(rectMask), background.addChild(clonedStage);
19
27
  }
20
28
  function removeBackground(application) {
21
- const child = application.stage.getChildByName(CROP_BACKGROUND_NAME, !0);
29
+ const child = application.stage.getChildByLabel(CROP_BACKGROUND_NAME, !0);
22
30
  child == null || child.removeFromParent();
23
31
  }
24
32
  function computeCornerPosition(cornerType, bounds) {
@@ -54,10 +62,10 @@ function computeCornerPosition(cornerType, bounds) {
54
62
  }
55
63
  }
56
64
  function refreshCorners(application) {
57
- const mask = application.stage.getChildByName(CROP_MASK_NAME, !0);
58
- mask != null && CORNERS.forEach((cornerType) => {
59
- const corner = application.stage.getChildByName(getCornerName(cornerType), !0);
60
- if (corner == null) return;
65
+ const mask = application.stage.getChildByLabel(CROP_MASK_NAME, !0);
66
+ mask && CORNERS.forEach((cornerType) => {
67
+ const corner = application.stage.getChildByLabel(getCornerName(cornerType), !0);
68
+ if (!corner) return;
61
69
  const position = computeCornerPosition(cornerType, {
62
70
  height: mask.height,
63
71
  width: mask.width,
@@ -70,10 +78,10 @@ function refreshCorners(application) {
70
78
  function drawCorner(application, cornerType, {
71
79
  spriteName
72
80
  }) {
73
- const previous = application.stage.getChildByName(getCornerName(cornerType), !0), scale = getApplicationScale(application);
81
+ const previous = application.stage.getChildByLabel(getCornerName(cornerType), !0), scale = getApplicationScale(application);
74
82
  previous == null || previous.removeFromParent();
75
- const background = application.stage.getChildByName(CROP_BACKGROUND_NAME, !0), mask = application.stage.getChildByName(CROP_MASK_NAME, !0), sprite = application.stage.getChildByName(spriteName);
76
- if (sprite == null || background === null || background === void 0 || mask === void 0 || mask === null)
83
+ const background = application.stage.getChildByLabel(CROP_BACKGROUND_NAME, !0), mask = application.stage.getChildByLabel(CROP_MASK_NAME, !0);
84
+ if (!application.stage.getChildByLabel(spriteName) || !background || !mask)
77
85
  return;
78
86
  const position = computeCornerPosition(cornerType, {
79
87
  height: mask.height,
@@ -81,13 +89,17 @@ function drawCorner(application, cornerType, {
81
89
  x: mask.x,
82
90
  y: mask.y
83
91
  }), corner = new PIXI.Graphics();
84
- corner.beginFill(4960213, 1), corner.arc(0, 0, POINT_RADIUS / scale, position.start, position.end), corner.lineTo(0, 0), corner.endFill(), corner.position = new PIXI.Point(position.x, position.y), corner.name = getCornerName(cornerType), corner.interactive = !0;
92
+ corner.arc(0, 0, POINT_RADIUS / scale, position.start, position.end), corner.lineTo(0, 0), corner.fill({
93
+ color: 4960213,
94
+ alpha: 1
95
+ }), corner.position = new PIXI.Point(position.x, position.y), corner.label = getCornerName(cornerType), corner.interactive = !0;
85
96
  let enable = !1;
86
- application.stage.on("pointermove", (event) => {
87
- if (enable === !1) return;
97
+ const handlePointerMove = (event) => {
98
+ if (!enable) return;
88
99
  const localPosition = background.toLocal(event.global);
89
100
  corner.position.x = localPosition.x, corner.position.y = localPosition.y, moveMask(application, cornerType, localPosition);
90
- });
101
+ };
102
+ application.stage.on("pointermove", handlePointerMove);
91
103
  const handlePointerDown = () => {
92
104
  enable = !0;
93
105
  };
@@ -96,12 +108,12 @@ function drawCorner(application, cornerType, {
96
108
  enable = !1;
97
109
  };
98
110
  globalThis.addEventListener("pointerup", handlePointerUp), corner.once("destroyed", () => {
99
- corner.off("pointerdown"), globalThis.removeEventListener("pointerup", handlePointerUp);
111
+ corner.off("pointerdown"), application.stage.off("pointermove", handlePointerMove), globalThis.removeEventListener("pointerup", handlePointerUp);
100
112
  }), background.addChild(corner);
101
113
  }
102
114
  function moveMask(application, cornerType, position) {
103
- const mask = application.stage.getChildByName(CROP_MASK_NAME, !0);
104
- if (mask == null) return;
115
+ const mask = application.stage.getChildByLabel(CROP_MASK_NAME, !0);
116
+ if (!mask) return;
105
117
  const right = mask.position.x + mask.width, bottom = mask.position.y + mask.height;
106
118
  switch (cornerType) {
107
119
  case "TOP_LEFT": {
@@ -142,11 +154,15 @@ function stop(application) {
142
154
  removeBackground(application), application.stage.off("pointermove"), application.render();
143
155
  }
144
156
  function save(application) {
145
- const mask = application.stage.getChildByName(CROP_MASK_NAME, !0);
146
- if (mask == null) return;
147
- stop(application);
148
- const stageTexture = application.renderer.generateTexture(application.stage).clone(), clonedStage = new PIXI.Sprite(stageTexture), maskBounds = mask.getBounds(), bounds = new PIXI.Rectangle(Math.floor(maskBounds.x), Math.floor(maskBounds.y), Math.floor(maskBounds.width), Math.floor(maskBounds.height)), cropped = new PIXI.Texture(clonedStage.texture.baseTexture, bounds);
149
- return new PIXI.Sprite(cropped);
157
+ const mask = application.stage.getChildByLabel(CROP_MASK_NAME, !0);
158
+ if (!mask) return;
159
+ const background = application.stage.getChildByLabel(CROP_BACKGROUND_NAME, !0), offsetX = (background == null ? void 0 : background.x) ?? 0, offsetY = (background == null ? void 0 : background.y) ?? 0, frame = new PIXI.Rectangle(Math.floor(offsetX + mask.x), Math.floor(offsetY + mask.y), Math.floor(mask.width), Math.floor(mask.height));
160
+ background && (background.visible = !1);
161
+ const croppedTexture = application.renderer.generateTexture({
162
+ target: application.stage,
163
+ frame
164
+ });
165
+ return removeBackground(application), application.stage.off("pointermove"), new PIXI.Sprite(croppedTexture);
150
166
  }
151
167
  export {
152
168
  save,
@@ -1,11 +1,8 @@
1
1
  import * as PIXI from 'pixi.js';
2
2
  export declare const DEFAULT_SPRITE_NAME = "image";
3
3
  /**
4
- * A structure that define all setting of an image
5
- * - positon
6
- * - scale
7
- * - size
8
- * - size of the stage
4
+ * A structure that defines all settings of an image:
5
+ * position, scale, size, and size of the stage
9
6
  */
10
7
  export interface ImageSettings {
11
8
  stage: {
@@ -39,13 +36,12 @@ export interface ImageSettings {
39
36
  };
40
37
  }
41
38
  /**
42
- * This function update the image content using Blob datasource
39
+ * Update the image content using a Blob datasource
43
40
  *
44
41
  * @param application the PIXI.Application context
45
42
  * @param param.spriteName the name of the sprite in the context
46
- * @param param.imgDatasource the img data could be one of: string url, HTMLImageElement, PIXI.Sprite
47
- * @param param.stageSize?: { width: number; height: number };
48
- * @param param.spriteSize?: { width: number; height: number };
43
+ * @param param.imgDatasource the Blob data to load as image
44
+ * @param param.settings optional image settings to restore position/scale/rotation
49
45
  */
50
46
  export declare function updateImageFromBlob(application: PIXI.Application, { spriteName, imgDatasource, settings, }: {
51
47
  spriteName: string;
@@ -53,13 +49,12 @@ export declare function updateImageFromBlob(application: PIXI.Application, { spr
53
49
  settings?: ImageSettings;
54
50
  }): Promise<PIXI.Sprite | null>;
55
51
  /**
56
- * This function update the image content for the sprite in the PIXI.Application context
52
+ * Update the image content for the sprite in the PIXI.Application context
57
53
  *
58
54
  * @param application the PIXI.Application context
59
55
  * @param param.spriteName the name of the sprite in the context
60
- * @param param.imgDatasource the img data could be one of: string url, HTMLImageElement, PIXI.Sprite
61
- * @param param.spriteSize
62
- * @param param.stageSize
56
+ * @param param.imgDatasource the image source: a URL string, HTMLImageElement, or PIXI.Sprite
57
+ * @param param.settings optional image settings to restore position/scale/rotation
63
58
  */
64
59
  export declare function updateImage(application: PIXI.Application, { spriteName, imgDatasource, settings, }: {
65
60
  spriteName: string;
@@ -104,10 +99,9 @@ export declare function saveAsBlob(application: PIXI.Application): Promise<Blob>
104
99
  */
105
100
  export declare function saveAsDataURL(application: PIXI.Application): string | undefined;
106
101
  /**
107
- * Calculates the scale percentage for a PIXI.Sprite or the application view based on the parent container's dimensions.
102
+ * Calculates the scale ratio between the CSS display size and the actual canvas size.
108
103
  * @param application - The PIXI.Application instance.
109
- * @param sprite - The PIXI.Sprite instance (optional).
110
- * @returns The scale percentage.
104
+ * @returns The scale ratio (CSS width / canvas width).
111
105
  */
112
106
  export declare function getApplicationScale(application: PIXI.Application): number;
113
107
  export declare function toBlob(application: PIXI.Application): Promise<Blob>;
@@ -1,4 +1,5 @@
1
1
  import * as PIXI from "pixi.js";
2
+ import { BLUR_LAYER_NAME } from "./constants.js";
2
3
  const MIN_HEIGHT = 100, MIN_WIDTH = 100, MODAL_VERTICAL_PADDING = 450, MODAL_HORIZONTAL_PADDING = 64, DEFAULT_QUALITY = 0.5, DEFAULT_SPRITE_NAME = "image";
3
4
  function updateImageFromBlob(application, {
4
5
  spriteName,
@@ -6,15 +7,17 @@ function updateImageFromBlob(application, {
6
7
  settings
7
8
  }) {
8
9
  const imageUrl = URL.createObjectURL(imgDatasource), image = new Image();
9
- return image.src = imageUrl, new Promise((resolve) => {
10
+ return image.src = imageUrl, new Promise((resolve, reject) => {
10
11
  image.onload = async () => {
11
- await updateImage(application, {
12
+ URL.revokeObjectURL(imageUrl), await updateImage(application, {
12
13
  spriteName,
13
14
  imgDatasource: image,
14
15
  settings
15
16
  });
16
- const newSprite = application == null ? void 0 : application.stage.getChildByName(spriteName, !0);
17
+ const newSprite = application == null ? void 0 : application.stage.getChildByLabel(spriteName, !0);
17
18
  resolve(newSprite);
19
+ }, image.onerror = () => {
20
+ URL.revokeObjectURL(imageUrl), reject(new Error("Failed to load image from Blob"));
18
21
  };
19
22
  });
20
23
  }
@@ -25,10 +28,22 @@ async function updateImage(application, {
25
28
  }) {
26
29
  if (application === void 0 || application.stage === null)
27
30
  return;
28
- const previous = application.stage.getChildByName(spriteName, !0);
31
+ const previous = application.stage.getChildByLabel(spriteName, !0);
29
32
  previous == null || previous.removeFromParent();
30
- const texture = imgDatasource instanceof HTMLImageElement ? PIXI.Texture.from(imgDatasource) : imgDatasource instanceof PIXI.Sprite ? imgDatasource : await PIXI.Texture.fromURL(imgDatasource), sprite = texture instanceof PIXI.Sprite ? texture : PIXI.Sprite.from(texture, {});
31
- if (sprite.interactive = !0, sprite.name = spriteName, settings) {
33
+ const blurLayer = application.stage.getChildByLabel(BLUR_LAYER_NAME);
34
+ blurLayer == null || blurLayer.removeFromParent();
35
+ let sprite;
36
+ if (imgDatasource instanceof PIXI.Sprite)
37
+ sprite = imgDatasource;
38
+ else if (imgDatasource instanceof HTMLImageElement)
39
+ sprite = new PIXI.Sprite(PIXI.Texture.from(imgDatasource));
40
+ else {
41
+ const img = new Image();
42
+ img.crossOrigin = "anonymous", img.src = imgDatasource, await new Promise((resolve, reject) => {
43
+ img.complete ? resolve() : (img.onload = () => resolve(), img.onerror = reject);
44
+ }), sprite = new PIXI.Sprite(PIXI.Texture.from(img));
45
+ }
46
+ if (sprite.interactive = !0, sprite.label = spriteName, settings) {
32
47
  const {
33
48
  sprite: {
34
49
  anchor,
@@ -48,7 +63,7 @@ async function updateImage(application, {
48
63
  }
49
64
  function autoResize(application, sprite) {
50
65
  var _a;
51
- const parent = application.view.parentNode, maxMobileWidth = window.innerWidth - MODAL_HORIZONTAL_PADDING, parentWidth = Math.max((parent == null ? void 0 : parent.offsetWidth) ?? 0, MIN_WIDTH), newSize = constraintSize({
66
+ const parent = application.canvas.parentNode, maxMobileWidth = window.innerWidth - MODAL_HORIZONTAL_PADDING, parentWidth = Math.max((parent == null ? void 0 : parent.offsetWidth) ?? 0, MIN_WIDTH), newSize = constraintSize({
52
67
  width: sprite.width,
53
68
  height: sprite.height
54
69
  }, {
@@ -64,7 +79,7 @@ function autoResize(application, sprite) {
64
79
  height: newHeight,
65
80
  width: newWidth
66
81
  } = newSize;
67
- (_a = application.view) != null && _a.style && (application.view.style.width = `${newWidth}px`, application.view.style.height = `${newHeight}px`);
82
+ (_a = application.canvas) != null && _a.style && (application.canvas.style.width = `${newWidth}px`, application.canvas.style.height = `${newHeight}px`);
68
83
  }
69
84
  function constraintSize(size, constraints) {
70
85
  const {
@@ -83,22 +98,22 @@ function constraintSize(size, constraints) {
83
98
  function saveAsBlob(application) {
84
99
  return new Promise((resolve, reject) => {
85
100
  var _a;
86
- (_a = application == null ? void 0 : application.view) != null && _a.toBlob ? application.view.toBlob((blob) => {
101
+ (_a = application == null ? void 0 : application.canvas) != null && _a.toBlob ? application.canvas.toBlob((blob) => {
87
102
  blob ? resolve(blob) : reject("EXTRACT_FAILED");
88
103
  }, "image/jpeg", DEFAULT_QUALITY) : reject("EXTRACT_FAILED");
89
104
  });
90
105
  }
91
106
  function saveAsDataURL(application) {
92
107
  var _a, _b;
93
- return (_b = (_a = application.view).toDataURL) == null ? void 0 : _b.call(_a);
108
+ return (_b = (_a = application.canvas).toDataURL) == null ? void 0 : _b.call(_a);
94
109
  }
95
110
  function getApplicationScale(application) {
96
- return application.view.getBoundingClientRect ? application.view.getBoundingClientRect().width / application.view.width : 1;
111
+ return application.canvas.getBoundingClientRect ? application.canvas.getBoundingClientRect().width / application.canvas.width : 1;
97
112
  }
98
113
  function toBlob(application) {
99
114
  return new Promise((resolve, reject) => {
100
115
  var _a, _b;
101
- (_b = (_a = application.view).toBlob) == null || _b.call(_a, (blob) => {
116
+ (_b = (_a = application.canvas).toBlob) == null || _b.call(_a, (blob) => {
102
117
  blob ? resolve(blob) : reject("EXTRACT_FAIL");
103
118
  }, "image/png", 1);
104
119
  });
@@ -7,19 +7,15 @@ import * as PIXI from 'pixi.js';
7
7
  */
8
8
  export declare function start(application: PIXI.Application, spriteName: string): void;
9
9
  /**
10
- * If {saveChanges} is true remove all graphical controls then resize the sprite
11
- * If {saveChanges} is false remove all graphical controls and keep original size
10
+ * Remove all graphical controls and mouse event listeners
12
11
  *
13
12
  * @param application the PIXI.Application context
14
- * @param param.saveChanges true if we should save the resize
15
- * @param param.spriteName the name of the sprite representing the original image
16
13
  */
17
14
  export declare function stop(application: PIXI.Application): void;
18
15
  /**
16
+ * Apply the resize and return the result as a PIXI.Sprite
19
17
  *
20
18
  * @param application the PIXI.Application context
21
- * @param spriteName the name of the sprite representing the image
22
- * @param size the target size of the image {width, height}
23
- * @returns a PIXI.Sprite with a image resized or undefined if not found
19
+ * @returns a PIXI.Sprite with the resized image or undefined if no resize was applied
24
20
  */
25
21
  export declare function save(application: PIXI.Application): PIXI.Sprite | undefined;
@@ -42,8 +42,8 @@ function resizeContainer(application, {
42
42
  position,
43
43
  spriteName
44
44
  }) {
45
- const sprite = application.stage.getChildByName(spriteName, !0);
46
- if (sprite == null) return;
45
+ const sprite = application.stage.getChildByLabel(spriteName, !0);
46
+ if (!sprite) return;
47
47
  const isRotated = sprite.rotation % Math.PI !== 0, spriteWidth = isRotated ? sprite.height : sprite.width, spriteHeight = isRotated ? sprite.width : sprite.height;
48
48
  switch (cornerType) {
49
49
  case "TOP_LEFT": {
@@ -68,20 +68,23 @@ function resizeContainer(application, {
68
68
  }
69
69
  }
70
70
  function removeCorner(application, cornerType) {
71
- const previous = application.stage.getChildByName(getCornerName(cornerType), !0);
71
+ const previous = application.stage.getChildByLabel(getCornerName(cornerType), !0);
72
72
  previous == null || previous.removeFromParent();
73
73
  }
74
74
  function drawCorner(application, cornerType, {
75
75
  spriteName
76
76
  }) {
77
77
  removeCorner(application, cornerType);
78
- const sprite = application.stage.getChildByName(spriteName, !0), container = application.stage.getChildByName(CONTROL_NAME, !0);
79
- if (sprite == null || container === null || container === void 0) return;
78
+ const sprite = application.stage.getChildByLabel(spriteName, !0), container = application.stage.getChildByLabel(CONTROL_NAME, !0);
79
+ if (!sprite || !container) return;
80
80
  const position = computeCornerPosition(cornerType, container), corner = new PIXI.Graphics();
81
- corner.beginFill(4960213, 1), corner.arc(0, 0, POINT_RADIUS, position.start, position.end), corner.lineTo(0, 0), corner.endFill(), corner.position = new PIXI.Point(position.x, position.y), corner.name = getCornerName(cornerType), corner.interactive = !0;
81
+ corner.arc(0, 0, POINT_RADIUS, position.start, position.end), corner.lineTo(0, 0), corner.fill({
82
+ color: 4960213,
83
+ alpha: 1
84
+ }), corner.position = new PIXI.Point(position.x, position.y), corner.label = getCornerName(cornerType), corner.interactive = !0;
82
85
  let enable = !1;
83
- application.stage.on("pointermove", (event) => {
84
- if (enable === !1) return;
86
+ const handlePointerMove = (event) => {
87
+ if (!enable) return;
85
88
  const localPosition = application.stage.toLocal(event.global);
86
89
  resizeContainer(application, {
87
90
  cornerType,
@@ -89,31 +92,37 @@ function drawCorner(application, cornerType, {
89
92
  container,
90
93
  spriteName
91
94
  });
92
- });
93
- const handlePointerUp = () => {
94
- enable = !1;
95
95
  };
96
- globalThis.addEventListener("pointerup", handlePointerUp), corner.once("destroyed", () => {
97
- corner.off("pointerdown"), globalThis.removeEventListener("pointerup", handlePointerUp);
98
- });
96
+ application.stage.on("pointermove", handlePointerMove);
99
97
  const handlePointerDown = () => {
100
98
  enable = !0;
101
99
  };
102
- corner.on("pointerdown", handlePointerDown), container.addChild(corner);
100
+ corner.on("pointerdown", handlePointerDown);
101
+ const handlePointerUp = () => {
102
+ enable = !1;
103
+ };
104
+ globalThis.addEventListener("pointerup", handlePointerUp), corner.once("destroyed", () => {
105
+ corner.off("pointerdown"), application.stage.off("pointermove", handlePointerMove), globalThis.removeEventListener("pointerup", handlePointerUp);
106
+ }), container.addChild(corner);
103
107
  }
104
108
  function drawContainer(application, spriteName) {
105
109
  removeContainer(application);
106
- const sprite = application.stage.getChildByName(spriteName, !0);
107
- if (sprite == null) return;
110
+ const sprite = application.stage.getChildByLabel(spriteName, !0);
111
+ if (!sprite) return;
108
112
  const stageTexture = application.renderer.generateTexture(application.stage), clonedStage = new PIXI.Sprite(stageTexture);
109
113
  application.stage.children.forEach((child) => {
110
114
  child.alpha = 0;
111
115
  });
112
- const container = new PIXI.Graphics();
113
- container.drawRect(0, 0, sprite.width, sprite.height), container.name = CONTROL_NAME, container.interactive = !0, container.interactiveChildren = !0, application.stage.interactive = !0, application.stage.interactiveChildren = !0, application.stage.addChild(container), container.addChild(clonedStage);
116
+ const container = new PIXI.Container();
117
+ container.label = CONTROL_NAME, container.interactive = !0, container.interactiveChildren = !0;
118
+ const bounds = new PIXI.Graphics();
119
+ bounds.rect(0, 0, sprite.width, sprite.height), bounds.fill({
120
+ color: 0,
121
+ alpha: 0
122
+ }), application.stage.interactive = !0, application.stage.interactiveChildren = !0, application.stage.addChild(container), container.addChild(bounds), container.addChild(clonedStage);
114
123
  }
115
124
  function removeContainer(application) {
116
- const container = application.stage.getChildByName(CONTROL_NAME, !0);
125
+ const container = application.stage.getChildByLabel(CONTROL_NAME, !0);
117
126
  container == null || container.removeFromParent(), application.stage.children.forEach((child) => {
118
127
  child.alpha = 1;
119
128
  });
@@ -140,12 +149,12 @@ function stop(application) {
140
149
  }
141
150
  function save(application) {
142
151
  var _a;
143
- const container = (_a = application == null ? void 0 : application.stage) == null ? void 0 : _a.getChildByName(CONTROL_NAME, !0), size = container ? {
152
+ const container = (_a = application == null ? void 0 : application.stage) == null ? void 0 : _a.getChildByLabel(CONTROL_NAME, !0), size = container ? {
144
153
  height: container.height,
145
154
  width: container.width
146
155
  } : void 0;
147
156
  if (removeControl(application), size) {
148
- const stageTexture = application.renderer.generateTexture(application.stage).clone(), clonedStage = new PIXI.Sprite(stageTexture);
157
+ const stageTexture = application.renderer.generateTexture(application.stage), clonedStage = new PIXI.Sprite(stageTexture);
149
158
  return clonedStage.width = size.width, clonedStage.height = size.height, clonedStage;
150
159
  } else
151
160
  return;
@@ -1,8 +1,7 @@
1
1
  import { toBlob, updateImageFromBlob, createImageSettings, resizeStage } from "./misc.js";
2
2
  async function rotate(application, spriteName) {
3
- const sprite = application == null ? void 0 : application.stage.getChildByName(spriteName, !0);
3
+ const sprite = application == null ? void 0 : application.stage.getChildByLabel(spriteName, !0);
4
4
  if (application && sprite) {
5
- if (!application) return;
6
5
  const blobBefore = await toBlob(application), mergedSprite = await updateImageFromBlob(application, {
7
6
  imgDatasource: blobBefore,
8
7
  spriteName,
@@ -14,7 +13,7 @@ async function rotate(application, spriteName) {
14
13
  if (!mergedSprite)
15
14
  return;
16
15
  let backupOldMaxHeight, backupOldVisibility;
17
- const canvas = application.view;
16
+ const canvas = application.canvas;
18
17
  canvas.style && (backupOldMaxHeight = canvas.style.maxHeight ?? "", backupOldVisibility = canvas.style.visibility ?? "", canvas.style.maxHeight = `${canvas.clientHeight}px`, canvas.style.visibility = "hidden"), mergedSprite.rotation += Math.PI / 2, resizeStage({
19
18
  application,
20
19
  sprite: mergedSprite,