@wix/web5-core 1.56.1 → 1.57.1

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.
Files changed (192) hide show
  1. package/dist/cjs/client/wixAuthFetch.js +2 -2
  2. package/dist/cjs/client/wixAuthFetch.js.map +1 -1
  3. package/dist/cjs/component/componentDefinitions/HeroEntitySectionDefinition.js +20 -15
  4. package/dist/cjs/component/componentDefinitions/HeroEntitySectionDefinition.js.map +1 -1
  5. package/dist/cjs/component/componentDefinitions/HeroSectionDefinition.js +12 -4
  6. package/dist/cjs/component/componentDefinitions/HeroSectionDefinition.js.map +1 -1
  7. package/dist/cjs/component/componentDefinitions/listItemsSectionDefinition.js +24 -29
  8. package/dist/cjs/component/componentDefinitions/listItemsSectionDefinition.js.map +1 -1
  9. package/dist/cjs/component/componentParser.js +8 -1
  10. package/dist/cjs/component/componentParser.js.map +1 -1
  11. package/dist/cjs/component/types.js.map +1 -1
  12. package/dist/cjs/components/placement/PlacementResponseRenderer.css +0 -4
  13. package/dist/cjs/components/placement/PlacementResponseRenderer.js +11 -33
  14. package/dist/cjs/components/placement/PlacementResponseRenderer.js.map +1 -1
  15. package/dist/cjs/components/placement/buildPlacementDependencies.js.map +1 -1
  16. package/dist/cjs/components/ui/OptimizedImage.js +59 -14
  17. package/dist/cjs/components/ui/OptimizedImage.js.map +1 -1
  18. package/dist/cjs/components/ui/SectionSkeleton.css +19 -0
  19. package/dist/cjs/components/ui/SectionSkeleton.js +8 -4
  20. package/dist/cjs/components/ui/SectionSkeleton.js.map +1 -1
  21. package/dist/cjs/components/ui/UserQuery.css +72 -0
  22. package/dist/cjs/components/ui/UserQuery.js +131 -37
  23. package/dist/cjs/components/ui/UserQuery.js.map +1 -1
  24. package/dist/cjs/context/UserQueryContext.js +34 -0
  25. package/dist/cjs/context/UserQueryContext.js.map +1 -0
  26. package/dist/cjs/entity/defaultExtractor.js +9 -2
  27. package/dist/cjs/entity/defaultExtractor.js.map +1 -1
  28. package/dist/cjs/entity/fetchEntityListData.js +13 -26
  29. package/dist/cjs/entity/fetchEntityListData.js.map +1 -1
  30. package/dist/cjs/entity/index.js +5 -1
  31. package/dist/cjs/entity/index.js.map +1 -1
  32. package/dist/cjs/entity/listEntityItems.js +90 -0
  33. package/dist/cjs/entity/listEntityItems.js.map +1 -0
  34. package/dist/cjs/hostScope.js +63 -0
  35. package/dist/cjs/hostScope.js.map +1 -0
  36. package/dist/cjs/index.js +38 -13
  37. package/dist/cjs/index.js.map +1 -1
  38. package/dist/cjs/patternValidator/validator.test.js +61 -61
  39. package/dist/cjs/patternValidator/validator.test.js.map +1 -1
  40. package/dist/cjs/registry/ComponentRegistry.js +22 -2
  41. package/dist/cjs/registry/ComponentRegistry.js.map +1 -1
  42. package/dist/cjs/registry/index.js +1 -3
  43. package/dist/cjs/registry/index.js.map +1 -1
  44. package/dist/cjs/registry/types.js.map +1 -1
  45. package/dist/cjs/styles/base-utilities.css +35 -0
  46. package/dist/cjs/styles/components.css +1 -0
  47. package/dist/cjs/styles/host-reset.css +100 -0
  48. package/dist/cjs/styles/tailwind-theme.css +6 -6
  49. package/dist/cjs/utils/backendEnvironment.js +78 -0
  50. package/dist/cjs/utils/backendEnvironment.js.map +1 -0
  51. package/dist/cjs/utils/entityLinkParser.js +3 -1
  52. package/dist/cjs/utils/entityLinkParser.js.map +1 -1
  53. package/dist/cjs/utils/imageBackdrop.js +269 -0
  54. package/dist/cjs/utils/imageBackdrop.js.map +1 -0
  55. package/dist/cjs/utils/intentExtractor.js +20 -9
  56. package/dist/cjs/utils/intentExtractor.js.map +1 -1
  57. package/dist/cjs/utils/productBackHandoff.js +106 -0
  58. package/dist/cjs/utils/productBackHandoff.js.map +1 -0
  59. package/dist/cjs/utils/refreshPrompts.js +72 -0
  60. package/dist/cjs/utils/refreshPrompts.js.map +1 -0
  61. package/dist/esm/client/wixAuthFetch.js +2 -2
  62. package/dist/esm/client/wixAuthFetch.js.map +1 -1
  63. package/dist/esm/component/componentDefinitions/HeroEntitySectionDefinition.js +20 -15
  64. package/dist/esm/component/componentDefinitions/HeroEntitySectionDefinition.js.map +1 -1
  65. package/dist/esm/component/componentDefinitions/HeroSectionDefinition.js +12 -4
  66. package/dist/esm/component/componentDefinitions/HeroSectionDefinition.js.map +1 -1
  67. package/dist/esm/component/componentDefinitions/listItemsSectionDefinition.js +25 -30
  68. package/dist/esm/component/componentDefinitions/listItemsSectionDefinition.js.map +1 -1
  69. package/dist/esm/component/componentParser.js +8 -1
  70. package/dist/esm/component/componentParser.js.map +1 -1
  71. package/dist/esm/component/types.js.map +1 -1
  72. package/dist/esm/components/placement/PlacementResponseRenderer.css +0 -4
  73. package/dist/esm/components/placement/PlacementResponseRenderer.js +1 -16
  74. package/dist/esm/components/placement/PlacementResponseRenderer.js.map +1 -1
  75. package/dist/esm/components/placement/buildPlacementDependencies.js.map +1 -1
  76. package/dist/esm/components/ui/OptimizedImage.js +50 -5
  77. package/dist/esm/components/ui/OptimizedImage.js.map +1 -1
  78. package/dist/esm/components/ui/SectionSkeleton.css +19 -0
  79. package/dist/esm/components/ui/SectionSkeleton.js +5 -1
  80. package/dist/esm/components/ui/SectionSkeleton.js.map +1 -1
  81. package/dist/esm/components/ui/UserQuery.css +72 -0
  82. package/dist/esm/components/ui/UserQuery.js +52 -6
  83. package/dist/esm/components/ui/UserQuery.js.map +1 -1
  84. package/dist/esm/context/UserQueryContext.js +21 -0
  85. package/dist/esm/context/UserQueryContext.js.map +1 -0
  86. package/dist/esm/entity/defaultExtractor.js +9 -2
  87. package/dist/esm/entity/defaultExtractor.js.map +1 -1
  88. package/dist/esm/entity/fetchEntityListData.js +14 -26
  89. package/dist/esm/entity/fetchEntityListData.js.map +1 -1
  90. package/dist/esm/entity/index.js +1 -0
  91. package/dist/esm/entity/index.js.map +1 -1
  92. package/dist/esm/entity/listEntityItems.js +85 -0
  93. package/dist/esm/entity/listEntityItems.js.map +1 -0
  94. package/dist/esm/hostScope.js +59 -0
  95. package/dist/esm/hostScope.js.map +1 -0
  96. package/dist/esm/index.js +13 -4
  97. package/dist/esm/index.js.map +1 -1
  98. package/dist/esm/patternValidator/validator.test.js +61 -61
  99. package/dist/esm/patternValidator/validator.test.js.map +1 -1
  100. package/dist/esm/registry/ComponentRegistry.js +22 -2
  101. package/dist/esm/registry/ComponentRegistry.js.map +1 -1
  102. package/dist/esm/registry/index.js +0 -1
  103. package/dist/esm/registry/index.js.map +1 -1
  104. package/dist/esm/registry/types.js.map +1 -1
  105. package/dist/esm/styles/base-utilities.css +35 -0
  106. package/dist/esm/styles/components.css +1 -0
  107. package/dist/esm/styles/host-reset.css +100 -0
  108. package/dist/esm/styles/tailwind-theme.css +6 -6
  109. package/dist/esm/utils/backendEnvironment.js +71 -0
  110. package/dist/esm/utils/backendEnvironment.js.map +1 -0
  111. package/dist/esm/utils/entityLinkParser.js +3 -1
  112. package/dist/esm/utils/entityLinkParser.js.map +1 -1
  113. package/dist/esm/utils/imageBackdrop.js +262 -0
  114. package/dist/esm/utils/imageBackdrop.js.map +1 -0
  115. package/dist/esm/utils/intentExtractor.js +21 -12
  116. package/dist/esm/utils/intentExtractor.js.map +1 -1
  117. package/dist/esm/utils/productBackHandoff.js +100 -0
  118. package/dist/esm/utils/productBackHandoff.js.map +1 -0
  119. package/dist/esm/utils/refreshPrompts.js +67 -0
  120. package/dist/esm/utils/refreshPrompts.js.map +1 -0
  121. package/dist/types/component/componentDefinitions/HeroEntitySectionDefinition.d.ts.map +1 -1
  122. package/dist/types/component/componentDefinitions/HeroSectionDefinition.d.ts.map +1 -1
  123. package/dist/types/component/componentDefinitions/listItemsSectionDefinition.d.ts +2 -2
  124. package/dist/types/component/componentDefinitions/listItemsSectionDefinition.d.ts.map +1 -1
  125. package/dist/types/component/componentParser.d.ts.map +1 -1
  126. package/dist/types/component/types.d.ts +1 -5
  127. package/dist/types/component/types.d.ts.map +1 -1
  128. package/dist/types/components/placement/PlacementResponseRenderer.d.ts +1 -1
  129. package/dist/types/components/placement/PlacementResponseRenderer.d.ts.map +1 -1
  130. package/dist/types/components/placement/buildPlacementDependencies.d.ts +1 -2
  131. package/dist/types/components/placement/buildPlacementDependencies.d.ts.map +1 -1
  132. package/dist/types/components/ui/OptimizedImage.d.ts +9 -0
  133. package/dist/types/components/ui/OptimizedImage.d.ts.map +1 -1
  134. package/dist/types/components/ui/SectionSkeleton.d.ts.map +1 -1
  135. package/dist/types/components/ui/UserQuery.d.ts +21 -0
  136. package/dist/types/components/ui/UserQuery.d.ts.map +1 -1
  137. package/dist/types/context/UserQueryContext.d.ts +12 -0
  138. package/dist/types/context/UserQueryContext.d.ts.map +1 -0
  139. package/dist/types/entity/defaultExtractor.d.ts.map +1 -1
  140. package/dist/types/entity/fetchEntityListData.d.ts +0 -2
  141. package/dist/types/entity/fetchEntityListData.d.ts.map +1 -1
  142. package/dist/types/entity/index.d.ts +1 -0
  143. package/dist/types/entity/index.d.ts.map +1 -1
  144. package/dist/types/entity/listEntityItems.d.ts +40 -0
  145. package/dist/types/entity/listEntityItems.d.ts.map +1 -0
  146. package/dist/types/hostScope.d.ts +83 -0
  147. package/dist/types/hostScope.d.ts.map +1 -0
  148. package/dist/types/index.d.ts +11 -7
  149. package/dist/types/index.d.ts.map +1 -1
  150. package/dist/types/registry/ComponentRegistry.d.ts +8 -0
  151. package/dist/types/registry/ComponentRegistry.d.ts.map +1 -1
  152. package/dist/types/registry/index.d.ts +0 -1
  153. package/dist/types/registry/index.d.ts.map +1 -1
  154. package/dist/types/registry/types.d.ts +5 -6
  155. package/dist/types/registry/types.d.ts.map +1 -1
  156. package/dist/types/utils/backendEnvironment.d.ts +30 -0
  157. package/dist/types/utils/backendEnvironment.d.ts.map +1 -0
  158. package/dist/types/utils/entityLinkParser.d.ts.map +1 -1
  159. package/dist/types/utils/imageBackdrop.d.ts +102 -0
  160. package/dist/types/utils/imageBackdrop.d.ts.map +1 -0
  161. package/dist/types/utils/intentExtractor.d.ts +21 -4
  162. package/dist/types/utils/intentExtractor.d.ts.map +1 -1
  163. package/dist/types/utils/productBackHandoff.d.ts +43 -0
  164. package/dist/types/utils/productBackHandoff.d.ts.map +1 -0
  165. package/dist/types/utils/refreshPrompts.d.ts +32 -0
  166. package/dist/types/utils/refreshPrompts.d.ts.map +1 -0
  167. package/package.json +2 -2
  168. package/src/components/placement/PlacementResponseRenderer.css +0 -4
  169. package/src/components/ui/SectionSkeleton.css +19 -0
  170. package/src/components/ui/UserQuery.css +72 -0
  171. package/src/styles/base-utilities.css +35 -0
  172. package/src/styles/components.css +1 -0
  173. package/src/styles/host-reset.css +100 -0
  174. package/src/styles/tailwind-theme.css +6 -6
  175. package/dist/cjs/registry/Intent.js +0 -19
  176. package/dist/cjs/registry/Intent.js.map +0 -1
  177. package/dist/cjs/utils/conversationApi.js +0 -52
  178. package/dist/cjs/utils/conversationApi.js.map +0 -1
  179. package/dist/cjs/utils/conversationMode.js +0 -23
  180. package/dist/cjs/utils/conversationMode.js.map +0 -1
  181. package/dist/esm/registry/Intent.js +0 -15
  182. package/dist/esm/registry/Intent.js.map +0 -1
  183. package/dist/esm/utils/conversationApi.js +0 -45
  184. package/dist/esm/utils/conversationApi.js.map +0 -1
  185. package/dist/esm/utils/conversationMode.js +0 -18
  186. package/dist/esm/utils/conversationMode.js.map +0 -1
  187. package/dist/types/registry/Intent.d.ts +0 -12
  188. package/dist/types/registry/Intent.d.ts.map +0 -1
  189. package/dist/types/utils/conversationApi.d.ts +0 -26
  190. package/dist/types/utils/conversationApi.d.ts.map +0 -1
  191. package/dist/types/utils/conversationMode.d.ts +0 -16
  192. package/dist/types/utils/conversationMode.d.ts.map +0 -1
