@braze/sanity-plugin-ai-translation 0.2.83 → 0.2.84

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.
package/dist/index.js CHANGED
@@ -416,9 +416,7 @@ const isLoggingEnabled = () => process.env.NEXT_PUBLIC_SANITY_STUDIO_AI_TRANSLAT
416
416
  const refIdSet = new Set(refIds);
417
417
  for (const metadataDoc of refMetadataDocs) {
418
418
  if (!metadataDoc.translations?.length) continue;
419
- const matchingRefId = metadataDoc.translations.find(
420
- (t) => t.value?._ref && refIdSet.has(t.value._ref)
421
- )?.value._ref;
419
+ const matchingRefId = metadataDoc.translations.find((t) => t.value?._ref && refIdSet.has(t.value._ref))?.value._ref;
422
420
  if (matchingRefId)
423
421
  for (const lang of selectedTargetLanguages) {
424
422
  const targetId = getExistingTranslationId(metadataDoc, lang);
@@ -3411,14 +3409,14 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
3411
3409
  padding: 2
3412
3410
  }
3413
3411
  );
3414
- }, VALIDATION_TIMEOUT_MS = 2e3, DocumentValidator = ({ documentId, documentType, onResult }) => {
3415
- const publishedId = getPublishedId(documentId), { isValidating, validation } = useValidationStatus(publishedId, documentType), hasReceivedRealResult = useRef(!1), hasSettled = useRef(!1), lastReported = useRef(null), [timedOut, setTimedOut] = useState(!1);
3412
+ }, VALIDATION_TIMEOUT_MS = 1e4, DocumentValidator = ({ documentId, documentType, onResult }) => {
3413
+ const publishedId = getPublishedId(documentId), { isValidating, validation } = useValidationStatus(publishedId, documentType), hasReceivedRealResult = useRef(!1), hasSettled = useRef(!1), lastReported = useRef(null), [timedOut, setTimedOut] = useState(!1), initialValidationRef = useRef(validation);
3416
3414
  return useEffect(() => {
3417
3415
  const timer = setTimeout(() => setTimedOut(!0), VALIDATION_TIMEOUT_MS);
3418
3416
  return () => clearTimeout(timer);
3419
3417
  }, []), useEffect(() => {
3420
3418
  if (hasSettled.current) return;
3421
- (isValidating || validation.length > 0) && (hasReceivedRealResult.current = !0);
3419
+ (isValidating || validation.length > 0 || validation !== initialValidationRef.current) && (hasReceivedRealResult.current = !0);
3422
3420
  const stillWaitingForFirstResult = !hasReceivedRealResult.current && !timedOut, errors = validation.filter((v) => v.level === "error"), computedIsValidating = isValidating || stillWaitingForFirstResult;
3423
3421
  !computedIsValidating && hasReceivedRealResult.current && (hasSettled.current = !0), !(lastReported.current && lastReported.current.isValidating === computedIsValidating && lastReported.current.errorCount === errors.length) && (lastReported.current = { isValidating: computedIsValidating, errorCount: errors.length }, onResult(documentId, {
3424
3422
  isValidating: computedIsValidating,
@@ -3512,7 +3510,14 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
3512
3510
  } finally {
3513
3511
  setIsDraftCheckLoading(!1);
3514
3512
  }
3515
- }, [client, translationMetadata, selectedTargetLanguages, document._id, shouldTranslateReferences, filteredReferences]), runConflictCheck = useCallback(async () => {
3513
+ }, [
3514
+ client,
3515
+ translationMetadata,
3516
+ selectedTargetLanguages,
3517
+ document._id,
3518
+ shouldTranslateReferences,
3519
+ filteredReferences
3520
+ ]), runConflictCheck = useCallback(async () => {
3516
3521
  if (releaseConfig.mode === "new") {
3517
3522
  setIsCheckingConflicts(!1), setConflictContext(null);
3518
3523
  return;
@@ -3776,16 +3781,7 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
3776
3781
  /* @__PURE__ */ jsxs(Flex, { justify: "space-between", gap: 2, children: [
3777
3782
  /* @__PURE__ */ jsx(Button, { mode: "ghost", text: "Back", onClick: handleBack }),
3778
3783
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
3779
- /* @__PURE__ */ jsx(
3780
- Button,
3781
- {
3782
- mode: "ghost",
3783
- text: "Rescan",
3784
- icon: SyncIcon,
3785
- onClick: handleRescan,
3786
- disabled: isLoading
3787
- }
3788
- ),
3784
+ /* @__PURE__ */ jsx(Button, { mode: "ghost", text: "Rescan", icon: SyncIcon, onClick: handleRescan, disabled: isLoading }),
3789
3785
  /* @__PURE__ */ jsx(
3790
3786
  Button,
3791
3787
  {