qrdx 0.0.51 → 0.0.52

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 (436) hide show
  1. package/README.md +102 -6
  2. package/dist/angular.js +252 -0
  3. package/dist/angular.js.map +1 -0
  4. package/dist/angular.mjs +226 -0
  5. package/dist/angular.mjs.map +1 -0
  6. package/dist/core.js +7 -7
  7. package/dist/core.js.map +1 -1
  8. package/dist/core.mjs +7 -7
  9. package/dist/core.mjs.map +1 -1
  10. package/dist/element-define.browser.mjs +2 -0
  11. package/dist/element-define.browser.mjs.map +1 -0
  12. package/dist/element-define.js +2 -0
  13. package/dist/element-define.js.map +1 -0
  14. package/dist/element-define.mjs +2 -0
  15. package/dist/element-define.mjs.map +1 -0
  16. package/dist/element.browser.mjs +91 -0
  17. package/dist/element.browser.mjs.map +1 -0
  18. package/dist/element.js +2 -0
  19. package/dist/element.js.map +1 -0
  20. package/dist/element.mjs +2 -0
  21. package/dist/element.mjs.map +1 -0
  22. package/dist/frames-index.js +1 -1
  23. package/dist/frames-index.js.map +1 -1
  24. package/dist/frames-index.mjs +1 -1
  25. package/dist/frames-index.mjs.map +1 -1
  26. package/dist/frames-official.js +1 -1
  27. package/dist/frames-official.js.map +1 -1
  28. package/dist/frames-official.mjs +1 -1
  29. package/dist/frames-official.mjs.map +1 -1
  30. package/dist/index.js +7 -7
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +7 -7
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/preact.js +2 -0
  35. package/dist/preact.js.map +1 -0
  36. package/dist/preact.mjs +2 -0
  37. package/dist/preact.mjs.map +1 -0
  38. package/dist/qr-code-canvas.js +1 -1
  39. package/dist/qr-code-canvas.js.map +1 -1
  40. package/dist/qr-code-canvas.mjs +1 -1
  41. package/dist/qr-code-canvas.mjs.map +1 -1
  42. package/dist/solid.js +2 -0
  43. package/dist/solid.js.map +1 -0
  44. package/dist/solid.mjs +2 -0
  45. package/dist/solid.mjs.map +1 -0
  46. package/dist/src/angular.d.ts +94 -0
  47. package/dist/src/element-define.d.ts +3 -0
  48. package/dist/src/element-define.d.ts.map +1 -0
  49. package/dist/src/element.d.ts +150 -0
  50. package/dist/src/element.d.ts.map +1 -0
  51. package/dist/src/engine.d.ts +3 -3
  52. package/dist/src/engine.d.ts.map +1 -1
  53. package/dist/src/frame-spec.d.ts +22 -4
  54. package/dist/src/frame-spec.d.ts.map +1 -1
  55. package/dist/src/frame-text.d.ts +19 -0
  56. package/dist/src/frame-text.d.ts.map +1 -0
  57. package/dist/src/frame.d.ts +12 -7
  58. package/dist/src/frame.d.ts.map +1 -1
  59. package/dist/src/frames/builtin.d.ts +53 -5
  60. package/dist/src/frames/builtin.d.ts.map +1 -1
  61. package/dist/src/frames/catalogue/all.d.ts.map +1 -1
  62. package/dist/src/frames/catalogue/automotive.d.ts.map +1 -1
  63. package/dist/src/frames/catalogue/counts.d.ts +6 -6
  64. package/dist/src/frames/catalogue/counts.d.ts.map +1 -1
  65. package/dist/src/frames/catalogue/events.d.ts.map +1 -1
  66. package/dist/src/frames/catalogue/holidays.d.ts.map +1 -1
  67. package/dist/src/frames/catalogue/index.d.ts.map +1 -1
  68. package/dist/src/frames/catalogue/places.d.ts.map +1 -1
  69. package/dist/src/frames/catalogue/seasons.d.ts.map +1 -1
  70. package/dist/src/frames/catalogue/tags.d.ts.map +1 -1
  71. package/dist/src/preact.d.ts +29 -0
  72. package/dist/src/preact.d.ts.map +1 -0
  73. package/dist/src/scan-score.d.ts +4 -3
  74. package/dist/src/scan-score.d.ts.map +1 -1
  75. package/dist/src/solid.d.ts +21 -0
  76. package/dist/src/solid.d.ts.map +1 -0
  77. package/dist/src/template/dot-ring-layout.d.ts +44 -0
  78. package/dist/src/template/dot-ring-layout.d.ts.map +1 -0
  79. package/dist/src/template/dot-ring.d.ts +41 -0
  80. package/dist/src/template/dot-ring.d.ts.map +1 -0
  81. package/dist/src/template/index.d.ts +1 -0
  82. package/dist/src/template/index.d.ts.map +1 -1
  83. package/dist/src/template-placement.d.ts +8 -0
  84. package/dist/src/template-placement.d.ts.map +1 -0
  85. package/dist/src/templates.d.ts.map +1 -1
  86. package/dist/types/frame-spec.d.ts +149 -14
  87. package/dist/types/frame-spec.d.ts.map +1 -1
  88. package/dist/types/index.js +2 -2
  89. package/dist/types/index.js.map +1 -1
  90. package/dist/types/index.mjs +2 -2
  91. package/dist/types/index.mjs.map +1 -1
  92. package/dist/types/qr.d.ts +26 -3
  93. package/dist/types/qr.d.ts.map +1 -1
  94. package/dist/vanilla.browser.mjs +30 -30
  95. package/dist/vanilla.browser.mjs.map +1 -1
  96. package/package.json +81 -5
  97. package/src/angular.ts +218 -0
  98. package/src/element-define.ts +9 -0
  99. package/src/element.ts +608 -0
  100. package/src/engine.ts +13 -2
  101. package/src/frame-spec.ts +314 -54
  102. package/src/frame-text.ts +111 -0
  103. package/src/frame.tsx +17 -280
  104. package/src/frames/builtin/badge.json +108 -0
  105. package/src/frames/builtin/banner-bottom.json +2 -1
  106. package/src/frames/builtin/banner-top-bottom.json +72 -0
  107. package/src/frames/builtin/banner-top.json +59 -0
  108. package/src/frames/builtin/border.json +62 -0
  109. package/src/frames/builtin/chat-bubble.json +54 -0
  110. package/src/frames/builtin/circle.json +2 -1
  111. package/src/frames/builtin/envelope.json +81 -0
  112. package/src/frames/builtin/focus.json +88 -0
  113. package/src/frames/builtin/gradient-border.json +76 -0
  114. package/src/frames/builtin/menu-card.json +108 -0
  115. package/src/frames/builtin/phone.json +75 -0
  116. package/src/frames/builtin/polaroid.json +56 -0
  117. package/src/frames/builtin/rounded-border.json +8 -4
  118. package/src/frames/builtin/speech-bubble-top.json +76 -0
  119. package/src/frames/builtin/speech-bubble.json +76 -0
  120. package/src/frames/builtin/sticker.json +78 -0
  121. package/src/frames/builtin/tag.json +55 -0
  122. package/src/frames/builtin.ts +181 -12
  123. package/src/frames/catalogue/all.ts +584 -0
  124. package/src/frames/catalogue/automotive.ts +2 -0
  125. package/src/frames/catalogue/counts.ts +6 -6
  126. package/src/frames/catalogue/events.ts +90 -0
  127. package/src/frames/catalogue/holidays.ts +336 -0
  128. package/src/frames/catalogue/index.ts +2733 -0
  129. package/src/frames/catalogue/places.ts +92 -0
  130. package/src/frames/catalogue/seasons.ts +64 -0
  131. package/src/frames/catalogue/tags.ts +384 -0
  132. package/src/frames/official/africa-day.json +110 -0
  133. package/src/frames/official/aquarium-feeding.json +113 -0
  134. package/src/frames/official/autumn-apple-picking.json +81 -0
  135. package/src/frames/official/autumn-mushroom.json +72 -0
  136. package/src/frames/official/autumn-pumpkin-patch.json +83 -0
  137. package/src/frames/official/avurudu-pot.json +87 -0
  138. package/src/frames/official/beach-conditions.json +113 -0
  139. package/src/frames/official/beach-info-sticker.json +81 -0
  140. package/src/frames/official/beach-lifeguard.json +71 -0
  141. package/src/frames/official/blood-donor-drop.json +87 -0
  142. package/src/frames/official/blood-donor-sticker.json +94 -0
  143. package/src/frames/official/book-day-arch.json +71 -0
  144. package/src/frames/official/book-day-list.json +114 -0
  145. package/src/frames/official/camp-check-in.json +74 -0
  146. package/src/frames/official/camp-fire-rules.json +114 -0
  147. package/src/frames/official/camp-map.json +85 -0
  148. package/src/frames/official/carnival-mask.json +76 -0
  149. package/src/frames/official/carnival-pass.json +85 -0
  150. package/src/frames/official/carnival-plume.json +71 -0
  151. package/src/frames/official/childrens-day-carp.json +114 -0
  152. package/src/frames/official/childrens-day-sticker.json +88 -0
  153. package/src/frames/official/chuseok-gift-tag.json +59 -0
  154. package/src/frames/official/chuseok-moon.json +99 -0
  155. package/src/frames/official/chuseok-songpyeon.json +114 -0
  156. package/src/frames/official/cowork-desk.json +82 -0
  157. package/src/frames/official/cowork-meeting-room.json +107 -0
  158. package/src/frames/official/dragon-boat-race.json +83 -0
  159. package/src/frames/official/dragon-boat-ticket.json +98 -0
  160. package/src/frames/official/dragon-boat-zongzi.json +81 -0
  161. package/src/frames/official/durga-puja-lotus.json +114 -0
  162. package/src/frames/official/dussehra-seal.json +187 -0
  163. package/src/frames/official/earth-day-globe.json +77 -0
  164. package/src/frames/official/earth-day-pledge.json +66 -0
  165. package/src/frames/official/earth-day-recycle.json +109 -0
  166. package/src/frames/official/enkutatash-daisy.json +87 -0
  167. package/src/frames/official/enkutatash-seal.json +179 -0
  168. package/src/frames/official/environment-day.json +83 -0
  169. package/src/frames/official/event-anniversary.json +107 -0
  170. package/src/frames/official/event-awards.json +93 -0
  171. package/src/frames/official/event-baby-gifts.json +113 -0
  172. package/src/frames/official/event-baby-shower.json +70 -0
  173. package/src/frames/official/event-birth-announcement.json +71 -0
  174. package/src/frames/official/event-book-fair.json +142 -0
  175. package/src/frames/official/event-booth.json +98 -0
  176. package/src/frames/official/event-craft-fair.json +96 -0
  177. package/src/frames/official/event-cupcake.json +81 -0
  178. package/src/frames/official/event-engagement.json +116 -0
  179. package/src/frames/official/event-film-festival.json +92 -0
  180. package/src/frames/official/event-food-festival.json +108 -0
  181. package/src/frames/official/event-fun-run.json +107 -0
  182. package/src/frames/official/event-gala.json +121 -0
  183. package/src/frames/official/event-game-night.json +97 -0
  184. package/src/frames/official/event-grad-diploma.json +126 -0
  185. package/src/frames/official/event-grad-party.json +108 -0
  186. package/src/frames/official/event-grad-seal.json +186 -0
  187. package/src/frames/official/event-grad-stream.json +94 -0
  188. package/src/frames/official/event-guest-book.json +121 -0
  189. package/src/frames/official/event-hackathon.json +82 -0
  190. package/src/frames/official/event-keynote.json +74 -0
  191. package/src/frames/official/event-match-lineup.json +66 -0
  192. package/src/frames/official/event-meetup.json +86 -0
  193. package/src/frames/official/event-memorial.json +124 -0
  194. package/src/frames/official/event-milestone.json +168 -0
  195. package/src/frames/official/event-night-market.json +88 -0
  196. package/src/frames/official/event-open-mic.json +94 -0
  197. package/src/frames/official/event-party-hat.json +74 -0
  198. package/src/frames/official/event-prom.json +82 -0
  199. package/src/frames/official/event-quince.json +70 -0
  200. package/src/frames/official/event-retirement.json +92 -0
  201. package/src/frames/official/event-reunion.json +98 -0
  202. package/src/frames/official/event-runner-tracker.json +101 -0
  203. package/src/frames/official/event-season-ticket.json +89 -0
  204. package/src/frames/official/event-session-feedback.json +89 -0
  205. package/src/frames/official/event-setlist.json +70 -0
  206. package/src/frames/official/event-short-films.json +113 -0
  207. package/src/frames/official/event-slides.json +85 -0
  208. package/src/frames/official/event-speaker-qa.json +112 -0
  209. package/src/frames/official/event-talent-show.json +130 -0
  210. package/src/frames/official/event-tour-merch.json +63 -0
  211. package/src/frames/official/event-tournament.json +98 -0
  212. package/src/frames/official/event-trivia.json +79 -0
  213. package/src/frames/official/event-workshop.json +127 -0
  214. package/src/frames/official/festa-della-repubblica.json +100 -0
  215. package/src/frames/official/festa-junina-bonfire.json +81 -0
  216. package/src/frames/official/festa-junina-corn.json +72 -0
  217. package/src/frames/official/festa-junina-flags.json +110 -0
  218. package/src/frames/official/fiestas-patrias-chile.json +76 -0
  219. package/src/frames/official/food-day-wheat.json +109 -0
  220. package/src/frames/official/freedom-day-south-africa.json +109 -0
  221. package/src/frames/official/ganesh-marigold.json +71 -0
  222. package/src/frames/official/ganesh-modak.json +81 -0
  223. package/src/frames/official/ganesh-pandal.json +109 -0
  224. package/src/frames/official/garden-plant-label.json +98 -0
  225. package/src/frames/official/german-unity-day.json +100 -0
  226. package/src/frames/official/green-ribbon.json +123 -0
  227. package/src/frames/official/gudi-padwa.json +81 -0
  228. package/src/frames/official/hanami-arch.json +71 -0
  229. package/src/frames/official/hanami-picnic.json +90 -0
  230. package/src/frames/official/hanami-sakura.json +81 -0
  231. package/src/frames/official/hari-raya-haji.json +122 -0
  232. package/src/frames/official/hari-raya-ketupat.json +81 -0
  233. package/src/frames/official/hari-raya-open-house.json +114 -0
  234. package/src/frames/official/hari-raya-pelita.json +77 -0
  235. package/src/frames/official/harvest-basket.json +87 -0
  236. package/src/frames/official/harvest-corn.json +115 -0
  237. package/src/frames/official/harvest-hay.json +89 -0
  238. package/src/frames/official/harvest-market.json +109 -0
  239. package/src/frames/official/hijri-new-year-stamp.json +77 -0
  240. package/src/frames/official/hijri-new-year.json +122 -0
  241. package/src/frames/official/historic-marker.json +176 -0
  242. package/src/frames/official/hostel-check-in.json +113 -0
  243. package/src/frames/official/hostel-house-rules.json +136 -0
  244. package/src/frames/official/hostel-local-tips.json +86 -0
  245. package/src/frames/official/independence-argentina.json +105 -0
  246. package/src/frames/official/independence-bangladesh.json +64 -0
  247. package/src/frames/official/independence-colombia.json +108 -0
  248. package/src/frames/official/independence-ghana.json +105 -0
  249. package/src/frames/official/independence-indonesia.json +92 -0
  250. package/src/frames/official/independence-nigeria.json +100 -0
  251. package/src/frames/official/independence-pakistan.json +95 -0
  252. package/src/frames/official/independence-peru.json +100 -0
  253. package/src/frames/official/independence-poland.json +92 -0
  254. package/src/frames/official/independence-ukraine.json +92 -0
  255. package/src/frames/official/inti-raymi-sun.json +183 -0
  256. package/src/frames/official/jamhuri-day.json +116 -0
  257. package/src/frames/official/janmashtami-feather.json +77 -0
  258. package/src/frames/official/janmashtami-flute.json +81 -0
  259. package/src/frames/official/juneteenth-seal.json +187 -0
  260. package/src/frames/official/juneteenth-star.json +81 -0
  261. package/src/frames/official/kindness-day.json +109 -0
  262. package/src/frames/official/kings-day-crown.json +88 -0
  263. package/src/frames/official/kwanzaa-bands.json +100 -0
  264. package/src/frames/official/kwanzaa-harvest.json +77 -0
  265. package/src/frames/official/kwanzaa-kinara.json +81 -0
  266. package/src/frames/official/lantern-festival-riddles.json +77 -0
  267. package/src/frames/official/lantern-festival-tangyuan.json +122 -0
  268. package/src/frames/official/library-catalog.json +120 -0
  269. package/src/frames/official/library-ebooks.json +107 -0
  270. package/src/frames/official/library-hours.json +107 -0
  271. package/src/frames/official/lohri-bonfire.json +81 -0
  272. package/src/frames/official/lohri-dhol.json +114 -0
  273. package/src/frames/official/loy-krathong-float.json +88 -0
  274. package/src/frames/official/loy-krathong-moon.json +96 -0
  275. package/src/frames/official/loy-krathong-program.json +128 -0
  276. package/src/frames/official/mardi-gras-seal.json +183 -0
  277. package/src/frames/official/marina-welcome.json +172 -0
  278. package/src/frames/official/maslenitsa-pancakes.json +81 -0
  279. package/src/frames/official/maslenitsa-sun.json +183 -0
  280. package/src/frames/official/mid-autumn-gift.json +105 -0
  281. package/src/frames/official/mid-autumn-lantern-walk.json +96 -0
  282. package/src/frames/official/mid-autumn-mooncake.json +81 -0
  283. package/src/frames/official/mid-autumn-rabbit.json +77 -0
  284. package/src/frames/official/mid-autumn-seal.json +178 -0
  285. package/src/frames/official/monsoon-boots.json +88 -0
  286. package/src/frames/official/monsoon-chai.json +82 -0
  287. package/src/frames/official/monsoon-cloud.json +114 -0
  288. package/src/frames/official/monsoon-paper-boat.json +71 -0
  289. package/src/frames/official/monsoon-umbrella.json +81 -0
  290. package/src/frames/official/muertos-marigold.json +87 -0
  291. package/src/frames/official/muertos-ofrenda.json +129 -0
  292. package/src/frames/official/muertos-pan.json +78 -0
  293. package/src/frames/official/muertos-papel-picado.json +120 -0
  294. package/src/frames/official/muertos-seal.json +185 -0
  295. package/src/frames/official/museum-artist-note.json +124 -0
  296. package/src/frames/official/museum-exhibit-label.json +106 -0
  297. package/src/frames/official/museum-gallery-map.json +99 -0
  298. package/src/frames/official/museum-ticket.json +86 -0
  299. package/src/frames/official/national-day-belgium.json +100 -0
  300. package/src/frames/official/national-day-singapore.json +120 -0
  301. package/src/frames/official/navratri-dandiya.json +88 -0
  302. package/src/frames/official/navratri-garba-pass.json +90 -0
  303. package/src/frames/official/navratri-lamp.json +72 -0
  304. package/src/frames/official/nowruz-goldfish.json +71 -0
  305. package/src/frames/official/nowruz-party.json +90 -0
  306. package/src/frames/official/nowruz-sabzeh.json +81 -0
  307. package/src/frames/official/nowruz-seal.json +187 -0
  308. package/src/frames/official/obon-lantern.json +81 -0
  309. package/src/frames/official/obon-sign.json +109 -0
  310. package/src/frames/official/ocean-day-waves.json +114 -0
  311. package/src/frames/official/onam-boat-race.json +83 -0
  312. package/src/frames/official/onam-kasavu.json +122 -0
  313. package/src/frames/official/onam-pookalam.json +175 -0
  314. package/src/frames/official/onam-sadya.json +114 -0
  315. package/src/frames/official/orthodox-christmas-candle.json +71 -0
  316. package/src/frames/official/orthodox-christmas-star.json +76 -0
  317. package/src/frames/official/orthodox-easter-arch.json +77 -0
  318. package/src/frames/official/orthodox-easter-pysanka.json +87 -0
  319. package/src/frames/official/orthodox-easter-seal.json +185 -0
  320. package/src/frames/official/pancake-day.json +114 -0
  321. package/src/frames/official/park-bench-walks.json +121 -0
  322. package/src/frames/official/park-dog-rules.json +88 -0
  323. package/src/frames/official/park-map.json +92 -0
  324. package/src/frames/official/park-playground.json +64 -0
  325. package/src/frames/official/park-report.json +118 -0
  326. package/src/frames/official/parking-find-car.json +89 -0
  327. package/src/frames/official/peace-day-dove.json +66 -0
  328. package/src/frames/official/pink-ribbon-seal.json +180 -0
  329. package/src/frames/official/pink-ribbon.json +82 -0
  330. package/src/frames/official/pohela-boishakh-mela.json +116 -0
  331. package/src/frames/official/pohela-boishakh.json +120 -0
  332. package/src/frames/official/pongal-offers.json +120 -0
  333. package/src/frames/official/pongal-pot.json +81 -0
  334. package/src/frames/official/pongal-sun.json +183 -0
  335. package/src/frames/official/posadas-candle.json +71 -0
  336. package/src/frames/official/posadas-pinata.json +114 -0
  337. package/src/frames/official/pride-flag.json +124 -0
  338. package/src/frames/official/pride-heart.json +83 -0
  339. package/src/frames/official/pride-rainbow.json +81 -0
  340. package/src/frames/official/purim-mask.json +109 -0
  341. package/src/frames/official/purim-pastry.json +71 -0
  342. package/src/frames/official/puthandu-sun.json +101 -0
  343. package/src/frames/official/rakhi-envelope.json +75 -0
  344. package/src/frames/official/rakhi-gift-tag.json +59 -0
  345. package/src/frames/official/rakhi-thread.json +114 -0
  346. package/src/frames/official/ramadan-dates.json +81 -0
  347. package/src/frames/official/ramadan-suhoor.json +94 -0
  348. package/src/frames/official/red-ribbon.json +66 -0
  349. package/src/frames/official/republic-day-india-bands.json +120 -0
  350. package/src/frames/official/republic-day-india.json +182 -0
  351. package/src/frames/official/reyes-crown.json +78 -0
  352. package/src/frames/official/reyes-rosca.json +89 -0
  353. package/src/frames/official/rosh-hashanah-apple.json +81 -0
  354. package/src/frames/official/rosh-hashanah-honey.json +71 -0
  355. package/src/frames/official/rosh-hashanah-shofar.json +128 -0
  356. package/src/frames/official/sankranti-kite.json +114 -0
  357. package/src/frames/official/sankranti-sky.json +98 -0
  358. package/src/frames/official/sankranti-sticker.json +90 -0
  359. package/src/frames/official/school-backpack.json +81 -0
  360. package/src/frames/official/school-bus-routes.json +83 -0
  361. package/src/frames/official/school-lunch-menu.json +81 -0
  362. package/src/frames/official/school-uniform.json +109 -0
  363. package/src/frames/official/school-welcome-apple.json +71 -0
  364. package/src/frames/official/seollal-knot.json +122 -0
  365. package/src/frames/official/sham-el-nessim.json +81 -0
  366. package/src/frames/official/shogatsu-kadomatsu.json +81 -0
  367. package/src/frames/official/songkran-bands.json +123 -0
  368. package/src/frames/official/songkran-bowl.json +81 -0
  369. package/src/frames/official/songkran-drop.json +90 -0
  370. package/src/frames/official/songkran-waves.json +96 -0
  371. package/src/frames/official/spring-cleaning.json +107 -0
  372. package/src/frames/official/spring-showers.json +71 -0
  373. package/src/frames/official/spring-watering-can.json +114 -0
  374. package/src/frames/official/summer-camp.json +90 -0
  375. package/src/frames/official/summer-pool.json +95 -0
  376. package/src/frames/official/summer-reading.json +81 -0
  377. package/src/frames/official/summer-sunglasses.json +114 -0
  378. package/src/frames/official/summer-watermelon.json +89 -0
  379. package/src/frames/official/tabaski.json +114 -0
  380. package/src/frames/official/tanabata-stars.json +170 -0
  381. package/src/frames/official/tanabata-wishes.json +114 -0
  382. package/src/frames/official/teachers-day-apple.json +81 -0
  383. package/src/frames/official/teachers-day-note.json +109 -0
  384. package/src/frames/official/tet-apricot.json +114 -0
  385. package/src/frames/official/tet-banh-chung.json +81 -0
  386. package/src/frames/official/transit-bike-share.json +94 -0
  387. package/src/frames/official/transit-bus-arrivals.json +113 -0
  388. package/src/frames/official/transit-fare.json +97 -0
  389. package/src/frames/official/transit-ferry.json +88 -0
  390. package/src/frames/official/transit-next-trains.json +119 -0
  391. package/src/frames/official/transit-report.json +99 -0
  392. package/src/frames/official/transit-train-timetable.json +98 -0
  393. package/src/frames/official/ugadi-leaves.json +66 -0
  394. package/src/frames/official/vaisakhi-bands.json +120 -0
  395. package/src/frames/official/vaisakhi-dhol.json +81 -0
  396. package/src/frames/official/vaisakhi-wheat.json +73 -0
  397. package/src/frames/official/vesak-candle.json +122 -0
  398. package/src/frames/official/vesak-lantern.json +114 -0
  399. package/src/frames/official/vesak-lotus.json +71 -0
  400. package/src/frames/official/vesak-seal.json +179 -0
  401. package/src/frames/official/visitor-info.json +78 -0
  402. package/src/frames/official/visitor-town-map.json +108 -0
  403. package/src/frames/official/visitor-wildlife.json +70 -0
  404. package/src/frames/official/water-day-drop.json +81 -0
  405. package/src/frames/official/wifi-cafe-cup.json +81 -0
  406. package/src/frames/official/wifi-cowork.json +63 -0
  407. package/src/frames/official/wifi-hostel-board.json +80 -0
  408. package/src/frames/official/wifi-library.json +96 -0
  409. package/src/frames/official/wifi-reception.json +118 -0
  410. package/src/frames/official/wifi-rental.json +91 -0
  411. package/src/frames/official/wifi-venue.json +80 -0
  412. package/src/frames/official/wifi-waiting-room.json +89 -0
  413. package/src/frames/official/winter-lift-pass.json +90 -0
  414. package/src/frames/official/winter-sale.json +120 -0
  415. package/src/frames/official/winter-skating.json +71 -0
  416. package/src/frames/official/winter-snowman.json +81 -0
  417. package/src/frames/official/womens-day-mimosa.json +81 -0
  418. package/src/frames/official/womens-day-seal.json +179 -0
  419. package/src/frames/official/yalda-poem.json +122 -0
  420. package/src/frames/official/yalda-pomegranate.json +81 -0
  421. package/src/frames/official/yalda-watermelon.json +72 -0
  422. package/src/frames/official/yoga-day-lotus.json +81 -0
  423. package/src/frames/official/zoo-animal-facts.json +109 -0
  424. package/src/preact.ts +80 -0
  425. package/src/scan-score.ts +14 -7
  426. package/src/solid.ts +75 -0
  427. package/src/template/dot-ring-layout.ts +230 -0
  428. package/src/template/dot-ring.tsx +165 -0
  429. package/src/template/index.ts +1 -0
  430. package/src/template-placement.ts +149 -0
  431. package/src/templates.tsx +16 -1
  432. package/types/frame-spec.ts +214 -10
  433. package/types/qr.ts +1 -1
  434. package/dist/src/frame-styles.d.ts +0 -50
  435. package/dist/src/frame-styles.d.ts.map +0 -1
  436. package/src/frame-styles.ts +0 -1095