@@ -6,12 +6,12 @@ var _sdk = require("@wix/sdk");
6
6
  /**
7
7
  * Wix-authenticated `fetch` for Web5 BE calls from a host (third-party) origin.
8
8
  *
9
- * `wixapis.com`'s `/wix-assistant-web5/v1/conversation` endpoint refuses
9
+ * `wixapis.com`'s `/wix-assistant-web5/v1/turn` endpoint refuses
10
10
  * cross-origin anonymous calls (HTTP 500) — the only auth path that survives
11
11
  * CORS from a host (e.g. Shopify) origin is `@wix/sdk`'s `OAuthStrategy`, which
12
12
  * supplies the `Authorization` header the BE allowlists.
13
13
  *
14
- * Shared by every embed bundle that talks to the conversation endpoint — the
14
+ * Shared by every embed bundle that talks to the turn endpoint — the
15
15
  * placement bundle and the input-widget chip generator — so they all attach
16
16
  * the same token. Token caching uses the same `localStorage` key format
17
17
  * (`web5_tokens_<clientId>`) as `web50-server-ui`'s token cache, so the loader,
@@ -1 +1 @@
1
- {"version":3,"names":["_sdk","require","TOKEN_CACHE_KEY_PREFIX","tokenKey","clientId","loadTokens","client","raw","localStorage","getItem","auth","setTokens","JSON","parse","removeItem","saveTokens","setItem","stringify","getTokens","createWixAuthFetch","Error","createClient","OAuthStrategy","input","init","res","fetchWithAuth"],"sources":["../../../src/client/wixAuthFetch.ts"],"sourcesContent":["/**\n * Wix-authenticated `fetch` for Web5 BE calls from a host (third-party) origin.\n *\n * `wixapis.com`'s `/wix-assistant-web5/v1/conversation` endpoint refuses\n * cross-origin anonymous calls (HTTP 500) — the only auth path that survives\n * CORS from a host (e.g. Shopify) origin is `@wix/sdk`'s `OAuthStrategy`, which\n * supplies the `Authorization` header the BE allowlists.\n *\n * Shared by every embed bundle that talks to the conversation endpoint — the\n * placement bundle and the input-widget chip generator — so they all attach\n * the same token. Token caching uses the same `localStorage` key format\n * (`web5_tokens_<clientId>`) as `web50-server-ui`'s token cache, so the loader,\n * full app, placement, and input widget share one OAuth token instead of each\n * burning a `/oauth2/token` round-trip per page load.\n */\nimport { createClient, OAuthStrategy } from '@wix/sdk';\n\nconst TOKEN_CACHE_KEY_PREFIX = 'web5_tokens_';\n\ninterface SdkClient {\n fetchWithAuth: typeof fetch;\n auth: {\n setTokens: (tokens: unknown) => void;\n getTokens: () => unknown;\n };\n}\n\nfunction tokenKey(clientId: string): string {\n return `${TOKEN_CACHE_KEY_PREFIX}${clientId}`;\n}\n\nfunction loadTokens(client: SdkClient, clientId: string): void {\n try {\n const raw = localStorage.getItem(tokenKey(clientId));\n if (!raw) return;\n client.auth.setTokens(JSON.parse(raw));\n } catch {\n try {\n localStorage.removeItem(tokenKey(clientId));\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction saveTokens(client: SdkClient, clientId: string): void {\n try {\n localStorage.setItem(\n tokenKey(clientId),\n JSON.stringify(client.auth.getTokens()),\n );\n } catch {\n // privacy mode / quota — in-memory token still works for this session\n }\n}\n\n/**\n * Build a `fetch`-shaped function pre-bound to the given Wix client id. The\n * returned value is drop-in compatible with any `fetchImpl` option\n * (`placementFetch`, `fetchContextualChips`, …).\n *\n * Each call loads cached tokens before the request, then saves the (possibly\n * refreshed) tokens after the response headers arrive — we deliberately do NOT\n * wait for the streaming body; the SDK's refresh runs alongside the stream and\n * the saved tokens benefit subsequent calls.\n */\nexport function createWixAuthFetch(clientId: string): typeof fetch {\n if (!clientId) {\n throw new Error('[web5-core] createWixAuthFetch: clientId is empty');\n }\n const client = createClient({\n auth: OAuthStrategy({ clientId }),\n }) as unknown as SdkClient;\n\n return (async (input: RequestInfo | URL, init?: RequestInit) => {\n loadTokens(client, clientId);\n const res = await client.fetchWithAuth(input, init);\n saveTokens(client, clientId);\n return res;\n }) as typeof fetch;\n}\n"],"mappings":";;;;AAeA,IAAAA,IAAA,GAAAC,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAMC,sBAAsB,GAAG,cAAc;AAU7C,SAASC,QAAQA,CAACC,QAAgB,EAAU;EAC1C,OAAO,GAAGF,sBAAsB,GAAGE,QAAQ,EAAE;AAC/C;AAEA,SAASC,UAAUA,CAACC,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACF,MAAMG,GAAG,GAAGC,YAAY,CAACC,OAAO,CAACN,QAAQ,CAACC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAACG,GAAG,EAAE;IACVD,MAAM,CAACI,IAAI,CAACC,SAAS,CAACC,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC;EACxC,CAAC,CAAC,MAAM;IACN,IAAI;MACFC,YAAY,CAACM,UAAU,CAACX,QAAQ,CAACC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;AACF;AAEA,SAASW,UAAUA,CAACT,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACFI,YAAY,CAACQ,OAAO,CAClBb,QAAQ,CAACC,QAAQ,CAAC,EAClBQ,IAAI,CAACK,SAAS,CAACX,MAAM,CAACI,IAAI,CAACQ,SAAS,CAAC,CAAC,CACxC,CAAC;EACH,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACf,QAAgB,EAAgB;EACjE,IAAI,CAACA,QAAQ,EAAE;IACb,MAAM,IAAIgB,KAAK,CAAC,mDAAmD,CAAC;EACtE;EACA,MAAMd,MAAM,GAAG,IAAAe,iBAAY,EAAC;IAC1BX,IAAI,EAAE,IAAAY,kBAAa,EAAC;MAAElB;IAAS,CAAC;EAClC,CAAC,CAAyB;EAE1B,OAAQ,OAAOmB,KAAwB,EAAEC,IAAkB,KAAK;IAC9DnB,UAAU,CAACC,MAAM,EAAEF,QAAQ,CAAC;IAC5B,MAAMqB,GAAG,GAAG,MAAMnB,MAAM,CAACoB,aAAa,CAACH,KAAK,EAAEC,IAAI,CAAC;IACnDT,UAAU,CAACT,MAAM,EAAEF,QAAQ,CAAC;IAC5B,OAAOqB,GAAG;EACZ,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_sdk","require","TOKEN_CACHE_KEY_PREFIX","tokenKey","clientId","loadTokens","client","raw","localStorage","getItem","auth","setTokens","JSON","parse","removeItem","saveTokens","setItem","stringify","getTokens","createWixAuthFetch","Error","createClient","OAuthStrategy","input","init","res","fetchWithAuth"],"sources":["../../../src/client/wixAuthFetch.ts"],"sourcesContent":["/**\n * Wix-authenticated `fetch` for Web5 BE calls from a host (third-party) origin.\n *\n * `wixapis.com`'s `/wix-assistant-web5/v1/turn` endpoint refuses\n * cross-origin anonymous calls (HTTP 500) — the only auth path that survives\n * CORS from a host (e.g. Shopify) origin is `@wix/sdk`'s `OAuthStrategy`, which\n * supplies the `Authorization` header the BE allowlists.\n *\n * Shared by every embed bundle that talks to the turn endpoint — the\n * placement bundle and the input-widget chip generator — so they all attach\n * the same token. Token caching uses the same `localStorage` key format\n * (`web5_tokens_<clientId>`) as `web50-server-ui`'s token cache, so the loader,\n * full app, placement, and input widget share one OAuth token instead of each\n * burning a `/oauth2/token` round-trip per page load.\n */\nimport { createClient, OAuthStrategy } from '@wix/sdk';\n\nconst TOKEN_CACHE_KEY_PREFIX = 'web5_tokens_';\n\ninterface SdkClient {\n fetchWithAuth: typeof fetch;\n auth: {\n setTokens: (tokens: unknown) => void;\n getTokens: () => unknown;\n };\n}\n\nfunction tokenKey(clientId: string): string {\n return `${TOKEN_CACHE_KEY_PREFIX}${clientId}`;\n}\n\nfunction loadTokens(client: SdkClient, clientId: string): void {\n try {\n const raw = localStorage.getItem(tokenKey(clientId));\n if (!raw) return;\n client.auth.setTokens(JSON.parse(raw));\n } catch {\n try {\n localStorage.removeItem(tokenKey(clientId));\n } catch {\n /* ignore */\n }\n }\n}\n\nfunction saveTokens(client: SdkClient, clientId: string): void {\n try {\n localStorage.setItem(\n tokenKey(clientId),\n JSON.stringify(client.auth.getTokens()),\n );\n } catch {\n // privacy mode / quota — in-memory token still works for this session\n }\n}\n\n/**\n * Build a `fetch`-shaped function pre-bound to the given Wix client id. The\n * returned value is drop-in compatible with any `fetchImpl` option\n * (`placementFetch`, `fetchContextualChips`, …).\n *\n * Each call loads cached tokens before the request, then saves the (possibly\n * refreshed) tokens after the response headers arrive — we deliberately do NOT\n * wait for the streaming body; the SDK's refresh runs alongside the stream and\n * the saved tokens benefit subsequent calls.\n */\nexport function createWixAuthFetch(clientId: string): typeof fetch {\n if (!clientId) {\n throw new Error('[web5-core] createWixAuthFetch: clientId is empty');\n }\n const client = createClient({\n auth: OAuthStrategy({ clientId }),\n }) as unknown as SdkClient;\n\n return (async (input: RequestInfo | URL, init?: RequestInit) => {\n loadTokens(client, clientId);\n const res = await client.fetchWithAuth(input, init);\n saveTokens(client, clientId);\n return res;\n }) as typeof fetch;\n}\n"],"mappings":";;;;AAeA,IAAAA,IAAA,GAAAC,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAMC,sBAAsB,GAAG,cAAc;AAU7C,SAASC,QAAQA,CAACC,QAAgB,EAAU;EAC1C,OAAO,GAAGF,sBAAsB,GAAGE,QAAQ,EAAE;AAC/C;AAEA,SAASC,UAAUA,CAACC,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACF,MAAMG,GAAG,GAAGC,YAAY,CAACC,OAAO,CAACN,QAAQ,CAACC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAACG,GAAG,EAAE;IACVD,MAAM,CAACI,IAAI,CAACC,SAAS,CAACC,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC;EACxC,CAAC,CAAC,MAAM;IACN,IAAI;MACFC,YAAY,CAACM,UAAU,CAACX,QAAQ,CAACC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;AACF;AAEA,SAASW,UAAUA,CAACT,MAAiB,EAAEF,QAAgB,EAAQ;EAC7D,IAAI;IACFI,YAAY,CAACQ,OAAO,CAClBb,QAAQ,CAACC,QAAQ,CAAC,EAClBQ,IAAI,CAACK,SAAS,CAACX,MAAM,CAACI,IAAI,CAACQ,SAAS,CAAC,CAAC,CACxC,CAAC;EACH,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACf,QAAgB,EAAgB;EACjE,IAAI,CAACA,QAAQ,EAAE;IACb,MAAM,IAAIgB,KAAK,CAAC,mDAAmD,CAAC;EACtE;EACA,MAAMd,MAAM,GAAG,IAAAe,iBAAY,EAAC;IAC1BX,IAAI,EAAE,IAAAY,kBAAa,EAAC;MAAElB;IAAS,CAAC;EAClC,CAAC,CAAyB;EAE1B,OAAQ,OAAOmB,KAAwB,EAAEC,IAAkB,KAAK;IAC9DnB,UAAU,CAACC,MAAM,EAAEF,QAAQ,CAAC;IAC5B,MAAMqB,GAAG,GAAG,MAAMnB,MAAM,CAACoB,aAAa,CAACH,KAAK,EAAEC,IAAI,CAAC;IACnDT,UAAU,CAACT,MAAM,EAAEF,QAAQ,CAAC;IAC5B,OAAOqB,GAAG;EACZ,CAAC;AACH","ignoreList":[]}
@@ -23,10 +23,14 @@ class HeroEntitySectionDefinition {
23
23
  (0, _defineProperty2.default)(this, "sectionType", 'hero-entity');
24
24
  (0, _defineProperty2.default)(this, "singleInstance", true);
25
25
  (0, _defineProperty2.default)(this, "patterns", [
26
+ // Leading slots mirror HeroSectionDefinition: section descriptor, then the
27
+ // optional leading ECHO callout, then an optional h3 badge, then the h1.
28
+ // Callout and badge are independent; the second `html_comment?` preserves the
29
+ // legacy callout-before-descriptor ordering for pages saved before this change.
26
30
  // Entity links carried as list items (the canonical shape).
27
- 'html_comment? > (h3 | callout)? > html_comment? > h1 > (image | t | link)* > list{item[1-]:link[entityType] > image? > (t | callout)*}',
31
+ 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t | link)* > list{item[1-]:link[entityType] > image? > (t | callout)*}',
28
32
  // Entity links sitting at the top level of the hero body.
29
- 'html_comment? > (h3 | callout)? > html_comment? > h1 > (image | t)* > (link[entityType] > image? > (t | callout)*)[1-] > list?']);
33
+ 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t)* > (link[entityType] > image? > (t | callout)*)[1-] > list?']);
30
34
  (0, _defineProperty2.default)(this, "defaults", {
31
35
  headline: 'Featured collection',
32
36
  content: 'Explore the highlights from this collection.',
@@ -45,27 +49,27 @@ class HeroEntitySectionDefinition {
45
49
  ![Nike Life collection](web5://image/Nike+Life+collection)
46
50
  Nike offerings span performance and lifestyle lines.
47
51
 
48
- * [Nike Throwback Future Collection](web5://entity/CMS_web5_ecom_articles/WAyuiC63OSjwpvnOyZcblQ)
49
- * [Nike Life Cable Knit Turtleneck Sweater](web5://entity/CMS_web5_ecom_products/ZDvHxsa3IJA8CyGX8BNpdw)
50
- * [Nike x Jacquemus NRG HE Swoosh Hoodie](web5://entity/CMS_web5_ecom_products/qH2lqINGneHWYVZzzGnXTA)`,
52
+ * [Nike Throwback Future Collection](web5://entity/article/WAyuiC63OSjwpvnOyZcblQ)
53
+ * [Nike Life Cable Knit Turtleneck Sweater](web5://entity/product/ZDvHxsa3IJA8CyGX8BNpdw)
54
+ * [Nike x Jacquemus NRG HE Swoosh Hoodie](web5://entity/product/qH2lqINGneHWYVZzzGnXTA)`,
51
55
  expected: {
52
56
  headline: 'Nike collections',
53
57
  content: 'Nike offerings span performance and lifestyle lines.',
54
58
  image: 'web5://image/Nike+Life+collection',
55
59
  items: [{
56
60
  entityId: 'WAyuiC63OSjwpvnOyZcblQ',
57
- entityType: 'CMS_web5_ecom_articles',
58
- entityUrl: 'web5://entity/CMS_web5_ecom_articles/WAyuiC63OSjwpvnOyZcblQ',
61
+ entityType: 'article',
62
+ entityUrl: 'web5://entity/article/WAyuiC63OSjwpvnOyZcblQ',
59
63
  linkText: 'Nike Throwback Future Collection'
60
64
  }, {
61
65
  entityId: 'ZDvHxsa3IJA8CyGX8BNpdw',
62
- entityType: 'CMS_web5_ecom_products',
63
- entityUrl: 'web5://entity/CMS_web5_ecom_products/ZDvHxsa3IJA8CyGX8BNpdw',
66
+ entityType: 'product',
67
+ entityUrl: 'web5://entity/product/ZDvHxsa3IJA8CyGX8BNpdw',
64
68
  linkText: 'Nike Life Cable Knit Turtleneck Sweater'
65
69
  }, {
66
70
  entityId: 'qH2lqINGneHWYVZzzGnXTA',
67
- entityType: 'CMS_web5_ecom_products',
68
- entityUrl: 'web5://entity/CMS_web5_ecom_products/qH2lqINGneHWYVZzzGnXTA',
71
+ entityType: 'product',
72
+ entityUrl: 'web5://entity/product/qH2lqINGneHWYVZzzGnXTA',
69
73
  linkText: 'Nike x Jacquemus NRG HE Swoosh Hoodie'
70
74
  }]
71
75
  }
@@ -88,10 +92,11 @@ Nike offerings span performance and lifestyle lines.
88
92
  callout: e.callout
89
93
  }));
90
94
 
91
- // Only a leading callout (before the h1) is part of the hero now, mirroring
92
- // HeroSectionDefinition. A trailing callout falls through to a downstream
93
- // callout section. (Per-item callouts inside the entity list are handled by
94
- // extractEntityRefs above and are unaffected.)
95
+ // The leading callout before the h1 the ECHO the orchestrator emits as the
96
+ // hero's opening line, right after the section descriptor — is part of the
97
+ // hero, mirroring HeroSectionDefinition. A trailing callout falls through to a
98
+ // downstream callout section. (Per-item callouts inside the entity list are
99
+ // handled by extractEntityRefs above and are unaffected.)
95
100
  const h1Index = parts.findIndex(p => {
96
101
  var _p$meta;
97
102
  return p.type === 'heading' && ((_p$meta = p.meta) == null ? void 0 : _p$meta.level) === 1;
@@ -1 +1 @@
1
- {"version":3,"names":["_parseUtils","require","_parts","_diagnosticTypes","HeroEntitySectionDefinition","constructor","_defineProperty2","default","headline","content","items","entityId","entityType","entityUrl","linkText","markdown","expected","image","parse","parts","context","entityRefs","extractEntityRefs","length","reportDiagnostic","DIAGNOSTIC_TYPES","SECTION_REJECTED","map","e","undefined","description","imageUrl","markdownImageUrl","callout","h1Index","findIndex","p","_p$meta","type","meta","level","blockquotes","getPartsByType","leadingQuote","bq","_bq$meta","_bq$content","bqIndex","indexOf","raw","trim","parseCalloutTag","text","headingText","badge","bodyText","firstImageSrc","exports"],"sources":["../../../../src/component/componentDefinitions/HeroEntitySectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n bodyText,\n firstImageSrc,\n parseCalloutTag,\n extractEntityRefs,\n} from './parse-utils';\nimport type { Part } from '../../parts/parts';\nimport { getPartsByType } from '../../parts/parts';\nimport type {\n EntityItem,\n HeroEntityCompProps,\n HeroEntitySectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition, ParseContext } from '../section-definition';\nimport { DIAGNOSTIC_TYPES } from '../diagnosticTypes';\n\n/**\n * Hero section whose body carries one or more web5 entity links\n * (`web5://entity/...`). It mirrors the framing of {@link HeroSectionDefinition}\n * (leading callout, h1, image, intro text) but, instead of turning the links\n * into CTA buttons, surfaces them as resolvable entities.\n *\n * Registered ahead of `HeroSectionDefinition` so an entity-bearing hero is\n * claimed here first. The pattern requires at least one `link[entityType]`, and\n * `parse()` returns `null` when no entity refs are found, letting a plain hero\n * fall through to `HeroSectionDefinition`.\n */\nexport class HeroEntitySectionDefinition\n implements SectionDefinition<HeroEntitySectionComponent>\n{\n sectionType = 'hero-entity' as const;\n singleInstance = true;\n patterns = [\n // Entity links carried as list items (the canonical shape).\n 'html_comment? > (h3 | callout)? > html_comment? > h1 > (image | t | link)* > list{item[1-]:link[entityType] > image? > (t | callout)*}',\n // Entity links sitting at the top level of the hero body.\n 'html_comment? > (h3 | callout)? > html_comment? > h1 > (image | t)* > (link[entityType] > image? > (t | callout)*)[1-] > list?',\n ];\n\n defaults: HeroEntityCompProps = {\n headline: 'Featured collection',\n content: 'Explore the highlights from this collection.',\n items: [\n {\n entityId: 'example-1',\n entityType: 'product',\n entityUrl: 'web5://entity/product/example-1',\n linkText: 'Example product',\n },\n ],\n };\n\n fixtures: SectionFixture<HeroEntityCompProps>[] = [\n {\n markdown: `<!-- section:hero, id:hero, semantic:hero -->\n\n# **Nike** collections\n\n![Nike Life collection](web5://image/Nike+Life+collection)\nNike offerings span performance and lifestyle lines.\n\n* [Nike Throwback Future Collection](web5://entity/CMS_web5_ecom_articles/WAyuiC63OSjwpvnOyZcblQ)\n* [Nike Life Cable Knit Turtleneck Sweater](web5://entity/CMS_web5_ecom_products/ZDvHxsa3IJA8CyGX8BNpdw)\n* [Nike x Jacquemus NRG HE Swoosh Hoodie](web5://entity/CMS_web5_ecom_products/qH2lqINGneHWYVZzzGnXTA)`,\n expected: {\n headline: 'Nike collections',\n content: 'Nike offerings span performance and lifestyle lines.',\n image: 'web5://image/Nike+Life+collection',\n items: [\n {\n entityId: 'WAyuiC63OSjwpvnOyZcblQ',\n entityType: 'CMS_web5_ecom_articles',\n entityUrl:\n 'web5://entity/CMS_web5_ecom_articles/WAyuiC63OSjwpvnOyZcblQ',\n linkText: 'Nike Throwback Future Collection',\n },\n {\n entityId: 'ZDvHxsa3IJA8CyGX8BNpdw',\n entityType: 'CMS_web5_ecom_products',\n entityUrl:\n 'web5://entity/CMS_web5_ecom_products/ZDvHxsa3IJA8CyGX8BNpdw',\n linkText: 'Nike Life Cable Knit Turtleneck Sweater',\n },\n {\n entityId: 'qH2lqINGneHWYVZzzGnXTA',\n entityType: 'CMS_web5_ecom_products',\n entityUrl:\n 'web5://entity/CMS_web5_ecom_products/qH2lqINGneHWYVZzzGnXTA',\n linkText: 'Nike x Jacquemus NRG HE Swoosh Hoodie',\n },\n ],\n },\n },\n ];\n\n parse(parts: Part[], context?: ParseContext): HeroEntityCompProps | null {\n const entityRefs = extractEntityRefs(parts);\n\n if (entityRefs.length === 0) {\n // Not an entity hero — let HeroSectionDefinition claim it.\n context?.reportDiagnostic?.(\n DIAGNOSTIC_TYPES.SECTION_REJECTED,\n 'hero-entity: no entity links found',\n );\n return null;\n }\n\n const items: EntityItem[] = entityRefs.map((e) => ({\n entityId: e.entityId,\n entityType: e.entityType,\n entityUrl: e.entityUrl,\n linkText: e.linkText || undefined,\n description: e.description || undefined,\n imageUrl: e.markdownImageUrl,\n callout: e.callout,\n }));\n\n // Only a leading callout (before the h1) is part of the hero now, mirroring\n // HeroSectionDefinition. A trailing callout falls through to a downstream\n // callout section. (Per-item callouts inside the entity list are handled by\n // extractEntityRefs above and are unaffected.)\n const h1Index = parts.findIndex(\n (p) =>\n p.type === 'heading' && (p.meta as { level?: number })?.level === 1,\n );\n const blockquotes = getPartsByType<Part>(parts, 'callout');\n let leadingQuote: string | undefined;\n\n for (const bq of blockquotes) {\n const bqIndex = parts.indexOf(bq);\n if (h1Index >= 0 && bqIndex > h1Index) {\n continue;\n }\n const raw = (bq.meta?.markdown as string)?.trim() || bq.content?.trim();\n if (!raw) {\n continue;\n }\n leadingQuote = parseCalloutTag(raw).text || undefined;\n }\n\n return {\n headline: headingText(parts, 1),\n badge: headingText(parts, 3) || undefined,\n content: bodyText(parts) || undefined,\n image: firstImageSrc(parts),\n leadingQuote,\n items,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,gBAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,2BAA2B,CAExC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,aAAa;IAAA,IAAAD,gBAAA,CAAAC,OAAA,0BACV,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACV;IACT;IACA,wIAAwI;IACxI;IACA,gIAAgI,CACjI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAE+B;MAC9BC,QAAQ,EAAE,qBAAqB;MAC/BC,OAAO,EAAE,8CAA8C;MACvDC,KAAK,EAAE,CACL;QACEC,QAAQ,EAAE,WAAW;QACrBC,UAAU,EAAE,SAAS;QACrBC,SAAS,EAAE,iCAAiC;QAC5CC,QAAQ,EAAE;MACZ,CAAC;IAEL,CAAC;IAAA,IAAAR,gBAAA,CAAAC,OAAA,oBAEiD,CAChD;MACEQ,QAAQ,EAAE;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uGAAuG;MACjGC,QAAQ,EAAE;QACRR,QAAQ,EAAE,kBAAkB;QAC5BC,OAAO,EAAE,sDAAsD;QAC/DQ,KAAK,EAAE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EntitySectionDefinition","constructor","_defineProperty2","default","headline","content","items","entityId","entityType","entityUrl","linkText","markdown","expected","image","parse","parts","context","entityRefs","extractEntityRefs","length","reportDiagnostic","DIAGNOSTIC_TYPES","SECTION_REJECTED","map","e","undefined","description","imageUrl","markdownImageUrl","callout","h1Index","findIndex","p","_p$meta","type","meta","level","blockquotes","getPartsByType","leadingQuote","bq","_bq$meta","_bq$content","bqIndex","indexOf","raw","trim","parseCalloutTag","text","headingText","badge","bodyText","firstImageSrc","exports"],"sources":["../../../../src/component/componentDefinitions/HeroEntitySectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n bodyText,\n firstImageSrc,\n parseCalloutTag,\n extractEntityRefs,\n} from './parse-utils';\nimport type { Part } from '../../parts/parts';\nimport { getPartsByType } from '../../parts/parts';\nimport type {\n EntityItem,\n HeroEntityCompProps,\n HeroEntitySectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition, ParseContext } from '../section-definition';\nimport { DIAGNOSTIC_TYPES } from '../diagnosticTypes';\n\n/**\n * Hero section whose body carries one or more web5 entity links\n * (`web5://entity/...`). It mirrors the framing of {@link HeroSectionDefinition}\n * (leading callout, h1, image, intro text) but, instead of turning the links\n * into CTA buttons, surfaces them as resolvable entities.\n *\n * Registered ahead of `HeroSectionDefinition` so an entity-bearing hero is\n * claimed here first. The pattern requires at least one `link[entityType]`, and\n * `parse()` returns `null` when no entity refs are found, letting a plain hero\n * fall through to `HeroSectionDefinition`.\n */\nexport class HeroEntitySectionDefinition\n implements SectionDefinition<HeroEntitySectionComponent>\n{\n sectionType = 'hero-entity' as const;\n singleInstance = true;\n patterns = [\n // Leading slots mirror HeroSectionDefinition: section descriptor, then the\n // optional leading ECHO callout, then an optional h3 badge, then the h1.\n // Callout and badge are independent; the second `html_comment?` preserves the\n // legacy callout-before-descriptor ordering for pages saved before this change.\n // Entity links carried as list items (the canonical shape).\n 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t | link)* > list{item[1-]:link[entityType] > image? > (t | callout)*}',\n // Entity links sitting at the top level of the hero body.\n 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t)* > (link[entityType] > image? > (t | callout)*)[1-] > list?',\n ];\n\n defaults: HeroEntityCompProps = {\n headline: 'Featured collection',\n content: 'Explore the highlights from this collection.',\n items: [\n {\n entityId: 'example-1',\n entityType: 'product',\n entityUrl: 'web5://entity/product/example-1',\n linkText: 'Example product',\n },\n ],\n };\n\n fixtures: SectionFixture<HeroEntityCompProps>[] = [\n {\n markdown: `<!-- section:hero, id:hero, semantic:hero -->\n\n# **Nike** collections\n\n![Nike Life collection](web5://image/Nike+Life+collection)\nNike offerings span performance and lifestyle lines.\n\n* [Nike Throwback Future Collection](web5://entity/article/WAyuiC63OSjwpvnOyZcblQ)\n* [Nike Life Cable Knit Turtleneck Sweater](web5://entity/product/ZDvHxsa3IJA8CyGX8BNpdw)\n* [Nike x Jacquemus NRG HE Swoosh Hoodie](web5://entity/product/qH2lqINGneHWYVZzzGnXTA)`,\n expected: {\n headline: 'Nike collections',\n content: 'Nike offerings span performance and lifestyle lines.',\n image: 'web5://image/Nike+Life+collection',\n items: [\n {\n entityId: 'WAyuiC63OSjwpvnOyZcblQ',\n entityType: 'article',\n entityUrl:\n 'web5://entity/article/WAyuiC63OSjwpvnOyZcblQ',\n linkText: 'Nike Throwback Future Collection',\n },\n {\n entityId: 'ZDvHxsa3IJA8CyGX8BNpdw',\n entityType: 'product',\n entityUrl:\n 'web5://entity/product/ZDvHxsa3IJA8CyGX8BNpdw',\n linkText: 'Nike Life Cable Knit Turtleneck Sweater',\n },\n {\n entityId: 'qH2lqINGneHWYVZzzGnXTA',\n entityType: 'product',\n entityUrl:\n 'web5://entity/product/qH2lqINGneHWYVZzzGnXTA',\n linkText: 'Nike x Jacquemus NRG HE Swoosh Hoodie',\n },\n ],\n },\n },\n ];\n\n parse(parts: Part[], context?: ParseContext): HeroEntityCompProps | null {\n const entityRefs = extractEntityRefs(parts);\n\n if (entityRefs.length === 0) {\n // Not an entity hero — let HeroSectionDefinition claim it.\n context?.reportDiagnostic?.(\n DIAGNOSTIC_TYPES.SECTION_REJECTED,\n 'hero-entity: no entity links found',\n );\n return null;\n }\n\n const items: EntityItem[] = entityRefs.map((e) => ({\n entityId: e.entityId,\n entityType: e.entityType,\n entityUrl: e.entityUrl,\n linkText: e.linkText || undefined,\n description: e.description || undefined,\n imageUrl: e.markdownImageUrl,\n callout: e.callout,\n }));\n\n // The leading callout before the h1 the ECHO the orchestrator emits as the\n // hero's opening line, right after the section descriptor — is part of the\n // hero, mirroring HeroSectionDefinition. A trailing callout falls through to a\n // downstream callout section. (Per-item callouts inside the entity list are\n // handled by extractEntityRefs above and are unaffected.)\n const h1Index = parts.findIndex(\n (p) =>\n p.type === 'heading' && (p.meta as { level?: number })?.level === 1,\n );\n const blockquotes = getPartsByType<Part>(parts, 'callout');\n let leadingQuote: string | undefined;\n\n for (const bq of blockquotes) {\n const bqIndex = parts.indexOf(bq);\n if (h1Index >= 0 && bqIndex > h1Index) {\n continue;\n }\n const raw = (bq.meta?.markdown as string)?.trim() || bq.content?.trim();\n if (!raw) {\n continue;\n }\n leadingQuote = parseCalloutTag(raw).text || undefined;\n }\n\n return {\n headline: headingText(parts, 1),\n badge: headingText(parts, 3) || undefined,\n content: bodyText(parts) || undefined,\n image: firstImageSrc(parts),\n leadingQuote,\n items,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,gBAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,2BAA2B,CAExC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,aAAa;IAAA,IAAAD,gBAAA,CAAAC,OAAA,0BACV,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACV;IACT;IACA;IACA;IACA;IACA;IACA,uIAAuI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BAAe,EAACF,GAAG,CAAC,CAACG,IAAI,IAAIvB,SAAS;IACvD;IAEA,OAAO;MACLrB,QAAQ,EAAE,IAAA6C,uBAAW,EAAClC,KAAK,EAAE,CAAC,CAAC;MAC/BmC,KAAK,EAAE,IAAAD,uBAAW,EAAClC,KAAK,EAAE,CAAC,CAAC,IAAIU,SAAS;MACzCpB,OAAO,EAAE,IAAA8C,oBAAQ,EAACpC,KAAK,CAAC,IAAIU,SAAS;MACrCZ,KAAK,EAAE,IAAAuC,yBAAa,EAACrC,KAAK,CAAC;MAC3BwB,YAAY;MACZjC;IACF,CAAC;EACH;AACF;AAAC+C,OAAA,CAAArD,2BAAA,GAAAA,2BAAA","ignoreList":[]}
@@ -10,7 +10,14 @@ class HeroSectionDefinition {
10
10
  constructor() {
11
11
  (0, _defineProperty2.default)(this, "sectionType", 'hero');
12
12
  (0, _defineProperty2.default)(this, "singleInstance", true);
13
- (0, _defineProperty2.default)(this, "patterns", ['html_comment? > (h3 | callout)? > html_comment? > h1 > (image | t | link)* > list?']);
13
+ (0, _defineProperty2.default)(this, "patterns", [
14
+ // Canonical hero shape: section descriptor, then the leading ECHO callout
15
+ // (optional in the grammar — the orchestrator always emits it, but a missing
16
+ // ECHO must not stop the hero from rendering), then an optional h3 badge,
17
+ // then the h1. The callout and badge are independent slots so a hero can
18
+ // carry both. The second `html_comment?` keeps the legacy ordering
19
+ // (callout before the descriptor) matching for pages saved before this change.
20
+ 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t | link)* > list?']);
14
21
  (0, _defineProperty2.default)(this, "defaults", {
15
22
  headline: 'Build something amazing',
16
23
  content: 'Your platform for data-driven decisions.',
@@ -173,9 +180,10 @@ Get started today with our amazing features.
173
180
  }
174
181
  }
175
182
 
176
- // The hero only claims a leading blockquote (before the h1). A trailing
177
- // blockquote is no longer part of the hero pattern, so it falls through to
178
- // a downstream callout section instead.
183
+ // The hero claims the leading callout before the h1 the ECHO the
184
+ // orchestrator emits as the hero's opening line, right after the section
185
+ // descriptor. A trailing blockquote is not part of the hero pattern, so it
186
+ // falls through to a downstream callout section instead.
179
187
  const h1Index = parts.findIndex(p => {
180
188
  var _p$meta;
181
189
  return p.type === 'heading' && ((_p$meta = p.meta) == null ? void 0 : _p$meta.level) === 1;
@@ -1 +1 @@
1
- {"version":3,"names":["_parseUtils","require","_parts","HeroSectionDefinition","constructor","_defineProperty2","default","headline","content","buttons","id","text","variant","markdown","expected","onClick","image","parse","parts","firstImageSrc","lists","getPartsByType","list","item","_list$meta","meta","items","_item$meta","itemParts","nestedImage","buttonIndex","getLinks","map","l","i","_l$content","trim","href","length","trailingList","filteredItems","_list$meta2","_item$meta2","hasImage","some","p","type","push","allItemsAreLinks","listLinks","_item$meta3","_itemLinkParts$0$cont","itemLinkParts","filter","allText","extractListItemText","linkTexts","_l$content2","join","link","isFirstButton","lines","_item$meta4","h1Index","findIndex","_p$meta","level","blockquotes","leadingQuote","bq","_bq$meta","_bq$content","bqIndex","indexOf","raw","parseCalloutTag","undefined","headingText","badge","bodyText","exports"],"sources":["../../../../src/component/componentDefinitions/HeroSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n bodyText,\n firstImageSrc,\n parseCalloutTag,\n extractListItemText,\n} from './parse-utils';\nimport type { Part, ListPart, LinkPart, ListItemPart } from '../../parts/parts';\nimport { getPartsByType, getLinks } from '../../parts/parts';\nimport type {\n HeroButton,\n HeroCompProps,\n HeroSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\nexport class HeroSectionDefinition\n implements SectionDefinition<HeroSectionComponent>\n{\n sectionType = 'hero' as const;\n singleInstance = true;\n patterns = [\n 'html_comment? > (h3 | callout)? > html_comment? > h1 > (image | t | link)* > list?',\n ];\n\n defaults: HeroCompProps = {\n headline: 'Build something amazing',\n content: 'Your platform for data-driven decisions.',\n buttons: [{ id: 'btn-0', text: 'Get started', variant: 'primary' }],\n };\n\n fixtures: SectionFixture<HeroCompProps>[] = [\n {\n markdown:\n '# Welcome\\n\\nBuild amazing things.\\n\\n[Get Started](/) [Learn More](/about)',\n expected: {\n headline: 'Welcome',\n content: 'Build amazing things.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n },\n },\n {\n markdown: `<!-- Hero Section -->\n\n# Welcome to Our Platform\n\n![Hero Image](hero.jpg)\n\nGet started today with our amazing features.\n\n[Get Started](/signup) [Learn More](/about)`,\n expected: {\n headline: 'Welcome to Our Platform',\n content: 'Get started today with our amazing features.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/signup',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n image: 'hero.jpg',\n },\n },\n ];\n\n parse(parts: Part[]): HeroCompProps {\n let image = firstImageSrc(parts);\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n if (!image) {\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const nestedImage = firstImageSrc(itemParts);\n if (nestedImage) {\n image = nestedImage;\n break;\n }\n }\n if (image) {\n break;\n }\n }\n }\n\n // Start with top-level links as buttons\n let buttonIndex = 0;\n const buttons: HeroButton[] = getLinks(parts).map(\n (l, i): HeroButton => ({\n id: `btn-${i}`,\n text: l.content?.trim() || 'Learn more',\n variant: i === 0 ? 'primary' : 'secondary',\n onClick: l.meta.href,\n }),\n );\n buttonIndex = buttons.length;\n\n // Process lists: filter out image-only items, then check if remaining\n // items are all link-only. If so, convert to buttons; otherwise keep as trailingList.\n let trailingList: string | undefined;\n if (lists.length > 0) {\n for (const list of lists) {\n // Filter out image-only items\n const filteredItems: ListItemPart[] = [];\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const hasImage = itemParts.some((p) => p.type === 'image');\n if (hasImage) {\n continue;\n }\n filteredItems.push(item);\n }\n\n if (filteredItems.length === 0) {\n continue;\n }\n\n // Check if ALL remaining items contain only links (no other text)\n let allItemsAreLinks = true;\n const listLinks: { text: string; href: string }[] = [];\n\n for (const item of filteredItems) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const itemLinkParts = itemParts.filter(\n (p): p is LinkPart => p.type === 'link',\n );\n\n if (itemLinkParts.length === 0) {\n allItemsAreLinks = false;\n break;\n }\n\n // Check if the item text is entirely link text (no extra content)\n const allText = extractListItemText(item).trim();\n const linkTexts = itemLinkParts\n .map((l) => l.content?.trim() || '')\n .join(' ')\n .trim();\n\n if (allText !== linkTexts) {\n allItemsAreLinks = false;\n break;\n }\n\n listLinks.push({\n text: itemLinkParts[0].content?.trim() || 'Learn more',\n href: itemLinkParts[0].meta.href,\n });\n }\n\n if (allItemsAreLinks && listLinks.length > 0) {\n // Convert link-only list items to buttons\n for (const link of listLinks) {\n const isFirstButton = buttons.length === 0;\n buttons.push({\n id: `btn-${buttonIndex++}`,\n text: link.text,\n variant: isFirstButton ? 'primary' : 'secondary',\n onClick: link.href,\n });\n }\n } else {\n // Keep as trailing list markdown\n const lines: string[] = [];\n for (const item of filteredItems) {\n const text =\n (item.meta?.markdown as string) || extractListItemText(item);\n if (text) {\n lines.push(`- ${text}`);\n }\n }\n if (lines.length > 0) {\n trailingList = lines.join('\\n');\n }\n }\n }\n }\n\n // The hero only claims a leading blockquote (before the h1). A trailing\n // blockquote is no longer part of the hero pattern, so it falls through to\n // a downstream callout section instead.\n const h1Index = parts.findIndex(\n (p) => p.type === 'heading' && (p.meta as { level: number })?.level === 1,\n );\n const blockquotes = getPartsByType<Part>(parts, 'callout');\n let leadingQuote: string | undefined;\n\n for (const bq of blockquotes) {\n const bqIndex = parts.indexOf(bq);\n if (h1Index >= 0 && bqIndex > h1Index) {\n continue;\n }\n const raw = (bq.meta?.markdown as string)?.trim() || bq.content?.trim();\n if (!raw) {\n continue;\n }\n leadingQuote = parseCalloutTag(raw).text || undefined;\n }\n\n return {\n headline: headingText(parts, 1),\n badge: headingText(parts, 3) || undefined,\n content: bodyText(parts) || undefined,\n buttons: buttons.length > 0 ? buttons : undefined,\n image,\n trailingList,\n leadingQuote,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AASO,MAAME,qBAAqB,CAElC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,MAAM;IAAA,IAAAD,gBAAA,CAAAC,OAAA,0BACH,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACV,CACT,oFAAoF,CACrF;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAEyB;MACxBC,QAAQ,EAAE,yBAAyB;MACnCC,OAAO,EAAE,0CAA0C;MACnDC,OAAO,EAAE,CAAC;QAAEC,EAAE,EAAE,OAAO;QAAEC,IAAI,EAAE,aAAa;QAAEC,OAAO,EAAE;MAAU,CAAC;IACpE,CAAC;IAAA,IAAAP,gBAAA,CAAAC,OAAA,oBAE2C,CAC1C;MACEO,QAAQ,EACN,6EAA6E;MAC/EC,QAAQ,EAAE;QACRP,QAAQ,EAAE,SAAS;QACnBC,OAAO,EAAE,uBAAuB;QAChCC,OAAO,EAAE,CACP;UACEC,EAAE,EAAE,OAAO;UACXC,IAAI,EAAE,aAAa;UACnBC,OAAO,EAAE,SAAS;UAClBG,OAAO,EAAE;QACX,CAAC,EACD;UACEL,EAAE,EAAE,OAAO;UACXC,IAAI,EAAE,YAAY;UAClBC,OAAO,EAAE,WAAW;UACpBG,OAAO,EAAE;QACX,CAAC;MAEL;IACF,CAAC,EACD;MACEF,QAAQ,EAAE;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C;MACtCC,QAAQ,EAAE;QACRP,QAAQ,EAAE,yBAAyB;QACnCC,OAAO,EAAE,8CAA8C;QACvDC,OAAO,EAAE,CACP;U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C,IAAI,CAAC,CAAC;MACvE,IAAI,CAACsC,GAAG,EAAE;QACR;MACF;MACAN,YAAY,GAAG,IAAAO,2BAAe,EAACD,GAAG,CAAC,CAAC/D,IAAI,IAAIiE,SAAS;IACvD;IAEA,OAAO;MACLrE,QAAQ,EAAE,IAAAsE,uBAAW,EAAC3D,KAAK,EAAE,CAAC,CAAC;MAC/B4D,KAAK,EAAE,IAAAD,uBAAW,EAAC3D,KAAK,EAAE,CAAC,CAAC,IAAI0D,SAAS;MACzCpE,OAAO,EAAE,IAAAuE,oBAAQ,EAAC7D,KAAK,CAAC,IAAI0D,SAAS;MACrCnE,OAAO,EAAEA,OAAO,CAAC6B,MAAM,GAAG,CAAC,GAAG7B,OAAO,GAAGmE,SAAS;MACjD5D,KAAK;MACLuB,YAAY;MACZ6B;IACF,CAAC;EACH;AACF;AAACY,OAAA,CAAA7E,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_parseUtils","require","_parts","HeroSectionDefinition","constructor","_defineProperty2","default","headline","content","buttons","id","text","variant","markdown","expected","onClick","image","parse","parts","firstImageSrc","lists","getPartsByType","list","item","_list$meta","meta","items","_item$meta","itemParts","nestedImage","buttonIndex","getLinks","map","l","i","_l$content","trim","href","length","trailingList","filteredItems","_list$meta2","_item$meta2","hasImage","some","p","type","push","allItemsAreLinks","listLinks","_item$meta3","_itemLinkParts$0$cont","itemLinkParts","filter","allText","extractListItemText","linkTexts","_l$content2","join","link","isFirstButton","lines","_item$meta4","h1Index","findIndex","_p$meta","level","blockquotes","leadingQuote","bq","_bq$meta","_bq$content","bqIndex","indexOf","raw","parseCalloutTag","undefined","headingText","badge","bodyText","exports"],"sources":["../../../../src/component/componentDefinitions/HeroSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n bodyText,\n firstImageSrc,\n parseCalloutTag,\n extractListItemText,\n} from './parse-utils';\nimport type { Part, ListPart, LinkPart, ListItemPart } from '../../parts/parts';\nimport { getPartsByType, getLinks } from '../../parts/parts';\nimport type {\n HeroButton,\n HeroCompProps,\n HeroSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\nexport class HeroSectionDefinition\n implements SectionDefinition<HeroSectionComponent>\n{\n sectionType = 'hero' as const;\n singleInstance = true;\n patterns = [\n // Canonical hero shape: section descriptor, then the leading ECHO callout\n // (optional in the grammar — the orchestrator always emits it, but a missing\n // ECHO must not stop the hero from rendering), then an optional h3 badge,\n // then the h1. The callout and badge are independent slots so a hero can\n // carry both. The second `html_comment?` keeps the legacy ordering\n // (callout before the descriptor) matching for pages saved before this change.\n 'html_comment? > callout? > html_comment? > h3? > h1 > (image | t | link)* > list?',\n ];\n\n defaults: HeroCompProps = {\n headline: 'Build something amazing',\n content: 'Your platform for data-driven decisions.',\n buttons: [{ id: 'btn-0', text: 'Get started', variant: 'primary' }],\n };\n\n fixtures: SectionFixture<HeroCompProps>[] = [\n {\n markdown:\n '# Welcome\\n\\nBuild amazing things.\\n\\n[Get Started](/) [Learn More](/about)',\n expected: {\n headline: 'Welcome',\n content: 'Build amazing things.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n },\n },\n {\n markdown: `<!-- Hero Section -->\n\n# Welcome to Our Platform\n\n![Hero Image](hero.jpg)\n\nGet started today with our amazing features.\n\n[Get Started](/signup) [Learn More](/about)`,\n expected: {\n headline: 'Welcome to Our Platform',\n content: 'Get started today with our amazing features.',\n buttons: [\n {\n id: 'btn-0',\n text: 'Get Started',\n variant: 'primary',\n onClick: '/signup',\n },\n {\n id: 'btn-1',\n text: 'Learn More',\n variant: 'secondary',\n onClick: '/about',\n },\n ],\n image: 'hero.jpg',\n },\n },\n ];\n\n parse(parts: Part[]): HeroCompProps {\n let image = firstImageSrc(parts);\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n if (!image) {\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const nestedImage = firstImageSrc(itemParts);\n if (nestedImage) {\n image = nestedImage;\n break;\n }\n }\n if (image) {\n break;\n }\n }\n }\n\n // Start with top-level links as buttons\n let buttonIndex = 0;\n const buttons: HeroButton[] = getLinks(parts).map(\n (l, i): HeroButton => ({\n id: `btn-${i}`,\n text: l.content?.trim() || 'Learn more',\n variant: i === 0 ? 'primary' : 'secondary',\n onClick: l.meta.href,\n }),\n );\n buttonIndex = buttons.length;\n\n // Process lists: filter out image-only items, then check if remaining\n // items are all link-only. If so, convert to buttons; otherwise keep as trailingList.\n let trailingList: string | undefined;\n if (lists.length > 0) {\n for (const list of lists) {\n // Filter out image-only items\n const filteredItems: ListItemPart[] = [];\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const hasImage = itemParts.some((p) => p.type === 'image');\n if (hasImage) {\n continue;\n }\n filteredItems.push(item);\n }\n\n if (filteredItems.length === 0) {\n continue;\n }\n\n // Check if ALL remaining items contain only links (no other text)\n let allItemsAreLinks = true;\n const listLinks: { text: string; href: string }[] = [];\n\n for (const item of filteredItems) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const itemLinkParts = itemParts.filter(\n (p): p is LinkPart => p.type === 'link',\n );\n\n if (itemLinkParts.length === 0) {\n allItemsAreLinks = false;\n break;\n }\n\n // Check if the item text is entirely link text (no extra content)\n const allText = extractListItemText(item).trim();\n const linkTexts = itemLinkParts\n .map((l) => l.content?.trim() || '')\n .join(' ')\n .trim();\n\n if (allText !== linkTexts) {\n allItemsAreLinks = false;\n break;\n }\n\n listLinks.push({\n text: itemLinkParts[0].content?.trim() || 'Learn more',\n href: itemLinkParts[0].meta.href,\n });\n }\n\n if (allItemsAreLinks && listLinks.length > 0) {\n // Convert link-only list items to buttons\n for (const link of listLinks) {\n const isFirstButton = buttons.length === 0;\n buttons.push({\n id: `btn-${buttonIndex++}`,\n text: link.text,\n variant: isFirstButton ? 'primary' : 'secondary',\n onClick: link.href,\n });\n }\n } else {\n // Keep as trailing list markdown\n const lines: string[] = [];\n for (const item of filteredItems) {\n const text =\n (item.meta?.markdown as string) || extractListItemText(item);\n if (text) {\n lines.push(`- ${text}`);\n }\n }\n if (lines.length > 0) {\n trailingList = lines.join('\\n');\n }\n }\n }\n }\n\n // The hero claims the leading callout before the h1 — the ECHO the\n // orchestrator emits as the hero's opening line, right after the section\n // descriptor. A trailing blockquote is not part of the hero pattern, so it\n // falls through to a downstream callout section instead.\n const h1Index = parts.findIndex(\n (p) => p.type === 'heading' && (p.meta as { level: number })?.level === 1,\n );\n const blockquotes = getPartsByType<Part>(parts, 'callout');\n let leadingQuote: string | undefined;\n\n for (const bq of blockquotes) {\n const bqIndex = parts.indexOf(bq);\n if (h1Index >= 0 && bqIndex > h1Index) {\n continue;\n }\n const raw = (bq.meta?.markdown as string)?.trim() || bq.content?.trim();\n if (!raw) {\n continue;\n }\n leadingQuote = parseCalloutTag(raw).text || undefined;\n }\n\n return {\n headline: headingText(parts, 1),\n badge: headingText(parts, 3) || undefined,\n content: bodyText(parts) || undefined,\n buttons: buttons.length > 0 ? buttons : undefined,\n image,\n trailingList,\n leadingQuote,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AASO,MAAME,qBAAqB,CAElC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,MAAM;IAAA,IAAAD,gBAAA,CAAAC,OAAA,0BACH,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACV;IACT;IACA;IACA;IACA;IACA;IACA;IACA,mFAAmF,CACpF;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBAEyB;MACxBC,QAAQ,EAAE,yBAAyB;MACnCC,OAAO,EAAE,0CAA0C;MACnDC,OAAO,EAAE,CAAC;QAAEC,EAAE,EAAE,OAAO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6,32 +6,32 @@ exports.ListItemsSectionDefinition = void 0;
6
6
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
7
  var _parseUtils = require("./parse-utils");
8
8
  var _parts = require("../../parts/parts");
9
- function resolveVariant(itemCount, context, sectionType) {
10
- const defaultVariant = itemCount <= 3 ? 'list' : 'cards';
11
- const lastVariant = sectionType ? context == null || context.getMeta == null ? void 0 : context.getMeta(sectionType, 'lastVariant') : undefined;
12
-
13
- // Alternate: after 'list' force 'cards', after 'cards' force 'list'
14
- const variant = lastVariant ? lastVariant === 'list' ? 'cards' : 'list' : defaultVariant;
15
- if (sectionType) {
16
- context == null || context.setMeta == null || context.setMeta(sectionType, 'lastVariant', variant);
17
- }
18
- return variant;
19
- }
9
+ /** A valid list section needs at least this many feature items. */
10
+ const MIN_FEATURES = 2;
20
11
  class ListItemsSectionDefinition {
21
12
  constructor() {
22
13
  (0, _defineProperty2.default)(this, "sectionType", 'listItemsSection');
23
- (0, _defineProperty2.default)(this, "patterns", ['html_comment? > (h2 | h3) > t? > callout? > list{item[2-]:t+}', 'html_comment? > (h2 | h3) > t? > callout? > list{item[2-]:(h3 | t)* > t+}']);
14
+ // Comment-delimited: the section spans from a `<!-- section:list -->` marker
15
+ // and greedily captures the tokens that follow. The repetition deliberately
16
+ // excludes `html_comment`, so the match naturally ends just before the next
17
+ // section marker (or end of input) without consuming it — no explicit `~`
18
+ // stop clause needed, and it still matches when this is the final section.
19
+ // The structural contract is enforced in `parse()` instead of the pattern:
20
+ // `parse()` returns null unless the content is an h2 followed by a 2+ item
21
+ // feature list, so a non-conforming block falls through to the next
22
+ // matching definition.
23
+ (0, _defineProperty2.default)(this, "patterns", ['html_comment[section="list"] > (h2 | h3 | t | callout | list | image | link | table | blockquote)*']);
24
24
  (0, _defineProperty2.default)(this, "defaults", {
25
25
  title: 'Features',
26
- features: [],
27
- variant: 'list'
26
+ features: []
28
27
  });
29
28
  (0, _defineProperty2.default)(this, "fixtures", []);
30
29
  }
31
- parse(parts, context) {
32
- const title = (0, _parseUtils.headingText)(parts, 2) || (0, _parseUtils.headingText)(parts, 3) || 'Features';
33
- const description = (0, _parseUtils.bodyText)(parts) || undefined;
34
- const callout = (0, _parseUtils.calloutFromParts)(parts);
30
+ parse(parts) {
31
+ const title = (0, _parseUtils.headingText)(parts, 2);
32
+ if (!title) {
33
+ return null;
34
+ }
35
35
  const features = [];
36
36
  const lists = (0, _parts.getPartsByType)(parts, 'list');
37
37
  for (const list of lists) {
@@ -66,19 +66,14 @@ class ListItemsSectionDefinition {
66
66
  }
67
67
  }
68
68
 
69
- // Resolve contextual image from title + description
70
- const imageResult = context == null || context.getContextualImage == null ? void 0 : context.getContextualImage([title, description]);
71
- const imageUrl = (imageResult == null ? void 0 : imageResult.filename) || undefined;
72
- const imageFromText = (imageResult == null ? void 0 : imageResult.isFromText) || undefined;
73
- const variant = resolveVariant(features.length, context, this.sectionType);
69
+ // Valid structure is an h2 title followed by a 2+ item feature list.
70
+ // Anything else is not this section let the next definition try.
71
+ if (features.length < MIN_FEATURES) {
72
+ return null;
73
+ }
74
74
  return {
75
75
  title,
76
- description,
77
- features,
78
- callout,
79
- imageUrl,
80
- imageFromText,
81
- variant
76
+ features
82
77
  };
83
78
  }
84
79
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_parseUtils","require","_parts","resolveVariant","itemCount","context","sectionType","defaultVariant","lastVariant","getMeta","undefined","variant","setMeta","ListItemsSectionDefinition","constructor","_defineProperty2","default","title","features","parse","parts","headingText","description","bodyText","callout","calloutFromParts","lists","getPartsByType","list","item","_list$meta","meta","items","_item$meta","_item$meta2","itemParts","heading","find","p","type","textParts","filter","featureDescription","map","_p$content","content","trim","Boolean","join","markdown","extractListItemText","boldMatch","match","_heading$content","push","imageResult","getContextualImage","imageUrl","filename","imageFromText","isFromText","length","exports"],"sources":["../../../../src/component/componentDefinitions/listItemsSectionDefinition.ts"],"sourcesContent":["import {\n headingText,\n bodyText,\n calloutFromParts,\n extractListItemText,\n} from './parse-utils';\nimport { getPartsByType, type Part, type ListPart } from '../../parts/parts';\nimport type {\n ListItemsSectionCompProps,\n ListItemsSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition, ParseContext } from '../section-definition';\n\ntype ListItemsVariant = 'cards' | 'list';\n\nfunction resolveVariant(\n itemCount: number,\n context?: ParseContext,\n sectionType?: string,\n): ListItemsVariant {\n const defaultVariant: ListItemsVariant = itemCount <= 3 ? 'list' : 'cards';\n const lastVariant = sectionType\n ? (context?.getMeta?.(sectionType, 'lastVariant') as\n | ListItemsVariant\n | undefined)\n : undefined;\n\n // Alternate: after 'list' force 'cards', after 'cards' force 'list'\n const variant = lastVariant\n ? lastVariant === 'list'\n ? 'cards'\n : 'list'\n : defaultVariant;\n\n if (sectionType) {\n context?.setMeta?.(sectionType, 'lastVariant', variant);\n }\n return variant;\n}\n\nexport class ListItemsSectionDefinition\n implements SectionDefinition<ListItemsSectionComponent>\n{\n sectionType = 'listItemsSection' as const;\n patterns = [\n 'html_comment? > (h2 | h3) > t? > callout? > list{item[2-]:t+}',\n 'html_comment? > (h2 | h3) > t? > callout? > list{item[2-]:(h3 | t)* > t+}',\n ];\n\n defaults: ListItemsSectionCompProps = {\n title: 'Features',\n features: [],\n variant: 'list',\n };\n\n fixtures: SectionFixture<ListItemsSectionCompProps>[] = [];\n\n parse(parts: Part[], context?: ParseContext): ListItemsSectionCompProps {\n const title = headingText(parts, 2) || headingText(parts, 3) || 'Features';\n const description = bodyText(parts) || undefined;\n const callout = calloutFromParts(parts);\n\n const features: { title?: string; description: string }[] = [];\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const heading = itemParts.find((p) => p.type === 'heading');\n const textParts = itemParts.filter(\n (p) => p.type === 'text' || p.type === 'richText',\n );\n const featureDescription = textParts\n .map((p) => p.content?.trim())\n .filter(Boolean)\n .join('\\n');\n\n const markdown = (item.meta?.markdown as string)?.trim();\n const content = markdown || extractListItemText(item);\n const boldMatch = content.match(/^\\*\\*([^*]+)\\*\\*:?\\s*(.*)/s);\n\n if (heading) {\n features.push({\n title: heading.content?.trim(),\n description: featureDescription || content,\n });\n } else if (boldMatch) {\n features.push({\n title: boldMatch[1].trim(),\n description: boldMatch[2].trim() || featureDescription,\n });\n } else {\n features.push({\n description: featureDescription || content,\n });\n }\n }\n }\n\n // Resolve contextual image from title + description\n const imageResult = context?.getContextualImage?.([title, description]);\n const imageUrl = imageResult?.filename || undefined;\n const imageFromText = imageResult?.isFromText || undefined;\n\n const variant = resolveVariant(features.length, context, this.sectionType);\n\n return {\n title,\n description,\n features,\n callout,\n imageUrl,\n imageFromText,\n variant,\n };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAUA,SAASE,cAAcA,CACrBC,SAAiB,EACjBC,OAAsB,EACtBC,WAAoB,EACF;EAClB,MAAMC,cAAgC,GAAGH,SAAS,IAAI,CAAC,GAAG,MAAM,GAAG,OAAO;EAC1E,MAAMI,WAAW,GAAGF,WAAW,GAC1BD,OAAO,YAAPA,OAAO,CAAEI,OAAO,oBAAhBJ,OAAO,CAAEI,OAAO,CAAGH,WAAW,EAAE,aAAa,CAAC,GAG/CI,SAAS;;EAEb;EACA,MAAMC,OAAO,GAAGH,WAAW,GACvBA,WAAW,KAAK,MAAM,GACpB,OAAO,GACP,MAAM,GACRD,cAAc;EAElB,IAAID,WAAW,EAAE;IACfD,OAAO,YAAPA,OAAO,CAAEO,OAAO,YAAhBP,OAAO,CAAEO,OAAO,CAAGN,WAAW,EAAE,aAAa,EAAEK,OAAO,CAAC;EACzD;EACA,OAAOA,OAAO;AAChB;AAEO,MAAME,0BAA0B,CAEvC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,kBAAkB;IAAA,IAAAD,gBAAA,CAAAC,OA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ACvE,MAAMmC,QAAQ,GAAG,CAAAF,WAAW,oBAAXA,WAAW,CAAEG,QAAQ,KAAIhD,SAAS;IACnD,MAAMiD,aAAa,GAAG,CAAAJ,WAAW,oBAAXA,WAAW,CAAEK,UAAU,KAAIlD,SAAS;IAE1D,MAAMC,OAAO,GAAGR,cAAc,CAACe,QAAQ,CAAC2C,MAAM,EAAExD,OAAO,EAAE,IAAI,CAACC,WAAW,CAAC;IAE1E,OAAO;MACLW,KAAK;MACLK,WAAW;MACXJ,QAAQ;MACRM,OAAO;MACPiC,QAAQ;MACRE,aAAa;MACbhD;IACF,CAAC;EACH;AACF;AAACmD,OAAA,CAAAjD,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_parseUtils","require","_parts","MIN_FEATURES","ListItemsSectionDefinition","constructor","_defineProperty2","default","title","features","parse","parts","headingText","lists","getPartsByType","list","item","_list$meta","meta","items","_item$meta","_item$meta2","itemParts","heading","find","p","type","textParts","filter","featureDescription","map","_p$content","content","trim","Boolean","join","markdown","extractListItemText","boldMatch","match","_heading$content","push","description","length","exports"],"sources":["../../../../src/component/componentDefinitions/listItemsSectionDefinition.ts"],"sourcesContent":["import { headingText, extractListItemText } from './parse-utils';\nimport { getPartsByType, type Part, type ListPart } from '../../parts/parts';\nimport type {\n ListItemsSectionCompProps,\n ListItemsSectionComponent,\n SectionFixture,\n} from '../types';\nimport type { SectionDefinition } from '../section-definition';\n\n/** A valid list section needs at least this many feature items. */\nconst MIN_FEATURES = 2;\n\nexport class ListItemsSectionDefinition\n implements SectionDefinition<ListItemsSectionComponent>\n{\n sectionType = 'listItemsSection' as const;\n\n // Comment-delimited: the section spans from a `<!-- section:list -->` marker\n // and greedily captures the tokens that follow. The repetition deliberately\n // excludes `html_comment`, so the match naturally ends just before the next\n // section marker (or end of input) without consuming it — no explicit `~`\n // stop clause needed, and it still matches when this is the final section.\n // The structural contract is enforced in `parse()` instead of the pattern:\n // `parse()` returns null unless the content is an h2 followed by a 2+ item\n // feature list, so a non-conforming block falls through to the next\n // matching definition.\n patterns = [\n 'html_comment[section=\"list\"] > (h2 | h3 | t | callout | list | image | link | table | blockquote)*',\n ];\n\n defaults: ListItemsSectionCompProps = {\n title: 'Features',\n features: [],\n };\n\n fixtures: SectionFixture<ListItemsSectionCompProps>[] = [];\n\n parse(parts: Part[]): ListItemsSectionCompProps | null {\n const title = headingText(parts, 2);\n if (!title) {\n return null;\n }\n\n const features: { title?: string; description: string }[] = [];\n const lists = getPartsByType<ListPart>(parts, 'list');\n\n for (const list of lists) {\n for (const item of list.meta?.items ?? []) {\n const itemParts = (item.meta?.parts ?? []) as Part[];\n const heading = itemParts.find((p) => p.type === 'heading');\n const textParts = itemParts.filter(\n (p) => p.type === 'text' || p.type === 'richText',\n );\n const featureDescription = textParts\n .map((p) => p.content?.trim())\n .filter(Boolean)\n .join('\\n');\n\n const markdown = (item.meta?.markdown as string)?.trim();\n const content = markdown || extractListItemText(item);\n const boldMatch = content.match(/^\\*\\*([^*]+)\\*\\*:?\\s*(.*)/s);\n\n if (heading) {\n features.push({\n title: heading.content?.trim(),\n description: featureDescription || content,\n });\n } else if (boldMatch) {\n features.push({\n title: boldMatch[1].trim(),\n description: boldMatch[2].trim() || featureDescription,\n });\n } else {\n features.push({\n description: featureDescription || content,\n });\n }\n }\n }\n\n // Valid structure is an h2 title followed by a 2+ item feature list.\n // Anything else is not this section let the next definition try.\n if (features.length < MIN_FEATURES) {\n return null;\n }\n\n return { title, features };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQA;AACA,MAAME,YAAY,GAAG,CAAC;AAEf,MAAMC,0BAA0B,CAEvC;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,uBACgB,kBAAkB;IAEhC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,oBACW,CACT,oGAAoG,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f,WAAA,GAAIL,IAAI,CAACE,IAAI,cAAAG,WAAA,GAATA,WAAA,CAAWe,QAAQ,qBAApBf,WAAA,CAAiCY,IAAI,CAAC,CAAC;QACxD,MAAMD,OAAO,GAAGI,QAAQ,IAAI,IAAAC,+BAAmB,EAACrB,IAAI,CAAC;QACrD,MAAMsB,SAAS,GAAGN,OAAO,CAACO,KAAK,CAAC,4BAA4B,CAAC;QAE7D,IAAIhB,OAAO,EAAE;UAAA,IAAAiB,gBAAA;UACX/B,QAAQ,CAACgC,IAAI,CAAC;YACZjC,KAAK,GAAAgC,gBAAA,GAAEjB,OAAO,CAACS,OAAO,qBAAfQ,gBAAA,CAAiBP,IAAI,CAAC,CAAC;YAC9BS,WAAW,EAAEb,kBAAkB,IAAIG;UACrC,CAAC,CAAC;QACJ,CAAC,MAAM,IAAIM,SAAS,EAAE;UACpB7B,QAAQ,CAACgC,IAAI,CAAC;YACZjC,KAAK,EAAE8B,SAAS,CAAC,CAAC,CAAC,CAACL,IAAI,CAAC,CAAC;YAC1BS,WAAW,EAAEJ,SAAS,CAAC,CAAC,CAAC,CAACL,IAAI,CAAC,CAAC,IAAIJ;UACtC,CAAC,CAAC;QACJ,CAAC,MAAM;UACLpB,QAAQ,CAACgC,IAAI,CAAC;YACZC,WAAW,EAAEb,kBAAkB,IAAIG;UACrC,CAAC,CAAC;QACJ;MACF;IACF;;IAEA;IACA;IACA,IAAIvB,QAAQ,CAACkC,MAAM,GAAGxC,YAAY,EAAE;MAClC,OAAO,IAAI;IACb;IAEA,OAAO;MAAEK,KAAK;MAAEC;IAAS,CAAC;EAC5B;AACF;AAACmC,OAAA,CAAAxC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -160,7 +160,14 @@ function parseMarkdownToComponents(pageMarkdown, options) {
160
160
  markdown: preprocessedMarkdown,
161
161
  diagnostics: preprocessDiagnostics
162
162
  } = (0, _markdownPreprocessor.preprocessMarkdown)(pageMarkdown);
163
- const intentInfo = providedIntent ?? (0, _intentExtractor.getIntentFromMarkdown)(preprocessedMarkdown);
163
+
164
+ // Validate the emitted intent against this client's own registered intents
165
+ // (its taxonomy), falling back to core's DEFAULT_INTENTS when the registry
166
+ // declares none.
167
+ const knownIntents = registry.getKnownIntents();
168
+ const intentInfo = providedIntent ?? (0, _intentExtractor.getIntentFromMarkdown)(preprocessedMarkdown, {
169
+ validIntents: knownIntents.length > 0 ? knownIntents : undefined
170
+ });
164
171
  const allNodes = [...(0, _unifiedMarkdownParser.parseMarkdownToAst)(preprocessedMarkdown).children];
165
172
  const nodes = [...allNodes];
166
173
  const sections = [];
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_patternValidator","_astToParts","_linkTypes","_web5LinkValidator","_diagnosticTypes","_componentTracking","_diagnosticsCollector","_unifiedMarkdownParser","_markdownPreprocessor","_intentExtractor","_contentKeywordMatcher","_propsExtractor","isEntityCompProps","props","Array","isArray","items","isItemsFromContentSection","sectionType","semantic","serverSectionId","normalizedSemantic","toLowerCase","replace","normalizedId","includes","mergeSectionsWithStableReferences","existingSections","newSections","length","merged","i","_existing$sourceMarkd","_updated$sourceMarkdo","existing","updated","push","existingLength","sourceMarkdown","updatedLength","component","componentOptions","debugProps","isSkeleton","newSectionsToAdd","slice","combineAdjacentGeneralTextSections","sections","registry","placement","placementId","combined","currentSection","sectionsToCombine","j","mergedSection","mergeGeneralTextSections","index","Error","mergedSourceMarkdown","map","section","filter","markdown","trim","join","mergedProps","FallbackComponent","resolveSection","mergedComponent","React","createElement","createPageSection","componentName","displayName","name","parseMarkdownToComponents","pageMarkdown","options","_clientConfig$feature","clientConfig","enrichEntityProps","clientId","intentInfo","providedIntent","payload","disableContextualImages","explicitDisableImages","preprocessedMarkdown","diagnostics","preprocessDiagnostics","preprocessMarkdown","getIntentFromMarkdown","allNodes","parseMarkdownToAst","children","nodes","tracking","ComponentTracking","diagnosticsCollector","DiagnosticsCollector","d","report","diagnosticType","type","sectionIndex","details","original","normalized","features","disableContextualImagesEnrichment","context","intent","currentGlobalIndex","startIndex","parsedCount","tryParseComponent","parseAstToMarkdown","endIndex","addRange","splice","link","findInvalidWeb5Links","label","reason","DIAGNOSTIC_TYPES","LEGACY_PROTOCOL_LINK","INVALID_LINK_FORMAT","BROKEN_WEB5_LINK","nodeType","url","combinedSections","definitions","getAllDefinitions","allowedKeywords","allowedImageSearchKeywords","baseParseContext","getContextualImage","undefined","contentParts","result","getContextualImageFilename","isWeb5ImageUrl","filename","getComponentCount","setMeta","key","value","getMeta","definition","isPlacementOnly","pattern","patterns","_parts$find","_context$intent","validatePattern","valid","parsedNodes","astEndIndex","maxNodes","maxConsumedNodes","matchedNodes","parts","nodesToParts","parseContext","reportDiagnostic","parse","leadingHtmlCommentMeta","find","p","meta","id","singleInstance","isNullComponent","nullComponent","Component","resolvedSectionOptions","resolveSectionOptions","patternValidation","astStartIndex"],"sources":["../../../src/component/componentParser.ts"],"sourcesContent":["/**\n * Markdown → component orchestrator. Lifted from\n * `web50-server-ui/src/utils/componentParser.ts` per DL #088 B9.5.\n *\n * The lift replaces three app-side singletons with options:\n * - `getAppRegistry()` → `options.registry`\n * - `getClientConfigSync(clientId)` → `options.clientConfig`\n * - `setLastDiagnosticsCollector(...)` → returned in the result object\n *\n * Adds a `placement` option that flows into every `registry.resolveSection`\n * call so the placement bundle can pick the placement variant of each section.\n *\n * The app-side `componentParser.ts` is a thin wrapper around this orchestrator\n * that pre-binds its singletons and a product-payload enrichment callback.\n */\nimport type { RootContent } from 'mdast';\nimport React from 'react';\n\nimport { validatePattern } from '../patternValidator';\nimport { nodesToParts } from '../match/astToParts';\nimport { isWeb5ImageUrl } from '../types/link-types';\nimport { findInvalidWeb5Links } from '../utils/web5LinkValidator';\nimport { DIAGNOSTIC_TYPES, type DiagnosticType } from './diagnosticTypes';\nimport { ComponentTracking } from '../utils/componentTracking';\nimport {\n DiagnosticsCollector,\n} from '../utils/diagnosticsCollector';\nimport {\n parseAstToMarkdown,\n parseMarkdownToAst,\n} from '../utils/unifiedMarkdownParser';\nimport { preprocessMarkdown } from '../utils/markdownPreprocessor';\nimport { getIntentFromMarkdown, type IntentInfo } from '../utils/intentExtractor';\nimport { getContextualImageFilename } from '../utils/contentKeywordMatcher';\nimport { createPageSection } from '../utils/propsExtractor';\nimport type { PageSection } from '../types/page-section';\nimport type { ApiPayloadItem } from '../types/entity';\nimport type { ComponentRegistry } from '../registry';\nimport type {\n EntityCompProps,\n GeneralTextCompProps,\n} from './types';\nimport type { SectionDefinition, ParseContext } from './section-definition';\nimport type {\n EnrichEntityProps,\n ParserClientConfig,\n ParserContext,\n} from './parser-types';\n\nexport type { ComponentMatch, ParserContext } from './parser-types';\n\nexport interface ParseMarkdownOptions {\n /** Required — replaces the app-side `getAppRegistry()` singleton. */\n registry: ComponentRegistry<React.FC<any>>;\n /** Replaces `getClientConfigSync(clientId)` — caller resolves it first. */\n clientConfig?: ParserClientConfig | null;\n /** When true, resolveSection prefers placement variants (DL #088 D3.1). */\n placement?: boolean;\n /**\n * Placement slot id (the `data-web5-placement` value) — forwarded to\n * `resolveSection` so a section can resolve a per-placement variant. Only\n * meaningful with `placement: true`.\n */\n placementId?: string;\n /** App-specific payload-to-entity enrichment; omitted by the placement bundle. */\n enrichEntityProps?: EnrichEntityProps;\n /** Reuse an existing collector (e.g. for streaming) instead of creating one. */\n diagnosticsCollector?: DiagnosticsCollector;\n clientId?: string;\n intentInfo?: IntentInfo | null;\n payload?: ApiPayloadItem[];\n disableContextualImages?: boolean;\n}\n\nexport interface ParseMarkdownResult {\n sections: PageSection[];\n tracking: ComponentTracking;\n diagnosticsCollector: DiagnosticsCollector;\n}\n\nfunction isEntityCompProps(props: unknown): props is EntityCompProps {\n return (\n typeof props === 'object' &&\n props !== null &&\n Array.isArray((props as EntityCompProps).items)\n );\n}\n\nfunction isItemsFromContentSection(\n sectionType: string,\n semantic?: string,\n serverSectionId?: string,\n): boolean {\n if (sectionType !== 'entity') {\n return false;\n }\n const normalizedSemantic = semantic?.toLowerCase().replace(/_/g, '-');\n const normalizedId = serverSectionId?.toLowerCase().replace(/_/g, '-');\n return (\n normalizedSemantic === 'items' ||\n normalizedSemantic === 'items-from-content' ||\n normalizedId?.includes('items-from-content') === true\n );\n}\n\n/**\n * Merges new sections with existing sections, maintaining stable references\n * for unchanged sections to prevent unnecessary rerenders.\n */\nexport function mergeSectionsWithStableReferences(\n existingSections: PageSection[],\n newSections: PageSection[],\n): PageSection[] {\n if (existingSections.length === 0) {\n return newSections;\n }\n if (newSections.length < existingSections.length) {\n return newSections;\n }\n\n const merged: PageSection[] = [];\n\n for (let i = 0; i < existingSections.length; i++) {\n const existing = existingSections[i];\n const updated = newSections[i];\n\n if (!updated) {\n merged.push(existing);\n continue;\n }\n\n const existingLength = existing.sourceMarkdown?.length || 0;\n const updatedLength = updated.sourceMarkdown?.length || 0;\n\n if (existingLength === updatedLength) {\n existing.sourceMarkdown = updated.sourceMarkdown;\n existing.component = updated.component;\n existing.componentOptions = updated.componentOptions;\n existing.debugProps = updated.debugProps;\n // V3 (DL #106): a skeleton and its real section both have empty\n // sourceMarkdown, so without carrying this flag the slot would stay a\n // skeleton forever (its real component never rendering).\n existing.isSkeleton = updated.isSkeleton;\n merged.push(existing);\n } else {\n merged.push(updated);\n }\n }\n\n if (newSections.length > existingSections.length) {\n const newSectionsToAdd = newSections.slice(existingSections.length);\n merged.push(...newSectionsToAdd);\n }\n\n return merged;\n}\n\nfunction combineAdjacentGeneralTextSections(\n sections: PageSection[],\n registry: ComponentRegistry<React.FC<any>>,\n placement?: boolean,\n placementId?: string,\n): PageSection[] {\n if (sections.length === 0) {\n return sections;\n }\n\n const combined: PageSection[] = [];\n let i = 0;\n\n while (i < sections.length) {\n const currentSection = sections[i];\n if (currentSection.sectionType === 'fallback') {\n const sectionsToCombine: PageSection[] = [currentSection];\n let j = i + 1;\n\n while (j < sections.length && sections[j].sectionType === 'fallback') {\n sectionsToCombine.push(sections[j]);\n j++;\n }\n\n if (sectionsToCombine.length > 1) {\n const mergedSection = mergeGeneralTextSections(\n sectionsToCombine,\n combined.length,\n registry,\n placement,\n placementId,\n );\n combined.push(mergedSection);\n i = j;\n } else {\n combined.push(currentSection);\n i++;\n }\n } else {\n combined.push(currentSection);\n i++;\n }\n }\n\n return combined;\n}\n\nfunction mergeGeneralTextSections(\n sections: PageSection[],\n index: number,\n registry: ComponentRegistry<React.FC<any>>,\n placement?: boolean,\n placementId?: string,\n): PageSection {\n if (sections.length === 0) {\n throw new Error('Cannot merge empty sections array');\n }\n if (sections.length === 1) {\n return sections[0];\n }\n\n const mergedSourceMarkdown = sections\n .map((section) => section.sourceMarkdown || '')\n .filter((markdown) => markdown.trim().length > 0)\n .join('\\n\\n');\n\n const mergedProps: GeneralTextCompProps = {\n markdown: mergedSourceMarkdown,\n };\n\n const FallbackComponent = registry.resolveSection('fallback', {\n placement,\n placementId,\n });\n const mergedComponent = React.createElement(FallbackComponent, mergedProps);\n\n return createPageSection({\n sectionType: 'fallback',\n componentName:\n (FallbackComponent as React.FC).displayName || FallbackComponent.name,\n index,\n component: mergedComponent,\n sourceMarkdown: mergedSourceMarkdown,\n debugProps: mergedProps,\n });\n}\n\nexport function parseMarkdownToComponents(\n pageMarkdown: string,\n options: ParseMarkdownOptions,\n): ParseMarkdownResult {\n const {\n registry,\n clientConfig,\n placement,\n placementId,\n enrichEntityProps,\n clientId,\n intentInfo: providedIntent,\n payload,\n disableContextualImages: explicitDisableImages,\n } = options;\n\n const { markdown: preprocessedMarkdown, diagnostics: preprocessDiagnostics } =\n preprocessMarkdown(pageMarkdown);\n\n const intentInfo =\n providedIntent ?? getIntentFromMarkdown(preprocessedMarkdown);\n\n const allNodes: RootContent[] = [\n ...parseMarkdownToAst(preprocessedMarkdown).children,\n ];\n const nodes: RootContent[] = [...allNodes];\n\n const sections: PageSection[] = [];\n const tracking = new ComponentTracking();\n const diagnosticsCollector =\n options.diagnosticsCollector ?? new DiagnosticsCollector();\n\n for (const d of preprocessDiagnostics) {\n diagnosticsCollector.report({\n diagnosticType: d.type as DiagnosticType,\n sectionType: 'preprocessor',\n sectionIndex: -1,\n details: `${d.original} → ${d.normalized}`,\n });\n }\n\n const disableContextualImages =\n explicitDisableImages ??\n clientConfig?.features?.disableContextualImagesEnrichment ??\n false;\n\n const context: ParserContext = {\n registry,\n clientConfig,\n placement,\n placementId,\n enrichEntityProps,\n clientId,\n intent: intentInfo,\n tracking,\n disableContextualImages,\n diagnosticsCollector,\n payload,\n };\n let currentGlobalIndex = 0;\n\n while (nodes.length > 0) {\n const startIndex = currentGlobalIndex;\n const { section, parsedCount } = tryParseComponent(\n nodes,\n sections.length,\n context,\n );\n\n if (!parsedCount) {\n break;\n }\n\n if (section) {\n section.sourceMarkdown = parseAstToMarkdown(nodes.slice(0, parsedCount));\n sections.push(section);\n\n const endIndex = startIndex + parsedCount;\n tracking.addRange(\n section.sectionType,\n startIndex,\n endIndex,\n sections.length - 1,\n );\n } else {\n const endIndex = startIndex + parsedCount;\n tracking.addRange('', startIndex, endIndex, -1);\n }\n\n currentGlobalIndex += parsedCount;\n nodes.splice(0, parsedCount);\n }\n\n for (const link of findInvalidWeb5Links(allNodes)) {\n let diagnosticType: DiagnosticType;\n let label: string;\n switch (link.reason) {\n case 'legacy':\n diagnosticType = DIAGNOSTIC_TYPES.LEGACY_PROTOCOL_LINK;\n label = 'legacy protocol';\n break;\n case 'empty':\n diagnosticType = DIAGNOSTIC_TYPES.INVALID_LINK_FORMAT;\n label = 'empty href';\n break;\n default:\n diagnosticType = DIAGNOSTIC_TYPES.BROKEN_WEB5_LINK;\n label = 'web5://';\n break;\n }\n diagnosticsCollector.report({\n diagnosticType,\n sectionType: 'parser',\n sectionIndex: -1,\n details: `Invalid ${label} URL in ${link.nodeType}: ${link.url}`.slice(\n 0,\n 200,\n ),\n });\n }\n\n const combinedSections = combineAdjacentGeneralTextSections(\n sections,\n registry,\n placement,\n placementId,\n );\n\n return {\n sections: combinedSections,\n tracking,\n diagnosticsCollector,\n };\n}\n\nexport function tryParseComponent(\n nodes: RootContent[],\n sectionIndex: number,\n context: ParserContext,\n): { section?: PageSection; parsedCount?: number } {\n if (!nodes?.length) {\n return {};\n }\n\n const registry = context.registry;\n const placement = context.placement;\n const placementId = context.placementId;\n const definitions = registry.getAllDefinitions();\n\n const clientConfig = context.clientConfig ?? null;\n const allowedKeywords = clientConfig?.allowedImageSearchKeywords ?? [];\n const disableContextualImages = context.disableContextualImages ?? false;\n\n const baseParseContext: ParseContext = {\n getContextualImage:\n disableContextualImages || allowedKeywords.length === 0\n ? undefined\n : (contentParts) => {\n const result = getContextualImageFilename(\n contentParts,\n allowedKeywords,\n '',\n context.tracking,\n );\n return isWeb5ImageUrl(result.filename) ? result : null;\n },\n getComponentCount: context.tracking\n ? (sectionType) => context.tracking!.getComponentCount(sectionType)\n : undefined,\n setMeta: context.tracking\n ? (sectionType, key, value) =>\n context.tracking!.setMeta(sectionType, key, value)\n : undefined,\n getMeta: context.tracking\n ? (sectionType, key) => context.tracking!.getMeta(sectionType, key)\n : undefined,\n };\n\n for (const { sectionType, definition } of definitions) {\n // Placement-only definitions (registered with `{ placement: true }`\n // variants and no non-placement variant) must not match in a non-placement\n // render (the main app) — their markdown should fall through to the generic\n // sections there. Skip them unless this is a placement parse.\n if (!placement && registry.isPlacementOnly(sectionType)) {\n continue;\n }\n for (const pattern of definition.patterns) {\n const result = validatePattern(nodes, pattern);\n if (!result.valid) {\n continue;\n }\n\n let parsedNodes =\n result.astEndIndex !== undefined && result.astEndIndex >= 0\n ? result.astEndIndex + 1\n : result.endIndex >= 0\n ? result.endIndex + 1\n : 1;\n\n const maxNodes = (\n definition as SectionDefinition & { maxConsumedNodes?: number }\n ).maxConsumedNodes;\n if (typeof maxNodes === 'number' && parsedNodes > maxNodes) {\n parsedNodes = maxNodes;\n }\n\n const matchedNodes = nodes.slice(0, parsedNodes);\n const parts = nodesToParts(matchedNodes);\n const parseContext: ParseContext = {\n ...baseParseContext,\n reportDiagnostic: context.diagnosticsCollector\n ? (type, details) => {\n context.diagnosticsCollector!.report({\n diagnosticType: type,\n sectionType,\n sectionIndex,\n details: details.slice(0, 200),\n });\n }\n : undefined,\n };\n let props = definition.parse(parts, parseContext);\n\n if (props === null) {\n continue;\n }\n\n const leadingHtmlCommentMeta = parts.find(\n (p) => p.type === 'htmlComment' && p.meta,\n )?.meta;\n const semantic = leadingHtmlCommentMeta?.semantic as string | undefined;\n const serverSectionId = leadingHtmlCommentMeta?.id as string | undefined;\n\n if (\n isEntityCompProps(props) &&\n isItemsFromContentSection(sectionType, semantic, serverSectionId) &&\n context.enrichEntityProps\n ) {\n props = context.enrichEntityProps(props, {\n payload: context.payload,\n clientConfig,\n sectionType,\n semantic,\n serverSectionId,\n });\n }\n\n if (\n definition.singleInstance &&\n context.tracking &&\n context.tracking.getComponentCount(sectionType) > 0\n ) {\n continue;\n }\n\n const isNullComponent =\n (definition as SectionDefinition & { nullComponent?: boolean })\n .nullComponent === true;\n if (isNullComponent) {\n return { parsedCount: parsedNodes };\n }\n\n const intent = context.intent?.intent;\n const Component = registry.resolveSection(sectionType, {\n intent,\n semantic,\n placement,\n placementId,\n });\n const resolvedSectionOptions = registry.resolveSectionOptions(\n sectionType,\n { intent, semantic, placement, placementId },\n );\n const component = React.createElement(Component, props);\n const componentName =\n Component.displayName || Component.name || undefined;\n\n const section = createPageSection({\n sectionType,\n componentName,\n semantic,\n componentOptions: resolvedSectionOptions?.componentOptions,\n index: sectionIndex,\n id: serverSectionId,\n component,\n sourceMarkdown: '',\n debugProps: {\n ...props,\n patternValidation: {\n astStartIndex: result.astStartIndex,\n astEndIndex: result.astEndIndex,\n endIndex: result.endIndex,\n },\n },\n });\n\n return { section, parsedCount: parsedNodes };\n }\n }\n\n return {};\n}\n"],"mappings":";;;;;;;AAgBA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI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sBAAsB,CAAEvI,gBAAgB;QAC1DgB,KAAK,EAAEgD,YAAY;QACnBkE,EAAE,EAAEvJ,eAAe;QACnBoB,SAAS;QACTF,cAAc,EAAE,EAAE;QAClBI,UAAU,EAAE;UACV,GAAG7B,KAAK;UACRqK,iBAAiB,EAAE;YACjBC,aAAa,EAAEvC,MAAM,CAACuC,aAAa;YACnCrB,WAAW,EAAElB,MAAM,CAACkB,WAAW;YAC/BxC,QAAQ,EAAEsB,MAAM,CAACtB;UACnB;QACF;MACF,CAAC,CAAC;MAEF,OAAO;QAAEzD,OAAO;QAAEsD,WAAW,EAAE0C;MAAY,CAAC;IAC9C;EACF;EAEA,OAAO,CAAC,CAAC;AACX","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_patternValidator","_astToParts","_linkTypes","_web5LinkValidator","_diagnosticTypes","_componentTracking","_diagnosticsCollector","_unifiedMarkdownParser","_markdownPreprocessor","_intentExtractor","_contentKeywordMatcher","_propsExtractor","isEntityCompProps","props","Array","isArray","items","isItemsFromContentSection","sectionType","semantic","serverSectionId","normalizedSemantic","toLowerCase","replace","normalizedId","includes","mergeSectionsWithStableReferences","existingSections","newSections","length","merged","i","_existing$sourceMarkd","_updated$sourceMarkdo","existing","updated","push","existingLength","sourceMarkdown","updatedLength","component","componentOptions","debugProps","isSkeleton","newSectionsToAdd","slice","combineAdjacentGeneralTextSections","sections","registry","placement","placementId","combined","currentSection","sectionsToCombine","j","mergedSection","mergeGeneralTextSections","index","Error","mergedSourceMarkdown","map","section","filter","markdown","trim","join","mergedProps","FallbackComponent","resolveSection","mergedComponent","React","createElement","createPageSection","componentName","displayName","name","parseMarkdownToComponents","pageMarkdown","options","_clientConfig$feature","clientConfig","enrichEntityProps","clientId","intentInfo","providedIntent","payload","disableContextualImages","explicitDisableImages","preprocessedMarkdown","diagnostics","preprocessDiagnostics","preprocessMarkdown","knownIntents","getKnownIntents","getIntentFromMarkdown","validIntents","undefined","allNodes","parseMarkdownToAst","children","nodes","tracking","ComponentTracking","diagnosticsCollector","DiagnosticsCollector","d","report","diagnosticType","type","sectionIndex","details","original","normalized","features","disableContextualImagesEnrichment","context","intent","currentGlobalIndex","startIndex","parsedCount","tryParseComponent","parseAstToMarkdown","endIndex","addRange","splice","link","findInvalidWeb5Links","label","reason","DIAGNOSTIC_TYPES","LEGACY_PROTOCOL_LINK","INVALID_LINK_FORMAT","BROKEN_WEB5_LINK","nodeType","url","combinedSections","definitions","getAllDefinitions","allowedKeywords","allowedImageSearchKeywords","baseParseContext","getContextualImage","contentParts","result","getContextualImageFilename","isWeb5ImageUrl","filename","getComponentCount","setMeta","key","value","getMeta","definition","isPlacementOnly","pattern","patterns","_parts$find","_context$intent","validatePattern","valid","parsedNodes","astEndIndex","maxNodes","maxConsumedNodes","matchedNodes","parts","nodesToParts","parseContext","reportDiagnostic","parse","leadingHtmlCommentMeta","find","p","meta","id","singleInstance","isNullComponent","nullComponent","Component","resolvedSectionOptions","resolveSectionOptions","patternValidation","astStartIndex"],"sources":["../../../src/component/componentParser.ts"],"sourcesContent":["/**\n * Markdown → component orchestrator. Lifted from\n * `web50-server-ui/src/utils/componentParser.ts` per DL #088 B9.5.\n *\n * The lift replaces three app-side singletons with options:\n * - `getAppRegistry()` → `options.registry`\n * - `getClientConfigSync(clientId)` → `options.clientConfig`\n * - `setLastDiagnosticsCollector(...)` → returned in the result object\n *\n * Adds a `placement` option that flows into every `registry.resolveSection`\n * call so the placement bundle can pick the placement variant of each section.\n *\n * The app-side `componentParser.ts` is a thin wrapper around this orchestrator\n * that pre-binds its singletons and a product-payload enrichment callback.\n */\nimport type { RootContent } from 'mdast';\nimport React from 'react';\n\nimport { validatePattern } from '../patternValidator';\nimport { nodesToParts } from '../match/astToParts';\nimport { isWeb5ImageUrl } from '../types/link-types';\nimport { findInvalidWeb5Links } from '../utils/web5LinkValidator';\nimport { DIAGNOSTIC_TYPES, type DiagnosticType } from './diagnosticTypes';\nimport { ComponentTracking } from '../utils/componentTracking';\nimport {\n DiagnosticsCollector,\n} from '../utils/diagnosticsCollector';\nimport {\n parseAstToMarkdown,\n parseMarkdownToAst,\n} from '../utils/unifiedMarkdownParser';\nimport { preprocessMarkdown } from '../utils/markdownPreprocessor';\nimport { getIntentFromMarkdown, type IntentInfo } from '../utils/intentExtractor';\nimport { getContextualImageFilename } from '../utils/contentKeywordMatcher';\nimport { createPageSection } from '../utils/propsExtractor';\nimport type { PageSection } from '../types/page-section';\nimport type { ApiPayloadItem } from '../types/entity';\nimport type { ComponentRegistry } from '../registry';\nimport type {\n EntityCompProps,\n GeneralTextCompProps,\n} from './types';\nimport type { SectionDefinition, ParseContext } from './section-definition';\nimport type {\n EnrichEntityProps,\n ParserClientConfig,\n ParserContext,\n} from './parser-types';\n\nexport type { ComponentMatch, ParserContext } from './parser-types';\n\nexport interface ParseMarkdownOptions {\n /** Required — replaces the app-side `getAppRegistry()` singleton. */\n registry: ComponentRegistry<React.FC<any>>;\n /** Replaces `getClientConfigSync(clientId)` — caller resolves it first. */\n clientConfig?: ParserClientConfig | null;\n /** When true, resolveSection prefers placement variants (DL #088 D3.1). */\n placement?: boolean;\n /**\n * Placement slot id (the `data-web5-placement` value) — forwarded to\n * `resolveSection` so a section can resolve a per-placement variant. Only\n * meaningful with `placement: true`.\n */\n placementId?: string;\n /** App-specific payload-to-entity enrichment; omitted by the placement bundle. */\n enrichEntityProps?: EnrichEntityProps;\n /** Reuse an existing collector (e.g. for streaming) instead of creating one. */\n diagnosticsCollector?: DiagnosticsCollector;\n clientId?: string;\n intentInfo?: IntentInfo | null;\n payload?: ApiPayloadItem[];\n disableContextualImages?: boolean;\n}\n\nexport interface ParseMarkdownResult {\n sections: PageSection[];\n tracking: ComponentTracking;\n diagnosticsCollector: DiagnosticsCollector;\n}\n\nfunction isEntityCompProps(props: unknown): props is EntityCompProps {\n return (\n typeof props === 'object' &&\n props !== null &&\n Array.isArray((props as EntityCompProps).items)\n );\n}\n\nfunction isItemsFromContentSection(\n sectionType: string,\n semantic?: string,\n serverSectionId?: string,\n): boolean {\n if (sectionType !== 'entity') {\n return false;\n }\n const normalizedSemantic = semantic?.toLowerCase().replace(/_/g, '-');\n const normalizedId = serverSectionId?.toLowerCase().replace(/_/g, '-');\n return (\n normalizedSemantic === 'items' ||\n normalizedSemantic === 'items-from-content' ||\n normalizedId?.includes('items-from-content') === true\n );\n}\n\n/**\n * Merges new sections with existing sections, maintaining stable references\n * for unchanged sections to prevent unnecessary rerenders.\n */\nexport function mergeSectionsWithStableReferences(\n existingSections: PageSection[],\n newSections: PageSection[],\n): PageSection[] {\n if (existingSections.length === 0) {\n return newSections;\n }\n if (newSections.length < existingSections.length) {\n return newSections;\n }\n\n const merged: PageSection[] = [];\n\n for (let i = 0; i < existingSections.length; i++) {\n const existing = existingSections[i];\n const updated = newSections[i];\n\n if (!updated) {\n merged.push(existing);\n continue;\n }\n\n const existingLength = existing.sourceMarkdown?.length || 0;\n const updatedLength = updated.sourceMarkdown?.length || 0;\n\n if (existingLength === updatedLength) {\n existing.sourceMarkdown = updated.sourceMarkdown;\n existing.component = updated.component;\n existing.componentOptions = updated.componentOptions;\n existing.debugProps = updated.debugProps;\n // V3 (DL #106): a skeleton and its real section both have empty\n // sourceMarkdown, so without carrying this flag the slot would stay a\n // skeleton forever (its real component never rendering).\n existing.isSkeleton = updated.isSkeleton;\n merged.push(existing);\n } else {\n merged.push(updated);\n }\n }\n\n if (newSections.length > existingSections.length) {\n const newSectionsToAdd = newSections.slice(existingSections.length);\n merged.push(...newSectionsToAdd);\n }\n\n return merged;\n}\n\nfunction combineAdjacentGeneralTextSections(\n sections: PageSection[],\n registry: ComponentRegistry<React.FC<any>>,\n placement?: boolean,\n placementId?: string,\n): PageSection[] {\n if (sections.length === 0) {\n return sections;\n }\n\n const combined: PageSection[] = [];\n let i = 0;\n\n while (i < sections.length) {\n const currentSection = sections[i];\n if (currentSection.sectionType === 'fallback') {\n const sectionsToCombine: PageSection[] = [currentSection];\n let j = i + 1;\n\n while (j < sections.length && sections[j].sectionType === 'fallback') {\n sectionsToCombine.push(sections[j]);\n j++;\n }\n\n if (sectionsToCombine.length > 1) {\n const mergedSection = mergeGeneralTextSections(\n sectionsToCombine,\n combined.length,\n registry,\n placement,\n placementId,\n );\n combined.push(mergedSection);\n i = j;\n } else {\n combined.push(currentSection);\n i++;\n }\n } else {\n combined.push(currentSection);\n i++;\n }\n }\n\n return combined;\n}\n\nfunction mergeGeneralTextSections(\n sections: PageSection[],\n index: number,\n registry: ComponentRegistry<React.FC<any>>,\n placement?: boolean,\n placementId?: string,\n): PageSection {\n if (sections.length === 0) {\n throw new Error('Cannot merge empty sections array');\n }\n if (sections.length === 1) {\n return sections[0];\n }\n\n const mergedSourceMarkdown = sections\n .map((section) => section.sourceMarkdown || '')\n .filter((markdown) => markdown.trim().length > 0)\n .join('\\n\\n');\n\n const mergedProps: GeneralTextCompProps = {\n markdown: mergedSourceMarkdown,\n };\n\n const FallbackComponent = registry.resolveSection('fallback', {\n placement,\n placementId,\n });\n const mergedComponent = React.createElement(FallbackComponent, mergedProps);\n\n return createPageSection({\n sectionType: 'fallback',\n componentName:\n (FallbackComponent as React.FC).displayName || FallbackComponent.name,\n index,\n component: mergedComponent,\n sourceMarkdown: mergedSourceMarkdown,\n debugProps: mergedProps,\n });\n}\n\nexport function parseMarkdownToComponents(\n pageMarkdown: string,\n options: ParseMarkdownOptions,\n): ParseMarkdownResult {\n const {\n registry,\n clientConfig,\n placement,\n placementId,\n enrichEntityProps,\n clientId,\n intentInfo: providedIntent,\n payload,\n disableContextualImages: explicitDisableImages,\n } = options;\n\n const { markdown: preprocessedMarkdown, diagnostics: preprocessDiagnostics } =\n preprocessMarkdown(pageMarkdown);\n\n // Validate the emitted intent against this client's own registered intents\n // (its taxonomy), falling back to core's DEFAULT_INTENTS when the registry\n // declares none.\n const knownIntents = registry.getKnownIntents();\n const intentInfo =\n providedIntent ??\n getIntentFromMarkdown(preprocessedMarkdown, {\n validIntents: knownIntents.length > 0 ? knownIntents : undefined,\n });\n\n const allNodes: RootContent[] = [\n ...parseMarkdownToAst(preprocessedMarkdown).children,\n ];\n const nodes: RootContent[] = [...allNodes];\n\n const sections: PageSection[] = [];\n const tracking = new ComponentTracking();\n const diagnosticsCollector =\n options.diagnosticsCollector ?? new DiagnosticsCollector();\n\n for (const d of preprocessDiagnostics) {\n diagnosticsCollector.report({\n diagnosticType: d.type as DiagnosticType,\n sectionType: 'preprocessor',\n sectionIndex: -1,\n details: `${d.original} → ${d.normalized}`,\n });\n }\n\n const disableContextualImages =\n explicitDisableImages ??\n clientConfig?.features?.disableContextualImagesEnrichment ??\n false;\n\n const context: ParserContext = {\n registry,\n clientConfig,\n placement,\n placementId,\n enrichEntityProps,\n clientId,\n intent: intentInfo,\n tracking,\n disableContextualImages,\n diagnosticsCollector,\n payload,\n };\n let currentGlobalIndex = 0;\n\n while (nodes.length > 0) {\n const startIndex = currentGlobalIndex;\n const { section, parsedCount } = tryParseComponent(\n nodes,\n sections.length,\n context,\n );\n\n if (!parsedCount) {\n break;\n }\n\n if (section) {\n section.sourceMarkdown = parseAstToMarkdown(nodes.slice(0, parsedCount));\n sections.push(section);\n\n const endIndex = startIndex + parsedCount;\n tracking.addRange(\n section.sectionType,\n startIndex,\n endIndex,\n sections.length - 1,\n );\n } else {\n const endIndex = startIndex + parsedCount;\n tracking.addRange('', startIndex, endIndex, -1);\n }\n\n currentGlobalIndex += parsedCount;\n nodes.splice(0, parsedCount);\n }\n\n for (const link of findInvalidWeb5Links(allNodes)) {\n let diagnosticType: DiagnosticType;\n let label: string;\n switch (link.reason) {\n case 'legacy':\n diagnosticType = DIAGNOSTIC_TYPES.LEGACY_PROTOCOL_LINK;\n label = 'legacy protocol';\n break;\n case 'empty':\n diagnosticType = DIAGNOSTIC_TYPES.INVALID_LINK_FORMAT;\n label = 'empty href';\n break;\n default:\n diagnosticType = DIAGNOSTIC_TYPES.BROKEN_WEB5_LINK;\n label = 'web5://';\n break;\n }\n diagnosticsCollector.report({\n diagnosticType,\n sectionType: 'parser',\n sectionIndex: -1,\n details: `Invalid ${label} URL in ${link.nodeType}: ${link.url}`.slice(\n 0,\n 200,\n ),\n });\n }\n\n const combinedSections = combineAdjacentGeneralTextSections(\n sections,\n registry,\n placement,\n placementId,\n );\n\n return {\n sections: combinedSections,\n tracking,\n diagnosticsCollector,\n };\n}\n\nexport function tryParseComponent(\n nodes: RootContent[],\n sectionIndex: number,\n context: ParserContext,\n): { section?: PageSection; parsedCount?: number } {\n if (!nodes?.length) {\n return {};\n }\n\n const registry = context.registry;\n const placement = context.placement;\n const placementId = context.placementId;\n const definitions = registry.getAllDefinitions();\n\n const clientConfig = context.clientConfig ?? null;\n const allowedKeywords = clientConfig?.allowedImageSearchKeywords ?? [];\n const disableContextualImages = context.disableContextualImages ?? false;\n\n const baseParseContext: ParseContext = {\n getContextualImage:\n disableContextualImages || allowedKeywords.length === 0\n ? undefined\n : (contentParts) => {\n const result = getContextualImageFilename(\n contentParts,\n allowedKeywords,\n '',\n context.tracking,\n );\n return isWeb5ImageUrl(result.filename) ? result : null;\n },\n getComponentCount: context.tracking\n ? (sectionType) => context.tracking!.getComponentCount(sectionType)\n : undefined,\n setMeta: context.tracking\n ? (sectionType, key, value) =>\n context.tracking!.setMeta(sectionType, key, value)\n : undefined,\n getMeta: context.tracking\n ? (sectionType, key) => context.tracking!.getMeta(sectionType, key)\n : undefined,\n };\n\n for (const { sectionType, definition } of definitions) {\n // Placement-only definitions (registered with `{ placement: true }`\n // variants and no non-placement variant) must not match in a non-placement\n // render (the main app) — their markdown should fall through to the generic\n // sections there. Skip them unless this is a placement parse.\n if (!placement && registry.isPlacementOnly(sectionType)) {\n continue;\n }\n for (const pattern of definition.patterns) {\n const result = validatePattern(nodes, pattern);\n if (!result.valid) {\n continue;\n }\n\n let parsedNodes =\n result.astEndIndex !== undefined && result.astEndIndex >= 0\n ? result.astEndIndex + 1\n : result.endIndex >= 0\n ? result.endIndex + 1\n : 1;\n\n const maxNodes = (\n definition as SectionDefinition & { maxConsumedNodes?: number }\n ).maxConsumedNodes;\n if (typeof maxNodes === 'number' && parsedNodes > maxNodes) {\n parsedNodes = maxNodes;\n }\n\n const matchedNodes = nodes.slice(0, parsedNodes);\n const parts = nodesToParts(matchedNodes);\n const parseContext: ParseContext = {\n ...baseParseContext,\n reportDiagnostic: context.diagnosticsCollector\n ? (type, details) => {\n context.diagnosticsCollector!.report({\n diagnosticType: type,\n sectionType,\n sectionIndex,\n details: details.slice(0, 200),\n });\n }\n : undefined,\n };\n let props = definition.parse(parts, parseContext);\n\n if (props === null) {\n continue;\n }\n\n const leadingHtmlCommentMeta = parts.find(\n (p) => p.type === 'htmlComment' && p.meta,\n )?.meta;\n const semantic = leadingHtmlCommentMeta?.semantic as string | undefined;\n const serverSectionId = leadingHtmlCommentMeta?.id as string | undefined;\n\n if (\n isEntityCompProps(props) &&\n isItemsFromContentSection(sectionType, semantic, serverSectionId) &&\n context.enrichEntityProps\n ) {\n props = context.enrichEntityProps(props, {\n payload: context.payload,\n clientConfig,\n sectionType,\n semantic,\n serverSectionId,\n });\n }\n\n if (\n definition.singleInstance &&\n context.tracking &&\n context.tracking.getComponentCount(sectionType) > 0\n ) {\n continue;\n }\n\n const isNullComponent =\n (definition as SectionDefinition & { nullComponent?: boolean })\n .nullComponent === true;\n if (isNullComponent) {\n return { parsedCount: parsedNodes };\n }\n\n const intent = context.intent?.intent;\n const Component = registry.resolveSection(sectionType, {\n intent,\n semantic,\n placement,\n placementId,\n });\n const resolvedSectionOptions = registry.resolveSectionOptions(\n sectionType,\n { intent, semantic, placement, placementId },\n );\n const component = React.createElement(Component, props);\n const componentName =\n Component.displayName || Component.name || undefined;\n\n const section = createPageSection({\n sectionType,\n componentName,\n semantic,\n componentOptions: resolvedSectionOptions?.componentOptions,\n index: sectionIndex,\n id: serverSectionId,\n component,\n sourceMarkdown: '',\n debugProps: {\n ...props,\n patternValidation: {\n astStartIndex: result.astStartIndex,\n astEndIndex: result.astEndIndex,\n endIndex: result.endIndex,\n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