@procore/ai-translations 0.6.1 → 0.6.2

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/README.md CHANGED
@@ -144,6 +144,7 @@ type ToolConfig = {
144
144
  - Frontend strategy depends on Chrome-family AI support; behavior differs by browser support.
145
145
  - Backend/config endpoints are resolved from `window.location.origin` under `/rest/`.
146
146
  - Translation cache uses IndexedDB; some restricted browser environments may limit persistence.
147
+ - For error handling behavior and failure modes, see [`docs/error-handling.md`](./docs/error-handling.md).
147
148
 
148
149
  ## Development
149
150
 
@@ -209,6 +209,8 @@ interface UseAIAnalyticsReturn {
209
209
  */
210
210
  declare function useAIAnalytics(): UseAIAnalyticsReturn;
211
211
 
212
+ declare function isSupportedBrowser(): boolean;
213
+
212
214
  interface AITranslationProviderProps {
213
215
  children: ReactNode;
214
216
  locale: string;
@@ -279,4 +281,4 @@ declare global {
279
281
  var _BACKEND_AI_TRANSLATION_IN_PROGRESS_: boolean;
280
282
  }
281
283
 
282
- export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, useAIAnalytics, useAITranslation, useConfig };
284
+ export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, isSupportedBrowser, useAIAnalytics, useAITranslation, useConfig };
@@ -209,6 +209,8 @@ interface UseAIAnalyticsReturn {
209
209
  */
210
210
  declare function useAIAnalytics(): UseAIAnalyticsReturn;
211
211
 
212
+ declare function isSupportedBrowser(): boolean;
213
+
212
214
  interface AITranslationProviderProps {
213
215
  children: ReactNode;
214
216
  locale: string;
@@ -279,4 +281,4 @@ declare global {
279
281
  var _BACKEND_AI_TRANSLATION_IN_PROGRESS_: boolean;
280
282
  }
281
283
 
282
- export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, useAIAnalytics, useAITranslation, useConfig };
284
+ export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, isSupportedBrowser, useAIAnalytics, useAITranslation, useConfig };
@@ -31,6 +31,7 @@ __export(index_exports, {
31
31
  buildEventKey: () => buildEventKey,
32
32
  buildObject: () => buildObject,
33
33
  getAITranslationLDId: () => getAITranslationLDId,
34
+ isSupportedBrowser: () => isSupportedBrowser,
34
35
  useAIAnalytics: () => useAIAnalytics,
35
36
  useAITranslation: () => useAITranslation,
36
37
  useConfig: () => useConfig
@@ -1455,6 +1456,7 @@ var aitFunction = async (text, translationRegistry, config2, tool) => {
1455
1456
  };
1456
1457
 
1457
1458
  // src/utils/browser.ts
1459
+ var supportedBrowsers = ["chrome", "arc", "opera"];
1458
1460
  function detectBrowser() {
1459
1461
  const ua = navigator.userAgent;
1460
1462
  if (ua.includes("Arc/")) return "arc";
@@ -1465,6 +1467,10 @@ function detectBrowser() {
1465
1467
  if (ua.includes("Chrome/")) return "chrome";
1466
1468
  return "unknown";
1467
1469
  }
1470
+ function isSupportedBrowser() {
1471
+ const browser = detectBrowser();
1472
+ return supportedBrowsers.includes(browser);
1473
+ }
1468
1474
 
1469
1475
  // src/Provider.tsx
1470
1476
  var import_react_query2 = require("@tanstack/react-query");
@@ -1742,7 +1748,7 @@ var TranslatedIcon = ({
1742
1748
  "path",
1743
1749
  {
1744
1750
  fill: color,
1745
- d: "M11.99 2C6.47 2 2 6.48 2 12C2 17.52 6.47 22 11.99 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 11.99 2ZM18.92 8H15.97C15.65 6.75 15.19 5.55 14.59 4.44C16.43 5.07 17.96 6.35 18.92 8ZM12 4.04C12.83 5.24 13.48 6.57 13.91 8H10.09C10.52 6.57 11.17 5.24 12 4.04ZM4.26 14C4.1 13.36 4 12.69 4 12C4 11.31 4.1 10.64 4.26 10H7.64C7.56 10.66 7.5 11.32 7.5 12C7.5 12.68 7.56 13.34 7.64 14H4.26ZM5.08 16H8.03C8.35 17.25 8.81 18.45 9.41 19.56C7.57 18.93 6.04 17.66 5.08 16ZM8.03 8H5.08C6.04 6.34 7.57 5.07 9.41 4.44C8.81 5.55 8.35 6.75 8.03 8ZM12 19.96C11.17 18.76 10.52 17.43 10.09 16H13.91C13.48 17.43 12.83 18.76 12 19.96ZM14.34 14H9.66C9.57 13.34 9.5 12.68 9.5 12C9.5 11.32 9.57 10.65 9.66 10H14.34C14.43 10.65 14.5 11.32 14.5 12C14.5 12.68 14.43 13.34 14.34 14ZM14.59 19.56C15.19 18.45 15.65 17.25 15.97 16H18.92C17.96 17.65 16.43 18.93 14.59 19.56ZM16.36 14C16.44 13.34 16.5 12.68 16.5 12C16.5 11.32 16.44 10.66 16.36 10H19.74C19.9 10.64 20 11.31 20 12C20 12.69 19.9 13.36 19.74 14H16.36Z"
1751
+ d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 19.93C7.05 19.44 4 16.08 4 12C4 11.38 4.08 10.79 4.21 10.21L9 15V16C9 17.1 9.9 18 11 18V19.93ZM17.9 17.39C17.64 16.58 16.9 16 16 16H15V13C15 12.45 14.55 12 14 12H8V10H10C10.55 10 11 9.55 11 9V7H13C14.1 7 15 6.1 15 5V4.59C17.93 5.78 20 8.65 20 12C20 14.08 19.2 15.97 17.9 17.39Z"
1746
1752
  }
1747
1753
  )
1748
1754
  }
@@ -1848,6 +1854,7 @@ var getAITranslationLDId = (domain) => {
1848
1854
  buildEventKey,
1849
1855
  buildObject,
1850
1856
  getAITranslationLDId,
1857
+ isSupportedBrowser,
1851
1858
  useAIAnalytics,
1852
1859
  useAITranslation,
1853
1860
  useConfig
@@ -1426,6 +1426,7 @@ var aitFunction = async (text, translationRegistry, config2, tool) => {
1426
1426
  };
1427
1427
 
1428
1428
  // src/utils/browser.ts
1429
+ var supportedBrowsers = ["chrome", "arc", "opera"];
1429
1430
  function detectBrowser() {
1430
1431
  const ua = navigator.userAgent;
1431
1432
  if (ua.includes("Arc/")) return "arc";
@@ -1436,6 +1437,10 @@ function detectBrowser() {
1436
1437
  if (ua.includes("Chrome/")) return "chrome";
1437
1438
  return "unknown";
1438
1439
  }
1440
+ function isSupportedBrowser() {
1441
+ const browser = detectBrowser();
1442
+ return supportedBrowsers.includes(browser);
1443
+ }
1439
1444
 
1440
1445
  // src/Provider.tsx
1441
1446
  import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
@@ -1719,7 +1724,7 @@ var TranslatedIcon = ({
1719
1724
  "path",
1720
1725
  {
1721
1726
  fill: color,
1722
- d: "M11.99 2C6.47 2 2 6.48 2 12C2 17.52 6.47 22 11.99 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 11.99 2ZM18.92 8H15.97C15.65 6.75 15.19 5.55 14.59 4.44C16.43 5.07 17.96 6.35 18.92 8ZM12 4.04C12.83 5.24 13.48 6.57 13.91 8H10.09C10.52 6.57 11.17 5.24 12 4.04ZM4.26 14C4.1 13.36 4 12.69 4 12C4 11.31 4.1 10.64 4.26 10H7.64C7.56 10.66 7.5 11.32 7.5 12C7.5 12.68 7.56 13.34 7.64 14H4.26ZM5.08 16H8.03C8.35 17.25 8.81 18.45 9.41 19.56C7.57 18.93 6.04 17.66 5.08 16ZM8.03 8H5.08C6.04 6.34 7.57 5.07 9.41 4.44C8.81 5.55 8.35 6.75 8.03 8ZM12 19.96C11.17 18.76 10.52 17.43 10.09 16H13.91C13.48 17.43 12.83 18.76 12 19.96ZM14.34 14H9.66C9.57 13.34 9.5 12.68 9.5 12C9.5 11.32 9.57 10.65 9.66 10H14.34C14.43 10.65 14.5 11.32 14.5 12C14.5 12.68 14.43 13.34 14.34 14ZM14.59 19.56C15.19 18.45 15.65 17.25 15.97 16H18.92C17.96 17.65 16.43 18.93 14.59 19.56ZM16.36 14C16.44 13.34 16.5 12.68 16.5 12C16.5 11.32 16.44 10.66 16.36 10H19.74C19.9 10.64 20 11.31 20 12C20 12.69 19.9 13.36 19.74 14H16.36Z"
1727
+ d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 19.93C7.05 19.44 4 16.08 4 12C4 11.38 4.08 10.79 4.21 10.21L9 15V16C9 17.1 9.9 18 11 18V19.93ZM17.9 17.39C17.64 16.58 16.9 16 16 16H15V13C15 12.45 14.55 12 14 12H8V10H10C10.55 10 11 9.55 11 9V7H13C14.1 7 15 6.1 15 5V4.59C17.93 5.78 20 8.65 20 12C20 14.08 19.2 15.97 17.9 17.39Z"
1723
1728
  }
1724
1729
  )
1725
1730
  }
@@ -1824,6 +1829,7 @@ export {
1824
1829
  buildEventKey,
1825
1830
  buildObject,
1826
1831
  getAITranslationLDId,
1832
+ isSupportedBrowser,
1827
1833
  useAIAnalytics,
1828
1834
  useAITranslation,
1829
1835
  useConfig
@@ -209,6 +209,8 @@ interface UseAIAnalyticsReturn {
209
209
  */
210
210
  declare function useAIAnalytics(): UseAIAnalyticsReturn;
211
211
 
212
+ declare function isSupportedBrowser(): boolean;
213
+
212
214
  interface AITranslationProviderProps {
213
215
  children: ReactNode;
214
216
  locale: string;
@@ -279,4 +281,4 @@ declare global {
279
281
  var _BACKEND_AI_TRANSLATION_IN_PROGRESS_: boolean;
280
282
  }
281
283
 
282
- export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, useAIAnalytics, useAITranslation, useConfig };
284
+ export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, isSupportedBrowser, useAIAnalytics, useAITranslation, useConfig };
@@ -209,6 +209,8 @@ interface UseAIAnalyticsReturn {
209
209
  */
210
210
  declare function useAIAnalytics(): UseAIAnalyticsReturn;
211
211
 
212
+ declare function isSupportedBrowser(): boolean;
213
+
212
214
  interface AITranslationProviderProps {
213
215
  children: ReactNode;
214
216
  locale: string;
@@ -279,4 +281,4 @@ declare global {
279
281
  var _BACKEND_AI_TRANSLATION_IN_PROGRESS_: boolean;
280
282
  }
281
283
 
282
- export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, useAIAnalytics, useAITranslation, useConfig };
284
+ export { ACTION, type AIAnalyticsEventProperties, type AIAnalyticsTracker, AITranslateText, type AITranslateTextProps, AITranslationProvider, AI_TRANSLATION_FEATURE_FLAG_KEY, type Action, type AnalyticEvent, BUTTON_TYPE, type BuildAnalyticEventParams, type ButtonType, type EventKeyParts, type Scope, type TranslatedIconProps, type UseAIAnalyticsReturn, type UseConfigOptions, buildAnalyticEvent, buildEventKey, buildObject, getAITranslationLDId, isSupportedBrowser, useAIAnalytics, useAITranslation, useConfig };
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  buildEventKey: () => buildEventKey,
30
30
  buildObject: () => buildObject,
31
31
  getAITranslationLDId: () => getAITranslationLDId,
32
+ isSupportedBrowser: () => isSupportedBrowser,
32
33
  useAIAnalytics: () => useAIAnalytics,
33
34
  useAITranslation: () => useAITranslation,
34
35
  useConfig: () => useConfig
@@ -1432,6 +1433,7 @@ var aitFunction = async (text, translationRegistry, config2, tool) => {
1432
1433
  };
1433
1434
 
1434
1435
  // src/utils/browser.ts
1436
+ var supportedBrowsers = ["chrome", "arc", "opera"];
1435
1437
  function detectBrowser() {
1436
1438
  const ua = navigator.userAgent;
1437
1439
  if (ua.includes("Arc/")) return "arc";
@@ -1442,6 +1444,10 @@ function detectBrowser() {
1442
1444
  if (ua.includes("Chrome/")) return "chrome";
1443
1445
  return "unknown";
1444
1446
  }
1447
+ function isSupportedBrowser() {
1448
+ const browser = detectBrowser();
1449
+ return supportedBrowsers.includes(browser);
1450
+ }
1445
1451
 
1446
1452
  // src/Provider.tsx
1447
1453
  var import_react_query2 = require("@tanstack/react-query");
@@ -1719,7 +1725,7 @@ var TranslatedIcon = ({
1719
1725
  "path",
1720
1726
  {
1721
1727
  fill: color,
1722
- d: "M11.99 2C6.47 2 2 6.48 2 12C2 17.52 6.47 22 11.99 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 11.99 2ZM18.92 8H15.97C15.65 6.75 15.19 5.55 14.59 4.44C16.43 5.07 17.96 6.35 18.92 8ZM12 4.04C12.83 5.24 13.48 6.57 13.91 8H10.09C10.52 6.57 11.17 5.24 12 4.04ZM4.26 14C4.1 13.36 4 12.69 4 12C4 11.31 4.1 10.64 4.26 10H7.64C7.56 10.66 7.5 11.32 7.5 12C7.5 12.68 7.56 13.34 7.64 14H4.26ZM5.08 16H8.03C8.35 17.25 8.81 18.45 9.41 19.56C7.57 18.93 6.04 17.66 5.08 16ZM8.03 8H5.08C6.04 6.34 7.57 5.07 9.41 4.44C8.81 5.55 8.35 6.75 8.03 8ZM12 19.96C11.17 18.76 10.52 17.43 10.09 16H13.91C13.48 17.43 12.83 18.76 12 19.96ZM14.34 14H9.66C9.57 13.34 9.5 12.68 9.5 12C9.5 11.32 9.57 10.65 9.66 10H14.34C14.43 10.65 14.5 11.32 14.5 12C14.5 12.68 14.43 13.34 14.34 14ZM14.59 19.56C15.19 18.45 15.65 17.25 15.97 16H18.92C17.96 17.65 16.43 18.93 14.59 19.56ZM16.36 14C16.44 13.34 16.5 12.68 16.5 12C16.5 11.32 16.44 10.66 16.36 10H19.74C19.9 10.64 20 11.31 20 12C20 12.69 19.9 13.36 19.74 14H16.36Z"
1728
+ d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 19.93C7.05 19.44 4 16.08 4 12C4 11.38 4.08 10.79 4.21 10.21L9 15V16C9 17.1 9.9 18 11 18V19.93ZM17.9 17.39C17.64 16.58 16.9 16 16 16H15V13C15 12.45 14.55 12 14 12H8V10H10C10.55 10 11 9.55 11 9V7H13C14.1 7 15 6.1 15 5V4.59C17.93 5.78 20 8.65 20 12C20 14.08 19.2 15.97 17.9 17.39Z"
1723
1729
  }
1724
1730
  )
1725
1731
  }
@@ -1825,6 +1831,7 @@ var getAITranslationLDId = (domain) => {
1825
1831
  buildEventKey,
1826
1832
  buildObject,
1827
1833
  getAITranslationLDId,
1834
+ isSupportedBrowser,
1828
1835
  useAIAnalytics,
1829
1836
  useAITranslation,
1830
1837
  useConfig
@@ -1401,6 +1401,7 @@ var aitFunction = async (text, translationRegistry, config2, tool) => {
1401
1401
  };
1402
1402
 
1403
1403
  // src/utils/browser.ts
1404
+ var supportedBrowsers = ["chrome", "arc", "opera"];
1404
1405
  function detectBrowser() {
1405
1406
  const ua = navigator.userAgent;
1406
1407
  if (ua.includes("Arc/")) return "arc";
@@ -1411,6 +1412,10 @@ function detectBrowser() {
1411
1412
  if (ua.includes("Chrome/")) return "chrome";
1412
1413
  return "unknown";
1413
1414
  }
1415
+ function isSupportedBrowser() {
1416
+ const browser = detectBrowser();
1417
+ return supportedBrowsers.includes(browser);
1418
+ }
1414
1419
 
1415
1420
  // src/Provider.tsx
1416
1421
  import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
@@ -1694,7 +1699,7 @@ var TranslatedIcon = ({
1694
1699
  "path",
1695
1700
  {
1696
1701
  fill: color,
1697
- d: "M11.99 2C6.47 2 2 6.48 2 12C2 17.52 6.47 22 11.99 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 11.99 2ZM18.92 8H15.97C15.65 6.75 15.19 5.55 14.59 4.44C16.43 5.07 17.96 6.35 18.92 8ZM12 4.04C12.83 5.24 13.48 6.57 13.91 8H10.09C10.52 6.57 11.17 5.24 12 4.04ZM4.26 14C4.1 13.36 4 12.69 4 12C4 11.31 4.1 10.64 4.26 10H7.64C7.56 10.66 7.5 11.32 7.5 12C7.5 12.68 7.56 13.34 7.64 14H4.26ZM5.08 16H8.03C8.35 17.25 8.81 18.45 9.41 19.56C7.57 18.93 6.04 17.66 5.08 16ZM8.03 8H5.08C6.04 6.34 7.57 5.07 9.41 4.44C8.81 5.55 8.35 6.75 8.03 8ZM12 19.96C11.17 18.76 10.52 17.43 10.09 16H13.91C13.48 17.43 12.83 18.76 12 19.96ZM14.34 14H9.66C9.57 13.34 9.5 12.68 9.5 12C9.5 11.32 9.57 10.65 9.66 10H14.34C14.43 10.65 14.5 11.32 14.5 12C14.5 12.68 14.43 13.34 14.34 14ZM14.59 19.56C15.19 18.45 15.65 17.25 15.97 16H18.92C17.96 17.65 16.43 18.93 14.59 19.56ZM16.36 14C16.44 13.34 16.5 12.68 16.5 12C16.5 11.32 16.44 10.66 16.36 10H19.74C19.9 10.64 20 11.31 20 12C20 12.69 19.9 13.36 19.74 14H16.36Z"
1702
+ d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 19.93C7.05 19.44 4 16.08 4 12C4 11.38 4.08 10.79 4.21 10.21L9 15V16C9 17.1 9.9 18 11 18V19.93ZM17.9 17.39C17.64 16.58 16.9 16 16 16H15V13C15 12.45 14.55 12 14 12H8V10H10C10.55 10 11 9.55 11 9V7H13C14.1 7 15 6.1 15 5V4.59C17.93 5.78 20 8.65 20 12C20 14.08 19.2 15.97 17.9 17.39Z"
1698
1703
  }
1699
1704
  )
1700
1705
  }
@@ -1799,6 +1804,7 @@ export {
1799
1804
  buildEventKey,
1800
1805
  buildObject,
1801
1806
  getAITranslationLDId,
1807
+ isSupportedBrowser,
1802
1808
  useAIAnalytics,
1803
1809
  useAITranslation,
1804
1810
  useConfig
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/ai-translations",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Library that provides a solution to use AI to translate text into a language",
5
5
  "main": "dist/legacy/index.js",
6
6
  "types": "dist/legacy/index.d.ts",