microboard-ui-temp 0.1.107 → 0.1.109

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 (3) hide show
  1. package/dist/index.js +57 -13
  2. package/dist/spa.js +70 -26
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -235403,7 +235403,8 @@ var conf = {
235403
235403
  cursorsMap,
235404
235404
  DECK_HORIZONTAL_OFFSET: 2,
235405
235405
  DECK_VERTICAL_OFFSET: 2,
235406
- CARD_DIMENSIONS: { width: 250, height: 400 }
235406
+ CARD_DIMENSIONS: { width: 250, height: 400 },
235407
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
235407
235408
  };
235408
235409
  initDefaultI18N();
235409
235410
 
@@ -249464,6 +249465,7 @@ class BaseItem extends Mbr {
249464
249465
  shouldRenderOutsideViewRect = true;
249465
249466
  shouldUseRelativeAlignment = true;
249466
249467
  enableResize = true;
249468
+ onlyProportionalResize = false;
249467
249469
  itemType = "";
249468
249470
  children = [];
249469
249471
  constructor(board, id2 = "", defaultItemData, isGroupItem) {
@@ -275369,7 +275371,8 @@ var defaultCardData = {
275369
275371
  itemType: "Card",
275370
275372
  isOpen: false,
275371
275373
  faceUrl: "",
275372
- backsideUrl: ""
275374
+ backsideUrl: "",
275375
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
275373
275376
  };
275374
275377
 
275375
275378
  class Card extends BaseItem {
@@ -275382,9 +275385,13 @@ class Card extends BaseItem {
275382
275385
  backside = null;
275383
275386
  imageToRender = null;
275384
275387
  shouldUseCustomRender = false;
275385
- enableResize = false;
275386
- constructor(board, id2 = "", urls) {
275388
+ onlyProportionalResize = true;
275389
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
275390
+ constructor(board, id2 = "", urls, dimensions) {
275387
275391
  super(board, id2, defaultCardData);
275392
+ if (dimensions) {
275393
+ this.dimensions = dimensions;
275394
+ }
275388
275395
  if (urls) {
275389
275396
  this.faceUrl = urls.faceUrl;
275390
275397
  this.backsideUrl = urls.backsideUrl;
@@ -275402,6 +275409,9 @@ class Card extends BaseItem {
275402
275409
  });
275403
275410
  this.updateMbr();
275404
275411
  }
275412
+ getDimensions() {
275413
+ return this.dimensions;
275414
+ }
275405
275415
  createImages() {
275406
275416
  this.face = conf.documentFactory.createElement("img");
275407
275417
  this.backside = conf.documentFactory.createElement("img");
@@ -275457,8 +275467,8 @@ class Card extends BaseItem {
275457
275467
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
275458
275468
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
275459
275469
  div.id = this.getId();
275460
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
275461
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
275470
+ div.style.width = `${this.dimensions.width}px`;
275471
+ div.style.height = `${this.dimensions.height}px`;
275462
275472
  div.style.transformOrigin = "top left";
275463
275473
  div.style.transform = transform;
275464
275474
  div.style.position = "absolute";
@@ -275469,8 +275479,8 @@ class Card extends BaseItem {
275469
275479
  updateMbr() {
275470
275480
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
275471
275481
  const rotation = this.transformation.getRotation();
275472
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
275473
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
275482
+ const height3 = this.dimensions.height * scaleY;
275483
+ const width2 = this.dimensions.width * scaleX;
275474
275484
  if (rotation % 180 === 0) {
275475
275485
  this.left = translateX;
275476
275486
  this.top = translateY;
@@ -275610,7 +275620,9 @@ class Deck extends BaseItem {
275610
275620
  childIds.forEach((childId) => {
275611
275621
  const foundItem = this.board.items.getById(childId);
275612
275622
  if (this.parent !== childId && this.getId() !== childId) {
275613
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
275623
+ const firstCard = this.getFirstCard();
275624
+ const firstCardDimensions = firstCard?.getDimensions();
275625
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
275614
275626
  if (canAddItem) {
275615
275627
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
275616
275628
  foundItem.transformation.apply({
@@ -275620,6 +275632,19 @@ class Deck extends BaseItem {
275620
275632
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
275621
275633
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
275622
275634
  });
275635
+ if (firstCard) {
275636
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
275637
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
275638
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
275639
+ foundItem.transformation.apply({
275640
+ class: "Transformation",
275641
+ method: "scaleTo",
275642
+ item: [this.id],
275643
+ x: targetScaleX,
275644
+ y: targetScaleY
275645
+ });
275646
+ }
275647
+ }
275623
275648
  this.board.selection.remove(foundItem);
275624
275649
  this.board.items.index.remove(foundItem);
275625
275650
  foundItem.parent = this.getId();
@@ -275784,6 +275809,9 @@ class Deck extends BaseItem {
275784
275809
  this.isCacheDirty = false;
275785
275810
  this.updateMbr();
275786
275811
  }
275812
+ getFirstCard() {
275813
+ return this.index?.list()[0];
275814
+ }
275787
275815
  }
275788
275816
  registerItem({
275789
275817
  item: Deck,
@@ -279199,7 +279227,7 @@ function transformItems({
279199
279227
  setSnapCursorPos
279200
279228
  }) {
279201
279229
  const items = selection.items.list();
279202
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
279230
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
279203
279231
  if (includesProportionalItem && (isWidth || isHeight)) {
279204
279232
  return null;
279205
279233
  }
@@ -439059,6 +439087,18 @@ var import_react353 = __toESM(require_react(), 1);
439059
439087
  // src/features/GameItems/CreateCardsModal.tsx
439060
439088
  var import_react352 = __toESM(require_react(), 1);
439061
439089
  var CREATE_CARDS_MODAL = Symbol("createCardsModal");
439090
+ var getImageDimensions = (file) => {
439091
+ return new Promise((resolve2) => {
439092
+ const img2 = new Image;
439093
+ img2.src = URL.createObjectURL(file);
439094
+ img2.onload = () => {
439095
+ resolve2({
439096
+ width: img2.naturalWidth,
439097
+ height: img2.naturalHeight
439098
+ });
439099
+ };
439100
+ });
439101
+ };
439062
439102
  function CreateCardsModal() {
439063
439103
  const { t: t11 } = useTranslation();
439064
439104
  const { closeModal: closeModal2 } = useUiModalContext();
@@ -439073,13 +439113,16 @@ function CreateCardsModal() {
439073
439113
  const cardsInputRef = import_react352.default.useRef(null);
439074
439114
  const handleCoverClick = () => coverInputRef.current?.click();
439075
439115
  const handleCardsClick = () => cardsInputRef.current?.click();
439076
- const createDeck2 = (backsideUrl, faceUrls) => {
439116
+ const createDeck2 = (backsideUrl, faceUrls, dimensions) => {
439077
439117
  const cards2 = [];
439118
+ const { width: width3, height: height4 } = dimensions;
439119
+ const { width: defaultWidth, height: defaultHeight } = conf.DEFAULT_GAME_ITEM_DIMENSIONS;
439120
+ const normalizedDimensions = width3 > height4 ? { width: defaultWidth * width3 / height4, height: defaultHeight } : { width: defaultWidth, height: defaultHeight * height4 / width3 };
439078
439121
  faceUrls.forEach((faceUrl, index4) => {
439079
439122
  const card = new Card(board, index4 + faceUrl, {
439080
439123
  backsideUrl,
439081
439124
  faceUrl
439082
- });
439125
+ }, normalizedDimensions);
439083
439126
  cards2.push(card);
439084
439127
  });
439085
439128
  const itemsMap = {};
@@ -439114,8 +439157,9 @@ function CreateCardsModal() {
439114
439157
  setLoading(true);
439115
439158
  try {
439116
439159
  if (cards.length > 0 && cover) {
439160
+ const dimensions = await getImageDimensions(cover);
439117
439161
  const urls = await uploadImages([cover, ...cards], board.getBoardId(), account.accessToken);
439118
- createDeck2(urls[0], urls.slice(1));
439162
+ createDeck2(urls[0], urls.slice(1), dimensions);
439119
439163
  }
439120
439164
  closeModal2();
439121
439165
  } catch (err2) {
package/dist/spa.js CHANGED
@@ -134733,7 +134733,7 @@ function proxy(initialObject = {}) {
134733
134733
  }
134734
134734
  function subscribe(proxyObject, callback, notifyInSync) {
134735
134735
  const proxyState = proxyStateMap.get(proxyObject);
134736
- if ((import.meta.env ? import.meta.env.MODE : undefined) !== "production" && !proxyState) {
134736
+ if ((import.meta.env ? globalThis.__ENV__?.MODE ?? "" : undefined) !== "production" && !proxyState) {
134737
134737
  console.warn("Please use proxy object");
134738
134738
  }
134739
134739
  let promise;
@@ -134764,7 +134764,7 @@ function subscribe(proxyObject, callback, notifyInSync) {
134764
134764
  }
134765
134765
  function snapshot(proxyObject, handlePromise) {
134766
134766
  const proxyState = proxyStateMap.get(proxyObject);
134767
- if ((import.meta.env ? import.meta.env.MODE : undefined) !== "production" && !proxyState) {
134767
+ if ((import.meta.env ? globalThis.__ENV__?.MODE ?? "" : undefined) !== "production" && !proxyState) {
134768
134768
  console.warn("Please use proxy object");
134769
134769
  }
134770
134770
  const [target, ensureVersion, createSnapshot] = proxyState;
@@ -134850,7 +134850,7 @@ var isObject6 = (x8) => typeof x8 === "object" && x8 !== null, proxyStateMap, re
134850
134850
  };
134851
134851
  const propProxyStates = /* @__PURE__ */ new Map;
134852
134852
  const addPropListener = (prop, propProxyState) => {
134853
- if ((import.meta.env ? import.meta.env.MODE : undefined) !== "production" && propProxyStates.has(prop)) {
134853
+ if ((import.meta.env ? globalThis.__ENV__?.MODE ?? "" : undefined) !== "production" && propProxyStates.has(prop)) {
134854
134854
  throw new Error("prop listener already exists");
134855
134855
  }
134856
134856
  if (listeners3.size) {
@@ -134872,7 +134872,7 @@ var isObject6 = (x8) => typeof x8 === "object" && x8 !== null, proxyStateMap, re
134872
134872
  listeners3.add(listener);
134873
134873
  if (listeners3.size === 1) {
134874
134874
  propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
134875
- if ((import.meta.env ? import.meta.env.MODE : undefined) !== "production" && prevRemove) {
134875
+ if ((import.meta.env ? globalThis.__ENV__?.MODE ?? "" : undefined) !== "production" && prevRemove) {
134876
134876
  throw new Error("remove already exists");
134877
134877
  }
134878
134878
  const remove2 = propProxyState[3](createPropListener(prop));
@@ -235403,7 +235403,8 @@ var conf = {
235403
235403
  cursorsMap,
235404
235404
  DECK_HORIZONTAL_OFFSET: 2,
235405
235405
  DECK_VERTICAL_OFFSET: 2,
235406
- CARD_DIMENSIONS: { width: 250, height: 400 }
235406
+ CARD_DIMENSIONS: { width: 250, height: 400 },
235407
+ DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 }
235407
235408
  };
235408
235409
  initDefaultI18N();
235409
235410
 
@@ -249464,6 +249465,7 @@ class BaseItem extends Mbr {
249464
249465
  shouldRenderOutsideViewRect = true;
249465
249466
  shouldUseRelativeAlignment = true;
249466
249467
  enableResize = true;
249468
+ onlyProportionalResize = false;
249467
249469
  itemType = "";
249468
249470
  children = [];
249469
249471
  constructor(board, id2 = "", defaultItemData, isGroupItem) {
@@ -275369,7 +275371,8 @@ var defaultCardData = {
275369
275371
  itemType: "Card",
275370
275372
  isOpen: false,
275371
275373
  faceUrl: "",
275372
- backsideUrl: ""
275374
+ backsideUrl: "",
275375
+ dimensions: { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height }
275373
275376
  };
275374
275377
 
275375
275378
  class Card extends BaseItem {
@@ -275382,9 +275385,13 @@ class Card extends BaseItem {
275382
275385
  backside = null;
275383
275386
  imageToRender = null;
275384
275387
  shouldUseCustomRender = false;
275385
- enableResize = false;
275386
- constructor(board, id2 = "", urls) {
275388
+ onlyProportionalResize = true;
275389
+ dimensions = { width: conf.CARD_DIMENSIONS.width, height: conf.CARD_DIMENSIONS.height };
275390
+ constructor(board, id2 = "", urls, dimensions) {
275387
275391
  super(board, id2, defaultCardData);
275392
+ if (dimensions) {
275393
+ this.dimensions = dimensions;
275394
+ }
275388
275395
  if (urls) {
275389
275396
  this.faceUrl = urls.faceUrl;
275390
275397
  this.backsideUrl = urls.backsideUrl;
@@ -275402,6 +275409,9 @@ class Card extends BaseItem {
275402
275409
  });
275403
275410
  this.updateMbr();
275404
275411
  }
275412
+ getDimensions() {
275413
+ return this.dimensions;
275414
+ }
275405
275415
  createImages() {
275406
275416
  this.face = conf.documentFactory.createElement("img");
275407
275417
  this.backside = conf.documentFactory.createElement("img");
@@ -275457,8 +275467,8 @@ class Card extends BaseItem {
275457
275467
  const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
275458
275468
  div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
275459
275469
  div.id = this.getId();
275460
- div.style.width = `${conf.CARD_DIMENSIONS.width}px`;
275461
- div.style.height = `${conf.CARD_DIMENSIONS.height}px`;
275470
+ div.style.width = `${this.dimensions.width}px`;
275471
+ div.style.height = `${this.dimensions.height}px`;
275462
275472
  div.style.transformOrigin = "top left";
275463
275473
  div.style.transform = transform;
275464
275474
  div.style.position = "absolute";
@@ -275469,8 +275479,8 @@ class Card extends BaseItem {
275469
275479
  updateMbr() {
275470
275480
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
275471
275481
  const rotation = this.transformation.getRotation();
275472
- const height3 = conf.CARD_DIMENSIONS.height * scaleY;
275473
- const width2 = conf.CARD_DIMENSIONS.width * scaleX;
275482
+ const height3 = this.dimensions.height * scaleY;
275483
+ const width2 = this.dimensions.width * scaleX;
275474
275484
  if (rotation % 180 === 0) {
275475
275485
  this.left = translateX;
275476
275486
  this.top = translateY;
@@ -275610,7 +275620,9 @@ class Deck extends BaseItem {
275610
275620
  childIds.forEach((childId) => {
275611
275621
  const foundItem = this.board.items.getById(childId);
275612
275622
  if (this.parent !== childId && this.getId() !== childId) {
275613
- const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular());
275623
+ const firstCard = this.getFirstCard();
275624
+ const firstCardDimensions = firstCard?.getDimensions();
275625
+ const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
275614
275626
  if (canAddItem) {
275615
275627
  this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
275616
275628
  foundItem.transformation.apply({
@@ -275620,6 +275632,19 @@ class Deck extends BaseItem {
275620
275632
  x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
275621
275633
  y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
275622
275634
  });
275635
+ if (firstCard) {
275636
+ const { scaleX, scaleY } = foundItem.transformation.matrix;
275637
+ const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.matrix;
275638
+ if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
275639
+ foundItem.transformation.apply({
275640
+ class: "Transformation",
275641
+ method: "scaleTo",
275642
+ item: [this.id],
275643
+ x: targetScaleX,
275644
+ y: targetScaleY
275645
+ });
275646
+ }
275647
+ }
275623
275648
  this.board.selection.remove(foundItem);
275624
275649
  this.board.items.index.remove(foundItem);
275625
275650
  foundItem.parent = this.getId();
@@ -275784,6 +275809,9 @@ class Deck extends BaseItem {
275784
275809
  this.isCacheDirty = false;
275785
275810
  this.updateMbr();
275786
275811
  }
275812
+ getFirstCard() {
275813
+ return this.index?.list()[0];
275814
+ }
275787
275815
  }
275788
275816
  registerItem({
275789
275817
  item: Deck,
@@ -279199,7 +279227,7 @@ function transformItems({
279199
279227
  setSnapCursorPos
279200
279228
  }) {
279201
279229
  const items = selection.items.list();
279202
- const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio");
279230
+ const includesProportionalItem = items.some((item) => item.itemType === "Sticker" || item.itemType === "RichText" || item.itemType === "AINode" || item.itemType === "Video" || item.itemType === "Audio" || item instanceof BaseItem && item.onlyProportionalResize);
279203
279231
  if (includesProportionalItem && (isWidth || isHeight)) {
279204
279232
  return null;
279205
279233
  }
@@ -358202,7 +358230,7 @@ var ImgAuthClipboardModal = () => {
358202
358230
  const { app } = useAppContext();
358203
358231
  const onAuthClick = () => {
358204
358232
  closeModal2();
358205
- const clientId = import.meta.env.MIRO_CLIENT_ID;
358233
+ const clientId = globalThis.__ENV__?.MIRO_CLIENT_ID ?? "";
358206
358234
  const redirectRoute = "/boards/blank?clipboard=true";
358207
358235
  const redirectUrl = window.location.origin + redirectRoute;
358208
358236
  window.location.href = "https://miro.com/oauth/authorize?response_type=code&client_id=" + clientId + "&redirect_uri=" + redirectUrl;
@@ -375574,8 +375602,8 @@ function ImportMiro() {
375574
375602
  const { openModal: openModal2 } = useUiModalContext();
375575
375603
  const fetchToken = async () => {
375576
375604
  try {
375577
- const clientId = import.meta.env.MIRO_CLIENT_ID;
375578
- const clientSecret = import.meta.env.MIRO_CLIENT_SECRET;
375605
+ const clientId = globalThis.__ENV__?.MIRO_CLIENT_ID ?? "";
375606
+ const clientSecret = globalThis.__ENV__?.MIRO_CLIENT_SECRET ?? "";
375579
375607
  const redirectRoute = "/boards/blank?clipboard=true";
375580
375608
  const redirectUrl = window.location.origin + redirectRoute;
375581
375609
  const response = await fetch(getApiUrl("/miro/token" + "?grant_type=authorization_code&client_id=" + clientId + "&client_secret=" + clientSecret + "&code=" + authCode + "&redirect_uri=" + redirectUrl), {
@@ -435448,9 +435476,9 @@ var TolgeeProviderProvider = import_react309.memo(({ children }) => {
435448
435476
  language: "en",
435449
435477
  availableLanguages: ["en", "ru"],
435450
435478
  observerType: "text",
435451
- apiUrl: import.meta.env.TOLGEE_API_URL,
435452
- apiKey: import.meta.env.TOLGEE_API_KEY,
435453
- projectId: import.meta.env.TOLGEE_PROJECT_ID,
435479
+ apiUrl: globalThis.__ENV__?.TOLGEE_API_URL ?? "",
435480
+ apiKey: globalThis.__ENV__?.TOLGEE_API_KEY ?? "",
435481
+ projectId: globalThis.__ENV__?.TOLGEE_PROJECT_ID ?? "",
435454
435482
  staticData: {}
435455
435483
  }), []);
435456
435484
  return /* @__PURE__ */ import_react309.default.createElement(TolgeeProvider, {
@@ -435463,7 +435491,7 @@ function getTolgeeApiUrl(path5) {
435463
435491
  if (!path5) {
435464
435492
  path5 = "";
435465
435493
  }
435466
- return `${import.meta.env.TOLGEE_API_URL}/v2/projects/${import.meta.env.TOLGEE_PROJECT_ID}${path5}`;
435494
+ return `${globalThis.__ENV__?.TOLGEE_API_URL ?? ""}/v2/projects/${globalThis.__ENV__?.TOLGEE_PROJECT_ID ?? ""}${path5}`;
435467
435495
  }
435468
435496
 
435469
435497
  // src/features/Templates/lib.ts
@@ -435641,7 +435669,7 @@ var CreateTemplate = () => {
435641
435669
  method: "get",
435642
435670
  headers: {
435643
435671
  Accept: "application/json",
435644
- "X-API-Key": import.meta.env.TOLGEE_API_KEY
435672
+ "X-API-Key": globalThis.__ENV__?.TOLGEE_API_KEY ?? ""
435645
435673
  }
435646
435674
  });
435647
435675
  return (await response.json())._embedded.languages;
@@ -435656,7 +435684,7 @@ var CreateTemplate = () => {
435656
435684
  headers: {
435657
435685
  "Content-Type": "application/json",
435658
435686
  Accept: "application/json",
435659
- "X-API-Key": import.meta.env.TOLGEE_API_KEY
435687
+ "X-API-Key": globalThis.__ENV__?.TOLGEE_API_KEY ?? ""
435660
435688
  },
435661
435689
  body: data
435662
435690
  }).then((response) => response.json()).catch((error3) => console.log(error3));
@@ -439059,6 +439087,18 @@ var import_react353 = __toESM(require_react(), 1);
439059
439087
  // src/features/GameItems/CreateCardsModal.tsx
439060
439088
  var import_react352 = __toESM(require_react(), 1);
439061
439089
  var CREATE_CARDS_MODAL = Symbol("createCardsModal");
439090
+ var getImageDimensions = (file) => {
439091
+ return new Promise((resolve2) => {
439092
+ const img2 = new Image;
439093
+ img2.src = URL.createObjectURL(file);
439094
+ img2.onload = () => {
439095
+ resolve2({
439096
+ width: img2.naturalWidth,
439097
+ height: img2.naturalHeight
439098
+ });
439099
+ };
439100
+ });
439101
+ };
439062
439102
  function CreateCardsModal() {
439063
439103
  const { t: t11 } = useTranslation();
439064
439104
  const { closeModal: closeModal2 } = useUiModalContext();
@@ -439073,13 +439113,16 @@ function CreateCardsModal() {
439073
439113
  const cardsInputRef = import_react352.default.useRef(null);
439074
439114
  const handleCoverClick = () => coverInputRef.current?.click();
439075
439115
  const handleCardsClick = () => cardsInputRef.current?.click();
439076
- const createDeck2 = (backsideUrl, faceUrls) => {
439116
+ const createDeck2 = (backsideUrl, faceUrls, dimensions) => {
439077
439117
  const cards2 = [];
439118
+ const { width: width3, height: height4 } = dimensions;
439119
+ const { width: defaultWidth, height: defaultHeight } = conf.DEFAULT_GAME_ITEM_DIMENSIONS;
439120
+ const normalizedDimensions = width3 > height4 ? { width: defaultWidth * width3 / height4, height: defaultHeight } : { width: defaultWidth, height: defaultHeight * height4 / width3 };
439078
439121
  faceUrls.forEach((faceUrl, index4) => {
439079
439122
  const card = new Card(board, index4 + faceUrl, {
439080
439123
  backsideUrl,
439081
439124
  faceUrl
439082
- });
439125
+ }, normalizedDimensions);
439083
439126
  cards2.push(card);
439084
439127
  });
439085
439128
  const itemsMap = {};
@@ -439114,8 +439157,9 @@ function CreateCardsModal() {
439114
439157
  setLoading(true);
439115
439158
  try {
439116
439159
  if (cards.length > 0 && cover) {
439160
+ const dimensions = await getImageDimensions(cover);
439117
439161
  const urls = await uploadImages([cover, ...cards], board.getBoardId(), account.accessToken);
439118
- createDeck2(urls[0], urls.slice(1));
439162
+ createDeck2(urls[0], urls.slice(1), dimensions);
439119
439163
  }
439120
439164
  closeModal2();
439121
439165
  } catch (err2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-ui-temp",
3
- "version": "0.1.107",
3
+ "version": "0.1.109",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "type": "module",
@@ -63,7 +63,7 @@
63
63
  "i18next-browser-languagedetector": "^8.2.0",
64
64
  "js-cookie": "^3.0.5",
65
65
  "jwt-decode": "^4.0.0",
66
- "microboard-temp": "^0.5.38",
66
+ "microboard-temp": "^0.5.40",
67
67
  "nanoid": "^5.1.5",
68
68
  "prop-types": "^15.8.1",
69
69
  "react-hot-toast": "2.4.1",