qrdx 0.0.49 → 0.0.51

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 (534) hide show
  1. package/README.md +123 -3
  2. package/dist/core.js +31 -0
  3. package/dist/core.js.map +1 -0
  4. package/dist/core.mjs +31 -0
  5. package/dist/core.mjs.map +1 -0
  6. package/dist/frames-index.js +1 -1
  7. package/dist/frames-index.js.map +1 -1
  8. package/dist/frames-index.mjs +1 -1
  9. package/dist/frames-index.mjs.map +1 -1
  10. package/dist/frames-official.js +1 -1
  11. package/dist/frames-official.js.map +1 -1
  12. package/dist/frames-official.mjs +1 -1
  13. package/dist/frames-official.mjs.map +1 -1
  14. package/dist/index.js +7 -7
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +7 -7
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/node.js +3 -0
  19. package/dist/node.js.map +1 -0
  20. package/dist/node.mjs +3 -0
  21. package/dist/node.mjs.map +1 -0
  22. package/dist/qr-code-canvas.js +1 -1
  23. package/dist/qr-code-canvas.js.map +1 -1
  24. package/dist/qr-code-canvas.mjs +1 -1
  25. package/dist/qr-code-canvas.mjs.map +1 -1
  26. package/dist/src/api.d.ts +8 -2
  27. package/dist/src/api.d.ts.map +1 -1
  28. package/dist/src/art.d.ts +4 -3
  29. package/dist/src/art.d.ts.map +1 -1
  30. package/dist/src/body-patterns.d.ts +3 -2
  31. package/dist/src/body-patterns.d.ts.map +1 -1
  32. package/dist/src/core.d.ts +5 -0
  33. package/dist/src/core.d.ts.map +1 -0
  34. package/dist/src/corner-dot.d.ts +3 -2
  35. package/dist/src/corner-dot.d.ts.map +1 -1
  36. package/dist/src/engine.d.ts +44 -0
  37. package/dist/src/engine.d.ts.map +1 -0
  38. package/dist/src/export.d.ts +5 -0
  39. package/dist/src/export.d.ts.map +1 -0
  40. package/dist/src/frame.d.ts +6 -4
  41. package/dist/src/frame.d.ts.map +1 -1
  42. package/dist/src/frames/catalogue/all.d.ts.map +1 -1
  43. package/dist/src/frames/catalogue/automotive.d.ts +5 -0
  44. package/dist/src/frames/catalogue/automotive.d.ts.map +1 -0
  45. package/dist/src/frames/catalogue/beauty-wellness.d.ts +5 -0
  46. package/dist/src/frames/catalogue/beauty-wellness.d.ts.map +1 -0
  47. package/dist/src/frames/catalogue/business.d.ts.map +1 -1
  48. package/dist/src/frames/catalogue/call-to-action.d.ts.map +1 -1
  49. package/dist/src/frames/catalogue/counts.d.ts +12 -7
  50. package/dist/src/frames/catalogue/counts.d.ts.map +1 -1
  51. package/dist/src/frames/catalogue/food-drink.d.ts.map +1 -1
  52. package/dist/src/frames/catalogue/health-learning.d.ts.map +1 -1
  53. package/dist/src/frames/catalogue/index.d.ts.map +1 -1
  54. package/dist/src/frames/catalogue/nonprofit.d.ts +5 -0
  55. package/dist/src/frames/catalogue/nonprofit.d.ts.map +1 -0
  56. package/dist/src/frames/catalogue/places.d.ts.map +1 -1
  57. package/dist/src/frames/catalogue/real-estate.d.ts +5 -0
  58. package/dist/src/frames/catalogue/real-estate.d.ts.map +1 -0
  59. package/dist/src/frames/catalogue/shopping.d.ts.map +1 -1
  60. package/dist/src/frames/catalogue/sports-fitness.d.ts +5 -0
  61. package/dist/src/frames/catalogue/sports-fitness.d.ts.map +1 -0
  62. package/dist/src/frames/catalogue/tags.d.ts.map +1 -1
  63. package/dist/src/frames/collections.d.ts.map +1 -1
  64. package/dist/src/frames/official-types.d.ts +1 -1
  65. package/dist/src/frames/official-types.d.ts.map +1 -1
  66. package/dist/src/index.d.ts +3 -37
  67. package/dist/src/index.d.ts.map +1 -1
  68. package/dist/src/jsx/index.d.ts +2 -0
  69. package/dist/src/jsx/index.d.ts.map +1 -0
  70. package/dist/src/jsx/jsx-dev-runtime.d.ts +5 -0
  71. package/dist/src/jsx/jsx-dev-runtime.d.ts.map +1 -0
  72. package/dist/src/jsx/jsx-runtime.d.ts +30 -0
  73. package/dist/src/jsx/jsx-runtime.d.ts.map +1 -0
  74. package/dist/src/jsx/runtime.d.ts +73 -0
  75. package/dist/src/jsx/runtime.d.ts.map +1 -0
  76. package/dist/src/logo.d.ts +3 -2
  77. package/dist/src/logo.d.ts.map +1 -1
  78. package/dist/src/node.d.ts +23 -0
  79. package/dist/src/node.d.ts.map +1 -0
  80. package/dist/src/part-markers.d.ts +15 -0
  81. package/dist/src/part-markers.d.ts.map +1 -0
  82. package/dist/src/plain.d.ts +31 -0
  83. package/dist/src/plain.d.ts.map +1 -0
  84. package/dist/src/qr-code-canvas.d.ts +1 -1
  85. package/dist/src/qr-code-canvas.d.ts.map +1 -1
  86. package/dist/src/qr-code-props.d.ts +22 -0
  87. package/dist/src/qr-code-props.d.ts.map +1 -0
  88. package/dist/src/qr-code-svg.d.ts +10 -0
  89. package/dist/src/qr-code-svg.d.ts.map +1 -0
  90. package/dist/src/qr-code.d.ts +2 -10
  91. package/dist/src/qr-code.d.ts.map +1 -1
  92. package/dist/src/rasterize.d.ts +25 -0
  93. package/dist/src/rasterize.d.ts.map +1 -0
  94. package/dist/src/react-elements.d.ts +3 -0
  95. package/dist/src/react-elements.d.ts.map +1 -0
  96. package/dist/src/render/attributes.d.ts +33 -0
  97. package/dist/src/render/attributes.d.ts.map +1 -0
  98. package/dist/src/render/dom.d.ts +8 -0
  99. package/dist/src/render/dom.d.ts.map +1 -0
  100. package/dist/src/render/hyperscript.d.ts +10 -0
  101. package/dist/src/render/hyperscript.d.ts.map +1 -0
  102. package/dist/src/render/string.d.ts +8 -0
  103. package/dist/src/render/string.d.ts.map +1 -0
  104. package/dist/src/svg.d.ts +14 -0
  105. package/dist/src/svg.d.ts.map +1 -0
  106. package/dist/src/template/arrow.d.ts +1 -0
  107. package/dist/src/template/arrow.d.ts.map +1 -1
  108. package/dist/src/template/default.d.ts +1 -0
  109. package/dist/src/template/default.d.ts.map +1 -1
  110. package/dist/src/template/halloween.d.ts +1 -0
  111. package/dist/src/template/halloween.d.ts.map +1 -1
  112. package/dist/src/template/square-border.d.ts +1 -0
  113. package/dist/src/template/square-border.d.ts.map +1 -1
  114. package/dist/src/template/standard-box.d.ts +1 -0
  115. package/dist/src/template/standard-box.d.ts.map +1 -1
  116. package/dist/src/template/striked-box.d.ts +1 -0
  117. package/dist/src/template/striked-box.d.ts.map +1 -1
  118. package/dist/src/utils.d.ts +9 -3
  119. package/dist/src/utils.d.ts.map +1 -1
  120. package/dist/src/vanilla-api.d.ts +47 -0
  121. package/dist/src/vanilla-api.d.ts.map +1 -0
  122. package/dist/src/vanilla-browser.d.ts +4 -0
  123. package/dist/src/vanilla-browser.d.ts.map +1 -0
  124. package/dist/src/vanilla.d.ts +4 -0
  125. package/dist/src/vanilla.d.ts.map +1 -0
  126. package/dist/src/vue.d.ts +56 -0
  127. package/dist/src/vue.d.ts.map +1 -0
  128. package/dist/types/index.d.ts +2 -2
  129. package/dist/types/index.d.ts.map +1 -1
  130. package/dist/types/index.js +2 -2
  131. package/dist/types/index.mjs +2 -2
  132. package/dist/types/public.d.ts +3 -0
  133. package/dist/types/public.d.ts.map +1 -0
  134. package/dist/types/qr.d.ts +18 -4
  135. package/dist/types/qr.d.ts.map +1 -1
  136. package/dist/types/react.d.ts +5 -0
  137. package/dist/types/react.d.ts.map +1 -0
  138. package/dist/types/template.d.ts +7 -1
  139. package/dist/types/template.d.ts.map +1 -1
  140. package/dist/vanilla.browser.mjs +92 -0
  141. package/dist/vanilla.browser.mjs.map +1 -0
  142. package/dist/vanilla.js +2 -0
  143. package/dist/vanilla.js.map +1 -0
  144. package/dist/vanilla.mjs +2 -0
  145. package/dist/vanilla.mjs.map +1 -0
  146. package/dist/vue.js +2 -0
  147. package/dist/vue.js.map +1 -0
  148. package/dist/vue.mjs +2 -0
  149. package/dist/vue.mjs.map +1 -0
  150. package/package.json +71 -6
  151. package/src/api.tsx +16 -139
  152. package/src/art.tsx +18 -16
  153. package/src/body-patterns.tsx +5 -3
  154. package/src/core.ts +13 -0
  155. package/src/corner-dot.tsx +4 -2
  156. package/src/download.tsx +1 -1
  157. package/src/engine.ts +170 -0
  158. package/src/export.ts +212 -0
  159. package/src/frame.tsx +7 -6
  160. package/src/frames/catalogue/all.ts +606 -0
  161. package/src/frames/catalogue/automotive.ts +61 -0
  162. package/src/frames/catalogue/beauty-wellness.ts +61 -0
  163. package/src/frames/catalogue/business.ts +68 -0
  164. package/src/frames/catalogue/call-to-action.ts +60 -0
  165. package/src/frames/catalogue/counts.ts +12 -7
  166. package/src/frames/catalogue/food-drink.ts +78 -0
  167. package/src/frames/catalogue/health-learning.ts +62 -14
  168. package/src/frames/catalogue/index.ts +2440 -16
  169. package/src/frames/catalogue/nonprofit.ts +65 -0
  170. package/src/frames/catalogue/places.ts +0 -18
  171. package/src/frames/catalogue/real-estate.ts +79 -0
  172. package/src/frames/catalogue/shopping.ts +68 -0
  173. package/src/frames/catalogue/sports-fitness.ts +81 -0
  174. package/src/frames/catalogue/tags.ts +354 -0
  175. package/src/frames/collections.ts +5 -0
  176. package/src/frames/official/add-engraving.json +90 -0
  177. package/src/frames/official/add-to-calendar.json +98 -0
  178. package/src/frames/official/adopt-me.json +72 -0
  179. package/src/frames/official/aftercare-guide.json +98 -0
  180. package/src/frames/official/alterations.json +142 -0
  181. package/src/frames/official/annual-report.json +85 -0
  182. package/src/frames/official/archery-lesson.json +106 -0
  183. package/src/frames/official/arrival-guide.json +71 -0
  184. package/src/frames/official/art-class.json +137 -0
  185. package/src/frames/official/ask-a-stylist.json +112 -0
  186. package/src/frames/official/assembly-guide.json +93 -0
  187. package/src/frames/official/badminton-session.json +104 -0
  188. package/src/frames/official/bake-sale.json +158 -0
  189. package/src/frames/official/bakery-board.json +80 -0
  190. package/src/frames/official/barber-booking.json +64 -0
  191. package/src/frames/official/bath-ritual.json +70 -0
  192. package/src/frames/official/bathroom-showroom.json +113 -0
  193. package/src/frames/official/battery-check.json +95 -0
  194. package/src/frames/official/beauty-rewards.json +81 -0
  195. package/src/frames/official/become-a-member.json +79 -0
  196. package/src/frames/official/bike-service.json +113 -0
  197. package/src/frames/official/book-a-call.json +105 -0
  198. package/src/frames/official/book-a-cleaning.json +92 -0
  199. package/src/frames/official/book-a-consultation.json +101 -0
  200. package/src/frames/official/book-a-court.json +74 -0
  201. package/src/frames/official/book-a-facial.json +108 -0
  202. package/src/frames/official/book-a-massage.json +80 -0
  203. package/src/frames/official/book-a-vaccine.json +88 -0
  204. package/src/frames/official/book-this-room.json +80 -0
  205. package/src/frames/official/boxing-class.json +81 -0
  206. package/src/frames/official/brewery-tour.json +89 -0
  207. package/src/frames/official/bridal-beauty.json +80 -0
  208. package/src/frames/official/brunch-menu.json +79 -0
  209. package/src/frames/official/bubble-tea.json +81 -0
  210. package/src/frames/official/bulk-orders.json +108 -0
  211. package/src/frames/official/burger-order.json +80 -0
  212. package/src/frames/official/call-a-server.json +115 -0
  213. package/src/frames/official/car-detailing.json +102 -0
  214. package/src/frames/official/car-details.json +90 -0
  215. package/src/frames/official/car-for-sale.json +74 -0
  216. package/src/frames/official/car-service.json +92 -0
  217. package/src/frames/official/carpool.json +79 -0
  218. package/src/frames/official/catering-order.json +79 -0
  219. package/src/frames/official/charging-prices.json +105 -0
  220. package/src/frames/official/charity-shop.json +75 -0
  221. package/src/frames/official/check-symptoms.json +80 -0
  222. package/src/frames/official/cheese-pairing.json +91 -0
  223. package/src/frames/official/chess-club.json +64 -0
  224. package/src/frames/official/chess-lessons.json +83 -0
  225. package/src/frames/official/choose-your-plan.json +113 -0
  226. package/src/frames/official/choose-your-wash.json +86 -0
  227. package/src/frames/official/clean-beauty.json +94 -0
  228. package/src/frames/official/click-and-collect.json +85 -0
  229. package/src/frames/official/clock-in.json +101 -0
  230. package/src/frames/official/club-fees.json +94 -0
  231. package/src/frames/official/coach-sign-up.json +108 -0
  232. package/src/frames/official/community-notices.json +107 -0
  233. package/src/frames/official/compare-specs.json +112 -0
  234. package/src/frames/official/consultation-form.json +120 -0
  235. package/src/frames/official/continued-online.json +81 -0
  236. package/src/frames/official/cookie-box.json +88 -0
  237. package/src/frames/official/cooking-class.json +89 -0
  238. package/src/frames/official/coworking-pass.json +89 -0
  239. package/src/frames/official/cricket-club.json +158 -0
  240. package/src/frames/official/cupcake-order.json +108 -0
  241. package/src/frames/official/damage-report.json +114 -0
  242. package/src/frames/official/dashboard-lights.json +106 -0
  243. package/src/frames/official/delivery-instructions.json +98 -0
  244. package/src/frames/official/diy-how-to.json +87 -0
  245. package/src/frames/official/donate-coats.json +74 -0
  246. package/src/frames/official/donate-food.json +80 -0
  247. package/src/frames/official/donation-jar.json +101 -0
  248. package/src/frames/official/donut-shop.json +94 -0
  249. package/src/frames/official/dress-fitting.json +64 -0
  250. package/src/frames/official/driving-lessons.json +110 -0
  251. package/src/frames/official/dumpling-house.json +82 -0
  252. package/src/frames/official/eye-exam.json +70 -0
  253. package/src/frames/official/eyewear-try-on.json +99 -0
  254. package/src/frames/official/fan-club.json +152 -0
  255. package/src/frames/official/farm-stand.json +109 -0
  256. package/src/frames/official/farmers-market.json +74 -0
  257. package/src/frames/official/find-a-charger.json +107 -0
  258. package/src/frames/official/find-a-doctor.json +85 -0
  259. package/src/frames/official/find-it-in-store.json +101 -0
  260. package/src/frames/official/find-our-office.json +80 -0
  261. package/src/frames/official/first-aid-guide.json +109 -0
  262. package/src/frames/official/fish-market.json +113 -0
  263. package/src/frames/official/fitness-challenge.json +1 -1
  264. package/src/frames/official/fitness-equipment.json +1 -1
  265. package/src/frames/official/fitness-kettlebell.json +1 -1
  266. package/src/frames/official/fitness-schedule.json +1 -1
  267. package/src/frames/official/fitness-test.json +94 -0
  268. package/src/frames/official/fitness-timer.json +1 -1
  269. package/src/frames/official/fitness-trial.json +1 -1
  270. package/src/frames/official/fitness-yoga.json +1 -1
  271. package/src/frames/official/food-support.json +102 -0
  272. package/src/frames/official/food-truck-location.json +80 -0
  273. package/src/frames/official/furnished-rental.json +101 -0
  274. package/src/frames/official/game-night.json +79 -0
  275. package/src/frames/official/garden-design.json +70 -0
  276. package/src/frames/official/garden-plot.json +74 -0
  277. package/src/frames/official/get-a-quote.json +113 -0
  278. package/src/frames/official/get-it-delivered.json +82 -0
  279. package/src/frames/official/get-started-rocket.json +80 -0
  280. package/src/frames/official/get-the-brochure.json +116 -0
  281. package/src/frames/official/gift-ideas.json +86 -0
  282. package/src/frames/official/gift-message.json +85 -0
  283. package/src/frames/official/give-blood.json +88 -0
  284. package/src/frames/official/giving-jar.json +89 -0
  285. package/src/frames/official/golf-scorecard.json +120 -0
  286. package/src/frames/official/grand-opening.json +158 -0
  287. package/src/frames/official/grill-menu.json +92 -0
  288. package/src/frames/official/hand-washing.json +106 -0
  289. package/src/frames/official/handyman.json +130 -0
  290. package/src/frames/official/hear-it-spoken.json +86 -0
  291. package/src/frames/official/home-valuation.json +87 -0
  292. package/src/frames/official/homework-help.json +79 -0
  293. package/src/frames/official/hot-shave.json +121 -0
  294. package/src/frames/official/house-rules.json +121 -0
  295. package/src/frames/official/how-it-works.json +98 -0
  296. package/src/frames/official/how-to-apply.json +93 -0
  297. package/src/frames/official/impact-report.json +90 -0
  298. package/src/frames/official/intake-forms.json +114 -0
  299. package/src/frames/official/join-a-league.json +94 -0
  300. package/src/frames/official/join-the-cleanup.json +110 -0
  301. package/src/frames/official/join-the-waitlist.json +102 -0
  302. package/src/frames/official/join-the-webinar.json +108 -0
  303. package/src/frames/official/juice-bar.json +70 -0
  304. package/src/frames/official/kids-haircuts.json +75 -0
  305. package/src/frames/official/kids-menu.json +107 -0
  306. package/src/frames/official/large-print.json +80 -0
  307. package/src/frames/official/lash-bar.json +86 -0
  308. package/src/frames/official/last-chance.json +94 -0
  309. package/src/frames/official/late-night-menu.json +77 -0
  310. package/src/frames/official/learn-the-signs.json +107 -0
  311. package/src/frames/official/library-card.json +90 -0
  312. package/src/frames/official/live-scores.json +101 -0
  313. package/src/frames/official/lost-and-found.json +85 -0
  314. package/src/frames/official/lost-pet-tag.json +84 -0
  315. package/src/frames/official/make-a-claim.json +74 -0
  316. package/src/frames/official/makeup-artist.json +94 -0
  317. package/src/frames/official/math-practice.json +136 -0
  318. package/src/frames/official/meal-plan.json +121 -0
  319. package/src/frames/official/meet-the-maker.json +91 -0
  320. package/src/frames/official/meet-the-team.json +82 -0
  321. package/src/frames/official/membership-card.json +108 -0
  322. package/src/frames/official/mortgage-calculator.json +94 -0
  323. package/src/frames/official/moving-checklist.json +108 -0
  324. package/src/frames/official/music-lessons.json +64 -0
  325. package/src/frames/official/nail-studio.json +70 -0
  326. package/src/frames/official/neighborhood-guide.json +98 -0
  327. package/src/frames/official/nutrition-facts.json +98 -0
  328. package/src/frames/official/online-class.json +82 -0
  329. package/src/frames/official/open-an-account.json +88 -0
  330. package/src/frames/official/open-house-sign-in.json +104 -0
  331. package/src/frames/official/parcel-room.json +98 -0
  332. package/src/frames/official/parent-meeting.json +108 -0
  333. package/src/frames/official/parking-permit.json +74 -0
  334. package/src/frames/official/pay-at-the-pump.json +108 -0
  335. package/src/frames/official/pay-for-parking.json +89 -0
  336. package/src/frames/official/pay-it-forward.json +102 -0
  337. package/src/frames/official/pay-your-rent.json +105 -0
  338. package/src/frames/official/permission-form.json +120 -0
  339. package/src/frames/official/personal-trainer.json +76 -0
  340. package/src/frames/official/physio-exercises.json +86 -0
  341. package/src/frames/official/pick-your-own.json +158 -0
  342. package/src/frames/official/plant-a-tree.json +88 -0
  343. package/src/frames/official/plant-based-menu.json +103 -0
  344. package/src/frames/official/plant-care.json +84 -0
  345. package/src/frames/official/podcast.json +107 -0
  346. package/src/frames/official/polling-place.json +109 -0
  347. package/src/frames/official/pool-timetable.json +113 -0
  348. package/src/frames/official/portfolio-card.json +110 -0
  349. package/src/frames/official/pre-order-bread.json +110 -0
  350. package/src/frames/official/press-kit.json +136 -0
  351. package/src/frames/official/price-list.json +111 -0
  352. package/src/frames/official/privacy-notice.json +115 -0
  353. package/src/frames/official/property-floor-plan.json +1 -1
  354. package/src/frames/official/property-for-sale.json +1 -1
  355. package/src/frames/official/property-house-light.json +1 -1
  356. package/src/frames/official/property-house.json +1 -1
  357. package/src/frames/official/property-key.json +1 -1
  358. package/src/frames/official/property-open-house.json +1 -1
  359. package/src/frames/official/property-rent.json +1 -1
  360. package/src/frames/official/property-virtual-tour.json +1 -1
  361. package/src/frames/official/questions-cloud.json +65 -0
  362. package/src/frames/official/race-entry.json +90 -0
  363. package/src/frames/official/race-photos.json +93 -0
  364. package/src/frames/official/rate-your-ride.json +103 -0
  365. package/src/frames/official/read-a-sample.json +108 -0
  366. package/src/frames/official/read-the-ebook.json +116 -0
  367. package/src/frames/official/read-the-faq.json +88 -0
  368. package/src/frames/official/read-the-reviews.json +110 -0
  369. package/src/frames/official/read-the-story.json +90 -0
  370. package/src/frames/official/read-the-transcript.json +142 -0
  371. package/src/frames/official/reading-challenge.json +97 -0
  372. package/src/frames/official/rebook-visit.json +86 -0
  373. package/src/frames/official/recipe-card.json +120 -0
  374. package/src/frames/official/refill-reminder.json +104 -0
  375. package/src/frames/official/register-interest.json +82 -0
  376. package/src/frames/official/register-to-vote.json +80 -0
  377. package/src/frames/official/renovation-quote.json +80 -0
  378. package/src/frames/official/rent-a-bike.json +95 -0
  379. package/src/frames/official/rent-this-item.json +95 -0
  380. package/src/frames/official/rental-car-guide.json +115 -0
  381. package/src/frames/official/report-a-problem.json +114 -0
  382. package/src/frames/official/report-a-repair.json +79 -0
  383. package/src/frames/official/report-a-street-issue.json +113 -0
  384. package/src/frames/official/request-maintenance.json +74 -0
  385. package/src/frames/official/resident-portal.json +98 -0
  386. package/src/frames/official/restaurant-gift-card.json +94 -0
  387. package/src/frames/official/restock-alert.json +98 -0
  388. package/src/frames/official/restroom-feedback.json +86 -0
  389. package/src/frames/official/return-your-cup.json +130 -0
  390. package/src/frames/official/return-your-rental.json +113 -0
  391. package/src/frames/official/ring-size.json +107 -0
  392. package/src/frames/official/roadside-help.json +92 -0
  393. package/src/frames/official/run-club.json +79 -0
  394. package/src/frames/official/safety-information.json +92 -0
  395. package/src/frames/official/salon-prices.json +92 -0
  396. package/src/frames/official/save-for-later.json +79 -0
  397. package/src/frames/official/scan-for-the-answer.json +86 -0
  398. package/src/frames/official/scan-for-the-checklist.json +108 -0
  399. package/src/frames/official/scan-for-the-latest.json +74 -0
  400. package/src/frames/official/scan-for-translations.json +108 -0
  401. package/src/frames/official/scan-here-arrow.json +76 -0
  402. package/src/frames/official/scan-here-post.json +89 -0
  403. package/src/frames/official/scan-me-banner.json +147 -0
  404. package/src/frames/official/scan-me-cloud.json +73 -0
  405. package/src/frames/official/scan-me-folded.json +74 -0
  406. package/src/frames/official/scan-me-stack.json +93 -0
  407. package/src/frames/official/scan-to-unlock.json +107 -0
  408. package/src/frames/official/scent-finder.json +94 -0
  409. package/src/frames/official/scholarships.json +108 -0
  410. package/src/frames/official/school-supply-list.json +80 -0
  411. package/src/frames/official/science-fair.json +89 -0
  412. package/src/frames/official/season-schedule.json +66 -0
  413. package/src/frames/official/see-more-stack.json +91 -0
  414. package/src/frames/official/see-our-pitch.json +85 -0
  415. package/src/frames/official/see-the-full-list.json +107 -0
  416. package/src/frames/official/see-the-map.json +79 -0
  417. package/src/frames/official/send-flowers.json +93 -0
  418. package/src/frames/official/service-times.json +115 -0
  419. package/src/frames/official/shade-finder.json +113 -0
  420. package/src/frames/official/shoe-size-check.json +95 -0
  421. package/src/frames/official/sign-rider.json +1 -1
  422. package/src/frames/official/sign-the-agreement.json +120 -0
  423. package/src/frames/official/sign-the-petition.json +120 -0
  424. package/src/frames/official/site-hoarding.json +158 -0
  425. package/src/frames/official/site-induction.json +120 -0
  426. package/src/frames/official/size-guide.json +80 -0
  427. package/src/frames/official/skate-park-rules.json +109 -0
  428. package/src/frames/official/skincare-routine.json +85 -0
  429. package/src/frames/official/sofa-fabric.json +84 -0
  430. package/src/frames/official/spa-gift.json +90 -0
  431. package/src/frames/official/spa-menu.json +124 -0
  432. package/src/frames/official/split-the-bill.json +77 -0
  433. package/src/frames/official/sponsor-a-pet.json +102 -0
  434. package/src/frames/official/sponsor-my-run.json +136 -0
  435. package/src/frames/official/sports-camp.json +142 -0
  436. package/src/frames/official/staff-handbook.json +121 -0
  437. package/src/frames/official/staff-rota.json +112 -0
  438. package/src/frames/official/start-a-return.json +92 -0
  439. package/src/frames/official/start-charging.json +104 -0
  440. package/src/frames/official/start-here-arrow.json +79 -0
  441. package/src/frames/official/start-saving.json +74 -0
  442. package/src/frames/official/storage-units.json +79 -0
  443. package/src/frames/official/student-portal.json +80 -0
  444. package/src/frames/official/style-gallery.json +111 -0
  445. package/src/frames/official/sushi-menu.json +115 -0
  446. package/src/frames/official/swim-lessons.json +70 -0
  447. package/src/frames/official/table-tennis.json +116 -0
  448. package/src/frames/official/take-a-closer-look.json +94 -0
  449. package/src/frames/official/takeout-order.json +98 -0
  450. package/src/frames/official/talk-to-someone.json +115 -0
  451. package/src/frames/official/talk-to-the-agent.json +115 -0
  452. package/src/frames/official/tea-menu.json +70 -0
  453. package/src/frames/official/tea-time.json +124 -0
  454. package/src/frames/official/team-jersey.json +77 -0
  455. package/src/frames/official/team-kit.json +85 -0
  456. package/src/frames/official/tee-time.json +85 -0
  457. package/src/frames/official/tennis-court.json +94 -0
  458. package/src/frames/official/test-drive.json +88 -0
  459. package/src/frames/official/test-results.json +85 -0
  460. package/src/frames/official/tire-change.json +74 -0
  461. package/src/frames/official/town-hall.json +158 -0
  462. package/src/frames/official/toy-finder.json +81 -0
  463. package/src/frames/official/trace-your-coffee.json +87 -0
  464. package/src/frames/official/trade-it-in.json +97 -0
  465. package/src/frames/official/try-the-demo.json +106 -0
  466. package/src/frames/official/unlock-this-car.json +82 -0
  467. package/src/frames/official/upload-receipts.json +108 -0
  468. package/src/frames/official/validate-parking.json +91 -0
  469. package/src/frames/official/vehicle-history.json +106 -0
  470. package/src/frames/official/virtual-try-on.json +93 -0
  471. package/src/frames/official/visiting-hours.json +90 -0
  472. package/src/frames/official/visitor-map.json +92 -0
  473. package/src/frames/official/visitor-sign-in.json +98 -0
  474. package/src/frames/official/volunteer.json +74 -0
  475. package/src/frames/official/vote-for-us.json +103 -0
  476. package/src/frames/official/walk-in-queue.json +102 -0
  477. package/src/frames/official/wash-club.json +81 -0
  478. package/src/frames/official/watch-repair.json +115 -0
  479. package/src/frames/official/watch-the-experiment.json +93 -0
  480. package/src/frames/official/water-refill.json +95 -0
  481. package/src/frames/official/weekly-deals.json +107 -0
  482. package/src/frames/official/wellness-retreat.json +85 -0
  483. package/src/frames/official/whats-inside.json +91 -0
  484. package/src/frames/official/wholesale.json +85 -0
  485. package/src/frames/official/window-quote.json +121 -0
  486. package/src/frames/official/wine-pairings.json +142 -0
  487. package/src/frames/official/wine-staff-pick.json +100 -0
  488. package/src/frames/official/winery-tasting.json +94 -0
  489. package/src/frames/official/yard-sign-coming-soon.json +115 -0
  490. package/src/frames/official/yard-sign-for-sale.json +150 -0
  491. package/src/frames/official/yard-sign-sold.json +162 -0
  492. package/src/frames/official/yard-sign-viewing.json +121 -0
  493. package/src/frames/official/your-prescription.json +107 -0
  494. package/src/frames/official/youth-club.json +104 -0
  495. package/src/frames/official-types.ts +6 -1
  496. package/src/frames/official.ts +4 -4
  497. package/src/index.tsx +6 -352
  498. package/src/jsx/index.ts +3 -0
  499. package/src/jsx/jsx-dev-runtime.ts +14 -0
  500. package/src/jsx/jsx-runtime.ts +34 -0
  501. package/src/jsx/runtime.ts +209 -0
  502. package/src/logo.tsx +5 -3
  503. package/src/node.ts +61 -0
  504. package/src/part-markers.ts +40 -0
  505. package/src/plain.tsx +194 -0
  506. package/src/qr-code-canvas.tsx +2 -1
  507. package/src/qr-code-props.ts +115 -0
  508. package/src/qr-code-svg.tsx +17 -0
  509. package/src/qr-code.tsx +34 -112
  510. package/src/rasterize.ts +282 -0
  511. package/src/react-elements.ts +13 -0
  512. package/src/render/attributes.ts +404 -0
  513. package/src/render/dom.ts +90 -0
  514. package/src/render/hyperscript.ts +66 -0
  515. package/src/render/string.ts +70 -0
  516. package/src/scan-score.ts +1 -1
  517. package/src/svg.ts +27 -0
  518. package/src/template/arrow.tsx +1 -0
  519. package/src/template/default.tsx +1 -0
  520. package/src/template/halloween.tsx +1 -0
  521. package/src/template/square-border.tsx +1 -0
  522. package/src/template/standard-box.tsx +1 -0
  523. package/src/template/striked-box.tsx +1 -0
  524. package/src/utils/print-shared.ts +1 -1
  525. package/src/utils.tsx +82 -38
  526. package/src/vanilla-api.ts +146 -0
  527. package/src/vanilla-browser.ts +11 -0
  528. package/src/vanilla.ts +10 -0
  529. package/src/vue.ts +220 -0
  530. package/types/index.ts +4 -2
  531. package/types/public.ts +4 -0
  532. package/types/qr.ts +24 -5
  533. package/types/react.ts +8 -0
  534. package/types/template.ts +10 -3