@@ -0,0 +1,165 @@
1
+ /** @jsxImportSource ../jsx */
2
+ // A round code: the code in a disc of decorative dots, inside a dark ring
3
+ // with a line of text set along it. Which dots a code gets comes from a hash
4
+ // of its content, so every link has a ring of its own and the same link
5
+ // always gets the same one (dot-ring-layout.ts).
6
+ import type { TemplateDefinition } from "../../types";
7
+ import { FRAME_FONT_FAMILY } from "../frame";
8
+ import { getSolidColor } from "../utils/color";
9
+ import { roundTo } from "../utils/fmt";
10
+ import {
11
+ BACKGROUND_RADIUS,
12
+ CENTER,
13
+ CODE_OFFSET,
14
+ DEFAULT_FONT_SIZE,
15
+ DEFAULT_LETTER_SPACING,
16
+ DEFAULT_TEXT,
17
+ dotRingDots,
18
+ dotRingLetters,
19
+ dotsClearOfCode,
20
+ RING_INNER_RADIUS,
21
+ RING_PATH,
22
+ VIEW,
23
+ } from "./dot-ring-layout";
24
+
25
+ /** Custom props of the dot ring template (`customProps`). */
26
+ export interface DotRingProps {
27
+ /**
28
+ * Text set along the ring. Defaults to "Scan the QR code" four times
29
+ * round; `""` leaves the ring empty. Letters that don't fit around the
30
+ * ring are left out.
31
+ */
32
+ customText?: string;
33
+ /** "top" (default): centered over the top, reading clockwise. "bottom": centered along the bottom, reading left to right. */
34
+ textPosition?: "top" | "bottom";
35
+ /** Turns the text around the center, in degrees clockwise (default 0). */
36
+ textRotation?: number;
37
+ /** Text color (default white). */
38
+ textColor?: string;
39
+ /** CSS font family of the text (default: the system sans-serif stack frames use). */
40
+ fontFamily?: string;
41
+ /** Font weight (default 900). */
42
+ fontWeight?: number | string;
43
+ /** Font size in the template's 593-unit drawing, where the code is 300 across (default 32). */
44
+ fontSize?: number;
45
+ /** Extra space between letters, in the same units (default 3.5). */
46
+ fontLetterSpacing?: number;
47
+ /** Color of the ring (default: the code's `fgColor`). */
48
+ outerCircleColor?: string;
49
+ /** Width of a stroke along both edges of the ring (default 0: none). */
50
+ strokeWidth?: number;
51
+ /** Color of that stroke (default black). */
52
+ strokeColor?: string;
53
+ /** Stroke width along the ring's outer edge only (default `strokeWidth`). */
54
+ outerStrokeWidth?: number;
55
+ /** Stroke color along the outer edge (default `strokeColor`). */
56
+ outerStrokeColor?: string;
57
+ /** Stroke width along the ring's inner edge only (default `strokeWidth`). */
58
+ innerStrokeWidth?: number;
59
+ /** Stroke color along the inner edge (default `strokeColor`). */
60
+ innerStrokeColor?: string;
61
+ }
62
+
63
+ const finite = (value: unknown, fallback: number) =>
64
+ typeof value === "number" && Number.isFinite(value) ? value : fallback;
65
+
66
+ export const DotRing: TemplateDefinition<DotRingProps> = {
67
+ id: "DotRing",
68
+ name: "Dot Ring",
69
+ description:
70
+ "A round code in a ring of dots of its own for every link, with text along the ring",
71
+ wrapper: (children, props, templateConfig) => {
72
+ const fg = getSolidColor(props?.fgColor, "#000000");
73
+ const bg = getSolidColor(props?.bgColor, "#ffffff");
74
+ const moduleSize = templateConfig?.pixelSize ?? 9;
75
+ const dotRadius = roundTo(moduleSize / 2);
76
+ const dots = dotsClearOfCode(
77
+ dotRingDots(templateConfig?.url ?? ""),
78
+ moduleSize
79
+ );
80
+
81
+ const requestedSize = finite(props?.fontSize, DEFAULT_FONT_SIZE);
82
+ const fontSize = requestedSize > 0 ? requestedSize : DEFAULT_FONT_SIZE;
83
+ const text =
84
+ typeof props?.customText === "string" ? props.customText : DEFAULT_TEXT;
85
+ const letters = dotRingLetters(text, {
86
+ fontSize,
87
+ letterSpacing: finite(props?.fontLetterSpacing, DEFAULT_LETTER_SPACING),
88
+ position: props?.textPosition === "bottom" ? "bottom" : "top",
89
+ rotation: finite(props?.textRotation, 0),
90
+ });
91
+ const textColor = props?.textColor || "#ffffff";
92
+ const fontFamily = props?.fontFamily || FRAME_FONT_FAMILY;
93
+ const fontWeight = props?.fontWeight ?? 900;
94
+
95
+ const strokeWidth = finite(props?.strokeWidth, 0);
96
+ const strokeColor = props?.strokeColor || "#000000";
97
+ const edges = [
98
+ {
99
+ radius: CENTER,
100
+ width: finite(props?.outerStrokeWidth, strokeWidth),
101
+ color: props?.outerStrokeColor || strokeColor,
102
+ },
103
+ {
104
+ radius: RING_INNER_RADIUS,
105
+ width: finite(props?.innerStrokeWidth, strokeWidth),
106
+ color: props?.innerStrokeColor || strokeColor,
107
+ },
108
+ ].filter((edge) => edge.width > 0);
109
+
110
+ return (
111
+ <svg
112
+ height={VIEW}
113
+ id="svgQrWrapper"
114
+ style={{
115
+ width: "100%",
116
+ height: "100%",
117
+ }}
118
+ viewBox={`0 0 ${VIEW} ${VIEW}`}
119
+ width={VIEW}
120
+ xmlns="http://www.w3.org/2000/svg"
121
+ xmlnsXlink="http://www.w3.org/1999/xlink"
122
+ >
123
+ <circle cx={CENTER} cy={CENTER} fill={bg} r={BACKGROUND_RADIUS} />
124
+ <g fill={fg}>
125
+ {dots.map((dot, index) => (
126
+ <circle cx={dot.cx} cy={dot.cy} key={index} r={dotRadius} />
127
+ ))}
128
+ </g>
129
+ <path d={RING_PATH} fill={props?.outerCircleColor || fg} />
130
+ {edges.map((edge, index) => (
131
+ <circle
132
+ cx={CENTER}
133
+ cy={CENTER}
134
+ fill="none"
135
+ key={index}
136
+ r={edge.radius}
137
+ stroke={edge.color}
138
+ strokeWidth={edge.width}
139
+ />
140
+ ))}
141
+ {/* One letter per <text>: read one by one they'd make no sense to a
142
+ screen reader, so they're hidden from it */}
143
+ {/* biome-ignore lint/a11y/noAriaHiddenOnFocusable: an SVG <g> can't take focus */}
144
+ <g aria-hidden="true">
145
+ {letters.map((letter, index) => (
146
+ <text
147
+ fill={textColor}
148
+ fontFamily={fontFamily}
149
+ fontSize={fontSize}
150
+ fontWeight={fontWeight}
151
+ key={index}
152
+ textAnchor="middle"
153
+ transform={`rotate(${letter.rotate} ${letter.x} ${letter.y})`}
154
+ x={letter.x}
155
+ y={letter.y}
156
+ >
157
+ {letter.char}
158
+ </text>
159
+ ))}
160
+ </g>
161
+ <g transform={`translate(${CODE_OFFSET} ${CODE_OFFSET})`}>{children}</g>
162
+ </svg>
163
+ );
164
+ },
165
+ };
@@ -1,5 +1,6 @@
1
1
  export * from "./arrow";
