qrdx 0.0.48 → 0.0.50

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 (517) hide show
  1. package/README.md +14 -5
  2. package/dist/frames-index.js +2 -0
  3. package/dist/frames-index.js.map +1 -0
  4. package/dist/frames-index.mjs +2 -0
  5. package/dist/frames-index.mjs.map +1 -0
  6. package/dist/frames-official.js +2 -0
  7. package/dist/frames-official.js.map +1 -0
  8. package/dist/frames-official.mjs +2 -0
  9. package/dist/frames-official.mjs.map +1 -0
  10. package/dist/index.js +7 -7
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +7 -7
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/node.js +6 -0
  15. package/dist/node.js.map +1 -0
  16. package/dist/node.mjs +6 -0
  17. package/dist/node.mjs.map +1 -0
  18. package/dist/qr-code-canvas.js +1 -1
  19. package/dist/qr-code-canvas.js.map +1 -1
  20. package/dist/qr-code-canvas.mjs +1 -1
  21. package/dist/qr-code-canvas.mjs.map +1 -1
  22. package/dist/src/api.d.ts.map +1 -1
  23. package/dist/src/frames/catalogue/all.d.ts +4 -0
  24. package/dist/src/frames/catalogue/all.d.ts.map +1 -0
  25. package/dist/src/frames/catalogue/business.d.ts +5 -0
  26. package/dist/src/frames/catalogue/business.d.ts.map +1 -0
  27. package/dist/src/frames/catalogue/call-to-action.d.ts +5 -0
  28. package/dist/src/frames/catalogue/call-to-action.d.ts.map +1 -0
  29. package/dist/src/frames/catalogue/counts.d.ts +15 -0
  30. package/dist/src/frames/catalogue/counts.d.ts.map +1 -0
  31. package/dist/src/frames/catalogue/events.d.ts +5 -0
  32. package/dist/src/frames/catalogue/events.d.ts.map +1 -0
  33. package/dist/src/frames/catalogue/food-drink.d.ts +5 -0
  34. package/dist/src/frames/catalogue/food-drink.d.ts.map +1 -0
  35. package/dist/src/frames/catalogue/health-learning.d.ts +5 -0
  36. package/dist/src/frames/catalogue/health-learning.d.ts.map +1 -0
  37. package/dist/src/frames/catalogue/holidays.d.ts +5 -0
  38. package/dist/src/frames/catalogue/holidays.d.ts.map +1 -0
  39. package/dist/src/frames/catalogue/index.d.ts +4 -0
  40. package/dist/src/frames/catalogue/index.d.ts.map +1 -0
  41. package/dist/src/frames/catalogue/places.d.ts +5 -0
  42. package/dist/src/frames/catalogue/places.d.ts.map +1 -0
  43. package/dist/src/frames/catalogue/seasons.d.ts +5 -0
  44. package/dist/src/frames/catalogue/seasons.d.ts.map +1 -0
  45. package/dist/src/frames/catalogue/shopping.d.ts +5 -0
  46. package/dist/src/frames/catalogue/shopping.d.ts.map +1 -0
  47. package/dist/src/frames/catalogue/tags.d.ts +3 -0
  48. package/dist/src/frames/catalogue/tags.d.ts.map +1 -0
  49. package/dist/src/frames/collections.d.ts +6 -0
  50. package/dist/src/frames/collections.d.ts.map +1 -0
  51. package/dist/src/frames/official-types.d.ts +35 -0
  52. package/dist/src/frames/official-types.d.ts.map +1 -0
  53. package/dist/src/frames/official.d.ts +7 -16
  54. package/dist/src/frames/official.d.ts.map +1 -1
  55. package/dist/src/frames/spec-hash.d.ts +9 -0
  56. package/dist/src/frames/spec-hash.d.ts.map +1 -0
  57. package/dist/src/index.d.ts +7 -1
  58. package/dist/src/index.d.ts.map +1 -1
  59. package/dist/src/node.d.ts +23 -0
  60. package/dist/src/node.d.ts.map +1 -0
  61. package/dist/src/part-markers.d.ts +15 -0
  62. package/dist/src/part-markers.d.ts.map +1 -0
  63. package/dist/src/qr-code-canvas.d.ts.map +1 -1
  64. package/dist/src/qr-code.d.ts +1 -1
  65. package/dist/src/qr-code.d.ts.map +1 -1
  66. package/dist/src/rasterize.d.ts +25 -0
  67. package/dist/src/rasterize.d.ts.map +1 -0
  68. package/dist/src/utils.d.ts.map +1 -1
  69. package/dist/types/qr.d.ts +1 -0
  70. package/dist/types/qr.d.ts.map +1 -1
  71. package/package.json +33 -13
  72. package/src/api.tsx +1 -0
  73. package/src/frames/catalogue/all.ts +844 -0
  74. package/src/frames/catalogue/business.ts +105 -0
  75. package/src/frames/catalogue/call-to-action.ts +159 -0
  76. package/src/frames/catalogue/counts.ts +18 -0
  77. package/src/frames/catalogue/events.ts +73 -0
  78. package/src/frames/catalogue/food-drink.ts +73 -0
  79. package/src/frames/catalogue/health-learning.ts +57 -0
  80. package/src/frames/catalogue/holidays.ts +239 -0
  81. package/src/frames/catalogue/index.ts +3512 -0
  82. package/src/frames/catalogue/places.ts +77 -0
  83. package/src/frames/catalogue/seasons.ts +65 -0
  84. package/src/frames/catalogue/shopping.ts +69 -0
  85. package/src/frames/catalogue/tags.ts +412 -0
  86. package/src/frames/collections.ts +18 -0
  87. package/src/frames/official/allergen-info.json +77 -0
  88. package/src/frames/official/app-arrow.json +89 -0
  89. package/src/frames/official/app-download.json +93 -0
  90. package/src/frames/official/app-install.json +83 -0
  91. package/src/frames/official/app-phone-dark.json +87 -0
  92. package/src/frames/official/app-phone.json +105 -0
  93. package/src/frames/official/arrow-tag.json +89 -0
  94. package/src/frames/official/attendance.json +1 -0
  95. package/src/frames/official/audio-guide.json +1 -0
  96. package/src/frames/official/autumn-acorn.json +83 -0
  97. package/src/frames/official/autumn-hills.json +93 -0
  98. package/src/frames/official/autumn-maple.json +76 -0
  99. package/src/frames/official/autumn-oak.json +114 -0
  100. package/src/frames/official/autumn-wheat.json +117 -0
  101. package/src/frames/official/bakery-cake.json +70 -0
  102. package/src/frames/official/bar-beer.json +80 -0
  103. package/src/frames/official/bar-bottle.json +94 -0
  104. package/src/frames/official/bar-cocktail.json +82 -0
  105. package/src/frames/official/bar-happy-hour.json +130 -0
  106. package/src/frames/official/bar-tab.json +78 -0
  107. package/src/frames/official/bar-wine.json +121 -0
  108. package/src/frames/official/biz-booking.json +100 -0
  109. package/src/frames/official/biz-hiring.json +130 -0
  110. package/src/frames/official/biz-launch.json +123 -0
  111. package/src/frames/official/biz-repair.json +74 -0
  112. package/src/frames/official/biz-salon.json +65 -0
  113. package/src/frames/official/biz-support.json +115 -0
  114. package/src/frames/official/bizcard-badge.json +89 -0
  115. package/src/frames/official/bizcard-dark.json +81 -0
  116. package/src/frames/official/bizcard-edge.json +125 -0
  117. package/src/frames/official/bizcard-hello.json +108 -0
  118. package/src/frames/official/bizcard-light.json +100 -0
  119. package/src/frames/official/bizcard-portrait.json +105 -0
  120. package/src/frames/official/black-friday-bands.json +120 -0
  121. package/src/frames/official/black-friday-bolt.json +76 -0
  122. package/src/frames/official/black-friday-burst.json +131 -0
  123. package/src/frames/official/black-friday-tab.json +95 -0
  124. package/src/frames/official/black-friday-tag.json +65 -0
  125. package/src/frames/official/book-now.json +1 -0
  126. package/src/frames/official/browser-window.json +120 -0
  127. package/src/frames/official/bubble-outline.json +88 -0
  128. package/src/frames/official/bubble-tail-left.json +60 -0
  129. package/src/frames/official/bubble-tail-right.json +82 -0
  130. package/src/frames/official/cafe-bean.json +94 -0
  131. package/src/frames/official/cafe-cup.json +81 -0
  132. package/src/frames/official/cafe-loyalty.json +89 -0
  133. package/src/frames/official/cafe-menu-board.json +66 -0
  134. package/src/frames/official/cafe-steam.json +113 -0
  135. package/src/frames/official/cafe-wifi.json +105 -0
  136. package/src/frames/official/chat-pair.json +107 -0
  137. package/src/frames/official/check-in.json +1 -0
  138. package/src/frames/official/christmas-bauble.json +71 -0
  139. package/src/frames/official/christmas-bells.json +127 -0
  140. package/src/frames/official/christmas-candle.json +122 -0
  141. package/src/frames/official/christmas-gift-box.json +99 -0
  142. package/src/frames/official/christmas-holly.json +114 -0
  143. package/src/frames/official/christmas-market-ticket.json +85 -0
  144. package/src/frames/official/christmas-postcard.json +95 -0
  145. package/src/frames/official/christmas-snow-tab.json +80 -0
  146. package/src/frames/official/christmas-star-seal.json +178 -0
  147. package/src/frames/official/christmas-tree.json +81 -0
  148. package/src/frames/official/christmas-wreath.json +96 -0
  149. package/src/frames/official/christmas.json +2 -0
  150. package/src/frames/official/circle-badge-top.json +88 -0
  151. package/src/frames/official/curl-arrow-tinted.json +85 -0
  152. package/src/frames/official/curl-arrow.json +101 -0
  153. package/src/frames/official/cyber-monday-browser.json +122 -0
  154. package/src/frames/official/cyber-monday-neon.json +78 -0
  155. package/src/frames/official/cyber-monday-ticket.json +86 -0
  156. package/src/frames/official/cyber-monday-wide.json +78 -0
  157. package/src/frames/official/diwali-diya.json +82 -0
  158. package/src/frames/official/diwali-lantern.json +120 -0
  159. package/src/frames/official/diwali-lotus.json +122 -0
  160. package/src/frames/official/diwali-marigold.json +71 -0
  161. package/src/frames/official/diwali-rangoli-card.json +95 -0
  162. package/src/frames/official/diwali-rangoli.json +175 -0
  163. package/src/frames/official/diwali-toran.json +110 -0
  164. package/src/frames/official/donate.json +1 -0
  165. package/src/frames/official/double-border.json +110 -0
  166. package/src/frames/official/easter-bunting.json +110 -0
  167. package/src/frames/official/easter-butterfly.json +83 -0
  168. package/src/frames/official/easter-corners.json +99 -0
  169. package/src/frames/official/easter-egg-hunt.json +93 -0
  170. package/src/frames/official/easter-egg.json +71 -0
  171. package/src/frames/official/easter-tulip.json +114 -0
  172. package/src/frames/official/edu-assignment.json +127 -0
  173. package/src/frames/official/edu-attendance.json +117 -0
  174. package/src/frames/official/edu-course.json +99 -0
  175. package/src/frames/official/edu-exam.json +83 -0
  176. package/src/frames/official/edu-graduation.json +182 -0
  177. package/src/frames/official/edu-idea.json +94 -0
  178. package/src/frames/official/edu-lab.json +74 -0
  179. package/src/frames/official/edu-library.json +70 -0
  180. package/src/frames/official/edu-open-day.json +109 -0
  181. package/src/frames/official/eid-adha-envelope.json +75 -0
  182. package/src/frames/official/eid-adha-lantern.json +80 -0
  183. package/src/frames/official/eid-adha-night.json +76 -0
  184. package/src/frames/official/eid-adha-seal.json +99 -0
  185. package/src/frames/official/eid-fitr-arch.json +71 -0
  186. package/src/frames/official/eid-fitr-border.json +117 -0
  187. package/src/frames/official/eid-fitr-gift.json +99 -0
  188. package/src/frames/official/eid-fitr-lantern.json +120 -0
  189. package/src/frames/official/eid-fitr-seal.json +181 -0
  190. package/src/frames/official/event-agenda.json +96 -0
  191. package/src/frames/official/event-announcement.json +79 -0
  192. package/src/frames/official/event-badge.json +89 -0
  193. package/src/frames/official/event-birthday.json +70 -0
  194. package/src/frames/official/event-check-in.json +117 -0
  195. package/src/frames/official/event-cinema.json +66 -0
  196. package/src/frames/official/event-comedy.json +89 -0
  197. package/src/frames/official/event-concert.json +91 -0
  198. package/src/frames/official/event-exhibit.json +102 -0
  199. package/src/frames/official/event-festival.json +109 -0
  200. package/src/frames/official/event-livestream.json +111 -0
  201. package/src/frames/official/event-party.json +113 -0
  202. package/src/frames/official/event-photos.json +104 -0
  203. package/src/frames/official/event-race.json +80 -0
  204. package/src/frames/official/event-raffle.json +89 -0
  205. package/src/frames/official/event-save-the-date.json +113 -0
  206. package/src/frames/official/event-sports.json +71 -0
  207. package/src/frames/official/event-theatre.json +115 -0
  208. package/src/frames/official/event-ticket.json +1 -0
  209. package/src/frames/official/event-wristband.json +91 -0
  210. package/src/frames/official/fathers-day-bow-tie.json +114 -0
  211. package/src/frames/official/fathers-day-photo.json +106 -0
  212. package/src/frames/official/fathers-day-tie.json +81 -0
  213. package/src/frames/official/fathers-day-trophy.json +72 -0
  214. package/src/frames/official/feedback-bubble.json +1 -0
  215. package/src/frames/official/feedback-survey.json +115 -0
  216. package/src/frames/official/fitness-challenge.json +72 -0
  217. package/src/frames/official/fitness-equipment.json +93 -0
  218. package/src/frames/official/fitness-kettlebell.json +74 -0
  219. package/src/frames/official/fitness-schedule.json +93 -0
  220. package/src/frames/official/fitness-timer.json +88 -0
  221. package/src/frames/official/fitness-trial.json +130 -0
  222. package/src/frames/official/fitness-yoga.json +70 -0
  223. package/src/frames/official/folder-tab-arrow.json +78 -0
  224. package/src/frames/official/folder-tab.json +87 -0
  225. package/src/frames/official/follow-us.json +1 -0
  226. package/src/frames/official/food-truck.json +108 -0
  227. package/src/frames/official/geo-corners.json +98 -0
  228. package/src/frames/official/get-the-app.json +1 -0
  229. package/src/frames/official/half-circle.json +66 -0
  230. package/src/frames/official/halloween-bat.json +76 -0
  231. package/src/frames/official/halloween-candle.json +71 -0
  232. package/src/frames/official/halloween-hat.json +90 -0
  233. package/src/frames/official/halloween-moon.json +90 -0
  234. package/src/frames/official/halloween-pumpkin.json +100 -0
  235. package/src/frames/official/halloween-seal.json +170 -0
  236. package/src/frames/official/halloween-web.json +76 -0
  237. package/src/frames/official/halloween.json +2 -0
  238. package/src/frames/official/hang-tag-light.json +60 -0
  239. package/src/frames/official/hang-tag.json +58 -0
  240. package/src/frames/official/hanging-tab-two-lines.json +78 -0
  241. package/src/frames/official/hanging-tab.json +64 -0
  242. package/src/frames/official/hanukkah-border.json +117 -0
  243. package/src/frames/official/hanukkah-candles.json +81 -0
  244. package/src/frames/official/hanukkah-gift.json +99 -0
  245. package/src/frames/official/hanukkah-menorah.json +114 -0
  246. package/src/frames/official/hanukkah-star.json +178 -0
  247. package/src/frames/official/health-appointment.json +113 -0
  248. package/src/frames/official/health-check-in.json +93 -0
  249. package/src/frames/official/health-dental.json +102 -0
  250. package/src/frames/official/health-medication.json +58 -0
  251. package/src/frames/official/health-pet.json +81 -0
  252. package/src/frames/official/health-pharmacy.json +94 -0
  253. package/src/frames/official/health-portal.json +74 -0
  254. package/src/frames/official/health-waiting-room.json +117 -0
  255. package/src/frames/official/holi-bands.json +120 -0
  256. package/src/frames/official/holi-bunting.json +110 -0
  257. package/src/frames/official/holi-corners.json +99 -0
  258. package/src/frames/official/holi-splash.json +109 -0
  259. package/src/frames/official/holi-sticker.json +83 -0
  260. package/src/frames/official/hotel-bed.json +99 -0
  261. package/src/frames/official/hotel-breakfast.json +121 -0
  262. package/src/frames/official/hotel-check-out.json +109 -0
  263. package/src/frames/official/hotel-concierge.json +115 -0
  264. package/src/frames/official/hotel-hanger-light.json +69 -0
  265. package/src/frames/official/hotel-key.json +77 -0
  266. package/src/frames/official/hotel-room-service.json +66 -0
  267. package/src/frames/official/ice-cream-shop.json +111 -0
  268. package/src/frames/official/independence-brazil.json +112 -0
  269. package/src/frames/official/independence-canada.json +112 -0
  270. package/src/frames/official/independence-fireworks.json +183 -0
  271. package/src/frames/official/independence-france.json +100 -0
  272. package/src/frames/official/independence-india.json +105 -0
  273. package/src/frames/official/independence-mexico.json +100 -0
  274. package/src/frames/official/independence-us-fireworks.json +81 -0
  275. package/src/frames/official/independence-us.json +128 -0
  276. package/src/frames/official/landscape-light.json +92 -0
  277. package/src/frames/official/landscape-panel.json +71 -0
  278. package/src/frames/official/learn-more-card.json +63 -0
  279. package/src/frames/official/lunar-banner.json +123 -0
  280. package/src/frames/official/lunar-blossom.json +71 -0
  281. package/src/frames/official/lunar-coin.json +190 -0
  282. package/src/frames/official/lunar-knot.json +87 -0
  283. package/src/frames/official/lunar-lantern.json +120 -0
  284. package/src/frames/official/lunar-red-envelope.json +82 -0
  285. package/src/frames/official/menu-arch.json +64 -0
  286. package/src/frames/official/menu-chalkboard.json +66 -0
  287. package/src/frames/official/menu-chef.json +80 -0
  288. package/src/frames/official/menu-cloche.json +121 -0
  289. package/src/frames/official/menu-cutlery.json +93 -0
  290. package/src/frames/official/menu-noodles.json +94 -0
  291. package/src/frames/official/menu-pizza.json +86 -0
  292. package/src/frames/official/mothers-day-brunch.json +122 -0
  293. package/src/frames/official/mothers-day-daisy.json +109 -0
  294. package/src/frames/official/mothers-day-photo.json +106 -0
  295. package/src/frames/official/mothers-day-tulip.json +71 -0
  296. package/src/frames/official/neon-tube.json +72 -0
  297. package/src/frames/official/new-year-calendar.json +115 -0
  298. package/src/frames/official/new-year-countdown.json +120 -0
  299. package/src/frames/official/new-year-firework.json +81 -0
  300. package/src/frames/official/new-year-seal.json +173 -0
  301. package/src/frames/official/new-year-skyline.json +102 -0
  302. package/src/frames/official/new-year-sparkle.json +86 -0
  303. package/src/frames/official/new-year-toast.json +71 -0
  304. package/src/frames/official/new-year.json +2 -0
  305. package/src/frames/official/order-at-table.json +1 -0
  306. package/src/frames/official/order-here-tab.json +98 -0
  307. package/src/frames/official/order-pickup.json +70 -0
  308. package/src/frames/official/pack-authentic.json +179 -0
  309. package/src/frames/official/pack-care.json +60 -0
  310. package/src/frames/official/pack-eco.json +79 -0
  311. package/src/frames/official/pack-instructions.json +99 -0
  312. package/src/frames/official/pack-label.json +91 -0
  313. package/src/frames/official/pack-parcel.json +96 -0
  314. package/src/frames/official/pack-recycle.json +121 -0
  315. package/src/frames/official/pack-reorder.json +92 -0
  316. package/src/frames/official/pack-unboxing.json +98 -0
  317. package/src/frames/official/pack-video-guide.json +88 -0
  318. package/src/frames/official/pack-warranty.json +91 -0
  319. package/src/frames/official/passover-arch.json +66 -0
  320. package/src/frames/official/passover-border.json +122 -0
  321. package/src/frames/official/passover-cup.json +81 -0
  322. package/src/frames/official/passover-matzah.json +109 -0
  323. package/src/frames/official/pay-at-table.json +103 -0
  324. package/src/frames/official/pay-card.json +99 -0
  325. package/src/frames/official/pay-coins.json +117 -0
  326. package/src/frames/official/pay-donate-heart.json +77 -0
  327. package/src/frames/official/pay-invoice.json +115 -0
  328. package/src/frames/official/pay-receipt.json +131 -0
  329. package/src/frames/official/pay-tap.json +78 -0
  330. package/src/frames/official/pay-tips.json +81 -0
  331. package/src/frames/official/pay-wallet.json +83 -0
  332. package/src/frames/official/phone-button.json +105 -0
  333. package/src/frames/official/phone-outline.json +94 -0
  334. package/src/frames/official/phone-screen.json +96 -0
  335. package/src/frames/official/polaroid-caption.json +108 -0
  336. package/src/frames/official/polaroid-photo.json +104 -0
  337. package/src/frames/official/postage-stamp-light.json +90 -0
  338. package/src/frames/official/postage-stamp.json +88 -0
  339. package/src/frames/official/product-info.json +1 -0
  340. package/src/frames/official/property-floor-plan.json +99 -0
  341. package/src/frames/official/property-for-sale.json +107 -0
  342. package/src/frames/official/property-house-light.json +89 -0
  343. package/src/frames/official/property-house.json +71 -0
  344. package/src/frames/official/property-key.json +89 -0
  345. package/src/frames/official/property-open-house.json +79 -0
  346. package/src/frames/official/property-rent.json +119 -0
  347. package/src/frames/official/property-virtual-tour.json +77 -0
  348. package/src/frames/official/ramadan-crescent.json +81 -0
  349. package/src/frames/official/ramadan-hanging.json +109 -0
  350. package/src/frames/official/ramadan-iftar-menu.json +95 -0
  351. package/src/frames/official/ramadan-lantern.json +77 -0
  352. package/src/frames/official/ramadan-seal.json +183 -0
  353. package/src/frames/official/rate-your-meal.json +93 -0
  354. package/src/frames/official/register-product.json +1 -0
  355. package/src/frames/official/restaurant-booking.json +113 -0
  356. package/src/frames/official/restaurant-delivery.json +82 -0
  357. package/src/frames/official/review-bubble.json +82 -0
  358. package/src/frames/official/review-laurel.json +93 -0
  359. package/src/frames/official/review-quote.json +74 -0
  360. package/src/frames/official/review-ribbon.json +136 -0
  361. package/src/frames/official/review-star.json +88 -0
  362. package/src/frames/official/review-thumb.json +81 -0
  363. package/src/frames/official/review-us.json +1 -0
  364. package/src/frames/official/ribbon-banner-solid.json +115 -0
  365. package/src/frames/official/ribbon-banner.json +117 -0
  366. package/src/frames/official/ribbon-sparkle.json +139 -0
  367. package/src/frames/official/rosette-badge.json +176 -0
  368. package/src/frames/official/round-badge-light.json +101 -0
  369. package/src/frames/official/round-badge.json +104 -0
  370. package/src/frames/official/rsvp-card.json +1 -0
  371. package/src/frames/official/save-contact.json +1 -0
  372. package/src/frames/official/scalloped-badge.json +172 -0
  373. package/src/frames/official/scan-button-tinted.json +72 -0
  374. package/src/frames/official/scan-button.json +97 -0
  375. package/src/frames/official/scan-for-directions.json +105 -0
  376. package/src/frames/official/scan-for-link.json +120 -0
  377. package/src/frames/official/scan-for-schedule.json +96 -0
  378. package/src/frames/official/scan-me-band-top.json +102 -0
  379. package/src/frames/official/scan-me-band.json +88 -0
  380. package/src/frames/official/scan-me-card.json +69 -0
  381. package/src/frames/official/scan-me-tile.json +55 -0
  382. package/src/frames/official/scan-to-call.json +95 -0
  383. package/src/frames/official/scan-to-download-file.json +74 -0
  384. package/src/frames/official/scan-to-email.json +91 -0
  385. package/src/frames/official/scan-to-listen.json +107 -0
  386. package/src/frames/official/scan-to-pay.json +1 -0
  387. package/src/frames/official/scan-to-share.json +96 -0
  388. package/src/frames/official/scan-to-sign-up.json +89 -0
  389. package/src/frames/official/scan-to-subscribe.json +91 -0
  390. package/src/frames/official/scan-to-vote.json +86 -0
  391. package/src/frames/official/scan-to-watch.json +75 -0
  392. package/src/frames/official/school-book.json +71 -0
  393. package/src/frames/official/school-calendar.json +115 -0
  394. package/src/frames/official/school-notebook.json +128 -0
  395. package/src/frames/official/school-palette.json +84 -0
  396. package/src/frames/official/school-pencil.json +81 -0
  397. package/src/frames/official/school-ruler.json +114 -0
  398. package/src/frames/official/shop-awning.json +108 -0
  399. package/src/frames/official/shop-bag.json +70 -0
  400. package/src/frames/official/shop-cart.json +76 -0
  401. package/src/frames/official/shop-coupon.json +129 -0
  402. package/src/frames/official/shop-fashion.json +58 -0
  403. package/src/frames/official/shop-gift-card.json +98 -0
  404. package/src/frames/official/shop-hanger.json +88 -0
  405. package/src/frames/official/shop-jewelry.json +121 -0
  406. package/src/frames/official/shop-loyalty.json +92 -0
  407. package/src/frames/official/shop-new-arrivals.json +139 -0
  408. package/src/frames/official/shop-percent.json +75 -0
  409. package/src/frames/official/shop-price-check.json +106 -0
  410. package/src/frames/official/shop-sale-burst.json +130 -0
  411. package/src/frames/official/shop-sale-tag.json +63 -0
  412. package/src/frames/official/shop-tshirt.json +81 -0
  413. package/src/frames/official/shop-window-sticker.json +104 -0
  414. package/src/frames/official/shop-window.json +1 -0
  415. package/src/frames/official/side-bar-arrow.json +104 -0
  416. package/src/frames/official/side-bar.json +96 -0
  417. package/src/frames/official/side-rules-border.json +109 -0
  418. package/src/frames/official/side-rules.json +73 -0
  419. package/src/frames/official/sign-rider.json +1 -0
  420. package/src/frames/official/social-camera.json +104 -0
  421. package/src/frames/official/social-follow-bubble.json +86 -0
  422. package/src/frames/official/social-hashtag.json +74 -0
  423. package/src/frames/official/social-like.json +171 -0
  424. package/src/frames/official/social-links.json +120 -0
  425. package/src/frames/official/social-music.json +93 -0
  426. package/src/frames/official/social-newsletter.json +69 -0
  427. package/src/frames/official/social-video.json +102 -0
  428. package/src/frames/official/speech-bubble-over.json +72 -0
  429. package/src/frames/official/speech-bubble-round.json +86 -0
  430. package/src/frames/official/spring-blossom.json +114 -0
  431. package/src/frames/official/spring-butterfly.json +109 -0
  432. package/src/frames/official/spring-daisy.json +175 -0
  433. package/src/frames/official/spring-sprout.json +123 -0
  434. package/src/frames/official/spring-tulip.json +71 -0
  435. package/src/frames/official/st-patricks-clover.json +175 -0
  436. package/src/frames/official/st-patricks-horseshoe.json +86 -0
  437. package/src/frames/official/st-patricks-pub.json +114 -0
  438. package/src/frames/official/st-patricks-shamrock.json +76 -0
  439. package/src/frames/official/sticker-grey.json +94 -0
  440. package/src/frames/official/sticker-outline.json +90 -0
  441. package/src/frames/official/sticker-peel.json +97 -0
  442. package/src/frames/official/stitched-card.json +125 -0
  443. package/src/frames/official/stitched-light.json +107 -0
  444. package/src/frames/official/summer-ice-pop.json +83 -0
  445. package/src/frames/official/summer-palm.json +71 -0
  446. package/src/frames/official/summer-parasol.json +114 -0
  447. package/src/frames/official/summer-shell.json +122 -0
  448. package/src/frames/official/summer-sun-scene.json +93 -0
  449. package/src/frames/official/summer-waves.json +89 -0
  450. package/src/frames/official/table-number.json +119 -0
  451. package/src/frames/official/table-tent.json +1 -0
  452. package/src/frames/official/tap-or-scan-band.json +107 -0
  453. package/src/frames/official/thanksgiving-acorn.json +71 -0
  454. package/src/frames/official/thanksgiving-leaf.json +109 -0
  455. package/src/frames/official/thanksgiving-pumpkin.json +81 -0
  456. package/src/frames/official/thanksgiving-table.json +95 -0
  457. package/src/frames/official/thanksgiving-wheat.json +117 -0
  458. package/src/frames/official/ticket-light.json +67 -0
  459. package/src/frames/official/ticket-stub.json +78 -0
  460. package/src/frames/official/ticket-wide.json +97 -0
  461. package/src/frames/official/travel-boarding-pass.json +118 -0
  462. package/src/frames/official/travel-city-guide.json +103 -0
  463. package/src/frames/official/travel-compass.json +100 -0
  464. package/src/frames/official/travel-directions.json +96 -0
  465. package/src/frames/official/travel-excursions.json +70 -0
  466. package/src/frames/official/travel-luggage.json +58 -0
  467. package/src/frames/official/travel-tour.json +77 -0
  468. package/src/frames/official/travel-trail.json +97 -0
  469. package/src/frames/official/two-bands.json +119 -0
  470. package/src/frames/official/underline-bold.json +79 -0
  471. package/src/frames/official/underline-left.json +85 -0
  472. package/src/frames/official/valentine-arrow.json +71 -0
  473. package/src/frames/official/valentine-bands.json +123 -0
  474. package/src/frames/official/valentine-dinner.json +122 -0
  475. package/src/frames/official/valentine-heart.json +76 -0
  476. package/src/frames/official/valentine-hearts.json +83 -0
  477. package/src/frames/official/valentine-letter.json +76 -0
  478. package/src/frames/official/viewfinder-note.json +120 -0
  479. package/src/frames/official/viewfinder.json +103 -0
  480. package/src/frames/official/wave-band.json +77 -0
  481. package/src/frames/official/wedding-invitation.json +122 -0
  482. package/src/frames/official/wedding-letter.json +78 -0
  483. package/src/frames/official/wedding-photos.json +105 -0
  484. package/src/frames/official/wedding-registry.json +98 -0
  485. package/src/frames/official/wedding-rings.json +71 -0
  486. package/src/frames/official/wedding-seal.json +179 -0
  487. package/src/frames/official/wedding-seating.json +102 -0
  488. package/src/frames/official/wedding-toast.json +121 -0
  489. package/src/frames/official/wedding-welcome.json +70 -0
  490. package/src/frames/official/wifi-bubble.json +86 -0
  491. package/src/frames/official/wifi-card.json +1 -0
  492. package/src/frames/official/wifi-circle-top.json +91 -0
  493. package/src/frames/official/wifi-corners.json +117 -0
  494. package/src/frames/official/wifi-seal.json +104 -0
  495. package/src/frames/official/wifi-sticker.json +84 -0
  496. package/src/frames/official/wifi-tab.json +78 -0
  497. package/src/frames/official/wifi-tile.json +55 -0
  498. package/src/frames/official/wifi-wide.json +79 -0
  499. package/src/frames/official/winter-cocoa.json +82 -0
  500. package/src/frames/official/winter-crystal.json +76 -0
  501. package/src/frames/official/winter-mitten.json +114 -0
  502. package/src/frames/official/winter-peaks.json +95 -0
  503. package/src/frames/official/winter-snow-seal.json +174 -0
  504. package/src/frames/official/winter.json +2 -0
  505. package/src/frames/official-types.ts +48 -0
  506. package/src/frames/official.ts +26 -70
  507. package/src/frames/spec-hash.ts +34 -0
  508. package/src/helpers.ts +4 -4
  509. package/src/index.tsx +24 -5
  510. package/src/logo-budget.ts +4 -4
  511. package/src/node.ts +61 -0
  512. package/src/part-markers.ts +40 -0
  513. package/src/qr-code-canvas.tsx +1 -0
  514. package/src/qr-code.tsx +2 -0
  515. package/src/rasterize.ts +282 -0
  516. package/src/utils.tsx +62 -19
  517. package/types/qr.ts +5 -0
