@guideai/react-native 0.6.0 → 0.7.0

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.
@@ -3537,8 +3537,9 @@ function reset() {
3537
3537
  const GuideAI = { configure, identify, setUserProfile, setToolContext, setFollowUps, isConfigured, reset };
3538
3538
  const LIMITS = {
3539
3539
  steps: 12,
3540
- itemsPerStep: 8,
3541
- items: 60,
3540
+ // A label round a photo arrives as two items: its words and its arrow.
3541
+ itemsPerStep: 16,
3542
+ items: 96,
3542
3543
  say: 300,
3543
3544
  text: 60,
3544
3545
  art: 80,
@@ -3581,6 +3582,7 @@ const ID = /^[A-Za-z0-9_-]{1,24}$/;
3581
3582
  const SIZES = ["s", "m", "l"];
3582
3583
  const TONES = ["ink", "blue", "red", "green"];
3583
3584
  const PATH_DATA = /^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]*$/;
3585
+ const PHOTO_URL = /^https:\/\/res\.cloudinary\.com\/[A-Za-z0-9_-]+\/image\/upload\/[^\s"'<>\\]+$/;
3584
3586
  const flat = (value, max) => typeof value === "string" ? value.replace(/\s+/g, " ").trim().slice(0, max) : "";
3585
3587
  const clamp = (n, top = BOARD_H) => Math.round(Math.min(top, Math.max(0, n)) * 10) / 10;
3586
3588
  function num(value) {
@@ -3612,7 +3614,7 @@ function item(raw) {
3612
3614
  var _a;
3613
3615
  if (!raw || typeof raw !== "object") return null;
3614
3616
  const r = raw;
3615
- const kinds = ["art", "text", "ink", "rows", "mark", "erase", "point"].filter((k) => r[k] !== void 0 && r[k] !== null && r[k] !== "");
3617
+ const kinds = ["art", "photo", "text", "ink", "rows", "mark", "erase", "point"].filter((k) => r[k] !== void 0 && r[k] !== null && r[k] !== "");
3616
3618
  if (kinds.length !== 1) return null;
3617
3619
  switch (kinds[0]) {
3618
3620
  case "art": {
@@ -3620,6 +3622,11 @@ function item(raw) {
3620
3622
  const art = flat(r.art, LIMITS.art);
3621
3623
  return at && art ? { kind: "art", id: id(r.id), art, at, tone: tone(r.tone) } : null;
3622
3624
  }
3625
+ case "photo": {
3626
+ const at = box(r.at);
3627
+ const photo2 = flat(r.photo, LIMITS.art);
3628
+ return at && photo2 ? { kind: "photo", id: id(r.id), photo: photo2, at } : null;
3629
+ }
3623
3630
  case "text": {
3624
3631
  const at = point(Array.isArray(r.at) ? r.at.slice(0, 2) : null);
3625
3632
  const text = flat(r.text, LIMITS.text);
@@ -3683,6 +3690,15 @@ function artInk(raw) {
3683
3690
  const transform = typeof r.transform === "string" && /^[a-z()\d.,\s-]*$/i.test(r.transform) ? r.transform : "";
3684
3691
  return contours.length ? { view_box: viewBox, transform, contours } : null;
3685
3692
  }
3693
+ function photo(raw) {
3694
+ if (!raw || typeof raw !== "object") return null;
3695
+ const r = raw;
3696
+ const w = num(r.w);
3697
+ const h = num(r.h);
3698
+ if (typeof r.url !== "string" || r.url.length > 600 || !PHOTO_URL.test(r.url) || !w || !h || w <= 0 || h <= 0) return null;
3699
+ const credit = flat(r.credit, 60);
3700
+ return credit ? { url: r.url, w, h, credit } : { url: r.url, w, h };
3701
+ }
3686
3702
  function validateScene(raw) {
3687
3703
  if (!raw || typeof raw !== "object") throw new SceneError("A scene is an object.");
3688
3704
  const r = raw;
@@ -3724,12 +3740,20 @@ function validateScene(raw) {
3724
3740
  if (ink) art[name.slice(0, LIMITS.art)] = ink;
3725
3741
  }
3726
3742
  }
3743
+ const photos = {};
3744
+ if (r.photos && typeof r.photos === "object") {
3745
+ for (const [name, value] of Object.entries(r.photos)) {
3746
+ const pic = photo(value);
3747
+ if (pic) photos[name.slice(0, LIMITS.art)] = pic;
3748
+ }
3749
+ }
3727
3750
  return {
3728
3751
  v: 3,
3729
3752
  title: flat(r.title, LIMITS.title) || "Explanation",
3730
3753
  sample: r.sample === true,
3731
3754
  steps,
3732
- art
3755
+ art,
3756
+ photos
3733
3757
  };
3734
3758
  }
3735
3759
  const BLOCKS_PATH = "/api/v1/chat/blocks";
@@ -3787,7 +3811,8 @@ class WhiteboardStore {
3787
3811
  try {
3788
3812
  const raw = await this.api().post(
3789
3813
  WHITEBOARD_PATH,
3790
- { question: q, answer: a || void 0, language: this.language() },
3814
+ // pictures: this board shows real photos with labelled parts.
3815
+ { question: q, answer: a || void 0, language: this.language(), pictures: true },
3791
3816
  6e4
3792
3817
  );
3793
3818
  if (token !== this.request) return false;
@@ -4214,4 +4239,4 @@ exports.useGuideAIRuntime = useGuideAIRuntime;
4214
4239
  exports.useOnboarding = useOnboarding;
4215
4240
  exports.useScreenRegistry = useScreenRegistry;
4216
4241
  exports.useWhiteboard = useWhiteboard;
4217
- //# sourceMappingURL=useConversations-C9ivx2l-.cjs.map
4242
+ //# sourceMappingURL=useConversations-CTbQBTz-.cjs.map