2
2
  export * from "./default";
3
+ export * from "./dot-ring";
3
4
  export * from "./halloween";
4
5
  export * from "./square-border";
5
6
  export * from "./standard-box";
@@ -0,0 +1,149 @@
1
+ // Where a template draws the code in its artwork. A template wraps the code
2
+ // (a 300 × 300 drawing) in artwork of its own and usually draws it smaller
3
+ // than the whole, so the scan score measures the code's share of the
4
+ // artwork to test the code at its real size.
5
+ import type { QRProps } from "../types";
6
+ import { getTemplate } from "./templates";
7
+ import {
8
+ applyMatrix,
9
+ IDENTITY,
10
+ type Matrix,
11
+ multiply,
12
+ parseNumbers,
13
+ parseTransform,
14
+ } from "./utils/svg-geometry";
15
+
16
+ /** The code's own drawing size inside a template (see utils.tsx). */
17
+ const TEMPLATE_CODE_SIZE = 300;
18
+
19
+ interface ElementLike {
20
+ type?: unknown;
21
+ props?: Record<string, unknown>;
22
+ }
23
+
24
+ const toNumber = (value: unknown): number | undefined => {
25
+ const number =
26
+ typeof value === "number" ? value : Number.parseFloat(String(value));
27
+ return Number.isFinite(number) ? number : undefined;
28
+ };
29
+
30
+ /** A nested `<svg>`'s mapping from its viewBox into its parent's units. */
31
+ function viewportMatrix(props: Record<string, unknown>): Matrix {
32
+ const x = toNumber(props.x) ?? 0;
33
+ const y = toNumber(props.y) ?? 0;
34
+ const viewBox = parseNumbers(
35
+ typeof props.viewBox === "string" ? props.viewBox : undefined
36
+ );
37
+ const width = toNumber(props.width);
38
+ const height = toNumber(props.height);
39
+ if (viewBox.length !== 4 || !(viewBox[2] && viewBox[3] && width && height)) {
40
+ return [1, 0, 0, 1, x, y];
41
+ }
42
+ const [vbX, vbY, vbWidth, vbHeight] = viewBox as [
43
+ number,
44
+ number,
45
+ number,
46
+ number,
47
+ ];
48
+ // preserveAspectRatio's default (xMidYMid meet)
49
+ const scale = Math.min(width / vbWidth, height / vbHeight);
50
+ return [
51
+ scale,
52
+ 0,
53
+ 0,
54
+ scale,
55
+ x + (width - vbWidth * scale) / 2 - vbX * scale,
56
+ y + (height - vbHeight * scale) / 2 - vbY * scale,
57
+ ];
58
+ }
59
+
60
+ /** The transform from `target`'s parent into the root's units, or null. */
61
+ function locate(
62
+ node: unknown,
63
+ target: object,
64
+ matrix: Matrix,
65
+ isRoot: boolean
66
+ ): Matrix | null {
67
+ if (node === target) {
68
+ return matrix;
69
+ }
70
+ if (Array.isArray(node)) {
71
+ for (const child of node) {
72
+ const found = locate(child, target, matrix, false);
73
+ if (found) {
74
+ return found;
75
+ }
76
+ }
77
+ return null;
78
+ }
79
+ const element = node as ElementLike | null;
80
+ if (!element || typeof element !== "object" || !element.props) {
81
+ return null;
82
+ }
83
+ const { props } = element;
84
+ let inner = multiply(
85
+ matrix,
86
+ parseTransform(
87
+ typeof props.transform === "string" ? props.transform : undefined
88
+ )
89
+ );
90
+ if (element.type === "svg" && !isRoot) {
91
+ inner = multiply(inner, viewportMatrix(props));
92
+ }
93
+ return locate(props.children, target, inner, false);
94
+ }
95
+
96
+ /**
97
+ * The code's width as a share of the artwork `props` draws: below 1 when a
98
+ * template draws it smaller than its artwork, 1 without a template (or when
99
+ * the template's wrapper doesn't place the code it is given).
100
+ */
101
+ export function getTemplateCodeShare(props: QRProps): number {
102
+ const template =
103
+ props.customTemplate ||
104
+ (props.templateId ? getTemplate(props.templateId) : undefined);
105
+ if (!template) {
106
+ return 1;
107
+ }
108
+ const marker = {
109
+ type: "svg",
110
+ props: {
111
+ height: TEMPLATE_CODE_SIZE,
112
+ viewBox: `0 0 ${TEMPLATE_CODE_SIZE} ${TEMPLATE_CODE_SIZE}`,
113
+ width: TEMPLATE_CODE_SIZE,
114
+ },
115
+ key: null,
116
+ };
117
+ let root: ElementLike | null;
118
+ try {
119
+ root = template.wrapper(
120
+ marker,
121
+ {
122
+ fgColor: typeof props.fgColor === "string" ? props.fgColor : undefined,
123
+ bgColor: typeof props.bgColor === "string" ? props.bgColor : undefined,
124
+ ...(props.customProps ?? {}),
125
+ },
126
+ { pixelSize: 10, url: props.value }
127
+ ) as ElementLike | null;
128
+ } catch {
129
+ return 1;
130
+ }
131
+ const rootProps = root?.props;
132
+ if (!rootProps) {
133
+ return 1;
134
+ }
135
+ const viewBox = parseNumbers(
136
+ typeof rootProps.viewBox === "string" ? rootProps.viewBox : undefined
137
+ );
138
+ const artworkWidth =
139
+ viewBox.length === 4 ? viewBox[2] : toNumber(rootProps.width);
140
+ const matrix = locate(root, marker, IDENTITY, true);
141
+ if (!(matrix && artworkWidth)) {
142
+ return 1;
143
+ }
144
+ const [x0, y0] = applyMatrix(matrix, 0, 0);
145
+ const [x1, y1] = applyMatrix(matrix, TEMPLATE_CODE_SIZE, TEMPLATE_CODE_SIZE);
146
+ const width = Math.min(Math.abs(x1 - x0), Math.abs(y1 - y0));
147
+ const share = width / artworkWidth;
148
+ return share > 0 && share <= 1 ? share : 1;
149
+ }
package/src/templates.tsx CHANGED
@@ -19,12 +19,27 @@ export const TEMPLATES: Record<string, TemplateDefinition<any>> = {
19
19
  SquareBorder: templates.SquareBorder,
20
20
  StrikedBox: templates.StrikedBox,
21
21
  Halloween: templates.Halloween,
22
+ DotRing: templates.DotRing,
23
+ };
24
+
25
+ // Earlier ids that still draw their template, so designs saved with them keep
26
+ // working. getTemplateIds and getAllTemplates leave them out.
27
+ const TEMPLATE_ALIASES: Record<string, string> = {
28
+ FlamQR: "DotRing",
22
29
  };
