npm package diff

Package: @forge/manifest

Versions: 7.5.2-next.0-experimental-10722bc - 7.7.0-next.13

File: package/out/utils/i18n/module-i18n-helper.js

Index: package/out/utils/i18n/module-i18n-helper.js
===================================================================
--- package/out/utils/i18n/module-i18n-helper.js
+++ package/out/utils/i18n/module-i18n-helper.js
@@ -0,0 +1,44 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.extractInternalI18nPropertyKeysFromModules = void 0;
+const i18n_1 = require("@forge/i18n");
+const INTERNAL_I18N_PROPERTY_KEY_SUFFIX = '__i18n';
+const isObject = (value) => {
+    return typeof value === 'object' && value !== null && !Array.isArray(value);
+};
+const isInternalI18nPropertyKey = (key) => {
+    return key.length > INTERNAL_I18N_PROPERTY_KEY_SUFFIX.length && key.endsWith(INTERNAL_I18N_PROPERTY_KEY_SUFFIX);
+};
+const isI18nProperty = (key, value) => {
+    return isInternalI18nPropertyKey(key) && typeof value === 'string';
+};
+const getInternalI18nPropertyKeysFromObject = (obj) => {
+    const visited = new Set();
+    const visit = (value) => {
+        if (!isObject(value) || visited.has(value)) {
+            return [];
+        }
+        visited.add(value);
+        return Object.entries(value).flatMap(([propKey, propValue]) => {
+            if (isI18nProperty(propKey, propValue)) {
+                return [propKey];
+            }
+            else if (Array.isArray(propValue)) {
+                return propValue.flatMap((item) => visit(item));
+            }
+            return visit(propValue);
+        });
+    };
+    return visit(obj);
+};
+const extractInternalI18nPropertyKeysFromModules = (modules) => {
+    const i18nKeys = new Set();
+    for (const [moduleEntryObject, moduleKey] of (0, i18n_1.getI18nSupportedModuleEntries)(modules)) {
+        const i18nKeysForEntryValue = getInternalI18nPropertyKeysFromObject(moduleEntryObject);
+        for (const key of i18nKeysForEntryValue) {
+            i18nKeys.add(`${key},${moduleKey}`);
+        }
+    }
+    return i18nKeys.size > 0 ? Array.from(i18nKeys).map((key) => key.split(',')) : [];
+};
+exports.extractInternalI18nPropertyKeysFromModules = extractInternalI18nPropertyKeysFromModules;