package/src/index.tsx CHANGED
@@ -1,360 +1,14 @@
1
1
  /** biome-ignore-all lint/performance/noBarrelFile: false positive */
2
- /** biome-ignore-all lint/style/noMagicNumbers: false positive */
2
+ // The main entry: the React components plus everything in qrdx/core (the
3
+ // React-free engine they draw with). The components build React elements
4
+ // through the same renderer as the core, so their markup is the core's.
3
5
 
4
- import type { QRProps } from "../types";
5
- import { DEFAULT_SIZE } from "./constants";
6
- import { getFrameDimensions } from "./frame";
7
- import { blobToDataUrl, canvasToWebP } from "./webp";
8
-
9
- export * from "../types";
6
+ export type { QRPropsCanvas, QRPropsSVG } from "../types/react";
10
7
  export * from "./api";
11
- export {
12
- createQRArtImage,
13
- DEFAULT_ART_INTENSITY,
14
- getQRArtColorIssue,
15
- getQRArtEyeColors,
16
- getQRArtVariant,
17
- getQRFunctionModules,
18
- isQRArtActive,
19
- loadQRArtImage,
20
- QR_ART_MIN_LUMA_GAP,
21
- QR_ART_SAMPLE_SIZES,
22
- type QRArtColorIssue,
23
- type QRArtEyeColorOptions,
24
- type QRArtPixels,
25
- type QRArtRenderOptions,
26
- renderQRArt,
27
- } from "./art";
28
- export { clampModuleScale, MODULE_SCALE_FLOOR } from "./body-patterns";
29
- export * from "./detection";
30
- export * from "./download";
31
- export {
32
- downloadPrintEPS,
33
- EPS_IMAGE_FILL_REASON,
34
- type EPSOptions,
35
- epsToDataUrl,
36
- getQRAsEPS,
37
- hasImageFill,
38
- type SVGToEPSOptions,
39
- svgToEPS,
40
- } from "./eps";
41
- export {
42
- FRAME_FONT_FAMILY,
43
- FRAME_GAP_RATIO,
44
- FRAME_LABEL_ATTRIBUTE,
45
- type FrameBox,
46
- type FrameLabel,
47
- type FrameLayout,
48
- type FramePath,
49
- type FramePolygon,
50
- type FrameRect,
51
- type FrameShape,
52
- frameLabels,
53
- getFrameDimensions,
54
- getFrameGapRatio,
55
- getFrameLayout,
56
- getFrameSecondaryText,
57
- getFrameText,
58
- isFrameActive,
59
- } from "./frame";
60
- export {
61
- FRAME_ICON_BOX,
62
- type FrameIconPath,
63
- getFrameIconPath,
64
- } from "./frame-icons";
65
- export {
66
- FRAME_IMPORT_LIMITS,
67
- type FrameImportColor,
68
- type FrameImportOptions,
69
- type FrameImportResult,
70
- type FrameImportWarning,
71
- importFrameSvg,
72
- } from "./frame-import";
73
- export {
74
- FrameSpecError,
75
- getCustomFrameLayout,
76
- getFrameSpecGapRatio,
77
- resolveFrameSpec,
78
- } from "./frame-spec";
79
- export { GRADIENT_FRAME_DEFAULTS, mixFrameColors } from "./frame-styles";
80
- export { BUILT_IN_FRAME_SPECS } from "./frames/builtin";
81
- export {
82
- OFFICIAL_FRAME_COUNT,
83
- OFFICIAL_FRAME_COUNTS,
84
- } from "./frames/catalogue/counts";
85
- // The frame library's data is built as modules of its own and only
86
- // re-exported here (tsup.config.ts), so bundlers skip what an app never uses.
87
- export { OFFICIAL_FRAME_INDEX } from "./frames/catalogue/index";
88
- export { OFFICIAL_FRAME_COLLECTIONS } from "./frames/collections";
89
- export { getOfficialFrame, OFFICIAL_FRAMES } from "./frames/official";
90
- export type {
91
- OfficialFrame,
92
- OfficialFrameCollection,
93
- OfficialFrameIndexEntry,
94
- } from "./frames/official-types";
95
- export { frameSpecHash } from "./frames/spec-hash";
96
- export {
97
- LOGO_PLATE_INSET,
98
- LOGO_ROUNDED_RADIUS,
99
- } from "./logo";
100
- export {
101
- LOGO_CLEANUP_MAX_SIDE,
102
- type LogoPixels,
103
- removeLogoBackdrop,
104
- removeLogoBackground,
105
- } from "./logo-cleanup";
106
- export * from "./print";
8
+ export * from "./core";
107
9
  export * from "./qr-code";