23
30
 
24
31
  // Utility functions
25
32
  export const getTemplate = (
26
33
  templateId: string
27
- ): TemplateDefinition<any> | undefined => TEMPLATES[templateId];
34
+ ): TemplateDefinition<any> | undefined => {
35
+ if (Object.hasOwn(TEMPLATES, templateId)) {
36
+ return TEMPLATES[templateId];
37
+ }
38
+ const alias = Object.hasOwn(TEMPLATE_ALIASES, templateId)
39
+ ? TEMPLATE_ALIASES[templateId]
40
+ : undefined;
41
+ return alias ? TEMPLATES[alias] : undefined;
42
+ };
28
43
 
29
44
  export const getAllTemplates = (): TemplateDefinition<any>[] =>
30
45
  Object.values(TEMPLATES);
@@ -8,7 +8,7 @@
8
8
 
9
9
  import { z } from "zod";
10
10
  import { countPathSegments, tokenizePathData } from "../src/utils/path-data";
11
- import { segmentsBounds } from "../src/utils/polygon-clip";
11
+ import { clipPolygon, segmentsBounds } from "../src/utils/polygon-clip";
12
12
  import { parsePathData } from "../src/utils/svg-geometry";
13
13
  import {
14
14
  FRAME_FONT_SCALE_MAX,
@@ -165,15 +165,30 @@ const hexColorSchema = z
165
165
 
166
166
  const baseColorSchema = z.union([z.enum(FRAME_COLOR_TOKENS), hexColorSchema]);
167
167
 
168
- /** A theme token, a fixed hex color, or an opaque mix of two of them. */
169
- export const frameSpecColorSchema = z.union([
170
- baseColorSchema,
168
+ const mixSchema = <T extends z.ZodType>(base: T) =>
171
169
  z
172
170
  .object({
173
- mix: z.tuple([baseColorSchema, baseColorSchema]),
171
+ mix: z.tuple([base, base]),
174
172
  amount: z.number().min(0).max(1).refine(hasPrecision),
175
173
  })
176
- .strict(),
174
+ .strict();
175
+
176
+ /** A theme token, a fixed hex color, or an opaque mix of two of them. */
177
+ export const frameSpecColorSchema = z.union([
178
+ baseColorSchema,
179
+ mixSchema(baseColorSchema),
180
+ ]);
181
+
182
+ /**
183
+ * The text color's default: a hex color, or a mix of the frame and accent
184
+ * colors (and fixed colors), worked out from the frame's own colors. It
185
+ * can't refer to `text` itself.
186
+ */
187
+ const defaultTextColorSchema = z.union([
188
+ hexColorSchema,
189
+ mixSchema(
190
+ z.union([z.enum(["frame", "accent", "background"]), hexColorSchema])
191
+ ),
177
192
  ]);
178
193
 
179
194
  /**
@@ -318,6 +333,14 @@ const labelFields = {
318
333
  maxLength: z.int().min(1).max(FRAME_TEXT_MAX_LENGTH).optional(),
319
334
  color: frameSpecColorSchema,
320
335
  weight: z.enum(["bold", "regular"]).optional(),
336
+ /**
337
+ * A band of the artboard that goes away when the label shows no text:
338
+ * the rows from `y` to `y + height` are cut out, everything below moves
339
+ * up and the artwork gets shorter. Shapes that lie wholly inside the band
340
+ * are left out; shapes that cross it are shortened. The band never
341
+ * touches the code or its padding.
342
+ */
343
+ collapse: z.object({ y: number, height: positive }).strict().optional(),
321
344
  };
322
345
 
323
346
  const textLabelSchema = z
@@ -386,13 +409,26 @@ const frameSpecObjectSchema = z
386
409
  padding: nonNegative.optional(),
387
410
  /** Corner radius of the plate */
388
411
  radius: nonNegative.optional(),
412
+ /**
413
+ * What the plate and `background` fills are painted with when the
414
+ * code's background is see-through. "opaque" (the default) paints
415
+ * them white, so artwork never shows through the quiet zone.
416
+ * "background" keeps them see-through too (and leaves the plate
417
+ * out); it's allowed only when nothing but `background` fills, or a
418
+ * ring whose hole clears the plate, lies under the plate.
419
+ */
420
+ plate: z.enum(["opaque", "background"]).optional(),
389
421
  })
