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.
- package/README.md +123 -3
- package/dist/core.js +31 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +31 -0
- package/dist/core.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/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +3 -0
- package/dist/node.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/src/api.d.ts +8 -2
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/art.d.ts +4 -3
- package/dist/src/art.d.ts.map +1 -1
- package/dist/src/body-patterns.d.ts +3 -2
- package/dist/src/body-patterns.d.ts.map +1 -1
- package/dist/src/core.d.ts +5 -0
- package/dist/src/core.d.ts.map +1 -0
- package/dist/src/corner-dot.d.ts +3 -2
- package/dist/src/corner-dot.d.ts.map +1 -1
- package/dist/src/engine.d.ts +44 -0
- package/dist/src/engine.d.ts.map +1 -0
- package/dist/src/export.d.ts +5 -0
- package/dist/src/export.d.ts.map +1 -0
- package/dist/src/frame.d.ts +6 -4
- package/dist/src/frame.d.ts.map +1 -1
- package/dist/src/frames/catalogue/all.d.ts.map +1 -1
- package/dist/src/frames/catalogue/automotive.d.ts +5 -0
- package/dist/src/frames/catalogue/automotive.d.ts.map +1 -0
- package/dist/src/frames/catalogue/beauty-wellness.d.ts +5 -0
- package/dist/src/frames/catalogue/beauty-wellness.d.ts.map +1 -0
- package/dist/src/frames/catalogue/business.d.ts.map +1 -1
- package/dist/src/frames/catalogue/call-to-action.d.ts.map +1 -1
- package/dist/src/frames/catalogue/counts.d.ts +12 -7
- package/dist/src/frames/catalogue/counts.d.ts.map +1 -1
- package/dist/src/frames/catalogue/food-drink.d.ts.map +1 -1
- package/dist/src/frames/catalogue/health-learning.d.ts.map +1 -1
- package/dist/src/frames/catalogue/index.d.ts.map +1 -1
- package/dist/src/frames/catalogue/nonprofit.d.ts +5 -0
- package/dist/src/frames/catalogue/nonprofit.d.ts.map +1 -0
- package/dist/src/frames/catalogue/places.d.ts.map +1 -1
- package/dist/src/frames/catalogue/real-estate.d.ts +5 -0
- package/dist/src/frames/catalogue/real-estate.d.ts.map +1 -0
- package/dist/src/frames/catalogue/shopping.d.ts.map +1 -1
- package/dist/src/frames/catalogue/sports-fitness.d.ts +5 -0
- package/dist/src/frames/catalogue/sports-fitness.d.ts.map +1 -0
- package/dist/src/frames/catalogue/tags.d.ts.map +1 -1
- package/dist/src/frames/collections.d.ts.map +1 -1
- package/dist/src/frames/official-types.d.ts +1 -1
- package/dist/src/frames/official-types.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -37
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/jsx/index.d.ts +2 -0
- package/dist/src/jsx/index.d.ts.map +1 -0
- package/dist/src/jsx/jsx-dev-runtime.d.ts +5 -0
- package/dist/src/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/jsx/jsx-runtime.d.ts +30 -0
- package/dist/src/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/src/jsx/runtime.d.ts +73 -0
- package/dist/src/jsx/runtime.d.ts.map +1 -0
- package/dist/src/logo.d.ts +3 -2
- package/dist/src/logo.d.ts.map +1 -1
- package/dist/src/node.d.ts +23 -0
- package/dist/src/node.d.ts.map +1 -0
- package/dist/src/part-markers.d.ts +15 -0
- package/dist/src/part-markers.d.ts.map +1 -0
- package/dist/src/plain.d.ts +31 -0
- package/dist/src/plain.d.ts.map +1 -0
- package/dist/src/qr-code-canvas.d.ts +1 -1
- package/dist/src/qr-code-canvas.d.ts.map +1 -1
- package/dist/src/qr-code-props.d.ts +22 -0
- package/dist/src/qr-code-props.d.ts.map +1 -0
- package/dist/src/qr-code-svg.d.ts +10 -0
- package/dist/src/qr-code-svg.d.ts.map +1 -0
- package/dist/src/qr-code.d.ts +2 -10
- package/dist/src/qr-code.d.ts.map +1 -1
- package/dist/src/rasterize.d.ts +25 -0
- package/dist/src/rasterize.d.ts.map +1 -0
- package/dist/src/react-elements.d.ts +3 -0
- package/dist/src/react-elements.d.ts.map +1 -0
- package/dist/src/render/attributes.d.ts +33 -0
- package/dist/src/render/attributes.d.ts.map +1 -0
- package/dist/src/render/dom.d.ts +8 -0
- package/dist/src/render/dom.d.ts.map +1 -0
- package/dist/src/render/hyperscript.d.ts +10 -0
- package/dist/src/render/hyperscript.d.ts.map +1 -0
- package/dist/src/render/string.d.ts +8 -0
- package/dist/src/render/string.d.ts.map +1 -0
- package/dist/src/svg.d.ts +14 -0
- package/dist/src/svg.d.ts.map +1 -0
- package/dist/src/template/arrow.d.ts +1 -0
- package/dist/src/template/arrow.d.ts.map +1 -1
- package/dist/src/template/default.d.ts +1 -0
- package/dist/src/template/default.d.ts.map +1 -1
- package/dist/src/template/halloween.d.ts +1 -0
- package/dist/src/template/halloween.d.ts.map +1 -1
- package/dist/src/template/square-border.d.ts +1 -0
- package/dist/src/template/square-border.d.ts.map +1 -1
- package/dist/src/template/standard-box.d.ts +1 -0
- package/dist/src/template/standard-box.d.ts.map +1 -1
- package/dist/src/template/striked-box.d.ts +1 -0
- package/dist/src/template/striked-box.d.ts.map +1 -1
- package/dist/src/utils.d.ts +9 -3
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/vanilla-api.d.ts +47 -0
- package/dist/src/vanilla-api.d.ts.map +1 -0
- package/dist/src/vanilla-browser.d.ts +4 -0
- package/dist/src/vanilla-browser.d.ts.map +1 -0
- package/dist/src/vanilla.d.ts +4 -0
- package/dist/src/vanilla.d.ts.map +1 -0
- package/dist/src/vue.d.ts +56 -0
- package/dist/src/vue.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -2
- package/dist/types/index.mjs +2 -2
- package/dist/types/public.d.ts +3 -0
- package/dist/types/public.d.ts.map +1 -0
- package/dist/types/qr.d.ts +18 -4
- package/dist/types/qr.d.ts.map +1 -1
- package/dist/types/react.d.ts +5 -0
- package/dist/types/react.d.ts.map +1 -0
- package/dist/types/template.d.ts +7 -1
- package/dist/types/template.d.ts.map +1 -1
- package/dist/vanilla.browser.mjs +92 -0
- package/dist/vanilla.browser.mjs.map +1 -0
- package/dist/vanilla.js +2 -0
- package/dist/vanilla.js.map +1 -0
- package/dist/vanilla.mjs +2 -0
- package/dist/vanilla.mjs.map +1 -0
- package/dist/vue.js +2 -0
- package/dist/vue.js.map +1 -0
- package/dist/vue.mjs +2 -0
- package/dist/vue.mjs.map +1 -0
- package/package.json +71 -6
- package/src/api.tsx +16 -139
- package/src/art.tsx +18 -16
- package/src/body-patterns.tsx +5 -3
- package/src/core.ts +13 -0
- package/src/corner-dot.tsx +4 -2
- package/src/download.tsx +1 -1
- package/src/engine.ts +170 -0
- package/src/export.ts +212 -0
- package/src/frame.tsx +7 -6
- package/src/frames/catalogue/all.ts +606 -0
- package/src/frames/catalogue/automotive.ts +61 -0
- package/src/frames/catalogue/beauty-wellness.ts +61 -0
- package/src/frames/catalogue/business.ts +68 -0
- package/src/frames/catalogue/call-to-action.ts +60 -0
- package/src/frames/catalogue/counts.ts +12 -7
- package/src/frames/catalogue/food-drink.ts +78 -0
- package/src/frames/catalogue/health-learning.ts +62 -14
- package/src/frames/catalogue/index.ts +2440 -16
- package/src/frames/catalogue/nonprofit.ts +65 -0
- package/src/frames/catalogue/places.ts +0 -18
- package/src/frames/catalogue/real-estate.ts +79 -0
- package/src/frames/catalogue/shopping.ts +68 -0
- package/src/frames/catalogue/sports-fitness.ts +81 -0
- package/src/frames/catalogue/tags.ts +354 -0
- package/src/frames/collections.ts +5 -0
- package/src/frames/official/add-engraving.json +90 -0
- package/src/frames/official/add-to-calendar.json +98 -0
- package/src/frames/official/adopt-me.json +72 -0
- package/src/frames/official/aftercare-guide.json +98 -0
- package/src/frames/official/alterations.json +142 -0
- package/src/frames/official/annual-report.json +85 -0
- package/src/frames/official/archery-lesson.json +106 -0
- package/src/frames/official/arrival-guide.json +71 -0
- package/src/frames/official/art-class.json +137 -0
- package/src/frames/official/ask-a-stylist.json +112 -0
- package/src/frames/official/assembly-guide.json +93 -0
- package/src/frames/official/badminton-session.json +104 -0
- package/src/frames/official/bake-sale.json +158 -0
- package/src/frames/official/bakery-board.json +80 -0
- package/src/frames/official/barber-booking.json +64 -0
- package/src/frames/official/bath-ritual.json +70 -0
- package/src/frames/official/bathroom-showroom.json +113 -0
- package/src/frames/official/battery-check.json +95 -0
- package/src/frames/official/beauty-rewards.json +81 -0
- package/src/frames/official/become-a-member.json +79 -0
- package/src/frames/official/bike-service.json +113 -0
- package/src/frames/official/book-a-call.json +105 -0
- package/src/frames/official/book-a-cleaning.json +92 -0
- package/src/frames/official/book-a-consultation.json +101 -0
- package/src/frames/official/book-a-court.json +74 -0
- package/src/frames/official/book-a-facial.json +108 -0
- package/src/frames/official/book-a-massage.json +80 -0
- package/src/frames/official/book-a-vaccine.json +88 -0
- package/src/frames/official/book-this-room.json +80 -0
- package/src/frames/official/boxing-class.json +81 -0
- package/src/frames/official/brewery-tour.json +89 -0
- package/src/frames/official/bridal-beauty.json +80 -0
- package/src/frames/official/brunch-menu.json +79 -0
- package/src/frames/official/bubble-tea.json +81 -0
- package/src/frames/official/bulk-orders.json +108 -0
- package/src/frames/official/burger-order.json +80 -0
- package/src/frames/official/call-a-server.json +115 -0
- package/src/frames/official/car-detailing.json +102 -0
- package/src/frames/official/car-details.json +90 -0
- package/src/frames/official/car-for-sale.json +74 -0
- package/src/frames/official/car-service.json +92 -0
- package/src/frames/official/carpool.json +79 -0
- package/src/frames/official/catering-order.json +79 -0
- package/src/frames/official/charging-prices.json +105 -0
- package/src/frames/official/charity-shop.json +75 -0
- package/src/frames/official/check-symptoms.json +80 -0
- package/src/frames/official/cheese-pairing.json +91 -0
- package/src/frames/official/chess-club.json +64 -0
- package/src/frames/official/chess-lessons.json +83 -0
- package/src/frames/official/choose-your-plan.json +113 -0
- package/src/frames/official/choose-your-wash.json +86 -0
- package/src/frames/official/clean-beauty.json +94 -0
- package/src/frames/official/click-and-collect.json +85 -0
- package/src/frames/official/clock-in.json +101 -0
- package/src/frames/official/club-fees.json +94 -0
- package/src/frames/official/coach-sign-up.json +108 -0
- package/src/frames/official/community-notices.json +107 -0
- package/src/frames/official/compare-specs.json +112 -0
- package/src/frames/official/consultation-form.json +120 -0
- package/src/frames/official/continued-online.json +81 -0
- package/src/frames/official/cookie-box.json +88 -0
- package/src/frames/official/cooking-class.json +89 -0
- package/src/frames/official/coworking-pass.json +89 -0
- package/src/frames/official/cricket-club.json +158 -0
- package/src/frames/official/cupcake-order.json +108 -0
- package/src/frames/official/damage-report.json +114 -0
- package/src/frames/official/dashboard-lights.json +106 -0
- package/src/frames/official/delivery-instructions.json +98 -0
- package/src/frames/official/diy-how-to.json +87 -0
- package/src/frames/official/donate-coats.json +74 -0
- package/src/frames/official/donate-food.json +80 -0
- package/src/frames/official/donation-jar.json +101 -0
- package/src/frames/official/donut-shop.json +94 -0
- package/src/frames/official/dress-fitting.json +64 -0
- package/src/frames/official/driving-lessons.json +110 -0
- package/src/frames/official/dumpling-house.json +82 -0
- package/src/frames/official/eye-exam.json +70 -0
- package/src/frames/official/eyewear-try-on.json +99 -0
- package/src/frames/official/fan-club.json +152 -0
- package/src/frames/official/farm-stand.json +109 -0
- package/src/frames/official/farmers-market.json +74 -0
- package/src/frames/official/find-a-charger.json +107 -0
- package/src/frames/official/find-a-doctor.json +85 -0
- package/src/frames/official/find-it-in-store.json +101 -0
- package/src/frames/official/find-our-office.json +80 -0
- package/src/frames/official/first-aid-guide.json +109 -0
- package/src/frames/official/fish-market.json +113 -0
- package/src/frames/official/fitness-challenge.json +1 -1
- package/src/frames/official/fitness-equipment.json +1 -1
- package/src/frames/official/fitness-kettlebell.json +1 -1
- package/src/frames/official/fitness-schedule.json +1 -1
- package/src/frames/official/fitness-test.json +94 -0
- package/src/frames/official/fitness-timer.json +1 -1
- package/src/frames/official/fitness-trial.json +1 -1
- package/src/frames/official/fitness-yoga.json +1 -1
- package/src/frames/official/food-support.json +102 -0
- package/src/frames/official/food-truck-location.json +80 -0
- package/src/frames/official/furnished-rental.json +101 -0
- package/src/frames/official/game-night.json +79 -0
- package/src/frames/official/garden-design.json +70 -0
- package/src/frames/official/garden-plot.json +74 -0
- package/src/frames/official/get-a-quote.json +113 -0
- package/src/frames/official/get-it-delivered.json +82 -0
- package/src/frames/official/get-started-rocket.json +80 -0
- package/src/frames/official/get-the-brochure.json +116 -0
- package/src/frames/official/gift-ideas.json +86 -0
- package/src/frames/official/gift-message.json +85 -0
- package/src/frames/official/give-blood.json +88 -0
- package/src/frames/official/giving-jar.json +89 -0
- package/src/frames/official/golf-scorecard.json +120 -0
- package/src/frames/official/grand-opening.json +158 -0
- package/src/frames/official/grill-menu.json +92 -0
- package/src/frames/official/hand-washing.json +106 -0
- package/src/frames/official/handyman.json +130 -0
- package/src/frames/official/hear-it-spoken.json +86 -0
- package/src/frames/official/home-valuation.json +87 -0
- package/src/frames/official/homework-help.json +79 -0
- package/src/frames/official/hot-shave.json +121 -0
- package/src/frames/official/house-rules.json +121 -0
- package/src/frames/official/how-it-works.json +98 -0
- package/src/frames/official/how-to-apply.json +93 -0
- package/src/frames/official/impact-report.json +90 -0
- package/src/frames/official/intake-forms.json +114 -0
- package/src/frames/official/join-a-league.json +94 -0
- package/src/frames/official/join-the-cleanup.json +110 -0
- package/src/frames/official/join-the-waitlist.json +102 -0
- package/src/frames/official/join-the-webinar.json +108 -0
- package/src/frames/official/juice-bar.json +70 -0
- package/src/frames/official/kids-haircuts.json +75 -0
- package/src/frames/official/kids-menu.json +107 -0
- package/src/frames/official/large-print.json +80 -0
- package/src/frames/official/lash-bar.json +86 -0
- package/src/frames/official/last-chance.json +94 -0
- package/src/frames/official/late-night-menu.json +77 -0
- package/src/frames/official/learn-the-signs.json +107 -0
- package/src/frames/official/library-card.json +90 -0
- package/src/frames/official/live-scores.json +101 -0
- package/src/frames/official/lost-and-found.json +85 -0
- package/src/frames/official/lost-pet-tag.json +84 -0
- package/src/frames/official/make-a-claim.json +74 -0
- package/src/frames/official/makeup-artist.json +94 -0
- package/src/frames/official/math-practice.json +136 -0
- package/src/frames/official/meal-plan.json +121 -0
- package/src/frames/official/meet-the-maker.json +91 -0
- package/src/frames/official/meet-the-team.json +82 -0
- package/src/frames/official/membership-card.json +108 -0
- package/src/frames/official/mortgage-calculator.json +94 -0
- package/src/frames/official/moving-checklist.json +108 -0
- package/src/frames/official/music-lessons.json +64 -0
- package/src/frames/official/nail-studio.json +70 -0
- package/src/frames/official/neighborhood-guide.json +98 -0
- package/src/frames/official/nutrition-facts.json +98 -0
- package/src/frames/official/online-class.json +82 -0
- package/src/frames/official/open-an-account.json +88 -0
- package/src/frames/official/open-house-sign-in.json +104 -0
- package/src/frames/official/parcel-room.json +98 -0
- package/src/frames/official/parent-meeting.json +108 -0
- package/src/frames/official/parking-permit.json +74 -0
- package/src/frames/official/pay-at-the-pump.json +108 -0
- package/src/frames/official/pay-for-parking.json +89 -0
- package/src/frames/official/pay-it-forward.json +102 -0
- package/src/frames/official/pay-your-rent.json +105 -0
- package/src/frames/official/permission-form.json +120 -0
- package/src/frames/official/personal-trainer.json +76 -0
- package/src/frames/official/physio-exercises.json +86 -0
- package/src/frames/official/pick-your-own.json +158 -0
- package/src/frames/official/plant-a-tree.json +88 -0
- package/src/frames/official/plant-based-menu.json +103 -0
- package/src/frames/official/plant-care.json +84 -0
- package/src/frames/official/podcast.json +107 -0
- package/src/frames/official/polling-place.json +109 -0
- package/src/frames/official/pool-timetable.json +113 -0
- package/src/frames/official/portfolio-card.json +110 -0
- package/src/frames/official/pre-order-bread.json +110 -0
- package/src/frames/official/press-kit.json +136 -0
- package/src/frames/official/price-list.json +111 -0
- package/src/frames/official/privacy-notice.json +115 -0
- package/src/frames/official/property-floor-plan.json +1 -1
- package/src/frames/official/property-for-sale.json +1 -1
- package/src/frames/official/property-house-light.json +1 -1
- package/src/frames/official/property-house.json +1 -1
- package/src/frames/official/property-key.json +1 -1
- package/src/frames/official/property-open-house.json +1 -1
- package/src/frames/official/property-rent.json +1 -1
- package/src/frames/official/property-virtual-tour.json +1 -1
- package/src/frames/official/questions-cloud.json +65 -0
- package/src/frames/official/race-entry.json +90 -0
- package/src/frames/official/race-photos.json +93 -0
- package/src/frames/official/rate-your-ride.json +103 -0
- package/src/frames/official/read-a-sample.json +108 -0
- package/src/frames/official/read-the-ebook.json +116 -0
- package/src/frames/official/read-the-faq.json +88 -0
- package/src/frames/official/read-the-reviews.json +110 -0
- package/src/frames/official/read-the-story.json +90 -0
- package/src/frames/official/read-the-transcript.json +142 -0
- package/src/frames/official/reading-challenge.json +97 -0
- package/src/frames/official/rebook-visit.json +86 -0
- package/src/frames/official/recipe-card.json +120 -0
- package/src/frames/official/refill-reminder.json +104 -0
- package/src/frames/official/register-interest.json +82 -0
- package/src/frames/official/register-to-vote.json +80 -0
- package/src/frames/official/renovation-quote.json +80 -0
- package/src/frames/official/rent-a-bike.json +95 -0
- package/src/frames/official/rent-this-item.json +95 -0
- package/src/frames/official/rental-car-guide.json +115 -0
- package/src/frames/official/report-a-problem.json +114 -0
- package/src/frames/official/report-a-repair.json +79 -0
- package/src/frames/official/report-a-street-issue.json +113 -0
- package/src/frames/official/request-maintenance.json +74 -0
- package/src/frames/official/resident-portal.json +98 -0
- package/src/frames/official/restaurant-gift-card.json +94 -0
- package/src/frames/official/restock-alert.json +98 -0
- package/src/frames/official/restroom-feedback.json +86 -0
- package/src/frames/official/return-your-cup.json +130 -0
- package/src/frames/official/return-your-rental.json +113 -0
- package/src/frames/official/ring-size.json +107 -0
- package/src/frames/official/roadside-help.json +92 -0
- package/src/frames/official/run-club.json +79 -0
- package/src/frames/official/safety-information.json +92 -0
- package/src/frames/official/salon-prices.json +92 -0
- package/src/frames/official/save-for-later.json +79 -0
- package/src/frames/official/scan-for-the-answer.json +86 -0
- package/src/frames/official/scan-for-the-checklist.json +108 -0
- package/src/frames/official/scan-for-the-latest.json +74 -0
- package/src/frames/official/scan-for-translations.json +108 -0
- package/src/frames/official/scan-here-arrow.json +76 -0
- package/src/frames/official/scan-here-post.json +89 -0
- package/src/frames/official/scan-me-banner.json +147 -0
- package/src/frames/official/scan-me-cloud.json +73 -0
- package/src/frames/official/scan-me-folded.json +74 -0
- package/src/frames/official/scan-me-stack.json +93 -0
- package/src/frames/official/scan-to-unlock.json +107 -0
- package/src/frames/official/scent-finder.json +94 -0
- package/src/frames/official/scholarships.json +108 -0
- package/src/frames/official/school-supply-list.json +80 -0
- package/src/frames/official/science-fair.json +89 -0
- package/src/frames/official/season-schedule.json +66 -0
- package/src/frames/official/see-more-stack.json +91 -0
- package/src/frames/official/see-our-pitch.json +85 -0
- package/src/frames/official/see-the-full-list.json +107 -0
- package/src/frames/official/see-the-map.json +79 -0
- package/src/frames/official/send-flowers.json +93 -0
- package/src/frames/official/service-times.json +115 -0
- package/src/frames/official/shade-finder.json +113 -0
- package/src/frames/official/shoe-size-check.json +95 -0
- package/src/frames/official/sign-rider.json +1 -1
- package/src/frames/official/sign-the-agreement.json +120 -0
- package/src/frames/official/sign-the-petition.json +120 -0
- package/src/frames/official/site-hoarding.json +158 -0
- package/src/frames/official/site-induction.json +120 -0
- package/src/frames/official/size-guide.json +80 -0
- package/src/frames/official/skate-park-rules.json +109 -0
- package/src/frames/official/skincare-routine.json +85 -0
- package/src/frames/official/sofa-fabric.json +84 -0
- package/src/frames/official/spa-gift.json +90 -0
- package/src/frames/official/spa-menu.json +124 -0
- package/src/frames/official/split-the-bill.json +77 -0
- package/src/frames/official/sponsor-a-pet.json +102 -0
- package/src/frames/official/sponsor-my-run.json +136 -0
- package/src/frames/official/sports-camp.json +142 -0
- package/src/frames/official/staff-handbook.json +121 -0
- package/src/frames/official/staff-rota.json +112 -0
- package/src/frames/official/start-a-return.json +92 -0
- package/src/frames/official/start-charging.json +104 -0
- package/src/frames/official/start-here-arrow.json +79 -0
- package/src/frames/official/start-saving.json +74 -0
- package/src/frames/official/storage-units.json +79 -0
- package/src/frames/official/student-portal.json +80 -0
- package/src/frames/official/style-gallery.json +111 -0
- package/src/frames/official/sushi-menu.json +115 -0
- package/src/frames/official/swim-lessons.json +70 -0
- package/src/frames/official/table-tennis.json +116 -0
- package/src/frames/official/take-a-closer-look.json +94 -0
- package/src/frames/official/takeout-order.json +98 -0
- package/src/frames/official/talk-to-someone.json +115 -0
- package/src/frames/official/talk-to-the-agent.json +115 -0
- package/src/frames/official/tea-menu.json +70 -0
- package/src/frames/official/tea-time.json +124 -0
- package/src/frames/official/team-jersey.json +77 -0
- package/src/frames/official/team-kit.json +85 -0
- package/src/frames/official/tee-time.json +85 -0
- package/src/frames/official/tennis-court.json +94 -0
- package/src/frames/official/test-drive.json +88 -0
- package/src/frames/official/test-results.json +85 -0
- package/src/frames/official/tire-change.json +74 -0
- package/src/frames/official/town-hall.json +158 -0
- package/src/frames/official/toy-finder.json +81 -0
- package/src/frames/official/trace-your-coffee.json +87 -0
- package/src/frames/official/trade-it-in.json +97 -0
- package/src/frames/official/try-the-demo.json +106 -0
- package/src/frames/official/unlock-this-car.json +82 -0
- package/src/frames/official/upload-receipts.json +108 -0
- package/src/frames/official/validate-parking.json +91 -0
- package/src/frames/official/vehicle-history.json +106 -0
- package/src/frames/official/virtual-try-on.json +93 -0
- package/src/frames/official/visiting-hours.json +90 -0
- package/src/frames/official/visitor-map.json +92 -0
- package/src/frames/official/visitor-sign-in.json +98 -0
- package/src/frames/official/volunteer.json +74 -0
- package/src/frames/official/vote-for-us.json +103 -0
- package/src/frames/official/walk-in-queue.json +102 -0
- package/src/frames/official/wash-club.json +81 -0
- package/src/frames/official/watch-repair.json +115 -0
- package/src/frames/official/watch-the-experiment.json +93 -0
- package/src/frames/official/water-refill.json +95 -0
- package/src/frames/official/weekly-deals.json +107 -0
- package/src/frames/official/wellness-retreat.json +85 -0
- package/src/frames/official/whats-inside.json +91 -0
- package/src/frames/official/wholesale.json +85 -0
- package/src/frames/official/window-quote.json +121 -0
- package/src/frames/official/wine-pairings.json +142 -0
- package/src/frames/official/wine-staff-pick.json +100 -0
- package/src/frames/official/winery-tasting.json +94 -0
- package/src/frames/official/yard-sign-coming-soon.json +115 -0
- package/src/frames/official/yard-sign-for-sale.json +150 -0
- package/src/frames/official/yard-sign-sold.json +162 -0
- package/src/frames/official/yard-sign-viewing.json +121 -0
- package/src/frames/official/your-prescription.json +107 -0
- package/src/frames/official/youth-club.json +104 -0
- package/src/frames/official-types.ts +6 -1
- package/src/frames/official.ts +4 -4
- package/src/index.tsx +6 -352
- package/src/jsx/index.ts +3 -0
- package/src/jsx/jsx-dev-runtime.ts +14 -0
- package/src/jsx/jsx-runtime.ts +34 -0
- package/src/jsx/runtime.ts +209 -0
- package/src/logo.tsx +5 -3
- package/src/node.ts +61 -0
- package/src/part-markers.ts +40 -0
- package/src/plain.tsx +194 -0
- package/src/qr-code-canvas.tsx +2 -1
- package/src/qr-code-props.ts +115 -0
- package/src/qr-code-svg.tsx +17 -0
- package/src/qr-code.tsx +34 -112
- package/src/rasterize.ts +282 -0
- package/src/react-elements.ts +13 -0
- package/src/render/attributes.ts +404 -0
- package/src/render/dom.ts +90 -0
- package/src/render/hyperscript.ts +66 -0
- package/src/render/string.ts +70 -0
- package/src/scan-score.ts +1 -1
- package/src/svg.ts +27 -0
- package/src/template/arrow.tsx +1 -0
- package/src/template/default.tsx +1 -0
- package/src/template/halloween.tsx +1 -0
- package/src/template/square-border.tsx +1 -0
- package/src/template/standard-box.tsx +1 -0
- package/src/template/striked-box.tsx +1 -0
- package/src/utils/print-shared.ts +1 -1
- package/src/utils.tsx +82 -38
- package/src/vanilla-api.ts +146 -0
- package/src/vanilla-browser.ts +11 -0
- package/src/vanilla.ts +10 -0
- package/src/vue.ts +220 -0
- package/types/index.ts +4 -2
- package/types/public.ts +4 -0
- package/types/qr.ts +24 -5
- package/types/react.ts +8 -0
- package/types/template.ts +10 -3
package/src/rasterize.ts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: image format magic bytes */
|
|
2
|
+
// Node-friendly rasterization for PNG export (getQRAsPNG in download.tsx).
|
|
3
|
+
// Both rasterizers are optional peer dependencies loaded only when a PNG is
|
|
4
|
+
// asked for, so installing qrdx never pulls in a native module:
|
|
5
|
+
//
|
|
6
|
+
// - @resvg/resvg-js is tried first: it draws the SVG the way browsers do,
|
|
7
|
+
// embedded logos included (PNG, JPEG, GIF, WebP and SVG images).
|
|
8
|
+
// - sharp is tried next, but its bundled SVG renderer skips embedded <image>
|
|
9
|
+
// elements, so the logo is located with a marker render and composited
|
|
10
|
+
// onto the pixels afterwards.
|
|
11
|
+
|
|
12
|
+
type SharpFactory = typeof import("sharp").default;
|
|
13
|
+
|
|
14
|
+
/** A logo loaded for rasterizing: the raw bytes, plus the data URL the SVG embeds. */
|
|
15
|
+
export interface RasterLogo {
|
|
16
|
+
bytes: Uint8Array;
|
|
17
|
+
dataUrl: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Largest logo the rasterizer loads (the cap apps/docs/lib/qr-api/logo.ts uses). */
|
|
21
|
+
const LOGO_MAX_BYTES = 1024 * 1024;
|
|
22
|
+
|
|
23
|
+
const LOGO_FETCH_TIMEOUT_MS = 10_000;
|
|
24
|
+
|
|
25
|
+
/** Reads the response body, giving up once it passes the size cap. */
|
|
26
|
+
async function readBodyCapped(
|
|
27
|
+
response: Response,
|
|
28
|
+
maxBytes: number
|
|
29
|
+
): Promise<Uint8Array | null> {
|
|
30
|
+
if (!response.body) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const reader = response.body.getReader();
|
|
34
|
+
const chunks: Uint8Array[] = [];
|
|
35
|
+
let received = 0;
|
|
36
|
+
for (;;) {
|
|
37
|
+
const { done, value } = await reader.read();
|
|
38
|
+
if (done) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
received += value.byteLength;
|
|
42
|
+
if (received > maxBytes) {
|
|
43
|
+
await reader.cancel().catch(() => {
|
|
44
|
+
// Already over the cap; losing this read is fine.
|
|
45
|
+
});
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
chunks.push(value);
|
|
49
|
+
}
|
|
50
|
+
const bytes = new Uint8Array(received);
|
|
51
|
+
let offset = 0;
|
|
52
|
+
for (const chunk of chunks) {
|
|
53
|
+
bytes.set(chunk, offset);
|
|
54
|
+
offset += chunk.byteLength;
|
|
55
|
+
}
|
|
56
|
+
return bytes;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const base64ToBytes = (base64: string) =>
|
|
60
|
+
Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));
|
|
61
|
+
|
|
62
|
+
const bytesToBase64 = (bytes: Uint8Array) => {
|
|
63
|
+
let binary = "";
|
|
64
|
+
for (let i = 0; i < bytes.length; i += 0x80_00) {
|
|
65
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + 0x80_00));
|
|
66
|
+
}
|
|
67
|
+
return btoa(binary);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sniffs a file's first bytes into an image MIME type, or null. These are
|
|
72
|
+
* the types the rasterizers draw (resvg renders PNG, JPEG, GIF and WebP
|
|
73
|
+
* images, plus nested SVG, the same way browsers do).
|
|
74
|
+
*/
|
|
75
|
+
function sniffImageMime(bytes: Uint8Array): string | null {
|
|
76
|
+
if (bytes[0] === 0x89 && bytes[1] === 0x50) {
|
|
77
|
+
return "image/png";
|
|
78
|
+
}
|
|
79
|
+
if (bytes[0] === 0xff && bytes[1] === 0xd8) {
|
|
80
|
+
return "image/jpeg";
|
|
81
|
+
}
|
|
82
|
+
if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
|
|
83
|
+
return "image/gif";
|
|
84
|
+
}
|
|
85
|
+
if (
|
|
86
|
+
bytes[0] === 0x52 &&
|
|
87
|
+
bytes[1] === 0x49 &&
|
|
88
|
+
bytes[2] === 0x46 &&
|
|
89
|
+
bytes[3] === 0x46 &&
|
|
90
|
+
bytes[8] === 0x57 &&
|
|
91
|
+
bytes[9] === 0x45 &&
|
|
92
|
+
bytes[10] === 0x42 &&
|
|
93
|
+
bytes[11] === 0x50
|
|
94
|
+
) {
|
|
95
|
+
return "image/webp";
|
|
96
|
+
}
|
|
97
|
+
const head = new TextDecoder()
|
|
98
|
+
.decode(bytes.subarray(0, 512))
|
|
99
|
+
.trimStart()
|
|
100
|
+
.toLowerCase();
|
|
101
|
+
if (head.startsWith("<?xml") || head.startsWith("<svg")) {
|
|
102
|
+
return "image/svg+xml";
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Loads a logo the way a Node export needs it: a data URL is decoded; an
|
|
109
|
+
* http(s) URL is fetched and anything else is read from disk — but only when
|
|
110
|
+
* the caller opts in with `loadExternal`, since a library function that runs
|
|
111
|
+
* on servers must not become a way to fetch internal URLs or read files
|
|
112
|
+
* (a data URL, which the caller already holds, needs no opt-in). Fetches are
|
|
113
|
+
* capped at 1 MB and refuse redirects. Returns null when it can't be loaded
|
|
114
|
+
* or isn't an image the rasterizers draw — the logo is left out then, the
|
|
115
|
+
* same thing the browser path does when an <img> fails to load.
|
|
116
|
+
*/
|
|
117
|
+
export async function loadLogoForRasterizer(
|
|
118
|
+
src: string,
|
|
119
|
+
loadExternal = false
|
|
120
|
+
): Promise<RasterLogo | null> {
|
|
121
|
+
if (src.startsWith("data:")) {
|
|
122
|
+
const comma = src.indexOf(",");
|
|
123
|
+
if (comma < 0) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
// Whatever the caller handed over stays the <image> href; the bytes are
|
|
127
|
+
// for sharp's composite path only and may fail to decode.
|
|
128
|
+
try {
|
|
129
|
+
const bytes = src.slice(5, comma).endsWith(";base64")
|
|
130
|
+
? base64ToBytes(src.slice(comma + 1))
|
|
131
|
+
: new TextEncoder().encode(decodeURIComponent(src.slice(comma + 1)));
|
|
132
|
+
return { bytes, dataUrl: src };
|
|
133
|
+
} catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!loadExternal) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let bytes: Uint8Array;
|
|
143
|
+
if (/^https?:\/\//i.test(src)) {
|
|
144
|
+
try {
|
|
145
|
+
// redirect: "error" keeps a URL a caller sent from being walked
|
|
146
|
+
// somewhere else by a redirect.
|
|
147
|
+
const response = await fetch(src, {
|
|
148
|
+
redirect: "error",
|
|
149
|
+
signal: AbortSignal.timeout(LOGO_FETCH_TIMEOUT_MS),
|
|
150
|
+
});
|
|
151
|
+
if (!response.ok) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
const body = await readBodyCapped(response, LOGO_MAX_BYTES);
|
|
155
|
+
if (!body) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
bytes = body;
|
|
159
|
+
} catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
} else if (typeof process !== "undefined" && process.versions?.node) {
|
|
163
|
+
// A local path. The specifier is computed so browser bundlers never
|
|
164
|
+
// try to resolve node:fs.
|
|
165
|
+
try {
|
|
166
|
+
const specifier = ["node:fs", "promises"].join("/");
|
|
167
|
+
const fs = (await import(specifier)) as typeof import("node:fs/promises");
|
|
168
|
+
const stats = await fs.stat(src);
|
|
169
|
+
if (stats.size > LOGO_MAX_BYTES) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
bytes = new Uint8Array(await fs.readFile(src));
|
|
173
|
+
} catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const mime = sniffImageMime(bytes);
|
|
181
|
+
if (!mime) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return { bytes, dataUrl: `data:${mime};base64,${bytesToBase64(bytes)}` };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Rasterizes the SVG the library renders into PNG bytes, at the SVG's own
|
|
189
|
+
* size (a fractional frame size rounds the way the browser's canvas does).
|
|
190
|
+
* The rasterizer is an optional peer dependency, loaded only here; when
|
|
191
|
+
* neither is installed the error names what to install.
|
|
192
|
+
*/
|
|
193
|
+
export async function rasterizeSvgToPng(
|
|
194
|
+
svg: string,
|
|
195
|
+
logo: RasterLogo | null
|
|
196
|
+
): Promise<Uint8Array> {
|
|
197
|
+
let Resvg: typeof import("@resvg/resvg-js").Resvg;
|
|
198
|
+
try {
|
|
199
|
+
({ Resvg } = await import("@resvg/resvg-js"));
|
|
200
|
+
} catch (resvgError) {
|
|
201
|
+
// Not installed (or its binary didn't load): try sharp instead.
|
|
202
|
+
return await rasterizeWithSharp(svg, logo, resvgError);
|
|
203
|
+
}
|
|
204
|
+
// fitTo "original" (the default) renders at the SVG's own width and
|
|
205
|
+
// height, so the PNG is exactly as large as the SVG markup says.
|
|
206
|
+
const rendered = new Resvg(svg).render();
|
|
207
|
+
return new Uint8Array(rendered.asPng());
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const describeError = (error: unknown) =>
|
|
211
|
+
error instanceof Error ? error.message : String(error);
|
|
212
|
+
|
|
213
|
+
async function rasterizeWithSharp(
|
|
214
|
+
svg: string,
|
|
215
|
+
logo: RasterLogo | null,
|
|
216
|
+
resvgError: unknown
|
|
217
|
+
): Promise<Uint8Array> {
|
|
218
|
+
let sharp: SharpFactory;
|
|
219
|
+
try {
|
|
220
|
+
sharp = ((await import("sharp")) as { default: SharpFactory }).default;
|
|
221
|
+
} catch (sharpError) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
"PNG export in Node needs an optional rasterizer package: " +
|
|
224
|
+
"`npm install @resvg/resvg-js` (draws embedded logos like a browser) " +
|
|
225
|
+
"or `npm install sharp`. " +
|
|
226
|
+
`(${describeError(resvgError)}; ${describeError(sharpError)})`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const png = await sharp(new TextEncoder().encode(svg)).png().toBuffer();
|
|
231
|
+
// sharp's bundled SVG renderer skips embedded <image> elements, so the
|
|
232
|
+
// logo never reaches the pixels: find where it belongs and composite it.
|
|
233
|
+
if (!logo) {
|
|
234
|
+
return new Uint8Array(png);
|
|
235
|
+
}
|
|
236
|
+
const box = await findLogoBox(sharp, svg);
|
|
237
|
+
if (!box) {
|
|
238
|
+
return new Uint8Array(png);
|
|
239
|
+
}
|
|
240
|
+
const logoPng = await sharp(logo.bytes)
|
|
241
|
+
.resize(box.width, box.height, { fit: "fill" })
|
|
242
|
+
.png()
|
|
243
|
+
.toBuffer();
|
|
244
|
+
const composited = await sharp(png)
|
|
245
|
+
.composite([{ input: logoPng, left: box.left, top: box.top }])
|
|
246
|
+
.png()
|
|
247
|
+
.toBuffer();
|
|
248
|
+
return new Uint8Array(composited);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Finds the logo's pixel box in the rendered output. The <image> is swapped
|
|
253
|
+
* for a lone visible rect, so the box comes out right even inside template
|
|
254
|
+
* transforms.
|
|
255
|
+
*/
|
|
256
|
+
async function findLogoBox(sharp: SharpFactory, svg: string) {
|
|
257
|
+
const imageTag = svg.match(/<image\b[^>]*?(?:\/>|><\/image>)/)?.[0];
|
|
258
|
+
if (!imageTag) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
const markerTag = imageTag
|
|
262
|
+
.replace(/^<image\b/, '<rect class="qrdx-logo-box"')
|
|
263
|
+
.replace(/\shref="[^"]*"/, "")
|
|
264
|
+
.replace(/(?:\/>|><\/image>)$/, ' fill="#000"/>');
|
|
265
|
+
const markerSvg = svg
|
|
266
|
+
.replace(imageTag, markerTag)
|
|
267
|
+
.replace(
|
|
268
|
+
/<svg\b[^>]*>/,
|
|
269
|
+
(open) =>
|
|
270
|
+
`${open}<style>*{visibility:hidden}.qrdx-logo-box{visibility:visible}</style>`
|
|
271
|
+
);
|
|
272
|
+
const { info } = await sharp(new TextEncoder().encode(markerSvg))
|
|
273
|
+
.png()
|
|
274
|
+
.trim()
|
|
275
|
+
.toBuffer({ resolveWithObject: true });
|
|
276
|
+
return {
|
|
277
|
+
left: -(info.trimOffsetLeft ?? 0),
|
|
278
|
+
top: -(info.trimOffsetTop ?? 0),
|
|
279
|
+
width: info.width,
|
|
280
|
+
height: info.height,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// React's element functions, plugged into the renderer (jsx/runtime.ts) when
|
|
2
|
+
// a React component draws the code, so it builds React elements directly.
|
|
3
|
+
import { cloneElement, createElement, Fragment } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import type { ElementFactory } from "./jsx/runtime";
|
|
6
|
+
|
|
7
|
+
export const REACT_ELEMENTS: ElementFactory = {
|
|
8
|
+
jsx,
|
|
9
|
+
jsxs,
|
|
10
|
+
createElement,
|
|
11
|
+
cloneElement: cloneElement as ElementFactory["cloneElement"],
|
|
12
|
+
Fragment,
|
|
13
|
+
};
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: character codes */
|
|
2
|
+
/**
|
|
3
|
+
* How a prop becomes an attribute, the way React DOM's server renderer writes
|
|
4
|
+
* it (react-dom 19, `pushAttribute` in ReactFizzConfigDOM): the same names
|
|
5
|
+
* (`fillRule` → `fill-rule`, `className` → `class`), the same values (style
|
|
6
|
+
* objects, URLs, booleans) and the same props left out (event handlers,
|
|
7
|
+
* functions, `ref`). `renderToString`, `renderToDOM` and `toHyperscript` all
|
|
8
|
+
* use it, so markup, DOM nodes and React agree byte for byte.
|
|
9
|
+
*
|
|
10
|
+
* Ported from React (MIT License, Copyright (c) Meta Platforms, Inc. and
|
|
11
|
+
* affiliates).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** camelCase props written under another name (React's `aliases`). */
|
|
15
|
+
const ALIASES = new Map<string, string>([
|
|
16
|
+
["acceptCharset", "accept-charset"],
|
|
17
|
+
["htmlFor", "for"],
|
|
18
|
+
["httpEquiv", "http-equiv"],
|
|
19
|
+
["crossOrigin", "crossorigin"],
|
|
20
|
+
["accentHeight", "accent-height"],
|
|
21
|
+
["alignmentBaseline", "alignment-baseline"],
|
|
22
|
+
["arabicForm", "arabic-form"],
|
|
23
|
+
["baselineShift", "baseline-shift"],
|
|
24
|
+
["capHeight", "cap-height"],
|
|
25
|
+
["clipPath", "clip-path"],
|
|
26
|
+
["clipRule", "clip-rule"],
|
|
27
|
+
["colorInterpolation", "color-interpolation"],
|
|
28
|
+
["colorInterpolationFilters", "color-interpolation-filters"],
|
|
29
|
+
["colorProfile", "color-profile"],
|
|
30
|
+
["colorRendering", "color-rendering"],
|
|
31
|
+
["dominantBaseline", "dominant-baseline"],
|
|
32
|
+
["enableBackground", "enable-background"],
|
|
33
|
+
["fillOpacity", "fill-opacity"],
|
|
34
|
+
["fillRule", "fill-rule"],
|
|
35
|
+
["floodColor", "flood-color"],
|
|
36
|
+
["floodOpacity", "flood-opacity"],
|
|
37
|
+
["fontFamily", "font-family"],
|
|
38
|
+
["fontSize", "font-size"],
|
|
39
|
+
["fontSizeAdjust", "font-size-adjust"],
|
|
40
|
+
["fontStretch", "font-stretch"],
|
|
41
|
+
["fontStyle", "font-style"],
|
|
42
|
+
["fontVariant", "font-variant"],
|
|
43
|
+
["fontWeight", "font-weight"],
|
|
44
|
+
["glyphName", "glyph-name"],
|
|
45
|
+
["glyphOrientationHorizontal", "glyph-orientation-horizontal"],
|
|
46
|
+
["glyphOrientationVertical", "glyph-orientation-vertical"],
|
|
47
|
+
["horizAdvX", "horiz-adv-x"],
|
|
48
|
+
["horizOriginX", "horiz-origin-x"],
|
|
49
|
+
["imageRendering", "image-rendering"],
|
|
50
|
+
["letterSpacing", "letter-spacing"],
|
|
51
|
+
["lightingColor", "lighting-color"],
|
|
52
|
+
["markerEnd", "marker-end"],
|
|
53
|
+
["markerMid", "marker-mid"],
|
|
54
|
+
["markerStart", "marker-start"],
|
|
55
|
+
["maskType", "mask-type"],
|
|
56
|
+
["overlinePosition", "overline-position"],
|
|
57
|
+
["overlineThickness", "overline-thickness"],
|
|
58
|
+
["paintOrder", "paint-order"],
|
|
59
|
+
["panose-1", "panose-1"],
|
|
60
|
+
["pointerEvents", "pointer-events"],
|
|
61
|
+
["renderingIntent", "rendering-intent"],
|
|
62
|
+
["shapeRendering", "shape-rendering"],
|
|
63
|
+
["stopColor", "stop-color"],
|
|
64
|
+
["stopOpacity", "stop-opacity"],
|
|
65
|
+
["strikethroughPosition", "strikethrough-position"],
|
|
66
|
+
["strikethroughThickness", "strikethrough-thickness"],
|
|
67
|
+
["strokeDasharray", "stroke-dasharray"],
|
|
68
|
+
["strokeDashoffset", "stroke-dashoffset"],
|
|
69
|
+
["strokeLinecap", "stroke-linecap"],
|
|
70
|
+
["strokeLinejoin", "stroke-linejoin"],
|
|
71
|
+
["strokeMiterlimit", "stroke-miterlimit"],
|
|
72
|
+
["strokeOpacity", "stroke-opacity"],
|
|
73
|
+
["strokeWidth", "stroke-width"],
|
|
74
|
+
["textAnchor", "text-anchor"],
|
|
75
|
+
["textDecoration", "text-decoration"],
|
|
76
|
+
["textRendering", "text-rendering"],
|
|
77
|
+
["transformOrigin", "transform-origin"],
|
|
78
|
+
["underlinePosition", "underline-position"],
|
|
79
|
+
["underlineThickness", "underline-thickness"],
|
|
80
|
+
["unicodeBidi", "unicode-bidi"],
|
|
81
|
+
["unicodeRange", "unicode-range"],
|
|
82
|
+
["unitsPerEm", "units-per-em"],
|
|
83
|
+
["vAlphabetic", "v-alphabetic"],
|
|
84
|
+
["vHanging", "v-hanging"],
|
|
85
|
+
["vIdeographic", "v-ideographic"],
|
|
86
|
+
["vMathematical", "v-mathematical"],
|
|
87
|
+
["vectorEffect", "vector-effect"],
|
|
88
|
+
["vertAdvY", "vert-adv-y"],
|
|
89
|
+
["vertOriginX", "vert-origin-x"],
|
|
90
|
+
["vertOriginY", "vert-origin-y"],
|
|
91
|
+
["wordSpacing", "word-spacing"],
|
|
92
|
+
["writingMode", "writing-mode"],
|
|
93
|
+
["xmlnsXlink", "xmlns:xlink"],
|
|
94
|
+
["xHeight", "x-height"],
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
/** String attributes React renames (and writes only for non-booleans). */
|
|
98
|
+
const STRING_ATTRIBUTES = new Map<string, string>([
|
|
99
|
+
["className", "class"],
|
|
100
|
+
["tabIndex", "tabindex"],
|
|
101
|
+
["dir", "dir"],
|
|
102
|
+
["role", "role"],
|
|
103
|
+
["viewBox", "viewBox"],
|
|
104
|
+
["width", "width"],
|
|
105
|
+
["height", "height"],
|
|
106
|
+
["xlinkActuate", "xlink:actuate"],
|
|
107
|
+
["xlinkArcrole", "xlink:arcrole"],
|
|
108
|
+
["xlinkRole", "xlink:role"],
|
|
109
|
+
["xlinkShow", "xlink:show"],
|
|
110
|
+
["xlinkTitle", "xlink:title"],
|
|
111
|
+
["xlinkType", "xlink:type"],
|
|
112
|
+
["xmlBase", "xml:base"],
|
|
113
|
+
["xmlLang", "xml:lang"],
|
|
114
|
+
["xmlSpace", "xml:space"],
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
/** Props that are never attributes. */
|
|
118
|
+
const SKIPPED = new Set([
|
|
119
|
+
"children",
|
|
120
|
+
"dangerouslySetInnerHTML",
|
|
121
|
+
"key",
|
|
122
|
+
"defaultValue",
|
|
123
|
+
"defaultChecked",
|
|
124
|
+
"innerHTML",
|
|
125
|
+
"suppressContentEditableWarning",
|
|
126
|
+
"suppressHydrationWarning",
|
|
127
|
+
"ref",
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
/** Written as `name=""` when truthy, left out otherwise. */
|
|
131
|
+
const BOOLEAN = new Set([
|
|
132
|
+
"inert",
|
|
133
|
+
"allowFullScreen",
|
|
134
|
+
"async",
|
|
135
|
+
"autoPlay",
|
|
136
|
+
"controls",
|
|
137
|
+
"credentialless",
|
|
138
|
+
"default",
|
|
139
|
+
"defer",
|
|
140
|
+
"disabled",
|
|
141
|
+
"disablePictureInPicture",
|
|
142
|
+
"disableRemotePlayback",
|
|
143
|
+
"formNoValidate",
|
|
144
|
+
"hidden",
|
|
145
|
+
"loop",
|
|
146
|
+
"noModule",
|
|
147
|
+
"noValidate",
|
|
148
|
+
"open",
|
|
149
|
+
"playsInline",
|
|
150
|
+
"readOnly",
|
|
151
|
+
"required",
|
|
152
|
+
"reversed",
|
|
153
|
+
"scoped",
|
|
154
|
+
"seamless",
|
|
155
|
+
"itemScope",
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
/** Booleans React writes lower-cased (`autoFocus` → `autofocus=""`). */
|
|
159
|
+
const LOWERCASE_BOOLEAN = new Set(["autoFocus", "multiple", "muted"]);
|
|
160
|
+
|
|
161
|
+
/** Written as their string form, booleans included ("true"/"false"). */
|
|
162
|
+
const BOOLEANISH_STRING = new Set([
|
|
163
|
+
"contentEditable",
|
|
164
|
+
"spellCheck",
|
|
165
|
+
"draggable",
|
|
166
|
+
"value",
|
|
167
|
+
"autoReverse",
|
|
168
|
+
"externalResourcesRequired",
|
|
169
|
+
"focusable",
|
|
170
|
+
"preserveAlpha",
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
/** CSS properties whose numbers take no `px` (React's `unitlessNumbers`). */
|
|
174
|
+
const UNITLESS = new Set(
|
|
175
|
+
"animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(
|
|
176
|
+
" "
|
|
177
|
+
)
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
// React's VALID_ATTRIBUTE_NAME_REGEX (XML name characters), written as a
|
|
181
|
+
// string so the ranges stay readable escapes.
|
|
182
|
+
const NAME_START =
|
|
183
|
+
":A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
|
|
184
|
+
const VALID_ATTRIBUTE_NAME = new RegExp(
|
|
185
|
+
`^[${NAME_START}][${NAME_START}\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
/** Element names React accepts. */
|
|
189
|
+
export const VALID_TAG = /^[a-zA-Z][a-zA-Z:_.\-\d]*$/;
|
|
190
|
+
|
|
191
|
+
const JAVASCRIPT_URL =
|
|
192
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: React's pattern
|
|
193
|
+
/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;
|
|
194
|
+
|
|
195
|
+
const BLOCKED_URL =
|
|
196
|
+
"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')";
|
|
197
|
+
|
|
198
|
+
const sanitizeURL = (url: string) =>
|
|
199
|
+
JAVASCRIPT_URL.test(url) ? BLOCKED_URL : url;
|
|
200
|
+
|
|
201
|
+
/** HTML elements that never have children (`<img/>`). */
|
|
202
|
+
export const VOID_ELEMENTS = new Set([
|
|
203
|
+
"area",
|
|
204
|
+
"base",
|
|
205
|
+
"br",
|
|
206
|
+
"col",
|
|
207
|
+
"embed",
|
|
208
|
+
"hr",
|
|
209
|
+
"img",
|
|
210
|
+
"input",
|
|
211
|
+
"keygen",
|
|
212
|
+
"link",
|
|
213
|
+
"meta",
|
|
214
|
+
"param",
|
|
215
|
+
"source",
|
|
216
|
+
"track",
|
|
217
|
+
"wbr",
|
|
218
|
+
]);
|
|
219
|
+
|
|
220
|
+
const ESCAPED = /["'&<>]/;
|
|
221
|
+
|
|
222
|
+
/** Escapes `"&'<>` exactly as React does (`'` → `'`). */
|
|
223
|
+
export function escapeText(value: string): string {
|
|
224
|
+
if (!ESCAPED.test(value)) {
|
|
225
|
+
return value;
|
|
226
|
+
}
|
|
227
|
+
let out = "";
|
|
228
|
+
let last = 0;
|
|
229
|
+
for (let index = 0; index < value.length; index++) {
|
|
230
|
+
let entity: string;
|
|
231
|
+
switch (value.charCodeAt(index)) {
|
|
232
|
+
case 34:
|
|
233
|
+
entity = """;
|
|
234
|
+
break;
|
|
235
|
+
case 38:
|
|
236
|
+
entity = "&";
|
|
237
|
+
break;
|
|
238
|
+
case 39:
|
|
239
|
+
entity = "'";
|
|
240
|
+
break;
|
|
241
|
+
case 60:
|
|
242
|
+
entity = "<";
|
|
243
|
+
break;
|
|
244
|
+
case 62:
|
|
245
|
+
entity = ">";
|
|
246
|
+
break;
|
|
247
|
+
default:
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
out += value.slice(last, index) + entity;
|
|
251
|
+
last = index + 1;
|
|
252
|
+
}
|
|
253
|
+
return out + value.slice(last);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const isDropped = (value: unknown) =>
|
|
257
|
+
typeof value === "function" || typeof value === "symbol";
|
|
258
|
+
|
|
259
|
+
const hyphenated = new Map<string, string>();
|
|
260
|
+
const hyphenate = (name: string) => {
|
|
261
|
+
let css = hyphenated.get(name);
|
|
262
|
+
if (css === undefined) {
|
|
263
|
+
css = name
|
|
264
|
+
.replace(/([A-Z])/g, "-$1")
|
|
265
|
+
.toLowerCase()
|
|
266
|
+
.replace(/^ms-/, "-ms-");
|
|
267
|
+
hyphenated.set(name, css);
|
|
268
|
+
}
|
|
269
|
+
return css;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* A style object as CSS text (`{ marginTop: 4 }` → `margin-top:4px`), as
|
|
274
|
+
* React writes it. A string is taken as CSS text already (React itself
|
|
275
|
+
* refuses one).
|
|
276
|
+
*/
|
|
277
|
+
export function styleText(style: unknown): string {
|
|
278
|
+
if (typeof style === "string") {
|
|
279
|
+
return style;
|
|
280
|
+
}
|
|
281
|
+
if (typeof style !== "object" || style === null) {
|
|
282
|
+
return "";
|
|
283
|
+
}
|
|
284
|
+
let css = "";
|
|
285
|
+
for (const name of Object.keys(style)) {
|
|
286
|
+
const value = (style as Record<string, unknown>)[name];
|
|
287
|
+
if (
|
|
288
|
+
value === null ||
|
|
289
|
+
value === undefined ||
|
|
290
|
+
typeof value === "boolean" ||
|
|
291
|
+
value === ""
|
|
292
|
+
) {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
let declaration: string;
|
|
296
|
+
if (name.startsWith("--")) {
|
|
297
|
+
declaration = `${name}:${`${value}`.trim()}`;
|
|
298
|
+
} else {
|
|
299
|
+
const text =
|
|
300
|
+
typeof value === "number"
|
|
301
|
+
? value === 0 || UNITLESS.has(name)
|
|
302
|
+
? `${value}`
|
|
303
|
+
: `${value}px`
|
|
304
|
+
: `${value}`.trim();
|
|
305
|
+
declaration = `${hyphenate(name)}:${text}`;
|
|
306
|
+
}
|
|
307
|
+
css = css ? `${css};${declaration}` : declaration;
|
|
308
|
+
}
|
|
309
|
+
return css;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* The attribute a prop is written as, with its unescaped value, or null when
|
|
314
|
+
* React leaves it out.
|
|
315
|
+
*/
|
|
316
|
+
export function toAttribute(
|
|
317
|
+
prop: string,
|
|
318
|
+
value: unknown
|
|
319
|
+
): { name: string; value: string } | null {
|
|
320
|
+
if (value === null || value === undefined || SKIPPED.has(prop)) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
const renamed = STRING_ATTRIBUTES.get(prop);
|
|
324
|
+
if (renamed !== undefined) {
|
|
325
|
+
return isDropped(value) || typeof value === "boolean"
|
|
326
|
+
? null
|
|
327
|
+
: { name: renamed, value: `${value}` };
|
|
328
|
+
}
|
|
329
|
+
switch (prop) {
|
|
330
|
+
case "style": {
|
|
331
|
+
const css = styleText(value);
|
|
332
|
+
return css ? { name: "style", value: css } : null;
|
|
333
|
+
}
|
|
334
|
+
case "src":
|
|
335
|
+
case "href":
|
|
336
|
+
case "action":
|
|
337
|
+
case "formAction":
|
|
338
|
+
case "xlinkHref":
|
|
339
|
+
if ((prop === "src" || prop === "href") && value === "") {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
if (isDropped(value) || typeof value === "boolean") {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
name: prop === "xlinkHref" ? "xlink:href" : prop,
|
|
347
|
+
value: sanitizeURL(`${value}`),
|
|
348
|
+
};
|
|
349
|
+
case "capture":
|
|
350
|
+
case "download":
|
|
351
|
+
if (value === true) {
|
|
352
|
+
return { name: prop, value: "" };
|
|
353
|
+
}
|
|
354
|
+
return value === false || isDropped(value)
|
|
355
|
+
? null
|
|
356
|
+
: { name: prop, value: `${value}` };
|
|
357
|
+
case "cols":
|
|
358
|
+
case "rows":
|
|
359
|
+
case "size":
|
|
360
|
+
case "span":
|
|
361
|
+
return isDropped(value) ||
|
|
362
|
+
Number.isNaN(Number(value)) ||
|
|
363
|
+
!((value as number) >= 1)
|
|
364
|
+
? null
|
|
365
|
+
: { name: prop, value: `${value}` };
|
|
366
|
+
case "rowSpan":
|
|
367
|
+
case "start":
|
|
368
|
+
return isDropped(value) || Number.isNaN(Number(value))
|
|
369
|
+
? null
|
|
370
|
+
: { name: prop, value: `${value}` };
|
|
371
|
+
default:
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
if (LOWERCASE_BOOLEAN.has(prop)) {
|
|
375
|
+
return value && !isDropped(value)
|
|
376
|
+
? { name: prop.toLowerCase(), value: "" }
|
|
377
|
+
: null;
|
|
378
|
+
}
|
|
379
|
+
if (BOOLEANISH_STRING.has(prop)) {
|
|
380
|
+
return isDropped(value) ? null : { name: prop, value: `${value}` };
|
|
381
|
+
}
|
|
382
|
+
if (BOOLEAN.has(prop)) {
|
|
383
|
+
return value && !isDropped(value) ? { name: prop, value: "" } : null;
|
|
384
|
+
}
|
|
385
|
+
// Event handlers (onClick, onload…) are never written, whatever the value
|
|
386
|
+
if (
|
|
387
|
+
prop.length > 2 &&
|
|
388
|
+
(prop[0] === "o" || prop[0] === "O") &&
|
|
389
|
+
(prop[1] === "n" || prop[1] === "N")
|
|
390
|
+
) {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
const name = ALIASES.get(prop) ?? prop;
|
|
394
|
+
if (!VALID_ATTRIBUTE_NAME.test(name) || isDropped(value)) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
if (typeof value === "boolean") {
|
|
398
|
+
const prefix = name.toLowerCase().slice(0, 5);
|
|
399
|
+
if (prefix !== "data-" && prefix !== "aria-") {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return { name, value: `${value}` };
|
|
404
|
+
}
|