108
10
  // QRCodeCanvas is the only export that needs client-only hooks. It lives in
109
11
  // its own "use client" module (built as a separate entry) so the rest of the
110
12
  // package stays usable from React Server Components.
111
13
  export { QRCodeCanvas } from "./qr-code-canvas";
112
- export {
113
- circleQuietZone,
114
- getLayoutMargin,
115
- getQRShapePath,
116
- getQRSilhouetteFit,
117
- isShapedCode,
118
- type QRSilhouetteFit,
119
- } from "./qr-shape";
120
- export {
121
- getStylePairRisk,
122
- isWeakSharpPair,
123
- SHARP_DOT_EYE_SAFE_BODIES,
124
- type StylePairRisk,
125
- WEAK_BODY_EYES,
126
- WEAK_DOT_EYES,
127
- WEAK_DOTS,
128
- WEAK_EYES,
129
- WEAK_SHARP_DOT_EYES,
130
- } from "./scan-risk";
131
- export * from "./scan-score";
132
- export {
133
- createQRSilhouette,
134
- loadQRSilhouette,
135
- } from "./silhouette";
136
- export * from "./templates";
137
- export * from "./utils";
138
- /** Reads an 8-bit PNG into RGBA pixels (no DOM or sharp), or null. */
139
- export { type DecodedImage, decodePng as decodePNGPixels } from "./utils/png";
140
- export * from "./webp";
141
-
142
- export async function getQRAsSVGDataUri(props: QRProps) {
143
- // Import QRCodeSVG and render it to string
144
- const { QRCodeSVG } = await import("./utils");
145
- const { renderToStaticMarkup } = await import("react-dom/server");
146
- const React = await import("react");
147
-
148
- // If there's an image in imageSettings, convert it to base64 first
149
- let updatedProps = { ...props };
150
- if (props.imageSettings?.src) {
151
- try {
152
- const base64Image = (await getBase64Image(
153
- props.imageSettings.src
154
- )) as string;
155
- updatedProps = {
156
- ...props,
157
- imageSettings: {
158
- ...props.imageSettings,
159
- src: base64Image,
160
- },
161
- };
162
- } catch {
163
- // Remove the image from settings if it fails to load
164
- // This prevents SVG from containing external URLs that will fail during canvas conversion
165
- const { imageSettings: _removed, ...propsWithoutImage } = props;
166
- updatedProps = propsWithoutImage;
167
- }
168
- }
169
-
170
- // Create the SVG element with all props including templateId
171
- // Filter out props that aren't valid for QRCodeSVG (like hideLogo, url, etc.)
172
- // Exports never carry the preview's frame label markers.
173
- const {
174
- hideLogo: _hideLogo,
175
- url: _url,
176
- logo: _logo,
177
- scale: _scale,
178
- frameLabelMarkers: _frameLabelMarkers,
179
- ...validSVGProps
180
- } = updatedProps as any;
181
-
182
- const svgElement = React.createElement(QRCodeSVG, {
183
- ...validSVGProps,
184
- templateId: updatedProps.templateId, // Ensure templateId is passed
185
- customTemplate: updatedProps.customTemplate, // Ensure customTemplate is passed
186
- });
187
-
188
- const svgString = renderToStaticMarkup(svgElement);
189
-
190
- return `data:image/svg+xml,${encodeURIComponent(svgString)}`;
191
- }
192
-
193
- const getBase64Image = (imgUrl: string) =>
194
- new Promise((resolve, reject) => {
195
- // If already a data URL, return as is
196
- if (imgUrl.startsWith("data:")) {
197
- resolve(imgUrl);
198
- return;
199
- }
200
-
201
- const img = new Image();
202
- // Set crossOrigin before setting src
203
- img.crossOrigin = "anonymous";
204
-
205
- img.onload = () => {
206
- try {
207
- const canvas = document.createElement("canvas");
208
- canvas.width = img.naturalWidth || img.width;
209
- canvas.height = img.naturalHeight || img.height;
210
-
211
- const ctx = canvas.getContext("2d");
212
- if (!ctx) {
213
- reject(new Error("Could not get canvas context"));
214
- return;
215
- }
216
-
217
- ctx.drawImage(img, 0, 0);
218
- const dataURL = canvas.toDataURL("image/png");
219
-
220
- canvas.remove();
221
- resolve(dataURL);
222
- } catch (error) {
223
- reject(new Error(`Failed to convert image to base64: ${error}`));
224
- }
225
- };
226
-
227
- img.onerror = () => {
228
- reject(
229
- new Error(
230
- `Could not load image from ${imgUrl.slice(0, 100)}... Check CORS settings or use a data URL.`
231
- )
232
- );
233
- };
234
-
235
- img.src = imgUrl;
236
- });
237
-
238
- // function waitUntilImageLoaded(img: HTMLImageElement, src: string) {
239
- // return new Promise((resolve) => {
240
- // function onFinish() {
241
- // img.onload = null;
242
- // img.onerror = null;
243
- // resolve(true);
244
- // }
245
- // img.onload = onFinish;
246
- // img.onerror = onFinish;
247
- // img.src = src;
248
- // img.loading = "eager";
249
- // });
250
- // }
251
-
252
- export async function getQRAsCanvas(
253
- props: QRProps,
254
- type: string,
255
- getCanvas?: boolean
256
- ): Promise<HTMLCanvasElement | string> {
257
- // First get the SVG using the same logic as displayed
258
- const svgDataUri = await getQRAsSVGDataUri(props);
259
- const svgString = decodeURIComponent(
260
- svgDataUri.replace("data:image/svg+xml,", "")
261
- );
262
-
263
- // Convert SVG to base64 for better compatibility
264
- let base64DataUri: string;
265
- try {
266
- // Use modern approach instead of deprecated unescape
267
- const utf8Bytes = new TextEncoder().encode(svgString);
268
- const binaryString = Array.from(utf8Bytes, (byte) =>
269
- String.fromCharCode(byte)
270
- ).join("");
271
- const base64SVG = btoa(binaryString);
272
- base64DataUri = `data:image/svg+xml;base64,${base64SVG}`;
273
- } catch (error) {
274
- throw new Error(`Failed to encode SVG for canvas conversion: ${error}`);
275
- }
276
-
277
- return new Promise((resolve, reject) => {
278
- const canvas = document.createElement("canvas");
279
- const ctx = canvas.getContext("2d");
280
-
281
- if (!ctx) {
282
- reject(new Error("Could not get canvas context"));
283
- return;
284
- }
285
-
286
- const img = new Image();
287
-
288
- // Set canvas size to match the QR code (plus its frame, if any)
289
- const { width, height } = getFrameDimensions(
290
- props.size || DEFAULT_SIZE,
291
- props.frame
292
- );
293
- canvas.width = Math.round(width);
294
- canvas.height = Math.round(height);
295
-
296
- // Add timeout to prevent hanging
297
- const timeout = setTimeout(() => {
298
- canvas.remove();
299
- reject(
300
- new Error(
301
- "SVG load timeout - image may be too large or contain invalid data"
302
- )
303
- );
304
- }, 30_000); // 30 second timeout
305
-
306
- img.onload = () => {
307
- clearTimeout(timeout);
308
- try {
309
- // Fill white background for JPG
310
- if (type === "image/jpeg") {
311
- ctx.fillStyle = "white";
312
- ctx.fillRect(0, 0, canvas.width, canvas.height);
313
- }
314
-
315
- ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
316
-
317
- if (getCanvas) {
318
- resolve(canvas);
319
- } else if (type === "image/webp") {
320
- // toDataURL would hand back a PNG where the browser can't encode
321
- // WebP (Safari); canvasToWebP encodes it itself there.
322
- canvasToWebP(canvas)
323
- .then(blobToDataUrl)
324
- .then(resolve, reject)
325
- .finally(() => canvas.remove());
326
- } else {
327
- const dataUrl = canvas.toDataURL(type, 1.0);
328
- canvas.remove();
329
- resolve(dataUrl);
330
- }
331
- } catch (error) {
332
- clearTimeout(timeout);
333
- canvas.remove();
334
- reject(new Error(`Failed to draw SVG to canvas: ${error}`));
335
- }
336
- };
337
-
338
- img.onerror = () => {
339
- clearTimeout(timeout);
340
- canvas.remove();
341
- reject(new Error("Could not load SVG"));
342
- };
343
-
344
- // Use base64-encoded data URI for maximum compatibility
345
- img.src = base64DataUri;
346
- });
347
- }
348
-
349
- export {
350
- type CodewordMap,
351
- damagedCodewords,
352
- getCodewordMap,
353
- } from "./codeword-map";
354
- export { getLogoSizeLimit, getQRData } from "./helpers";
355
- export {
356
- getLogoBlockDamage,
357
- LOGO_EC_SAFETY,
358
- type LogoBlockDamage,
359
- logoFitsBudget,
360
- } from "./logo-budget";
14
+ export { QRCodeSVG } from "./qr-code-svg";
@@ -0,0 +1,3 @@
1
+ // Compilers fall back to `createElement` from the JSX import source for a
2
+ // `key` placed after a spread (`<g {...props} key={k} />`).
3
+ export { h as createElement } from "./runtime";
@@ -0,0 +1,14 @@
1
+ // The development JSX runtime (test runners compile JSX in dev mode).
2
+ import { jsx, jsxs, type QRNode } from "./runtime";
3
+
4
+ export type { JSX } from "./jsx-runtime";
5
+ export { Fragment } from "./runtime";
6
+
7
+ export function jsxDEV(
8
+ type: unknown,
9
+ props: object | null,
10
+ key?: string | number | null,
11
+ isStaticChildren?: boolean
12
+ ): QRNode {
13
+ return (isStaticChildren ? jsxs : jsx)(type, props, key);
14
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The automatic JSX runtime of the SVG renderer (see runtime.ts). A file opts
3
+ * in with `/** @jsxImportSource ./jsx *\/` (relative to it).
4
+ *
5
+ * Attribute names and values are React's (`fillRule`, `strokeWidth`,
6
+ * `style={{ … }}`), checked against React's SVG types when this package is
7
+ * type-checked; nothing here imports React at run time, and the published
8
+ * types of the core never reach this file.
9
+ */
10
+ import type { JSX as ReactJSX } from "react";
11
+ import type { QRNode } from "./runtime";
12
+
13
+ export { Fragment, jsx, jsxs } from "./runtime";
14
+
15
+ type WithChildren<T> = Omit<T, "children" | "ref"> & { children?: unknown };
16
+
17
+ type IntrinsicElementsMap = {
18
+ [K in keyof ReactJSX.IntrinsicElements]: WithChildren<
19
+ ReactJSX.IntrinsicElements[K]
20
+ >;
21
+ };
22
+
23
+ // biome-ignore lint/style/noNamespace: TypeScript reads JSX types from a namespace named JSX
24
+ export declare namespace JSX {
25
+ type Element = QRNode;
26
+ interface ElementChildrenAttribute {
27
+ // biome-ignore lint/complexity/noBannedTypes: the JSX convention
28
+ children: {};
29
+ }
30
+ interface IntrinsicAttributes {
31
+ key?: string | number | null;
32
+ }
33
+ interface IntrinsicElements extends IntrinsicElementsMap {}
34
+ }
@@ -0,0 +1,209 @@
1
+ /**
2
+ * The element runtime of the SVG renderer. The renderer's .tsx files compile
3
+ * their JSX against this folder (`/** @jsxImportSource ./jsx *\/`), so they
4
+ * need no framework: by default an element is a plain `QRNode`
5
+ * (`{ type, props, key }`) that `renderToString`, `renderToDOM` and
6
+ * `toHyperscript` turn into markup, DOM nodes or another framework's
7
+ * elements.
8
+ *
9
+ * The React components draw through the same code with React's own element
10
+ * functions plugged in (`withElementFactory`), so they build exactly the
11
+ * React elements they always have, with no conversion step.
12
+ */
13
+
14
+ /** A component: a function from props to a tree. */
15
+ export type QRComponent = (props: any) => QRChild;
16
+
17
+ /** A node of the tree the renderer builds without a framework. */
18
+ export interface QRNode {
19
+ /** An element name ("svg", "path"…), `Fragment`, or a component */
20
+ type: string | QRComponent;
21
+ /** Attributes with React's names (`fillRule`, `className`), plus `children` */
22
+ props: QRNodeProps;
23
+ /** Like React's: a string, or null when none was given */
24
+ key: string | null;
25
+ }
26
+
27
+ export interface QRNodeProps {
28
+ children?: QRChild;
29
+ [name: string]: unknown;
30
+ }
31
+
32
+ /** Anything that can sit in a tree. Booleans, null and undefined draw nothing. */
33
+ export type QRChild =
34
+ | QRNode
35
+ | string
36
+ | number
37
+ | bigint
38
+ | boolean
39
+ | null
40
+ | undefined
41
+ | readonly QRChild[];
42
+
43
+ /** Groups children without adding an element. */
44
+ export function Fragment(props: { children?: QRChild }): QRChild {
45
+ return props.children;
46
+ }
47
+
48
+ type Key = string | number | bigint | null | undefined;
49
+
50
+ /**
51
+ * The element functions the renderer calls. `QRNode`s by default; the React
52
+ * entry plugs in React's (see `withElementFactory`).
53
+ */
54
+ export interface ElementFactory {
55
+ jsx(type: unknown, props: object | null, key?: Key): unknown;
56
+ jsxs(type: unknown, props: object | null, key?: Key): unknown;
57
+ createElement(
58
+ type: unknown,
59
+ props: object | null,
60
+ ...children: unknown[]
61
+ ): unknown;
62
+ cloneElement(element: unknown, props?: object | null): unknown;
63
+ Fragment: unknown;
64
+ }
65
+
66
+ const toKey = (key: Key): string | null =>
67
+ key === undefined || key === null ? null : `${key}`;
68
+
69
+ /** Builds a node; a `key` among the props wins and is taken out, as in React. */
70
+ function node(type: unknown, props: object | null, key?: Key): QRNode {
71
+ let ownProps = (props ?? {}) as QRNodeProps;
72
+ let ownKey = key;
73
+ if ("key" in ownProps) {
74
+ const { key: propKey, ...rest } = ownProps;
75
+ if (propKey !== undefined) {
76
+ ownKey = propKey as Key;
77
+ }
78
+ ownProps = rest;
79
+ }
80
+ return { type: type as QRNode["type"], props: ownProps, key: toKey(ownKey) };
81
+ }
82
+
83
+ /**
84
+ * A copy of `element` with `props` merged over its own, like React's
85
+ * `cloneElement` (the key is kept). Works on React elements too (a custom
86
+ * template written for React, drawn without React).
87
+ */
88
+ function cloneNode(element: unknown, props?: object | null): QRNode {
89
+ const source = element as QRNode;
90
+ return {
91
+ type: source.type,
92
+ props: { ...source.props, ...props },
93
+ key: source.key ?? null,
94
+ };
95
+ }
96
+
97
+ /** `createElement(type, props, ...children)`, the classic signature. */
98
+ function createNode(
99
+ type: unknown,
100
+ config: object | null,
101
+ ...children: unknown[]
102
+ ): QRNode {
103
+ const props: Record<string, unknown> = { ...config };
104
+ if (children.length > 0) {
105
+ props.children = children.length === 1 ? children[0] : children;
106
+ }
107
+ return node(type, props);
108
+ }
109
+
110
+ const NODE_FACTORY: ElementFactory = {
111
+ jsx: node,
112
+ jsxs: node,
113
+ createElement: createNode,
114
+ cloneElement: cloneNode,
115
+ Fragment,
116
+ };
117
+
118
+ let factory: ElementFactory = NODE_FACTORY;
119
+
120
+ /**
121
+ * Runs `render` with another framework's element functions: the React
122
+ * components call the renderer through this, so it builds React elements.
123
+ * Rendering is synchronous, so nothing else runs while the factory is set.
124
+ */
125
+ export function withElementFactory<T>(
126
+ elements: ElementFactory,
127
+ render: () => T
128
+ ): T {
129
+ const previous = factory;
130
+ factory = elements;
131
+ try {
132
+ return render();
133
+ } finally {
134
+ factory = previous;
135
+ }
136
+ }
137
+
138
+ const typeOf = (type: unknown) => (type === Fragment ? factory.Fragment : type);
139
+
140
+ /** Builds an element (what compiled JSX calls). */
141
+ export function jsx(type: unknown, props: object | null, key?: Key): QRNode {
142
+ return factory.jsx(typeOf(type), props, key) as QRNode;
143
+ }
144
+
145
+ /** Builds an element with children written out (what compiled JSX calls). */
146
+ export function jsxs(type: unknown, props: object | null, key?: Key): QRNode {
147
+ return factory.jsxs(typeOf(type), props, key) as QRNode;
148
+ }
149
+
150
+ /**
151
+ * Hyperscript: `h("path", { d: "M0 0h1v1H0z" })`, children last. For custom
152
+ * templates written without JSX; it builds whatever the code is drawn with
153
+ * (React elements inside the React components, `QRNode`s otherwise).
154
+ */
155
+ export function h(
156
+ type: string | QRComponent,
157
+ props?: Record<string, unknown> | null,
158
+ ...children: QRChild[]
159
+ ): QRNode {
160
+ return factory.createElement(
161
+ typeOf(type),
162
+ props ?? null,
163
+ ...children
164
+ ) as QRNode;
165
+ }
166
+
167
+ /** `cloneElement` for the current factory. */
168
+ export function cloneElement(element: unknown, props?: object | null): QRNode {
169
+ return factory.cloneElement(element, props) as QRNode;
170
+ }
171
+
172
+ const REACT_ELEMENT_TYPES = new Set<unknown>([
173
+ Symbol.for("react.element"),
174
+ Symbol.for("react.transitional.element"),
175
+ ]);
176
+ const REACT_FRAGMENT = Symbol.for("react.fragment");
177
+
178
+ /**
179
+ * A node of this tree, or a React element (a custom template written for
180
+ * React can still be drawn without React: a React element has the same
181
+ * type, props and key).
182
+ */
183
+ export function isQRNode(value: unknown): value is QRNode {
184
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
185
+ return false;
186
+ }
187
+ const candidate = value as {
188
+ type?: unknown;
189
+ props?: unknown;
190
+ $$typeof?: unknown;
191
+ };
192
+ if (
193
+ candidate.$$typeof !== undefined &&
194
+ !REACT_ELEMENT_TYPES.has(candidate.$$typeof)
195
+ ) {
196
+ return false;
197
+ }
198
+ return (
199
+ (typeof candidate.type === "string" ||
200
+ typeof candidate.type === "function" ||
201
+ candidate.type === REACT_FRAGMENT) &&
202
+ typeof candidate.props === "object" &&
203
+ candidate.props !== null
204
+ );
205
+ }
206
+
207
+ /** True for this runtime's Fragment and React's. */
208
+ export const isFragment = (type: unknown): boolean =>
209
+ type === Fragment || type === REACT_FRAGMENT;
package/src/logo.tsx CHANGED
@@ -1,10 +1,12 @@
1
+ /** @jsxImportSource ./jsx */
1
2
  /** biome-ignore-all lint/style/noMagicNumbers: logo geometry */
