@homepages/concrete 7.0.0 → 9.0.0

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 (331) hide show
  1. package/CHANGELOG.md +1007 -0
  2. package/README.md +20 -9
  3. package/codemods/list-grammar.mjs +923 -0
  4. package/codemods/manifest.json +66 -0
  5. package/codemods/process-builders.mjs +198 -0
  6. package/codemods/slot-object.mjs +1097 -0
  7. package/codemods/steps/content-object-fields.mjs +324 -0
  8. package/codemods/steps/list-object-form.mjs +6 -7
  9. package/codemods/table-rows.mjs +568 -0
  10. package/codemods/unwrap-object-fields.mjs +310 -0
  11. package/codemods/viewer-slot-document.mjs +131 -0
  12. package/codemods/write-property-as-facts-document.mjs +716 -0
  13. package/codemods/write-the-address-line.mjs +255 -0
  14. package/codemods/write-the-registry-members.mjs +653 -0
  15. package/codemods/write-the-select-from.mjs +141 -0
  16. package/codemods/write-the-sole-from.mjs +369 -0
  17. package/codemods/write-the-table-from.mjs +267 -0
  18. package/codemods/write-the-whole-item.mjs +512 -0
  19. package/codemods/writeback-drop.mjs +168 -0
  20. package/codemods/written-contact-address.mjs +162 -0
  21. package/codemods/written-media-category.mjs +227 -0
  22. package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
  23. package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
  24. package/codemods/written-uploads-sort-into-lists.mjs +405 -0
  25. package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
  26. package/codemods/written-video-sources-drop.mjs +144 -0
  27. package/codemods/written-without-pick-none.mjs +146 -0
  28. package/codemods/written-without-retired-knowledge.mjs +223 -0
  29. package/codemods/written-without-the-media-key.mjs +202 -0
  30. package/codemods/written-without-the-property-type.mjs +249 -0
  31. package/dist/artifact/playground/client/assets/index-BUmdDDX5.js +1259 -0
  32. package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
  33. package/dist/artifact/playground/client/index.html +2 -2
  34. package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
  35. package/dist/artifact/playground/host.mjs +61 -27
  36. package/dist/base.css +58 -1
  37. package/dist/cli/build/artifact.js +6 -9
  38. package/dist/cli/build/captures.js +2 -12
  39. package/dist/cli/build/esbuild.js +1 -25
  40. package/dist/cli/build/fixtures.js +2 -1
  41. package/dist/cli/build/icons.js +1 -1
  42. package/dist/cli/build/static.js +2 -2
  43. package/dist/cli/capture/capture.js +8 -9
  44. package/dist/cli/check/analyze.js +8 -1
  45. package/dist/cli/check/load-outdir.js +47 -0
  46. package/dist/cli/check/load-workspace.js +4 -4
  47. package/dist/cli/check/render/html.js +1 -2
  48. package/dist/cli/check/render/inputs.js +10 -3
  49. package/dist/cli/check/render/island-frames.js +2 -1
  50. package/dist/cli/check/render/marker-coverage.js +23 -15
  51. package/dist/cli/check/report.js +5 -0
  52. package/dist/cli/check/stages/bundles.js +1 -1
  53. package/dist/cli/check/stages/relations.js +1 -1
  54. package/dist/cli/check/stages/render.js +48 -33
  55. package/dist/cli/check/stages/sections.js +83 -31
  56. package/dist/cli/commands.js +1 -1
  57. package/dist/cli/dev/crop.js +1 -1
  58. package/dist/cli/dev/fixture-ladders.js +96 -0
  59. package/dist/cli/dev/islands.js +12 -123
  60. package/dist/cli/dev/listen.js +20 -1
  61. package/dist/cli/dev/load-template.js +1 -1
  62. package/dist/cli/dev/server.js +35 -10
  63. package/dist/cli/dev/vite.js +9 -7
  64. package/dist/cli/dev/workspace-reader.js +16 -16
  65. package/dist/cli/media/derive.js +43 -57
  66. package/dist/cli/media/frame-rung-floor.js +0 -1
  67. package/dist/cli/property/index.js +1 -6
  68. package/dist/css/inline.js +1 -22
  69. package/dist/eslint/rules/no-marker-literal.js +1 -1
  70. package/dist/fixtures/load.js +16 -7
  71. package/dist/fixtures/media-plugin.js +17 -12
  72. package/dist/fixtures/media-store.js +115 -0
  73. package/dist/fixtures/property.js +345 -126
  74. package/dist/fixtures/resolve.js +263 -251
  75. package/dist/fixtures/rows.js +4 -11
  76. package/dist/fixtures.d.ts +234 -109
  77. package/dist/index.d.ts +25 -16
  78. package/dist/index.js +10 -6
  79. package/dist/islands/marker.js +2 -1
  80. package/dist/packages/external/concrete/package.js +1 -1
  81. package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
  82. package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
  83. package/dist/packages/internal/capture-settle/dist/index.js +3 -0
  84. package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
  85. package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
  86. package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
  87. package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
  88. package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +252 -35
  89. package/dist/packages/internal/fill-bake/dist/compute-reads.js +365 -4
  90. package/dist/packages/internal/fill-bake/dist/derive-source.js +35 -21
  91. package/dist/packages/internal/fill-bake/dist/index.js +8 -3
  92. package/dist/packages/internal/fill-bake/dist/item-merge.js +119 -0
  93. package/dist/packages/internal/fill-bake/dist/item-overrides.js +28 -0
  94. package/dist/packages/internal/fill-bake/dist/linked-merge.js +40 -0
  95. package/dist/packages/internal/fill-bake/dist/list-grammar.js +175 -0
  96. package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
  97. package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +390 -0
  98. package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
  99. package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +1 -1
  100. package/dist/packages/internal/fill-vocabulary/dist/verbs.js +75 -0
  101. package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
  102. package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
  103. package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
  104. package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
  105. package/dist/packages/internal/image-ladder/dist/index.js +3 -3
  106. package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
  107. package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
  108. package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
  109. package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
  110. package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
  111. package/dist/packages/internal/island-runtime/dist/index.js +2 -1
  112. package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
  113. package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
  114. package/dist/packages/internal/media-resolution/dist/document.js +63 -0
  115. package/dist/packages/internal/media-resolution/dist/image.js +228 -0
  116. package/dist/packages/internal/media-resolution/dist/index.js +11 -0
  117. package/dist/packages/internal/media-resolution/dist/list.js +112 -0
  118. package/dist/packages/internal/media-resolution/dist/media.js +59 -0
  119. package/dist/packages/internal/media-resolution/dist/records.js +7 -0
  120. package/dist/packages/internal/media-resolution/dist/slot.js +34 -0
  121. package/dist/packages/internal/media-resolution/dist/store.js +19 -0
  122. package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
  123. package/dist/packages/internal/media-resolution/dist/video.js +93 -0
  124. package/dist/packages/internal/property-facts/dist/registry-facts.js +244 -0
  125. package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
  126. package/dist/packages/internal/section-contracts/dist/catalog.js +35 -27
  127. package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
  128. package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +27 -0
  129. package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
  130. package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -0
  131. package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
  132. package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
  133. package/dist/packages/internal/section-contracts/dist/index.js +7 -5
  134. package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +23 -19
  135. package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -7
  136. package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
  137. package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
  138. package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
  139. package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +5 -5
  140. package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
  141. package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +7 -4
  142. package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +83 -0
  143. package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
  144. package/dist/packages/internal/section-contracts/dist/runners.js +77 -33
  145. package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
  146. package/dist/packages/internal/section-contracts/dist/source-contract.js +120 -66
  147. package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
  148. package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
  149. package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +43 -18
  150. package/dist/packages/internal/source-resolution/dist/index.js +113 -118
  151. package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
  152. package/dist/packages/internal/street-address/dist/index.js +72 -0
  153. package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
  154. package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
  155. package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
  156. package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
  157. package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
  158. package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
  159. package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
  160. package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
  161. package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
  162. package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
  163. package/dist/packages/internal/template-contracts/dist/decision-fills.js +85 -0
  164. package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
  165. package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
  166. package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
  167. package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
  168. package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
  169. package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
  170. package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
  171. package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
  172. package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +12 -36
  173. package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
  174. package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
  175. package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
  176. package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
  177. package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +158 -0
  178. package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
  179. package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
  180. package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
  181. package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
  182. package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
  183. package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
  184. package/dist/packages/internal/template-contracts/dist/list-editing.js +94 -0
  185. package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
  186. package/dist/packages/internal/template-contracts/dist/list.js +258 -0
  187. package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
  188. package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
  189. package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
  190. package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
  191. package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
  192. package/dist/packages/internal/template-contracts/dist/object.js +131 -0
  193. package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
  194. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
  195. package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
  196. package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
  197. package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
  198. package/dist/packages/internal/template-contracts/dist/read-graph.js +250 -0
  199. package/dist/packages/internal/template-contracts/dist/ref-locate.js +192 -0
  200. package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
  201. package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +268 -0
  202. package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
  203. package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
  204. package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
  205. package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
  206. package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
  207. package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
  208. package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +133 -0
  209. package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
  210. package/dist/packages/internal/template-contracts/dist/row-sources.js +48 -8
  211. package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
  212. package/dist/packages/internal/template-contracts/dist/row.js +84 -0
  213. package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
  214. package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
  215. package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
  216. package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +243 -384
  217. package/dist/packages/internal/template-contracts/dist/slot-catalog.js +334 -230
  218. package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
  219. package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
  220. package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
  221. package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
  222. package/dist/packages/internal/template-contracts/dist/slot-types.js +140 -0
  223. package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +97 -0
  224. package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
  225. package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
  226. package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
  227. package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
  228. package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
  229. package/dist/platform/fs.js +5 -2
  230. package/dist/playground/canvas-island-host.d.ts +11 -0
  231. package/dist/playground/canvas-island-host.js +29 -0
  232. package/dist/playground/canvas-markers.js +14 -0
  233. package/dist/playground-island-runtime.d.ts +3 -2
  234. package/dist/playground-island-runtime.js +3 -2
  235. package/dist/primitives/FrameShell.js +0 -1
  236. package/dist/primitives/Image.d.ts +5 -4
  237. package/dist/primitives/Tour.d.ts +1 -1
  238. package/dist/primitives/Video.d.ts +2 -2
  239. package/dist/primitives/index.d.ts +2 -3
  240. package/dist/primitives/picture-sources.js +2 -2
  241. package/dist/primitives/probe-context.js +2 -12
  242. package/dist/primitives/slot-address.d.ts +44 -0
  243. package/dist/primitives/slot-address.js +19 -0
  244. package/dist/primitives/slot-bindings.d.ts +65 -26
  245. package/dist/primitives/slot-bindings.js +104 -46
  246. package/dist/primitives/slot-document.d.ts +23 -18
  247. package/dist/primitives/slot-document.js +39 -14
  248. package/dist/primitives/slot-download.d.ts +39 -0
  249. package/dist/primitives/slot-download.js +39 -0
  250. package/dist/primitives/slot-list.d.ts +3 -3
  251. package/dist/primitives/slot-list.js +0 -2
  252. package/dist/primitives/slot-media.d.ts +24 -5
  253. package/dist/primitives/slot-media.js +6 -9
  254. package/dist/primitives/slot-object.d.ts +49 -0
  255. package/dist/primitives/slot-object.js +20 -0
  256. package/dist/primitives/slot-scalar.d.ts +27 -2
  257. package/dist/primitives/slot-scalar.js +50 -7
  258. package/dist/primitives/slot.d.ts +13 -6
  259. package/dist/primitives/slot.js +10 -3
  260. package/dist/rules/registry.js +19 -30
  261. package/dist/schema/define-schema.d.ts +4 -8
  262. package/dist/schema/define-schema.js +178 -79
  263. package/dist/schema/extract-fill-spec.js +2 -158
  264. package/dist/schema/fact.d.ts +57 -15
  265. package/dist/schema/fact.js +42 -7
  266. package/dist/schema/facts-view.d.ts +14 -0
  267. package/dist/schema/format.d.ts +1 -0
  268. package/dist/schema/format.js +2 -1
  269. package/dist/schema/manifest.js +24 -0
  270. package/dist/schema/property-facts.d.ts +8 -11
  271. package/dist/schema/section-props.d.ts +2 -66
  272. package/dist/schema/section-schema.d.ts +8 -11
  273. package/dist/schema/section-schema.js +27 -10
  274. package/dist/section/declare.d.ts +18 -7
  275. package/dist/section/declare.js +18 -5
  276. package/dist/section/materialize.js +3 -8
  277. package/dist/section/section.d.ts +12 -8
  278. package/dist/section/section.js +1 -1
  279. package/dist/template/logic-shim.d.ts +14 -7
  280. package/dist/template/logic-shim.js +14 -7
  281. package/dist/template/materialize.js +17 -18
  282. package/dist/template/mirror-types.js +30 -31
  283. package/dist/template/section-reads.js +85 -9
  284. package/guide/reference/cli/INDEX.md +2 -2
  285. package/guide/reference/cli/build.md +1 -1
  286. package/guide/reference/cli/check.md +1 -1
  287. package/guide/reference/cli/dev.md +1 -1
  288. package/guide/reference/cli/property-add.md +1 -1
  289. package/guide/reference/cli/property-list.md +2 -2
  290. package/guide/reference/cli/publish.md +1 -1
  291. package/guide/reference/cli/upgrade.md +1 -1
  292. package/guide/reference/rules/INDEX.md +29 -29
  293. package/package.json +9 -8
  294. package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
  295. package/dist/artifact/playground/client/assets/index-D8eepVr-.js +0 -1101
  296. package/dist/fixtures/canonical.d.ts +0 -166
  297. package/dist/fixtures/media.js +0 -163
  298. package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -111
  299. package/dist/packages/internal/format-geometry/dist/index.js +0 -4
  300. package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
  301. package/dist/packages/internal/property-facts/dist/index.js +0 -3
  302. package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
  303. package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +0 -20
  304. package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
  305. package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -22
  306. package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
  307. package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
  308. package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
  309. package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -111
  310. package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
  311. package/dist/primitives/slot-group.d.ts +0 -40
  312. package/dist/primitives/slot-group.js +0 -36
  313. package/dist/schema/extract-used-facts.js +0 -34
  314. package/dist/schema/fill-builders.d.ts +0 -115
  315. package/dist/schema/fill-builders.js +0 -25
  316. package/dist/schema/fill-declaration.d.ts +0 -14
  317. package/dist/schema/fill-spec.js +0 -89
  318. package/dist/schema/layout.d.ts +0 -30
  319. package/dist/schema/layout.js +0 -14
  320. package/dist/schema/row-fields.js +0 -88
  321. package/dist/schema/row-ref.d.ts +0 -59
  322. package/dist/schema/row-ref.js +0 -28
  323. package/dist/schema/runtime-values.d.ts +0 -71
  324. package/dist/schema/section-nav.js +0 -14
  325. package/dist/schema/slot-builders.d.ts +0 -613
  326. package/dist/schema/slot-builders.js +0 -177
  327. package/dist/schema/slot-ref.d.ts +0 -79
  328. package/dist/schema/slot-ref.js +0 -41
  329. package/dist/schema/slot-types.d.ts +0 -111
  330. package/dist/schema/slot-types.js +0 -214
  331. package/dist/section/groups.js +0 -68