@@ -208,7 +208,7 @@ export function capImageSettings(
208
208
  };
209
209
  const drawnAt = (settings: ImageSettings) =>
210
210
  resolveErrorLevel({ ...code, level: requested, imageSettings: settings });
211
- const fit = (level: ErrorLevel) => {
211
+ const fitAt = (level: ErrorLevel) => {
212
212
  const fitted = fitLogoWidth(base, [level], width, layout);
213
213
  return fitted > 0 ? layout(fitted) : undefined;
214
214
  };
@@ -216,11 +216,11 @@ export function capImageSettings(
216
216
  // while the logo still raises it, else size it for the requested level.
217
217
  const drawn = drawnAt(imageSettings);
218
218
  if (drawn === requested) {
219
- return fit(requested);
219
+ return fitAt(requested);
220
220
  }
221
- const atDrawn = fit(drawn);
221
+ const atDrawn = fitAt(drawn);
222
222
  if (atDrawn && drawnAt(atDrawn) === drawn) {
223
223
  return atDrawn;
224
224
  }
225
- return fit(requested);
225
+ return fitAt(requested);
226
226
  }
package/src/node.ts ADDED
@@ -0,0 +1,61 @@
1
+ // The Node-only entry (`qrdx/node`). PNG rasterization needs an optional
2
+ // native rasterizer (@resvg/resvg-js or sharp), and bundlers follow dynamic
3
+ // imports as well as static ones, so this lives apart from the main entry:
4
+ // dist/index.mjs never mentions either package, and an app that bundles the
5
+ // library for the browser doesn't try to link a native module. Import it
6
+ // from "qrdx/node", never from "qrdx", when you want a PNG on a server.
7
+
8
+ import type { QRProps } from "../types";
9
+ import { DEFAULT_SIZE } from "./constants";
10
+ import { withQRSize } from "./download";
11
+ import { getQRAsSVGDataUri } from "./index";
12
+ import {
13
+ loadLogoForRasterizer,
14
+ type RasterLogo,
15
+ rasterizeSvgToPng,
16
+ } from "./rasterize";
17
+
18
+ export interface QRAsPNGOptions {
19
+ /** Pixel size of the code; defaults to the props' own size (128). */
20
+ size?: number;
21
+ /**
22
+ * Whether logos that aren't already data URLs are loaded: http(s) URLs are
23
+ * fetched (1 MB cap, no redirects) and local paths are read from disk. Off
24
+ * by default, so a server passing a caller's imageSettings through can't
25
+ * be made to fetch internal URLs or read files off its own disk.
26
+ */
27
+ loadExternalLogos?: boolean;
28
+ }
29
+
30
+ /**
31
+ * The code as PNG bytes (plus its frame, if any), without a browser: the SVG
32
+ * the library renders is rasterized by an optional peer dependency —
33
+ * `@resvg/resvg-js`, which draws the SVG (logos included) the way browsers
34
+ * do, or `sharp` — loaded only when this is called. A logo is embedded as a
35
+ * data URL first: a data URL is kept as-is, and with `loadExternalLogos` an
36
+ * http(s) URL is fetched and a local path is read from disk (Node). A logo
37
+ * that can't be loaded is left out, like in the browser.
38
+ */
39
+ export async function getQRAsPNG(
40
+ qrProps: QRProps,
41
+ options: QRAsPNGOptions = {}
42
+ ): Promise<Uint8Array> {
43
+ const size = options.size ?? qrProps.size ?? DEFAULT_SIZE;
44
+ const propsWithSize = withQRSize(qrProps, size);
45
+
46
+ const src = propsWithSize.imageSettings?.src;
47
+ const logo: RasterLogo | null = src
48
+ ? await loadLogoForRasterizer(src, options.loadExternalLogos === true)
49
+ : null;
50
+ const propsWithLogo =
51
+ logo && propsWithSize.imageSettings && logo.dataUrl !== src
52
+ ? {
53
+ ...propsWithSize,
54
+ imageSettings: { ...propsWithSize.imageSettings, src: logo.dataUrl },
55
+ }
56
+ : propsWithSize;
57
+
58
+ const svgDataUri = await getQRAsSVGDataUri(propsWithLogo);
59
+ const svg = decodeURIComponent(svgDataUri.replace("data:image/svg+xml,", ""));
60
+ return await rasterizeSvgToPng(svg, logo);
61
+ }
@@ -0,0 +1,40 @@
1
+ // Part markers: an editor's live preview renders with `partMarkers` so it can
2
+ // find each part of the code on screen (the finder eyes, the dots, the logo,
3
+ // the background) and put a control over it. Off by default; exports drop it.
4
+
5
+ /** Marks a drawn part of the code in SVG drawn with `partMarkers`. */
6
+ export const QR_PART_ATTRIBUTE = "data-qrdx-part";
7
+
8
+ /** Says which finder an "eye-outer" or "eye-centre" part belongs to. */
9
+ export const QR_EYE_ATTRIBUTE = "data-qrdx-eye";
10
+
11
+ /** The parts `partMarkers` marks (values of QR_PART_ATTRIBUTE). */
12
+ export const QR_PARTS = [
13
+ "eye-outer",
14
+ "eye-centre",
15
+ "body",
16
+ "logo",
17
+ "background",
18
+ ] as const;
19
+
20
+ export type QRPart = (typeof QR_PARTS)[number];
21
+
22
+ /** The finder eyes, as QR_EYE_ATTRIBUTE names them. */
23
+ export type QRPartEye = "top-left" | "top-right" | "bottom-left";
24
+
25
+ /**
26
+ * The attributes that mark `part` (and its eye), or none when markers are
27
+ * off. Spread last on the element, so dropping them gives the default markup.
28
+ */
29
+ export function partMarker(
30
+ on: boolean | undefined,
31
+ part: QRPart,
32
+ eye?: QRPartEye
33
+ ): Record<string, string> | undefined {
34
+ if (!on) {
35
+ return;
36
+ }
37
+ return eye
38
+ ? { [QR_PART_ATTRIBUTE]: part, [QR_EYE_ATTRIBUTE]: eye }
39
+ : { [QR_PART_ATTRIBUTE]: part };
40
+ }
@@ -60,6 +60,7 @@ export function QRCodeCanvas(props: QRPropsCanvas) {
60
60
  eyeColors: _eyeColors,
61
61
  moduleScale: _moduleScale,
62
62
  frameLabelMarkers: _frameLabelMarkers,
63
+ partMarkers: _partMarkers,
63
64
  autoLevel,
64
65
  shape,
65
66
  ...otherProps
package/src/qr-code.tsx CHANGED
@@ -42,6 +42,7 @@ export const QRCode = memo(
42
42
  autoLevel,
43
43
  shape,
44
44
  frameLabelMarkers,
45
+ partMarkers,
45
46
  }: QRCodeProps) => {
46
47
  // getQRData lays the logo out on a 1024px canvas; scale it to the rendered size.
47
48
  const renderSize = size * scale;
@@ -122,6 +123,7 @@ export const QRCode = memo(
122
123
  {...(autoLevel && { autoLevel })}
123
124
  {...(shape && shape !== "square" && { shape })}
124
125
  {...(frameLabelMarkers && { frameLabelMarkers })}
126
+ {...(partMarkers && { partMarkers })}
125
127
  size={renderSize}
126
128
  style={style}
127
129
  templateId={qrData.templateId}
@@ -0,0 +1,282 @@
1
+ /** biome-ignore-all lint/style/noMagicNumbers: image format magic bytes */
2
+ // Node-friendly rasterization for PNG export (getQRAsPNG in download.tsx).
3
+ // Both rasterizers are optional peer dependencies loaded only when a PNG is
4
+ // asked for, so installing qrdx never pulls in a native module:
5
+ //
6
+ // - @resvg/resvg-js is tried first: it draws the SVG the way browsers do,
7
+ // embedded logos included (PNG, JPEG, GIF, WebP and SVG images).
8
+ // - sharp is tried next, but its bundled SVG renderer skips embedded <image>
9
+ // elements, so the logo is located with a marker render and composited
10
+ // onto the pixels afterwards.
11
+
12
+ type SharpFactory = typeof import("sharp").default;
13
+
14
+ /** A logo loaded for rasterizing: the raw bytes, plus the data URL the SVG embeds. */
15
+ export interface RasterLogo {
16
+ bytes: Uint8Array;
17
+ dataUrl: string;
18
+ }
19
+
20
+ /** Largest logo the rasterizer loads (the cap apps/docs/lib/qr-api/logo.ts uses). */
21
+ const LOGO_MAX_BYTES = 1024 * 1024;
22
+
23
+ const LOGO_FETCH_TIMEOUT_MS = 10_000;
24
+
25
+ /** Reads the response body, giving up once it passes the size cap. */
26
+ async function readBodyCapped(
27
+ response: Response,
28
+ maxBytes: number
29
+ ): Promise<Uint8Array | null> {
30
+ if (!response.body) {
31
+ return null;
32
+ }
33
+ const reader = response.body.getReader();
34
+ const chunks: Uint8Array[] = [];
35
+ let received = 0;
36
+ for (;;) {
37
+ const { done, value } = await reader.read();
38
+ if (done) {
39
+ break;
40
+ }
41
+ received += value.byteLength;
42
+ if (received > maxBytes) {
43
+ await reader.cancel().catch(() => {
44
+ // Already over the cap; losing this read is fine.
45
+ });
46
+ return null;
47
+ }
48
+ chunks.push(value);
49
+ }
50
+ const bytes = new Uint8Array(received);
51
+ let offset = 0;
52
+ for (const chunk of chunks) {
53
+ bytes.set(chunk, offset);
54
+ offset += chunk.byteLength;
55
+ }
56
+ return bytes;
57
+ }
58
+
59
+ const base64ToBytes = (base64: string) =>
60
+ Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));
61
+
62
+ const bytesToBase64 = (bytes: Uint8Array) => {
63
+ let binary = "";
64
+ for (let i = 0; i < bytes.length; i += 0x80_00) {
65
+ binary += String.fromCharCode(...bytes.subarray(i, i + 0x80_00));
66
+ }
67
+ return btoa(binary);
68
+ };
69
+
70
+ /**
71
+ * Sniffs a file's first bytes into an image MIME type, or null. These are
72
+ * the types the rasterizers draw (resvg renders PNG, JPEG, GIF and WebP
73
+ * images, plus nested SVG, the same way browsers do).
74
+ */
75
+ function sniffImageMime(bytes: Uint8Array): string | null {
76
+ if (bytes[0] === 0x89 && bytes[1] === 0x50) {
77
+ return "image/png";
78
+ }
79
+ if (bytes[0] === 0xff && bytes[1] === 0xd8) {
80
+ return "image/jpeg";
81
+ }
82
+ if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
83
+ return "image/gif";
84
+ }
85
+ if (
86
+ bytes[0] === 0x52 &&
87
+ bytes[1] === 0x49 &&
88
+ bytes[2] === 0x46 &&
89
+ bytes[3] === 0x46 &&
90
+ bytes[8] === 0x57 &&
91
+ bytes[9] === 0x45 &&
92
+ bytes[10] === 0x42 &&
93
+ bytes[11] === 0x50
94
+ ) {
95
+ return "image/webp";
96
+ }
97
+ const head = new TextDecoder()
98
+ .decode(bytes.subarray(0, 512))
99
+ .trimStart()
100
+ .toLowerCase();
101
+ if (head.startsWith("<?xml") || head.startsWith("<svg")) {
102
+ return "image/svg+xml";
103
+ }
104
+ return null;
105
+ }
106
+
107
+ /**
108
+ * Loads a logo the way a Node export needs it: a data URL is decoded; an
109
+ * http(s) URL is fetched and anything else is read from disk — but only when
110
+ * the caller opts in with `loadExternal`, since a library function that runs
111
+ * on servers must not become a way to fetch internal URLs or read files
112
+ * (a data URL, which the caller already holds, needs no opt-in). Fetches are
113
+ * capped at 1 MB and refuse redirects. Returns null when it can't be loaded
114
+ * or isn't an image the rasterizers draw — the logo is left out then, the
115
+ * same thing the browser path does when an <img> fails to load.
116
+ */
117
+ export async function loadLogoForRasterizer(
118
+ src: string,
119
+ loadExternal = false
120
+ ): Promise<RasterLogo | null> {
121
+ if (src.startsWith("data:")) {
122
+ const comma = src.indexOf(",");
123
+ if (comma < 0) {
124
+ return null;
125
+ }
126
+ // Whatever the caller handed over stays the <image> href; the bytes are
127
+ // for sharp's composite path only and may fail to decode.
128
+ try {
129
+ const bytes = src.slice(5, comma).endsWith(";base64")
130
+ ? base64ToBytes(src.slice(comma + 1))
131
+ : new TextEncoder().encode(decodeURIComponent(src.slice(comma + 1)));
132
+ return { bytes, dataUrl: src };
133
+ } catch {
134
+ return null;
135
+ }
136
+ }
137
+
138
+ if (!loadExternal) {
139
+ return null;
140
+ }
141
+
142
+ let bytes: Uint8Array;
143
+ if (/^https?:\/\//i.test(src)) {
144
+ try {
145
+ // redirect: "error" keeps a URL a caller sent from being walked
146
+ // somewhere else by a redirect.
147
+ const response = await fetch(src, {
148
+ redirect: "error",
149
+ signal: AbortSignal.timeout(LOGO_FETCH_TIMEOUT_MS),
150
+ });
151
+ if (!response.ok) {
152
+ return null;
153
+ }
154
+ const body = await readBodyCapped(response, LOGO_MAX_BYTES);
155
+ if (!body) {
156
+ return null;
157
+ }
158
+ bytes = body;
159
+ } catch {
160
+ return null;
161
+ }
162
+ } else if (typeof process !== "undefined" && process.versions?.node) {
163
+ // A local path. The specifier is computed so browser bundlers never
164
+ // try to resolve node:fs.
165
+ try {
166
+ const specifier = ["node:fs", "promises"].join("/");
167
+ const fs = (await import(specifier)) as typeof import("node:fs/promises");
168
+ const stats = await fs.stat(src);
169
+ if (stats.size > LOGO_MAX_BYTES) {
170
+ return null;
171
+ }
172
+ bytes = new Uint8Array(await fs.readFile(src));
173
+ } catch {
174
+ return null;
175
+ }
176
+ } else {
177
+ return null;
178
+ }
179
+
180
+ const mime = sniffImageMime(bytes);
181
+ if (!mime) {
182
+ return null;
183
+ }
184
+ return { bytes, dataUrl: `data:${mime};base64,${bytesToBase64(bytes)}` };
185
+ }
186
+
187
+ /**
188
+ * Rasterizes the SVG the library renders into PNG bytes, at the SVG's own
189
+ * size (a fractional frame size rounds the way the browser's canvas does).
190
+ * The rasterizer is an optional peer dependency, loaded only here; when
191
+ * neither is installed the error names what to install.
192
+ */
193
+ export async function rasterizeSvgToPng(
194
+ svg: string,
195
+ logo: RasterLogo | null
196
+ ): Promise<Uint8Array> {
197
+ let Resvg: typeof import("@resvg/resvg-js").Resvg;
198
+ try {
199
+ ({ Resvg } = await import("@resvg/resvg-js"));
200
+ } catch (resvgError) {
201
+ // Not installed (or its binary didn't load): try sharp instead.
202
+ return await rasterizeWithSharp(svg, logo, resvgError);
203
+ }
204
+ // fitTo "original" (the default) renders at the SVG's own width and
205
+ // height, so the PNG is exactly as large as the SVG markup says.
206
+ const rendered = new Resvg(svg).render();
207
+ return new Uint8Array(rendered.asPng());
208
+ }
209
+
210
+ const describeError = (error: unknown) =>
211
+ error instanceof Error ? error.message : String(error);
212
+
213
+ async function rasterizeWithSharp(
214
+ svg: string,
215
+ logo: RasterLogo | null,
216
+ resvgError: unknown
217
+ ): Promise<Uint8Array> {
218
+ let sharp: SharpFactory;
219
+ try {
220
+ sharp = ((await import("sharp")) as { default: SharpFactory }).default;
221
+ } catch (sharpError) {
222
+ throw new Error(
223
+ "PNG export in Node needs an optional rasterizer package: " +
224
+ "`npm install @resvg/resvg-js` (draws embedded logos like a browser) " +
225
+ "or `npm install sharp`. " +
226
+ `(${describeError(resvgError)}; ${describeError(sharpError)})`
227
+ );
228
+ }
229
+
230
+ const png = await sharp(new TextEncoder().encode(svg)).png().toBuffer();
231
+ // sharp's bundled SVG renderer skips embedded <image> elements, so the
232
+ // logo never reaches the pixels: find where it belongs and composite it.
233
+ if (!logo) {
234
+ return new Uint8Array(png);
235
+ }
236
+ const box = await findLogoBox(sharp, svg);
237
+ if (!box) {
238
+ return new Uint8Array(png);
239
+ }
240
+ const logoPng = await sharp(logo.bytes)
241
+ .resize(box.width, box.height, { fit: "fill" })
242
+ .png()
243
+ .toBuffer();
244
+ const composited = await sharp(png)
245
+ .composite([{ input: logoPng, left: box.left, top: box.top }])
246
+ .png()
247
+ .toBuffer();
248
+ return new Uint8Array(composited);
249
+ }
250
+
251
+ /**
252
+ * Finds the logo's pixel box in the rendered output. The <image> is swapped
253
+ * for a lone visible rect, so the box comes out right even inside template
254
+ * transforms.
255
+ */
256
+ async function findLogoBox(sharp: SharpFactory, svg: string) {
257
+ const imageTag = svg.match(/<image\b[^>]*?(?:\/>|><\/image>)/)?.[0];
258
+ if (!imageTag) {
259
+ return null;
260
+ }
261
+ const markerTag = imageTag
262
+ .replace(/^<image\b/, '<rect class="qrdx-logo-box"')
263
+ .replace(/\shref="[^"]*"/, "")
264
+ .replace(/(?:\/>|><\/image>)$/, ' fill="#000"/>');
265
+ const markerSvg = svg
266
+ .replace(imageTag, markerTag)
267
+ .replace(
268
+ /<svg\b[^>]*>/,
269
+ (open) =>
270
+ `${open}<style>*{visibility:hidden}.qrdx-logo-box{visibility:visible}</style>`
271
+ );
272
+ const { info } = await sharp(new TextEncoder().encode(markerSvg))
273
+ .png()
274
+ .trim()
275
+ .toBuffer({ resolveWithObject: true });
276
+ return {
277
+ left: -(info.trimOffsetLeft ?? 0),
278
+ top: -(info.trimOffsetTop ?? 0),
279
+ width: info.width,
280
+ height: info.height,
281
+ };
282
+ }
package/src/utils.tsx CHANGED
@@ -43,6 +43,7 @@ import { generateCornerSquarePath } from "./corner-eye";
43
43
  import { isFrameActive, wrapWithFrame } from "./frame";