390
422
  .strict(),
391
423
  /** Default colors, used when the theme sets none */
392
424
  colors: z
393
425
  .object({
394
426
  frame: hexColorSchema,
395
- text: hexColorSchema.optional(),
427
+ /**
428
+ * Default text color (else the frame color): a hex color, or a mix
429
+ * of `frame`, `accent` and fixed colors
430
+ */
431
+ text: defaultTextColorSchema.optional(),
396
432
  accent: hexColorSchema.optional(),
397
433
  })
398
434
  .strict(),
@@ -408,6 +444,8 @@ const frameSpecObjectSchema = z
408
444
  .strict();
409
445
 
410
446
  export type FrameSpecColor = z.infer<typeof frameSpecColorSchema>;
447
+ /** A spec's default text color (`colors.text`). */
448
+ export type FrameSpecDefaultTextColor = z.infer<typeof defaultTextColorSchema>;
411
449
  export type FrameSpecPaint = z.infer<typeof frameSpecPaintSchema>;
412
450
  export type FrameSpecShape = z.infer<typeof frameSpecShapeSchema>;
413
451
  export type FrameSpecLabel = z.infer<typeof frameSpecLabelSchema>;
@@ -434,16 +472,143 @@ export function frameSpecQrZone(spec: FrameSpec): Box {
434
472
  };
