@webquark/core 1.1.0-dev.6 → 1.1.0-dev.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/README.md +7 -5
- package/dist/cjs/{action.props-CtwTiyf6.js → action.props-N0urQtdP.js} +1 -1
- package/dist/cjs/{chevron-up-Dysp_9UJ.js → chevron-up-D4t2OSHA.js} +2 -2
- package/dist/cjs/{data-table-cell-BAv6IIYx.js → data-table-cell-8uUCk2Qz.js} +5 -0
- package/dist/cjs/{field-CiEtk37y.js → field-CsrQGhG-.js} +2 -2
- package/dist/cjs/form-field-adapter-D0CJ6poh.js +51 -0
- package/dist/cjs/form-field-state-P63wN30v.js +51 -0
- package/dist/cjs/form-submit-action-C6c4aq6C.js +227 -0
- package/dist/cjs/image-crop-BZD5Cxd7.js +53 -0
- package/dist/cjs/{index-BLlc_shC.js → index-DWXhKHCB.js} +25 -26
- package/dist/cjs/index.cjs.js +8 -3
- package/dist/cjs/leaflet-maplibre-gl-JIaCQ-7v.js +1025 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{map.types-DNrz8rJh.js → map.types-BWymIRql.js} +1 -1
- package/dist/cjs/q-accordion.cjs.entry.js +2 -2
- package/dist/cjs/q-alert.cjs.entry.js +1 -1
- package/dist/cjs/q-avatar.cjs.entry.js +2 -2
- package/dist/cjs/q-banner.cjs.entry.js +1 -1
- package/dist/cjs/q-button_2.cjs.entry.js +112 -25
- package/dist/cjs/q-card.cjs.entry.js +3 -3
- package/dist/cjs/q-carousel.cjs.entry.js +400 -13
- package/dist/cjs/q-chip.cjs.entry.js +2 -2
- package/dist/cjs/q-conversation-bubble.cjs.entry.js +1 -1
- package/dist/cjs/q-data-table.cjs.entry.js +73 -11
- package/dist/cjs/q-dialog.cjs.entry.js +4 -4
- package/dist/cjs/q-dropdown.cjs.entry.js +65 -12
- package/dist/cjs/q-form.cjs.entry.js +775 -288
- package/dist/cjs/q-grid.cjs.entry.js +3 -3
- package/dist/cjs/q-icon.cjs.entry.js +143 -89
- package/dist/cjs/q-image-comparison.cjs.entry.js +201 -0
- package/dist/cjs/q-inline.cjs.entry.js +3 -3
- package/dist/cjs/q-input_2.cjs.entry.js +91 -23
- package/dist/cjs/q-link.cjs.entry.js +2 -2
- package/dist/cjs/q-map.cjs.entry.js +141 -22
- package/dist/cjs/q-media.cjs.entry.js +3 -3
- package/dist/cjs/q-navbar.cjs.entry.js +4 -4
- package/dist/cjs/q-pagination.cjs.entry.js +2 -2
- package/dist/cjs/q-panel.cjs.entry.js +6 -6
- package/dist/cjs/q-quantity-selector.cjs.entry.js +6 -6
- package/dist/cjs/q-radio-group.cjs.entry.js +49 -12
- package/dist/cjs/q-reel.cjs.entry.js +3 -3
- package/dist/cjs/q-scrollable.cjs.entry.js +4 -4
- package/dist/cjs/q-section.cjs.entry.js +2 -2
- package/dist/cjs/q-sidepanel.cjs.entry.js +145 -25
- package/dist/cjs/q-stack.cjs.entry.js +3 -3
- package/dist/cjs/q-step-diagram-item.cjs.entry.js +2 -2
- package/dist/cjs/q-step-diagram.cjs.entry.js +3 -3
- package/dist/cjs/q-syntax-box.cjs.entry.js +418 -301
- package/dist/cjs/q-tabs.cjs.entry.js +3 -3
- package/dist/cjs/q-textarea.cjs.entry.js +67 -22
- package/dist/cjs/q-thumbnail.cjs.entry.js +3 -3
- package/dist/cjs/q-toast.cjs.entry.js +1 -1
- package/dist/cjs/q-toggle.cjs.entry.js +59 -13
- package/dist/cjs/q-toolbar.cjs.entry.js +5 -5
- package/dist/cjs/registry-C3IYlNMp.js +323 -0
- package/dist/cjs/tokens-RMRaIOqv.js +957 -0
- package/dist/cjs/webquark.cjs.js +3 -3
- package/dist/collection/assets/icons/spinner.svg +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/actions/button/button.css +6 -6
- package/dist/collection/components/actions/button/button.js +250 -14
- package/dist/collection/components/actions/button/test/button-slots.cmp.test.js +70 -0
- package/dist/collection/components/content/card/card.css +1 -1
- package/dist/collection/components/content/carousel/carousel.css +91 -5
- package/dist/collection/components/content/carousel/carousel.js +511 -20
- package/dist/collection/components/content/carousel/internals/autoplay.js +64 -0
- package/dist/collection/components/content/carousel/internals/slide-state.js +50 -0
- package/dist/collection/components/content/carousel/test/transitions.cmp.test.js +328 -0
- package/dist/collection/components/data-display/accordion/accordion.js +1 -1
- package/dist/collection/components/data-display/data-table/data-table-cell.js +4 -0
- package/dist/collection/components/data-display/data-table/data-table.css +73 -0
- package/dist/collection/components/data-display/data-table/data-table.js +117 -3
- package/dist/collection/components/data-display/data-table/internals/render-table-body.js +15 -3
- package/dist/collection/components/data-display/data-table/internals/render-table-head.js +1 -1
- package/dist/collection/components/data-display/data-table/internals/table-model.js +9 -1
- package/dist/collection/components/data-display/data-table/test/row-gutter.cmp.test.js +104 -0
- package/dist/collection/components/data-display/data-table/test/two-line-rows.cmp.test.js +164 -0
- package/dist/collection/components/data-display/map/internals/marker-controller.js +22 -0
- package/dist/collection/components/data-display/map/internals/marker-presentation.js +51 -2
- package/dist/collection/components/data-display/map/internals/markers.js +16 -1
- package/dist/collection/components/data-display/map/map.css +31 -0
- package/dist/collection/components/data-display/map/map.js +96 -15
- package/dist/collection/components/data-display/map/map.types.js +1 -1
- package/dist/collection/components/data-display/map/test/map.cmp.test.js +213 -0
- package/dist/collection/components/data-display/pagination/pagination.js +1 -1
- package/dist/collection/components/data-display/syntax-box/internals/value-sync.js +6 -23
- package/dist/collection/components/data-display/syntax-box/internals/value-sync.unit.test.js +25 -0
- package/dist/collection/components/data-display/syntax-box/syntax-box.css +12 -5
- package/dist/collection/components/data-display/syntax-box/syntax-box.js +78 -23
- package/dist/collection/components/data-display/syntax-box/test/format-fixtures.js +20 -0
- package/dist/collection/components/data-display/syntax-box/test/syntax-box.cmp.test.js +241 -0
- package/dist/collection/components/data-display/syntax-box/test/syntax-fixtures.js +14 -0
- package/dist/collection/components/data-display/syntax-box/test/syntax-format.cmp.test.js +157 -0
- package/dist/collection/components/indicators/step-diagram/step-diagram.js +2 -2
- package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.js +1 -1
- package/dist/collection/components/inputs/dropdown/dropdown.css +11 -11
- package/dist/collection/components/inputs/dropdown/dropdown.js +64 -10
- package/dist/collection/components/inputs/form/form.css +5 -5
- package/dist/collection/components/inputs/form/form.js +203 -100
- package/dist/collection/components/inputs/form/internals/controls.js +121 -27
- package/dist/collection/components/inputs/form/internals/enter-behavior.js +14 -25
- package/dist/collection/components/inputs/form/internals/field-state.js +129 -0
- package/dist/collection/components/inputs/form/internals/reset.js +50 -0
- package/dist/collection/components/inputs/form/internals/submission.js +140 -0
- package/dist/collection/components/inputs/form/internals/values.js +176 -153
- package/dist/collection/components/inputs/form/internals/values.unit.test.js +59 -0
- package/dist/collection/components/inputs/form/test/form-reset-state.cmp.test.js +559 -0
- package/dist/collection/components/inputs/form/test/form-submit-transport.cmp.test.js +352 -0
- package/dist/collection/components/inputs/form/test/form-submit.cmp.test.js +438 -0
- package/dist/collection/components/inputs/form/test/form-values.cmp.test.js +440 -0
- package/dist/collection/components/inputs/input/input.css +10 -10
- package/dist/collection/components/inputs/input/input.js +91 -20
- package/dist/collection/components/inputs/quantity-selector/quantity-selector.css +6 -6
- package/dist/collection/components/inputs/quantity-selector/quantity-selector.js +4 -4
- package/dist/collection/components/inputs/radio-group/radio-group.css +10 -10
- package/dist/collection/components/inputs/radio-group/radio-group.js +51 -9
- package/dist/collection/components/inputs/textarea/textarea.css +10 -10
- package/dist/collection/components/inputs/textarea/textarea.js +70 -18
- package/dist/collection/components/inputs/toggle/toggle.css +10 -10
- package/dist/collection/components/inputs/toggle/toggle.js +57 -10
- package/dist/collection/components/layout/grid/grid.js +1 -1
- package/dist/collection/components/layout/inline/inline.js +1 -1
- package/dist/collection/components/layout/navbar/navbar.css +10 -10
- package/dist/collection/components/layout/navbar/navbar.js +2 -2
- package/dist/collection/components/layout/panel/panel.js +4 -4
- package/dist/collection/components/layout/scrollable/scrollable.js +3 -3
- package/dist/collection/components/layout/section/section.js +1 -1
- package/dist/collection/components/layout/sidepanel/internals/drawer.js +42 -4
- package/dist/collection/components/layout/sidepanel/sidepanel.css +148 -17
- package/dist/collection/components/layout/sidepanel/sidepanel.js +99 -10
- package/dist/collection/components/layout/sidepanel/test/nav-drawer-transitions.cmp.test.js +120 -0
- package/dist/collection/components/layout/sidepanel/test/panel-transitions.cmp.test.js +180 -0
- package/dist/collection/components/layout/stack/stack.js +1 -1
- package/dist/collection/components/layout/tabs/tabs.css +9 -9
- package/dist/collection/components/layout/tabs/tabs.js +1 -1
- package/dist/collection/components/layout/toolbar/toolbar.css +6 -6
- package/dist/collection/components/layout/toolbar/toolbar.js +2 -2
- package/dist/collection/components/media/avatar/avatar.js +1 -1
- package/dist/collection/components/media/icon/internals/fetch-icon.js +33 -4
- package/dist/collection/components/media/icon/internals/fetch-icon.unit.test.js +51 -0
- package/dist/collection/components/media/icon/internals/policy.js +184 -0
- package/dist/collection/components/media/icon/internals/policy.unit.test.js +65 -0
- package/dist/collection/components/media/icon/internals/registry-lucide.unit.test.js +78 -0
- package/dist/collection/components/media/icon/internals/registry.js +33 -82
- package/dist/collection/components/media/icon/internals/sanitize-svg.js +80 -57
- package/dist/collection/components/media/icon/internals/url.js +31 -27
- package/dist/collection/components/media/icon/internals/url.unit.test.js +34 -0
- package/dist/collection/components/media/icon/test/icon-fixtures.js +47 -0
- package/dist/collection/components/media/icon/test/icon.cmp.test.js +223 -0
- package/dist/collection/components/media/image-comparison/image-comparison.css +124 -0
- package/dist/collection/components/media/image-comparison/image-comparison.js +468 -0
- package/dist/collection/components/media/image-comparison/test/image-comparison.cmp.test.js +234 -0
- package/dist/collection/components/media/media/media.js +22 -22
- package/dist/collection/components/media/reel/reel.js +2 -2
- package/dist/collection/components/media/thumbnail/thumbnail.js +2 -2
- package/dist/collection/components/overlays/dialog/dialog.css +1 -1
- package/dist/collection/components/overlays/dialog/dialog.js +2 -2
- package/dist/collection/components/overlays/tooltip/internals/positioning.js +20 -5
- package/dist/collection/components/overlays/tooltip/tooltip.css +6 -2
- package/dist/collection/components/overlays/tooltip/tooltip.js +9 -3
- package/dist/collection/components/shared/field.js +1 -1
- package/dist/collection/index.js +2 -1
- package/dist/collection/native-content.css +24 -0
- package/dist/collection/playground/assets/comparison-after.svg +1 -0
- package/dist/collection/playground/assets/comparison-before.svg +1 -0
- package/dist/collection/playground/components/playground-header/playground-header.js +1 -1
- package/dist/collection/playground/playground.bundled.js +164 -4
- package/dist/collection/theme/test/foundation.cmp.test.js +6 -0
- package/dist/collection/theme/test/presets.cmp.test.js +129 -0
- package/dist/collection/theme/tokens.js +136 -4
- package/dist/collection/utils/form-field-adapter.js +44 -0
- package/dist/collection/utils/form-field-state.js +45 -0
- package/dist/collection/utils/form-reset-action.js +60 -0
- package/dist/collection/utils/form-submit-action.js +151 -0
- package/dist/collection/utils/form-submit-action.unit.test.js +15 -0
- package/dist/collection/utils/formatter.js +137 -158
- package/dist/collection/utils/formatter.unit.test.js +69 -51
- package/dist/collection/utils/image-crop.js +47 -0
- package/dist/collection/utils/image-crop.unit.test.js +57 -0
- package/dist/collection/utils/syntax.js +210 -81
- package/dist/collection/utils/syntax.unit.test.js +134 -0
- package/dist/components/index.js +1 -1
- package/dist/components/{p-NEolaUak.js → p-6PPZ2sIO.js} +1 -1
- package/dist/components/p-B4Mg1xEw.js +1 -0
- package/dist/components/{p-BxFGkrUe.js → p-BH4gQWub.js} +1 -1
- package/dist/components/p-BOdNg0jc.js +1 -0
- package/dist/components/p-BcL0NVv0.js +1 -0
- package/dist/components/p-BofcK-7Z.js +1 -0
- package/dist/components/p-C6vxokHH.js +1 -0
- package/dist/components/p-CGml_DQ8.js +1 -0
- package/dist/components/{p-CK7avZdv.js → p-CKuPOxKN.js} +1 -1
- package/dist/components/p-CN1ut2Lb.js +1 -0
- package/dist/components/p-C_RztzNv.js +5 -0
- package/dist/components/p-CoIMrUb3.js +1 -0
- package/dist/components/{p-g9vOVxQ4.js → p-DKrPmn2y.js} +2 -2
- package/dist/components/p-DT6k8Yhx.js +1 -0
- package/dist/components/p-Dfp_If-_.js +1 -0
- package/dist/components/p-DstNl_WY.js +1 -0
- package/dist/components/p-GHhpSfZU.js +1 -0
- package/dist/components/p-SzKf4WZF.js +1 -0
- package/dist/components/p-ye27qtRo.js +1 -0
- package/dist/components/q-accordion.js +1 -1
- package/dist/components/q-alert.js +1 -1
- package/dist/components/q-avatar.js +1 -1
- package/dist/components/q-banner.js +1 -1
- package/dist/components/q-button.js +1 -1
- package/dist/components/q-card.js +1 -1
- package/dist/components/q-carousel.js +1 -1
- package/dist/components/q-chip.js +1 -1
- package/dist/components/q-conversation-bubble.js +1 -1
- package/dist/components/q-data-table.js +1 -1
- package/dist/components/q-dialog.js +1 -1
- package/dist/components/q-dropdown.js +1 -1
- package/dist/components/q-form.js +1 -1
- package/dist/components/q-grid.js +1 -1
- package/dist/components/q-icon.js +1 -1
- package/dist/components/q-image-comparison.d.ts +11 -0
- package/dist/components/q-image-comparison.js +1 -0
- package/dist/components/q-inline.js +1 -1
- package/dist/components/q-input.js +1 -1
- package/dist/components/q-link.js +1 -1
- package/dist/components/q-map.js +1 -1
- package/dist/components/q-media.js +1 -1
- package/dist/components/q-navbar.js +1 -1
- package/dist/components/q-pagination.js +1 -1
- package/dist/components/q-panel.js +1 -1
- package/dist/components/q-progress.js +1 -1
- package/dist/components/q-quantity-selector.js +1 -1
- package/dist/components/q-radio-group.js +1 -1
- package/dist/components/q-reel.js +1 -1
- package/dist/components/q-scrollable.js +1 -1
- package/dist/components/q-section.js +1 -1
- package/dist/components/q-sidepanel.js +5 -5
- package/dist/components/q-stack.js +1 -1
- package/dist/components/q-step-diagram-item.js +1 -1
- package/dist/components/q-step-diagram.js +1 -1
- package/dist/components/q-syntax-box.js +5 -5
- package/dist/components/q-tabs.js +1 -1
- package/dist/components/q-textarea.js +1 -1
- package/dist/components/q-thumbnail.js +1 -1
- package/dist/components/q-toast.js +1 -1
- package/dist/components/q-toggle.js +1 -1
- package/dist/components/q-toolbar.js +1 -1
- package/dist/components/q-tooltip.js +1 -1
- package/dist/esm/{action.props-GP1ameE3.js → action.props-CpnGza8z.js} +1 -1
- package/dist/esm/{chevron-up-g9vOVxQ4.js → chevron-up-DKrPmn2y.js} +2 -2
- package/dist/esm/{data-table-cell-DmqVhVoj.js → data-table-cell-SzKf4WZF.js} +5 -1
- package/dist/esm/{field-DkpyvZiX.js → field-zfD6OQ02.js} +2 -2
- package/dist/esm/form-field-adapter-CGml_DQ8.js +46 -0
- package/dist/esm/form-field-state-DstNl_WY.js +47 -0
- package/dist/esm/form-submit-action-CoEIvDqE.js +213 -0
- package/dist/esm/image-crop-BcL0NVv0.js +49 -0
- package/dist/esm/{index-DbGG9Q40.js → index-B5ElFlHv.js} +25 -26
- package/dist/esm/index.js +4 -3
- package/dist/esm/leaflet-maplibre-gl-BvKlNmWf.js +1020 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{map.types-WJHaLJS_.js → map.types-CoIMrUb3.js} +1 -1
- package/dist/esm/q-accordion.entry.js +2 -2
- package/dist/esm/q-alert.entry.js +1 -1
- package/dist/esm/q-avatar.entry.js +2 -2
- package/dist/esm/q-banner.entry.js +1 -1
- package/dist/esm/q-button_2.entry.js +112 -25
- package/dist/esm/q-card.entry.js +3 -3
- package/dist/esm/q-carousel.entry.js +400 -13
- package/dist/esm/q-chip.entry.js +2 -2
- package/dist/esm/q-conversation-bubble.entry.js +1 -1
- package/dist/esm/q-data-table.entry.js +73 -11
- package/dist/esm/q-dialog.entry.js +4 -4
- package/dist/esm/q-dropdown.entry.js +65 -12
- package/dist/esm/q-form.entry.js +775 -288
- package/dist/esm/q-grid.entry.js +3 -3
- package/dist/esm/q-icon.entry.js +143 -89
- package/dist/esm/q-image-comparison.entry.js +199 -0
- package/dist/esm/q-inline.entry.js +3 -3
- package/dist/esm/q-input_2.entry.js +91 -23
- package/dist/esm/q-link.entry.js +2 -2
- package/dist/esm/q-map.entry.js +141 -22
- package/dist/esm/q-media.entry.js +3 -3
- package/dist/esm/q-navbar.entry.js +4 -4
- package/dist/esm/q-pagination.entry.js +2 -2
- package/dist/esm/q-panel.entry.js +6 -6
- package/dist/esm/q-quantity-selector.entry.js +6 -6
- package/dist/esm/q-radio-group.entry.js +49 -12
- package/dist/esm/q-reel.entry.js +3 -3
- package/dist/esm/q-scrollable.entry.js +4 -4
- package/dist/esm/q-section.entry.js +2 -2
- package/dist/esm/q-sidepanel.entry.js +146 -26
- package/dist/esm/q-stack.entry.js +3 -3
- package/dist/esm/q-step-diagram-item.entry.js +2 -2
- package/dist/esm/q-step-diagram.entry.js +3 -3
- package/dist/esm/q-syntax-box.entry.js +418 -301
- package/dist/esm/q-tabs.entry.js +3 -3
- package/dist/esm/q-textarea.entry.js +67 -22
- package/dist/esm/q-thumbnail.entry.js +3 -3
- package/dist/esm/q-toast.entry.js +1 -1
- package/dist/esm/q-toggle.entry.js +59 -13
- package/dist/esm/q-toolbar.entry.js +5 -5
- package/dist/esm/registry-GHhpSfZU.js +308 -0
- package/dist/esm/tokens-B4Mg1xEw.js +953 -0
- package/dist/esm/webquark.js +4 -4
- package/dist/playground/assets/comparison-after.svg +1 -0
- package/dist/playground/assets/comparison-before.svg +1 -0
- package/dist/playground/assets/icons/check-preview.png +0 -0
- package/dist/playground/assets/icons/spinner.svg +1 -1
- package/dist/playground/build/index.esm.js +1 -1
- package/dist/playground/build/{p-737ca99e.entry.js → p-023f8437.entry.js} +1 -1
- package/dist/{webquark/p-989bdc1a.entry.js → playground/build/p-030ecde3.entry.js} +1 -1
- package/dist/playground/build/p-04c8cb9e.entry.js +1 -0
- package/dist/playground/build/p-059daa8a.entry.js +1 -0
- package/dist/playground/build/{p-ecbc0fee.entry.js → p-09cca7b9.entry.js} +1 -1
- package/dist/playground/build/p-0aa74ad6.entry.js +1 -0
- package/dist/playground/build/p-0ae43d6c.entry.js +1 -0
- package/dist/playground/build/p-0c3aac3f.entry.js +1 -0
- package/dist/playground/build/p-144ef339.entry.js +1 -0
- package/dist/playground/build/p-1d1f7bc3.entry.js +1 -0
- package/dist/playground/build/p-296fbdb1.entry.js +1 -0
- package/dist/playground/build/p-36118d90.entry.js +1 -0
- package/dist/playground/build/{p-742e39f1.entry.js → p-3bc4629c.entry.js} +1 -1
- package/dist/playground/build/{p-8bdababd.entry.js → p-48fb5228.entry.js} +1 -1
- package/dist/{webquark/p-abf54361.entry.js → playground/build/p-4d61b70d.entry.js} +1 -1
- package/dist/playground/build/p-5f232b44.entry.js +13 -0
- package/dist/playground/build/{p-6b63922b.entry.js → p-64096386.entry.js} +1 -1
- package/dist/playground/build/{p-15502232.entry.js → p-6bfffa79.entry.js} +1 -1
- package/dist/{webquark/p-ff1e2363.entry.js → playground/build/p-6e28cfe2.entry.js} +1 -1
- package/dist/playground/build/{p-96ef2b54.entry.js → p-70d9ffde.entry.js} +1 -1
- package/dist/playground/build/{p-97dae970.entry.js → p-8ece2c62.entry.js} +1 -1
- package/dist/playground/build/p-90b0858c.entry.js +1 -0
- package/dist/playground/build/p-91fff6b6.entry.js +1 -0
- package/dist/playground/build/p-923dac41.entry.js +1 -0
- package/dist/playground/build/p-97a89cae.entry.js +1 -0
- package/dist/playground/build/{p-f911c90f.entry.js → p-99d785ca.entry.js} +1 -1
- package/dist/playground/build/p-9e78b796.entry.js +1 -0
- package/dist/{webquark/p-d4a915e5.entry.js → playground/build/p-9ff7e5a4.entry.js} +1 -1
- package/dist/playground/build/p-B4Mg1xEw.js +1 -0
- package/dist/playground/build/p-B5ElFlHv.js +3 -0
- package/dist/playground/build/p-BOdNg0jc.js +1 -0
- package/dist/playground/build/p-BcL0NVv0.js +1 -0
- package/dist/playground/build/p-CGml_DQ8.js +1 -0
- package/dist/playground/build/p-C_RztzNv.js +5 -0
- package/dist/playground/build/p-CoIMrUb3.js +1 -0
- package/dist/{webquark/p-g9vOVxQ4.js → playground/build/p-DKrPmn2y.js} +2 -2
- package/dist/playground/build/{p-BqvCR2U8.js → p-DWO-pleQ.js} +1 -1
- package/dist/playground/build/p-Dhsn99q4.js +1 -0
- package/dist/playground/build/p-DstNl_WY.js +1 -0
- package/dist/playground/build/p-GHhpSfZU.js +1 -0
- package/dist/playground/build/p-SzKf4WZF.js +1 -0
- package/dist/playground/build/p-c523ec6f.entry.js +1 -0
- package/dist/playground/build/p-d0253d64.entry.js +1 -0
- package/dist/playground/build/p-d0fbd2b1.entry.js +1 -0
- package/dist/playground/build/{p-0d98e500.entry.js → p-dd115868.entry.js} +1 -1
- package/dist/playground/build/{p-c4fd89b8.entry.js → p-f1bac94c.entry.js} +1 -1
- package/dist/playground/build/p-f4f97e74.entry.js +1 -0
- package/dist/playground/build/p-f63b7214.entry.js +1 -0
- package/dist/{webquark/p-b465aebd.entry.js → playground/build/p-f98f9439.entry.js} +1 -1
- package/dist/playground/build/{p-de8813be.entry.js → p-f9ad63ff.entry.js} +1 -1
- package/dist/playground/build/p-fe200f68.entry.js +1 -0
- package/dist/playground/build/p-fe8c634a.entry.js +13 -0
- package/dist/playground/build/p-fec6fe0a.entry.js +1 -0
- package/dist/playground/build/webquark.css +1 -1
- package/dist/playground/build/webquark.esm.js +1 -1
- package/dist/playground/native-content.css +24 -0
- package/dist/playground/playground/components.manifest.json +1 -0
- package/dist/playground/playground/specs/q-carousel.sandbox.json +15 -0
- package/dist/playground/playground/specs/q-data-table.sandbox.json +24 -0
- package/dist/playground/playground/specs/q-icon.sandbox.json +17 -1
- package/dist/playground/playground/specs/q-image-comparison.sandbox.json +24 -0
- package/dist/playground/playground/specs/q-syntax-box.sandbox.json +68 -24
- package/dist/playground/playground.js +164 -4
- package/dist/playground/presets.html +47 -0
- package/dist/types/components/actions/button/button.d.ts +26 -0
- package/dist/types/components/actions/button/test/button-slots.cmp.test.d.ts +1 -0
- package/dist/types/components/content/carousel/carousel.d.ts +71 -4
- package/dist/types/components/content/carousel/carousel.types.d.ts +5 -0
- package/dist/types/components/content/carousel/internals/autoplay.d.ts +22 -0
- package/dist/types/components/content/carousel/internals/slide-state.d.ts +8 -0
- package/dist/types/components/content/carousel/test/transitions.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/data-table/data-table-cell.d.ts +2 -0
- package/dist/types/components/data-display/data-table/data-table.d.ts +18 -1
- package/dist/types/components/data-display/data-table/data-table.types.d.ts +3 -0
- package/dist/types/components/data-display/data-table/internals/render-table-body.d.ts +1 -0
- package/dist/types/components/data-display/data-table/internals/table-model.d.ts +5 -1
- package/dist/types/components/data-display/data-table/test/row-gutter.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/data-table/test/two-line-rows.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/map/internals/marker-controller.d.ts +2 -0
- package/dist/types/components/data-display/map/map.d.ts +7 -3
- package/dist/types/components/data-display/map/map.types.d.ts +11 -1
- package/dist/types/components/data-display/syntax-box/internals/value-sync.d.ts +1 -4
- package/dist/types/components/data-display/syntax-box/internals/value-sync.unit.test.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/syntax-box.d.ts +9 -3
- package/dist/types/components/data-display/syntax-box/test/format-fixtures.d.ts +6 -0
- package/dist/types/components/data-display/syntax-box/test/syntax-box.cmp.test.d.ts +1 -0
- package/dist/types/components/data-display/syntax-box/test/syntax-fixtures.d.ts +9 -0
- package/dist/types/components/data-display/syntax-box/test/syntax-format.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/dropdown/dropdown.d.ts +5 -0
- package/dist/types/components/inputs/form/form.d.ts +12 -7
- package/dist/types/components/inputs/form/form.types.d.ts +2 -0
- package/dist/types/components/inputs/form/internals/controls.d.ts +3 -0
- package/dist/types/components/inputs/form/internals/field-state.d.ts +19 -0
- package/dist/types/components/inputs/form/internals/reset.d.ts +3 -0
- package/dist/types/components/inputs/form/internals/submission.d.ts +17 -0
- package/dist/types/components/inputs/form/internals/values.d.ts +6 -1
- package/dist/types/components/inputs/form/internals/values.unit.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-reset-state.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-submit-transport.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-submit.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/test/form-values.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/input/input.d.ts +7 -1
- package/dist/types/components/inputs/radio-group/radio-group.d.ts +4 -0
- package/dist/types/components/inputs/textarea/textarea.d.ts +6 -1
- package/dist/types/components/inputs/toggle/toggle.d.ts +5 -0
- package/dist/types/components/layout/sidepanel/sidepanel.d.ts +9 -0
- package/dist/types/components/layout/sidepanel/test/nav-drawer-transitions.cmp.test.d.ts +1 -0
- package/dist/types/components/layout/sidepanel/test/panel-transitions.cmp.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/fetch-icon.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/policy.d.ts +19 -0
- package/dist/types/components/media/icon/internals/policy.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/registry-lucide.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/internals/sanitize-svg.d.ts +1 -1
- package/dist/types/components/media/icon/internals/url.unit.test.d.ts +1 -0
- package/dist/types/components/media/icon/test/icon-fixtures.d.ts +4 -0
- package/dist/types/components/media/icon/test/icon.cmp.test.d.ts +1 -0
- package/dist/types/components/media/image-comparison/image-comparison.d.ts +63 -0
- package/dist/types/components/media/image-comparison/test/image-comparison.cmp.test.d.ts +1 -0
- package/dist/types/components/media/media/media.d.ts +1 -1
- package/dist/types/components/overlays/tooltip/internals/positioning.d.ts +1 -1
- package/dist/types/components/overlays/tooltip/tooltip.d.ts +5 -0
- package/dist/types/components.d.ts +436 -23
- package/dist/types/index.d.ts +7 -4
- package/dist/types/theme/test/presets.cmp.test.d.ts +7 -0
- package/dist/types/theme/tokens.d.ts +78 -0
- package/dist/types/utils/form-field-adapter.d.ts +17 -0
- package/dist/types/utils/form-field-state.d.ts +4 -0
- package/dist/types/utils/form-reset-action.d.ts +5 -0
- package/dist/types/utils/form-submit-action.d.ts +17 -0
- package/dist/types/utils/form-submit-action.unit.test.d.ts +1 -0
- package/dist/types/utils/formatter.d.ts +10 -19
- package/dist/types/utils/image-crop.d.ts +30 -0
- package/dist/types/utils/image-crop.unit.test.d.ts +1 -0
- package/dist/types/utils/syntax.d.ts +11 -7
- package/dist/types/utils/syntax.unit.test.d.ts +1 -0
- package/dist/webquark/index.esm.js +1 -1
- package/dist/webquark/native-content.css +24 -0
- package/dist/webquark/{p-737ca99e.entry.js → p-023f8437.entry.js} +1 -1
- package/dist/{playground/build/p-989bdc1a.entry.js → webquark/p-030ecde3.entry.js} +1 -1
- package/dist/webquark/p-04c8cb9e.entry.js +1 -0
- package/dist/webquark/p-059daa8a.entry.js +1 -0
- package/dist/webquark/{p-ecbc0fee.entry.js → p-09cca7b9.entry.js} +1 -1
- package/dist/webquark/p-0aa74ad6.entry.js +1 -0
- package/dist/webquark/p-0ae43d6c.entry.js +1 -0
- package/dist/webquark/p-0c3aac3f.entry.js +1 -0
- package/dist/webquark/p-144ef339.entry.js +1 -0
- package/dist/webquark/p-1d1f7bc3.entry.js +1 -0
- package/dist/webquark/p-296fbdb1.entry.js +1 -0
- package/dist/webquark/p-36118d90.entry.js +1 -0
- package/dist/webquark/{p-742e39f1.entry.js → p-3bc4629c.entry.js} +1 -1
- package/dist/webquark/{p-8bdababd.entry.js → p-48fb5228.entry.js} +1 -1
- package/dist/{playground/build/p-abf54361.entry.js → webquark/p-4d61b70d.entry.js} +1 -1
- package/dist/webquark/p-5f232b44.entry.js +13 -0
- package/dist/webquark/{p-6b63922b.entry.js → p-64096386.entry.js} +1 -1
- package/dist/webquark/{p-15502232.entry.js → p-6bfffa79.entry.js} +1 -1
- package/dist/{playground/build/p-ff1e2363.entry.js → webquark/p-6e28cfe2.entry.js} +1 -1
- package/dist/webquark/{p-96ef2b54.entry.js → p-70d9ffde.entry.js} +1 -1
- package/dist/webquark/{p-97dae970.entry.js → p-8ece2c62.entry.js} +1 -1
- package/dist/webquark/p-90b0858c.entry.js +1 -0
- package/dist/webquark/p-91fff6b6.entry.js +1 -0
- package/dist/webquark/p-923dac41.entry.js +1 -0
- package/dist/webquark/p-97a89cae.entry.js +1 -0
- package/dist/webquark/{p-f911c90f.entry.js → p-99d785ca.entry.js} +1 -1
- package/dist/webquark/p-9e78b796.entry.js +1 -0
- package/dist/{playground/build/p-d4a915e5.entry.js → webquark/p-9ff7e5a4.entry.js} +1 -1
- package/dist/webquark/p-B4Mg1xEw.js +1 -0
- package/dist/webquark/p-B5ElFlHv.js +3 -0
- package/dist/webquark/p-BOdNg0jc.js +1 -0
- package/dist/webquark/p-BcL0NVv0.js +1 -0
- package/dist/webquark/p-CGml_DQ8.js +1 -0
- package/dist/webquark/p-C_RztzNv.js +5 -0
- package/dist/webquark/p-CoIMrUb3.js +1 -0
- package/dist/{playground/build/p-g9vOVxQ4.js → webquark/p-DKrPmn2y.js} +2 -2
- package/dist/webquark/{p-BqvCR2U8.js → p-DWO-pleQ.js} +1 -1
- package/dist/webquark/p-Dhsn99q4.js +1 -0
- package/dist/webquark/p-DstNl_WY.js +1 -0
- package/dist/webquark/p-GHhpSfZU.js +1 -0
- package/dist/webquark/p-SzKf4WZF.js +1 -0
- package/dist/webquark/p-c523ec6f.entry.js +1 -0
- package/dist/webquark/p-d0253d64.entry.js +1 -0
- package/dist/webquark/p-d0fbd2b1.entry.js +1 -0
- package/dist/webquark/{p-0d98e500.entry.js → p-dd115868.entry.js} +1 -1
- package/dist/webquark/{p-c4fd89b8.entry.js → p-f1bac94c.entry.js} +1 -1
- package/dist/webquark/p-f4f97e74.entry.js +1 -0
- package/dist/webquark/p-f63b7214.entry.js +1 -0
- package/dist/{playground/build/p-b465aebd.entry.js → webquark/p-f98f9439.entry.js} +1 -1
- package/dist/webquark/{p-de8813be.entry.js → p-f9ad63ff.entry.js} +1 -1
- package/dist/webquark/p-fe200f68.entry.js +1 -0
- package/dist/webquark/p-fe8c634a.entry.js +13 -0
- package/dist/webquark/p-fec6fe0a.entry.js +1 -0
- package/dist/webquark/webquark.css +1 -1
- package/dist/webquark/webquark.esm.js +1 -1
- package/package.json +17 -19
- package/scripts/webquark-serve.js +9 -7
- package/scripts/wq-switch/README.md +115 -103
- package/scripts/wq-switch/dist/index.js +129 -82
- package/scripts/wq-switch/dist/setup.js +81 -61
- package/dist/cjs/leaflet-maplibre-gl-BJKExsns.js +0 -1031
- package/dist/cjs/registry-BhkCNgxt.js +0 -179
- package/dist/cjs/tokens-DGECOqpA.js +0 -42
- package/dist/components/p-0PieXMX9.js +0 -1
- package/dist/components/p-BOYjkCNa.js +0 -1
- package/dist/components/p-BvBRW3dl.js +0 -1
- package/dist/components/p-Bw4TVbfm.js +0 -1
- package/dist/components/p-CFuqfXuv.js +0 -9
- package/dist/components/p-Cx1vCuMp.js +0 -1
- package/dist/components/p-D0Q2vrt5.js +0 -1
- package/dist/components/p-DmqVhVoj.js +0 -1
- package/dist/components/p-GU98U1DJ.js +0 -1
- package/dist/components/p-WJHaLJS_.js +0 -1
- package/dist/components/p-f95uguY1.js +0 -1
- package/dist/esm/leaflet-maplibre-gl-BVDAAs7w.js +0 -1026
- package/dist/esm/registry-BvBRW3dl.js +0 -173
- package/dist/esm/tokens-f95uguY1.js +0 -38
- package/dist/playground/build/p-0aea8464.entry.js +0 -1
- package/dist/playground/build/p-0aecd9b1.entry.js +0 -1
- package/dist/playground/build/p-139fec38.entry.js +0 -1
- package/dist/playground/build/p-17340abf.entry.js +0 -1
- package/dist/playground/build/p-303dcac8.entry.js +0 -1
- package/dist/playground/build/p-408bf48a.entry.js +0 -1
- package/dist/playground/build/p-47253466.entry.js +0 -1
- package/dist/playground/build/p-5f6860f2.entry.js +0 -13
- package/dist/playground/build/p-6b619655.entry.js +0 -1
- package/dist/playground/build/p-71e3d582.entry.js +0 -1
- package/dist/playground/build/p-8115ec23.entry.js +0 -1
- package/dist/playground/build/p-8ad43d7f.entry.js +0 -1
- package/dist/playground/build/p-9418caa0.entry.js +0 -1
- package/dist/playground/build/p-BvBRW3dl.js +0 -1
- package/dist/playground/build/p-CFuqfXuv.js +0 -9
- package/dist/playground/build/p-DbGG9Q40.js +0 -3
- package/dist/playground/build/p-DmqVhVoj.js +0 -1
- package/dist/playground/build/p-JgeOdXyP.js +0 -1
- package/dist/playground/build/p-WJHaLJS_.js +0 -1
- package/dist/playground/build/p-a4b36120.entry.js +0 -1
- package/dist/playground/build/p-aed4b219.entry.js +0 -1
- package/dist/playground/build/p-b3a07d94.entry.js +0 -1
- package/dist/playground/build/p-c1f3dca6.entry.js +0 -1
- package/dist/playground/build/p-c4899c2b.entry.js +0 -1
- package/dist/playground/build/p-cf8f7f2a.entry.js +0 -1
- package/dist/playground/build/p-d7d436c5.entry.js +0 -13
- package/dist/playground/build/p-eb71e335.entry.js +0 -1
- package/dist/playground/build/p-ed327679.entry.js +0 -1
- package/dist/playground/build/p-f95uguY1.js +0 -1
- package/dist/webquark/p-0aea8464.entry.js +0 -1
- package/dist/webquark/p-0aecd9b1.entry.js +0 -1
- package/dist/webquark/p-139fec38.entry.js +0 -1
- package/dist/webquark/p-17340abf.entry.js +0 -1
- package/dist/webquark/p-303dcac8.entry.js +0 -1
- package/dist/webquark/p-408bf48a.entry.js +0 -1
- package/dist/webquark/p-47253466.entry.js +0 -1
- package/dist/webquark/p-5f6860f2.entry.js +0 -13
- package/dist/webquark/p-6b619655.entry.js +0 -1
- package/dist/webquark/p-71e3d582.entry.js +0 -1
- package/dist/webquark/p-8115ec23.entry.js +0 -1
- package/dist/webquark/p-8ad43d7f.entry.js +0 -1
- package/dist/webquark/p-9418caa0.entry.js +0 -1
- package/dist/webquark/p-BvBRW3dl.js +0 -1
- package/dist/webquark/p-CFuqfXuv.js +0 -9
- package/dist/webquark/p-DbGG9Q40.js +0 -3
- package/dist/webquark/p-DmqVhVoj.js +0 -1
- package/dist/webquark/p-JgeOdXyP.js +0 -1
- package/dist/webquark/p-WJHaLJS_.js +0 -1
- package/dist/webquark/p-a4b36120.entry.js +0 -1
- package/dist/webquark/p-aed4b219.entry.js +0 -1
- package/dist/webquark/p-b3a07d94.entry.js +0 -1
- package/dist/webquark/p-c1f3dca6.entry.js +0 -1
- package/dist/webquark/p-c4899c2b.entry.js +0 -1
- package/dist/webquark/p-cf8f7f2a.entry.js +0 -1
- package/dist/webquark/p-d7d436c5.entry.js +0 -13
- package/dist/webquark/p-eb71e335.entry.js +0 -1
- package/dist/webquark/p-ed327679.entry.js +0 -1
- package/dist/webquark/p-f95uguY1.js +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { prepareQIconDefinition } from "./registry";
|
|
3
|
+
import { MAX_ICON_ATTRIBUTE_BYTES, MAX_ICON_ATTRIBUTES, MAX_ICON_DEPTH, MAX_ICON_NODES, MAX_ICON_SVG_BYTES } from "./policy";
|
|
4
|
+
import { RESOURCE_ICON } from "../test/icon-fixtures";
|
|
5
|
+
describe('shared strict icon definition policy', () => {
|
|
6
|
+
it('preserves ordinary geometry, masks, gradients, groups and local symbols as frozen data', () => {
|
|
7
|
+
const prepared = prepareQIconDefinition(RESOURCE_ICON);
|
|
8
|
+
expect(prepared).toEqual(RESOURCE_ICON);
|
|
9
|
+
expect(Object.isFrozen(prepared.node[0][2])).toBe(true);
|
|
10
|
+
expect(Object.isFrozen(prepared.node[1][1])).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
it.each(['script', 'foreignObject', 'a', 'animate', 'set', 'image', 'svg', 'unknown'])('rejects unsupported element %s', tag => {
|
|
13
|
+
expect(() => prepareQIconDefinition({ node: [[tag, {}]] })).toThrow(/unsupported SVG element/);
|
|
14
|
+
});
|
|
15
|
+
it.each([
|
|
16
|
+
['onclick', ''], ['OnLoad', ''], ['style', 'fill:red'], ['src', '#shape'], ['tabindex', '0'],
|
|
17
|
+
['innerHTML', 'inert'], ['xmlns', 'urn:unsupported'], ['fill', 'url(https://example.invalid/paint)'],
|
|
18
|
+
['fill', 'u\\72l(#paint)'], ['fill', 'var(--external-resource)'], ['fill', 'url(#paint) url(https://example.invalid/paint)'],
|
|
19
|
+
])('rejects unsupported attribute %s=%s', (name, value) => {
|
|
20
|
+
expect(() => prepareQIconDefinition({ node: [['path', { [name]: value }]] })).toThrow();
|
|
21
|
+
});
|
|
22
|
+
it('checks root attributes with the same allowlist and namespace policy', () => {
|
|
23
|
+
expect(() => prepareQIconDefinition({ node: [], attributes: { xmlns: 'urn:unsupported' } })).toThrow(/namespace/);
|
|
24
|
+
expect(() => prepareQIconDefinition({ node: [], attributes: { onload: '' } })).toThrow(/unsupported SVG attribute/);
|
|
25
|
+
});
|
|
26
|
+
it.each(['', ' ', 'two ids', 'bad#id'])('rejects invalid or empty root ID %j', id => {
|
|
27
|
+
expect(() => prepareQIconDefinition({ attributes: { id }, node: [['path', { d: 'M1 1' }]] })).toThrow(/nonempty and unique/);
|
|
28
|
+
});
|
|
29
|
+
it('rejects an ID shared by the root and a child', () => {
|
|
30
|
+
expect(() => prepareQIconDefinition({ attributes: { id: 'duplicate' }, node: [['path', { id: 'duplicate' }]] })).toThrow(/nonempty and unique/);
|
|
31
|
+
});
|
|
32
|
+
it('preserves a valid root ID and child references, but intentionally rejects references to the root', () => {
|
|
33
|
+
const definition = { ...RESOURCE_ICON, attributes: { id: 'icon-root' } };
|
|
34
|
+
expect(prepareQIconDefinition(definition)).toEqual(definition);
|
|
35
|
+
for (const attributes of [{ href: '#icon-root' }, { 'xlink:href': '#icon-root' }, { fill: 'url(#icon-root)' }]) {
|
|
36
|
+
expect(() => prepareQIconDefinition({ attributes: { id: 'icon-root' }, node: [['use', attributes]] })).toThrow(/not the SVG root/);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
it('bounds every attribute before large UTF-8 allocation and the accumulated attribute bytes', () => {
|
|
40
|
+
expect(() => prepareQIconDefinition({ node: [['path', { d: 'x'.repeat(MAX_ICON_ATTRIBUTE_BYTES + 1) }]] })).toThrow(/byte budget/);
|
|
41
|
+
expect(() => prepareQIconDefinition({ node: Array.from({ length: 3 }, () => ['path', { d: 'x'.repeat(MAX_ICON_SVG_BYTES / 2) }]) })).toThrow(/byte budget/);
|
|
42
|
+
expect(() => prepareQIconDefinition({ node: [['path', Object.fromEntries(Array.from({ length: MAX_ICON_ATTRIBUTES + 1 }, (_, i) => [`data-n${i}`, 'x']))]] })).toThrow(/attributes/);
|
|
43
|
+
});
|
|
44
|
+
it('accepts the node/depth boundaries and rejects one beyond either boundary', () => {
|
|
45
|
+
const leaf = () => ['path', { d: 'M1 1' }];
|
|
46
|
+
expect(prepareQIconDefinition({ node: Array.from({ length: MAX_ICON_NODES }, leaf) }).node).toHaveLength(MAX_ICON_NODES);
|
|
47
|
+
expect(() => prepareQIconDefinition({ node: Array.from({ length: MAX_ICON_NODES + 1 }, leaf) })).toThrow(/SVG nodes/);
|
|
48
|
+
let node = leaf();
|
|
49
|
+
for (let depth = 1; depth < MAX_ICON_DEPTH; depth++)
|
|
50
|
+
node = ['g', {}, [node]];
|
|
51
|
+
expect(() => prepareQIconDefinition({ node: [node] })).not.toThrow();
|
|
52
|
+
expect(() => prepareQIconDefinition({ node: [['g', {}, [node]]] })).toThrow(/depth/);
|
|
53
|
+
});
|
|
54
|
+
it('rejects missing/duplicate IDs, cyclic references and exponential local symbol expansion', () => {
|
|
55
|
+
expect(() => prepareQIconDefinition({ node: [['use', { href: '#missing' }]] })).toThrow(/same SVG/);
|
|
56
|
+
expect(() => prepareQIconDefinition({ node: [['path', { id: 'x' }], ['path', { id: 'x' }]] })).toThrow(/unique/);
|
|
57
|
+
expect(() => prepareQIconDefinition({ node: [['symbol', { id: 'x' }, [['use', { href: '#x' }]]]] })).toThrow(/cycle/);
|
|
58
|
+
const symbols = [['symbol', { id: 's0' }, [['path', { d: 'M1 1' }]]]];
|
|
59
|
+
for (let i = 1; i <= 12; i++)
|
|
60
|
+
symbols.push(['symbol', { id: `s${i}` }, [
|
|
61
|
+
['use', { href: `#s${i - 1}` }], ['use', { href: `#s${i - 1}` }],
|
|
62
|
+
]]);
|
|
63
|
+
expect(() => prepareQIconDefinition({ node: [['defs', {}, symbols], ['use', { href: '#s12' }]] })).toThrow(/expansion/);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { Braces, Check, Copy, Bell, CircleAlert } from "@lucide/icons";
|
|
3
|
+
import { prepareQIconDefinition, registerQIcons, resolveRegisteredQIcon } from "./registry";
|
|
4
|
+
import { cloneIconAttributes, createIconBudget, MAX_ICON_ATTRIBUTES, MAX_ICON_ATTRIBUTE_BYTES, MAX_ICON_DEPTH, MAX_ICON_NODES, MAX_ICON_SVG_BYTES } from "./policy";
|
|
5
|
+
const LUCIDE = { Braces, Check, Copy, Bell, CircleAlert };
|
|
6
|
+
afterEach(() => registerQIcons({}));
|
|
7
|
+
describe('registered Lucide node metadata boundary', () => {
|
|
8
|
+
it.each(Object.entries(LUCIDE))('preserves real %s geometry, strips keys and leaves original data intact', (_name, source) => {
|
|
9
|
+
const before = JSON.stringify(source);
|
|
10
|
+
const prepared = prepareQIconDefinition(source);
|
|
11
|
+
expect(prepared.size).toBe(source.size);
|
|
12
|
+
expect(prepared.name).toBe(source.name);
|
|
13
|
+
expect(prepared.node.length).toBe(source.node.length);
|
|
14
|
+
source.node.forEach(([tag, attributes], index) => {
|
|
15
|
+
expect(attributes.key).toBeTypeOf('string');
|
|
16
|
+
expect(prepared.node[index][0]).toBe(tag);
|
|
17
|
+
const { key: _metadata, ...geometry } = attributes;
|
|
18
|
+
expect(prepared.node[index][1]).toEqual(geometry);
|
|
19
|
+
expect(prepared.node[index][1]).not.toHaveProperty('key');
|
|
20
|
+
expect(Object.isFrozen(prepared.node[index][1])).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
expect(JSON.stringify(source)).toBe(before);
|
|
23
|
+
});
|
|
24
|
+
it('supports the documented real Bell/CircleAlert application-owned registry', () => {
|
|
25
|
+
registerQIcons({ bell: Bell, 'circle-alert': CircleAlert });
|
|
26
|
+
expect(resolveRegisteredQIcon('bell').node[0][1].d).toBe(Bell.node[0][1].d);
|
|
27
|
+
expect(resolveRegisteredQIcon('circle-alert').node[0][1].r).toBe(CircleAlert.node[0][1].r);
|
|
28
|
+
expect(resolveRegisteredQIcon('circle-alert').node.every(node => !('key' in node[1]))).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
it('normalizes nested node metadata without changing root attributes or SVG data', () => {
|
|
31
|
+
const prepared = prepareQIconDefinition({ attributes: { id: 'root' }, node: [['g', { key: 'group' }, [['path', { d: 'M1 1', key: 'child' }]]]] });
|
|
32
|
+
expect(prepared.attributes).toEqual({ id: 'root' });
|
|
33
|
+
expect(prepared.node).toEqual([['g', {}, [['path', { d: 'M1 1' }]]]]);
|
|
34
|
+
expect(() => prepareQIconDefinition({ attributes: { key: 'root-key' }, node: [] })).toThrow(/unsupported SVG attribute/);
|
|
35
|
+
expect(() => cloneIconAttributes({ d: 'M1 1', key: 'xml-key' }, 'path', createIconBudget(), 'fetched attributes')).toThrow(/unsupported SVG attribute/);
|
|
36
|
+
});
|
|
37
|
+
it.each([null, 3, true, {}, () => 'key'])('rejects non-string key metadata %s without accepting functions', key => {
|
|
38
|
+
expect(() => prepareQIconDefinition({ node: [['path', { d: 'M1 1', key }]] })).toThrow(/string data property/);
|
|
39
|
+
});
|
|
40
|
+
it('rejects a metadata accessor and does not invoke unknown-attribute getters', () => {
|
|
41
|
+
const getter = vi.fn(() => 'value');
|
|
42
|
+
const keyAttributes = { d: 'M1 1' };
|
|
43
|
+
Object.defineProperty(keyAttributes, 'key', { enumerable: true, get: getter });
|
|
44
|
+
expect(() => prepareQIconDefinition({ node: [['path', keyAttributes]] })).toThrow(/string data property/);
|
|
45
|
+
const unknown = { d: 'M1 1', key: 'metadata' };
|
|
46
|
+
Object.defineProperty(unknown, 'unknown', { enumerable: true, get: getter });
|
|
47
|
+
expect(() => prepareQIconDefinition({ node: [['path', unknown]] })).toThrow(/unsupported SVG attribute/);
|
|
48
|
+
expect(getter).not.toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
it.each([
|
|
51
|
+
['unknown', 'attribute'], ['Key', 'not-known-metadata'], ['onload', 'inert rejection fixture'], ['style', 'fill:red'],
|
|
52
|
+
['href', 'https://example.invalid/icon.svg#x'], ['fill', 'url(https://example.invalid/x)'], ['d', () => 'M1 1'],
|
|
53
|
+
])('still rejects %s SVG data beside a valid metadata key', (name, value) => {
|
|
54
|
+
registerQIcons({ kept: Check });
|
|
55
|
+
expect(() => registerQIcons({ rejected: { node: [['path', { d: 'M1 1', key: 'metadata', [name]: value }]] } })).toThrow();
|
|
56
|
+
expect(resolveRegisteredQIcon('kept')).toBeDefined();
|
|
57
|
+
expect(resolveRegisteredQIcon('rejected')).toBeUndefined();
|
|
58
|
+
});
|
|
59
|
+
it('counts discarded metadata against attribute, UTF-8 and total-byte budgets', () => {
|
|
60
|
+
const attributes = { key: 'metadata' };
|
|
61
|
+
for (let i = 0; i < MAX_ICON_ATTRIBUTES - 1; i++)
|
|
62
|
+
attributes[`data-x${i}`] = 'x';
|
|
63
|
+
expect(prepareQIconDefinition({ node: [['path', attributes]] }).node[0][1]).not.toHaveProperty('key');
|
|
64
|
+
attributes['data-over'] = 'x';
|
|
65
|
+
expect(() => prepareQIconDefinition({ node: [['path', attributes]] })).toThrow(/64 attributes/);
|
|
66
|
+
for (const key of ['a'.repeat(MAX_ICON_ATTRIBUTE_BYTES + 1), '雪'.repeat(Math.ceil(MAX_ICON_ATTRIBUTE_BYTES / 3))]) {
|
|
67
|
+
expect(() => prepareQIconDefinition({ node: [['path', { key }]] })).toThrow(/byte budget/);
|
|
68
|
+
}
|
|
69
|
+
expect(() => prepareQIconDefinition({ node: Array.from({ length: 3 }, () => ['path', { key: 'x'.repeat(Math.ceil(MAX_ICON_SVG_BYTES / 3)) }]) })).toThrow(/byte budget/);
|
|
70
|
+
});
|
|
71
|
+
it('retains node/depth limits while normalizing metadata', () => {
|
|
72
|
+
expect(() => prepareQIconDefinition({ node: Array.from({ length: MAX_ICON_NODES + 1 }, () => ['path', { key: 'x' }]) })).toThrow(/SVG nodes/);
|
|
73
|
+
let node = ['path', { key: 'leaf' }];
|
|
74
|
+
for (let i = 0; i < MAX_ICON_DEPTH; i++)
|
|
75
|
+
node = ['g', { key: 'group' }, [node]];
|
|
76
|
+
expect(() => prepareQIconDefinition({ node: [node] })).toThrow(/depth/);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
+
import { cloneIconAttributes, cloneIconNodes, createIconBudget, validateIconReferences, MAX_ICON_ATTRIBUTES, MAX_ICON_ATTRIBUTE_BYTES, MAX_ICON_SVG_BYTES, } from "./policy";
|
|
1
2
|
const REGISTRY_STATE_KEY = Symbol.for('@webquark/core:q-icon-registry:v1');
|
|
2
3
|
const ICON_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/;
|
|
3
|
-
const ATTRIBUTE_NAME_PATTERN = /^[a-zA-Z_:][a-zA-Z0-9_.:-]*$/;
|
|
4
4
|
const MAX_ICON_NAME_LENGTH = 128;
|
|
5
|
-
const MAX_NODE_DEPTH = 16;
|
|
6
|
-
const MAX_NODE_COUNT = 512;
|
|
7
|
-
const SAFE_SVG_ELEMENTS = new Set([
|
|
8
|
-
'circle',
|
|
9
|
-
'clipPath',
|
|
10
|
-
'defs',
|
|
11
|
-
'ellipse',
|
|
12
|
-
'g',
|
|
13
|
-
'line',
|
|
14
|
-
'linearGradient',
|
|
15
|
-
'mask',
|
|
16
|
-
'path',
|
|
17
|
-
'polygon',
|
|
18
|
-
'polyline',
|
|
19
|
-
'radialGradient',
|
|
20
|
-
'rect',
|
|
21
|
-
'stop',
|
|
22
|
-
'symbol',
|
|
23
|
-
'use',
|
|
24
|
-
]);
|
|
25
5
|
function getRuntimeState() {
|
|
26
6
|
const globalRecord = globalThis;
|
|
27
7
|
const existing = globalRecord[REGISTRY_STATE_KEY];
|
|
@@ -44,71 +24,41 @@ function getRuntimeState() {
|
|
|
44
24
|
function isRecord(value) {
|
|
45
25
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
46
26
|
}
|
|
47
|
-
function containsExternalResourceReference(value) {
|
|
48
|
-
const references = Array.from(value.matchAll(/url\s*\(([^)]*)\)/gi));
|
|
49
|
-
return references.some(([, rawReference]) => {
|
|
50
|
-
const reference = rawReference.trim().replace(/^(['"])(.*)\1$/, '$2').trim();
|
|
51
|
-
return !reference.startsWith('#');
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
27
|
function assertPositiveDimension(value, field, context) {
|
|
55
28
|
if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value) || value <= 0)) {
|
|
56
29
|
throw new TypeError(`${context}.${field} must be a positive finite number.`);
|
|
57
30
|
}
|
|
58
31
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
throw new TypeError(`${context}
|
|
32
|
+
/** Lucide node keys are inert library metadata, never SVG attributes. */
|
|
33
|
+
function cloneRegisteredIconAttributes(value, tag, budget, context) {
|
|
34
|
+
if (!isRecord(value) || !Object.prototype.propertyIsEnumerable.call(value, 'key')) {
|
|
35
|
+
return cloneIconAttributes(value, tag, budget, context);
|
|
36
|
+
}
|
|
37
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, 'key');
|
|
38
|
+
if (!('value' in descriptor) || typeof descriptor.value !== 'string') {
|
|
39
|
+
throw new TypeError(`${context}.key must be a string data property.`);
|
|
40
|
+
}
|
|
41
|
+
const key = descriptor.value;
|
|
42
|
+
if (key.length > MAX_ICON_ATTRIBUTE_BYTES)
|
|
43
|
+
throw new TypeError(`${context} exceeds the icon attribute byte budget.`);
|
|
44
|
+
const bytes = new TextEncoder().encode(key).byteLength;
|
|
45
|
+
budget.attributeBytes += bytes;
|
|
46
|
+
if (bytes > MAX_ICON_ATTRIBUTE_BYTES || budget.attributeBytes > MAX_ICON_SVG_BYTES) {
|
|
47
|
+
throw new TypeError(`${context} exceeds the icon attribute byte budget.`);
|
|
48
|
+
}
|
|
49
|
+
const attributes = Object.create(null);
|
|
50
|
+
let count = 0;
|
|
51
|
+
for (const name in value) {
|
|
52
|
+
if (!Object.prototype.hasOwnProperty.call(value, name))
|
|
53
|
+
continue;
|
|
54
|
+
if (++count > MAX_ICON_ATTRIBUTES)
|
|
55
|
+
throw new TypeError(`${context} exceeds ${MAX_ICON_ATTRIBUTES} attributes.`);
|
|
56
|
+
if (name !== 'key') {
|
|
57
|
+
// Preserve strict validation order: unknown attributes are rejected before getters are read.
|
|
58
|
+
Object.defineProperty(attributes, name, Object.getOwnPropertyDescriptor(value, name));
|
|
83
59
|
}
|
|
84
|
-
attributes[name] = rawValue;
|
|
85
|
-
}
|
|
86
|
-
return Object.freeze(attributes);
|
|
87
|
-
}
|
|
88
|
-
function cloneNode(value, context, depth, nodeCounter) {
|
|
89
|
-
if (!Array.isArray(value) || (value.length !== 2 && value.length !== 3)) {
|
|
90
|
-
throw new TypeError(`${context} must be a [tagName, attributes, children?] tuple.`);
|
|
91
|
-
}
|
|
92
|
-
if (depth > MAX_NODE_DEPTH) {
|
|
93
|
-
throw new TypeError(`${context} exceeds the maximum icon node depth of ${MAX_NODE_DEPTH}.`);
|
|
94
|
-
}
|
|
95
|
-
nodeCounter.value += 1;
|
|
96
|
-
if (nodeCounter.value > MAX_NODE_COUNT) {
|
|
97
|
-
throw new TypeError(`Icon definitions may contain at most ${MAX_NODE_COUNT} SVG nodes.`);
|
|
98
|
-
}
|
|
99
|
-
const [tagName, rawAttributes, rawChildren] = value;
|
|
100
|
-
if (typeof tagName !== 'string' || !SAFE_SVG_ELEMENTS.has(tagName)) {
|
|
101
|
-
throw new TypeError(`${context} contains an unsupported SVG element: ${String(tagName)}.`);
|
|
102
|
-
}
|
|
103
|
-
const attributes = cloneAttributes(rawAttributes, `${context}[1]`);
|
|
104
|
-
if (rawChildren === undefined) {
|
|
105
|
-
return Object.freeze([tagName, attributes]);
|
|
106
|
-
}
|
|
107
|
-
if (!Array.isArray(rawChildren)) {
|
|
108
|
-
throw new TypeError(`${context}[2] must be an array of SVG nodes.`);
|
|
109
60
|
}
|
|
110
|
-
|
|
111
|
-
return Object.freeze([tagName, attributes, children]);
|
|
61
|
+
return cloneIconAttributes(attributes, tag, budget, context);
|
|
112
62
|
}
|
|
113
63
|
export function prepareQIconDefinition(value, context = 'Icon definition') {
|
|
114
64
|
if (!isRecord(value) || !Array.isArray(value.node)) {
|
|
@@ -123,11 +73,12 @@ export function prepareQIconDefinition(value, context = 'Icon definition') {
|
|
|
123
73
|
if (value.name !== undefined && typeof value.name !== 'string') {
|
|
124
74
|
throw new TypeError(`${context}.name must be a string when provided.`);
|
|
125
75
|
}
|
|
126
|
-
const
|
|
127
|
-
const node =
|
|
76
|
+
const budget = createIconBudget();
|
|
77
|
+
const node = cloneIconNodes(value.node, budget, `${context}.node`, 1, cloneRegisteredIconAttributes);
|
|
128
78
|
const attributes = value.attributes === undefined
|
|
129
79
|
? undefined
|
|
130
|
-
:
|
|
80
|
+
: cloneIconAttributes(value.attributes, 'svg', budget, `${context}.attributes`);
|
|
81
|
+
validateIconReferences(node, attributes);
|
|
131
82
|
const definition = {
|
|
132
83
|
...(value.name === undefined ? {} : { name: value.name }),
|
|
133
84
|
node,
|
|
@@ -1,63 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const EVENT_HANDLER_ATTR_PATTERN = /\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
4
|
-
const BLOCKED_ATTR_PATTERN = /\s+(style|tabindex)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
5
|
-
const HREF_ATTR_PATTERN = /\s+(xlink:href|href)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi;
|
|
6
|
-
const JAVASCRIPT_ATTR_VALUE_PATTERN = /\s+[a-z_:.-]+\s*=\s*("[^"]*javascript:[^"]*"|'[^']*javascript:[^']*'|[^\s>]*javascript:[^\s>]*)/gi;
|
|
1
|
+
import { SVG_NAMESPACE, XLINK_NAMESPACE, MAX_ICON_ATTRIBUTES, MAX_ICON_SVG_BYTES, assertIconNode, cloneIconAttributes, cloneIconNodes, createIconBudget, validateIconReferences, } from "./policy";
|
|
2
|
+
/** Fail closed without a real XML parser; no regex recovery or browser work at import. */
|
|
7
3
|
export function sanitizeIconSvg(svgText) {
|
|
8
|
-
if (typeof DOMParser === 'undefined' || typeof XMLSerializer === 'undefined'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return;
|
|
4
|
+
if (typeof DOMParser === 'undefined' || typeof XMLSerializer === 'undefined'
|
|
5
|
+
|| typeof svgText !== 'string' || svgText.length > MAX_ICON_SVG_BYTES
|
|
6
|
+
|| new TextEncoder().encode(svgText).byteLength > MAX_ICON_SVG_BYTES
|
|
7
|
+
|| /<!\s*(?:DOCTYPE|ENTITY)/i.test(svgText))
|
|
8
|
+
return '';
|
|
9
|
+
try {
|
|
10
|
+
const parsed = new DOMParser().parseFromString(svgText, 'image/svg+xml');
|
|
11
|
+
const root = parsed.documentElement;
|
|
12
|
+
if (parsed.doctype || !root || root.tagName !== 'svg'
|
|
13
|
+
|| parsed.getElementsByTagName('parsererror').length || ![null, SVG_NAMESPACE].includes(root.namespaceURI))
|
|
14
|
+
return '';
|
|
15
|
+
for (const child of Array.from(parsed.childNodes)) {
|
|
16
|
+
if (child !== root && child.nodeType !== 8 && !(child.nodeType === 3 && !child.textContent?.trim()))
|
|
17
|
+
return '';
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const namespace = root.namespaceURI;
|
|
20
|
+
const readAttributes = (element) => {
|
|
21
|
+
if (element.attributes.length > MAX_ICON_ATTRIBUTES)
|
|
22
|
+
throw new TypeError('SVG attribute limit exceeded.');
|
|
23
|
+
const attributes = {};
|
|
24
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
25
|
+
if (attribute.name === 'xlink:href') {
|
|
26
|
+
if (attribute.namespaceURI !== XLINK_NAMESPACE)
|
|
27
|
+
throw new TypeError('Unsupported SVG attribute namespace.');
|
|
28
|
+
}
|
|
29
|
+
else if (attribute.namespaceURI && attribute.namespaceURI !== 'http://www.w3.org/2000/xmlns/') {
|
|
30
|
+
throw new TypeError('Unsupported SVG attribute namespace.');
|
|
31
|
+
}
|
|
32
|
+
attributes[attribute.name] = attribute.value;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
return attributes;
|
|
35
|
+
};
|
|
36
|
+
const parseBudget = createIconBudget();
|
|
37
|
+
const readChildren = (element, depth) => {
|
|
38
|
+
const children = [];
|
|
39
|
+
for (const child of Array.from(element.childNodes)) {
|
|
40
|
+
if (child.nodeType === 8 || child.nodeType === 3 && !child.textContent?.trim())
|
|
41
|
+
continue;
|
|
42
|
+
if (child.nodeType !== 1)
|
|
43
|
+
throw new TypeError('Unsupported SVG content.');
|
|
44
|
+
const node = child;
|
|
45
|
+
if (node.namespaceURI !== namespace)
|
|
46
|
+
throw new TypeError('Unsupported SVG element namespace.');
|
|
47
|
+
assertIconNode(node.tagName, depth, parseBudget, 'Fetched SVG');
|
|
48
|
+
children.push([node.tagName, readAttributes(node), readChildren(node, depth + 1)]);
|
|
49
|
+
}
|
|
50
|
+
return children;
|
|
51
|
+
};
|
|
52
|
+
const rawNodes = readChildren(root, 1);
|
|
53
|
+
const budget = createIconBudget();
|
|
54
|
+
const attributes = cloneIconAttributes(readAttributes(root), 'svg', budget, 'Fetched SVG root');
|
|
55
|
+
const nodes = cloneIconNodes(rawNodes, budget, 'Fetched SVG nodes');
|
|
56
|
+
validateIconReferences(nodes, attributes);
|
|
57
|
+
const output = parsed.implementation.createDocument(SVG_NAMESPACE, 'svg', null);
|
|
58
|
+
const apply = (element, attrs) => {
|
|
59
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
60
|
+
if (name === 'xmlns' || name === 'xmlns:xlink')
|
|
61
|
+
continue;
|
|
62
|
+
if (name === 'xlink:href')
|
|
63
|
+
element.setAttributeNS(XLINK_NAMESPACE, name, value);
|
|
64
|
+
else
|
|
65
|
+
element.setAttribute(name, value);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const append = (parent, items) => {
|
|
69
|
+
for (const [tag, attrs, children] of items) {
|
|
70
|
+
const element = output.createElementNS(SVG_NAMESPACE, tag);
|
|
71
|
+
apply(element, attrs);
|
|
72
|
+
if (children)
|
|
73
|
+
append(element, children);
|
|
74
|
+
parent.appendChild(element);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
apply(output.documentElement, attributes);
|
|
78
|
+
output.documentElement.setAttribute('aria-hidden', 'true');
|
|
79
|
+
output.documentElement.setAttribute('focusable', 'false');
|
|
80
|
+
append(output.documentElement, nodes);
|
|
81
|
+
return new XMLSerializer().serializeToString(output.documentElement);
|
|
82
|
+
}
|
|
83
|
+
catch (_) {
|
|
45
84
|
return '';
|
|
46
85
|
}
|
|
47
|
-
return svgText
|
|
48
|
-
.replace(BLOCKED_SVG_TAG_PATTERN, '')
|
|
49
|
-
.replace(EVENT_HANDLER_ATTR_PATTERN, '')
|
|
50
|
-
.replace(BLOCKED_ATTR_PATTERN, '')
|
|
51
|
-
.replace(JAVASCRIPT_ATTR_VALUE_PATTERN, '')
|
|
52
|
-
.replace(HREF_ATTR_PATTERN, (match, _name, rawValue) => {
|
|
53
|
-
const value = String(rawValue).replace(/^['"]|['"]$/g, '').trim().toLowerCase();
|
|
54
|
-
return value.startsWith('#') ? match : '';
|
|
55
|
-
})
|
|
56
|
-
.replace(/<svg\b([^>]*)>/i, (_match, attributes) => {
|
|
57
|
-
const cleanAttributes = String(attributes)
|
|
58
|
-
.replace(/\s+aria-hidden\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '')
|
|
59
|
-
.replace(/\s+focusable\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '');
|
|
60
|
-
return `<svg${cleanAttributes} aria-hidden="true" focusable="false">`;
|
|
61
|
-
})
|
|
62
|
-
.trim();
|
|
63
86
|
}
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { FONTAWESOME_FREE_VERSION, LUCIDE_STATIC_VERSION } from "./constants";
|
|
2
2
|
const BINARY_ICON_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.webp', '.gif', '.ico'];
|
|
3
|
+
const URL_BASE = 'http://localhost';
|
|
4
|
+
const ASSET_PROTOCOLS = ['http:', 'https:', 'file:', 'blob:'];
|
|
3
5
|
export function getResolvedLibraryVersion(version, fallback) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
return version?.trim() || fallback;
|
|
7
|
+
}
|
|
8
|
+
function parseIconUrl(url, base = URL_BASE) {
|
|
9
|
+
const parsed = new URL(url, base);
|
|
10
|
+
if (!ASSET_PROTOCOLS.includes(parsed.protocol)
|
|
11
|
+
&& !(parsed.protocol === 'data:' && /^data:image\/svg\+xml(?:[;,])/i.test(url))) {
|
|
12
|
+
throw new TypeError('Icon URLs must use HTTP(S), file/blob assets, a relative path, or SVG image data.');
|
|
13
|
+
}
|
|
14
|
+
return parsed;
|
|
6
15
|
}
|
|
7
16
|
export function isBinaryIconUrl(url) {
|
|
8
|
-
|
|
9
|
-
|
|
17
|
+
try {
|
|
18
|
+
const parsed = parseIconUrl(url);
|
|
19
|
+
return ASSET_PROTOCOLS.includes(parsed.protocol)
|
|
20
|
+
&& BINARY_ICON_EXTENSIONS.some(extension => parsed.pathname.toLowerCase().endsWith(extension));
|
|
21
|
+
}
|
|
22
|
+
catch (_) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
10
25
|
}
|
|
11
26
|
export function resolveIconUrl(options) {
|
|
12
27
|
const cleanName = options.name.trim();
|
|
@@ -19,30 +34,19 @@ export function resolveIconUrl(options) {
|
|
|
19
34
|
return `https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@${version}/svgs/solid/${encodeURIComponent(cleanName)}.svg`;
|
|
20
35
|
}
|
|
21
36
|
if (options.library === 'local') {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
const path = options.localPath || '/assets/icons/';
|
|
38
|
+
const suffixIndex = cleanName.search(/[?#]/);
|
|
39
|
+
const filename = suffixIndex < 0 ? cleanName : cleanName.slice(0, suffixIndex);
|
|
40
|
+
const suffix = suffixIndex < 0 ? '' : cleanName.slice(suffixIndex);
|
|
41
|
+
const basename = filename.slice(filename.lastIndexOf('/') + 1);
|
|
42
|
+
return `${path.endsWith('/') ? path : `${path}/`}${filename}${basename.includes('.') ? '' : '.svg'}${suffix}`;
|
|
43
|
+
}
|
|
44
|
+
if (options.library.includes('{name}'))
|
|
29
45
|
return options.library.replace('{name}', cleanName);
|
|
30
|
-
}
|
|
31
|
-
let basePath = options.library;
|
|
32
|
-
if (!basePath.endsWith('/')) {
|
|
33
|
-
basePath += '/';
|
|
34
|
-
}
|
|
35
|
-
return `${basePath}${cleanName}`;
|
|
46
|
+
return `${options.library.endsWith('/') ? options.library : `${options.library}/`}${cleanName}`;
|
|
36
47
|
}
|
|
37
48
|
export function resolveFetchableIconUrl(url, locationLike = typeof window !== 'undefined' ? window.location : undefined) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const base = locationLike.origin && locationLike.origin !== 'null' ? locationLike.origin : 'http://localhost';
|
|
42
|
-
try {
|
|
43
|
-
return new URL(url, base).href;
|
|
44
|
-
}
|
|
45
|
-
catch (_) {
|
|
46
|
-
return url;
|
|
47
|
-
}
|
|
49
|
+
const base = locationLike?.origin && locationLike.origin !== 'null' ? locationLike.origin : URL_BASE;
|
|
50
|
+
const parsed = parseIconUrl(url, base);
|
|
51
|
+
return locationLike ? parsed.href : url;
|
|
48
52
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { isBinaryIconUrl, resolveFetchableIconUrl, resolveIconUrl } from "./url";
|
|
3
|
+
describe('icon URL policy', () => {
|
|
4
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
5
|
+
it.each(['logo.PNG?v=2#mark', '/icons/photo.jpg?x=1', '../icons/picture.JPEG#x', 'https://example.invalid/icon.webp?token=x#preview', '//example.invalid/icon.GIF?x=1', '/icons/favicon.ico#icon', 'file:///icons/logo.PNG?v=2', 'blob:https://example.invalid/logo.png'])('classifies pathname while preserving the full image URL: %s', url => {
|
|
6
|
+
expect(isBinaryIconUrl(url)).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it.each(['/icons/icon.svg?name=logo.png', '/icons/logo?download=.jpg#icon.webp', 'https://example.invalid/logo', 'javascript:inert.png', 'data:text/plain,logo.png', 'mailto:logo.png'])('does not infer an image from an unsupported scheme or suffix outside pathname: %s', url => {
|
|
9
|
+
expect(isBinaryIconUrl(url)).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
it('appends local inferred SVG extensions before query/fragment and ignores dots in a directory/query', () => {
|
|
12
|
+
const local = (name) => resolveIconUrl({ name, library: 'local', localPath: '/assets/icons' });
|
|
13
|
+
expect(local('check?v=1.2#mark')).toBe('/assets/icons/check.svg?v=1.2#mark');
|
|
14
|
+
expect(local('v1.2/check#mark')).toBe('/assets/icons/v1.2/check.svg#mark');
|
|
15
|
+
expect(local('logo.PNG?version=2#mark')).toBe('/assets/icons/logo.PNG?version=2#mark');
|
|
16
|
+
});
|
|
17
|
+
it('retains pinned libraries, aliases, custom templates and base paths', () => {
|
|
18
|
+
expect(resolveIconUrl({ name: 'heart', library: 'lucide', localPath: '' })).toContain('lucide-static@0.416.0/icons/heart.svg');
|
|
19
|
+
expect(resolveIconUrl({ name: 'heart', library: 'fontawesome', libraryVersion: '7.0.0', localPath: '' })).toContain('@fortawesome/fontawesome-free@7.0.0');
|
|
20
|
+
expect(resolveIconUrl({ name: 'logo.PNG', library: 'https://example.invalid/{name}?v=2#x', localPath: '' })).toBe('https://example.invalid/logo.PNG?v=2#x');
|
|
21
|
+
expect(resolveIconUrl({ name: 'check.svg', library: '/custom/icons', localPath: '' })).toBe('/custom/icons/check.svg');
|
|
22
|
+
});
|
|
23
|
+
it('uses one explicit protocol policy for fetches, including non-browser imports', () => {
|
|
24
|
+
expect(resolveFetchableIconUrl('/check.svg', { origin: 'https://example.invalid' })).toBe('https://example.invalid/check.svg');
|
|
25
|
+
vi.stubGlobal('window', undefined);
|
|
26
|
+
expect(resolveFetchableIconUrl('/check.svg', undefined)).toBe('/check.svg');
|
|
27
|
+
expect(resolveFetchableIconUrl('data:image/svg+xml,%3Csvg/%3E', undefined)).toBe('data:image/svg+xml,%3Csvg/%3E');
|
|
28
|
+
expect(resolveFetchableIconUrl('file:///check.svg', undefined)).toBe('file:///check.svg');
|
|
29
|
+
expect(resolveFetchableIconUrl('blob:https://example.invalid/icon.svg', undefined)).toBe('blob:https://example.invalid/icon.svg');
|
|
30
|
+
for (const url of ['javascript:inert.svg', 'data:text/html,inert', 'mailto:icon.svg']) {
|
|
31
|
+
expect(() => resolveFetchableIconUrl(url, undefined)).toThrow(/HTTP/);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const RESOURCE_ICON = {
|
|
2
|
+
size: 24,
|
|
3
|
+
node: [
|
|
4
|
+
['defs', {}, [
|
|
5
|
+
['linearGradient', { id: 'paint', x1: '0', x2: '1' }, [
|
|
6
|
+
['stop', { offset: '0', 'stop-color': '#246' }],
|
|
7
|
+
['stop', { offset: '1', 'stop-color': '#acf' }],
|
|
8
|
+
]],
|
|
9
|
+
['mask', { id: 'cutout' }, [['rect', { width: '24', height: '24', fill: 'white' }]]],
|
|
10
|
+
['clipPath', { id: 'clip' }, [['circle', { cx: '12', cy: '12', r: '11' }]]],
|
|
11
|
+
['symbol', { id: 'shape', viewBox: '0 0 24 24' }, [['path', { d: 'M2 2h20v20H2Z' }]]],
|
|
12
|
+
]],
|
|
13
|
+
['g', { mask: 'url(#cutout)', 'clip-path': 'url(#clip)' }, [
|
|
14
|
+
['use', { href: '#shape', fill: 'url(#paint)' }],
|
|
15
|
+
]],
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
export const RESOURCE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24">
|
|
19
|
+
<defs>
|
|
20
|
+
<linearGradient id="paint" x1="0" x2="1"><stop offset="0" stop-color="#246"/><stop offset="1" stop-color="#acf"/></linearGradient>
|
|
21
|
+
<mask id="cutout"><rect width="24" height="24" fill="white"/></mask>
|
|
22
|
+
<clipPath id="clip"><circle cx="12" cy="12" r="11"/></clipPath>
|
|
23
|
+
<symbol id="shape" viewBox="0 0 24 24"><path d="M2 2h20v20H2Z"/></symbol>
|
|
24
|
+
</defs>
|
|
25
|
+
<g mask="url(#cutout)" clip-path="url(#clip)"><use xlink:href="#shape" fill="url(#paint)"/></g>
|
|
26
|
+
</svg>`;
|
|
27
|
+
// Deliberately inert: rejection is asserted through DOM/fallback, never execution.
|
|
28
|
+
export const REJECTED_SVGS = [
|
|
29
|
+
['malformed XML', '<svg><path></svg>'],
|
|
30
|
+
['incomplete element', '<svg><script type="application/json">{"blocked":true}'],
|
|
31
|
+
['unsupported script', '<svg><script type="application/json">{}</script></svg>'],
|
|
32
|
+
['foreign content', '<svg><foreignObject/></svg>'],
|
|
33
|
+
['navigation', '<svg><a href="#marker"/></svg>'],
|
|
34
|
+
['animation', '<svg><animate attributeName="opacity" values="1;0"/></svg>'],
|
|
35
|
+
['event attribute', '<svg onload=""><path d="M1 1"/></svg>'],
|
|
36
|
+
['inline style', '<svg><path style="fill:red" d="M1 1"/></svg>'],
|
|
37
|
+
['external paint', '<svg><path fill="url(https://example.invalid/paint)" d="M1 1"/></svg>'],
|
|
38
|
+
['external use', '<svg><use href="https://example.invalid/shape.svg#x"/></svg>'],
|
|
39
|
+
['wrong namespace', '<svg xmlns="urn:unsupported"><path/></svg>'],
|
|
40
|
+
['namespace reset', '<svg xmlns="http://www.w3.org/2000/svg"><path xmlns=""/></svg>'],
|
|
41
|
+
['unknown prefixed namespace', '<svg xmlns:z="urn:unsupported"><z:path/></svg>'],
|
|
42
|
+
['entity declaration', '<!DOCTYPE svg [<!ENTITY x "inert">]><svg/>'],
|
|
43
|
+
['stylesheet instruction', '<?xml-stylesheet href="https://example.invalid/style"?><svg/>'],
|
|
44
|
+
['text-bearing content', '<svg><path>unsupported text</path></svg>'],
|
|
45
|
+
['unresolved reference', '<svg><use href="#missing"/></svg>'],
|
|
46
|
+
['cyclic reference', '<svg><defs><symbol id="loop"><use href="#loop"/></symbol></defs></svg>'],
|
|
47
|
+
];
|