@vandenberghinc/volt 1.2.6 → 1.2.8
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/.libris/config.json +82 -0
- package/backend/dist/cjs/backend/src/blacklist.d.ts +12 -0
- package/backend/dist/cjs/backend/src/blacklist.js +78 -0
- package/backend/dist/cjs/backend/src/cli.d.ts +2 -0
- package/backend/dist/cjs/backend/src/cli.js +198 -0
- package/backend/dist/cjs/backend/src/database/collection.d.ts +1765 -0
- package/backend/dist/cjs/backend/src/database/collection.js +3301 -0
- package/backend/dist/cjs/backend/src/database/database.d.ts +92 -0
- package/backend/dist/cjs/backend/src/database/database.js +170 -0
- package/backend/dist/cjs/backend/src/database/document.d.ts +1 -0
- package/backend/dist/cjs/backend/src/database/document.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/cjs/backend/src/database/filters/filters.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.d.ts +1 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +443 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +355 -0
- package/backend/dist/cjs/backend/src/database/flatten.d.ts +78 -0
- package/backend/dist/cjs/backend/src/database/flatten.js +53 -0
- package/backend/dist/cjs/backend/src/database/flatten_test.d.ts +1 -0
- package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
- package/backend/dist/cjs/backend/src/database/quota/quoata_v2.d.ts +533 -0
- package/backend/dist/cjs/backend/src/database/quota/quoata_v2.js +1046 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +551 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.js +1108 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +1087 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +412 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.js +745 -0
- package/backend/dist/cjs/backend/src/endpoint.d.ts +346 -0
- package/backend/dist/cjs/backend/src/endpoint.js +468 -0
- package/backend/dist/cjs/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/cjs/backend/src/errors/index.js +25 -0
- package/backend/dist/cjs/backend/src/errors/internal_external.d.ts +52 -0
- package/backend/dist/cjs/backend/src/errors/internal_external.js +95 -0
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +41 -0
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.js +47 -0
- package/backend/dist/cjs/backend/src/errors/system_error.d.ts +261 -0
- package/backend/dist/cjs/backend/src/errors/system_error.js +436 -0
- package/backend/dist/cjs/backend/src/events.d.ts +97 -0
- package/backend/dist/cjs/backend/src/events.js +15 -0
- package/backend/dist/cjs/backend/src/frontend.d.ts +13 -0
- package/backend/dist/cjs/backend/src/frontend.js +56 -0
- package/backend/dist/cjs/backend/src/image_endpoint.d.ts +44 -0
- package/backend/dist/cjs/backend/src/image_endpoint.js +185 -0
- package/backend/dist/cjs/backend/src/index.d.ts +23 -0
- package/backend/dist/cjs/backend/src/index.js +70 -0
- package/backend/dist/cjs/backend/src/logger.d.ts +5 -0
- package/backend/dist/cjs/backend/src/logger.js +15 -0
- package/backend/dist/cjs/backend/src/meta.d.ts +112 -0
- package/backend/dist/cjs/backend/src/meta.js +181 -0
- package/backend/dist/cjs/backend/src/payments/paddle.d.ts +329 -0
- package/backend/dist/cjs/backend/src/payments/paddle.js +1996 -0
- package/backend/dist/cjs/backend/src/payments/stripe/checkout.d.ts +113 -0
- package/backend/dist/cjs/backend/src/payments/stripe/checkout.js +295 -0
- package/backend/dist/cjs/backend/src/payments/stripe/customers.d.ts +17 -0
- package/backend/dist/cjs/backend/src/payments/stripe/customers.js +164 -0
- package/backend/dist/cjs/backend/src/payments/stripe/error.d.ts +74 -0
- package/backend/dist/cjs/backend/src/payments/stripe/error.js +64 -0
- package/backend/dist/cjs/backend/src/payments/stripe/events.d.ts +155 -0
- package/backend/dist/cjs/backend/src/payments/stripe/events.js +15 -0
- package/backend/dist/cjs/backend/src/payments/stripe/meters.d.ts +105 -0
- package/backend/dist/cjs/backend/src/payments/stripe/meters.js +230 -0
- package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.d.ts +58 -0
- package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.js +109 -0
- package/backend/dist/cjs/backend/src/payments/stripe/products.d.ts +519 -0
- package/backend/dist/cjs/backend/src/payments/stripe/products.js +650 -0
- package/backend/dist/cjs/backend/src/payments/stripe/stripe.d.ts +215 -0
- package/backend/dist/cjs/backend/src/payments/stripe/stripe.js +468 -0
- package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.d.ts +172 -0
- package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.js +557 -0
- package/backend/dist/cjs/backend/src/payments/stripe/utils.d.ts +63 -0
- package/backend/dist/cjs/backend/src/payments/stripe/utils.js +118 -0
- package/backend/dist/cjs/backend/src/payments/stripe/webhooks.d.ts +105 -0
- package/backend/dist/cjs/backend/src/payments/stripe/webhooks.js +627 -0
- package/backend/dist/cjs/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/cjs/backend/src/plugins/browser.js +15 -0
- package/backend/dist/cjs/backend/src/plugins/communication.d.ts +70 -0
- package/backend/dist/cjs/backend/src/plugins/communication.js +196 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +255 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.js +381 -0
- package/backend/dist/cjs/backend/src/plugins/mail/ui.d.ts +297 -0
- package/backend/dist/cjs/backend/src/plugins/mail/ui.js +1370 -0
- package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/cjs/backend/src/plugins/pdf.js +1456 -0
- package/backend/dist/cjs/backend/src/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/cjs/backend/src/plugins/thread_monitor.js +116 -0
- package/backend/dist/cjs/backend/src/rate_limit.d.ts +148 -0
- package/backend/dist/cjs/backend/src/rate_limit.js +543 -0
- package/backend/dist/cjs/backend/src/route.d.ts +39 -0
- package/backend/dist/cjs/backend/src/route.js +172 -0
- package/backend/dist/cjs/backend/src/server.d.ts +502 -0
- package/backend/dist/cjs/backend/src/server.js +1710 -0
- package/backend/dist/cjs/backend/src/server.old.d.ts +594 -0
- package/backend/dist/cjs/backend/src/server.old.js +2058 -0
- package/backend/dist/cjs/backend/src/splash_screen.d.ts +93 -0
- package/backend/dist/cjs/backend/src/splash_screen.js +119 -0
- package/backend/dist/cjs/backend/src/status.d.ts +89 -0
- package/backend/dist/cjs/backend/src/status.js +211 -0
- package/backend/dist/cjs/backend/src/stream.d.ts +494 -0
- package/backend/dist/cjs/backend/src/stream.js +1370 -0
- package/backend/dist/cjs/backend/src/users.d.ts +926 -0
- package/backend/dist/cjs/backend/src/users.js +2223 -0
- package/backend/dist/cjs/backend/src/utils.d.ts +22 -0
- package/backend/dist/cjs/backend/src/utils.js +626 -0
- package/backend/dist/cjs/backend/src/view.d.ts +115 -0
- package/backend/dist/cjs/backend/src/view.js +519 -0
- package/backend/dist/cjs/backend/src/vinc.d.ts +6 -0
- package/backend/dist/cjs/backend/src/vinc.js +40 -0
- package/backend/dist/cjs/backend/src/volt.d.ts +24 -0
- package/backend/dist/cjs/backend/src/volt.js +72 -0
- package/backend/dist/cjs/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/cjs/frontend/src/modules/request.js +99 -0
- package/backend/dist/cjs/package.json +1 -0
- package/backend/dist/esm/backend/src/blacklist.d.ts +12 -0
- package/backend/dist/esm/backend/src/blacklist.js +52 -0
- package/backend/dist/esm/backend/src/cli.d.ts +2 -0
- package/backend/dist/esm/backend/src/cli.js +211 -0
- package/backend/dist/esm/backend/src/database/collection.d.ts +1765 -0
- package/backend/dist/esm/backend/src/database/collection.js +3779 -0
- package/backend/dist/esm/backend/src/database/database.d.ts +92 -0
- package/backend/dist/esm/backend/src/database/database.js +214 -0
- package/backend/dist/esm/backend/src/database/document.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/document.js +558 -0
- package/backend/dist/esm/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/esm/backend/src/database/filters/filters.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.js +3 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +505 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +712 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +44 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +415 -0
- package/backend/dist/esm/backend/src/database/flatten.d.ts +78 -0
- package/backend/dist/esm/backend/src/database/flatten.js +22 -0
- package/backend/dist/esm/backend/src/database/flatten_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/flatten_test.js +174 -0
- package/backend/dist/esm/backend/src/database/quota/quoata_v2.d.ts +533 -0
- package/backend/dist/esm/backend/src/database/quota/quoata_v2.js +1155 -0
- package/backend/dist/esm/backend/src/database/quota/quota.d.ts +551 -0
- package/backend/dist/esm/backend/src/database/quota/quota.js +1219 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.js +1242 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +412 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.js +810 -0
- package/backend/dist/esm/backend/src/endpoint.d.ts +346 -0
- package/backend/dist/esm/backend/src/endpoint.js +479 -0
- package/backend/dist/esm/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/esm/backend/src/errors/index.js +7 -0
- package/backend/dist/esm/backend/src/errors/internal_external.d.ts +52 -0
- package/backend/dist/esm/backend/src/errors/internal_external.js +86 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +41 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +33 -0
- package/backend/dist/esm/backend/src/errors/system_error.d.ts +261 -0
- package/backend/dist/esm/backend/src/errors/system_error.js +444 -0
- package/backend/dist/esm/backend/src/events.d.ts +97 -0
- package/backend/dist/esm/backend/src/events.js +5 -0
- package/backend/dist/esm/backend/src/frontend.d.ts +13 -0
- package/backend/dist/esm/backend/src/frontend.js +23 -0
- package/backend/dist/esm/backend/src/image_endpoint.d.ts +44 -0
- package/backend/dist/esm/backend/src/image_endpoint.js +196 -0
- package/backend/dist/esm/backend/src/index.d.ts +23 -0
- package/backend/dist/esm/backend/src/index.js +26 -0
- package/backend/dist/esm/backend/src/logger.d.ts +5 -0
- package/backend/dist/esm/backend/src/logger.js +8 -0
- package/backend/dist/esm/backend/src/meta.d.ts +112 -0
- package/backend/dist/esm/backend/src/meta.js +152 -0
- package/backend/dist/esm/backend/src/payments/paddle.d.ts +329 -0
- package/backend/dist/esm/backend/src/payments/paddle.js +2276 -0
- package/backend/dist/esm/backend/src/payments/stripe/checkout.d.ts +113 -0
- package/backend/dist/esm/backend/src/payments/stripe/checkout.js +356 -0
- package/backend/dist/esm/backend/src/payments/stripe/customers.d.ts +17 -0
- package/backend/dist/esm/backend/src/payments/stripe/customers.js +193 -0
- package/backend/dist/esm/backend/src/payments/stripe/error.d.ts +74 -0
- package/backend/dist/esm/backend/src/payments/stripe/error.js +51 -0
- package/backend/dist/esm/backend/src/payments/stripe/events.d.ts +155 -0
- package/backend/dist/esm/backend/src/payments/stripe/events.js +5 -0
- package/backend/dist/esm/backend/src/payments/stripe/meters.d.ts +105 -0
- package/backend/dist/esm/backend/src/payments/stripe/meters.js +318 -0
- package/backend/dist/esm/backend/src/payments/stripe/payment_methods.d.ts +58 -0
- package/backend/dist/esm/backend/src/payments/stripe/payment_methods.js +135 -0
- package/backend/dist/esm/backend/src/payments/stripe/products.d.ts +519 -0
- package/backend/dist/esm/backend/src/payments/stripe/products.js +896 -0
- package/backend/dist/esm/backend/src/payments/stripe/stripe.d.ts +215 -0
- package/backend/dist/esm/backend/src/payments/stripe/stripe.js +464 -0
- package/backend/dist/esm/backend/src/payments/stripe/subscriptions.d.ts +172 -0
- package/backend/dist/esm/backend/src/payments/stripe/subscriptions.js +754 -0
- package/backend/dist/esm/backend/src/payments/stripe/utils.d.ts +63 -0
- package/backend/dist/esm/backend/src/payments/stripe/utils.js +131 -0
- package/backend/dist/esm/backend/src/payments/stripe/webhooks.d.ts +105 -0
- package/backend/dist/esm/backend/src/payments/stripe/webhooks.js +752 -0
- package/backend/dist/esm/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/esm/backend/src/plugins/browser.js +170 -0
- package/backend/dist/esm/backend/src/plugins/communication.d.ts +70 -0
- package/backend/dist/esm/backend/src/plugins/communication.js +169 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +255 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.js +396 -0
- package/backend/dist/esm/backend/src/plugins/mail/ui.d.ts +297 -0
- package/backend/dist/esm/backend/src/plugins/mail/ui.js +1400 -0
- package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/esm/backend/src/plugins/pdf.js +1694 -0
- package/backend/dist/esm/backend/src/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm/backend/src/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm/backend/src/rate_limit.d.ts +148 -0
- package/backend/dist/esm/backend/src/rate_limit.js +667 -0
- package/backend/dist/esm/backend/src/route.d.ts +39 -0
- package/backend/dist/esm/backend/src/route.js +222 -0
- package/backend/dist/esm/backend/src/server.d.ts +502 -0
- package/backend/dist/esm/backend/src/server.js +2031 -0
- package/backend/dist/esm/backend/src/server.old.d.ts +594 -0
- package/backend/dist/esm/backend/src/server.old.js +2630 -0
- package/backend/dist/esm/backend/src/splash_screen.d.ts +93 -0
- package/backend/dist/esm/backend/src/splash_screen.js +156 -0
- package/backend/dist/esm/backend/src/status.d.ts +89 -0
- package/backend/dist/esm/backend/src/status.js +213 -0
- package/backend/dist/esm/backend/src/stream.d.ts +494 -0
- package/backend/dist/esm/backend/src/stream.js +1611 -0
- package/backend/dist/esm/backend/src/users.d.ts +926 -0
- package/backend/dist/esm/backend/src/users.js +2423 -0
- package/backend/dist/esm/backend/src/utils.d.ts +22 -0
- package/backend/dist/esm/backend/src/utils.js +463 -0
- package/backend/dist/esm/backend/src/view.d.ts +115 -0
- package/backend/dist/esm/backend/src/view.js +584 -0
- package/backend/dist/esm/backend/src/vinc.d.ts +6 -0
- package/backend/dist/esm/backend/src/vinc.js +6 -0
- package/backend/dist/esm/backend/src/volt.d.ts +24 -0
- package/backend/dist/esm/backend/src/volt.js +27 -0
- package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/esm/frontend/src/modules/request.js +117 -0
- package/backend/old/file_watcher.ts +359 -0
- package/backend/old/request.deprc.js +626 -0
- package/backend/old/response.deprc.js +354 -0
- package/frontend/dist/backend/src/database/collection.d.ts +1765 -0
- package/frontend/dist/backend/src/database/collection.js +3779 -0
- package/frontend/dist/backend/src/database/database.d.ts +92 -0
- package/frontend/dist/backend/src/database/database.js +214 -0
- package/frontend/dist/backend/src/database/filters/filters.d.ts +6 -0
- package/frontend/dist/backend/src/database/filters/filters.js +1 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.js +3 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.js +5 -0
- package/frontend/dist/backend/src/database/flatten.d.ts +78 -0
- package/frontend/dist/backend/src/database/flatten.js +22 -0
- package/frontend/dist/backend/src/endpoint.d.ts +346 -0
- package/frontend/dist/backend/src/endpoint.js +479 -0
- package/frontend/dist/backend/src/errors/index.d.ts +7 -0
- package/frontend/dist/backend/src/errors/index.js +7 -0
- package/frontend/dist/backend/src/errors/internal_external.d.ts +52 -0
- package/frontend/dist/backend/src/errors/internal_external.js +86 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +41 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.js +33 -0
- package/frontend/dist/backend/src/errors/system_error.d.ts +261 -0
- package/frontend/dist/backend/src/errors/system_error.js +444 -0
- package/frontend/dist/backend/src/events.d.ts +97 -0
- package/frontend/dist/backend/src/events.js +5 -0
- package/frontend/dist/backend/src/frontend.d.ts +13 -0
- package/frontend/dist/backend/src/frontend.js +23 -0
- package/frontend/dist/backend/src/image_endpoint.d.ts +44 -0
- package/frontend/dist/backend/src/image_endpoint.js +196 -0
- package/frontend/dist/backend/src/meta.d.ts +112 -0
- package/frontend/dist/backend/src/meta.js +152 -0
- package/frontend/dist/backend/src/payments/paddle.d.ts +329 -0
- package/frontend/dist/backend/src/payments/paddle.js +2276 -0
- package/frontend/dist/backend/src/payments/stripe/checkout.d.ts +113 -0
- package/frontend/dist/backend/src/payments/stripe/checkout.js +356 -0
- package/frontend/dist/backend/src/payments/stripe/customers.d.ts +17 -0
- package/frontend/dist/backend/src/payments/stripe/customers.js +193 -0
- package/frontend/dist/backend/src/payments/stripe/error.d.ts +74 -0
- package/frontend/dist/backend/src/payments/stripe/error.js +51 -0
- package/frontend/dist/backend/src/payments/stripe/events.d.ts +155 -0
- package/frontend/dist/backend/src/payments/stripe/events.js +5 -0
- package/frontend/dist/backend/src/payments/stripe/meters.d.ts +105 -0
- package/frontend/dist/backend/src/payments/stripe/meters.js +318 -0
- package/frontend/dist/backend/src/payments/stripe/payment_methods.d.ts +58 -0
- package/frontend/dist/backend/src/payments/stripe/payment_methods.js +135 -0
- package/frontend/dist/backend/src/payments/stripe/products.d.ts +519 -0
- package/frontend/dist/backend/src/payments/stripe/products.js +896 -0
- package/frontend/dist/backend/src/payments/stripe/stripe.d.ts +215 -0
- package/frontend/dist/backend/src/payments/stripe/stripe.js +464 -0
- package/frontend/dist/backend/src/payments/stripe/subscriptions.d.ts +172 -0
- package/frontend/dist/backend/src/payments/stripe/subscriptions.js +754 -0
- package/frontend/dist/backend/src/payments/stripe/utils.d.ts +63 -0
- package/frontend/dist/backend/src/payments/stripe/utils.js +131 -0
- package/frontend/dist/backend/src/payments/stripe/webhooks.d.ts +105 -0
- package/frontend/dist/backend/src/payments/stripe/webhooks.js +752 -0
- package/frontend/dist/backend/src/plugins/mail/mail.d.ts +255 -0
- package/frontend/dist/backend/src/plugins/mail/mail.js +396 -0
- package/frontend/dist/backend/src/plugins/mail/ui.d.ts +297 -0
- package/frontend/dist/backend/src/plugins/mail/ui.js +1400 -0
- package/frontend/dist/backend/src/rate_limit.d.ts +148 -0
- package/frontend/dist/backend/src/rate_limit.js +667 -0
- package/frontend/dist/backend/src/route.d.ts +39 -0
- package/frontend/dist/backend/src/route.js +222 -0
- package/frontend/dist/backend/src/server.d.ts +502 -0
- package/frontend/dist/backend/src/server.js +2031 -0
- package/frontend/dist/backend/src/splash_screen.d.ts +93 -0
- package/frontend/dist/backend/src/splash_screen.js +156 -0
- package/frontend/dist/backend/src/status.d.ts +89 -0
- package/frontend/dist/backend/src/status.js +213 -0
- package/frontend/dist/backend/src/stream.d.ts +494 -0
- package/frontend/dist/backend/src/stream.js +1611 -0
- package/frontend/dist/backend/src/users.d.ts +926 -0
- package/frontend/dist/backend/src/users.js +2423 -0
- package/frontend/dist/backend/src/utils.d.ts +22 -0
- package/frontend/dist/backend/src/utils.js +463 -0
- package/frontend/dist/backend/src/view.d.ts +115 -0
- package/frontend/dist/backend/src/view.js +584 -0
- package/frontend/dist/frontend/src/css/adyen.css +92 -0
- package/frontend/dist/frontend/src/css/volt.css +75 -0
- package/frontend/dist/frontend/src/elements/base.d.ts +3743 -0
- package/frontend/dist/frontend/src/elements/base.js +12151 -0
- package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
- package/frontend/dist/frontend/src/elements/module.js +216 -0
- package/frontend/dist/frontend/src/elements/register_element.d.ts +3 -0
- package/frontend/dist/frontend/src/elements/register_element.js +22 -0
- package/frontend/dist/frontend/src/elements/resize_query_manager.d.ts +0 -0
- package/frontend/dist/frontend/src/elements/resize_query_manager.js +150 -0
- package/frontend/dist/frontend/src/elements/types.d.ts +52 -0
- package/frontend/dist/frontend/src/elements/types.js +5 -0
- package/frontend/dist/frontend/src/index.d.ts +21 -0
- package/frontend/dist/frontend/src/index.js +29 -0
- package/frontend/dist/frontend/src/modules/attachment.d.ts +126 -0
- package/frontend/dist/frontend/src/modules/attachment.js +306 -0
- package/frontend/dist/frontend/src/modules/auth.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/auth.js +80 -0
- package/frontend/dist/frontend/src/modules/color.d.ts +160 -0
- package/frontend/dist/frontend/src/modules/color.js +316 -0
- package/frontend/dist/frontend/src/modules/compression.d.ts +39 -0
- package/frontend/dist/frontend/src/modules/compression.js +102 -0
- package/frontend/dist/frontend/src/modules/cookies.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/cookies.js +143 -0
- package/frontend/dist/frontend/src/modules/events.d.ts +31 -0
- package/frontend/dist/frontend/src/modules/events.js +79 -0
- package/frontend/dist/frontend/src/modules/google.d.ts +23 -0
- package/frontend/dist/frontend/src/modules/google.js +52 -0
- package/frontend/dist/frontend/src/modules/meta.d.ts +14 -0
- package/frontend/dist/frontend/src/modules/meta.js +48 -0
- package/frontend/dist/frontend/src/modules/paddle.d.ts +1207 -0
- package/frontend/dist/frontend/src/modules/paddle.js +2594 -0
- package/frontend/dist/frontend/src/modules/request.d.ts +70 -0
- package/frontend/dist/frontend/src/modules/request.js +117 -0
- package/frontend/dist/frontend/src/modules/settings.d.ts +3 -0
- package/frontend/dist/frontend/src/modules/settings.js +5 -0
- package/frontend/dist/frontend/src/modules/statics.d.ts +21 -0
- package/frontend/dist/frontend/src/modules/statics.js +43 -0
- package/frontend/dist/frontend/src/modules/stripe/cart.d.ts +112 -0
- package/frontend/dist/frontend/src/modules/stripe/cart.js +321 -0
- package/frontend/dist/frontend/src/modules/stripe/checkout.d.ts +7 -0
- package/frontend/dist/frontend/src/modules/stripe/checkout.js +37 -0
- package/frontend/dist/frontend/src/modules/stripe/index.m.d.ts +6 -0
- package/frontend/dist/frontend/src/modules/stripe/index.m.js +6 -0
- package/frontend/dist/frontend/src/modules/stripe/payments.d.ts +58 -0
- package/frontend/dist/frontend/src/modules/stripe/payments.js +92 -0
- package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
- package/frontend/dist/frontend/src/modules/support.js +53 -0
- package/frontend/dist/frontend/src/modules/theme.d.ts +133 -0
- package/frontend/dist/frontend/src/modules/theme.js +406 -0
- package/frontend/dist/frontend/src/modules/themes.d.ts +12 -0
- package/frontend/dist/frontend/src/modules/themes.js +22 -0
- package/frontend/dist/frontend/src/modules/user.d.ts +164 -0
- package/frontend/dist/frontend/src/modules/user.js +270 -0
- package/frontend/dist/frontend/src/modules/utils.d.ts +176 -0
- package/frontend/dist/frontend/src/modules/utils.js +569 -0
- package/frontend/dist/frontend/src/types/gradient.d.ts +29 -0
- package/frontend/dist/frontend/src/types/gradient.js +79 -0
- package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
- package/frontend/dist/frontend/src/ui/border_button.js +228 -0
- package/frontend/dist/frontend/src/ui/button.d.ts +241 -0
- package/frontend/dist/frontend/src/ui/button.js +682 -0
- package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
- package/frontend/dist/frontend/src/ui/canvas.js +444 -0
- package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
- package/frontend/dist/frontend/src/ui/checkbox.js +321 -0
- package/frontend/dist/frontend/src/ui/code.d.ts +235 -0
- package/frontend/dist/frontend/src/ui/code.js +1007 -0
- package/frontend/dist/frontend/src/ui/context_menu.d.ts +36 -0
- package/frontend/dist/frontend/src/ui/context_menu.js +205 -0
- package/frontend/dist/frontend/src/ui/css.d.ts +16 -0
- package/frontend/dist/frontend/src/ui/css.js +48 -0
- package/frontend/dist/frontend/src/ui/divider.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/divider.js +78 -0
- package/frontend/dist/frontend/src/ui/dropdown.d.ts +176 -0
- package/frontend/dist/frontend/src/ui/dropdown.js +481 -0
- package/frontend/dist/frontend/src/ui/for_each.d.ts +37 -0
- package/frontend/dist/frontend/src/ui/for_each.js +92 -0
- package/frontend/dist/frontend/src/ui/form.d.ts +34 -0
- package/frontend/dist/frontend/src/ui/form.js +233 -0
- package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
- package/frontend/dist/frontend/src/ui/frame_modes.js +108 -0
- package/frontend/dist/frontend/src/ui/google_map.d.ts +24 -0
- package/frontend/dist/frontend/src/ui/google_map.js +106 -0
- package/frontend/dist/frontend/src/ui/gradient.d.ts +25 -0
- package/frontend/dist/frontend/src/ui/gradient.js +131 -0
- package/frontend/dist/frontend/src/ui/image.d.ts +111 -0
- package/frontend/dist/frontend/src/ui/image.js +576 -0
- package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
- package/frontend/dist/frontend/src/ui/input.js +1201 -0
- package/frontend/dist/frontend/src/ui/link.d.ts +25 -0
- package/frontend/dist/frontend/src/ui/link.js +140 -0
- package/frontend/dist/frontend/src/ui/list.d.ts +37 -0
- package/frontend/dist/frontend/src/ui/list.js +170 -0
- package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
- package/frontend/dist/frontend/src/ui/loader_button.js +193 -0
- package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
- package/frontend/dist/frontend/src/ui/loaders.js +157 -0
- package/frontend/dist/frontend/src/ui/popup.d.ts +94 -0
- package/frontend/dist/frontend/src/ui/popup.js +510 -0
- package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
- package/frontend/dist/frontend/src/ui/pseudo.js +154 -0
- package/frontend/dist/frontend/src/ui/scroller.d.ts +105 -0
- package/frontend/dist/frontend/src/ui/scroller.js +1253 -0
- package/frontend/dist/frontend/src/ui/slider.d.ts +45 -0
- package/frontend/dist/frontend/src/ui/slider.js +217 -0
- package/frontend/dist/frontend/src/ui/spacer.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/spacer.js +78 -0
- package/frontend/dist/frontend/src/ui/span.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/span.js +73 -0
- package/frontend/dist/frontend/src/ui/stack.d.ts +66 -0
- package/frontend/dist/frontend/src/ui/stack.js +335 -0
- package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
- package/frontend/dist/frontend/src/ui/steps.js +308 -0
- package/frontend/dist/frontend/src/ui/style.d.ts +17 -0
- package/frontend/dist/frontend/src/ui/style.js +73 -0
- package/frontend/dist/frontend/src/ui/switch.d.ts +69 -0
- package/frontend/dist/frontend/src/ui/switch.js +357 -0
- package/frontend/dist/frontend/src/ui/table.d.ts +100 -0
- package/frontend/dist/frontend/src/ui/table.js +405 -0
- package/frontend/dist/frontend/src/ui/tabs.d.ts +111 -0
- package/frontend/dist/frontend/src/ui/tabs.js +424 -0
- package/frontend/dist/frontend/src/ui/text.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/text.js +83 -0
- package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
- package/frontend/dist/frontend/src/ui/title.js +272 -0
- package/frontend/dist/frontend/src/ui/ui.d.ts +35 -0
- package/frontend/dist/frontend/src/ui/ui.js +38 -0
- package/frontend/dist/frontend/src/ui/view.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/view.js +88 -0
- package/frontend/dist/frontend/src/volt.d.ts +20 -0
- package/frontend/dist/frontend/src/volt.js +27 -0
- package/frontend/examples/theme/theme.ts +58 -0
- package/frontend/tools/bundle_d_ts.js +71 -0
- package/frontend/tools/convert_to_jsdoc_input.txt +9452 -0
- package/frontend/tools/convert_to_jsdoc_output.txt +7626 -0
- package/frontend/tools/convert_to_jsdoc_tmp.js +345 -0
- package/frontend/tools/scan_mixed_imports.js +69 -0
- package/package.json +1 -5
|
@@ -0,0 +1,1456 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var stdin_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
16
|
+
const import_meta = {};
|
|
17
|
+
const { vlib, vhighlight } = require("../vinc.js");
|
|
18
|
+
const { jsPDF } = require("jspdf");
|
|
19
|
+
const libfs = require("fs");
|
|
20
|
+
const PDF = {
|
|
21
|
+
// Use pixels instead of points (NOT ADVISED).
|
|
22
|
+
// use_pixels: false,
|
|
23
|
+
// Get opacity from hex as a floating number 0/1, returns `null` on no opacity.
|
|
24
|
+
hex_opacity(hex) {
|
|
25
|
+
if (typeof hex !== "string" && hex instanceof String === false || hex.charAt(0) !== "#" || hex.length <= 7) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const opacity = parseInt(hex.slice(-2)) / 100;
|
|
29
|
+
return isNaN(opacity) ? null : opacity;
|
|
30
|
+
},
|
|
31
|
+
// Convert hex to rgb(a), since pdfkit does not support a hex with opacity.
|
|
32
|
+
hex_to_rgb(hex) {
|
|
33
|
+
if (typeof hex !== "string" && hex instanceof String === false) {
|
|
34
|
+
return hex;
|
|
35
|
+
}
|
|
36
|
+
if (hex.charAt(0) !== "#") {
|
|
37
|
+
return hex;
|
|
38
|
+
}
|
|
39
|
+
hex = hex.slice(1);
|
|
40
|
+
let alpha = 1;
|
|
41
|
+
if (hex.length > 6) {
|
|
42
|
+
alpha = parseInt(hex.slice(-2)) / 100;
|
|
43
|
+
hex = hex.slice(0, -2);
|
|
44
|
+
}
|
|
45
|
+
const bigint = parseInt(hex, 16);
|
|
46
|
+
const r = bigint >> 16 & 255;
|
|
47
|
+
const g = bigint >> 8 & 255;
|
|
48
|
+
const b = bigint & 255;
|
|
49
|
+
if (alpha != 1) {
|
|
50
|
+
return [r, g, b, alpha];
|
|
51
|
+
}
|
|
52
|
+
return [r, g, b];
|
|
53
|
+
},
|
|
54
|
+
hex_to_cmyk(hex) {
|
|
55
|
+
if (typeof hex !== "string" && hex instanceof String === false) {
|
|
56
|
+
return hex;
|
|
57
|
+
}
|
|
58
|
+
if (hex.charAt(0) !== "#") {
|
|
59
|
+
return hex;
|
|
60
|
+
}
|
|
61
|
+
hex = hex.slice(1);
|
|
62
|
+
let alpha = 1;
|
|
63
|
+
if (hex.length > 6) {
|
|
64
|
+
alpha = parseInt(hex.slice(-2)) / 100;
|
|
65
|
+
hex = hex.slice(0, -2);
|
|
66
|
+
}
|
|
67
|
+
const bigint = parseInt(hex, 16);
|
|
68
|
+
let r = bigint >> 16 & 255;
|
|
69
|
+
let g = bigint >> 8 & 255;
|
|
70
|
+
let b = bigint & 255;
|
|
71
|
+
var computedC = 0;
|
|
72
|
+
var computedM = 0;
|
|
73
|
+
var computedY = 0;
|
|
74
|
+
var computedK = 0;
|
|
75
|
+
r = parseInt(("" + r).replace(/\s/g, ""), 10);
|
|
76
|
+
g = parseInt(("" + g).replace(/\s/g, ""), 10);
|
|
77
|
+
b = parseInt(("" + b).replace(/\s/g, ""), 10);
|
|
78
|
+
if (r == null || g == null || b == null || isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
79
|
+
console.error("Please enter numeric RGB values!");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (r < 0 || g < 0 || b < 0 || r > 255 || g > 255 || b > 255) {
|
|
83
|
+
console.error("RGB values must be in the range 0 to 255.");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (r == 0 && g == 0 && b == 0) {
|
|
87
|
+
computedK = 1;
|
|
88
|
+
return [0, 0, 0, 1];
|
|
89
|
+
}
|
|
90
|
+
computedC = 1 - r / 255;
|
|
91
|
+
computedM = 1 - g / 255;
|
|
92
|
+
computedY = 1 - b / 255;
|
|
93
|
+
var minCMY = Math.min(computedC, Math.min(computedM, computedY));
|
|
94
|
+
computedC = Math.round((computedC - minCMY) / (1 - minCMY) * 100);
|
|
95
|
+
computedM = Math.round((computedM - minCMY) / (1 - minCMY) * 100);
|
|
96
|
+
computedY = Math.round((computedY - minCMY) / (1 - minCMY) * 100);
|
|
97
|
+
computedK = Math.round(minCMY * 100);
|
|
98
|
+
return [computedC, computedM, computedY, computedK];
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
class Computed {
|
|
102
|
+
static ids = 0;
|
|
103
|
+
constructor({
|
|
104
|
+
start_x,
|
|
105
|
+
start_y,
|
|
106
|
+
resume_x,
|
|
107
|
+
resume_y,
|
|
108
|
+
inner_width = 0,
|
|
109
|
+
// inner width without padding or margin.
|
|
110
|
+
inner_height = 0,
|
|
111
|
+
// inner height without padding or margin.
|
|
112
|
+
is_absolute = false,
|
|
113
|
+
is_wrapped = false,
|
|
114
|
+
start_page = 0,
|
|
115
|
+
end_page = 0,
|
|
116
|
+
_padding,
|
|
117
|
+
_margin
|
|
118
|
+
}) {
|
|
119
|
+
this.start_x = start_x;
|
|
120
|
+
this.start_y = start_y;
|
|
121
|
+
this.resume_x = resume_x;
|
|
122
|
+
this.resume_y = resume_y;
|
|
123
|
+
this.inner_width = inner_width;
|
|
124
|
+
this.inner_height = inner_height;
|
|
125
|
+
this.is_absolute = is_absolute;
|
|
126
|
+
this.is_wrapped = is_wrapped;
|
|
127
|
+
this.start_page = start_page;
|
|
128
|
+
this.end_page = end_page;
|
|
129
|
+
this.allow_force_same_page = true;
|
|
130
|
+
this._margin = _margin;
|
|
131
|
+
this._padding = _padding;
|
|
132
|
+
++Computed.ids;
|
|
133
|
+
this._id = Computed.ids;
|
|
134
|
+
}
|
|
135
|
+
// Get end x/y.
|
|
136
|
+
get end_x() {
|
|
137
|
+
return this.start_x + this._margin[1] + this._margin[3] + this._padding[1] + this._padding[3] + this.inner_width;
|
|
138
|
+
}
|
|
139
|
+
get end_y() {
|
|
140
|
+
return this.start_y + this._margin[0] + this._margin[2] + this._padding[0] + this._padding[2] + this.inner_height;
|
|
141
|
+
}
|
|
142
|
+
// Start and end x/y from AFTER the margin.
|
|
143
|
+
get margin_start_x() {
|
|
144
|
+
return this.start_x + this._margin[3];
|
|
145
|
+
}
|
|
146
|
+
get margin_end_x() {
|
|
147
|
+
return this.end_x - this._margin[1];
|
|
148
|
+
}
|
|
149
|
+
get margin_start_y() {
|
|
150
|
+
return this.start_y + this._margin[0];
|
|
151
|
+
}
|
|
152
|
+
get margin_end_y() {
|
|
153
|
+
return this.end_y - this._margin[2];
|
|
154
|
+
}
|
|
155
|
+
// Start and end x/y from AFTER the padding and margin.
|
|
156
|
+
get padding_start_x() {
|
|
157
|
+
return this.start_x + this._margin[3] + this._padding[3];
|
|
158
|
+
}
|
|
159
|
+
get padding_end_x() {
|
|
160
|
+
return this.end_x - this._margin[1] - this._padding[1];
|
|
161
|
+
}
|
|
162
|
+
get padding_start_y() {
|
|
163
|
+
return this.start_y + this._margin[0] + this._padding[0];
|
|
164
|
+
}
|
|
165
|
+
get padding_end_y() {
|
|
166
|
+
return this.end_y - this._margin[2] - this._padding[2];
|
|
167
|
+
}
|
|
168
|
+
// As string for debugging.
|
|
169
|
+
toString() {
|
|
170
|
+
return {
|
|
171
|
+
id: this._id,
|
|
172
|
+
start_x: this.start_x,
|
|
173
|
+
start_y: this.start_y,
|
|
174
|
+
resume_x: this.resume_x,
|
|
175
|
+
resume_y: this.resume_y,
|
|
176
|
+
inner_width: this.inner_width,
|
|
177
|
+
inner_height: this.inner_height,
|
|
178
|
+
is_absolute: this.is_absolute,
|
|
179
|
+
is_wrapped: this.is_wrapped,
|
|
180
|
+
start_page: this.start_page,
|
|
181
|
+
end_page: this.end_page,
|
|
182
|
+
_margin: this._margin,
|
|
183
|
+
_padding: this._padding,
|
|
184
|
+
end_x: this.end_x,
|
|
185
|
+
end_y: this.end_y,
|
|
186
|
+
margin_start_x: this.margin_start_x,
|
|
187
|
+
margin_end_x: this.margin_end_x,
|
|
188
|
+
margin_start_y: this.margin_start_y,
|
|
189
|
+
margin_end_y: this.margin_end_y,
|
|
190
|
+
padding_start_x: this.padding_start_x,
|
|
191
|
+
padding_end_x: this.padding_end_x,
|
|
192
|
+
padding_start_y: this.padding_start_y,
|
|
193
|
+
padding_end_y: this.padding_end_y
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function CreateVElementClass({ type, is_text = false, is_img = false, is_hstack = false, is_stack = false }) {
|
|
198
|
+
class E {
|
|
199
|
+
// ---------------------------------------------------------
|
|
200
|
+
// Constructor.
|
|
201
|
+
constructor(...children2) {
|
|
202
|
+
this.type = type;
|
|
203
|
+
this._parent = null;
|
|
204
|
+
this._children = [];
|
|
205
|
+
this._text = null;
|
|
206
|
+
this._img = null;
|
|
207
|
+
this._options = {};
|
|
208
|
+
this._calls = {};
|
|
209
|
+
this._id = null;
|
|
210
|
+
this._width = void 0;
|
|
211
|
+
this._height = void 0;
|
|
212
|
+
this._stretch = void 0;
|
|
213
|
+
this._margin = [0, 0, 0, 0];
|
|
214
|
+
this._padding = [0, 0, 0, 0];
|
|
215
|
+
this._position = [null, null, null, null];
|
|
216
|
+
this._background = null;
|
|
217
|
+
this._border_radius = null;
|
|
218
|
+
this._border_color = null;
|
|
219
|
+
this._border_width = 1;
|
|
220
|
+
this._font = null;
|
|
221
|
+
this._font_weight = null;
|
|
222
|
+
this._href = null;
|
|
223
|
+
this._force_same_page = false;
|
|
224
|
+
this._page = void 0;
|
|
225
|
+
this._valign = void 0;
|
|
226
|
+
this.is_text = is_text;
|
|
227
|
+
this.is_img = is_img;
|
|
228
|
+
this.is_hstack = is_hstack;
|
|
229
|
+
this.is_stack = is_stack;
|
|
230
|
+
this.append(...children2);
|
|
231
|
+
}
|
|
232
|
+
copy() {
|
|
233
|
+
const copy = new this.constructor(this._children);
|
|
234
|
+
copy.type = this.type;
|
|
235
|
+
copy._parent = this._parent;
|
|
236
|
+
copy._children = this._children;
|
|
237
|
+
copy._text = this._text;
|
|
238
|
+
copy._img = this._img;
|
|
239
|
+
copy._style = this._options;
|
|
240
|
+
copy._calls = this._calls;
|
|
241
|
+
copy._id = this._id;
|
|
242
|
+
copy._width = this._width;
|
|
243
|
+
copy._height = this._height;
|
|
244
|
+
copy._stretch = this.stretch;
|
|
245
|
+
copy._margin = this._margin;
|
|
246
|
+
copy._padding = this._padding;
|
|
247
|
+
copy._position = this._position;
|
|
248
|
+
copy._background = this._background;
|
|
249
|
+
copy._border_radius = this._border_radius;
|
|
250
|
+
copy._border_color = this._border_color;
|
|
251
|
+
copy._border_width = this._border_width;
|
|
252
|
+
copy._font = this._font;
|
|
253
|
+
copy._font_weight = this._font_weight;
|
|
254
|
+
copy._href = this._href;
|
|
255
|
+
copy._force_same_page = this._force_same_page;
|
|
256
|
+
copy._page = this._page;
|
|
257
|
+
copy._valign = this._valign;
|
|
258
|
+
return copy;
|
|
259
|
+
}
|
|
260
|
+
// ---------------------------------------------------------
|
|
261
|
+
// System.
|
|
262
|
+
// Set doc styling.
|
|
263
|
+
_set_styling(doc) {
|
|
264
|
+
this._restore = {};
|
|
265
|
+
Object.keys(this._calls).iterate((func) => {
|
|
266
|
+
if (func === "setFont") {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
this._restore[func] = doc["g" + func.substr(1)]();
|
|
270
|
+
if (Array.isArray(this._calls[func])) {
|
|
271
|
+
doc[func](...this._calls[func]);
|
|
272
|
+
} else {
|
|
273
|
+
doc[func](this._calls[func]);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
if (this._font != null || this._font_weight != null) {
|
|
277
|
+
const font = doc.getFont();
|
|
278
|
+
this._restore.setFont = [font.fontName, font.fontStyle];
|
|
279
|
+
doc.setFont(this._font || doc.fontName, this._font_weight || doc.fontStyle);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// Restore doc styling.
|
|
283
|
+
_restore_styling(doc) {
|
|
284
|
+
Object.keys(this._restore).iterate((func) => {
|
|
285
|
+
if (Array.isArray(this._restore[func])) {
|
|
286
|
+
doc[func](...this._restore[func]);
|
|
287
|
+
} else {
|
|
288
|
+
doc[func](this._restore[func]);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
// Check if the _text attr contains whitespace.
|
|
293
|
+
_has_whitespace() {
|
|
294
|
+
if (!this.is_text) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
for (let i = 0; i < this._text.length; i++) {
|
|
298
|
+
const c = this._text.charAt(i);
|
|
299
|
+
if (c === " " || c === " ") {
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
// Compute.
|
|
306
|
+
_compute(doc, x2, y2, page, refresh = false) {
|
|
307
|
+
if (refresh === false && this._computed !== void 0) {
|
|
308
|
+
return this._computed;
|
|
309
|
+
}
|
|
310
|
+
if (this.type === "PDF" && doc == null) {
|
|
311
|
+
this._create_doc();
|
|
312
|
+
doc = this._doc;
|
|
313
|
+
x2 = 0;
|
|
314
|
+
y2 = 0;
|
|
315
|
+
page = 1;
|
|
316
|
+
refresh = true;
|
|
317
|
+
}
|
|
318
|
+
if (this._initialize !== void 0) {
|
|
319
|
+
this._initialize();
|
|
320
|
+
}
|
|
321
|
+
if (this._text != null) {
|
|
322
|
+
this._text = this._text.toString();
|
|
323
|
+
}
|
|
324
|
+
const is_absolute = this._position[0] != null || this._position[1] != null || this._position[2] != null || this._position[3] != null;
|
|
325
|
+
if (this._page != null) {
|
|
326
|
+
if (!is_absolute) {
|
|
327
|
+
throw Error(`Only absolute positioned elements may define an explicit page using "page()".`);
|
|
328
|
+
}
|
|
329
|
+
page = this._page;
|
|
330
|
+
}
|
|
331
|
+
let computed = new Computed({
|
|
332
|
+
start_x: x2,
|
|
333
|
+
start_y: y2,
|
|
334
|
+
resume_x: x2,
|
|
335
|
+
resume_y: y2,
|
|
336
|
+
start_page: page,
|
|
337
|
+
end_page: page,
|
|
338
|
+
is_absolute,
|
|
339
|
+
_margin: this._margin,
|
|
340
|
+
_padding: this._padding
|
|
341
|
+
});
|
|
342
|
+
if (this.type === "Page") {
|
|
343
|
+
computed.start_x = doc._volt_margin_left;
|
|
344
|
+
computed.start_y = doc._volt_margin_top;
|
|
345
|
+
++page;
|
|
346
|
+
++computed.start_page;
|
|
347
|
+
++computed.end_page;
|
|
348
|
+
}
|
|
349
|
+
let is_absolute_right = false;
|
|
350
|
+
let is_absolute_bottom = false;
|
|
351
|
+
if (computed.is_absolute) {
|
|
352
|
+
if (this._position[1] != null && this._position[3] != null) {
|
|
353
|
+
computed.start_x = this._position[3];
|
|
354
|
+
this._width = doc._volt_page_width - this._position[1] - this._position[3];
|
|
355
|
+
} else if (this._position[1] != null) {
|
|
356
|
+
computed.start_x = doc._volt_page_width - this._position[1] - this._margin[1] - this._margin[3] - this._padding[1] - this._padding[3];
|
|
357
|
+
is_absolute_right = true;
|
|
358
|
+
} else if (this._position[3] != null) {
|
|
359
|
+
computed.start_x = this._position[3];
|
|
360
|
+
}
|
|
361
|
+
if (this._position[0] != null && this._position[2] != null) {
|
|
362
|
+
computed.start_y = this._position[0];
|
|
363
|
+
this._height = doc._volt_page_height - this._position[0] - this._position[2];
|
|
364
|
+
} else if (this._position[0] != null) {
|
|
365
|
+
computed.start_y = this._position[0];
|
|
366
|
+
} else if (this._position[2] != null) {
|
|
367
|
+
computed.start_y = doc._volt_page_height - this._position[2] - this._margin[0] - this._margin[2] - this._padding[0] - this._padding[2];
|
|
368
|
+
is_absolute_bottom = true;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (typeof this._width === "string" && this._width.last() === "%") {
|
|
372
|
+
if (this._parent != null && this._parent._max_width != null) {
|
|
373
|
+
this._width = Math.max(0, this._parent._max_width * (parseInt(this._width.slice(0, -1)) / 100) - (this._margin[1] + this._margin[3] + this._padding[1] + this._padding[3]));
|
|
374
|
+
} else {
|
|
375
|
+
delete this._width;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (this._parent == null || this._parent._max_x != null) {
|
|
379
|
+
this._max_x = doc._volt_page_width - doc._volt_margin_right;
|
|
380
|
+
} else {
|
|
381
|
+
this._max_x = this._parent._max_x;
|
|
382
|
+
}
|
|
383
|
+
if (this._width != null) {
|
|
384
|
+
this._max_x = Math.min(x2 + this._width, this._max_x);
|
|
385
|
+
}
|
|
386
|
+
this._max_x -= this._margin[1] - this._padding[1];
|
|
387
|
+
this._max_width = parseInt(this._max_x - x2);
|
|
388
|
+
this._set_styling(doc);
|
|
389
|
+
if (this.is_text || this.is_img) {
|
|
390
|
+
let width2 = 0, height2 = 0, dimensions;
|
|
391
|
+
const has_whitespace = this._has_whitespace();
|
|
392
|
+
if (this.is_img) {
|
|
393
|
+
if (this._width == null) {
|
|
394
|
+
throw Error('A defined width is required for an "Image" element.');
|
|
395
|
+
}
|
|
396
|
+
if (this._height == null) {
|
|
397
|
+
throw Error('A defined height is required for an "Image" element.');
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (this._width != null) {
|
|
401
|
+
width2 = this._width;
|
|
402
|
+
} else if (this.is_text) {
|
|
403
|
+
let no_spaces = "", space_count = 0;
|
|
404
|
+
for (let i = 0; i < this._text.length; i++) {
|
|
405
|
+
const c = this._text.charAt(i);
|
|
406
|
+
if (c === " ") {
|
|
407
|
+
++space_count;
|
|
408
|
+
} else if (c === " ") {
|
|
409
|
+
space_count += 8;
|
|
410
|
+
} else {
|
|
411
|
+
no_spaces += c;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
dimensions = doc.getTextDimensions(no_spaces);
|
|
415
|
+
width2 = dimensions.w + doc.getStringUnitWidth(" ") * doc.getFontSize() * space_count;
|
|
416
|
+
}
|
|
417
|
+
if (width2 > this._max_width) {
|
|
418
|
+
width2 = this._max_width;
|
|
419
|
+
if (this._width != null) {
|
|
420
|
+
this._width = width2;
|
|
421
|
+
}
|
|
422
|
+
if (this.is_text && !has_whitespace && width2 < this._parent._max_width) {
|
|
423
|
+
this._restore_styling(doc);
|
|
424
|
+
const computed2 = this._compute(doc, this._parent._wrap_x, this._parent._wrap_y, page, true);
|
|
425
|
+
computed2.has_wrapped = true;
|
|
426
|
+
return computed2;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (this._font_weight === "bold") {
|
|
430
|
+
width2 *= 1.04;
|
|
431
|
+
}
|
|
432
|
+
if (this._height != null) {
|
|
433
|
+
height2 = this._height;
|
|
434
|
+
} else if (this.is_text) {
|
|
435
|
+
if (dimensions === void 0) {
|
|
436
|
+
dimensions = doc.getTextDimensions(this._text);
|
|
437
|
+
}
|
|
438
|
+
if (!has_whitespace && width2 < this._parent._max_width) {
|
|
439
|
+
height2 = 1 * (dimensions.h * doc.getLineHeightFactor());
|
|
440
|
+
} else {
|
|
441
|
+
const lines = doc.splitTextToSize(this._text, width2);
|
|
442
|
+
height2 = lines.length * (dimensions.h * doc.getLineHeightFactor());
|
|
443
|
+
}
|
|
444
|
+
height2 += dimensions.h * doc.getLineHeightFactor() * 0.15;
|
|
445
|
+
}
|
|
446
|
+
computed.inner_width = width2;
|
|
447
|
+
computed.inner_height = height2;
|
|
448
|
+
} else {
|
|
449
|
+
let max_child_x = 0, max_child_y = 0;
|
|
450
|
+
let x3 = computed.padding_start_x;
|
|
451
|
+
let y3 = computed.padding_start_y;
|
|
452
|
+
let child_page = page;
|
|
453
|
+
let stretch_children = [], row_children = [];
|
|
454
|
+
this._wrap_x = x3;
|
|
455
|
+
const apply_vertical_alignment = (children2) => {
|
|
456
|
+
const is_center = this._valign === "center";
|
|
457
|
+
const is_trailing = this._valign === "trailing";
|
|
458
|
+
if (!is_center && !is_trailing) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
let max_height = 0;
|
|
462
|
+
children2.iterate((child) => {
|
|
463
|
+
const height2 = child._computed.inner_height + child._computed._padding[0] + child._computed._padding[2];
|
|
464
|
+
if (!child._computed.is_absolute && height2 > max_height) {
|
|
465
|
+
max_height = height2;
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
children2.iterate((child) => {
|
|
469
|
+
if (!child._computed.is_absolute) {
|
|
470
|
+
const height2 = child._computed.inner_height + child._computed._padding[0] + child._computed._padding[2];
|
|
471
|
+
if (is_center) {
|
|
472
|
+
child._computed.start_y += (max_height - height2) / 2;
|
|
473
|
+
} else if (is_trailing) {
|
|
474
|
+
child._computed.start_y += max_height - height2;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
this._children.iterate((child) => {
|
|
480
|
+
const is_stack3 = child.is_stack;
|
|
481
|
+
child._parent = this;
|
|
482
|
+
let response = child._compute(doc, x3, y3, child_page, refresh);
|
|
483
|
+
if (response.end_page > computed.end_page) {
|
|
484
|
+
apply_vertical_alignment(row_children);
|
|
485
|
+
row_children = [];
|
|
486
|
+
stretch_children = [];
|
|
487
|
+
child_page = response.end_page;
|
|
488
|
+
computed.end_page = response.end_page;
|
|
489
|
+
if (this.is_hstack) {
|
|
490
|
+
x3 = response.resume_x;
|
|
491
|
+
y3 = doc._volt_margin_top;
|
|
492
|
+
if (response.has_wrapped || response.resume_x >= this._max_x) {
|
|
493
|
+
x3 = response.has_wrapped ? response.resume_x : this._wrap_x;
|
|
494
|
+
y3 = this._wrap_y === void 0 ? response.resume_y : this._wrap_y;
|
|
495
|
+
}
|
|
496
|
+
} else {
|
|
497
|
+
x3 = this._wrap_x;
|
|
498
|
+
y3 = response.resume_y;
|
|
499
|
+
}
|
|
500
|
+
max_child_x = x3;
|
|
501
|
+
max_child_y = y3;
|
|
502
|
+
} else if (this.is_hstack) {
|
|
503
|
+
x3 = response.resume_x;
|
|
504
|
+
if (response.has_wrapped || response.resume_x >= this._max_x) {
|
|
505
|
+
x3 = response.has_wrapped ? response.resume_x : this._wrap_x;
|
|
506
|
+
y3 = this._wrap_y === void 0 ? response.resume_y : this._wrap_y;
|
|
507
|
+
}
|
|
508
|
+
} else {
|
|
509
|
+
y3 = response.resume_y;
|
|
510
|
+
}
|
|
511
|
+
if (response.resume_y > max_child_y) {
|
|
512
|
+
max_child_y = response.resume_y;
|
|
513
|
+
this._wrap_y = max_child_y;
|
|
514
|
+
}
|
|
515
|
+
if (response.resume_x > max_child_x) {
|
|
516
|
+
max_child_x = response.resume_x;
|
|
517
|
+
}
|
|
518
|
+
if (child._stretch) {
|
|
519
|
+
stretch_children.append(child);
|
|
520
|
+
}
|
|
521
|
+
row_children.append(child);
|
|
522
|
+
});
|
|
523
|
+
apply_vertical_alignment(row_children);
|
|
524
|
+
if (stretch_children.length > 0) {
|
|
525
|
+
if (this.is_hstack) {
|
|
526
|
+
const step = (this._max_x - max_child_x) / stretch_children.length;
|
|
527
|
+
let incr_x = 0;
|
|
528
|
+
row_children.iterate((child) => {
|
|
529
|
+
child._computed.start_x += incr_x;
|
|
530
|
+
if (child._stretch) {
|
|
531
|
+
child._computed.inner_width += step;
|
|
532
|
+
incr_x += step;
|
|
533
|
+
console.log("Stretch:", child.type, child._text, step);
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
} else {
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (this._width == null) {
|
|
540
|
+
computed.inner_width = Math.max(0, max_child_x - computed.padding_start_x);
|
|
541
|
+
} else {
|
|
542
|
+
computed.inner_width = Math.max(this._width, max_child_x - computed.padding_start_x);
|
|
543
|
+
}
|
|
544
|
+
if (this._height == null) {
|
|
545
|
+
computed.inner_height = Math.max(0, max_child_y - computed.padding_start_y);
|
|
546
|
+
} else {
|
|
547
|
+
computed.inner_height = Math.max(this._height, max_child_y - computed.padding_start_y);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (is_absolute_right) {
|
|
551
|
+
computed.start_x -= computed.inner_width;
|
|
552
|
+
}
|
|
553
|
+
if (is_absolute_bottom) {
|
|
554
|
+
computed.start_y -= computed.inner_height;
|
|
555
|
+
}
|
|
556
|
+
if (!computed.is_absolute) {
|
|
557
|
+
computed.resume_x = computed.end_x;
|
|
558
|
+
computed.resume_y = computed.end_y;
|
|
559
|
+
}
|
|
560
|
+
if (!is_absolute && computed.resume_y > doc._volt_page_height - doc._volt_margin_bottom && (this.is_text || this.is_img)) {
|
|
561
|
+
if (this.is_text) {
|
|
562
|
+
const line_height_factor = doc.getLineHeightFactor();
|
|
563
|
+
const dimensions = doc.getTextDimensions(this._text);
|
|
564
|
+
let lines = doc.splitTextToSize(this._text, computed.inner_width);
|
|
565
|
+
const get_break_index = (max_height) => {
|
|
566
|
+
let i, height2;
|
|
567
|
+
for (i = 0; i < lines.length; i++) {
|
|
568
|
+
height2 = (i + 1) * (dimensions.h * line_height_factor);
|
|
569
|
+
height2 += dimensions.h * line_height_factor * 0.15;
|
|
570
|
+
if (height2 >= max_height) {
|
|
571
|
+
return i - 1;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return i;
|
|
575
|
+
};
|
|
576
|
+
if (computed.padding_start_y + dimensions.h > doc._volt_page_height - doc._volt_margin_bottom) {
|
|
577
|
+
this._restore_styling(doc);
|
|
578
|
+
return this._compute(doc, this._parent._wrap_x, doc._volt_margin_top, page + 1, true);
|
|
579
|
+
}
|
|
580
|
+
this._restore_styling(doc);
|
|
581
|
+
let remaining_text = this._text;
|
|
582
|
+
const sub_texts = [];
|
|
583
|
+
let child_page = page;
|
|
584
|
+
for (let i = 0; i < 1e5; i++) {
|
|
585
|
+
const max_height = i === 0 ? doc._volt_page_height - doc._volt_margin_bottom - computed.padding_start_y : doc._volt_page_height - doc._volt_margin_bottom - doc._volt_margin_top;
|
|
586
|
+
const break_index = get_break_index(max_height);
|
|
587
|
+
const is_last = break_index == lines.length;
|
|
588
|
+
if (break_index === 0) {
|
|
589
|
+
++child_page;
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
const copy = this.copy();
|
|
593
|
+
copy._parent = this._parent;
|
|
594
|
+
if (!is_last) {
|
|
595
|
+
copy._margin[3] = 0;
|
|
596
|
+
copy._padding[3] = 0;
|
|
597
|
+
}
|
|
598
|
+
if (i > 0) {
|
|
599
|
+
copy._margin[0] = 0;
|
|
600
|
+
copy._padding[0] = 0;
|
|
601
|
+
}
|
|
602
|
+
copy._text = lines.slice(0, break_index).join("\n");
|
|
603
|
+
lines = lines.slice(break_index);
|
|
604
|
+
if (i > 0) {
|
|
605
|
+
++child_page;
|
|
606
|
+
}
|
|
607
|
+
copy._compute(doc, i === 0 ? computed.start_x : this._parent._wrap_x, i === 0 ? computed.start_y : doc._volt_margin_top, child_page, true);
|
|
608
|
+
sub_texts.append(copy);
|
|
609
|
+
if (is_last) {
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
this._parent.insert_before(this, sub_texts);
|
|
614
|
+
this._parent.remove_child(this);
|
|
615
|
+
return sub_texts.last()._computed;
|
|
616
|
+
} else if (this.is_img && fits_on_one_page) {
|
|
617
|
+
this._restore_styling(doc);
|
|
618
|
+
return this._compute(doc, this._parent._wrap_x, doc._volt_margin_top, page + 1, true);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
const is_stack2 = this.is_stack;
|
|
622
|
+
if (!is_absolute && is_stack2 && this._force_same_page && computed.start_page !== computed.end_page && computed.end_y - computed.start_y <= doc._volt_page_height - doc._volt_margin_bottom - doc._volt_margin_top) {
|
|
623
|
+
this._restore_styling(doc);
|
|
624
|
+
return this._compute(doc, this._parent._wrap_x, doc._volt_margin_top, page + 1, true);
|
|
625
|
+
}
|
|
626
|
+
this._restore_styling(doc);
|
|
627
|
+
console.log(this.type, this._text, computed.start_y);
|
|
628
|
+
this._computed = computed;
|
|
629
|
+
return this._computed;
|
|
630
|
+
}
|
|
631
|
+
// Build element.
|
|
632
|
+
_build(doc) {
|
|
633
|
+
if (this.type === "PDF") {
|
|
634
|
+
this._create_doc();
|
|
635
|
+
doc = this._doc;
|
|
636
|
+
this._compute(doc, 0, 0, 1, true);
|
|
637
|
+
}
|
|
638
|
+
const computed = this._computed;
|
|
639
|
+
if (this.type === "PDF") {
|
|
640
|
+
for (let i = 0; i < computed.end_page - 1; i++) {
|
|
641
|
+
doc.addPage();
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
doc.setPage(computed.start_page);
|
|
645
|
+
this._set_styling(doc);
|
|
646
|
+
if (typeof this._background === "string" || typeof this._border_color === "string") {
|
|
647
|
+
let x2 = computed.margin_start_x, rect_width = computed.margin_end_x - computed.margin_start_x;
|
|
648
|
+
let y2, rect_height;
|
|
649
|
+
let color;
|
|
650
|
+
for (let i = computed.start_page; i <= computed.end_page; i++) {
|
|
651
|
+
doc.setPage(i);
|
|
652
|
+
if (computed.start_page === computed.end_page) {
|
|
653
|
+
y2 = computed.margin_start_y;
|
|
654
|
+
rect_height = computed.margin_end_y - computed.margin_start_y;
|
|
655
|
+
} else if (i === computed.start_page) {
|
|
656
|
+
y2 = computed.margin_start_y;
|
|
657
|
+
rect_height = doc._volt_page_height - doc._volt_margin_bottom - computed.margin_start_y;
|
|
658
|
+
} else if (i === computed.end_page) {
|
|
659
|
+
y2 = doc._volt_margin_top;
|
|
660
|
+
rect_height = computed.margin_end_y - doc._volt_margin_bottom;
|
|
661
|
+
} else {
|
|
662
|
+
y2 = doc._volt_margin_top;
|
|
663
|
+
rect_height = doc._volt_page_height - doc._volt_margin_bottom - doc._volt_margin_top;
|
|
664
|
+
}
|
|
665
|
+
let border_radius = this._border_radius;
|
|
666
|
+
if (typeof border_radius === "string" && border_radius.last() === "%") {
|
|
667
|
+
border_radius = Math.min(rect_width, rect_height) * (parseInt(border_radius.slice(0, -1)) / 100);
|
|
668
|
+
}
|
|
669
|
+
if (typeof this._background === "string") {
|
|
670
|
+
color = PDF.hex_to_rgb(this._background);
|
|
671
|
+
let restore = false;
|
|
672
|
+
if (Array.isArray(color)) {
|
|
673
|
+
if (color.length === 4) {
|
|
674
|
+
restore = true;
|
|
675
|
+
doc.saveGraphicsState();
|
|
676
|
+
doc.setGState(new doc.GState({ opacity: color[3] }));
|
|
677
|
+
--color.length;
|
|
678
|
+
}
|
|
679
|
+
doc.setFillColor(...color);
|
|
680
|
+
} else {
|
|
681
|
+
doc.setFillColor(color);
|
|
682
|
+
}
|
|
683
|
+
if (border_radius != null) {
|
|
684
|
+
doc.roundedRect(x2, y2, rect_width, rect_height, border_radius, border_radius, "F");
|
|
685
|
+
} else {
|
|
686
|
+
doc.rect(x2, y2, rect_width, rect_height, "F");
|
|
687
|
+
}
|
|
688
|
+
if (restore) {
|
|
689
|
+
doc.restoreGraphicsState();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (typeof this._border_color === "string") {
|
|
693
|
+
doc.setLineWidth(this._border_width === void 0 ? 1 : this._border_width);
|
|
694
|
+
color = PDF.hex_to_rgb(this._border_color);
|
|
695
|
+
let restore = false;
|
|
696
|
+
if (Array.isArray(color)) {
|
|
697
|
+
if (color.length === 4) {
|
|
698
|
+
restore = true;
|
|
699
|
+
doc.saveGraphicsState();
|
|
700
|
+
doc.setGState(new doc.GState({ "stroke-opacity": color[3] }));
|
|
701
|
+
--color.length;
|
|
702
|
+
}
|
|
703
|
+
doc.setDrawColor(...color);
|
|
704
|
+
} else {
|
|
705
|
+
doc.setDrawColor(color);
|
|
706
|
+
}
|
|
707
|
+
if (border_radius != null) {
|
|
708
|
+
doc.roundedRect(x2, y2, rect_width, rect_height, border_radius, border_radius, "S");
|
|
709
|
+
} else {
|
|
710
|
+
doc.rect(x2, y2, rect_width, rect_height, "S");
|
|
711
|
+
}
|
|
712
|
+
if (restore) {
|
|
713
|
+
doc.restoreGraphicsState();
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
this._restore_styling(doc);
|
|
718
|
+
doc.setPage(computed.start_page);
|
|
719
|
+
this._set_styling(doc);
|
|
720
|
+
}
|
|
721
|
+
if (this._id != null) {
|
|
722
|
+
doc._volt_ids[this._id] = computed.start_page;
|
|
723
|
+
}
|
|
724
|
+
if (this.is_text || this.is_img) {
|
|
725
|
+
if (this._href != null) {
|
|
726
|
+
if (this._href.startsWith("http")) {
|
|
727
|
+
doc.link(x, y, width, height, this._href);
|
|
728
|
+
} else {
|
|
729
|
+
doc._volt_hrefs.append({
|
|
730
|
+
page: computed.start_page,
|
|
731
|
+
href: this._href,
|
|
732
|
+
args: [x, y, width, height]
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (this.is_text) {
|
|
737
|
+
const font_size = doc.getFontSize();
|
|
738
|
+
let x2 = computed.padding_start_x;
|
|
739
|
+
let y2 = computed.padding_start_y + font_size;
|
|
740
|
+
if (this._options.align === "right") {
|
|
741
|
+
x2 += computed.inner_width;
|
|
742
|
+
}
|
|
743
|
+
y2 -= font_size * 0.05;
|
|
744
|
+
doc.text(this._text, x2, y2, this._options);
|
|
745
|
+
} else if (this.is_img) {
|
|
746
|
+
doc.addImage(libfs.readFileSync(this._img).toString("base64"), new vlib.Path(this._img).extension().slice(1).toUpperCase(), computed.padding_start_x, computed.padding_start_y, this._width, this._height);
|
|
747
|
+
}
|
|
748
|
+
} else if (this._children.length > 0) {
|
|
749
|
+
this._children.iterate((child) => {
|
|
750
|
+
child._build(doc);
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
this._restore_styling(doc);
|
|
754
|
+
if (this.type === "PDF") {
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
// ---------------------------------------------------------
|
|
758
|
+
// Functions.
|
|
759
|
+
// As string.
|
|
760
|
+
toString(indent = 0) {
|
|
761
|
+
let indent_str = "";
|
|
762
|
+
for (let i = 0; i < indent; i++) {
|
|
763
|
+
indent_str += " ";
|
|
764
|
+
}
|
|
765
|
+
if (this.children.length > 0) {
|
|
766
|
+
let str = `${indent_str}${this.type}(
|
|
767
|
+
`;
|
|
768
|
+
str += this._children.iterate_append((c) => c.toString(indent + 4)).join(",\n");
|
|
769
|
+
str += `
|
|
770
|
+
${indent_str})`;
|
|
771
|
+
return str;
|
|
772
|
+
} else if (this.type === "Text") {
|
|
773
|
+
return `${indent_str}${this.type}("${this._text}")`;
|
|
774
|
+
} else if (this.type === "Image") {
|
|
775
|
+
return `${indent_str}${this.type}("${this._img}")`;
|
|
776
|
+
} else {
|
|
777
|
+
return `${indent_str}${this.type}()`;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
// Get/set text.
|
|
781
|
+
text(val) {
|
|
782
|
+
if (val === void 0) {
|
|
783
|
+
return this._text;
|
|
784
|
+
}
|
|
785
|
+
this._text = val;
|
|
786
|
+
return this;
|
|
787
|
+
}
|
|
788
|
+
// Get/set children.
|
|
789
|
+
get children() {
|
|
790
|
+
return this._children;
|
|
791
|
+
}
|
|
792
|
+
set children(val) {
|
|
793
|
+
this._children = val;
|
|
794
|
+
}
|
|
795
|
+
// Append.
|
|
796
|
+
append(...children2) {
|
|
797
|
+
for (let i = 0; i < children2.length; i++) {
|
|
798
|
+
if (children2[i] == null) {
|
|
799
|
+
continue;
|
|
800
|
+
} else if (Array.isArray(children2[i])) {
|
|
801
|
+
this.append(...children2[i]);
|
|
802
|
+
} else if (typeof children2[i] === "string") {
|
|
803
|
+
this._children.append(PDF.Text(children2[i]));
|
|
804
|
+
} else if (typeof children2[i] !== "object") {
|
|
805
|
+
this._children.append(PDF.Text(children2[i].toString()));
|
|
806
|
+
} else {
|
|
807
|
+
this._children.append(children2[i]);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return this;
|
|
811
|
+
}
|
|
812
|
+
// Insert before.
|
|
813
|
+
insert_before(relative, child) {
|
|
814
|
+
const children2 = [];
|
|
815
|
+
this._children.iterate((x2) => {
|
|
816
|
+
if (x2 === relative) {
|
|
817
|
+
if (Array.isArray(child)) {
|
|
818
|
+
children2.append(...child);
|
|
819
|
+
} else {
|
|
820
|
+
children2.append(child);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
children2.append(x2);
|
|
824
|
+
});
|
|
825
|
+
this._children = children2;
|
|
826
|
+
return this;
|
|
827
|
+
}
|
|
828
|
+
// Insert after.
|
|
829
|
+
insert_after(relative, child) {
|
|
830
|
+
const children2 = [];
|
|
831
|
+
this._children.iterate((x2) => {
|
|
832
|
+
children2.append(x2);
|
|
833
|
+
if (x2 === relative) {
|
|
834
|
+
if (Array.isArray(child)) {
|
|
835
|
+
children2.append(...child);
|
|
836
|
+
} else {
|
|
837
|
+
children2.append(child);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
this._children = children2;
|
|
842
|
+
return this;
|
|
843
|
+
}
|
|
844
|
+
// Remove child.
|
|
845
|
+
remove_child(child) {
|
|
846
|
+
this._children = this._children.drop(child);
|
|
847
|
+
return this;
|
|
848
|
+
}
|
|
849
|
+
// Remove children.
|
|
850
|
+
remove_children() {
|
|
851
|
+
this._children = [];
|
|
852
|
+
return this;
|
|
853
|
+
}
|
|
854
|
+
// id.
|
|
855
|
+
id(val) {
|
|
856
|
+
if (val === void 0) {
|
|
857
|
+
return this._id;
|
|
858
|
+
}
|
|
859
|
+
this._id = val;
|
|
860
|
+
return this;
|
|
861
|
+
}
|
|
862
|
+
// Href.
|
|
863
|
+
href(val) {
|
|
864
|
+
if (val === void 0) {
|
|
865
|
+
return this._href;
|
|
866
|
+
}
|
|
867
|
+
this._href = val;
|
|
868
|
+
return this;
|
|
869
|
+
}
|
|
870
|
+
// Force same page for HStacks.
|
|
871
|
+
force_same_page(val) {
|
|
872
|
+
if (val === void 0) {
|
|
873
|
+
return this._force_same_page;
|
|
874
|
+
}
|
|
875
|
+
this._force_same_page = val;
|
|
876
|
+
return this;
|
|
877
|
+
}
|
|
878
|
+
// Set start page.
|
|
879
|
+
page(val) {
|
|
880
|
+
if (val === void 0) {
|
|
881
|
+
return this._page;
|
|
882
|
+
}
|
|
883
|
+
this._page = val;
|
|
884
|
+
return this;
|
|
885
|
+
}
|
|
886
|
+
// Margin, 1, 2 or 4 args.
|
|
887
|
+
margin(...values) {
|
|
888
|
+
if (values.length === 0) {
|
|
889
|
+
return this._margin;
|
|
890
|
+
} else {
|
|
891
|
+
if (values.length === 1) {
|
|
892
|
+
this._margin = [values[0], values[0], values[0], values[0]];
|
|
893
|
+
} else if (values.length === 2) {
|
|
894
|
+
this._margin = [values[0], values[1], values[0], values[1]];
|
|
895
|
+
} else if (values.length === 4) {
|
|
896
|
+
this._margin = [values[0], values[1], values[2], values[3]];
|
|
897
|
+
} else {
|
|
898
|
+
console.error('Invalid number of arguments for function "margin()".');
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
return this;
|
|
902
|
+
}
|
|
903
|
+
margin_top(val) {
|
|
904
|
+
if (val === void 0) {
|
|
905
|
+
return this._margin[0];
|
|
906
|
+
}
|
|
907
|
+
this._margin[0] = val;
|
|
908
|
+
return this;
|
|
909
|
+
}
|
|
910
|
+
margin_right(val) {
|
|
911
|
+
if (val === void 0) {
|
|
912
|
+
return this._margin[1];
|
|
913
|
+
}
|
|
914
|
+
this._margin[1] = val;
|
|
915
|
+
return this;
|
|
916
|
+
}
|
|
917
|
+
margin_bottom(val) {
|
|
918
|
+
if (val === void 0) {
|
|
919
|
+
return this._margin[2];
|
|
920
|
+
}
|
|
921
|
+
this._margin[2] = val;
|
|
922
|
+
return this;
|
|
923
|
+
}
|
|
924
|
+
margin_left(val) {
|
|
925
|
+
if (val === void 0) {
|
|
926
|
+
return this._margin[3];
|
|
927
|
+
}
|
|
928
|
+
this._margin[3] = val;
|
|
929
|
+
return this;
|
|
930
|
+
}
|
|
931
|
+
// Padding, 1, 2 or 4 args.
|
|
932
|
+
padding(...values) {
|
|
933
|
+
if (values.length === 0) {
|
|
934
|
+
return this._padding;
|
|
935
|
+
} else {
|
|
936
|
+
if (values.length === 1) {
|
|
937
|
+
this._padding = [values[0], values[0], values[0], values[0]];
|
|
938
|
+
} else if (values.length === 2) {
|
|
939
|
+
this._padding = [values[0], values[1], values[0], values[1]];
|
|
940
|
+
} else if (values.length === 4) {
|
|
941
|
+
this._padding = [values[0], values[1], values[2], values[3]];
|
|
942
|
+
} else {
|
|
943
|
+
console.error('Invalid number of arguments for function "padding()".');
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
return this;
|
|
947
|
+
}
|
|
948
|
+
padding_top(val) {
|
|
949
|
+
if (val === void 0) {
|
|
950
|
+
return this._padding[0];
|
|
951
|
+
}
|
|
952
|
+
this._padding[0] = val;
|
|
953
|
+
return this;
|
|
954
|
+
}
|
|
955
|
+
padding_right(val) {
|
|
956
|
+
if (val === void 0) {
|
|
957
|
+
return this._padding[1];
|
|
958
|
+
}
|
|
959
|
+
this._padding[1] = val;
|
|
960
|
+
return this;
|
|
961
|
+
}
|
|
962
|
+
padding_bottom(val) {
|
|
963
|
+
if (val === void 0) {
|
|
964
|
+
return this._padding[2];
|
|
965
|
+
}
|
|
966
|
+
this._padding[2] = val;
|
|
967
|
+
return this;
|
|
968
|
+
}
|
|
969
|
+
padding_left(val) {
|
|
970
|
+
if (val === void 0) {
|
|
971
|
+
return this._padding[3];
|
|
972
|
+
}
|
|
973
|
+
this._padding[3] = val;
|
|
974
|
+
return this;
|
|
975
|
+
}
|
|
976
|
+
// Position, 1 or 4 args.
|
|
977
|
+
position(...values) {
|
|
978
|
+
if (values.length === 0) {
|
|
979
|
+
return this._position;
|
|
980
|
+
} else if (values.length === 1) {
|
|
981
|
+
this._position = [values[0], values[0], values[0], values[0]];
|
|
982
|
+
} else if (values.length === 4) {
|
|
983
|
+
if (values[0] != null) {
|
|
984
|
+
this._position[0] = values[0];
|
|
985
|
+
}
|
|
986
|
+
if (values[1] != null) {
|
|
987
|
+
this._position[1] = values[1];
|
|
988
|
+
}
|
|
989
|
+
if (values[2] != null) {
|
|
990
|
+
this._position[2] = values[2];
|
|
991
|
+
}
|
|
992
|
+
if (values[3] != null) {
|
|
993
|
+
this._position[3] = values[3];
|
|
994
|
+
}
|
|
995
|
+
} else {
|
|
996
|
+
console.error('Invalid number of arguments for function "position()".');
|
|
997
|
+
}
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
top(val) {
|
|
1001
|
+
if (val === void 0) {
|
|
1002
|
+
return this._position[0];
|
|
1003
|
+
}
|
|
1004
|
+
this._position[0] = val;
|
|
1005
|
+
return this;
|
|
1006
|
+
}
|
|
1007
|
+
right(val) {
|
|
1008
|
+
if (val === void 0) {
|
|
1009
|
+
return this._position[1];
|
|
1010
|
+
}
|
|
1011
|
+
this._position[1] = val;
|
|
1012
|
+
return this;
|
|
1013
|
+
}
|
|
1014
|
+
bottom(val) {
|
|
1015
|
+
if (val === void 0) {
|
|
1016
|
+
return this._position[2];
|
|
1017
|
+
}
|
|
1018
|
+
this._position[2] = val;
|
|
1019
|
+
return this;
|
|
1020
|
+
}
|
|
1021
|
+
left(val) {
|
|
1022
|
+
if (val === void 0) {
|
|
1023
|
+
return this._position[3];
|
|
1024
|
+
}
|
|
1025
|
+
this._position[3] = val;
|
|
1026
|
+
return this;
|
|
1027
|
+
}
|
|
1028
|
+
// Align.
|
|
1029
|
+
align(val) {
|
|
1030
|
+
if (val === void 0) {
|
|
1031
|
+
return this._options.align;
|
|
1032
|
+
}
|
|
1033
|
+
this._options.align = val;
|
|
1034
|
+
return this;
|
|
1035
|
+
}
|
|
1036
|
+
leading() {
|
|
1037
|
+
return this.align("left");
|
|
1038
|
+
}
|
|
1039
|
+
center() {
|
|
1040
|
+
return this.align("center");
|
|
1041
|
+
}
|
|
1042
|
+
trailing() {
|
|
1043
|
+
return this.align("right");
|
|
1044
|
+
}
|
|
1045
|
+
justify() {
|
|
1046
|
+
return this.align("justify");
|
|
1047
|
+
}
|
|
1048
|
+
// Width.
|
|
1049
|
+
width(val) {
|
|
1050
|
+
if (val == void 0) {
|
|
1051
|
+
return this._width;
|
|
1052
|
+
}
|
|
1053
|
+
this._width = val;
|
|
1054
|
+
return this;
|
|
1055
|
+
}
|
|
1056
|
+
// Height.
|
|
1057
|
+
height(val) {
|
|
1058
|
+
if (val == void 0) {
|
|
1059
|
+
return this._height;
|
|
1060
|
+
}
|
|
1061
|
+
if (typeof val === "string" && val.last() === "%") {
|
|
1062
|
+
throw Error('Function "height()" does not accept relative percentages.');
|
|
1063
|
+
}
|
|
1064
|
+
this._height = val;
|
|
1065
|
+
return this;
|
|
1066
|
+
}
|
|
1067
|
+
// Stretch.
|
|
1068
|
+
stretch(val) {
|
|
1069
|
+
if (val == void 0) {
|
|
1070
|
+
return this._stretch;
|
|
1071
|
+
}
|
|
1072
|
+
this._stretch = val;
|
|
1073
|
+
return this;
|
|
1074
|
+
}
|
|
1075
|
+
// Font family.
|
|
1076
|
+
font_family(val) {
|
|
1077
|
+
if (val === void 0) {
|
|
1078
|
+
return this._font;
|
|
1079
|
+
}
|
|
1080
|
+
this._font = val;
|
|
1081
|
+
return this;
|
|
1082
|
+
}
|
|
1083
|
+
// Font size.
|
|
1084
|
+
font_size(val) {
|
|
1085
|
+
if (val === void 0) {
|
|
1086
|
+
return this._calls.setFontSize;
|
|
1087
|
+
}
|
|
1088
|
+
this._calls.setFontSize = val;
|
|
1089
|
+
return this;
|
|
1090
|
+
}
|
|
1091
|
+
// Font weight, the suffix for the font so: Helvetica-"Bold", can be lowercase.
|
|
1092
|
+
// Suffix might depend per font.
|
|
1093
|
+
font_weight(val) {
|
|
1094
|
+
if (val === void 0) {
|
|
1095
|
+
return this._font_weight;
|
|
1096
|
+
}
|
|
1097
|
+
this._font_weight = val;
|
|
1098
|
+
return this;
|
|
1099
|
+
}
|
|
1100
|
+
// Color.
|
|
1101
|
+
color(val) {
|
|
1102
|
+
if (val === void 0) {
|
|
1103
|
+
return this._calls.setTextColor;
|
|
1104
|
+
}
|
|
1105
|
+
this._calls.setTextColor = val;
|
|
1106
|
+
return this;
|
|
1107
|
+
}
|
|
1108
|
+
// Background.
|
|
1109
|
+
background(val) {
|
|
1110
|
+
if (val === void 0) {
|
|
1111
|
+
return this._background;
|
|
1112
|
+
}
|
|
1113
|
+
this._background = val;
|
|
1114
|
+
return this;
|
|
1115
|
+
}
|
|
1116
|
+
// Border radius.
|
|
1117
|
+
border_radius(val) {
|
|
1118
|
+
if (val === void 0) {
|
|
1119
|
+
return this._border_radius;
|
|
1120
|
+
}
|
|
1121
|
+
this._border_radius = val;
|
|
1122
|
+
return this;
|
|
1123
|
+
}
|
|
1124
|
+
// Border color.
|
|
1125
|
+
border_color(val) {
|
|
1126
|
+
if (val === void 0) {
|
|
1127
|
+
return this._border_color;
|
|
1128
|
+
}
|
|
1129
|
+
this._border_color = val;
|
|
1130
|
+
return this;
|
|
1131
|
+
}
|
|
1132
|
+
// Border width.
|
|
1133
|
+
border_width(val) {
|
|
1134
|
+
if (val === void 0) {
|
|
1135
|
+
return this._border_width;
|
|
1136
|
+
}
|
|
1137
|
+
this._border_width = val;
|
|
1138
|
+
return this;
|
|
1139
|
+
}
|
|
1140
|
+
// Align (for images mainly).
|
|
1141
|
+
align_vertical(val) {
|
|
1142
|
+
if (val === void 0) {
|
|
1143
|
+
return this._valign;
|
|
1144
|
+
}
|
|
1145
|
+
this._valign = val;
|
|
1146
|
+
return this;
|
|
1147
|
+
}
|
|
1148
|
+
leading_vertical() {
|
|
1149
|
+
return this.align_vertical("leading");
|
|
1150
|
+
}
|
|
1151
|
+
center_vertical() {
|
|
1152
|
+
return this.align_vertical("center");
|
|
1153
|
+
}
|
|
1154
|
+
trailing_vertical() {
|
|
1155
|
+
return this.align_vertical("trailing");
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
return E;
|
|
1159
|
+
}
|
|
1160
|
+
class PDFElement extends CreateVElementClass({
|
|
1161
|
+
type: "PDF",
|
|
1162
|
+
is_stack: true
|
|
1163
|
+
}) {
|
|
1164
|
+
// Constructor.
|
|
1165
|
+
constructor(...children2) {
|
|
1166
|
+
super(...children2);
|
|
1167
|
+
this._margin = [50, 50, 50, 50];
|
|
1168
|
+
this._is_built = false;
|
|
1169
|
+
this._fonts = [];
|
|
1170
|
+
this.add_font("Menlo", "normal", `${import_meta.dirname}/fonts/Menlo-Regular.ttf`);
|
|
1171
|
+
this.add_font("Menlo", "bold", `${import_meta.dirname}/fonts/Menlo-Bold.ttf`);
|
|
1172
|
+
}
|
|
1173
|
+
// Create a document.
|
|
1174
|
+
_create_doc() {
|
|
1175
|
+
this._doc = new jsPDF("p", "pt", "a4");
|
|
1176
|
+
this._doc._volt_margin_top = this._margin[0];
|
|
1177
|
+
this._doc._volt_margin_right = this._margin[1];
|
|
1178
|
+
this._doc._volt_margin_bottom = this._margin[2];
|
|
1179
|
+
this._doc._volt_margin_left = this._margin[3];
|
|
1180
|
+
this._doc._volt_page_width = this._doc.getPageWidth();
|
|
1181
|
+
this._doc._volt_page_height = this._doc.getPageHeight();
|
|
1182
|
+
this._doc._volt_ids = {};
|
|
1183
|
+
this._doc._volt_hrefs = [];
|
|
1184
|
+
this._fonts.iterate((item) => {
|
|
1185
|
+
this._doc.addFileToVFS(item.file_name, item.base64);
|
|
1186
|
+
this._doc.addFont(item.file_name, item.name, item.style);
|
|
1187
|
+
});
|
|
1188
|
+
return this._doc;
|
|
1189
|
+
}
|
|
1190
|
+
// Build.
|
|
1191
|
+
build() {
|
|
1192
|
+
this._build();
|
|
1193
|
+
this._is_built = true;
|
|
1194
|
+
return this;
|
|
1195
|
+
}
|
|
1196
|
+
// Get max page.
|
|
1197
|
+
max_page() {
|
|
1198
|
+
if (this._computed === void 0) {
|
|
1199
|
+
this._compute();
|
|
1200
|
+
}
|
|
1201
|
+
return this._computed.end_page;
|
|
1202
|
+
}
|
|
1203
|
+
// Iterate pages.
|
|
1204
|
+
iterate_pages(callback) {
|
|
1205
|
+
this._compute(void 0, void 0, void 0, void 0, true);
|
|
1206
|
+
for (let i = 1; i <= this._computed.end_page; i++) {
|
|
1207
|
+
callback(i);
|
|
1208
|
+
}
|
|
1209
|
+
return this;
|
|
1210
|
+
}
|
|
1211
|
+
// Number pages.
|
|
1212
|
+
number_pages({
|
|
1213
|
+
align = "right",
|
|
1214
|
+
// left, center, right
|
|
1215
|
+
margin = 12.5,
|
|
1216
|
+
font_size = 6,
|
|
1217
|
+
color = "black"
|
|
1218
|
+
}) {
|
|
1219
|
+
this.iterate_pages((page) => {
|
|
1220
|
+
const text = PDF.Text(`Page ${page}`).color(color).font_size(font_size).position(null, align === "right" ? margin : null, margin, align === "left" ? margin : null).page(page);
|
|
1221
|
+
this.append(text);
|
|
1222
|
+
});
|
|
1223
|
+
return this;
|
|
1224
|
+
}
|
|
1225
|
+
// Add font.
|
|
1226
|
+
add_font(name = "Menlo", style = "normal", path = "Menlo-Regular.ttf") {
|
|
1227
|
+
this._fonts.append({
|
|
1228
|
+
name,
|
|
1229
|
+
style,
|
|
1230
|
+
file_name: new vlib.Path(path).name(),
|
|
1231
|
+
base64: Buffer.from(libfs.readFileSync(path)).toString("base64")
|
|
1232
|
+
});
|
|
1233
|
+
return this;
|
|
1234
|
+
}
|
|
1235
|
+
// Save.
|
|
1236
|
+
save(path) {
|
|
1237
|
+
if (!this._is_built) {
|
|
1238
|
+
this.build();
|
|
1239
|
+
}
|
|
1240
|
+
libfs.writeFileSync(path, this._doc.output(), "binary");
|
|
1241
|
+
}
|
|
1242
|
+
// Get as bytes.
|
|
1243
|
+
async bytes() {
|
|
1244
|
+
if (!this._is_built) {
|
|
1245
|
+
this.build();
|
|
1246
|
+
}
|
|
1247
|
+
const stream = this._doc.pipe(blobstream());
|
|
1248
|
+
return new Promise((resolve, reject) => {
|
|
1249
|
+
stream.on("finish", () => {
|
|
1250
|
+
const bytes = stream.toBuffer();
|
|
1251
|
+
resolve(bytes);
|
|
1252
|
+
});
|
|
1253
|
+
stream.on("error", (error) => {
|
|
1254
|
+
reject(error);
|
|
1255
|
+
});
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
// Get as blob stream.
|
|
1259
|
+
stream() {
|
|
1260
|
+
if (!this._is_built) {
|
|
1261
|
+
this.build();
|
|
1262
|
+
}
|
|
1263
|
+
return this._doc.pipe(blobstream());
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
;
|
|
1267
|
+
PDF.PDFElement = PDFElement;
|
|
1268
|
+
PDF.PDF = function PDF2(...args) {
|
|
1269
|
+
return new PDFElement(...args);
|
|
1270
|
+
};
|
|
1271
|
+
PDF.PageElement = class PageElement extends CreateVElementClass({
|
|
1272
|
+
type: "Page",
|
|
1273
|
+
is_stack: true
|
|
1274
|
+
}) {
|
|
1275
|
+
// Constructor.
|
|
1276
|
+
constructor(...children2) {
|
|
1277
|
+
super(...children2);
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
PDF.Page = function Page(...args) {
|
|
1281
|
+
return new PDF.PageElement(...args);
|
|
1282
|
+
};
|
|
1283
|
+
PDF.VStackElement = class VStackElement extends CreateVElementClass({
|
|
1284
|
+
type: "VStack",
|
|
1285
|
+
is_stack: true
|
|
1286
|
+
}) {
|
|
1287
|
+
// Constructor.
|
|
1288
|
+
constructor(...children2) {
|
|
1289
|
+
super(...children2);
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
PDF.VStack = function VStack(...args) {
|
|
1293
|
+
return new PDF.VStackElement(...args);
|
|
1294
|
+
};
|
|
1295
|
+
PDF.HStackElement = class HStackElement extends CreateVElementClass({
|
|
1296
|
+
type: "HStack",
|
|
1297
|
+
is_stack: true,
|
|
1298
|
+
is_hstack: true
|
|
1299
|
+
}) {
|
|
1300
|
+
// Constructor.
|
|
1301
|
+
constructor(...children2) {
|
|
1302
|
+
super(...children2);
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
PDF.HStack = function HStack(...args) {
|
|
1306
|
+
return new PDF.HStackElement(...args);
|
|
1307
|
+
};
|
|
1308
|
+
PDF.TextElement = class TextElement extends CreateVElementClass({
|
|
1309
|
+
type: "Text",
|
|
1310
|
+
is_text: true
|
|
1311
|
+
}) {
|
|
1312
|
+
// Constructor.
|
|
1313
|
+
constructor(text = "") {
|
|
1314
|
+
super();
|
|
1315
|
+
this._text = text;
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
PDF.Text = function Text(...args) {
|
|
1319
|
+
return new PDF.TextElement(...args);
|
|
1320
|
+
};
|
|
1321
|
+
PDF.ImageElement = class ImageElement extends CreateVElementClass({
|
|
1322
|
+
type: "Image",
|
|
1323
|
+
is_img: true
|
|
1324
|
+
}) {
|
|
1325
|
+
// Constructor.
|
|
1326
|
+
constructor(img) {
|
|
1327
|
+
super();
|
|
1328
|
+
this._img = img;
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
PDF.Image = function Image(...args) {
|
|
1332
|
+
return new PDF.ImageElement(...args);
|
|
1333
|
+
};
|
|
1334
|
+
PDF.CodeBlockElement = class CodeBlockElement extends CreateVElementClass({
|
|
1335
|
+
type: "CodeBlock",
|
|
1336
|
+
is_stack: true
|
|
1337
|
+
}) {
|
|
1338
|
+
static menlo_initialized = false;
|
|
1339
|
+
// Constructor.
|
|
1340
|
+
constructor(language2, code) {
|
|
1341
|
+
super();
|
|
1342
|
+
this._language = language2;
|
|
1343
|
+
this._code = code;
|
|
1344
|
+
this._initialized = false;
|
|
1345
|
+
this._calls.setFontSize = 6;
|
|
1346
|
+
this._padding = [12.5, 5, 12.5, 5];
|
|
1347
|
+
this._background = "#00000005";
|
|
1348
|
+
this._border_radius = 5;
|
|
1349
|
+
this._border_color = "#00000020";
|
|
1350
|
+
this._border_width = 0.5;
|
|
1351
|
+
this._font = "Menlo";
|
|
1352
|
+
}
|
|
1353
|
+
copy() {
|
|
1354
|
+
const copy = super.copy();
|
|
1355
|
+
copy._language = this.language;
|
|
1356
|
+
copy._code = this.code;
|
|
1357
|
+
copy._initialized = this._initialized;
|
|
1358
|
+
return copy;
|
|
1359
|
+
}
|
|
1360
|
+
// Initialize.
|
|
1361
|
+
_initialize() {
|
|
1362
|
+
if (this._initialized) {
|
|
1363
|
+
return this;
|
|
1364
|
+
}
|
|
1365
|
+
const tokenizer = vhighlight.init_tokenizer(this._language);
|
|
1366
|
+
if (tokenizer == null) {
|
|
1367
|
+
throw Error(`Language "${language}" is not a supported code language for "PDF.CodeBlock".`);
|
|
1368
|
+
}
|
|
1369
|
+
tokenizer.code = this._code;
|
|
1370
|
+
const tokens = tokenizer.tokenize();
|
|
1371
|
+
this._children = [];
|
|
1372
|
+
this._children.append(CodeBlockElement.build_tokens(tokens));
|
|
1373
|
+
this._initialized = true;
|
|
1374
|
+
return this;
|
|
1375
|
+
}
|
|
1376
|
+
// Build tokens.
|
|
1377
|
+
static build_tokens(tokens) {
|
|
1378
|
+
const token_classes = {
|
|
1379
|
+
comment: (text) => {
|
|
1380
|
+
return PDF.Text(text).color("#818C97");
|
|
1381
|
+
},
|
|
1382
|
+
comment_keyword: (text) => {
|
|
1383
|
+
return PDF.Text(text).color("#818C97").font_weight("bold");
|
|
1384
|
+
},
|
|
1385
|
+
comment_codeblock: (text) => {
|
|
1386
|
+
return PDF.Text(text).color("#818C97").font_weight("italic").background("#FFFFFF10").border_radius(5);
|
|
1387
|
+
},
|
|
1388
|
+
url: (text) => {
|
|
1389
|
+
return PDF.Text(text).color("#818C97");
|
|
1390
|
+
},
|
|
1391
|
+
string: (text) => {
|
|
1392
|
+
return PDF.Text(text).color("#D6C986");
|
|
1393
|
+
},
|
|
1394
|
+
numeric: (text) => {
|
|
1395
|
+
return PDF.Text(text).color("#D6C986");
|
|
1396
|
+
},
|
|
1397
|
+
keyword: (text) => {
|
|
1398
|
+
return PDF.Text(text).color("#EE8378").font_weight("bold");
|
|
1399
|
+
},
|
|
1400
|
+
operator: (text) => {
|
|
1401
|
+
return PDF.Text(text).color("#EE8378").font_weight("bold");
|
|
1402
|
+
},
|
|
1403
|
+
preprocessor: (text) => {
|
|
1404
|
+
return PDF.Text(text).color("#EE8378");
|
|
1405
|
+
},
|
|
1406
|
+
type_def: (text) => {
|
|
1407
|
+
return PDF.Text(text).color("#C78BF0");
|
|
1408
|
+
},
|
|
1409
|
+
type: (text) => {
|
|
1410
|
+
return PDF.Text(text).color("#5795F3");
|
|
1411
|
+
},
|
|
1412
|
+
parameter: (text) => {
|
|
1413
|
+
return PDF.Text(text).color("#F9AE58");
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
if (tokens.length === 0) {
|
|
1417
|
+
return null;
|
|
1418
|
+
}
|
|
1419
|
+
if (Array.isArray(tokens[0])) {
|
|
1420
|
+
tokens.iterate((line_tokens) => {
|
|
1421
|
+
const hstack = PDF.HStack();
|
|
1422
|
+
line_tokens.iterate((token) => {
|
|
1423
|
+
if (token.is_line_break) {
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
const token_class = token_classes[token.token];
|
|
1427
|
+
if (token_class == null) {
|
|
1428
|
+
hstack.append(PDF.Text(token.data));
|
|
1429
|
+
} else {
|
|
1430
|
+
hstack.append(token_class(token.data));
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
children.append(hstack);
|
|
1434
|
+
});
|
|
1435
|
+
return children;
|
|
1436
|
+
} else {
|
|
1437
|
+
const hstack = PDF.HStack();
|
|
1438
|
+
tokens.iterate((token) => {
|
|
1439
|
+
if (token.is_line_break) {
|
|
1440
|
+
return null;
|
|
1441
|
+
}
|
|
1442
|
+
const token_class = token_classes[token.token];
|
|
1443
|
+
if (token_class == null) {
|
|
1444
|
+
hstack.append(PDF.Text(token.data));
|
|
1445
|
+
} else {
|
|
1446
|
+
hstack.append(token_class(token.data));
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
return hstack;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
PDF.CodeBlock = function CodeBlock(...args) {
|
|
1454
|
+
return new PDF.CodeBlockElement(...args);
|
|
1455
|
+
};
|
|
1456
|
+
module.exports = PDF;
|