@yoamigo.com/core 0.1.7 → 0.1.9

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 +2723 -2645
  2. package/dist/lib.js +74 -0
  3. package/package.json +7 -14
package/dist/lib.js CHANGED
@@ -157,6 +157,11 @@ var BuilderSelectionManager = class {
157
157
  case "CLEAR_SELECTIONS":
158
158
  this.clearAllSelections();
159
159
  break;
160
+ case "REQUEST_REGION_SCREENSHOT":
161
+ if (data.region) {
162
+ this.captureRegionScreenshot(data.region);
163
+ }
164
+ break;
160
165
  }
161
166
  });
162
167
  }
@@ -237,6 +242,9 @@ var BuilderSelectionManager = class {
237
242
  this.sendToParent({ type: "SHIFT_KEY_PRESSED" });
238
243
  }
239
244
  }
245
+ if (e.key === "Escape") {
246
+ this.sendToParent({ type: "ESCAPE_KEY_PRESSED" });
247
+ }
240
248
  };
241
249
  /**
242
250
  * Check if element matches any selectable selector
@@ -523,6 +531,72 @@ var BuilderSelectionManager = class {
523
531
  container.style.height = `${rect.height}px`;
524
532
  });
525
533
  };
534
+ /**
535
+ * Capture a region of the page as a screenshot
536
+ * Uses html2canvas to render the page and then crops to the specified region
537
+ */
538
+ async captureRegionScreenshot(region) {
539
+ try {
540
+ console.log("[BuilderSelection] Capturing region screenshot:", region);
541
+ const html2canvas = (await import("html2canvas")).default;
542
+ const overlays = document.querySelectorAll(".builder-selection-container, #builder-hover-overlay");
543
+ overlays.forEach((el) => {
544
+ ;
545
+ el.style.display = "none";
546
+ });
547
+ const canvas = await html2canvas(document.body, {
548
+ scale: window.devicePixelRatio || 1,
549
+ logging: false,
550
+ useCORS: true,
551
+ allowTaint: true,
552
+ backgroundColor: null
553
+ // Preserve transparency if any
554
+ });
555
+ overlays.forEach((el) => {
556
+ ;
557
+ el.style.display = "";
558
+ });
559
+ const scale = window.devicePixelRatio || 1;
560
+ const scaledRegion = {
561
+ x: Math.round(region.x * scale),
562
+ y: Math.round(region.y * scale),
563
+ width: Math.round(region.width * scale),
564
+ height: Math.round(region.height * scale)
565
+ };
566
+ const croppedCanvas = document.createElement("canvas");
567
+ croppedCanvas.width = scaledRegion.width;
568
+ croppedCanvas.height = scaledRegion.height;
569
+ const ctx = croppedCanvas.getContext("2d");
570
+ if (!ctx) {
571
+ throw new Error("Failed to get canvas context");
572
+ }
573
+ ctx.drawImage(
574
+ canvas,
575
+ scaledRegion.x,
576
+ scaledRegion.y,
577
+ scaledRegion.width,
578
+ scaledRegion.height,
579
+ 0,
580
+ 0,
581
+ scaledRegion.width,
582
+ scaledRegion.height
583
+ );
584
+ const dataUrl = croppedCanvas.toDataURL("image/png", 0.9);
585
+ console.log("[BuilderSelection] Region screenshot captured, size:", dataUrl.length);
586
+ this.sendToParent({
587
+ type: "REGION_SCREENSHOT_READY",
588
+ dataUrl,
589
+ region
590
+ });
591
+ } catch (error) {
592
+ console.error("[BuilderSelection] Region screenshot failed:", error);
593
+ this.sendToParent({
594
+ type: "REGION_SCREENSHOT_ERROR",
595
+ error: error instanceof Error ? error.message : "Screenshot capture failed",
596
+ region
597
+ });
598
+ }
599
+ }
526
600
  renderSelectionIndicator(element, selectionId, color) {
527
601
  const rect = element.getBoundingClientRect();
528
602
  const container = document.createElement("div");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoamigo.com/core",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Core components, router, and utilities for YoAmigo templates",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -43,15 +43,7 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "repository": {
47
- "type": "git",
48
- "url": "https://github.com/yoamigo/sdk.git",
49
- "directory": "packages/yoamigo-core"
50
- },
51
46
  "homepage": "https://yoamigo.com/developers",
52
- "bugs": {
53
- "url": "https://github.com/yoamigo/sdk/issues"
54
- },
55
47
  "keywords": [
56
48
  "yoamigo",
57
49
  "vite",
@@ -71,6 +63,7 @@
71
63
  },
72
64
  "dependencies": {
73
65
  "clsx": "^2.1.1",
66
+ "html2canvas": "^1.4.1",
74
67
  "preact": "^10.27.2",
75
68
  "wouter": "^3.8.0"
76
69
  },
@@ -95,18 +88,18 @@
95
88
  "vite": "^7.2.4"
96
89
  },
97
90
  "peerDependencies": {
98
- "@vitejs/plugin-react": "^5.0.0",
99
91
  "@preact/preset-vite": "^2.0.0",
100
- "react": "^18.0.0 || ^19.0.0",
101
- "react-dom": "^18.0.0 || ^19.0.0",
102
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
103
92
  "@tiptap/core": "^3.0.0",
104
93
  "@tiptap/extension-link": "^3.0.0",
105
94
  "@tiptap/extension-text-style": "^3.0.0",
106
95
  "@tiptap/pm": "^3.0.0",
107
96
  "@tiptap/react": "^3.0.0",
108
97
  "@tiptap/starter-kit": "^3.0.0",
109
- "dompurify": "^3.0.0"
98
+ "@vitejs/plugin-react": "^5.0.0",
99
+ "dompurify": "^3.0.0",
100
+ "react": "^18.0.0 || ^19.0.0",
101
+ "react-dom": "^18.0.0 || ^19.0.0",
102
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
110
103
  },
111
104
  "peerDependenciesMeta": {
112
105
  "react": {