2
3
  // The center logo as SVG: an optional plate behind it and a crop to its
3
4
  // shape (imageSettings.shape and .plate). Everything is plain SVG (a filled
4
5
  // shape, a <clipPath> and an <image>), which the PDF and EPS exporters
5
6
  // draw too: their painters clip to the same outline.
6
- import type { JSX } from "react";
7
+
7
8
  import type { ImageSettings, LogoShape } from "../types";
9
+ import type { QRNode } from "./jsx/runtime";
8
10
  import { hashString } from "./shapes";
9
11
  import { fmt } from "./utils/fmt";
10
12
 
@@ -25,7 +27,7 @@ function shapeElement(
25
27
  shape: LogoShape,
26
28
  box: Box,
27
29
  props: Record<string, string> = {}
28
- ): JSX.Element {
30
+ ): QRNode {
29
31
  if (shape === "circle") {
30
32
  return (
31
33
  <circle
@@ -65,7 +67,7 @@ function inset(box: Box, share: number): Box {
65
67
  export function renderLogo(
66
68
  settings: Pick<ImageSettings, "src" | "shape" | "plate">,
67
69
  box: Box
68
- ): JSX.Element {
70
+ ): QRNode {
69
71
  const shape = settings.shape ?? "square";
70
72
  const plate = settings.plate;
71
73
  const imageBox = plate ? inset(box, LOGO_PLATE_INSET) : box;