44
44
  import { LOGO_PLATE_INSET, LOGO_ROUNDED_RADIUS, renderLogo } from "./logo";
45
45
  import { capImageSettings } from "./logo-budget";
46
+ import { partMarker, type QRPart, type QRPartEye } from "./part-markers";
46
47
  import { getLayoutMargin, shapeBackground, shapeDecoration } from "./qr-shape";
47
48
  import { hashString } from "./shapes";
48
49
  import { getTemplate } from "./templates";
@@ -962,6 +963,7 @@ export function QRCodeSVG(props: QRPropsSVG) {
962
963
  autoLevel,
963
964
  shape,
964
965
  frameLabelMarkers,
966
+ partMarkers,
965
967
  ...otherProps
966
968
  } = props;
967
969
  // A logo no bigger than the code can repair (logo-budget.ts)
@@ -1006,15 +1008,33 @@ export function QRCodeSVG(props: QRPropsSVG) {
1006
1008
  // silhouette (a silhouette that can't hold the code draws square)
1007
1009
  const layoutMargin = getLayoutMargin(cells.length, margin, shape);
1008
1010
  const decoration = shapeDecoration(value, cells.length, margin, shape);
1011
+ // Editors find each part by its marker (partMarkers, part-markers.ts)
1012
+ const part = (name: QRPart, eye?: QRPartEye) =>
1013
+ partMarker(partMarkers, name, eye);
1009
1014
  const outline = (px: number, fill: FillProps) => {
1010
1015
  const background = shapeBackground(shape, px);
1011
1016
  if (!background) {
1012
- return <rect {...fill} height={px} width={px} x={0} y={0} />;
1017
+ return (
1018
+ <rect
1019
+ {...fill}
1020
+ height={px}
1021
+ width={px}
1022
+ x={0}
1023
+ y={0}
1024
+ {...part("background")}
1025
+ />
1026
+ );
1013
1027
  }
1014
1028
  return "circle" in background ? (
1015
- <circle cx={fmt(px / 2)} cy={fmt(px / 2)} {...fill} r={fmt(px / 2)} />
1029
+ <circle
1030
+ cx={fmt(px / 2)}
1031
+ cy={fmt(px / 2)}
1032
+ {...fill}
1033
+ r={fmt(px / 2)}
1034
+ {...part("background")}
1035
+ />
1016
1036
  ) : (
1017
- <path d={background.path} {...fill} />
1037
+ <path d={background.path} {...fill} {...part("background")} />
1018
1038
  );
1019
1039
  };
1020
1040
 
@@ -1075,6 +1095,9 @@ export function QRCodeSVG(props: QRPropsSVG) {
1075
1095
  w: imgWidth,
1076
1096
  h: imgHeight,
1077
1097
  });
