xmlui 0.4.0
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/dist/Pdf-DeGhSMXe.mjs +19537 -0
- package/dist/Pdf.css +1 -0
- package/dist/apiInterceptorWorker-CwuUhYyc.mjs +9229 -0
- package/dist/array-USo-Szhp.mjs +12 -0
- package/dist/index-C24dkfpd.mjs +1434 -0
- package/dist/index-ao27SnVp.mjs +145185 -0
- package/dist/index.css +1 -0
- package/dist/nivo-bar.es-CWh0ZlxB.mjs +1666 -0
- package/dist/nivo-geo.es-BTqNt5Db.mjs +1579 -0
- package/dist/nivo-legends.es-BuIxHGSU.mjs +6916 -0
- package/dist/nivo-pie.es-BvCBFA0L.mjs +700 -0
- package/dist/react-apexcharts.min-DqWuDOyO.mjs +8881 -0
- package/dist/scripts/bin/bootstrap.js +11 -0
- package/dist/scripts/bin/build.js +256 -0
- package/dist/scripts/bin/index.js +88 -0
- package/dist/scripts/bin/preview.js +27 -0
- package/dist/scripts/bin/start.js +41 -0
- package/dist/scripts/bin/vite-ueml-plugin.js +113 -0
- package/dist/scripts/bin/viteConfig.js +112 -0
- package/dist/scripts/src/abstractions/ActionDefs.js +2 -0
- package/dist/scripts/src/abstractions/AppContextDefs.js +2 -0
- package/dist/scripts/src/abstractions/BlockScope.js +4 -0
- package/dist/scripts/src/abstractions/ComponentDefs.js +2 -0
- package/dist/scripts/src/abstractions/ComponentDescriptorDefs.js +2 -0
- package/dist/scripts/src/abstractions/ContainerDefs.js +2 -0
- package/dist/scripts/src/abstractions/FunctionDefs.js +2 -0
- package/dist/scripts/src/abstractions/RendererDefs.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptParserError.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTree.js +2 -0
- package/dist/scripts/src/abstractions/scripting/Token.js +110 -0
- package/dist/scripts/src/components/App/App.js +253 -0
- package/dist/scripts/src/components/App/AppLayoutContext.js +9 -0
- package/dist/scripts/src/components/App/AppStateContext.js +9 -0
- package/dist/scripts/src/components/App/Sheet.js +89 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.js +121 -0
- package/dist/scripts/src/components/AppState/AppState.js +29 -0
- package/dist/scripts/src/components/Avatar/Avatar.js +81 -0
- package/dist/scripts/src/components/Badge/Badge.js +56 -0
- package/dist/scripts/src/components/BarChart/BarChart.js +199 -0
- package/dist/scripts/src/components/Bookmark/Bookmark.js +11 -0
- package/dist/scripts/src/components/Button/Button.js +196 -0
- package/dist/scripts/src/components/Card/Card.js +65 -0
- package/dist/scripts/src/components/ChangeListener/ChangeListener.js +43 -0
- package/dist/scripts/src/components/Chart/Chart.js +158 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.js +43 -0
- package/dist/scripts/src/components/Combobox/Combobox.js +145 -0
- package/dist/scripts/src/components/ComponentProvider.js +357 -0
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +40 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.js +196 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +175 -0
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +56 -0
- package/dist/scripts/src/components/FileInput/FileInput.js +127 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +106 -0
- package/dist/scripts/src/components/FlowLayout/FlowLayout.js +139 -0
- package/dist/scripts/src/components/Footer/Footer.js +42 -0
- package/dist/scripts/src/components/Form/Form.js +320 -0
- package/dist/scripts/src/components/Form/FormContext.js +9 -0
- package/dist/scripts/src/components/Form/formActions.js +86 -0
- package/dist/scripts/src/components/FormItem/FormItem.js +204 -0
- package/dist/scripts/src/components/FormItem/HelperText.js +27 -0
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +39 -0
- package/dist/scripts/src/components/FormItem/Validations.js +346 -0
- package/dist/scripts/src/components/FormSection/FormSection.js +45 -0
- package/dist/scripts/src/components/Heading/Heading.js +206 -0
- package/dist/scripts/src/components/HoverCard/HoverCard.js +45 -0
- package/dist/scripts/src/components/Icon/ApiIcon.js +10 -0
- package/dist/scripts/src/components/Icon/Attach.js +10 -0
- package/dist/scripts/src/components/Icon/Binding.js +11 -0
- package/dist/scripts/src/components/Icon/BoardIcon.js +7 -0
- package/dist/scripts/src/components/Icon/BoxIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CheckIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronLeft.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronRight.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
- package/dist/scripts/src/components/Icon/CodeFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CodeSandbox.js +10 -0
- package/dist/scripts/src/components/Icon/CompactListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ContentCopyIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DatabaseIcon.js +11 -0
- package/dist/scripts/src/components/Icon/DocFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DocIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DotMenuHorizontalIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DotMenuIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmailIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmptyFolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/ErrorIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ExpressionIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FillPlusCricleIcon.js +7 -0
- package/dist/scripts/src/components/Icon/FilterIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/GlobeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HomeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HyperLinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.js +101 -0
- package/dist/scripts/src/components/Icon/ImageFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/LinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/LooseListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/MoonIcon.js +10 -0
- package/dist/scripts/src/components/Icon/MoreOptionsIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PDFIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PenIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhoneIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhotoIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PlusIcon.js +7 -0
- package/dist/scripts/src/components/Icon/SearchIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ShareIcon.js +10 -0
- package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
- package/dist/scripts/src/components/Icon/TrashIcon.js +7 -0
- package/dist/scripts/src/components/Icon/TxtIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnknownFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnlinkIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UserIcon.js +7 -0
- package/dist/scripts/src/components/Icon/WarningIcon.js +7 -0
- package/dist/scripts/src/components/Icon/XlsIcon.js +10 -0
- package/dist/scripts/src/components/IconProvider.js +249 -0
- package/dist/scripts/src/components/IconRegistryContext.js +307 -0
- package/dist/scripts/src/components/Image/Image.js +34 -0
- package/dist/scripts/src/components/Input/InputAdornment.js +14 -0
- package/dist/scripts/src/components/Input/input-abstractions.js +44 -0
- package/dist/scripts/src/components/Items/Items.js +48 -0
- package/dist/scripts/src/components/Link/Link.js +72 -0
- package/dist/scripts/src/components/List/List.js +442 -0
- package/dist/scripts/src/components/Logo/Logo.js +25 -0
- package/dist/scripts/src/components/Map/Map.js +60 -0
- package/dist/scripts/src/components/Map/world_countries.json +45307 -0
- package/dist/scripts/src/components/Markdown/Markdown.js +120 -0
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +106 -0
- package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +145 -0
- package/dist/scripts/src/components/MultiCombobox/MultiCombobox.js +249 -0
- package/dist/scripts/src/components/MultiSelect/MultiSelect.js +192 -0
- package/dist/scripts/src/components/NavGroup/NavGroup.js +113 -0
- package/dist/scripts/src/components/NavLink/NavLink.js +115 -0
- package/dist/scripts/src/components/NavPanel/NavPanel.js +101 -0
- package/dist/scripts/src/components/NoResult/NoResult.js +39 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.js +373 -0
- package/dist/scripts/src/components/Option/Option.js +41 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +22 -0
- package/dist/scripts/src/components/Pages/Pages.js +74 -0
- package/dist/scripts/src/components/Pdf/LazyPdf.js +44 -0
- package/dist/scripts/src/components/Pdf/Pdf.js +19 -0
- package/dist/scripts/src/components/PieChart/PieChart.js +184 -0
- package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +29 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +38 -0
- package/dist/scripts/src/components/Queue/Queue.js +286 -0
- package/dist/scripts/src/components/Queue/queueActions.js +87 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +144 -0
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +147 -0
- package/dist/scripts/src/components/Redirect/Redirect.js +10 -0
- package/dist/scripts/src/components/Select/Select.js +139 -0
- package/dist/scripts/src/components/Select/SelectContext.js +45 -0
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +88 -0
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +22 -0
- package/dist/scripts/src/components/Spinner/Spinner.js +59 -0
- package/dist/scripts/src/components/Splitter/Splitter.js +205 -0
- package/dist/scripts/src/components/Splitter/utils.js +17 -0
- package/dist/scripts/src/components/Stack/Stack.js +117 -0
- package/dist/scripts/src/components/StickyBox/StickyBox.js +33 -0
- package/dist/scripts/src/components/Switch/Switch.js +50 -0
- package/dist/scripts/src/components/Table/Table.js +499 -0
- package/dist/scripts/src/components/Table/useRowSelection.js +169 -0
- package/dist/scripts/src/components/TableColumnDef/TableColumnDef.js +44 -0
- package/dist/scripts/src/components/TableColumnDef/TableContext.js +12 -0
- package/dist/scripts/src/components/Tabs/Tabs.js +85 -0
- package/dist/scripts/src/components/Text/Text.js +175 -0
- package/dist/scripts/src/components/TextArea/TextArea.js +194 -0
- package/dist/scripts/src/components/TextArea/TextAreaResizable.js +63 -0
- package/dist/scripts/src/components/TextArea/useComposedRef.js +50 -0
- package/dist/scripts/src/components/TextBox/TextBox.js +145 -0
- package/dist/scripts/src/components/Theme/NotificationToast.js +39 -0
- package/dist/scripts/src/components/Theme/Theme.js +153 -0
- package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +125 -0
- package/dist/scripts/src/components/Toggle/Toggle.js +88 -0
- package/dist/scripts/src/components/Tree/TreeComponent.js +79 -0
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +59 -0
- package/dist/scripts/src/components/ViewComponentRegistryContext.js +34 -0
- package/dist/scripts/src/components/abstractions.js +2 -0
- package/dist/scripts/src/components/chart-color-schemes.js +43 -0
- package/dist/scripts/src/components/component-utils.js +32 -0
- package/dist/scripts/src/components/container-helpers.js +18 -0
- package/dist/scripts/src/components-core/ApiBoundComponent.js +189 -0
- package/dist/scripts/src/components-core/AppContext.js +17 -0
- package/dist/scripts/src/components-core/ChildrenSlot.js +10 -0
- package/dist/scripts/src/components-core/Component.js +280 -0
- package/dist/scripts/src/components-core/ComponentDecorator.js +63 -0
- package/dist/scripts/src/components-core/CompoundComponent.js +132 -0
- package/dist/scripts/src/components-core/EngineError.js +91 -0
- package/dist/scripts/src/components-core/ErrorBoundary.js +58 -0
- package/dist/scripts/src/components-core/Fragment.js +14 -0
- package/dist/scripts/src/components-core/InvalidComponent.js +15 -0
- package/dist/scripts/src/components-core/LoaderComponent.js +78 -0
- package/dist/scripts/src/components-core/RestApiProxy.js +341 -0
- package/dist/scripts/src/components-core/RootComponent.js +272 -0
- package/dist/scripts/src/components-core/RouteContext.js +45 -0
- package/dist/scripts/src/components-core/ScrollContext.js +9 -0
- package/dist/scripts/src/components-core/UnknownComponent.js +15 -0
- package/dist/scripts/src/components-core/abstractions/ComponentRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/LoaderRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/containers.js +18 -0
- package/dist/scripts/src/components-core/abstractions/treeAbstractions.js +2 -0
- package/dist/scripts/src/components-core/action/ApiAction.js +276 -0
- package/dist/scripts/src/components-core/action/DownloadFileAction.js +80 -0
- package/dist/scripts/src/components-core/action/NavigateAction.js +20 -0
- package/dist/scripts/src/components-core/action/TimedAction.js +21 -0
- package/dist/scripts/src/components-core/action/UploadAction.js +88 -0
- package/dist/scripts/src/components-core/action/actions.js +15 -0
- package/dist/scripts/src/components-core/appContext/date-functions.js +19 -0
- package/dist/scripts/src/components-core/appContext/misc-utils.js +12 -0
- package/dist/scripts/src/components-core/component-hooks.js +25 -0
- package/dist/scripts/src/components-core/constants.js +18 -0
- package/dist/scripts/src/components-core/container/Container.js +1110 -0
- package/dist/scripts/src/components-core/container/ContainerComponentDef.js +16 -0
- package/dist/scripts/src/components-core/container/buildProxy.js +54 -0
- package/dist/scripts/src/components-core/container/collectFnVarDeps.js +26 -0
- package/dist/scripts/src/components-core/container/valueExtractor.js +195 -0
- package/dist/scripts/src/components-core/descriptorHelper.js +75 -0
- package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
- package/dist/scripts/src/components-core/loader/ApiLoader.js +46 -0
- package/dist/scripts/src/components-core/loader/DataLoader.js +160 -0
- package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +52 -0
- package/dist/scripts/src/components-core/loader/Loader.js +115 -0
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +32 -0
- package/dist/scripts/src/components-core/loader/PageableLoader.js +240 -0
- package/dist/scripts/src/components-core/renderers.js +45 -0
- package/dist/scripts/src/components-core/reportEngineError.js +59 -0
- package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +35 -0
- package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +34 -0
- package/dist/scripts/src/components-core/script-runner/LogicalThread.js +2 -0
- package/dist/scripts/src/components-core/script-runner/LoopScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/ParameterParser.js +117 -0
- package/dist/scripts/src/components-core/script-runner/TryScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +96 -0
- package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +34 -0
- package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +40 -0
- package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +40 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +551 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +498 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +434 -0
- package/dist/scripts/src/components-core/script-runner/modules.js +250 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +818 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +193 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +740 -0
- package/dist/scripts/src/components-core/script-runner/statement-queue.js +62 -0
- package/dist/scripts/src/components-core/script-runner/visitors.js +352 -0
- package/dist/scripts/src/components-core/theming/ThemeContext.js +43 -0
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +334 -0
- package/dist/scripts/src/components-core/theming/abstractions.js +11 -0
- package/dist/scripts/src/components-core/theming/extendThemeUtils.js +114 -0
- package/dist/scripts/src/components-core/theming/hvar.js +105 -0
- package/dist/scripts/src/components-core/theming/themeVars.js +62 -0
- package/dist/scripts/src/components-core/theming/themes/base-utils.js +31 -0
- package/dist/scripts/src/components-core/theming/themes/palette.js +53 -0
- package/dist/scripts/src/components-core/theming/themes/root.js +257 -0
- package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
- package/dist/scripts/src/components-core/theming/themes/theme-colors.js +407 -0
- package/dist/scripts/src/components-core/theming/themes/xmlui.js +32 -0
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +286 -0
- package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +34 -0
- package/dist/scripts/src/components-core/utils/LruCache.js +184 -0
- package/dist/scripts/src/components-core/utils/actionUtils.js +32 -0
- package/dist/scripts/src/components-core/utils/classnames.js +58 -0
- package/dist/scripts/src/components-core/utils/css-utils.js +127 -0
- package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
- package/dist/scripts/src/components-core/utils/extractParam.js +148 -0
- package/dist/scripts/src/components-core/utils/hooks.js +221 -0
- package/dist/scripts/src/components-core/utils/mergeProps.js +45 -0
- package/dist/scripts/src/components-core/utils/misc.js +460 -0
- package/dist/scripts/src/components-core/utils/statementUtils.js +205 -0
- package/dist/scripts/src/components-core/utils/treeUtils.js +48 -0
- package/dist/scripts/src/components-core/xmlui-parser.js +52 -0
- package/dist/scripts/src/parsers/scripting/InputStream.js +59 -0
- package/dist/scripts/src/parsers/scripting/Lexer.js +1028 -0
- package/dist/scripts/src/parsers/scripting/Parser.js +2647 -0
- package/dist/scripts/src/parsers/scripting/ParserError.js +46 -0
- package/dist/scripts/src/parsers/scripting/TokenTrait.js +109 -0
- package/dist/scripts/src/parsers/scripting/code-behind-collect.js +118 -0
- package/dist/scripts/src/parsers/scripting/tree-visitor.js +602 -0
- package/dist/scripts/src/parsers/style-parser/StyleInputStream.js +39 -0
- package/dist/scripts/src/parsers/style-parser/StyleLexer.js +621 -0
- package/dist/scripts/src/parsers/style-parser/StyleParser.js +1000 -0
- package/dist/scripts/src/parsers/style-parser/errors.js +37 -0
- package/dist/scripts/src/parsers/style-parser/source-tree.js +2 -0
- package/dist/scripts/src/parsers/style-parser/style-compiler.js +513 -0
- package/dist/scripts/src/parsers/style-parser/tokens.js +42 -0
- package/dist/scripts/src/parsers/ueml/ParserError.js +54 -0
- package/dist/scripts/src/parsers/ueml/UemlHelper.js +579 -0
- package/dist/scripts/src/parsers/ueml/UemlInputStream.js +59 -0
- package/dist/scripts/src/parsers/ueml/UemlLexer.js +868 -0
- package/dist/scripts/src/parsers/ueml/UemlParser.js +1439 -0
- package/dist/scripts/src/parsers/ueml/UemlToken.js +24 -0
- package/dist/scripts/src/parsers/ueml/fileExtensions.js +6 -0
- package/dist/scripts/src/parsers/ueml/source-tree.js +2 -0
- package/dist/scripts/src/parsers/ueml/ueml-tree.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/CharacterCodes.js +136 -0
- package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +100 -0
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +476 -0
- package/dist/scripts/src/parsers/xmlui-parser/scanner.js +415 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-kind.js +106 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-node.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +922 -0
- package/dist/scripts/src/parsers/xmlui-parser/utils.js +83 -0
- package/dist/xmlui.es.d.ts +1667 -0
- package/dist/xmlui.es.js +17 -0
- package/dist/xmlui.umd.js +1589 -0
- package/package.json +175 -0
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UemlHelper = exports.onPrefixRegex = exports.UCRegex = exports.COMPOUND_COMP_ID = void 0;
|
|
4
|
+
exports.COMPOUND_COMP_ID = "Component";
|
|
5
|
+
exports.UCRegex = /^[A-Z]/;
|
|
6
|
+
exports.onPrefixRegex = /^on[A-Z]/;
|
|
7
|
+
const attrBreakRegex = /[\r\n<>'"&]/;
|
|
8
|
+
/**
|
|
9
|
+
* Helper class for UEML serialization and parsing
|
|
10
|
+
*/
|
|
11
|
+
class UemlHelper {
|
|
12
|
+
/**
|
|
13
|
+
* Serialize the specified XML fragment into a string
|
|
14
|
+
* @param xml XML fragment to serialize
|
|
15
|
+
* @param options Formatting options to use
|
|
16
|
+
*/
|
|
17
|
+
serialize(xml, options) {
|
|
18
|
+
const fragment = Array.isArray(xml) ? xml : [xml];
|
|
19
|
+
return serializeFragment(fragment, 0);
|
|
20
|
+
function serializeFragment(nodes, depth) {
|
|
21
|
+
return nodes.map((n) => serializeNode(n, depth)).join((options === null || options === void 0 ? void 0 : options.prettify) ? "\n" + getIndent(depth) : "");
|
|
22
|
+
}
|
|
23
|
+
function serializeNode(node, depth) {
|
|
24
|
+
switch (node.type) {
|
|
25
|
+
case "UemlComment":
|
|
26
|
+
return serializeXmlComment(node, depth);
|
|
27
|
+
case "UemlElement":
|
|
28
|
+
return serializeXmlElement(node, depth);
|
|
29
|
+
default:
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function getIndent(depth) {
|
|
34
|
+
var _a;
|
|
35
|
+
return (options === null || options === void 0 ? void 0 : options.prettify) ? "".padEnd(((_a = options === null || options === void 0 ? void 0 : options.indents) !== null && _a !== void 0 ? _a : 2) * depth, " ") : "";
|
|
36
|
+
}
|
|
37
|
+
function serializeXmlComment(node, depth) {
|
|
38
|
+
return `${getIndent(depth)}<!--${node.text}-->`;
|
|
39
|
+
}
|
|
40
|
+
function serializeXmlElement(node, depth) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
42
|
+
let elementStr = `${getIndent(depth)}<${nodeName()}`;
|
|
43
|
+
const hasAttrs = ((_b = (_a = node.attributes) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
44
|
+
const hasChildren = ((_d = (_c = node.childNodes) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0;
|
|
45
|
+
if (node.text || hasAttrs || hasChildren) {
|
|
46
|
+
// --- Indicate that the node has not yet been broken into multiple lines
|
|
47
|
+
if (hasAttrs) {
|
|
48
|
+
// --- Render attributes
|
|
49
|
+
const attrTexts = node.attributes.map((a) => serializeXmlAttribute(a));
|
|
50
|
+
if (!(options === null || options === void 0 ? void 0 : options.prettify)) {
|
|
51
|
+
elementStr += " " + attrTexts.join(" ");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// --- Check line overflow
|
|
55
|
+
const nodeLength = elementStr.length +
|
|
56
|
+
1 + // --- Space after
|
|
57
|
+
attrTexts.join(" ").length + // --- Attributes total length
|
|
58
|
+
(hasChildren ? 1 : ((_e = options === null || options === void 0 ? void 0 : options.useSpaceBeforeClose) !== null && _e !== void 0 ? _e : false) ? 3 : 2); // --- Closing token length
|
|
59
|
+
if (nodeLength > ((_f = options === null || options === void 0 ? void 0 : options.lineLength) !== null && _f !== void 0 ? _f : 80)) {
|
|
60
|
+
// --- Too long, break attributes into new lines
|
|
61
|
+
attrTexts.forEach((text) => {
|
|
62
|
+
elementStr += "\n" + getIndent(depth + 1) + text;
|
|
63
|
+
});
|
|
64
|
+
if ((_g = options === null || options === void 0 ? void 0 : options.breakClosingTag) !== null && _g !== void 0 ? _g : false) {
|
|
65
|
+
elementStr += "\n" + getIndent(depth);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// --- Attributes fit into the line
|
|
70
|
+
elementStr += " " + attrTexts.join(" ");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (node.text || hasChildren) {
|
|
75
|
+
// --- Close the opening tag
|
|
76
|
+
elementStr += ">";
|
|
77
|
+
// --- Render the text
|
|
78
|
+
if (node.text) {
|
|
79
|
+
const textContents = node.preserveSpaces ? serializeQuotedText(node.text) : serializeText(node.text);
|
|
80
|
+
if ((options === null || options === void 0 ? void 0 : options.prettify) &&
|
|
81
|
+
elementStr.length + textContents.length + node.name.length + 3 > ((_h = options === null || options === void 0 ? void 0 : options.lineLength) !== null && _h !== void 0 ? _h : 80)) {
|
|
82
|
+
// --- break text
|
|
83
|
+
elementStr += "\n" + getIndent(depth + 1) + textContents + "\n";
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
elementStr += textContents;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// --- Render child nodes
|
|
90
|
+
if (hasChildren) {
|
|
91
|
+
const childrenTexts = node.childNodes.map((c) => serializeNode(c, depth + 1));
|
|
92
|
+
if (!(options === null || options === void 0 ? void 0 : options.prettify)) {
|
|
93
|
+
elementStr += childrenTexts.join("");
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
childrenTexts.forEach((text) => {
|
|
97
|
+
elementStr += "\n" + text;
|
|
98
|
+
});
|
|
99
|
+
elementStr += "\n";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// --- Render the closing tag
|
|
103
|
+
elementStr += `${getIndent(depth)}</${node.name}>`;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
elementStr += (((_j = options === null || options === void 0 ? void 0 : options.useSpaceBeforeClose) !== null && _j !== void 0 ? _j : false) ? " " : "") + "/>";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
elementStr += (((_k = options === null || options === void 0 ? void 0 : options.useSpaceBeforeClose) !== null && _k !== void 0 ? _k : false) ? " " : "") + "/>";
|
|
111
|
+
if (node.text === "") {
|
|
112
|
+
elementStr += `""</${nodeName()}>`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return elementStr;
|
|
116
|
+
function nodeName() {
|
|
117
|
+
return node.namespace ? `${node.namespace}:${node.name}` : node.name;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function serializeXmlAttribute(node) {
|
|
121
|
+
var _a;
|
|
122
|
+
// --- Handle valueless attributes
|
|
123
|
+
if (node.value === undefined || node.value === null) {
|
|
124
|
+
return `${nodeName()}`;
|
|
125
|
+
}
|
|
126
|
+
// --- Use quotes when required so
|
|
127
|
+
if (node.preserveSpaces) {
|
|
128
|
+
return `${nodeName()}=${serializeQuotedText(node.value)}`;
|
|
129
|
+
}
|
|
130
|
+
// --- Do the rest
|
|
131
|
+
const value = (_a = node.value) !== null && _a !== void 0 ? _a : "";
|
|
132
|
+
return `${nodeName()}=${serializeQuotedText(value)}`;
|
|
133
|
+
function nodeName() {
|
|
134
|
+
return node.namespace ? `${node.namespace}:${node.name}` : node.name;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function serializeText(text) {
|
|
138
|
+
return (options === null || options === void 0 ? void 0 : options.useQuotes) || attrBreakRegex.test(text) ? serializeQuotedText(text) : text;
|
|
139
|
+
}
|
|
140
|
+
function serializeQuotedText(text) {
|
|
141
|
+
const containsQuote = text.indexOf("'") >= 0;
|
|
142
|
+
const containsDQuote = text.indexOf('"') >= 0;
|
|
143
|
+
if ((!containsQuote && !containsDQuote) || (containsQuote && !containsDQuote)) {
|
|
144
|
+
return `"${text.replaceAll("`", "\\`")}"`;
|
|
145
|
+
}
|
|
146
|
+
if (containsDQuote && !containsQuote) {
|
|
147
|
+
return `'${text.replaceAll("`", "\\`")}'`;
|
|
148
|
+
}
|
|
149
|
+
return `\`${text.replaceAll("`", "\\`")}\``;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Transform the specified component definition into an UEML node
|
|
154
|
+
* @param def Component definitions
|
|
155
|
+
* @param options Transformation options
|
|
156
|
+
*/
|
|
157
|
+
transformComponentDefinition(def, options) {
|
|
158
|
+
return def.type
|
|
159
|
+
? this.transformSimpleComponentDefinition(def, options)
|
|
160
|
+
: this.transformCompoundComponentDefinition(def, options);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Transform the specified object into an UEML nodes
|
|
164
|
+
* @param def Object definition
|
|
165
|
+
* @param options Transformation options
|
|
166
|
+
*/
|
|
167
|
+
transformObject(def, options) {
|
|
168
|
+
var _a;
|
|
169
|
+
const transformed = this.transformValue("Object", "", def, options);
|
|
170
|
+
if (!transformed) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return (_a = transformed.childNodes) !== null && _a !== void 0 ? _a : [];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Transforms the specified simple component definition into an UEML node
|
|
177
|
+
* @param def Component definition
|
|
178
|
+
* @param options Transformation options
|
|
179
|
+
*/
|
|
180
|
+
transformSimpleComponentDefinition(def, options) {
|
|
181
|
+
const componentNode = {
|
|
182
|
+
type: "UemlElement",
|
|
183
|
+
name: def.type,
|
|
184
|
+
};
|
|
185
|
+
// --- Fundamental props
|
|
186
|
+
if (def.uid !== undefined) {
|
|
187
|
+
this.addProperty(componentNode, "id", def.uid, options);
|
|
188
|
+
}
|
|
189
|
+
if (def.testId !== undefined) {
|
|
190
|
+
this.addProperty(componentNode, "testId", def.testId, options);
|
|
191
|
+
}
|
|
192
|
+
if (def.when !== undefined) {
|
|
193
|
+
this.addProperty(componentNode, "when", def.when, options);
|
|
194
|
+
}
|
|
195
|
+
// --- Process vars
|
|
196
|
+
if (def.vars) {
|
|
197
|
+
Object.keys(def.vars).forEach((key) => {
|
|
198
|
+
var _a;
|
|
199
|
+
const varElement = this.transformValue("var", key, def.vars[key], options);
|
|
200
|
+
if (varElement === null)
|
|
201
|
+
return;
|
|
202
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
203
|
+
componentNode.childNodes.push(varElement);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// --- Process properties
|
|
207
|
+
if (def.props) {
|
|
208
|
+
Object.keys(def.props).forEach((key) => {
|
|
209
|
+
var _a, _b, _c;
|
|
210
|
+
// --- Special serialization for component-aware props
|
|
211
|
+
const propValue = def.props[key];
|
|
212
|
+
if (key.endsWith("Template") && propValue.type) {
|
|
213
|
+
// --- Consider this property holds a component
|
|
214
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
215
|
+
const propWrapper = {
|
|
216
|
+
type: "UemlElement",
|
|
217
|
+
name: "prop",
|
|
218
|
+
attributes: [
|
|
219
|
+
{
|
|
220
|
+
type: "UemlAttribute",
|
|
221
|
+
name: "name",
|
|
222
|
+
value: key,
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
};
|
|
226
|
+
this.addComponentElement(propWrapper, propValue);
|
|
227
|
+
componentNode.childNodes.push(propWrapper);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
// --- Undefined is not serialized
|
|
231
|
+
if (propValue === undefined) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
// --- Handle null property value
|
|
235
|
+
if (propValue === null) {
|
|
236
|
+
const nullPropElement = {
|
|
237
|
+
type: "UemlElement",
|
|
238
|
+
name: "prop",
|
|
239
|
+
attributes: [
|
|
240
|
+
{
|
|
241
|
+
type: "UemlAttribute",
|
|
242
|
+
name: "name",
|
|
243
|
+
value: key,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
};
|
|
247
|
+
(_b = componentNode.childNodes) !== null && _b !== void 0 ? _b : (componentNode.childNodes = []);
|
|
248
|
+
componentNode.childNodes.push(nullPropElement);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
// --- Extract prop if asked so, or if those are special, like "id", "when", or "testIs"
|
|
252
|
+
if (key === "id" || key === "when" || key === "testId" || (options === null || options === void 0 ? void 0 : options.extractProps)) {
|
|
253
|
+
const idPropElement = {
|
|
254
|
+
type: "UemlElement",
|
|
255
|
+
name: "prop",
|
|
256
|
+
};
|
|
257
|
+
this.addProperty(idPropElement, key, propValue, options);
|
|
258
|
+
(_c = componentNode.childNodes) !== null && _c !== void 0 ? _c : (componentNode.childNodes = []);
|
|
259
|
+
componentNode.childNodes.push(idPropElement);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
// --- Add property as the best according to the value
|
|
263
|
+
this.addProperty(componentNode, key, propValue, options);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
// --- Process events
|
|
268
|
+
if (def.events) {
|
|
269
|
+
Object.keys(def.events).forEach((key) => {
|
|
270
|
+
var _a;
|
|
271
|
+
const eventElement = this.transformValue("event", key, def.events[key], options);
|
|
272
|
+
if (eventElement === null)
|
|
273
|
+
return;
|
|
274
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
275
|
+
componentNode.childNodes.push(eventElement);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
// --- Process loaders
|
|
279
|
+
if (def.loaders) {
|
|
280
|
+
this.addComponentList(componentNode, "loaders", def.loaders);
|
|
281
|
+
}
|
|
282
|
+
// --- Process APIs
|
|
283
|
+
if (def.api) {
|
|
284
|
+
Object.keys(def.api).forEach((key) => {
|
|
285
|
+
var _a;
|
|
286
|
+
const apiElement = this.transformValue("api", key, def.api[key], options);
|
|
287
|
+
if (apiElement === null)
|
|
288
|
+
return;
|
|
289
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
290
|
+
componentNode.childNodes.push(apiElement);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
// --- Process uses
|
|
294
|
+
if (def.uses) {
|
|
295
|
+
this.addList(componentNode, "uses", "", def.uses, options);
|
|
296
|
+
}
|
|
297
|
+
// --- Process children
|
|
298
|
+
if (def.children) {
|
|
299
|
+
if (typeof def.children === "string") {
|
|
300
|
+
this.addProperty(componentNode, "children", def.children, options);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
def.children.forEach((ch) => {
|
|
304
|
+
this.addComponentElement(componentNode, ch);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// --- Done
|
|
309
|
+
return componentNode;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Transforms the specified simple component definition into an Xml node
|
|
313
|
+
* @param def Compound component definition
|
|
314
|
+
* @param options Transformation options
|
|
315
|
+
*/
|
|
316
|
+
transformCompoundComponentDefinition(def, options) {
|
|
317
|
+
if (typeof def === "string") {
|
|
318
|
+
return {
|
|
319
|
+
type: "UemlElement",
|
|
320
|
+
name: def,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
const nested = this.transformSimpleComponentDefinition(def.component, options);
|
|
324
|
+
const componentNode = {
|
|
325
|
+
type: "UemlElement",
|
|
326
|
+
name: exports.COMPOUND_COMP_ID,
|
|
327
|
+
attributes: [
|
|
328
|
+
{
|
|
329
|
+
type: "UemlAttribute",
|
|
330
|
+
name: "name",
|
|
331
|
+
value: def.name,
|
|
332
|
+
},
|
|
333
|
+
],
|
|
334
|
+
childNodes: Array.isArray(nested) ? [...nested] : [nested],
|
|
335
|
+
};
|
|
336
|
+
// --- Transform APIs
|
|
337
|
+
if (def.api) {
|
|
338
|
+
Object.keys(def.api).forEach((key) => {
|
|
339
|
+
var _a;
|
|
340
|
+
const apiElement = this.transformValue("api", key, def.api[key], options);
|
|
341
|
+
if (apiElement === null)
|
|
342
|
+
return;
|
|
343
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
344
|
+
componentNode.childNodes.push(apiElement);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
// --- Done
|
|
348
|
+
return componentNode;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Transforms a value into an UEML element
|
|
352
|
+
* @param nodeName Name of the value node
|
|
353
|
+
* @param name Optional (property) name
|
|
354
|
+
* @param value Value to transform
|
|
355
|
+
* @param options Transformation options
|
|
356
|
+
*/
|
|
357
|
+
transformValue(nodeName, name, value, options) {
|
|
358
|
+
var _a, _b, _c;
|
|
359
|
+
// --- Do not transform undefined elements
|
|
360
|
+
if (value === undefined)
|
|
361
|
+
return null;
|
|
362
|
+
// --- Prepare the node with the value
|
|
363
|
+
const valueNode = {
|
|
364
|
+
type: "UemlElement",
|
|
365
|
+
name: nodeName,
|
|
366
|
+
};
|
|
367
|
+
if (name) {
|
|
368
|
+
valueNode.attributes = [
|
|
369
|
+
{
|
|
370
|
+
type: "UemlAttribute",
|
|
371
|
+
name: "name",
|
|
372
|
+
value: name,
|
|
373
|
+
},
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
// --- Extend the node according to the specified value
|
|
377
|
+
// --- Null value: we're done
|
|
378
|
+
if (value === null) {
|
|
379
|
+
return valueNode;
|
|
380
|
+
}
|
|
381
|
+
// --- Simple value: use text or value attribute
|
|
382
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
383
|
+
const strValue = typeof value === "string" ? value.toString() : `{${value.toString()}}`;
|
|
384
|
+
const preserveSpaces = attrBreakRegex.test(strValue) || strValue.trim().length != strValue.length;
|
|
385
|
+
if (options === null || options === void 0 ? void 0 : options.preferTextToValue) {
|
|
386
|
+
valueNode.text = strValue;
|
|
387
|
+
valueNode.preserveSpaces = preserveSpaces;
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
(_a = valueNode.attributes) !== null && _a !== void 0 ? _a : (valueNode.attributes = []);
|
|
391
|
+
valueNode.attributes.push({
|
|
392
|
+
type: "UemlAttribute",
|
|
393
|
+
name: "value",
|
|
394
|
+
value: strValue,
|
|
395
|
+
preserveSpaces,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
return valueNode;
|
|
399
|
+
}
|
|
400
|
+
// --- Array value
|
|
401
|
+
if (Array.isArray(value)) {
|
|
402
|
+
if (value.length === 0) {
|
|
403
|
+
// --- Empty array
|
|
404
|
+
(_b = valueNode.attributes) !== null && _b !== void 0 ? _b : (valueNode.attributes = []);
|
|
405
|
+
valueNode.attributes.push({
|
|
406
|
+
type: "UemlAttribute",
|
|
407
|
+
name: "value",
|
|
408
|
+
value: "{[]}",
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
value.forEach((item) => {
|
|
413
|
+
var _a;
|
|
414
|
+
const itemElement = this.transformValue("item", undefined, item, options);
|
|
415
|
+
if (!itemElement)
|
|
416
|
+
return;
|
|
417
|
+
(_a = valueNode.childNodes) !== null && _a !== void 0 ? _a : (valueNode.childNodes = []);
|
|
418
|
+
valueNode.childNodes.push(itemElement);
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else if (typeof value === "object") {
|
|
423
|
+
const keys = Object.keys(value);
|
|
424
|
+
if (keys.length === 0) {
|
|
425
|
+
// --- Empty object
|
|
426
|
+
(_c = valueNode.attributes) !== null && _c !== void 0 ? _c : (valueNode.attributes = []);
|
|
427
|
+
valueNode.attributes.push({
|
|
428
|
+
type: "UemlAttribute",
|
|
429
|
+
name: "value",
|
|
430
|
+
value: "{{}}",
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
keys.forEach((key) => {
|
|
435
|
+
var _a;
|
|
436
|
+
const fieldElement = this.transformValue("field", key, value[key], options);
|
|
437
|
+
if (!fieldElement)
|
|
438
|
+
return;
|
|
439
|
+
(_a = valueNode.childNodes) !== null && _a !== void 0 ? _a : (valueNode.childNodes = []);
|
|
440
|
+
valueNode.childNodes.push(fieldElement);
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
throw new Error(`Cannot serialize '${typeof value}' value`);
|
|
446
|
+
}
|
|
447
|
+
return valueNode;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Transforms the specified simple component definition into an Xml node
|
|
451
|
+
* @param name Element name
|
|
452
|
+
* @param value Value to transform
|
|
453
|
+
* @param options Transformation options
|
|
454
|
+
*/
|
|
455
|
+
transformObjectValue(name, value, options) {
|
|
456
|
+
const componentNode = {
|
|
457
|
+
type: "UemlElement",
|
|
458
|
+
name: name,
|
|
459
|
+
};
|
|
460
|
+
if (value) {
|
|
461
|
+
Object.keys(value).forEach((key) => this.addProperty(componentNode, key, value[key], options));
|
|
462
|
+
}
|
|
463
|
+
return componentNode;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Add a property to the specified UEML element
|
|
467
|
+
* @param element XML element
|
|
468
|
+
* @param name Element name
|
|
469
|
+
* @param value Element value
|
|
470
|
+
* @param options Transformation options
|
|
471
|
+
*/
|
|
472
|
+
addProperty(element, name, value, options) {
|
|
473
|
+
var _a, _b, _c;
|
|
474
|
+
switch (typeof value) {
|
|
475
|
+
// --- We do not serialize undefined property values
|
|
476
|
+
case "undefined":
|
|
477
|
+
break;
|
|
478
|
+
case "string":
|
|
479
|
+
(_a = element.attributes) !== null && _a !== void 0 ? _a : (element.attributes = []);
|
|
480
|
+
element.attributes.push({
|
|
481
|
+
type: "UemlAttribute",
|
|
482
|
+
name,
|
|
483
|
+
value: value === null || value === void 0 ? void 0 : value.toString(),
|
|
484
|
+
preserveQuotes: (_b = options === null || options === void 0 ? void 0 : options.removeQuotes) !== null && _b !== void 0 ? _b : false,
|
|
485
|
+
preserveSpaces: attrBreakRegex.test(value.toString()),
|
|
486
|
+
});
|
|
487
|
+
break;
|
|
488
|
+
case "boolean":
|
|
489
|
+
case "number":
|
|
490
|
+
case "object":
|
|
491
|
+
const objElement = this.transformValue("prop", name, value, options);
|
|
492
|
+
if (objElement) {
|
|
493
|
+
(_c = element.childNodes) !== null && _c !== void 0 ? _c : (element.childNodes = []);
|
|
494
|
+
element.childNodes.push(objElement);
|
|
495
|
+
}
|
|
496
|
+
break;
|
|
497
|
+
default:
|
|
498
|
+
throw new Error(`'${typeof value}' transformation is not implemented yet`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
addComponentElement(element, component) {
|
|
502
|
+
var _a;
|
|
503
|
+
(_a = element.childNodes) !== null && _a !== void 0 ? _a : (element.childNodes = []);
|
|
504
|
+
const childDef = this.transformComponentDefinition(component);
|
|
505
|
+
if (Array.isArray(childDef)) {
|
|
506
|
+
element.childNodes.push(...childDef);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
element.childNodes.push(childDef);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Adds a list to the specified XML element
|
|
514
|
+
* @param element XML element
|
|
515
|
+
* @param name Name of the list (child in `element`)
|
|
516
|
+
* @param prefix Prefix to use for the list
|
|
517
|
+
* @param list List with items
|
|
518
|
+
* @param options Transformation options
|
|
519
|
+
*/
|
|
520
|
+
addList(element, name, prefix, list, options) {
|
|
521
|
+
var _a;
|
|
522
|
+
const nodeName = `${prefix ? prefix + "." : ""}${name}`;
|
|
523
|
+
(_a = element.childNodes) !== null && _a !== void 0 ? _a : (element.childNodes = []);
|
|
524
|
+
list.forEach((item) => {
|
|
525
|
+
if (typeof item === "string") {
|
|
526
|
+
// --- Special case, the item can be the text of an XML element
|
|
527
|
+
element.childNodes.push({
|
|
528
|
+
type: "UemlElement",
|
|
529
|
+
name: nodeName,
|
|
530
|
+
text: item,
|
|
531
|
+
preserveSpaces: attrBreakRegex.test(item) || item !== item.trim() || item === "",
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
else if (item === null) {
|
|
535
|
+
element.childNodes.push({
|
|
536
|
+
type: "UemlElement",
|
|
537
|
+
name: nodeName,
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
const transformed = this.transformObjectValue(nodeName, item, options);
|
|
542
|
+
if (Array.isArray(transformed)) {
|
|
543
|
+
element.childNodes.push(...transformed);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
element.childNodes.push(transformed);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Adds a component list to the specified element
|
|
553
|
+
* @param element XML element
|
|
554
|
+
* @param name Name to use for the wrapper element
|
|
555
|
+
* @param list List with component items
|
|
556
|
+
* @private
|
|
557
|
+
*/
|
|
558
|
+
addComponentList(element, name, list) {
|
|
559
|
+
var _a;
|
|
560
|
+
const children = [];
|
|
561
|
+
list.forEach((item) => {
|
|
562
|
+
const fragment = this.transformSimpleComponentDefinition(item);
|
|
563
|
+
if (Array.isArray(fragment)) {
|
|
564
|
+
children.push(...fragment);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
children.push(fragment);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
const listElement = {
|
|
571
|
+
type: "UemlElement",
|
|
572
|
+
name,
|
|
573
|
+
childNodes: children,
|
|
574
|
+
};
|
|
575
|
+
(_a = element.childNodes) !== null && _a !== void 0 ? _a : (element.childNodes = []);
|
|
576
|
+
element.childNodes.push(listElement);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
exports.UemlHelper = UemlHelper;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UemlInputStream = void 0;
|
|
4
|
+
// This class represents the input stream of the UEML parser
|
|
5
|
+
class UemlInputStream {
|
|
6
|
+
// Creates a stream that uses the specified source code
|
|
7
|
+
constructor(source) {
|
|
8
|
+
this.source = source;
|
|
9
|
+
// --- Current stream position
|
|
10
|
+
this._pos = 0;
|
|
11
|
+
// --- Current line number
|
|
12
|
+
this._line = 1;
|
|
13
|
+
// --- Current column number
|
|
14
|
+
this._column = 0;
|
|
15
|
+
}
|
|
16
|
+
// Gets the current position in the stream. Starts from 0.
|
|
17
|
+
get position() {
|
|
18
|
+
return this._pos;
|
|
19
|
+
}
|
|
20
|
+
// Gets the current line number. Starts from 1.
|
|
21
|
+
get line() {
|
|
22
|
+
return this._line;
|
|
23
|
+
}
|
|
24
|
+
// Gets the current column number. Starts from 0.
|
|
25
|
+
get column() {
|
|
26
|
+
return this._column;
|
|
27
|
+
}
|
|
28
|
+
// Peeks the next character in the stream. Returns null, if EOF; otherwise the current source code character
|
|
29
|
+
peek() {
|
|
30
|
+
return this.ahead(0);
|
|
31
|
+
}
|
|
32
|
+
// Looks ahead with `n` characters in the stream. Returns null, if EOF; otherwise the look-ahead character
|
|
33
|
+
ahead(n = 1) {
|
|
34
|
+
return this._pos + n > this.source.length - 1 ? null : this.source[this._pos + n];
|
|
35
|
+
}
|
|
36
|
+
// Gets the next character from the stream
|
|
37
|
+
get() {
|
|
38
|
+
// --- Check for EOF
|
|
39
|
+
if (this._pos >= this.source.length) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
// --- Get the char, and keep track of position
|
|
43
|
+
const ch = this.source[this._pos++];
|
|
44
|
+
if (ch === "\n") {
|
|
45
|
+
this._line++;
|
|
46
|
+
this._column = 0;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._column++;
|
|
50
|
+
}
|
|
51
|
+
return ch;
|
|
52
|
+
}
|
|
53
|
+
// Gets the tail of the input stream
|
|
54
|
+
getTail(start) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.substring(start)) !== null && _b !== void 0 ? _b : "";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.UemlInputStream = UemlInputStream;
|