435
473
  }
436
474
 
475
+ /** The code itself, without its padding. */
476
+ function frameSpecQrBox(spec: FrameSpec): Box {
477
+ return {
478
+ x0: spec.qr.x,
479
+ y0: spec.qr.y,
480
+ x1: spec.qr.x + spec.qr.size,
481
+ y1: spec.qr.y + spec.qr.size,
482
+ };
483
+ }
484
+
437
485
  /** The plate's padding around the code, in spec units. */
438
486
  export function frameSpecPadding(spec: FrameSpec): number {
439
487
  return spec.qr.padding ?? spec.qr.size * FRAME_SPEC_LIMITS.defaultPadding;
440
488
  }
441
489
 
490
+ /** Font size of a text label with no `fontSize`, as a share of its row. */
491
+ export const FRAME_SPEC_DEFAULT_FONT = 0.52;
492
+
493
+ /**
494
+ * Half the height a label's capitals fill, as a share of its font size: a
495
+ * text label's letters are centered on its row, so they fill the row's
496
+ * middle, this far above and below it.
497
+ */
498
+ export const FRAME_SPEC_CAP_HALF = 0.35;
499
+
500
+ /** The largest font a text label draws (at the largest fontScale). */
501
+ function textLabelMaxFont(
502
+ label: Extract<FrameSpecLabel, { type: "text" }>
503
+ ): number {
504
+ const base = label.fontSize ?? label.box.height * FRAME_SPEC_DEFAULT_FONT;
505
+ return Math.min(
506
+ base * FRAME_FONT_SCALE_MAX,
507
+ label.box.height * FRAME_SPEC_LABEL_MAX_FONT
508
+ );
509
+ }
510
+
442
511
  const overlaps = (a: Box, b: Box) =>
