npm package diff

Package: @forge/cli-shared

Versions: 6.6.1-next.15 - 6.6.1-next.16

File: package/out/service/supported-products-service.js

Index: package/out/service/supported-products-service.js
===================================================================
--- package/out/service/supported-products-service.js
+++ package/out/service/supported-products-service.js
@@ -67,31 +67,46 @@
     return definitionsForEnabledProducts.map((pd) => {
         return new SupportedProductEntry(pd.name, pd.productType, pd.special?.supportedByCrossProductApps ?? false);
     });
 }
-class SupportedProductsService {
-    supportedProducts;
-    constructor(supportedProducts) {
-        this.supportedProducts = supportedProducts;
+class SupportedProductEntriesHolder {
+    value;
+    constructor(value) {
+        this.value = value;
     }
-    async initializeWithSupportedProducts(statsigService) {
-        if (this.supportedProducts) {
-            throw new Error('SupportedProductsService is already initialized');
+    async initialize(valueProvider) {
+        if (this.value) {
+            throw new Error('SupportedProductsService was already initialized - is initialization called multiple times?');
         }
-        this.supportedProducts = await resolveEnabledProducts(statsigService);
+        this.value = await valueProvider();
     }
-    getSupportedProductsNames(filter = () => true) {
-        if (!this.supportedProducts) {
-            throw new Error('SupportedProductsService is not initialized, are you calling it from some constructor?');
+    get() {
+        if (!this.value) {
+            throw new Error('SupportedProductsService is not initialized - are you calling it from some constructor?');
         }
-        return this.supportedProducts.filter((p) => filter(p)).map((p) => p.productName);
+        return this.value;
     }
+}
+class SupportedProductsService {
+    supportedProductEntriesHolder;
+    constructor(supportedProductEntries) {
+        this.supportedProductEntriesHolder = new SupportedProductEntriesHolder(supportedProductEntries);
+    }
+    async initializeWithSupportedProducts(statsigService) {
+        await this.supportedProductEntriesHolder.initialize(async () => await resolveEnabledProducts(statsigService));
+    }
+    getFilteredSupportedProducts(filter) {
+        return this.supportedProductEntriesHolder
+            .get()
+            .filter((p) => filter(p))
+            .map((p) => p.productName);
+    }
     getSupportedProducts() {
-        return this.getSupportedProductsNames();
+        return this.supportedProductEntriesHolder.get().map((p) => p.productName);
     }
     getSupportedSecondaryProductsForXPA(requiredProducts) {
         const requiredProductsNames = requiredProducts.map((p) => (0, shared_1.productDisplayName)(p));
-        return this.getSupportedProductsNames((p) => p.supportedByCrossProductApps && !requiredProductsNames.includes(p.productName));
+        return this.getFilteredSupportedProducts((p) => p.supportedByCrossProductApps && !requiredProductsNames.includes(p.productName));
     }
     validateSupportedProduct(productNameInput) {
         const productName = (0, shared_1.productDisplayName)(productNameInput);
         const supportedProducts = this.getSupportedProducts();
@@ -102,9 +117,9 @@
             throw new shared_1.ValidationError(ui_1.Text.error.invalidProduct);
         }
     }
     isWorkspaceProduct(product) {
-        return this.getSupportedProductsNames((p) => p.productType === 'workspace').includes((0, shared_1.productDisplayName)(product));
+        return this.getFilteredSupportedProducts((p) => p.productType === 'workspace').includes((0, shared_1.productDisplayName)(product));
     }
     validateSite(site, product) {
         const trySites = [site, `https://${site}`];
         for (const trySite of trySites) {