@flipova/foundation 2.4.4 → 3.0.0-alpha.1
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/CHANGES.md +66 -0
- package/COMPONENTS.md +102 -0
- package/DOCS.md +261 -0
- package/LICENSE +1 -1
- package/README.md +169 -118
- package/components/contract/index.ts +3 -0
- package/components/contract/recipes/accordion.ts +42 -0
- package/components/contract/recipes/avatar.ts +41 -0
- package/components/contract/recipes/badge.ts +46 -0
- package/components/contract/recipes/button.ts +58 -0
- package/components/contract/recipes/calendar.ts +118 -0
- package/components/contract/recipes/card.ts +21 -0
- package/components/contract/recipes/checkbox.ts +33 -0
- package/components/contract/recipes/divider.ts +9 -0
- package/components/contract/recipes/fab.ts +31 -0
- package/components/contract/recipes/feedback.ts +66 -0
- package/components/contract/recipes/formcontrol.ts +16 -0
- package/components/contract/recipes/heading.ts +16 -0
- package/components/contract/recipes/icon.ts +40 -0
- package/components/contract/recipes/index.ts +30 -0
- package/components/contract/recipes/input.ts +39 -0
- package/components/contract/recipes/layout.ts +44 -0
- package/components/contract/recipes/link.ts +6 -0
- package/components/contract/recipes/modal.ts +40 -0
- package/components/contract/recipes/overlay.ts +250 -0
- package/components/contract/recipes/progress.ts +27 -0
- package/components/contract/recipes/radio.ts +39 -0
- package/components/contract/recipes/select.ts +63 -0
- package/components/contract/recipes/skeleton.ts +25 -0
- package/components/contract/recipes/slider.ts +50 -0
- package/components/contract/recipes/spinner.ts +12 -0
- package/components/contract/recipes/switch.ts +26 -0
- package/components/contract/recipes/table.ts +37 -0
- package/components/contract/recipes/tabs.ts +31 -0
- package/components/contract/recipes/text.ts +12 -0
- package/components/contract/recipes/textarea.ts +37 -0
- package/components/contract/recipes/util.ts +15 -0
- package/components/contract/theme.ts +116 -0
- package/components/contract/types.ts +598 -0
- package/components/providers/css-vars.ts +43 -0
- package/components/providers/flipova/components/Accordion.tsx +41 -0
- package/components/providers/flipova/components/ActionSheet.tsx +34 -0
- package/components/providers/flipova/components/Alert.tsx +15 -0
- package/components/providers/flipova/components/AlertDialog.tsx +31 -0
- package/components/providers/flipova/components/Avatar.tsx +30 -0
- package/components/providers/flipova/components/Badge.tsx +14 -0
- package/components/providers/flipova/components/BottomSheet.tsx +24 -0
- package/components/providers/flipova/components/Box.tsx +1 -0
- package/components/providers/flipova/components/Button.tsx +31 -0
- package/components/providers/flipova/components/Calendar.tsx +85 -0
- package/components/providers/flipova/components/Card.tsx +13 -0
- package/components/providers/flipova/components/Center.tsx +11 -0
- package/components/providers/flipova/components/Checkbox.tsx +24 -0
- package/components/providers/flipova/components/DateTimePicker.tsx +45 -0
- package/components/providers/flipova/components/Divider.tsx +9 -0
- package/components/providers/flipova/components/Drawer.tsx +18 -0
- package/components/providers/flipova/components/Fab.tsx +22 -0
- package/components/providers/flipova/components/FlatList.tsx +1 -0
- package/components/providers/flipova/components/FormControl.tsx +27 -0
- package/components/providers/flipova/components/Grid.tsx +18 -0
- package/components/providers/flipova/components/HStack.tsx +13 -0
- package/components/providers/flipova/components/Heading.tsx +19 -0
- package/components/providers/flipova/components/Icon.tsx +20 -0
- package/components/providers/flipova/components/Image.tsx +1 -0
- package/components/providers/flipova/components/ImageBackground.tsx +1 -0
- package/components/providers/flipova/components/ImageViewer.tsx +25 -0
- package/components/providers/flipova/components/Input.tsx +29 -0
- package/components/providers/flipova/components/InputAccessoryView.tsx +1 -0
- package/components/providers/flipova/components/KeyboardAvoidingView.tsx +1 -0
- package/components/providers/flipova/components/Link.tsx +21 -0
- package/components/providers/flipova/components/LiquidGlass.tsx +13 -0
- package/components/providers/flipova/components/Menu.tsx +43 -0
- package/components/providers/flipova/components/Modal.tsx +24 -0
- package/components/providers/flipova/components/Popover.tsx +23 -0
- package/components/providers/flipova/components/Portal.tsx +42 -0
- package/components/providers/flipova/components/Pressable.tsx +1 -0
- package/components/providers/flipova/components/Progress.tsx +22 -0
- package/components/providers/flipova/components/RadioGroup.tsx +36 -0
- package/components/providers/flipova/components/RefreshControl.tsx +1 -0
- package/components/providers/flipova/components/SafeAreaView.tsx +1 -0
- package/components/providers/flipova/components/ScrollView.tsx +1 -0
- package/components/providers/flipova/components/SectionList.tsx +1 -0
- package/components/providers/flipova/components/Select.tsx +61 -0
- package/components/providers/flipova/components/Skeleton.tsx +25 -0
- package/components/providers/flipova/components/Slider.tsx +52 -0
- package/components/providers/flipova/components/Spinner.tsx +19 -0
- package/components/providers/flipova/components/StatusBar.tsx +1 -0
- package/components/providers/flipova/components/Switch.tsx +21 -0
- package/components/providers/flipova/components/Table.tsx +33 -0
- package/components/providers/flipova/components/Tabs.tsx +39 -0
- package/components/providers/flipova/components/Text.tsx +13 -0
- package/components/providers/flipova/components/Textarea.tsx +28 -0
- package/components/providers/flipova/components/Toast.tsx +28 -0
- package/components/providers/flipova/components/Tooltip.tsx +34 -0
- package/components/providers/flipova/components/VStack.tsx +13 -0
- package/components/providers/flipova/components/View.tsx +1 -0
- package/components/providers/flipova/components/VirtualizedList.tsx +1 -0
- package/components/providers/flipova/index.tsx +189 -0
- package/components/providers/gluestack/index.tsx +226 -0
- package/components/providers/gluestack/more.tsx +151 -0
- package/components/{ui → providers/gluestack/ui}/accordion/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/actionsheet/index.tsx +15 -15
- package/components/{ui → providers/gluestack/ui}/alert/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/alert-dialog/index.tsx +3 -3
- package/components/{ui → providers/gluestack/ui}/badge/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/bottomsheet/index.tsx +11 -10
- package/components/{ui → providers/gluestack/ui}/box/index.tsx +4 -1
- package/components/{ui → providers/gluestack/ui}/button/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/calendar/index.tsx +4 -4
- package/components/{ui → providers/gluestack/ui}/card/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/center/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/checkbox/index.tsx +9 -8
- package/components/{ui → providers/gluestack/ui}/date-time-picker/index.tsx +4 -4
- package/components/providers/gluestack/ui/date-time-picker/index.web.tsx +197 -0
- package/components/{ui → providers/gluestack/ui}/divider/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/drawer/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/fab/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/form-control/index.tsx +3 -3
- package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/config.ts +1 -62
- package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/tokens.js +1 -1
- package/components/{ui → providers/gluestack/ui}/grid/index.tsx +3 -3
- package/components/{ui → providers/gluestack/ui}/heading/index.tsx +7 -7
- package/components/{ui → providers/gluestack/ui}/hstack/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/icon/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/image/index.tsx +0 -1
- package/components/{ui → providers/gluestack/ui}/image-viewer/index.tsx +96 -99
- package/components/providers/gluestack/ui/index.ts +58 -0
- package/components/{ui → providers/gluestack/ui}/input/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/link/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/liquid-glass/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/menu/index.tsx +5 -4
- package/components/{ui → providers/gluestack/ui}/modal/index.tsx +19 -17
- package/components/{ui → providers/gluestack/ui}/popover/index.tsx +4 -4
- package/components/{ui → providers/gluestack/ui}/portal/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/progress/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/radio/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/select/index.tsx +8 -12
- package/components/{ui → providers/gluestack/ui}/select/select-actionsheet.tsx +13 -13
- package/components/{ui → providers/gluestack/ui}/skeleton/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/slider/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/spinner/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/table/index.tsx +33 -33
- package/components/{ui → providers/gluestack/ui}/tabs/TabsAnimatedIndicator.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/tabs/index.tsx +2 -2
- package/components/{ui → providers/gluestack/ui}/text/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/toast/index.tsx +4 -4
- package/components/{ui → providers/gluestack/ui}/tooltip/index.tsx +1 -1
- package/components/{ui → providers/gluestack/ui}/vstack/index.tsx +1 -1
- package/components/providers/index.ts +2 -0
- package/components/providers/paper/index.tsx +449 -0
- package/components/providers/provider.tsx +80 -0
- package/components/providers/reusables/classes.ts +163 -0
- package/components/providers/reusables/index.tsx +289 -0
- package/components/providers/rn-base/Box.tsx +7 -0
- package/components/providers/rn-base/FlatList.tsx +16 -0
- package/components/providers/rn-base/Image.tsx +18 -0
- package/components/providers/rn-base/ImageBackground.tsx +11 -0
- package/components/providers/rn-base/InputAccessoryView.tsx +9 -0
- package/components/providers/rn-base/KeyboardAvoidingView.tsx +15 -0
- package/components/providers/rn-base/Pressable.tsx +19 -0
- package/components/providers/rn-base/RefreshControl.tsx +16 -0
- package/components/providers/rn-base/SafeAreaView.tsx +11 -0
- package/components/providers/rn-base/ScrollView.tsx +11 -0
- package/components/providers/rn-base/SectionList.tsx +22 -0
- package/components/providers/rn-base/StatusBar.tsx +17 -0
- package/components/providers/rn-base/View.tsx +7 -0
- package/components/providers/rn-base/VirtualizedList.tsx +18 -0
- package/components/providers/rn-base/index.tsx +64 -0
- package/components/providers/tamagui/index.tsx +375 -0
- package/components/providers/types.ts +17 -0
- package/components/theme/design-theme.ts +230 -0
- package/components/ui/create.tsx +14 -0
- package/components/ui/index.ts +68 -58
- package/components/ui/resolve.ts +40 -0
- package/design/canonical.index.txt +2 -16
- package/design/manifest.xml +4 -3
- package/design/schema.xsd +44 -434
- package/design/themes.xml +7 -177
- package/design/tools/{npm.js → cli.js} +173 -73
- package/design/tools/gui/index.html +998 -0
- package/design/tools/lib/check.js +533 -0
- package/design/tools/lib/contract.js +23 -0
- package/design/tools/lib/edit.js +166 -0
- package/design/tools/lib/generate.js +465 -0
- package/design/tools/lib/gui.js +614 -0
- package/design/tools/lib/lint.js +139 -0
- package/design/tools/lib/registry.js +135 -0
- package/design/tools/lib/util.js +53 -0
- package/design/tools/lib/xml.js +257 -0
- package/design/tools/lib/xsd.js +408 -0
- package/dist/chunk-2QM2ZUDS.mjs +1308 -0
- package/dist/chunk-2QM2ZUDS.mjs.map +1 -0
- package/dist/chunk-2T2TCUYF.js +1371 -0
- package/dist/chunk-2T2TCUYF.js.map +1 -0
- package/dist/chunk-6UKTC4KF.js +43 -0
- package/dist/chunk-6UKTC4KF.js.map +1 -0
- package/dist/chunk-6Z4WRTI4.mjs +37 -0
- package/dist/chunk-6Z4WRTI4.mjs.map +1 -0
- package/dist/chunk-G3K6J5KY.js +157 -0
- package/dist/chunk-G3K6J5KY.js.map +1 -0
- package/dist/chunk-GM45RCSI.mjs +96 -0
- package/dist/chunk-GM45RCSI.mjs.map +1 -0
- package/dist/chunk-GQJLHH2P.mjs +3 -0
- package/dist/chunk-GQJLHH2P.mjs.map +1 -0
- package/dist/chunk-ICNR56VP.js +1653 -0
- package/dist/chunk-ICNR56VP.js.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +9 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-LRPZLF2K.mjs +30 -0
- package/dist/chunk-LRPZLF2K.mjs.map +1 -0
- package/dist/chunk-OC4MXNXU.js +32 -0
- package/dist/chunk-OC4MXNXU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +11 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-RWVTZUEG.js +161 -0
- package/dist/chunk-RWVTZUEG.js.map +1 -0
- package/dist/chunk-V473I5XQ.js +4 -0
- package/dist/chunk-V473I5XQ.js.map +1 -0
- package/dist/chunk-V4ULAISZ.js +915 -0
- package/dist/chunk-V4ULAISZ.js.map +1 -0
- package/dist/chunk-WRJERTJS.mjs +145 -0
- package/dist/chunk-WRJERTJS.mjs.map +1 -0
- package/dist/chunk-YIBPE3KQ.mjs +864 -0
- package/dist/chunk-YIBPE3KQ.mjs.map +1 -0
- package/dist/chunk-YUAQIZPN.mjs +1556 -0
- package/dist/chunk-YUAQIZPN.mjs.map +1 -0
- package/dist/contract/index.d.mts +304 -0
- package/dist/contract/index.d.ts +304 -0
- package/dist/contract/index.js +256 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/index.mjs +3 -0
- package/dist/contract/index.mjs.map +1 -0
- package/dist/index.d.mts +4 -40
- package/dist/index.d.ts +4 -40
- package/dist/index.js +73 -992
- package/dist/index.mjs +2 -1
- package/dist/providers/flipova/index.d.mts +133 -0
- package/dist/providers/flipova/index.d.ts +133 -0
- package/dist/providers/flipova/index.js +249 -0
- package/dist/providers/flipova/index.js.map +1 -0
- package/dist/providers/flipova/index.mjs +4 -0
- package/dist/providers/flipova/index.mjs.map +1 -0
- package/dist/providers/gluestack/index.d.mts +7 -0
- package/dist/providers/gluestack/index.d.ts +7 -0
- package/dist/providers/gluestack/index.js +240 -0
- package/dist/providers/gluestack/index.js.map +1 -0
- package/dist/providers/gluestack/index.mjs +238 -0
- package/dist/providers/gluestack/index.mjs.map +1 -0
- package/dist/providers/gluestack/ui/index.d.mts +3472 -0
- package/dist/providers/gluestack/ui/index.d.ts +3472 -0
- package/dist/{chunk-LCTFQJZM.js → providers/gluestack/ui/index.js} +860 -2297
- package/dist/providers/gluestack/ui/index.js.map +1 -0
- package/dist/{chunk-2R66P5X5.mjs → providers/gluestack/ui/index.mjs} +468 -2062
- package/dist/providers/gluestack/ui/index.mjs.map +1 -0
- package/dist/providers/index.d.mts +37 -0
- package/dist/providers/index.d.ts +37 -0
- package/dist/providers/index.js +28 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/index.mjs +3 -0
- package/dist/providers/index.mjs.map +1 -0
- package/dist/providers/paper/index.d.mts +30 -0
- package/dist/providers/paper/index.d.ts +30 -0
- package/dist/providers/paper/index.js +362 -0
- package/dist/providers/paper/index.js.map +1 -0
- package/dist/providers/paper/index.mjs +353 -0
- package/dist/providers/paper/index.mjs.map +1 -0
- package/dist/providers/reusables/index.d.mts +60 -0
- package/dist/providers/reusables/index.d.ts +60 -0
- package/dist/providers/reusables/index.js +348 -0
- package/dist/providers/reusables/index.js.map +1 -0
- package/dist/providers/reusables/index.mjs +311 -0
- package/dist/providers/reusables/index.mjs.map +1 -0
- package/dist/providers/tamagui/index.d.mts +15 -0
- package/dist/providers/tamagui/index.d.ts +15 -0
- package/dist/providers/tamagui/index.js +275 -0
- package/dist/providers/tamagui/index.js.map +1 -0
- package/dist/providers/tamagui/index.mjs +270 -0
- package/dist/providers/tamagui/index.mjs.map +1 -0
- package/dist/theme-BznFrVT1.d.mts +566 -0
- package/dist/theme-BznFrVT1.d.ts +566 -0
- package/dist/types-C7P80VKR.d.ts +22 -0
- package/dist/types-Tspvmask.d.mts +22 -0
- package/dist/ui/index.d.mts +190 -7017
- package/dist/ui/index.d.ts +190 -7017
- package/dist/ui/index.js +73 -992
- package/dist/ui/index.mjs +2 -1
- package/package.json +136 -35
- package/components/ui/date-time-picker/index.web.tsx +0 -195
- package/design/documentation.xml +0 -607
- package/design/tools/design.js +0 -188
- package/design/tools/requirements.txt +0 -35
- package/design/tools/sources/.checker/__init__.py +0 -81
- package/design/tools/sources/.checker/checks.py +0 -198
- package/design/tools/sources/.checker/cli.py +0 -154
- package/design/tools/sources/.checker/io.py +0 -242
- package/design/tools/sources/.checker/model.py +0 -144
- package/design/tools/sources/.checker/registry.py +0 -115
- package/design/tools/sources/.checker/report.py +0 -21
- package/design/tools/sources/.docgen/__init__.py +0 -45
- package/design/tools/sources/.docgen/cli.py +0 -101
- package/design/tools/sources/.docgen/model.py +0 -147
- package/design/tools/sources/.docgen/reference.py +0 -97
- package/design/tools/sources/.docgen/site.py +0 -145
- package/design/tools/sources/.docgen/xsddoc.py +0 -329
- package/design/tools/sources/.generate/__init__.py +0 -35
- package/design/tools/sources/.generate/cli.py +0 -76
- package/design/tools/sources/.generate/common.py +0 -33
- package/design/tools/sources/.generate/config.py +0 -177
- package/design/tools/sources/.generate/model.py +0 -51
- package/design/tools/sources/.generate/tokens.py +0 -141
- package/design/tools/sources/.linter/__init__.py +0 -9
- package/design/tools/sources/.linter/cli.py +0 -44
- package/design/tools/sources/.linter/discovery.py +0 -30
- package/design/tools/sources/.linter/errors.py +0 -45
- package/design/tools/sources/.linter/linter.py +0 -68
- package/design/tools/sources/.xmleditor/__init__.py +0 -74
- package/design/tools/sources/.xmleditor/blocks.py +0 -185
- package/design/tools/sources/.xmleditor/cli.py +0 -141
- package/design/tools/sources/.xmleditor/editor.py +0 -906
- package/design/tools/sources/.xmleditor/model.py +0 -708
- package/design/tools/sources/.xmleditor/widgets.py +0 -1832
- package/design/tools/sources/.xmleditor/xsdmodel.py +0 -753
- package/design/tools/sources/checker.py +0 -55
- package/design/tools/sources/docgen.py +0 -66
- package/design/tools/sources/generate.py +0 -48
- package/design/tools/sources/linter.py +0 -54
- package/design/tools/sources/ruff.toml +0 -12
- package/design/tools/sources/xmleditor.py +0 -62
- package/design/tools/unix/_venv_python.sh +0 -16
- package/design/tools/unix/check.sh +0 -13
- package/design/tools/unix/doc.sh +0 -14
- package/design/tools/unix/gen.sh +0 -14
- package/design/tools/unix/lint.sh +0 -10
- package/design/tools/unix/run.sh +0 -20
- package/design/tools/unix/verify.sh +0 -12
- package/design/tools/unix/xmledit.sh +0 -12
- package/design/tools/windows/check.cmd +0 -12
- package/design/tools/windows/doc.cmd +0 -12
- package/design/tools/windows/gen.cmd +0 -11
- package/design/tools/windows/lint.cmd +0 -9
- package/design/tools/windows/run.cmd +0 -26
- package/design/tools/windows/verify.cmd +0 -10
- package/design/tools/windows/xmledit.cmd +0 -10
- package/dist/chunk-2R66P5X5.mjs.map +0 -1
- package/dist/chunk-LCTFQJZM.js.map +0 -1
- /package/components/{ui → providers/gluestack/ui}/accordion/ANIMATION_CUSTOMIZATION.md +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AccordionAnimatedHeight.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AccordionAnimatedIcon.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AnimatedHeight.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/AnimatedIcon.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/MIGRATION_SUMMARY.md +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/USAGE_EXAMPLE.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/accordion/animation-config.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/avatar/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/box/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/box/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/calendar/creator.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/calendar/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/card/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/card/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/center/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/center/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/date-time-picker/creator.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/date-time-picker/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/flat-list/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/script.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/theme-context.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/tokens.d.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/gluestack-ui-provider/useGluestackColors.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/grid/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/grid/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/heading/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/heading/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/hstack/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/hstack/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/icon/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/image-background/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/image-viewer/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/input-accessory-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/keyboard-avoiding-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/pressable/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/refresh-control/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/safe-area-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/scroll-view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/section-list/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/skeleton/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/skeleton/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/status-bar/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/switch/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/table/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/table/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/tabs/animation-config.ts +0 -0
- /package/components/{ui → providers/gluestack/ui}/tabs/creator.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/text/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/text/styles.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/textarea/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/view/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/virtualized-list/index.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/vstack/index.web.tsx +0 -0
- /package/components/{ui → providers/gluestack/ui}/vstack/styles.tsx +0 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* XML Schema validation for the subset the registries use — no dependency, no native library.
|
|
4
|
+
*
|
|
5
|
+
* Supported: global/local elements, named and anonymous complexType / simpleType, sequence and choice (nested, with
|
|
6
|
+
* minOccurs / maxOccurs), attributes (use, fixed, type), mixed content, simpleContent/extension, restriction with
|
|
7
|
+
* enumeration / pattern / length facets, xs:unique, the common builtin types. Anything else in a schema is refused
|
|
8
|
+
* with a clear message instead of being silently ignored, so a schema can never be "validated" by a validator that
|
|
9
|
+
* does not understand it.
|
|
10
|
+
*
|
|
11
|
+
* Verdicts (valid / invalid, and which element or attribute is at fault) are meant to match libxml2's; the wording of
|
|
12
|
+
* the messages follows it closely but is not identical.
|
|
13
|
+
*/
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const { parse, parseFile, XmlError } = require('./xml');
|
|
16
|
+
|
|
17
|
+
const XS = 'http://www.w3.org/2001/XMLSchema';
|
|
18
|
+
const XSI = 'http://www.w3.org/2001/XMLSchema-instance';
|
|
19
|
+
|
|
20
|
+
class SchemaError extends Error {}
|
|
21
|
+
|
|
22
|
+
const BUILTIN = {
|
|
23
|
+
string: () => true,
|
|
24
|
+
normalizedString: () => true,
|
|
25
|
+
token: () => true,
|
|
26
|
+
anyURI: () => true,
|
|
27
|
+
NMTOKEN: (v) => /^[\w.:\-]+$/.test(v.trim()),
|
|
28
|
+
NCName: (v) => /^[A-Za-z_][\w.\-]*$/.test(v.trim()),
|
|
29
|
+
boolean: (v) => ['true', 'false', '1', '0'].includes(v.trim()),
|
|
30
|
+
integer: (v) => /^[+-]?\d+$/.test(v.trim()),
|
|
31
|
+
int: (v) => /^[+-]?\d+$/.test(v.trim()),
|
|
32
|
+
long: (v) => /^[+-]?\d+$/.test(v.trim()),
|
|
33
|
+
nonNegativeInteger: (v) => /^\+?\d+$/.test(v.trim()),
|
|
34
|
+
positiveInteger: (v) => /^\+?0*[1-9]\d*$/.test(v.trim()),
|
|
35
|
+
decimal: (v) => /^[+-]?(\d+(\.\d*)?|\.\d+)$/.test(v.trim()),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const local = (q) => (q && q.includes(':') ? q.split(':').pop() : q);
|
|
39
|
+
const kids = (el, name) => el.children.filter((c) => c.ns === XS && c.name === name);
|
|
40
|
+
const content = (el) => el.children.filter((c) => c.ns === XS && c.name !== 'annotation');
|
|
41
|
+
const occurs = (el) => ({
|
|
42
|
+
min: el.get('minOccurs') === null ? 1 : Number(el.get('minOccurs')),
|
|
43
|
+
max: el.get('maxOccurs') === null ? 1 : el.get('maxOccurs') === 'unbounded' ? Infinity : Number(el.get('maxOccurs')),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
class Schema {
|
|
47
|
+
constructor(root) {
|
|
48
|
+
if (!root || root.ns !== XS || root.name !== 'schema') throw new SchemaError('not an XML Schema document');
|
|
49
|
+
this.tns = root.get('targetNamespace');
|
|
50
|
+
this.complex = new Map();
|
|
51
|
+
this.simple = new Map();
|
|
52
|
+
this.elements = new Map();
|
|
53
|
+
for (const c of content(root)) {
|
|
54
|
+
const name = c.get('name');
|
|
55
|
+
if (c.name === 'complexType') this.complex.set(name, c);
|
|
56
|
+
else if (c.name === 'simpleType') this.simple.set(name, c);
|
|
57
|
+
else if (c.name === 'element') this.elements.set(name, this.element(c));
|
|
58
|
+
else throw new SchemaError(`unsupported schema construct <xs:${c.name}>`);
|
|
59
|
+
}
|
|
60
|
+
this.cache = new Map();
|
|
61
|
+
// compile everything now: an unsupported construct must fail when the schema is loaded, not when a file happens to reach it
|
|
62
|
+
for (const n of [...this.complex.keys(), ...this.simple.keys()]) this.named(n);
|
|
63
|
+
for (const d of this.elements.values()) this.warm(d);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
warm(decl) {
|
|
67
|
+
const t = this.typeOf(decl);
|
|
68
|
+
const walk = (p) => (p.kind === 'element' ? this.warm(p.decl) : p.items.forEach(walk));
|
|
69
|
+
if (t.complex && t.complex.particle) walk(t.complex.particle);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static fromFile(path) {
|
|
73
|
+
try {
|
|
74
|
+
return new Schema(parseFile(path));
|
|
75
|
+
} catch (e) {
|
|
76
|
+
if (e instanceof XmlError) throw new SchemaError(`invalid XSD schema ${path}: ${e.message} (line ${e.line})`);
|
|
77
|
+
throw e;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static fromString(text) {
|
|
82
|
+
return new Schema(parse(text));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
element(el) {
|
|
86
|
+
if (el.get('ref') !== null) throw new SchemaError('unsupported schema construct: <xs:element ref>');
|
|
87
|
+
const decl = { name: el.get('name'), typeName: el.get('type'), inline: null, unique: [], ...occurs(el) };
|
|
88
|
+
for (const c of content(el)) {
|
|
89
|
+
if (c.name === 'complexType' || c.name === 'simpleType') decl.inline = c;
|
|
90
|
+
else if (c.name === 'unique') {
|
|
91
|
+
const sel = kids(c, 'selector')[0];
|
|
92
|
+
decl.unique.push({
|
|
93
|
+
name: c.get('name'),
|
|
94
|
+
selector: this.path(sel.get('xpath'), sel),
|
|
95
|
+
fields: kids(c, 'field').map((f) => this.field(f.get('xpath'), f)),
|
|
96
|
+
});
|
|
97
|
+
} else throw new SchemaError(`unsupported schema construct <xs:${c.name}> inside <xs:element>`);
|
|
98
|
+
}
|
|
99
|
+
return decl;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* XSD xpath: an UNPREFIXED name means "no namespace" (the default namespace does not apply), so a selector written
|
|
104
|
+
* `./items/token` against elements in a target namespace selects nothing. A prefixed step uses the prefix in scope.
|
|
105
|
+
*/
|
|
106
|
+
step(raw, at, xpath) {
|
|
107
|
+
const m = /^(?:([A-Za-z_][\w.\-]*):)?([A-Za-z_][\w.\-]*)$/.exec(raw);
|
|
108
|
+
if (!m) throw new SchemaError(`unsupported xpath '${xpath}' (child steps only)`);
|
|
109
|
+
const ns = m[1] ? at.nsmap[m[1]] : null;
|
|
110
|
+
if (m[1] && ns === undefined) throw new SchemaError(`xpath '${xpath}': namespace prefix '${m[1]}' is not declared`);
|
|
111
|
+
return { ns: ns ?? null, name: m[2] };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
path(xpath, at) {
|
|
115
|
+
return xpath
|
|
116
|
+
.replace(/^\.\/?/, '')
|
|
117
|
+
.split('/')
|
|
118
|
+
.filter(Boolean)
|
|
119
|
+
.map((s) => this.step(s, at, xpath));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
field(xpath, at) {
|
|
123
|
+
return xpath.startsWith('@')
|
|
124
|
+
? { attr: this.step(xpath.slice(1), at, xpath) }
|
|
125
|
+
: { child: this.step(xpath.replace(/^\.\//, ''), at, xpath) };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Resolved type of an element declaration: { builtin } | { simple } | { complex }. */
|
|
129
|
+
typeOf(decl) {
|
|
130
|
+
if (decl.inline)
|
|
131
|
+
return decl.inline.name === 'complexType'
|
|
132
|
+
? { complex: this.compileComplex(decl.inline) }
|
|
133
|
+
: { simple: this.compileSimple(decl.inline) };
|
|
134
|
+
if (!decl.typeName) return { builtin: 'string' }; // xs:anyType, narrowed to text
|
|
135
|
+
return this.named(decl.typeName);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
named(typeName) {
|
|
139
|
+
const n = local(typeName);
|
|
140
|
+
const prefixIsXs = typeName.includes(':') && !this.complex.has(n) && !this.simple.has(n);
|
|
141
|
+
if (prefixIsXs || (!this.complex.has(n) && !this.simple.has(n))) {
|
|
142
|
+
if (!(n in BUILTIN)) throw new SchemaError(`unsupported or unknown type '${typeName}'`);
|
|
143
|
+
return { builtin: n };
|
|
144
|
+
}
|
|
145
|
+
if (!this.cache.has(n)) {
|
|
146
|
+
this.cache.set(
|
|
147
|
+
n,
|
|
148
|
+
this.complex.has(n)
|
|
149
|
+
? { complex: this.compileComplex(this.complex.get(n)) }
|
|
150
|
+
: { simple: this.compileSimple(this.simple.get(n)) },
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return this.cache.get(n);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
compileSimple(st) {
|
|
157
|
+
const r = kids(st, 'restriction')[0];
|
|
158
|
+
if (!r) throw new SchemaError('unsupported simpleType (restriction only)');
|
|
159
|
+
const facets = { enumeration: [], pattern: [], base: local(r.get('base')) };
|
|
160
|
+
if (!(facets.base in BUILTIN) && !this.simple.has(facets.base))
|
|
161
|
+
throw new SchemaError(`unsupported simpleType base '${r.get('base')}'`);
|
|
162
|
+
for (const f of content(r)) {
|
|
163
|
+
if (f.name === 'enumeration') facets.enumeration.push(f.get('value'));
|
|
164
|
+
else if (f.name === 'pattern') facets.pattern.push(new RegExp(`^(?:${f.get('value')})$`));
|
|
165
|
+
else if (f.name === 'minLength') facets.minLength = Number(f.get('value'));
|
|
166
|
+
else if (f.name === 'maxLength') facets.maxLength = Number(f.get('value'));
|
|
167
|
+
else throw new SchemaError(`unsupported facet <xs:${f.name}>`);
|
|
168
|
+
}
|
|
169
|
+
return facets;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
attributes(parent) {
|
|
173
|
+
return kids(parent, 'attribute').map((a) => {
|
|
174
|
+
if (a.get('ref') !== null) throw new SchemaError('unsupported schema construct: <xs:attribute ref>');
|
|
175
|
+
const inline = kids(a, 'simpleType')[0];
|
|
176
|
+
return {
|
|
177
|
+
name: a.get('name'),
|
|
178
|
+
type: inline ? { simple: this.compileSimple(inline) } : this.named(a.get('type') || 'xs:string'),
|
|
179
|
+
use: a.get('use') || 'optional',
|
|
180
|
+
fixed: a.get('fixed'),
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
compileComplex(ct) {
|
|
186
|
+
const out = { mixed: ct.get('mixed') === 'true', particle: null, attrs: [], simple: null };
|
|
187
|
+
for (const c of content(ct)) {
|
|
188
|
+
if (c.name === 'sequence' || c.name === 'choice') out.particle = this.particle(c);
|
|
189
|
+
else if (c.name === 'attribute') continue;
|
|
190
|
+
else if (c.name === 'simpleContent') {
|
|
191
|
+
const ext = kids(c, 'extension')[0];
|
|
192
|
+
if (!ext) throw new SchemaError('unsupported simpleContent (extension only)');
|
|
193
|
+
out.simple = this.named(ext.get('base'));
|
|
194
|
+
out.attrs.push(...this.attributes(ext));
|
|
195
|
+
} else throw new SchemaError(`unsupported schema construct <xs:${c.name}> inside <xs:complexType>`);
|
|
196
|
+
}
|
|
197
|
+
out.attrs.push(...this.attributes(ct));
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
particle(el) {
|
|
202
|
+
if (el.name === 'element') {
|
|
203
|
+
const decl = this.element(el);
|
|
204
|
+
return { kind: 'element', decl, ...occurs(el) };
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
kind: el.name,
|
|
208
|
+
items: content(el).map((c) => {
|
|
209
|
+
if (c.name === 'element' || c.name === 'sequence' || c.name === 'choice') return this.particle(c);
|
|
210
|
+
throw new SchemaError(`unsupported schema construct <xs:${c.name}> in a content model`);
|
|
211
|
+
}),
|
|
212
|
+
...occurs(el),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// --- validation ----------------------------------------------------------------------------------------------------
|
|
218
|
+
|
|
219
|
+
const qn = (el) => el.name;
|
|
220
|
+
const blank = (s) => !s || !s.trim();
|
|
221
|
+
|
|
222
|
+
function simpleProblem(schema, type, value) {
|
|
223
|
+
if (type.builtin)
|
|
224
|
+
return BUILTIN[type.builtin](value)
|
|
225
|
+
? null
|
|
226
|
+
: `'${value}' is not a valid value of the atomic type 'xs:${type.builtin}'.`;
|
|
227
|
+
if (type.simple) {
|
|
228
|
+
const f = type.simple;
|
|
229
|
+
if (f.base in BUILTIN && !BUILTIN[f.base](value))
|
|
230
|
+
return `'${value}' is not a valid value of the atomic type 'xs:${f.base}'.`;
|
|
231
|
+
if (f.enumeration.length && !f.enumeration.includes(value))
|
|
232
|
+
return `[facet 'enumeration'] The value '${value}' is not an element of the set {${f.enumeration.map((v) => `'${v}'`).join(', ')}}.`;
|
|
233
|
+
if (f.pattern.length && !f.pattern.some((re) => re.test(value)))
|
|
234
|
+
return `[facet 'pattern'] The value '${value}' is not accepted by the pattern.`;
|
|
235
|
+
if (f.minLength !== undefined && value.length < f.minLength)
|
|
236
|
+
return `[facet 'minLength'] The value has a length of '${value.length}'; this underruns the allowed minimum length of '${f.minLength}'.`;
|
|
237
|
+
if (f.maxLength !== undefined && value.length > f.maxLength)
|
|
238
|
+
return `[facet 'maxLength'] The value has a length of '${value.length}'; this exceeds the allowed maximum length of '${f.maxLength}'.`;
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Possible end positions after matching `p` against kids[i..] (every way, since the model may be ambiguous). */
|
|
244
|
+
function matcher(schema, nodes, tns, tried) {
|
|
245
|
+
let reached = 0;
|
|
246
|
+
const once = (p, i) => {
|
|
247
|
+
if (p.kind === 'element') {
|
|
248
|
+
(tried.get(i) ?? tried.set(i, new Set()).get(i)).add(p.decl.name);
|
|
249
|
+
const n = nodes[i];
|
|
250
|
+
if (n && n.name === p.decl.name && n.ns === tns) {
|
|
251
|
+
reached = Math.max(reached, i + 1);
|
|
252
|
+
return new Set([i + 1]);
|
|
253
|
+
}
|
|
254
|
+
return new Set();
|
|
255
|
+
}
|
|
256
|
+
if (p.kind === 'sequence') {
|
|
257
|
+
let cur = new Set([i]);
|
|
258
|
+
for (const item of p.items) {
|
|
259
|
+
const next = new Set();
|
|
260
|
+
for (const s of cur) for (const e of repeat(item, s)) next.add(e);
|
|
261
|
+
cur = next;
|
|
262
|
+
if (!cur.size) break;
|
|
263
|
+
}
|
|
264
|
+
return cur;
|
|
265
|
+
}
|
|
266
|
+
const out = new Set();
|
|
267
|
+
for (const item of p.items) for (const s of repeat(item, i)) out.add(s);
|
|
268
|
+
return out;
|
|
269
|
+
};
|
|
270
|
+
const repeat = (p, i) => {
|
|
271
|
+
const result = new Set();
|
|
272
|
+
let states = new Set([i]);
|
|
273
|
+
if (p.min === 0) result.add(i);
|
|
274
|
+
const seen = new Set([i]);
|
|
275
|
+
for (let count = 1; count <= p.max && states.size; count++) {
|
|
276
|
+
const next = new Set();
|
|
277
|
+
for (const s of states) for (const e of once(p, s)) if (!(count > nodes.length + 1)) next.add(e);
|
|
278
|
+
if (count >= p.min) for (const e of next) result.add(e);
|
|
279
|
+
states = new Set([...next].filter((e) => !(seen.has(e) && count >= p.min)));
|
|
280
|
+
for (const e of next) seen.add(e);
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
};
|
|
284
|
+
return { fits: (p) => repeat(p, 0), reached: () => reached };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function validateElement(schema, el, decl, errors, file) {
|
|
288
|
+
const err = (e, message, attr) =>
|
|
289
|
+
errors.push({
|
|
290
|
+
file,
|
|
291
|
+
line: e.line,
|
|
292
|
+
column: null,
|
|
293
|
+
message: `Element '${qn(e)}'${attr ? `, attribute '${attr}'` : ''}: ${message}`,
|
|
294
|
+
});
|
|
295
|
+
const type = schema.typeOf(decl);
|
|
296
|
+
|
|
297
|
+
if (type.builtin || type.simple) {
|
|
298
|
+
if (el.children.length) err(el, 'Element content is not allowed, because the type definition is simple.');
|
|
299
|
+
const p = simpleProblem(schema, type, el.allText);
|
|
300
|
+
if (p) err(el, `${p}`);
|
|
301
|
+
for (const a of el.attrs) if (a.ns !== XSI) err(el, `The attribute '${a.name}' is not allowed.`, a.name);
|
|
302
|
+
} else {
|
|
303
|
+
const ct = type.complex;
|
|
304
|
+
// attributes
|
|
305
|
+
for (const a of el.attrs) {
|
|
306
|
+
if (a.ns === XSI) continue;
|
|
307
|
+
const d = a.prefix ? null : ct.attrs.find((x) => x.name === a.name);
|
|
308
|
+
if (!d) {
|
|
309
|
+
err(el, `The attribute '${a.name}' is not allowed.`, a.name);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (d.fixed !== null && a.value !== d.fixed)
|
|
313
|
+
err(el, `The value '${a.value}' does not match the fixed value constraint '${d.fixed}'.`, a.name);
|
|
314
|
+
else {
|
|
315
|
+
const p = simpleProblem(schema, d.type, a.value);
|
|
316
|
+
if (p) err(el, p, a.name);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
for (const d of ct.attrs)
|
|
320
|
+
if (d.use === 'required' && !el.has(d.name)) err(el, `The attribute '${d.name}' is required but missing.`);
|
|
321
|
+
|
|
322
|
+
if (ct.simple) {
|
|
323
|
+
if (el.children.length) err(el, 'Element content is not allowed, because the type definition is simple.');
|
|
324
|
+
const p = simpleProblem(schema, ct.simple, el.allText);
|
|
325
|
+
if (p) err(el, p);
|
|
326
|
+
} else {
|
|
327
|
+
if (!ct.mixed && !blank(el.allText))
|
|
328
|
+
err(el, "Character content other than whitespace is not allowed because the content type is 'element-only'.");
|
|
329
|
+
const tried = new Map();
|
|
330
|
+
if (!ct.particle) {
|
|
331
|
+
if (el.children.length) err(el.children[0], 'This element is not expected. No child element is allowed here.');
|
|
332
|
+
} else {
|
|
333
|
+
const m = matcher(schema, el.children, schema.tns, tried);
|
|
334
|
+
if (!m.fits(ct.particle).has(el.children.length)) {
|
|
335
|
+
const at = m.reached();
|
|
336
|
+
const exp = [...(tried.get(at) ?? [])];
|
|
337
|
+
if (at < el.children.length)
|
|
338
|
+
err(
|
|
339
|
+
el.children[at],
|
|
340
|
+
`This element is not expected.${exp.length ? ` Expected is ( ${exp.join(' | ')} ).` : ''}`,
|
|
341
|
+
);
|
|
342
|
+
else err(el, `Missing child element(s).${exp.length ? ` Expected is ( ${exp.join(' | ')} ).` : ''}`);
|
|
343
|
+
} else {
|
|
344
|
+
// the content model fits: descend, pairing each child with its declaration
|
|
345
|
+
const decls = new Map();
|
|
346
|
+
const collect = (p) => (p.kind === 'element' ? decls.set(p.decl.name, p.decl) : p.items.forEach(collect));
|
|
347
|
+
collect(ct.particle);
|
|
348
|
+
for (const c of el.children) {
|
|
349
|
+
const d = decls.get(c.name);
|
|
350
|
+
if (d && c.ns === schema.tns) validateElement(schema, c, d, errors, file);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// xs:unique, evaluated at the element that declares it
|
|
358
|
+
for (const u of decl.unique) {
|
|
359
|
+
let nodes = [el];
|
|
360
|
+
for (const step of u.selector)
|
|
361
|
+
nodes = nodes.flatMap((n) => n.children.filter((c) => c.name === step.name && c.ns === step.ns));
|
|
362
|
+
const seen = new Map();
|
|
363
|
+
for (const n of nodes) {
|
|
364
|
+
const key = u.fields.map((f) =>
|
|
365
|
+
f.attr
|
|
366
|
+
? n.get(f.attr.name)
|
|
367
|
+
: (n.children.find((c) => c.name === f.child.name && c.ns === f.child.ns)?.text ?? null),
|
|
368
|
+
);
|
|
369
|
+
if (key.some((k) => k === null)) continue;
|
|
370
|
+
const k = JSON.stringify(key);
|
|
371
|
+
if (seen.has(k))
|
|
372
|
+
err(
|
|
373
|
+
n,
|
|
374
|
+
`Duplicate key-sequence [${key.map((v) => `'${v}'`).join(', ')}] in unique identity-constraint '${u.name}'.`,
|
|
375
|
+
);
|
|
376
|
+
else seen.set(k, n);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Validates one file. Returns { errors: [{file,line,column,message,severity}], valid }. */
|
|
382
|
+
function validateFile(schema, file) {
|
|
383
|
+
const errors = [];
|
|
384
|
+
let root;
|
|
385
|
+
try {
|
|
386
|
+
root = parseFile(file);
|
|
387
|
+
} catch (e) {
|
|
388
|
+
if (e instanceof XmlError)
|
|
389
|
+
return {
|
|
390
|
+
errors: [{ file, line: e.line, column: e.column, message: `Malformed XML: ${e.message}`, severity: 'error' }],
|
|
391
|
+
valid: false,
|
|
392
|
+
};
|
|
393
|
+
throw e;
|
|
394
|
+
}
|
|
395
|
+
const decl = root.ns === schema.tns ? schema.elements.get(root.name) : null;
|
|
396
|
+
if (!decl)
|
|
397
|
+
errors.push({
|
|
398
|
+
file,
|
|
399
|
+
line: root.line,
|
|
400
|
+
column: null,
|
|
401
|
+
message: `Element '${root.name}': No matching global declaration available for the validation root.`,
|
|
402
|
+
});
|
|
403
|
+
else validateElement(schema, root, decl, errors, file);
|
|
404
|
+
for (const e of errors) e.severity = 'error';
|
|
405
|
+
return { errors, valid: errors.length === 0 };
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
module.exports = { Schema, SchemaError, validateFile, XSI };
|