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