1098
+ if (partMarkers) {
1099
+ image = React.cloneElement(image, part("logo"));
1100
+ }
1078
1101
  }
1079
1102
  }
1080
1103
 
@@ -1107,6 +1130,10 @@ export function QRCodeSVG(props: QRPropsSVG) {
1107
1130
  }),
1108
1131
  })
1109
1132
  : null;
1133
+ const markedArtLayer =
1134
+ artLayer && partMarkers
1135
+ ? React.cloneElement(artLayer, part("body"))
1136
+ : artLayer;
1110
1137
  const artEyes =
1111
1138
  artLayer && art
1112
1139
  ? getQRArtEyeColors({ art, version: qrCode.version, ...artColors })
@@ -1158,13 +1185,17 @@ export function QRCodeSVG(props: QRPropsSVG) {
1158
1185
  );
1159
1186
 
1160
1187
  // Data modules, plus a shaped code's decoration around them
1161
- const dataLayer = artLayer ? (
1188
+ const dataLayer = markedArtLayer ? (
1162
1189
  <>
1163
- {artLayer}
1164
- {decorationShapes && <g {...fgFillValue}>{decorationShapes}</g>}
1190
+ {markedArtLayer}
1191
+ {decorationShapes && (
1192
+ <g {...fgFillValue} {...part("body")}>
1193
+ {decorationShapes}
1194
+ </g>
1195
+ )}
1165
1196
  </>
1166
1197
  ) : (
1167
- <g {...fgFillValue}>
1198
+ <g {...fgFillValue} {...part("body")}>
1168
1199
  {dataCircles}
1169
1200
  {decorationShapes}
1170
1201
  </g>
@@ -1356,7 +1387,7 @@ export function QRCodeSVG(props: QRPropsSVG) {
1356
1387
  {dataLayer}
1357
1388
 
1358
1389
  {/* Top-left corner square */}
1359
- <g {...topLeftEyeFillValue}>
1390
+ <g {...topLeftEyeFillValue} {...part("eye-outer", "top-left")}>
1360
1391
  <path
1361
1392
  d={topLeftEye}
1362
1393
  fillRule="evenodd"
@@ -1365,10 +1396,12 @@ export function QRCodeSVG(props: QRPropsSVG) {
1365
1396
  </g>
1366
1397
 
1367
1398
  {/* Top-left corner dot */}
1368
- <g {...topLeftDotFillValue}>{topLeftDot}</g>
1399
+ <g {...topLeftDotFillValue} {...part("eye-centre", "top-left")}>
1400
+ {topLeftDot}
1401
+ </g>
1369
1402
 
1370
1403
  {/* Top-right corner square */}
1371
- <g {...topRightEyeFillValue}>
1404
+ <g {...topRightEyeFillValue} {...part("eye-outer", "top-right")}>
1372
1405
  <path
1373
1406
  d={topRightEye}
1374
1407
  fillRule="evenodd"
@@ -1377,10 +1410,12 @@ export function QRCodeSVG(props: QRPropsSVG) {
1377
1410
  </g>
1378
1411
 
1379
1412
  {/* Top-right corner dot */}
1380
- <g {...topRightDotFillValue}>{topRightDot}</g>
1413
+ <g {...topRightDotFillValue} {...part("eye-centre", "top-right")}>
1414
+ {topRightDot}
1415
+ </g>
1381
1416
 
1382
1417
  {/* Bottom-left corner square */}
1383
- <g {...bottomLeftEyeFillValue}>
1418
+ <g {...bottomLeftEyeFillValue} {...part("eye-outer", "bottom-left")}>
1384
1419
  <path
1385
1420
  d={bottomLeftEye}
1386
1421
  fillRule="evenodd"
@@ -1389,7 +1424,9 @@ export function QRCodeSVG(props: QRPropsSVG) {
1389
1424
  </g>
1390
1425
 
1391
1426
  {/* Bottom-left corner dot */}
1392
- <g {...bottomLeftDotFillValue}>{bottomLeftDot}</g>
1427
+ <g {...bottomLeftDotFillValue} {...part("eye-centre", "bottom-left")}>
1428
+ {bottomLeftDot}
1429
+ </g>
1393
1430
 
1394
1431
  {image}
1395
1432
  </>
@@ -1449,7 +1486,7 @@ export function QRCodeSVG(props: QRPropsSVG) {
1449
1486
  {dataLayer}
1450
1487
 
1451
1488
  {/* Top-left corner square */}
1452
- <g {...topLeftEyeFillValue}>
1489
+ <g {...topLeftEyeFillValue} {...part("eye-outer", "top-left")}>
1453
1490
  <path
1454
1491
  d={topLeftEye}
1455
1492
  fillRule="evenodd"
@@ -1458,10 +1495,12 @@ export function QRCodeSVG(props: QRPropsSVG) {
1458
1495
  </g>
1459
1496
 
1460
1497
  {/* Top-left corner dot */}
1461
- <g {...topLeftDotFillValue}>{topLeftDot}</g>
1498
+ <g {...topLeftDotFillValue} {...part("eye-centre", "top-left")}>
1499
+ {topLeftDot}
1500
+ </g>
1462
1501
 
1463
1502
  {/* Top-right corner square */}
1464
- <g {...topRightEyeFillValue}>
1503
+ <g {...topRightEyeFillValue} {...part("eye-outer", "top-right")}>
1465
1504
  <path
1466
1505
  d={topRightEye}
1467
1506
  fillRule="evenodd"
@@ -1470,10 +1509,12 @@ export function QRCodeSVG(props: QRPropsSVG) {
1470
1509
  </g>
1471
1510
 
1472
1511
  {/* Top-right corner dot */}
1473
- <g {...topRightDotFillValue}>{topRightDot}</g>
1512
+ <g {...topRightDotFillValue} {...part("eye-centre", "top-right")}>
1513
+ {topRightDot}
1514
+ </g>
1474
1515
 
1475
1516
  {/* Bottom-left corner square */}
1476
- <g {...bottomLeftEyeFillValue}>
1517
+ <g {...bottomLeftEyeFillValue} {...part("eye-outer", "bottom-left")}>
1477
1518
  <path
1478
1519
  d={bottomLeftEye}
1479
1520
  fillRule="evenodd"
@@ -1482,7 +1523,9 @@ export function QRCodeSVG(props: QRPropsSVG) {
1482
1523
  </g>
1483
1524
 
1484
1525
  {/* Bottom-left corner dot */}
1485
- <g {...bottomLeftDotFillValue}>{bottomLeftDot}</g>
1526
+ <g {...bottomLeftDotFillValue} {...part("eye-centre", "bottom-left")}>
1527
+ {bottomLeftDot}
1528
+ </g>
1486
1529
 
1487
1530
  {image}
1488
1531
  </g>
package/types/qr.ts CHANGED
@@ -242,6 +242,11 @@ export interface QRProps {
242
242
  // export (getQRAsSVGDataUri and the PNG, JPG, PDF and EPS built on it)
243
243
  // drops it, so downloads never carry the marker.
244
244
  frameLabelMarkers?: boolean;
245
+ // For editors drawing a live preview: marks the drawn parts with
246
+ // data-qrdx-part ("eye-outer" and "eye-centre", each with data-qrdx-eye,
247
+ // "body", "logo", "background"; see QR_PART_ATTRIBUTE). Off by default,
248
+ // and every export drops it, like frameLabelMarkers.
249
+ partMarkers?: boolean;
245
250
  }
246
251
 
247
252
  export type QRPropsCanvas = QRProps &