443
512
  Math.min(a.x1, b.x1) - Math.max(a.x0, b.x0) > 1e-6 &&
444
513
  Math.min(a.y1, b.y1) - Math.max(a.y0, b.y0) > 1e-6;
445
514
 
446
- function shapeBounds(shape: FrameSpecShape): {
515
+ // ── The plate ─────────────────────────────────────────────────────────────
516
+
517
+ type Point = [number, number];
518
+
519
+ /** Points along the plate's outline (its corners rounded by `qr.radius`). */
520
+ function plateOutline(spec: FrameSpec): Point[] {
521
+ const zone = frameSpecQrZone(spec);
522
+ const r = Math.min(
523
+ spec.qr.radius ?? 0,
524
+ (zone.x1 - zone.x0) / 2,
525
+ (zone.y1 - zone.y0) / 2
526
+ );
527
+ const corners: [number, number, number][] = [
528
+ [zone.x0 + r, zone.y0 + r, Math.PI],
529
+ [zone.x1 - r, zone.y0 + r, -Math.PI / 2],
530
+ [zone.x1 - r, zone.y1 - r, 0],
531
+ [zone.x0 + r, zone.y1 - r, Math.PI / 2],
532
+ ];
533
+ const points: Point[] = [];
534
+ for (const [cx, cy, start] of corners) {
535
+ for (let i = 0; i <= 8; i++) {
536
+ const angle = start + (Math.PI / 2) * (i / 8);
537
+ points.push([cx + r * Math.cos(angle), cy + r * Math.sin(angle)]);
538
+ }
539
+ }
540
+ return points;
541
+ }
542
+
543
+ function insideRoundedBox(
544
+ [x, y]: Point,
545
+ box: { x: number; y: number; width: number; height: number },
546
+ radius: number
547
+ ): boolean {
548
+ const tolerance = 0.01;
549
+ if (
550
+ x < box.x - tolerance ||
551
+ y < box.y - tolerance ||
552
+ x > box.x + box.width + tolerance ||
553
+ y > box.y + box.height + tolerance
554
+ ) {
555
+ return false;
556
+ }
557
+ const r = Math.min(radius, box.width / 2, box.height / 2);
558
+ const cx = Math.min(Math.max(x, box.x + r), box.x + box.width - r);
559
+ const cy = Math.min(Math.max(y, box.y + r), box.y + box.height - r);
560
+ return Math.hypot(x - cx, y - cy) <= r + tolerance;
561
+ }
562
+
563
+ /** Area of a simple polygon (shoelace). */
564
+ function polygonArea(points: Point[]): number {
565
+ let twice = 0;
566
+ points.forEach(([x0, y0], i) => {
567
+ const [x1, y1] = points[(i + 1) % points.length] as Point;
568
+ twice += x0 * y1 - x1 * y0;
569
+ });
570
+ return Math.abs(twice) / 2;
571
+ }
572
+
573
+ /**
574
+ * True when `shape` may paint under the plate: anything but a `background`
575
+ * fill, a ring whose hole holds the whole plate, or a polygon that stays
576
+ * off it. Paths, lines, ellipses and icons count when their bounds reach
577
+ * the plate.
578
+ */
579
+ function paintsUnderPlate(
580
+ shape: FrameSpecShape,
581
+ spec: FrameSpec,
582
+ bounds: Box
583
+ ): boolean {
584
+ const zone = frameSpecQrZone(spec);
585
+ if (shape.fill === "background" || !overlaps(bounds, zone)) {
586
+ return false;
587
+ }
588
+ if (shape.type === "rect" && shape.hole) {
589
+ const { hole } = shape;
590
+ return !plateOutline(spec).every((point) =>
591
+ insideRoundedBox(point, hole, hole.radius ?? 0)
592
+ );
593
+ }
594
+ if (shape.type === "circle" && shape.hole) {
595
+ const hole = shape.hole;
596
+ return !plateOutline(spec).every(
597
+ ([x, y]) => Math.hypot(x - shape.cx, y - shape.cy) <= hole + 0.01
598
+ );
599
+ }
600
+ if (shape.type === "polygon") {
601
+ const clipped = clipPolygon(shape.points as Point[], zone);
602
+ return clipped.length > 2 && polygonArea(clipped) > 1e-6;
603
+ }
604
+ return true;
605
+ }
606
+
607
+ /**
608
+ * Bounds of a spec shape (null for path data outside the grammar) and the
609
+ * segments it counts against FRAME_SPEC_LIMITS.maxSegments.
610
+ */
611
+ export function frameSpecShapeBounds(shape: FrameSpecShape): {
447
612
  bounds: Box | null;
448
613
  segments: number;
449
614
  } {
@@ -587,7 +752,7 @@ function checkFrameSpec(spec: FrameSpec, ctx: z.RefinementCtx) {
587
752
  let gradientWork = 0;
588
753
  spec.shapes.forEach((shape, index) => {
589
754
  const path = ["shapes", index];
590
- const { bounds, segments: count } = shapeBounds(shape);
755
+ const { bounds, segments: count } = frameSpecShapeBounds(shape);
591
756
  if (!bounds) {
592
757
  issue(
593
758
  "Path data must use only M L H V C S Q T A Z, plain numbers (up to 3 decimals) and start with M",
@@ -612,6 +777,12 @@ function checkFrameSpec(spec: FrameSpec, ctx: z.RefinementCtx) {
612
777
  if (shape.type === "circle" && shape.hole && shape.hole >= shape.r) {
613
778
  issue("The hole must be smaller than the circle", [...path, "hole"]);
614
779
  }
780
+ if (qr.plate === "background" && paintsUnderPlate(shape, spec, bounds)) {
781
+ issue(
782
+ 'With qr.plate "background", only background fills (or a ring whose hole holds the plate) may lie under the plate',
783
+ path
784
+ );
785
+ }
615
786
  segments += count;
616
787
  if (typeof shape.fill === "object" && "gradient" in shape.fill) {
617
788
  gradientWork += (shape.fill.gradient.steps ?? 32) * count;
@@ -630,6 +801,7 @@ function checkFrameSpec(spec: FrameSpec, ctx: z.RefinementCtx) {
630
801
  }
631
802
 
632
803
  // Labels: clean text, inside the artboard, never over the code
804
+ const bands: { y: number; height: number }[] = [];
633
805
  const ids = new Set<string>();
634
806
  const slots = new Set<string>();
635
807
  spec.labels.forEach((label, index) => {
@@ -671,7 +843,17 @@ function checkFrameSpec(spec: FrameSpec, ctx: z.RefinementCtx) {
671
843
  "fontSize",
672
844
  ]);
673
845
  }
674
- if (overlaps(box, zone)) {
846
+ // The row may reach into the padding, but never over the code, and
847
+ // the band its capitals fill (at the largest font) stays off both
848
+ const middle = label.box.y + label.box.height / 2;
849
+ const reach = textLabelMaxFont(label) * FRAME_SPEC_CAP_HALF;
850
+ const letters: Box = {
851
+ x0: box.x0,
852
+ x1: box.x1,
853
+ y0: middle - reach,
854
+ y1: middle + reach,
855
+ };
856
+ if (overlaps(box, frameSpecQrBox(spec)) || overlaps(letters, zone)) {
675
857
  issue("The label overlaps the code or its padding", [...path, "box"]);
676
858
  }
677
859
  } else {
@@ -701,6 +883,28 @@ function checkFrameSpec(spec: FrameSpec, ctx: z.RefinementCtx) {
701
883
  if (!inside(box)) {
702
884
  issue("The label extends outside the artboard", path);
703
885
  }
886
+ if (label.collapse) {
887
+ const band = label.collapse;
888
+ const end = band.y + band.height;
889
+ if (band.y < -1e-9 || end > height + 1e-9) {
890
+ issue("The collapse band must sit inside the artboard", [
891
+ ...path,
892
+ "collapse",
893
+ ]);
894
+ }
895
+ if (end > zone.y0 + 1e-6 && band.y < zone.y1 - 1e-6) {
896
+ issue("The collapse band crosses the code or its padding", [
897
+ ...path,
898
+ "collapse",
899
+ ]);
900
+ }
901
+ for (const other of bands) {
902
+ if (end > other.y + 1e-6 && band.y < other.y + other.height - 1e-6) {
903
+ issue("Collapse bands may not overlap", [...path, "collapse"]);
904
+ }
905
+ }
906
+ bands.push(band);
907
+ }
704
908
  });
705
909
  }
706
910
 
package/types/qr.ts CHANGED
@@ -218,7 +218,7 @@ export interface QRProps {
218
218
  // Custom template definition - if provided, this will be used instead of looking up by templateId
219
219
  customTemplate?: TemplateDefinition<any>;
220
220
  // Generic custom props that can be used by any template
221
- // Each template can define its own custom props type (e.g., FlamQRProps)
221
+ // Each template can define its own custom props type (e.g., DotRingProps)
222
222
  customProps?: Record<string, any>;
223
223
  // Frame around the code: a built-in style, or { style: "custom", spec }
224
224
  // (see types/frame-spec.ts); the rendered output grows to fit it