From 78a8caa47135c8e5217863a361743a91cd9ddf8b Mon Sep 17 00:00:00 2001 From: Alex Prudhomme <78121423+alexprudhomme@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:02:10 -0400 Subject: [PATCH] fix patch and bad imports --- packages/atomic/src/components.d.ts | 16 ++--- .../atomic-product-image.tsx | 6 +- .../atomic-ipx-result-link.tsx | 8 ++- packages/atomic/src/utils/result-utils.ts | 3 +- patches/@stencil+core+4.15.0.patch | 59 ------------------- patches/@stencil+core+4.19.2.patch | 52 ++++++++++++++++ 6 files changed, 70 insertions(+), 74 deletions(-) delete mode 100644 patches/@stencil+core+4.15.0.patch create mode 100644 patches/@stencil+core+4.19.2.patch diff --git a/packages/atomic/src/components.d.ts b/packages/atomic/src/components.d.ts index ad3329d63dd..380db2804d3 100644 --- a/packages/atomic/src/components.d.ts +++ b/packages/atomic/src/components.d.ts @@ -7,7 +7,7 @@ import { HTMLStencilElement, JSXBase } from "@stencil/core/internal"; import { AutomaticFacet, CategoryFacetSortCriterion, DateFilterRange, DateRangeRequest, FacetResultsMustMatch, FacetSortCriterion, FoldedResult, GeneratedAnswer, GeneratedAnswerCitation, GeneratedAnswerStyle, InlineLink, InteractiveCitation, InteractiveResult, LogLevel as LogLevel1, PlatformEnvironment as PlatformEnvironment2, RangeFacetRangeAlgorithm, RangeFacetSortCriterion, Result, ResultTemplate, ResultTemplateCondition, SearchEngine, SearchStatus } from "@coveo/headless"; import { CategoryFacet, CommerceEngine, DateFacet, InteractiveProduct, LogLevel, NumericFacet, PlatformEnvironment, Product, ProductListing, ProductListingSummaryState, ProductTemplate, ProductTemplateCondition, RegularFacet, Search, SearchSummaryState, Summary } from "@coveo/headless/commerce"; -import { Bindings } from "./components/commerce/atomic-commerce-interface/atomic-commerce-interface"; +import { CommerceBindings as Bindings } from "./components/commerce/atomic-commerce-interface/atomic-commerce-interface"; import { Range } from "./components/commerce/facets/facet-number-input/atomic-commerce-facet-number-input"; import { i18n } from "i18next"; import { CommerceInitializationOptions } from "./components/commerce/atomic-commerce-interface/atomic-commerce-interface"; @@ -16,11 +16,11 @@ import { ItemDisplayBasicLayout, ItemDisplayDensity, ItemDisplayImageSize, ItemD import { ItemRenderingFunction } from "./components/common/item-list/item-list-common"; import { RedirectionPayload } from "./components/search/atomic-search-box/redirection-payload"; import { AriaLabelGenerator } from "./components/commerce/search-box-suggestions/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products"; -import { AnyBindings, i18nCompatibilityVersion as i18nCompatibilityVersion1, ItemDisplayBasicLayout as ItemDisplayBasicLayout1, ItemDisplayDensity as ItemDisplayDensity1, ItemDisplayImageSize as ItemDisplayImageSize1, ItemRenderingFunction as ItemRenderingFunction1, ItemTarget as ItemTarget1 } from "./components"; +import { unknown as AnyBindings, i18nCompatibilityVersion as i18nCompatibilityVersion1, ItemDisplayBasicLayout as ItemDisplayBasicLayout1, ItemDisplayDensity as ItemDisplayDensity1, ItemDisplayImageSize as ItemDisplayImageSize1, ItemRenderingFunction as ItemRenderingFunction1, ItemTarget as ItemTarget1 } from "./components"; import { AnyBindings as AnyBindings1 } from "./components/common/interface/bindings"; import { NumberInputType } from "./components/common/facets/facet-number-input/number-input-type"; import { NumericFilter, NumericFilterState, RelativeDateUnit } from "./components/common/types"; -import { InsightEngine, InsightFacetSortCriterion, InsightFoldedResult, InsightGeneratedAnswerStyle, InsightInteractiveResult, InsightLogLevel, InsightRangeFacetRangeAlgorithm, InsightRangeFacetSortCriterion, InsightResult, InsightResultTemplate, InsightResultTemplateCondition, PlatformEnvironmentInsight } from "./components/insight"; +import { InsightEngine, FacetSortCriterion as InsightFacetSortCriterion, FoldedResult as InsightFoldedResult, GeneratedAnswerStyle as InsightGeneratedAnswerStyle, InteractiveResult as InsightInteractiveResult, LogLevel as InsightLogLevel, RangeFacetRangeAlgorithm as InsightRangeFacetRangeAlgorithm, RangeFacetSortCriterion as InsightRangeFacetSortCriterion, Result as InsightResult, ResultTemplate as InsightResultTemplate, ResultTemplateCondition as InsightResultTemplateCondition, PlatformEnvironment as PlatformEnvironmentInsight } from "./components/insight"; import { i18nCompatibilityVersion } from "./components/common/interface/i18n"; import { InsightInitializationOptions } from "./components/insight/atomic-insight-interface/atomic-insight-interface"; import { AtomicInsightStore } from "./components/insight/atomic-insight-interface/store"; @@ -29,7 +29,7 @@ import { Section } from "./components/common/atomic-layout-section/sections"; import { AtomicCommonStore, AtomicCommonStoreData } from "./components/common/interface/store"; import { SelectChildProductEventArgs } from "./components/commerce/product-template-components/atomic-product-children/atomic-product-children"; import { PlatformEnvironment as PlatformEnvironment1, RecommendationEngine } from "@coveo/headless/recommendation"; -import { RecsInteractiveResult, RecsLogLevel, RecsResult, RecsResultTemplate, RecsResultTemplateCondition } from "./components/recommendations"; +import { InteractiveResult as RecsInteractiveResult, LogLevel as RecsLogLevel, Result as RecsResult, ResultTemplate as RecsResultTemplate, ResultTemplateCondition as RecsResultTemplateCondition } from "./components/recommendations"; import { RecsInitializationOptions } from "./components/recommendations/atomic-recs-interface/atomic-recs-interface"; import { AtomicRecsStore } from "./components/recommendations/atomic-recs-interface/store"; import { Bindings as Bindings1 } from "./components/search/atomic-search-interface/atomic-search-interface"; @@ -37,7 +37,7 @@ import { AriaLabelGenerator as AriaLabelGenerator1 } from "./components/search/s import { InitializationOptions } from "./components/search/atomic-search-interface/atomic-search-interface"; export { AutomaticFacet, CategoryFacetSortCriterion, DateFilterRange, DateRangeRequest, FacetResultsMustMatch, FacetSortCriterion, FoldedResult, GeneratedAnswer, GeneratedAnswerCitation, GeneratedAnswerStyle, InlineLink, InteractiveCitation, InteractiveResult, LogLevel as LogLevel1, PlatformEnvironment as PlatformEnvironment2, RangeFacetRangeAlgorithm, RangeFacetSortCriterion, Result, ResultTemplate, ResultTemplateCondition, SearchEngine, SearchStatus } from "@coveo/headless"; export { CategoryFacet, CommerceEngine, DateFacet, InteractiveProduct, LogLevel, NumericFacet, PlatformEnvironment, Product, ProductListing, ProductListingSummaryState, ProductTemplate, ProductTemplateCondition, RegularFacet, Search, SearchSummaryState, Summary } from "@coveo/headless/commerce"; -export { Bindings } from "./components/commerce/atomic-commerce-interface/atomic-commerce-interface"; +export { CommerceBindings as Bindings } from "./components/commerce/atomic-commerce-interface/atomic-commerce-interface"; export { Range } from "./components/commerce/facets/facet-number-input/atomic-commerce-facet-number-input"; export { i18n } from "i18next"; export { CommerceInitializationOptions } from "./components/commerce/atomic-commerce-interface/atomic-commerce-interface"; @@ -46,11 +46,11 @@ export { ItemDisplayBasicLayout, ItemDisplayDensity, ItemDisplayImageSize, ItemD export { ItemRenderingFunction } from "./components/common/item-list/item-list-common"; export { RedirectionPayload } from "./components/search/atomic-search-box/redirection-payload"; export { AriaLabelGenerator } from "./components/commerce/search-box-suggestions/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products"; -export { AnyBindings, i18nCompatibilityVersion as i18nCompatibilityVersion1, ItemDisplayBasicLayout as ItemDisplayBasicLayout1, ItemDisplayDensity as ItemDisplayDensity1, ItemDisplayImageSize as ItemDisplayImageSize1, ItemRenderingFunction as ItemRenderingFunction1, ItemTarget as ItemTarget1 } from "./components"; +export { unknown as AnyBindings, i18nCompatibilityVersion as i18nCompatibilityVersion1, ItemDisplayBasicLayout as ItemDisplayBasicLayout1, ItemDisplayDensity as ItemDisplayDensity1, ItemDisplayImageSize as ItemDisplayImageSize1, ItemRenderingFunction as ItemRenderingFunction1, ItemTarget as ItemTarget1 } from "./components"; export { AnyBindings as AnyBindings1 } from "./components/common/interface/bindings"; export { NumberInputType } from "./components/common/facets/facet-number-input/number-input-type"; export { NumericFilter, NumericFilterState, RelativeDateUnit } from "./components/common/types"; -export { InsightEngine, InsightFacetSortCriterion, InsightFoldedResult, InsightGeneratedAnswerStyle, InsightInteractiveResult, InsightLogLevel, InsightRangeFacetRangeAlgorithm, InsightRangeFacetSortCriterion, InsightResult, InsightResultTemplate, InsightResultTemplateCondition, PlatformEnvironmentInsight } from "./components/insight"; +export { InsightEngine, FacetSortCriterion as InsightFacetSortCriterion, FoldedResult as InsightFoldedResult, GeneratedAnswerStyle as InsightGeneratedAnswerStyle, InteractiveResult as InsightInteractiveResult, LogLevel as InsightLogLevel, RangeFacetRangeAlgorithm as InsightRangeFacetRangeAlgorithm, RangeFacetSortCriterion as InsightRangeFacetSortCriterion, Result as InsightResult, ResultTemplate as InsightResultTemplate, ResultTemplateCondition as InsightResultTemplateCondition, PlatformEnvironment as PlatformEnvironmentInsight } from "./components/insight"; export { i18nCompatibilityVersion } from "./components/common/interface/i18n"; export { InsightInitializationOptions } from "./components/insight/atomic-insight-interface/atomic-insight-interface"; export { AtomicInsightStore } from "./components/insight/atomic-insight-interface/store"; @@ -59,7 +59,7 @@ export { Section } from "./components/common/atomic-layout-section/sections"; export { AtomicCommonStore, AtomicCommonStoreData } from "./components/common/interface/store"; export { SelectChildProductEventArgs } from "./components/commerce/product-template-components/atomic-product-children/atomic-product-children"; export { PlatformEnvironment as PlatformEnvironment1, RecommendationEngine } from "@coveo/headless/recommendation"; -export { RecsInteractiveResult, RecsLogLevel, RecsResult, RecsResultTemplate, RecsResultTemplateCondition } from "./components/recommendations"; +export { InteractiveResult as RecsInteractiveResult, LogLevel as RecsLogLevel, Result as RecsResult, ResultTemplate as RecsResultTemplate, ResultTemplateCondition as RecsResultTemplateCondition } from "./components/recommendations"; export { RecsInitializationOptions } from "./components/recommendations/atomic-recs-interface/atomic-recs-interface"; export { AtomicRecsStore } from "./components/recommendations/atomic-recs-interface/store"; export { Bindings as Bindings1 } from "./components/search/atomic-search-interface/atomic-search-interface"; diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-image/atomic-product-image.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-image/atomic-product-image.tsx index 774f8310859..ad5941153fc 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-image/atomic-product-image.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-image/atomic-product-image.tsx @@ -1,12 +1,12 @@ import {Product, ProductTemplatesHelpers} from '@coveo/headless/commerce'; import {Component, h, Prop, Element, State, Method} from '@stencil/core'; -import {Bindings} from '../../../../components'; import { - InitializeBindings, InitializableComponent, + InitializeBindings, } from '../../../../utils/initialization-utils'; import {filterProtocol} from '../../../../utils/xss-utils'; import {ImageCarousel} from '../../../common/image-carousel/image-carousel'; +import {CommerceBindings as Bindings} from '../../atomic-commerce-interface/atomic-commerce-interface'; import {ProductContext} from '../product-template-decorators'; type Image = { @@ -23,7 +23,7 @@ type Image = { styleUrl: 'atomic-product-image.pcss', shadow: true, }) -export class AtomicProductImage implements InitializableComponent { +export class AtomicProductImage implements InitializableComponent { @InitializeBindings() public bindings!: Bindings; @ProductContext() private product!: Product; @Element() private host!: HTMLElement; diff --git a/packages/atomic/src/components/ipx/atomic-ipx-result-link/atomic-ipx-result-link.tsx b/packages/atomic/src/components/ipx/atomic-ipx-result-link/atomic-ipx-result-link.tsx index dd67763665d..a54d6e40956 100644 --- a/packages/atomic/src/components/ipx/atomic-ipx-result-link/atomic-ipx-result-link.tsx +++ b/packages/atomic/src/components/ipx/atomic-ipx-result-link/atomic-ipx-result-link.tsx @@ -5,7 +5,6 @@ import { loadIPXActionsHistoryActions, } from '@coveo/headless'; import {Component, h, Prop, Element} from '@stencil/core'; -import {Bindings} from '../../../components'; import {buildCustomEvent} from '../../../utils/event-utils'; import { InitializableComponent, @@ -16,6 +15,7 @@ import {getDefaultSlotFromHost} from '../../../utils/slot-utils'; import {AnyUnfoldedItem} from '../../common/interface/item'; import {getAttributesFromLinkSlot} from '../../common/item-link/attributes-slot'; import {LinkWithItemAnalytics} from '../../common/item-link/item-link'; +import {RecsBindings} from '../../recommendations/atomic-recs-interface/atomic-recs-interface'; import { ResultContext, InteractiveResultContext, @@ -32,8 +32,10 @@ import { styleUrl: 'atomic-ipx-result-link.pcss', shadow: false, }) -export class AtomicIPXResultLink implements InitializableComponent { - @InitializeBindings() public bindings!: Bindings; +export class AtomicIPXResultLink + implements InitializableComponent +{ + @InitializeBindings() public bindings!: RecsBindings; public error!: Error; @ResultContext() private result!: AnyUnfoldedItem; diff --git a/packages/atomic/src/utils/result-utils.ts b/packages/atomic/src/utils/result-utils.ts index 1d009630d47..e409e288333 100644 --- a/packages/atomic/src/utils/result-utils.ts +++ b/packages/atomic/src/utils/result-utils.ts @@ -4,6 +4,7 @@ import { Result, ResultTemplatesHelpers, } from '@coveo/headless'; +import {RecsBindings} from '../components/recommendations/atomic-recs-interface/atomic-recs-interface'; import {Bindings} from '../components/search/atomic-search-interface/atomic-search-interface'; /** @@ -52,7 +53,7 @@ export function bindLogDocumentOpenOnResult( export function buildStringTemplateFromResult( template: string, result: Result, - bindings: Bindings + bindings: Bindings | RecsBindings ) { return template.replace(/\${(.*?)}/g, (value: string) => { const key = value.substring(2, value.length - 1); diff --git a/patches/@stencil+core+4.15.0.patch b/patches/@stencil+core+4.15.0.patch deleted file mode 100644 index 847b3027073..00000000000 --- a/patches/@stencil+core+4.15.0.patch +++ /dev/null @@ -1,59 +0,0 @@ -diff --git a/node_modules/@stencil/core/compiler/stencil.js b/node_modules/@stencil/core/compiler/stencil.js -index d4ea871..4faf84b 100644 ---- a/node_modules/@stencil/core/compiler/stencil.js -+++ b/node_modules/@stencil/core/compiler/stencil.js -@@ -276940,7 +276940,7 @@ const visitClassDeclaration = (config, diagnostics, typeChecker, program, classN - // We call the `handleClassFields` method which handles transforming any - // class fields, removing them from the class and adding statements to the - // class' constructor which instantiate them there instead. -- const updatedClassFields = handleClassFields(classNode, filteredMethodsAndFields, typeChecker, importAliasMap); -+ const updatedClassFields = handleClassFields(classNode, decoratedMembers, typeChecker, importAliasMap, filteredMethodsAndFields); - validateMethods(diagnostics, classMembers); - const currentDecorators = retrieveTsDecorators(classNode); - return ts$1.factory.updateClassDeclaration(classNode, [ -@@ -276975,19 +276975,8 @@ const removeStencilMethodDecorators = (classMembers, diagnostics, importAliasMap - return ts$1.factory.updateMethodDeclaration(member, [...(newDecorators !== null && newDecorators !== void 0 ? newDecorators : []), ...((_a = retrieveTsModifiers(member)) !== null && _a !== void 0 ? _a : [])], member.asteriskToken, member.name, member.questionToken, member.typeParameters, member.parameters, member.type, member.body); - } - else if (ts$1.isPropertyDeclaration(member)) { -- if (shouldInitializeInConstructor(member, importAliasMap)) { -- // if the current class member is decorated with either 'State' or -- // 'Prop' we need to modify the property declaration to transform it -- // from a class field but we handle this in the `handleClassFields` -- // method below, so we just want to return the class member here -- // untouched. -- return member; -- } -- else { -- // update the property to remove decorators -- const modifiers = retrieveTsModifiers(member); -- return ts$1.factory.updatePropertyDeclaration(member, [...(newDecorators !== null && newDecorators !== void 0 ? newDecorators : []), ...(modifiers !== null && modifiers !== void 0 ? modifiers : [])], member.name, member.questionToken, member.type, member.initializer); -- } -+ const modifiers = retrieveTsModifiers(member); -+ return ts$1.factory.updatePropertyDeclaration(member, [...(newDecorators !== null && newDecorators !== void 0 ? newDecorators : []), ...(modifiers !== null && modifiers !== void 0 ? modifiers : [])], member.name, member.questionToken, member.type, member.initializer); - } - else { - const err = buildError(diagnostics); -@@ -277127,10 +277116,9 @@ const filterDecorators = (decorators, excludeList) => { - * @param importAliasMap a map of Stencil decorator names to their import names - * @returns a list of updated class elements which can be inserted into the class - */ --function handleClassFields(classNode, classMembers, typeChecker, importAliasMap) { -+function handleClassFields(classNode, classMembers, typeChecker, importAliasMap, updatedClassMembers) { - var _a; - const statements = []; -- const updatedClassMembers = []; - for (const member of classMembers) { - if (shouldInitializeInConstructor(member, importAliasMap) && ts$1.isPropertyDeclaration(member)) { - const memberName = tsPropDeclNameAsString(member, typeChecker); -@@ -277141,11 +277129,6 @@ function handleClassFields(classNode, classMembers, typeChecker, importAliasMap) - // just 'undefined' - (_a = member.initializer) !== null && _a !== void 0 ? _a : ts$1.factory.createIdentifier('undefined')))); - } -- else { -- // if it's not a class field that is decorated with a Stencil decorator then -- // we just push it onto our class member list -- updatedClassMembers.push(member); -- } - } - if (statements.length === 0) { - // we didn't encounter any class fields we need to update, so we can diff --git a/patches/@stencil+core+4.19.2.patch b/patches/@stencil+core+4.19.2.patch new file mode 100644 index 00000000000..19a2988200d --- /dev/null +++ b/patches/@stencil+core+4.19.2.patch @@ -0,0 +1,52 @@ +diff --git a/node_modules/@stencil/core/compiler/stencil.js b/node_modules/@stencil/core/compiler/stencil.js +index 9fb2fba..92f2ee7 100644 +--- a/node_modules/@stencil/core/compiler/stencil.js ++++ b/node_modules/@stencil/core/compiler/stencil.js +@@ -257144,7 +257144,7 @@ var visitClassDeclaration = (config, diagnostics, typeChecker, program, classNod + importAliasMap.get("AttachInternals") + ); + } +- const updatedClassFields = handleClassFields(classNode, filteredMethodsAndFields, typeChecker, importAliasMap); ++ const updatedClassFields = handleClassFields(classNode, filteredMethodsAndFields, typeChecker, importAliasMap, filteredMethodsAndFields); + validateMethods(diagnostics, classMembers); + const currentDecorators = retrieveTsDecorators(classNode); + return typescript_5_4_5_bundle_cache_min_default.factory.updateClassDeclaration( +@@ -257184,9 +257184,6 @@ var removeStencilMethodDecorators = (classMembers, diagnostics, importAliasMap) + member2.body + ); + } else if (typescript_5_4_5_bundle_cache_min_default.isPropertyDeclaration(member2)) { +- if (shouldInitializeInConstructor(member2, importAliasMap)) { +- return member2; +- } else { + const modifiers = retrieveTsModifiers(member2); + return typescript_5_4_5_bundle_cache_min_default.factory.updatePropertyDeclaration( + member2, +@@ -257196,7 +257193,6 @@ var removeStencilMethodDecorators = (classMembers, diagnostics, importAliasMap) + member2.type, + member2.initializer + ); +- } + } else { + const err2 = buildError(diagnostics); + err2.messageText = "Unknown class member encountered!"; +@@ -257220,10 +257216,9 @@ var filterDecorators = (decorators, excludeList) => { + } + return decorators; + }; +-function handleClassFields(classNode, classMembers, typeChecker, importAliasMap) { ++function handleClassFields(classNode, classMembers, typeChecker, importAliasMap, updatedClassMembers) { + var _a; + const statements = []; +- const updatedClassMembers = []; + for (const member2 of classMembers) { + if (shouldInitializeInConstructor(member2, importAliasMap) && typescript_5_4_5_bundle_cache_min_default.isPropertyDeclaration(member2)) { + const memberName = tsPropDeclNameAsString(member2, typeChecker); +@@ -257238,8 +257233,6 @@ function handleClassFields(classNode, classMembers, typeChecker, importAliasMap) + ) + ) + ); +- } else { +- updatedClassMembers.push(member2); + } + } + if (statements.length === 0) {