@@ -0,0 +1,228 @@
1
+ import { cropsPart } from "../../template-contracts/dist/registry-facts.js";
2
+ import { cropKeyOwner } from "./crop-key.js";
3
+ import { readLadder } from "./store.js";
4
+ import { placeCrop } from "../../template-contracts/dist/content-pick.js";
5
+
6
+ //#region ../../internal/media-resolution/dist/image.js
7
+ function emptyImage() {
8
+ return {
9
+ photo_id: "",
10
+ url: "",
11
+ alt: ""
12
+ };
13
+ }
14
+ function servedKeyOf(asset, mask) {
15
+ const maskKey = mask === void 0 ? void 0 : asset.renditions[mask === "white" ? "mask_white" : "mask_black"]?.key;
16
+ const cutKey = cropsPart(asset.crop) ? asset.renditions.crop?.key : void 0;
17
+ return maskKey ?? asset.renditions.cutout?.key ?? cutKey ?? asset.key;
18
+ }
19
+ async function resolveImageAsset(id, asset, store, opts) {
20
+ if (asset === void 0) {
21
+ store.log?.warn({ id }, "resolve-asset-id: no image asset the render may reach; no asset");
22
+ return null;
23
+ }
24
+ if (asset.kind !== "image") {
25
+ store.log?.warn({
26
+ id,
27
+ kind: asset.kind
28
+ }, "resolve-asset-id: asset is not an image; no asset");
29
+ return null;
30
+ }
31
+ try {
32
+ const servedKey = servedKeyOf(asset, opts?.mask);
33
+ return {
34
+ url: await store.servedUrl(servedKey),
35
+ source_key: servedKey
36
+ };
37
+ } catch (err) {
38
+ store.log?.error({
39
+ id,
40
+ err: err.message
41
+ }, "resolve-asset-id: presign failed; no asset");
42
+ return null;
43
+ }
44
+ }
45
+ function clamp01(n) {
46
+ return n < 0 ? 0 : n > 1 ? 1 : n;
47
+ }
48
+ function normalizeRect(v) {
49
+ const nx = typeof v.nx === "number" ? v.nx : 0;
50
+ const ny = typeof v.ny === "number" ? v.ny : 0;
51
+ const nw = typeof v.nw === "number" ? v.nw : 1;
52
+ const nh = typeof v.nh === "number" ? v.nh : 1;
53
+ if (![
54
+ nx,
55
+ ny,
56
+ nw,
57
+ nh
58
+ ].every(Number.isFinite)) return null;
59
+ const r = {
60
+ nx: clamp01(nx),
61
+ ny: clamp01(ny),
62
+ nw: clamp01(nw),
63
+ nh: clamp01(nh)
64
+ };
65
+ if (r.nx === 0 && r.ny === 0 && r.nw === 1 && r.nh === 1) return null;
66
+ return r;
67
+ }
68
+ function renditionKey(rendition) {
69
+ const key = rendition && typeof rendition === "object" ? rendition.key : void 0;
70
+ return typeof key === "string" && key.length > 0 ? key : null;
71
+ }
72
+ function framingCrop(framing, at, mobile) {
73
+ const rect = framing.rect && typeof framing.rect === "object" ? normalizeRect(framing.rect) : null;
74
+ const stored = rect === null ? null : {
75
+ x: rect.nx,
76
+ y: rect.ny,
77
+ width: rect.nw,
78
+ height: rect.nh
79
+ };
80
+ return at === void 0 ? stored : placeCrop(stored, at.imageAspect, at.aspects, mobile);
81
+ }
82
+ function cutKeyOf(framing, photoId, crop) {
83
+ if (!cropsPart(crop)) return null;
84
+ const key = renditionKey((framing.renditions && typeof framing.renditions === "object" ? framing.renditions : {}).crop) ?? (typeof framing.crop_key === "string" && framing.crop_key.length > 0 ? framing.crop_key : null);
85
+ return key !== null && cropKeyOwner(key) === photoId ? key : null;
86
+ }
87
+ function slotCutKey(v, at) {
88
+ return cutKeyOf(v, readPhotoId(v), framingCrop(v, at));
89
+ }
90
+ function mobileCutKey(v, at) {
91
+ const mobile = v.mobile && typeof v.mobile === "object" ? v.mobile : at === void 0 ? null : {};
92
+ return mobile === null ? null : cutKeyOf(mobile, readPhotoId(v), framingCrop(mobile, at, "mobile"));
93
+ }
94
+ async function mobileCropUrl(key, store) {
95
+ try {
96
+ return { url: await store.servedUrl(key) };
97
+ } catch {
98
+ return null;
99
+ }
100
+ }
101
+ function slotServedKey(v, mask, at) {
102
+ const photoId = readPhotoId(v);
103
+ const renditions = v.renditions && typeof v.renditions === "object" ? v.renditions : {};
104
+ const own = (name) => {
105
+ const key = renditionKey(renditions[name]);
106
+ return key !== null && key.startsWith(`processed/cutout/${photoId}/`) ? key : null;
107
+ };
108
+ return (mask === null ? null : own(mask === "white" ? "mask_white" : "mask_black")) ?? own("cutout") ?? (mask === null ? slotCutKey(v, at) : null);
109
+ }
110
+ function readPhotoId(v) {
111
+ if (typeof v.photo_id === "string" && v.photo_id) return v.photo_id;
112
+ if (typeof v.asset_id === "string" && v.asset_id) return v.asset_id;
113
+ return "";
114
+ }
115
+ async function resolveImageValue(value, assets, store, aspects) {
116
+ if (value === null) return {
117
+ value: null,
118
+ desktopKey: null,
119
+ mobileKey: null
120
+ };
121
+ if (!value || typeof value !== "object") return {
122
+ value: emptyImage(),
123
+ desktopKey: null,
124
+ mobileKey: null
125
+ };
126
+ const v = value;
127
+ const rect = v.rect && typeof v.rect === "object" ? normalizeRect(v.rect) : null;
128
+ const ar = typeof v.ar === "number" ? v.ar : null;
129
+ const photoId = readPhotoId(v);
130
+ const mask = v.mask === "white" || v.mask === "black" ? v.mask : null;
131
+ const asset = photoId ? assets.get(photoId) : void 0;
132
+ const at = aspects === void 0 ? void 0 : {
133
+ aspects,
134
+ imageAspect: imageAspectOf(asset, ar)
135
+ };
136
+ const mobileKey = photoId ? mobileCutKey(v, at) : null;
137
+ const mobile = mobileKey ? await mobileCropUrl(mobileKey, store) : null;
138
+ const alt = typeof v.alt === "string" ? v.alt : "";
139
+ const placedKey = photoId ? slotServedKey(v, mask, at) : null;
140
+ let base;
141
+ let desktopKey;
142
+ if (placedKey) {
143
+ base = {
144
+ photo_id: photoId,
145
+ url: await store.servedUrl(placedKey),
146
+ alt
147
+ };
148
+ desktopKey = placedKey;
149
+ const uncropped = await resolveImageAsset(photoId, asset, store);
150
+ if (uncropped && uncropped.url !== base.url) base.download_url = uncropped.url;
151
+ } else if (photoId) {
152
+ const served = await resolveImageAsset(photoId, asset, store, mask ? { mask } : void 0);
153
+ if (!served) return {
154
+ value: withUnit(emptyImage(), v),
155
+ desktopKey: null,
156
+ mobileKey
157
+ };
158
+ base = {
159
+ photo_id: photoId,
160
+ url: served.url,
161
+ alt
162
+ };
163
+ desktopKey = served.source_key;
164
+ } else if (typeof v.url === "string" && v.url.length > 0) {
165
+ base = {
166
+ photo_id: "",
167
+ url: v.url,
168
+ alt
169
+ };
170
+ desktopKey = null;
171
+ } else return {
172
+ value: withUnit(emptyImage(), v),
173
+ desktopKey: null,
174
+ mobileKey: null
175
+ };
176
+ return {
177
+ value: withUnit(attach(base, rect, ar, mobile), v),
178
+ desktopKey,
179
+ mobileKey: mobile ? mobileKey : null
180
+ };
181
+ }
182
+ function imageAspectOf(asset, ar) {
183
+ if (asset?.kind === "image" && asset.width !== null && asset.height !== null && asset.width > 0 && asset.height > 0) return asset.width / asset.height;
184
+ return ar !== null && ar > 0 ? ar : null;
185
+ }
186
+ async function attachResponsive(entries, store) {
187
+ const ladder = await readLadder(store, entries.flatMap((entry) => [entry.desktopKey, entry.mobileKey]).filter((k) => !!k));
188
+ for (const entry of entries) {
189
+ if (!entry.value) continue;
190
+ const responsive = await ladder.responsiveFor(entry.desktopKey);
191
+ if (responsive) entry.value.responsive = responsive;
192
+ if (entry.value.mobile && entry.mobileKey) {
193
+ const mobileResponsive = await ladder.responsiveFor(entry.mobileKey);
194
+ if (mobileResponsive) entry.value.mobile = {
195
+ ...entry.value.mobile,
196
+ responsive: mobileResponsive
197
+ };
198
+ }
199
+ }
200
+ }
201
+ async function resolveImageSlot(value, assets, store, aspects) {
202
+ const entry = await resolveImageValue(value, assets, store, aspects);
203
+ await attachResponsive([entry], store);
204
+ return entry.value;
205
+ }
206
+ function withUnit(resolved, v) {
207
+ const unitId = v.unit_id;
208
+ const unitLabel = v.unit_label;
209
+ if (typeof unitId === "string") resolved.unit_id = unitId;
210
+ else if (unitId === null) resolved.unit_id = null;
211
+ if (typeof unitLabel === "string") resolved.unit_label = unitLabel;
212
+ else if (unitLabel === null) resolved.unit_label = null;
213
+ if ("floor_label" in v) {
214
+ const floorLabel = typeof v.floor_label === "string" ? v.floor_label : null;
215
+ resolved.floor_label = floorLabel;
216
+ if (resolved.alt === "") resolved.alt = floorLabel ?? "Floor plan";
217
+ }
218
+ return resolved;
219
+ }
220
+ function attach(base, rect, ar, mobile) {
221
+ if (rect) base.rect = rect;
222
+ if (ar) base.ar = ar;
223
+ if (mobile) base.mobile = mobile;
224
+ return base;
225
+ }
226
+
227
+ //#endregion
228
+ export { attachResponsive, emptyImage, mobileCutKey, normalizeRect, resolveImageAsset, resolveImageSlot, resolveImageValue, servedKeyOf, slotCutKey };
@@ -0,0 +1,11 @@
1
+ import { cropKeyOwner } from "./crop-key.js";
2
+ import { resolveDocumentSlot } from "./document.js";
3
+ import { attachResponsive, emptyImage, mobileCutKey, normalizeRect, resolveImageAsset, resolveImageSlot, resolveImageValue, servedKeyOf, slotCutKey } from "./image.js";
4
+ import { resolveTourSlot } from "./tour.js";
5
+ import { resolveVideoSlot } from "./video.js";
6
+ import { resolveMediaSlot } from "./media.js";
7
+ import { itemContentOf, resolveListSlot } from "./list.js";
8
+ import { recordsOf } from "./records.js";
9
+ import { resolveSlotValue } from "./slot.js";
10
+
11
+ export { cropKeyOwner, recordsOf, resolveSlotValue };
@@ -0,0 +1,112 @@
1
+ import { resolveDocumentSlot } from "./document.js";
2
+ import { slotCropAspects } from "../../template-contracts/dist/content-pick.js";
3
+ import { attachResponsive, emptyImage, resolveImageValue } from "./image.js";
4
+ import { resolveTourSlot } from "./tour.js";
5
+ import { resolveVideoSlot } from "./video.js";
6
+ import { resolveMediaSlot } from "./media.js";
7
+
8
+ //#region ../../internal/media-resolution/dist/list.js
9
+ function primitiveOf(type) {
10
+ if (type === "image") return "image";
11
+ if (type === "video") return "video";
12
+ if (type === "tour") return "tour";
13
+ if (type === "document") return "document";
14
+ if (type === "media") return "media";
15
+ if (type === "poi") return "poi";
16
+ return "scalar";
17
+ }
18
+ function itemContentOf(slot) {
19
+ if (slot?.type !== "list") return null;
20
+ const fields = slot.fields ?? (slot.element?.type === "object" ? slot.element?.fields : void 0);
21
+ return fields != null ? {
22
+ kind: "record",
23
+ fields
24
+ } : {
25
+ kind: "primitive",
26
+ primitive: primitiveOf(slot.element?.type)
27
+ };
28
+ }
29
+ async function resolveListSlot(value, slot, ctx) {
30
+ if (!Array.isArray(value)) return [];
31
+ const content = itemContentOf(slot);
32
+ if (content === null) return value;
33
+ return content.kind === "record" ? resolveRecordItems(value, content.fields, ctx) : resolvePrimitiveItems(value, content.primitive, ctx, slot.element);
34
+ }
35
+ async function resolvePrimitiveItems(members, primitive, ctx, element) {
36
+ switch (primitive) {
37
+ case "image": {
38
+ const entries = [];
39
+ for (const member of members) entries.push(await resolveImageValue(member, ctx.assets, ctx.store, slotCropAspects(element?.crop)));
40
+ await attachResponsive(entries, ctx.store);
41
+ return entries.map((entry) => entry.value ?? emptyImage());
42
+ }
43
+ case "video": return (await Promise.all(members.map((member) => resolveVideoSlot(member, ctx.assets, ctx.store)))).filter((v) => v !== null);
44
+ case "tour": return (await Promise.all(members.map((member) => resolveTourSlot(member, ctx.assets, ctx.store)))).filter((t) => t !== null);
45
+ case "document": return (await Promise.all(members.map((member) => resolveDocumentSlot(member, ctx.assets, ctx.store)))).filter((d) => d !== null);
46
+ case "media": return (await Promise.all(members.map((member) => resolveMediaSlot(member, element ?? {}, ctx.assets, ctx.store)))).filter((m) => m !== null);
47
+ case "poi": return members.map((member) => ctx.resolvePoi(member));
48
+ case "scalar": return members;
49
+ }
50
+ }
51
+ async function resolveRecordItems(rows, fields, ctx) {
52
+ if (!Object.values(fields).some(fieldResolves)) return rows;
53
+ const imageEntries = [];
54
+ const out = await resolveRecordRows(rows, fields, ctx, imageEntries);
55
+ await attachResponsive(imageEntries, ctx.store);
56
+ return out;
57
+ }
58
+ async function resolveRecordRows(rows, fields, ctx, batch) {
59
+ const resolvable = Object.entries(fields).filter(([, field]) => fieldResolves(field));
60
+ if (resolvable.length === 0) return rows;
61
+ const out = [];
62
+ for (const rawRow of rows) {
63
+ if (!rawRow || typeof rawRow !== "object" || Array.isArray(rawRow)) {
64
+ out.push(rawRow);
65
+ continue;
66
+ }
67
+ const row = { ...rawRow };
68
+ for (const [fieldId, field] of resolvable) {
69
+ if (!(fieldId in row)) continue;
70
+ row[fieldId] = await resolveField(row[fieldId], field, ctx, batch);
71
+ }
72
+ out.push(row);
73
+ }
74
+ return out;
75
+ }
76
+ function fieldResolves(field) {
77
+ if (primitiveOf(field.type) !== "scalar") return true;
78
+ const content = itemContentOf(field);
79
+ if (content === null) return false;
80
+ if (content.kind === "record") return Object.values(content.fields).some(fieldResolves);
81
+ return content.primitive !== "scalar";
82
+ }
83
+ async function resolveField(value, field, ctx, batch) {
84
+ if (itemContentOf(field) !== null) return resolveNestedList(value, field, ctx, batch);
85
+ switch (primitiveOf(field.type)) {
86
+ case "image": {
87
+ const entry = await resolveImageValue(value, ctx.assets, ctx.store, slotCropAspects(field.crop));
88
+ batch.push(entry);
89
+ return entry.value;
90
+ }
91
+ case "video": return resolveVideoSlot(value, ctx.assets, ctx.store);
92
+ case "tour": return resolveTourSlot(value, ctx.assets, ctx.store);
93
+ case "document": return resolveDocumentSlot(value, ctx.assets, ctx.store);
94
+ case "media": return resolveMediaSlot(value, field, ctx.assets, ctx.store);
95
+ case "poi": return ctx.resolvePoi(value);
96
+ case "scalar": return value;
97
+ }
98
+ }
99
+ async function resolveNestedList(value, field, ctx, batch) {
100
+ if (!Array.isArray(value)) return [];
101
+ const content = itemContentOf(field);
102
+ if (content === null) return value;
103
+ if (content.kind === "record") return resolveRecordRows(value, content.fields, ctx, batch);
104
+ if (content.primitive !== "image") return resolvePrimitiveItems(value, content.primitive, ctx, field.element);
105
+ const entries = [];
106
+ for (const member of value) entries.push(await resolveImageValue(member, ctx.assets, ctx.store, slotCropAspects(field.element?.crop)));
107
+ batch.push(...entries);
108
+ return entries.map((entry) => entry.value ?? emptyImage());
109
+ }
110
+
111
+ //#endregion
112
+ export { itemContentOf, resolveListSlot };
@@ -0,0 +1,59 @@
1
+ import { declaredKinds } from "../../template-contracts/dist/slot-catalog.js";
2
+ import { resolveDocumentSlot } from "./document.js";
3
+ import { slotCropAspects } from "../../template-contracts/dist/content-pick.js";
4
+ import { resolveImageSlot } from "./image.js";
5
+ import { resolveTourSlot } from "./tour.js";
6
+ import { resolveVideoSlot } from "./video.js";
7
+
8
+ //#region ../../internal/media-resolution/dist/media.js
9
+ async function resolveMediaSlot(value, declaration, assets, store) {
10
+ if (value === null || typeof value !== "object") return null;
11
+ const assetId = value.asset_id;
12
+ if (typeof assetId !== "string" || assetId === "") return null;
13
+ const asset = assets.get(assetId);
14
+ if (asset === void 0) {
15
+ store.log?.warn({ asset_id: assetId }, "resolve-media-slot: no asset the render may reach");
16
+ return null;
17
+ }
18
+ if (!declaredKinds(declaration).includes(asset.kind)) {
19
+ store.log?.warn({
20
+ asset_id: assetId,
21
+ kind: asset.kind
22
+ }, "resolve-media-slot: asset is of a kind the slot does not hold");
23
+ return null;
24
+ }
25
+ const reference = { asset_id: assetId };
26
+ switch (asset.kind) {
27
+ case "image": {
28
+ const image = await resolveImageSlot(value, assets, store, slotCropAspects(declaration.crop));
29
+ return image === null ? null : {
30
+ ...image,
31
+ kind: "image"
32
+ };
33
+ }
34
+ case "video": {
35
+ const video = await resolveVideoSlot(reference, assets, store);
36
+ return video === null ? null : {
37
+ ...video,
38
+ kind: "video"
39
+ };
40
+ }
41
+ case "tour": {
42
+ const tour = await resolveTourSlot(reference, assets, store);
43
+ return tour === null ? null : {
44
+ ...tour,
45
+ kind: "tour"
46
+ };
47
+ }
48
+ case "document": {
49
+ const document = await resolveDocumentSlot(reference, assets, store);
50
+ return document === null ? null : {
51
+ ...document,
52
+ kind: "document"
53
+ };
54
+ }
55
+ }
56
+ }
57
+
58
+ //#endregion
59
+ export { resolveMediaSlot };
@@ -0,0 +1,7 @@
1
+ //#region ../../internal/media-resolution/dist/records.js
2
+ function recordsOf(assets) {
3
+ return new Map(Object.entries(assets ?? {}));
4
+ }
5
+
6
+ //#endregion
7
+ export { recordsOf };
@@ -0,0 +1,34 @@
1
+ import { resolveDocumentSlot } from "./document.js";
2
+ import { slotCropAspects } from "../../template-contracts/dist/content-pick.js";
3
+ import { resolveImageSlot } from "./image.js";
4
+ import { resolveTourSlot } from "./tour.js";
5
+ import { resolveVideoSlot } from "./video.js";
6
+ import { resolveMediaSlot } from "./media.js";
7
+ import { itemContentOf, resolveListSlot } from "./list.js";
8
+
9
+ //#region ../../internal/media-resolution/dist/slot.js
10
+ async function resolveSlotValue(value, slot, ctx) {
11
+ if (slot === void 0) return value;
12
+ if (itemContentOf(slot) !== null) return resolveListSlot(value, slot, ctx);
13
+ switch (slot.type) {
14
+ case "image": return resolveImageSlot(value, ctx.assets, ctx.store, slotCropAspects(slot.crop));
15
+ case "video": return resolveVideoSlot(value, ctx.assets, ctx.store);
16
+ case "tour": return resolveTourSlot(value, ctx.assets, ctx.store);
17
+ case "document": return resolveDocumentSlot(value, ctx.assets, ctx.store);
18
+ case "media": return resolveMediaSlot(value, slot, ctx.assets, ctx.store);
19
+ case "poi": return ctx.resolvePoi(value);
20
+ case "object": return resolveObject(value, slot, ctx);
21
+ default: return value;
22
+ }
23
+ }
24
+ async function resolveObject(value, slot, ctx) {
25
+ if (slot.fields == null || !value || typeof value !== "object" || Array.isArray(value)) return value;
26
+ const [row] = await resolveListSlot([value], {
27
+ type: "list",
28
+ fields: slot.fields
29
+ }, ctx);
30
+ return row;
31
+ }
32
+
33
+ //#endregion
34
+ export { resolveSlotValue };
@@ -0,0 +1,19 @@
1
+ //#region ../../internal/media-resolution/dist/store.js
2
+ const NO_LADDER = { responsiveFor: () => Promise.resolve(null) };
3
+ async function readLadder(store, keys) {
4
+ try {
5
+ const ladder = await store.ladder(keys);
6
+ return { responsiveFor: async (key) => {
7
+ try {
8
+ return await ladder.responsiveFor(key);
9
+ } catch {
10
+ return null;
11
+ }
12
+ } };
13
+ } catch {
14
+ return NO_LADDER;
15
+ }
16
+ }
17
+
18
+ //#endregion
19
+ export { readLadder };
@@ -0,0 +1,59 @@
1
+ import { tourEmbedUrl } from "../../template-contracts/dist/slot-catalog.js";
2
+ import { readLadder } from "./store.js";
3
+
4
+ //#region ../../internal/media-resolution/dist/tour.js
5
+ const DEFAULT = {
6
+ tour_id: "",
7
+ url: "",
8
+ poster: "",
9
+ alt: ""
10
+ };
11
+ async function attachPosterResponsive(out, previewKey, store) {
12
+ if (!previewKey || !out.poster) return out;
13
+ const responsive = await (await readLadder(store, [previewKey])).responsiveFor(previewKey);
14
+ if (responsive) out.poster_responsive = responsive;
15
+ return out;
16
+ }
17
+ async function resolveTourSlot(value, assets, store) {
18
+ if (value === null) return null;
19
+ if (typeof value !== "object") return DEFAULT;
20
+ const v = value;
21
+ const tourId = typeof v.tour_id === "string" && v.tour_id ? v.tour_id : typeof v.asset_id === "string" && v.asset_id ? v.asset_id : "";
22
+ if (!tourId) return DEFAULT;
23
+ const asset = assets.get(tourId);
24
+ if (asset === void 0) {
25
+ store.log?.warn({ tour_id: tourId }, "resolve-tour-slot: no tour asset the render may reach");
26
+ return DEFAULT;
27
+ }
28
+ if (asset.kind !== "tour") {
29
+ store.log?.warn({
30
+ tour_id: tourId,
31
+ kind: asset.kind
32
+ }, "resolve-tour-slot: asset is not a tour");
33
+ return DEFAULT;
34
+ }
35
+ try {
36
+ const embed = tourEmbedUrl(asset.url);
37
+ if (embed === null) {
38
+ store.log?.warn({ tour_id: tourId }, "resolve-tour-slot: tour link embeds nowhere");
39
+ return DEFAULT;
40
+ }
41
+ const posterKey = asset.renditions.poster?.key ?? null;
42
+ return attachPosterResponsive({
43
+ tour_id: tourId,
44
+ url: embed,
45
+ poster: posterKey ? await store.fileUrl(posterKey) : "",
46
+ alt: typeof v.alt === "string" ? v.alt : "",
47
+ provider: asset.provider
48
+ }, posterKey, store);
49
+ } catch (err) {
50
+ store.log?.error({
51
+ tour_id: tourId,
52
+ err: err.message
53
+ }, "resolve-tour-slot: presign failed; soft-empty tour");
54
+ return DEFAULT;
55
+ }
56
+ }
57
+
58
+ //#endregion
59
+ export { resolveTourSlot };
@@ -0,0 +1,93 @@
1
+ import { videoEmbedUrl } from "../../template-contracts/dist/slot-catalog.js";
2
+ import { videoSourceOf } from "../../template-contracts/dist/registry-facts.js";
3
+ import { readLadder } from "./store.js";
4
+
5
+ //#region ../../internal/media-resolution/dist/video.js
6
+ const DEFAULT = {
7
+ video_id: "",
8
+ url: "",
9
+ poster: "",
10
+ alt: ""
11
+ };
12
+ async function attachPosterResponsive(out, previewKey, store) {
13
+ if (!previewKey || !out.poster) return out;
14
+ const responsive = await (await readLadder(store, [previewKey])).responsiveFor(previewKey);
15
+ if (responsive) out.poster_responsive = responsive;
16
+ return out;
17
+ }
18
+ async function resolveVideoSlot(value, assets, store) {
19
+ if (value === null) return null;
20
+ if (typeof value !== "object") return DEFAULT;
21
+ const v = value;
22
+ const videoId = typeof v.video_id === "string" && v.video_id ? v.video_id : typeof v.asset_id === "string" && v.asset_id ? v.asset_id : "";
23
+ if (!videoId) return DEFAULT;
24
+ const asset = assets.get(videoId);
25
+ if (asset === void 0) {
26
+ store.log?.warn({ video_id: videoId }, "resolve-video-slot: no video asset the render may reach");
27
+ return DEFAULT;
28
+ }
29
+ if (asset.kind !== "video") {
30
+ store.log?.warn({
31
+ video_id: videoId,
32
+ kind: asset.kind
33
+ }, "resolve-video-slot: asset is not a video");
34
+ return DEFAULT;
35
+ }
36
+ const posterKey = asset.renditions.poster?.key ?? null;
37
+ const alt = typeof v.alt === "string" ? v.alt : "";
38
+ try {
39
+ if (videoSourceOf(asset) === "link") {
40
+ const url = asset.url;
41
+ const embed = videoEmbedUrl(url);
42
+ if (!embed) {
43
+ store.log?.warn({ video_id: videoId }, "resolve-video-slot: link upload embeds nowhere");
44
+ return DEFAULT;
45
+ }
46
+ const out = {
47
+ video_id: videoId,
48
+ url: embed,
49
+ poster: posterKey ? await store.fileUrl(posterKey) : "",
50
+ alt,
51
+ source: "link"
52
+ };
53
+ if (asset.provider !== null) out.provider = asset.provider;
54
+ return attachPosterResponsive(out, posterKey, store);
55
+ }
56
+ const poster = posterKey ? await store.fileUrl(posterKey) : "";
57
+ const encode = asset.renditions.encode;
58
+ if (encode === null) {
59
+ store.log?.warn({
60
+ video_id: videoId,
61
+ state: asset.state
62
+ }, "resolve-video-slot: no encode; poster-only");
63
+ if (asset.state !== "failed") store.notePending?.({
64
+ kind: "video",
65
+ id: videoId
66
+ });
67
+ return attachPosterResponsive({
68
+ video_id: videoId,
69
+ url: "",
70
+ poster,
71
+ alt
72
+ }, posterKey, store);
73
+ }
74
+ const out = {
75
+ video_id: videoId,
76
+ url: await store.fileUrl(encode.key),
77
+ poster,
78
+ alt
79
+ };
80
+ if (encode.width !== null) out.width = encode.width;
81
+ if (encode.height !== null) out.height = encode.height;
82
+ return attachPosterResponsive(out, posterKey, store);
83
+ } catch (err) {
84
+ store.log?.error({
85
+ video_id: videoId,
86
+ err: err.message
87
+ }, "resolve-video-slot: presign failed; soft-empty video");
88
+ return DEFAULT;
89
+ }
90
+ }
91
+
92
+ //#endregion
93
+ export { resolveVideoSlot };