@vc-shell/framework 1.1.44 → 1.1.45
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/CHANGELOG.md +11 -0
- package/core/plugins/modularity/loader.ts +120 -74
- package/core/services/app-bar-mobile-buttons-service.ts +1 -1
- package/dist/core/plugins/modularity/loader.d.ts.map +1 -1
- package/dist/core/services/app-bar-mobile-buttons-service.d.ts +1 -1
- package/dist/core/services/app-bar-mobile-buttons-service.d.ts.map +1 -1
- package/dist/framework.js +33347 -295
- package/dist/index.css +1 -9
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/locales/de.json +0 -84
- package/dist/locales/en.json +0 -84
- package/dist/shared/components/blade-navigation/components/vc-blade-navigation/_internal/vc-mobile-back-button.vue.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/components/vc-blade-view/vc-blade-view.d.ts +1 -1
- package/dist/shared/components/blade-navigation/components/vc-blade-view/vc-blade-view.d.ts.map +1 -1
- package/dist/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeRouteResolver.d.ts.map +1 -1
- package/dist/shared/components/change-password-button/change-password-button.vue.d.ts.map +1 -1
- package/dist/shared/components/logout-button/logout-button.vue.d.ts.map +1 -1
- package/dist/shared/components/settings-menu-item/settings-menu-item.vue.d.ts.map +1 -1
- package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts +2 -2
- package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts +6 -6
- package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/atoms/vc-hint/vc-hint.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/icons/MenuBurgerIcon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/icons/index.d.ts +0 -26
- package/dist/ui/components/atoms/vc-icon/icons/index.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-bootstrap-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-fontawesome-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-lucide-icon.vue.d.ts +0 -5
- package/dist/ui/components/atoms/vc-icon/vc-lucide-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-material-icon.vue.d.ts +0 -20
- package/dist/ui/components/atoms/vc-icon/vc-material-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-button.vue.d.ts +36 -0
- package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-button.vue.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-toolbar.vue.d.ts +17 -0
- package/dist/ui/components/molecules/vc-editor/_internal/vc-editor-toolbar.vue.d.ts.map +1 -0
- package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts +16 -2381
- package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-form/vc-form.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.vue.d.ts +1 -1
- package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts +1 -1
- package/dist/ui/components/molecules/vc-pagination/vc-pagination.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-bar/_internal/MenuSidebar.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-bar/vc-app-bar.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-desktop.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-mobile.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/vc-blade.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-gallery/_internal/vc-gallery-item/vc-gallery-item.vue.d.ts +2 -2
- package/dist/ui/components/organisms/vc-gallery/vc-gallery.vue.d.ts +2 -2
- package/dist/ui/components/organisms/vc-table/_internal/vc-table-filter/vc-table-filter.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/_internal/vc-table-header/vc-table-header.vue.d.ts.map +1 -1
- package/dist/vendor-boolbase-Cp9L0GAZ.js +25 -0
- package/dist/vendor-cheerio-HN9zIPZn.js +3135 -0
- package/dist/vendor-cheerio-select-5Ry0HvBq.js +306 -0
- package/dist/vendor-core-js-l0sNRNKZ.js +1 -0
- package/dist/vendor-css-select-DRIZ9kfZ.js +966 -0
- package/dist/vendor-css-what-DuPJ1HEF.js +448 -0
- package/dist/vendor-cypress-signalr-mock-BKdBJpdt.js +778 -0
- package/dist/vendor-date-fns-515YWkk-.js +6724 -0
- package/dist/vendor-dom-serializer-nQMsqjYW.js +286 -0
- package/dist/vendor-dom7-CJLPMwy5.js +941 -0
- package/dist/vendor-domelementtype-CjSzQey5.js +53 -0
- package/dist/vendor-domhandler-9z8cS16a.js +484 -0
- package/dist/vendor-dompurify-CRFzu7ib.js +1336 -0
- package/dist/vendor-domutils-Bc-Opz-v.js +981 -0
- package/dist/vendor-entities-Bfsx4xOQ.js +636 -0
- package/dist/vendor-floating-ui-core-wV8u8QP4.js +511 -0
- package/dist/vendor-floating-ui-dom-DDnRPs17.js +706 -0
- package/dist/vendor-floating-ui-utils-OMIFy1QU.js +296 -0
- package/dist/vendor-floating-ui-vue-D-tCDAMm.js +167 -0
- package/dist/vendor-fontsource-plus-jakarta-sans.css +1 -0
- package/dist/vendor-headlessui-vue-CY9FRgTb.js +83 -0
- package/dist/vendor-htmlparser2-B1dhFPOs.js +1426 -0
- package/dist/vendor-iconify-vue-DfRGgyNu.js +1840 -0
- package/dist/vendor-intlify-core-base-BuknsFQe.js +1876 -0
- package/dist/vendor-intlify-message-compiler-CuOQDWx1.js +1508 -0
- package/dist/vendor-intlify-shared-Cz4YRMuC.js +241 -0
- package/dist/vendor-iso-639-1-BJCk9DvE.js +819 -0
- package/dist/vendor-linkify-it-CKUf4vsc.js +830 -0
- package/dist/vendor-linkifyjs-BfyGgbCh.js +1756 -0
- package/dist/vendor-lodash-es-BySUOlwf.js +18333 -0
- package/dist/vendor-markdown-it-D-apazHa.js +6000 -0
- package/dist/vendor-markdown-it-task-lists-rxMVH6Ku.js +131 -0
- package/dist/vendor-mdurl-BNh2CCgT.js +537 -0
- package/dist/vendor-microsoft-applicationinsights-analytics-js-kG3lLg8X.js +1275 -0
- package/dist/vendor-microsoft-applicationinsights-cfgsync-js-C0uQkiQq.js +591 -0
- package/dist/vendor-microsoft-applicationinsights-channel-js-Dyd_PXA3.js +2153 -0
- package/dist/vendor-microsoft-applicationinsights-common-CfmP1_Qr.js +2470 -0
- package/dist/vendor-microsoft-applicationinsights-core-js-Cq4YSEvZ.js +6589 -0
- package/dist/vendor-microsoft-applicationinsights-dependencies-js-C56OBFr4.js +1510 -0
- package/dist/vendor-microsoft-applicationinsights-properties-js-CBJTBawx.js +761 -0
- package/dist/vendor-microsoft-applicationinsights-shims-CX8sJgar.js +70 -0
- package/dist/vendor-microsoft-applicationinsights-web-pim2ri-g.js +667 -0
- package/dist/vendor-microsoft-dynamicproto-js-CFBBUu9p.js +520 -0
- package/dist/vendor-microsoft-signalr-dUnlRsGm.js +3339 -0
- package/dist/vendor-moment-Mki5YqAR.js +5679 -0
- package/dist/vendor-nevware21-ts-async-CLMApQ9E.js +395 -0
- package/dist/vendor-nevware21-ts-utils-e8v8Jty3.js +1160 -0
- package/dist/vendor-normalize-css.css +1 -0
- package/dist/vendor-nth-check-Bx8TxtJt.js +157 -0
- package/dist/vendor-orderedmap-dGG6uMFJ.js +137 -0
- package/dist/vendor-parse5-Bt2NhSzR.js +8432 -0
- package/dist/vendor-parse5-htmlparser2-tree-adapter-BUUtKzf8.js +216 -0
- package/dist/vendor-popperjs-core-Cr2byIky.js +1790 -0
- package/dist/vendor-prettier-B4PaeWRQ.js +98 -0
- package/dist/vendor-prosemirror-commands-BH9lWGpW.js +561 -0
- package/dist/vendor-prosemirror-dropcursor-CeyPcxrA.js +146 -0
- package/dist/vendor-prosemirror-gapcursor-U8UoUJII.js +236 -0
- package/dist/vendor-prosemirror-history-BDaJkvNx.js +414 -0
- package/dist/vendor-prosemirror-keymap-BbWvIWmH.js +128 -0
- package/dist/vendor-prosemirror-markdown-gB0PXBbz.js +866 -0
- package/dist/vendor-prosemirror-model-BZu3WVcD.js +3463 -0
- package/dist/vendor-prosemirror-schema-list-Bl9NpKA7.js +158 -0
- package/dist/vendor-prosemirror-state-BvL9Pxph.js +1003 -0
- package/dist/vendor-prosemirror-tables-17qAnviK.js +2159 -0
- package/dist/vendor-prosemirror-transform-CE9VV3qg.js +2156 -0
- package/dist/vendor-prosemirror-view-CU2WTHT7.js +5811 -0
- package/dist/vendor-punycode-js-iAs5RxMf.js +441 -0
- package/dist/vendor-rope-sequence-BdXDKoGt.js +207 -0
- package/dist/vendor-semver-CVLMK-S4.js +2702 -0
- package/dist/vendor-ssr-window-s6OpKa3O.js +150 -0
- package/dist/vendor-swiper-CdiyNHVt.js +5679 -0
- package/dist/vendor-swiper.css +1 -0
- package/dist/vendor-tanstack-virtual-core-l0sNRNKZ.js +1 -0
- package/dist/vendor-tanstack-vue-virtual-l0sNRNKZ.js +1 -0
- package/dist/vendor-tippy-js-DWFe2TfK.js +1647 -0
- package/dist/vendor-tiptap-core-NfwGfaQk.js +4910 -0
- package/dist/vendor-tiptap-extension-blockquote-jmWBTtsI.js +57 -0
- package/dist/vendor-tiptap-extension-bold-p5frh4ak.js +97 -0
- package/dist/vendor-tiptap-extension-bubble-menu-KUhZSfrs.js +218 -0
- package/dist/vendor-tiptap-extension-bullet-list-COmZRoSB.js +73 -0
- package/dist/vendor-tiptap-extension-code-block-DyTARZss.js +221 -0
- package/dist/vendor-tiptap-extension-code-jVv6CXpX.js +75 -0
- package/dist/vendor-tiptap-extension-document-DssuotYs.js +13 -0
- package/dist/vendor-tiptap-extension-dropcursor-BoO0Qv91.js +26 -0
- package/dist/vendor-tiptap-extension-floating-menu-CrO8CN5w.js +165 -0
- package/dist/vendor-tiptap-extension-gapcursor-KpsWEoMD.js +30 -0
- package/dist/vendor-tiptap-extension-hard-break-ldOzhSvf.js +68 -0
- package/dist/vendor-tiptap-extension-heading-CKz2llX0.js +77 -0
- package/dist/vendor-tiptap-extension-history-DeKZ2VQ9.js +48 -0
- package/dist/vendor-tiptap-extension-horizontal-rule-CAjWRyDS.js +92 -0
- package/dist/vendor-tiptap-extension-image-ZagcEYuk.js +76 -0
- package/dist/vendor-tiptap-extension-italic-CM4xdznY.js +96 -0
- package/dist/vendor-tiptap-extension-link-Z-AMC4Ri.js +414 -0
- package/dist/vendor-tiptap-extension-list-item-BJi5QpXc.js +37 -0
- package/dist/vendor-tiptap-extension-ordered-list-C_TMrfBE.js +97 -0
- package/dist/vendor-tiptap-extension-paragraph-CQw0E0Au.js +39 -0
- package/dist/vendor-tiptap-extension-placeholder-BBNVKfa_.js +66 -0
- package/dist/vendor-tiptap-extension-strike-DUyMYX1Z.js +79 -0
- package/dist/vendor-tiptap-extension-table-cell-CoDIMPA5.js +47 -0
- package/dist/vendor-tiptap-extension-table-header-DvbGHnmw.js +47 -0
- package/dist/vendor-tiptap-extension-table-row-D1uqN5Aj.js +26 -0
- package/dist/vendor-tiptap-extension-table-tKS4MOM4.js +354 -0
- package/dist/vendor-tiptap-extension-text-DtRBhKB2.js +12 -0
- package/dist/vendor-tiptap-extension-underline-DqaSFp_P.js +50 -0
- package/dist/vendor-tiptap-markdown-7-PCADTU.js +1017 -0
- package/dist/vendor-tiptap-pm-l0sNRNKZ.js +1 -0
- package/dist/vendor-tiptap-starter-kit-CDSV_Zuu.js +88 -0
- package/dist/vendor-tiptap-vue-3-DZg2fjq_.js +268 -0
- package/dist/vendor-truncate-html-3qQY0Djo.js +196 -0
- package/dist/vendor-uc-micro-jjt6LQ65.js +23 -0
- package/dist/vendor-vee-validate-i18n-v_gHjRmD.js +154 -0
- package/dist/vendor-vee-validate-rules-DzV3VY3N.js +536 -0
- package/dist/vendor-vue-currency-input-DGAkEFBO.js +545 -0
- package/dist/vendor-vue-demi-l0sNRNKZ.js +1 -0
- package/dist/vendor-vue-devtools-api-DXYR8qBG.js +169 -0
- package/dist/vendor-vue-i18n-Co752uk3.js +1897 -0
- package/dist/vendor-vue3-application-insights-CYWFCr_J.js +119 -0
- package/dist/vendor-vue3-touch-events-BJEAiSa3.js +416 -0
- package/dist/vendor-vuepic-vue-datepicker-BSWXRSiu.js +5019 -0
- package/dist/vendor-vuepic-vue-datepicker.css +1 -0
- package/dist/vendor-vueuse-components-l1bL12mE.js +339 -0
- package/dist/vendor-vueuse-core-DGcJOmwG.js +7743 -0
- package/dist/vendor-vueuse-shared-_mOXsFuM.js +1568 -0
- package/dist/vendor-w3c-keyname-BOm2dtJm.js +121 -0
- package/package.json +22 -11
- package/shared/components/blade-navigation/components/vc-blade-navigation/_internal/vc-mobile-back-button.vue +3 -3
- package/shared/components/blade-navigation/components/vc-blade-view/vc-blade-view.ts +2 -1
- package/shared/components/blade-navigation/composables/useBladeNavigation/internal/bladeRouteResolver.ts +1 -0
- package/shared/components/change-password-button/change-password-button.vue +1 -2
- package/shared/components/logout-button/logout-button.vue +1 -2
- package/shared/components/notifications/components/notification-container/index.ts +1 -1
- package/shared/components/notifications/core/notification.ts +1 -1
- package/shared/components/settings-menu-item/settings-menu-item.vue +1 -0
- package/shared/components/sidebar/sidebar.vue +2 -2
- package/shared/modules/dynamic/pages/dynamic-blade-list.vue +2 -1
- package/ui/components/atoms/vc-hint/vc-hint.vue +2 -0
- package/ui/components/atoms/vc-icon/composables/use-icon.ts +1 -1
- package/ui/components/atoms/vc-icon/icons/MenuBurgerIcon.vue +18 -14
- package/ui/components/atoms/vc-icon/icons/index.ts +1 -27
- package/ui/components/atoms/vc-icon/vc-bootstrap-icon.vue +7 -11
- package/ui/components/atoms/vc-icon/vc-fontawesome-icon.vue +37 -31
- package/ui/components/atoms/vc-icon/vc-icon-examples.vue +1 -1
- package/ui/components/atoms/vc-icon/vc-icon.stories.ts +4 -5
- package/ui/components/atoms/vc-icon/vc-icon.vue +33 -163
- package/ui/components/atoms/vc-icon/vc-lucide-icon.vue +22 -70
- package/ui/components/atoms/vc-icon/vc-material-icon.vue +28 -59
- package/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue +2 -3
- package/ui/components/molecules/vc-editor/_internal/vc-editor-button.vue +103 -0
- package/ui/components/molecules/vc-editor/_internal/vc-editor-toolbar.vue +252 -0
- package/ui/components/molecules/vc-editor/vc-editor.stories.ts +1 -4
- package/ui/components/molecules/vc-editor/vc-editor.vue +666 -360
- package/ui/components/molecules/vc-form/vc-form.vue +7 -5
- package/ui/components/molecules/vc-input/vc-input.vue +1 -1
- package/ui/components/molecules/vc-pagination/vc-pagination.vue +4 -17
- package/ui/components/organisms/vc-app/_internal/vc-app-bar/_internal/AppBarMobileActions.vue +1 -1
- package/ui/components/organisms/vc-app/_internal/vc-app-bar/_internal/MenuSidebar.vue +1 -3
- package/ui/components/organisms/vc-app/_internal/vc-app-bar/vc-app-bar.vue +1 -4
- package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue +1 -3
- package/ui/components/organisms/vc-app/vc-app.backupsb.ts +214 -214
- package/ui/components/organisms/vc-app/vc-app.vue +3 -5
- package/ui/components/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue +3 -10
- package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/mobile/vc-blade-toolbar-mobile.vue +1 -1
- package/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-desktop.vue +2 -2
- package/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/_internal/vc-widget-container-mobile.vue +2 -2
- package/ui/components/organisms/vc-blade/vc-blade.vue +4 -5
- package/ui/components/organisms/vc-table/_internal/vc-table-filter/vc-table-filter.vue +1 -3
- package/ui/components/organisms/vc-table/_internal/vc-table-header/vc-table-header.vue +1 -2
- package/ui/components/organisms/vc-table/composables/useTableState.ts +5 -5
- package/dist/apl-B2DGVGxc.js +0 -76
- package/dist/asciiarmor-2LVJmxlE.js +0 -34
- package/dist/asn1-jKiBa2Ya.js +0 -95
- package/dist/asterisk-DS281yxp.js +0 -271
- package/dist/brainfuck-C_p9pTT8.js +0 -34
- package/dist/clike-DGTaUp48.js +0 -620
- package/dist/clojure-CCKyeQKf.js +0 -800
- package/dist/cmake-CuaCgAKt.js +0 -28
- package/dist/cobol-BlTKFDRj.js +0 -72
- package/dist/coffeescript-BVCvwO8I.js +0 -179
- package/dist/commonlisp-D_kxz07b.js +0 -75
- package/dist/crystal-D309uH6_.js +0 -217
- package/dist/css-BkF-NPzE.js +0 -1553
- package/dist/cypher-BMq4Fwjl.js +0 -68
- package/dist/d-BZcgY6La.js +0 -127
- package/dist/diff-Cg9d_RX2.js +0 -18
- package/dist/dockerfile-DIy8NleC.js +0 -194
- package/dist/dtd-CtLokQ-U.js +0 -84
- package/dist/dylan-QYeExnWK.js +0 -234
- package/dist/ebnf-DUPDuY4r.js +0 -78
- package/dist/ecl-CiXN-g_D.js +0 -121
- package/dist/eiffel-yQhjl4T1.js +0 -110
- package/dist/elm-CNT9vbN0.js +0 -108
- package/dist/erlang-CFOYdy9e.js +0 -487
- package/dist/factor-DDOC7X6P.js +0 -65
- package/dist/fcl-CPC2WYrI.js +0 -103
- package/dist/forth-BmxRyE9S.js +0 -60
- package/dist/fortran-9bvPyrOW.js +0 -442
- package/dist/gas-cpmYfFX2.js +0 -183
- package/dist/gherkin-CJuwpceU.js +0 -34
- package/dist/groovy-DZeT_VM-.js +0 -146
- package/dist/haskell-Bvt3Qq1t.js +0 -375
- package/dist/haxe-70NVW1pR.js +0 -359
- package/dist/http-D9LttvKF.js +0 -44
- package/dist/idl-B6TRFYjl.js +0 -947
- package/dist/index-4DWvmoYg.js +0 -71
- package/dist/index-52o7mJaX.js +0 -156
- package/dist/index-B0KatioT.js +0 -98
- package/dist/index-BP3W8zuk.js +0 -268
- package/dist/index-BykT5L1A.js +0 -148134
- package/dist/index-CfXo9hsG.js +0 -75
- package/dist/index-Ch37pBUt.js +0 -308
- package/dist/index-D2KGkAYT.js +0 -93
- package/dist/index-D83zQom_.js +0 -58
- package/dist/index-DuQrVLbu.js +0 -134
- package/dist/index-_fdMid5h.js +0 -288
- package/dist/index-a1wO-owY.js +0 -545
- package/dist/index-crMpNSFe.js +0 -611
- package/dist/index-dmBRpHHY.js +0 -137
- package/dist/index-kBdB14Fz.js +0 -341
- package/dist/index-uBhy41le.js +0 -249
- package/dist/index-zZrijNsr.js +0 -299
- package/dist/javascript-C2yteZeJ.js +0 -691
- package/dist/jinja2-DnB6dQmV.js +0 -154
- package/dist/julia-DpvXAuO6.js +0 -241
- package/dist/livescript-CanGTf8u.js +0 -272
- package/dist/lua-XplVlWi_.js +0 -217
- package/dist/mathematica-jaRHnSxC.js +0 -35
- package/dist/mbox-BctzC1hL.js +0 -76
- package/dist/mirc-CFBPAOaF.js +0 -72
- package/dist/mllike-BSnXJBGA.js +0 -272
- package/dist/modelica-vUgVs--1.js +0 -93
- package/dist/mscgen-Cpl0NYLN.js +0 -104
- package/dist/mumps-CQoS1kWX.js +0 -25
- package/dist/nginx-zDPm3Z74.js +0 -89
- package/dist/nsis-fePjrhq7.js +0 -62
- package/dist/ntriples-CsNjv2QF.js +0 -79
- package/dist/octave-C8PmmSRH.js +0 -143
- package/dist/oz-Ce8aN8oE.js +0 -151
- package/dist/pascal-De0D6mP7.js +0 -77
- package/dist/perl-B4bSCe1C.js +0 -915
- package/dist/pig-D24Z8EXi.js +0 -54
- package/dist/powershell-DkYVfTzP.js +0 -249
- package/dist/properties-Dn9wna3M.js +0 -26
- package/dist/protobuf-BPIjwpzm.js +0 -49
- package/dist/pug-CwAQJzGR.js +0 -248
- package/dist/puppet-nyd4dhjf.js +0 -45
- package/dist/python-BkR3uSy8.js +0 -313
- package/dist/q-DXjKs-tC.js +0 -83
- package/dist/r-LKEuhEGI.js +0 -104
- package/dist/rpm-IznJm2Xc.js +0 -57
- package/dist/ruby-CcYfvIk6.js +0 -228
- package/dist/sas-7E8yHoCW.js +0 -105
- package/dist/scheme-DjibxsNh.js +0 -124
- package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts +0 -113
- package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts.map +0 -1
- package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts +0 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts.map +0 -1
- package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts +0 -102
- package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts.map +0 -1
- package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts +0 -4
- package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts.map +0 -1
- package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts +0 -3
- package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts.map +0 -1
- package/dist/shell-C0C2sNA_.js +0 -182
- package/dist/sieve-Bwz7vjP5.js +0 -72
- package/dist/simple-mode-B0dvCdAA.js +0 -89
- package/dist/smalltalk-Bhddl2pB.js +0 -48
- package/dist/solr-BNlsLglM.js +0 -41
- package/dist/sparql-FarWu_Gb.js +0 -197
- package/dist/spreadsheet-C-cy4P5N.js +0 -49
- package/dist/sql-CfG5lQ3l.js +0 -282
- package/dist/stex-Du4h4KAU.js +0 -129
- package/dist/stylus-CAdqWld3.js +0 -250
- package/dist/swift-DSxqR9R6.js +0 -230
- package/dist/tcl-xfoLljhY.js +0 -81
- package/dist/textile-D1AWE-pc.js +0 -295
- package/dist/tiddlywiki-5wqsXtSk.js +0 -155
- package/dist/tiki-__Kn3CeS.js +0 -181
- package/dist/toml-BHiuTcfn.js +0 -49
- package/dist/troff-D2UO-fKf.js +0 -35
- package/dist/ttcn-Bsa4sfRm.js +0 -123
- package/dist/ttcn-cfg-Bac_acMi.js +0 -88
- package/dist/turtle-xwJUxoPV.js +0 -80
- package/dist/ui/components/atoms/vc-icon/icons/AppWindowIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/AppWindowIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ArrowLeftIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ArrowLeftIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ArrowRightIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ArrowRightIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/BellIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/BellIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ChevronDownIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ChevronDownIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ChevronLeftIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ChevronLeftIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ChevronRightIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ChevronRightIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ChevronUpIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ChevronUpIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/CircleDotsIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/CircleDotsIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/CrossSignIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/CrossSignIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowLeftIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowLeftIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowRightIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/DoubleArrowRightIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/FulfillmentCentersIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/FulfillmentCentersIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/GridDotsIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/GridDotsIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/LogoutIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/LogoutIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/MinusSignIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/MinusSignIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/OffersIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/OffersIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/OrdersIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/OrdersIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/PeopleIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/PeopleIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/PlusSignIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/PlusSignIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ProductsIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ProductsIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ProfileIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ProfileIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/SearchIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/SearchIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/SettingsBoltIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/SettingsBoltIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/ShoppingCardIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/ShoppingCardIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/VendorSwitchIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/VendorSwitchIcon.vue.d.ts.map +0 -1
- package/dist/ui/components/atoms/vc-icon/icons/VertDotsIcon.vue.d.ts +0 -7
- package/dist/ui/components/atoms/vc-icon/icons/VertDotsIcon.vue.d.ts.map +0 -1
- package/dist/vb-c2kQGd6-.js +0 -74
- package/dist/vbscript-1f_Dhg5H.js +0 -324
- package/dist/velocity-DJd0pTTC.js +0 -96
- package/dist/verilog-CiS1jyi5.js +0 -262
- package/dist/vhdl-T9HkrbI2.js +0 -106
- package/dist/webidl-CjfDENEo.js +0 -155
- package/dist/xquery-BUQdORAS.js +0 -422
- package/dist/yacas-C0absKBh.js +0 -73
- package/dist/z80-Pki2zAjW.js +0 -61
- package/shared/modules/dynamic/components/fields/storybook/Button.stories.ts +0 -186
- package/shared/modules/dynamic/components/fields/storybook/Card.stories.ts +0 -175
- package/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.ts +0 -185
- package/shared/modules/dynamic/components/fields/storybook/ContentField.stories.ts +0 -245
- package/shared/modules/dynamic/components/fields/storybook/EditorField.stories.ts +0 -192
- package/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.ts +0 -347
- package/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.ts +0 -239
- package/shared/modules/dynamic/components/fields/storybook/ImageField.stories.ts +0 -186
- package/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.ts +0 -281
- package/shared/modules/dynamic/components/fields/storybook/InputField.stories.ts +0 -312
- package/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.ts +0 -361
- package/shared/modules/dynamic/components/fields/storybook/RadioButtonGroup.stories.ts +0 -224
- package/shared/modules/dynamic/components/fields/storybook/RatingField.stories.ts +0 -131
- package/shared/modules/dynamic/components/fields/storybook/SelectField.stories.ts +0 -666
- package/shared/modules/dynamic/components/fields/storybook/StatusField.stories.ts +0 -202
- package/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.ts +0 -178
- package/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.ts +0 -203
- package/shared/modules/dynamic/components/fields/storybook/VideoField.stories.ts +0 -92
- package/shared/modules/dynamic/components/fields/storybook/common/args.ts +0 -130
- package/shared/modules/dynamic/components/fields/storybook/common/templates.ts +0 -8
- package/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.ts +0 -54
- package/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.ts +0 -16
- package/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.ts +0 -41
- package/ui/components/atoms/vc-icon/icons/AppWindowIcon.vue +0 -15
- package/ui/components/atoms/vc-icon/icons/ArrowLeftIcon.vue +0 -20
- package/ui/components/atoms/vc-icon/icons/ArrowRightIcon.vue +0 -13
- package/ui/components/atoms/vc-icon/icons/BellIcon.vue +0 -14
- package/ui/components/atoms/vc-icon/icons/ChevronDownIcon.vue +0 -13
- package/ui/components/atoms/vc-icon/icons/ChevronLeftIcon.vue +0 -13
- package/ui/components/atoms/vc-icon/icons/ChevronRightIcon.vue +0 -13
- package/ui/components/atoms/vc-icon/icons/ChevronUpIcon.vue +0 -13
- package/ui/components/atoms/vc-icon/icons/CircleDotsIcon.vue +0 -16
- package/ui/components/atoms/vc-icon/icons/CrossSignIcon.vue +0 -20
- package/ui/components/atoms/vc-icon/icons/DoubleArrowLeftIcon.vue +0 -14
- package/ui/components/atoms/vc-icon/icons/DoubleArrowRightIcon.vue +0 -14
- package/ui/components/atoms/vc-icon/icons/FulfillmentCentersIcon.vue +0 -27
- package/ui/components/atoms/vc-icon/icons/GridDotsIcon.vue +0 -22
- package/ui/components/atoms/vc-icon/icons/LogoutIcon.vue +0 -13
- package/ui/components/atoms/vc-icon/icons/MinusSignIcon.vue +0 -14
- package/ui/components/atoms/vc-icon/icons/OffersIcon.vue +0 -23
- package/ui/components/atoms/vc-icon/icons/OrdersIcon.vue +0 -19
- package/ui/components/atoms/vc-icon/icons/PeopleIcon.vue +0 -21
- package/ui/components/atoms/vc-icon/icons/PlusSignIcon.vue +0 -20
- package/ui/components/atoms/vc-icon/icons/ProductsIcon.vue +0 -23
- package/ui/components/atoms/vc-icon/icons/ProfileIcon.vue +0 -18
- package/ui/components/atoms/vc-icon/icons/SearchIcon.vue +0 -14
- package/ui/components/atoms/vc-icon/icons/SettingsBoltIcon.vue +0 -21
- package/ui/components/atoms/vc-icon/icons/ShoppingCardIcon.vue +0 -16
- package/ui/components/atoms/vc-icon/icons/VendorSwitchIcon.vue +0 -26
- package/ui/components/atoms/vc-icon/icons/VertDotsIcon.vue +0 -19
|
@@ -0,0 +1,1508 @@
|
|
|
1
|
+
import { l as format, d as assign, u as join, b as isString } from './vendor-intlify-shared-Cz4YRMuC.js';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* message-compiler v11.1.7
|
|
5
|
+
* (c) 2025 kazuya kawaguchi
|
|
6
|
+
* Released under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
function createPosition(line, column, offset) {
|
|
9
|
+
return { line, column, offset };
|
|
10
|
+
}
|
|
11
|
+
function createLocation(start, end, source) {
|
|
12
|
+
const loc = { start, end };
|
|
13
|
+
return loc;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const CompileErrorCodes = {
|
|
17
|
+
// tokenizer error codes
|
|
18
|
+
EXPECTED_TOKEN: 1,
|
|
19
|
+
INVALID_TOKEN_IN_PLACEHOLDER: 2,
|
|
20
|
+
UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3,
|
|
21
|
+
UNKNOWN_ESCAPE_SEQUENCE: 4,
|
|
22
|
+
INVALID_UNICODE_ESCAPE_SEQUENCE: 5,
|
|
23
|
+
UNBALANCED_CLOSING_BRACE: 6,
|
|
24
|
+
UNTERMINATED_CLOSING_BRACE: 7,
|
|
25
|
+
EMPTY_PLACEHOLDER: 8,
|
|
26
|
+
NOT_ALLOW_NEST_PLACEHOLDER: 9,
|
|
27
|
+
INVALID_LINKED_FORMAT: 10,
|
|
28
|
+
// parser error codes
|
|
29
|
+
MUST_HAVE_MESSAGES_IN_PLURAL: 11,
|
|
30
|
+
UNEXPECTED_EMPTY_LINKED_MODIFIER: 12,
|
|
31
|
+
UNEXPECTED_EMPTY_LINKED_KEY: 13,
|
|
32
|
+
UNEXPECTED_LEXICAL_ANALYSIS: 14,
|
|
33
|
+
// generator error codes
|
|
34
|
+
UNHANDLED_CODEGEN_NODE_TYPE: 15,
|
|
35
|
+
// minifier error codes
|
|
36
|
+
UNHANDLED_MINIFIER_NODE_TYPE: 16
|
|
37
|
+
};
|
|
38
|
+
// Special value for higher-order compilers to pick up the last code
|
|
39
|
+
// to avoid collision of error codes.
|
|
40
|
+
// This should always be kept as the last item.
|
|
41
|
+
const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
|
|
42
|
+
/** @internal */
|
|
43
|
+
const errorMessages = {
|
|
44
|
+
// tokenizer error messages
|
|
45
|
+
[CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`,
|
|
46
|
+
[CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`,
|
|
47
|
+
[CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`,
|
|
48
|
+
[CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`,
|
|
49
|
+
[CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`,
|
|
50
|
+
[CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`,
|
|
51
|
+
[CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`,
|
|
52
|
+
[CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`,
|
|
53
|
+
[CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`,
|
|
54
|
+
[CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`,
|
|
55
|
+
// parser error messages
|
|
56
|
+
[CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`,
|
|
57
|
+
[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`,
|
|
58
|
+
[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`,
|
|
59
|
+
[CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`,
|
|
60
|
+
// generator error messages
|
|
61
|
+
[CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`,
|
|
62
|
+
// minimizer error messages
|
|
63
|
+
[CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'`
|
|
64
|
+
};
|
|
65
|
+
function createCompileError(code, loc, options = {}) {
|
|
66
|
+
const { domain, messages, args } = options;
|
|
67
|
+
const msg = (process.env.NODE_ENV !== 'production')
|
|
68
|
+
? format((messages || errorMessages)[code] || '', ...(args || []))
|
|
69
|
+
: code;
|
|
70
|
+
const error = new SyntaxError(String(msg));
|
|
71
|
+
error.code = code;
|
|
72
|
+
if (loc) {
|
|
73
|
+
error.location = loc;
|
|
74
|
+
}
|
|
75
|
+
error.domain = domain;
|
|
76
|
+
return error;
|
|
77
|
+
}
|
|
78
|
+
/** @internal */
|
|
79
|
+
function defaultOnError(error) {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// eslint-disable-next-line no-useless-escape
|
|
84
|
+
const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/;
|
|
85
|
+
const detectHtmlTag = (source) => RE_HTML_TAG.test(source);
|
|
86
|
+
|
|
87
|
+
const CHAR_SP = ' ';
|
|
88
|
+
const CHAR_CR = '\r';
|
|
89
|
+
const CHAR_LF = '\n';
|
|
90
|
+
const CHAR_LS = String.fromCharCode(0x2028);
|
|
91
|
+
const CHAR_PS = String.fromCharCode(0x2029);
|
|
92
|
+
function createScanner(str) {
|
|
93
|
+
const _buf = str;
|
|
94
|
+
let _index = 0;
|
|
95
|
+
let _line = 1;
|
|
96
|
+
let _column = 1;
|
|
97
|
+
let _peekOffset = 0;
|
|
98
|
+
const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF;
|
|
99
|
+
const isLF = (index) => _buf[index] === CHAR_LF;
|
|
100
|
+
const isPS = (index) => _buf[index] === CHAR_PS;
|
|
101
|
+
const isLS = (index) => _buf[index] === CHAR_LS;
|
|
102
|
+
const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index);
|
|
103
|
+
const index = () => _index;
|
|
104
|
+
const line = () => _line;
|
|
105
|
+
const column = () => _column;
|
|
106
|
+
const peekOffset = () => _peekOffset;
|
|
107
|
+
const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset];
|
|
108
|
+
const currentChar = () => charAt(_index);
|
|
109
|
+
const currentPeek = () => charAt(_index + _peekOffset);
|
|
110
|
+
function next() {
|
|
111
|
+
_peekOffset = 0;
|
|
112
|
+
if (isLineEnd(_index)) {
|
|
113
|
+
_line++;
|
|
114
|
+
_column = 0;
|
|
115
|
+
}
|
|
116
|
+
if (isCRLF(_index)) {
|
|
117
|
+
_index++;
|
|
118
|
+
}
|
|
119
|
+
_index++;
|
|
120
|
+
_column++;
|
|
121
|
+
return _buf[_index];
|
|
122
|
+
}
|
|
123
|
+
function peek() {
|
|
124
|
+
if (isCRLF(_index + _peekOffset)) {
|
|
125
|
+
_peekOffset++;
|
|
126
|
+
}
|
|
127
|
+
_peekOffset++;
|
|
128
|
+
return _buf[_index + _peekOffset];
|
|
129
|
+
}
|
|
130
|
+
function reset() {
|
|
131
|
+
_index = 0;
|
|
132
|
+
_line = 1;
|
|
133
|
+
_column = 1;
|
|
134
|
+
_peekOffset = 0;
|
|
135
|
+
}
|
|
136
|
+
function resetPeek(offset = 0) {
|
|
137
|
+
_peekOffset = offset;
|
|
138
|
+
}
|
|
139
|
+
function skipToPeek() {
|
|
140
|
+
const target = _index + _peekOffset;
|
|
141
|
+
while (target !== _index) {
|
|
142
|
+
next();
|
|
143
|
+
}
|
|
144
|
+
_peekOffset = 0;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
index,
|
|
148
|
+
line,
|
|
149
|
+
column,
|
|
150
|
+
peekOffset,
|
|
151
|
+
charAt,
|
|
152
|
+
currentChar,
|
|
153
|
+
currentPeek,
|
|
154
|
+
next,
|
|
155
|
+
peek,
|
|
156
|
+
reset,
|
|
157
|
+
resetPeek,
|
|
158
|
+
skipToPeek
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const EOF = undefined;
|
|
163
|
+
const DOT = '.';
|
|
164
|
+
const LITERAL_DELIMITER = "'";
|
|
165
|
+
const ERROR_DOMAIN$3 = 'tokenizer';
|
|
166
|
+
function createTokenizer(source, options = {}) {
|
|
167
|
+
const location = options.location !== false;
|
|
168
|
+
const _scnr = createScanner(source);
|
|
169
|
+
const currentOffset = () => _scnr.index();
|
|
170
|
+
const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index());
|
|
171
|
+
const _initLoc = currentPosition();
|
|
172
|
+
const _initOffset = currentOffset();
|
|
173
|
+
const _context = {
|
|
174
|
+
currentType: 13 /* TokenTypes.EOF */,
|
|
175
|
+
offset: _initOffset,
|
|
176
|
+
startLoc: _initLoc,
|
|
177
|
+
endLoc: _initLoc,
|
|
178
|
+
lastType: 13 /* TokenTypes.EOF */,
|
|
179
|
+
lastOffset: _initOffset,
|
|
180
|
+
lastStartLoc: _initLoc,
|
|
181
|
+
lastEndLoc: _initLoc,
|
|
182
|
+
braceNest: 0,
|
|
183
|
+
inLinked: false,
|
|
184
|
+
text: ''
|
|
185
|
+
};
|
|
186
|
+
const context = () => _context;
|
|
187
|
+
const { onError } = options;
|
|
188
|
+
function emitError(code, pos, offset, ...args) {
|
|
189
|
+
const ctx = context();
|
|
190
|
+
pos.column += offset;
|
|
191
|
+
pos.offset += offset;
|
|
192
|
+
if (onError) {
|
|
193
|
+
const loc = location ? createLocation(ctx.startLoc, pos) : null;
|
|
194
|
+
const err = createCompileError(code, loc, {
|
|
195
|
+
domain: ERROR_DOMAIN$3,
|
|
196
|
+
args
|
|
197
|
+
});
|
|
198
|
+
onError(err);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function getToken(context, type, value) {
|
|
202
|
+
context.endLoc = currentPosition();
|
|
203
|
+
context.currentType = type;
|
|
204
|
+
const token = { type };
|
|
205
|
+
if (location) {
|
|
206
|
+
token.loc = createLocation(context.startLoc, context.endLoc);
|
|
207
|
+
}
|
|
208
|
+
if (value != null) {
|
|
209
|
+
token.value = value;
|
|
210
|
+
}
|
|
211
|
+
return token;
|
|
212
|
+
}
|
|
213
|
+
const getEndToken = (context) => getToken(context, 13 /* TokenTypes.EOF */);
|
|
214
|
+
function eat(scnr, ch) {
|
|
215
|
+
if (scnr.currentChar() === ch) {
|
|
216
|
+
scnr.next();
|
|
217
|
+
return ch;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch);
|
|
221
|
+
return '';
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function peekSpaces(scnr) {
|
|
225
|
+
let buf = '';
|
|
226
|
+
while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) {
|
|
227
|
+
buf += scnr.currentPeek();
|
|
228
|
+
scnr.peek();
|
|
229
|
+
}
|
|
230
|
+
return buf;
|
|
231
|
+
}
|
|
232
|
+
function skipSpaces(scnr) {
|
|
233
|
+
const buf = peekSpaces(scnr);
|
|
234
|
+
scnr.skipToPeek();
|
|
235
|
+
return buf;
|
|
236
|
+
}
|
|
237
|
+
function isIdentifierStart(ch) {
|
|
238
|
+
if (ch === EOF) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
const cc = ch.charCodeAt(0);
|
|
242
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
243
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
244
|
+
cc === 95 // _
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function isNumberStart(ch) {
|
|
248
|
+
if (ch === EOF) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
const cc = ch.charCodeAt(0);
|
|
252
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
253
|
+
}
|
|
254
|
+
function isNamedIdentifierStart(scnr, context) {
|
|
255
|
+
const { currentType } = context;
|
|
256
|
+
if (currentType !== 2 /* TokenTypes.BraceLeft */) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
peekSpaces(scnr);
|
|
260
|
+
const ret = isIdentifierStart(scnr.currentPeek());
|
|
261
|
+
scnr.resetPeek();
|
|
262
|
+
return ret;
|
|
263
|
+
}
|
|
264
|
+
function isListIdentifierStart(scnr, context) {
|
|
265
|
+
const { currentType } = context;
|
|
266
|
+
if (currentType !== 2 /* TokenTypes.BraceLeft */) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
peekSpaces(scnr);
|
|
270
|
+
const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek();
|
|
271
|
+
const ret = isNumberStart(ch);
|
|
272
|
+
scnr.resetPeek();
|
|
273
|
+
return ret;
|
|
274
|
+
}
|
|
275
|
+
function isLiteralStart(scnr, context) {
|
|
276
|
+
const { currentType } = context;
|
|
277
|
+
if (currentType !== 2 /* TokenTypes.BraceLeft */) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
peekSpaces(scnr);
|
|
281
|
+
const ret = scnr.currentPeek() === LITERAL_DELIMITER;
|
|
282
|
+
scnr.resetPeek();
|
|
283
|
+
return ret;
|
|
284
|
+
}
|
|
285
|
+
function isLinkedDotStart(scnr, context) {
|
|
286
|
+
const { currentType } = context;
|
|
287
|
+
if (currentType !== 7 /* TokenTypes.LinkedAlias */) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
peekSpaces(scnr);
|
|
291
|
+
const ret = scnr.currentPeek() === "." /* TokenChars.LinkedDot */;
|
|
292
|
+
scnr.resetPeek();
|
|
293
|
+
return ret;
|
|
294
|
+
}
|
|
295
|
+
function isLinkedModifierStart(scnr, context) {
|
|
296
|
+
const { currentType } = context;
|
|
297
|
+
if (currentType !== 8 /* TokenTypes.LinkedDot */) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
peekSpaces(scnr);
|
|
301
|
+
const ret = isIdentifierStart(scnr.currentPeek());
|
|
302
|
+
scnr.resetPeek();
|
|
303
|
+
return ret;
|
|
304
|
+
}
|
|
305
|
+
function isLinkedDelimiterStart(scnr, context) {
|
|
306
|
+
const { currentType } = context;
|
|
307
|
+
if (!(currentType === 7 /* TokenTypes.LinkedAlias */ ||
|
|
308
|
+
currentType === 11 /* TokenTypes.LinkedModifier */)) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
peekSpaces(scnr);
|
|
312
|
+
const ret = scnr.currentPeek() === ":" /* TokenChars.LinkedDelimiter */;
|
|
313
|
+
scnr.resetPeek();
|
|
314
|
+
return ret;
|
|
315
|
+
}
|
|
316
|
+
function isLinkedReferStart(scnr, context) {
|
|
317
|
+
const { currentType } = context;
|
|
318
|
+
if (currentType !== 9 /* TokenTypes.LinkedDelimiter */) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
const fn = () => {
|
|
322
|
+
const ch = scnr.currentPeek();
|
|
323
|
+
if (ch === "{" /* TokenChars.BraceLeft */) {
|
|
324
|
+
return isIdentifierStart(scnr.peek());
|
|
325
|
+
}
|
|
326
|
+
else if (ch === "@" /* TokenChars.LinkedAlias */ ||
|
|
327
|
+
ch === "|" /* TokenChars.Pipe */ ||
|
|
328
|
+
ch === ":" /* TokenChars.LinkedDelimiter */ ||
|
|
329
|
+
ch === "." /* TokenChars.LinkedDot */ ||
|
|
330
|
+
ch === CHAR_SP ||
|
|
331
|
+
!ch) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
else if (ch === CHAR_LF) {
|
|
335
|
+
scnr.peek();
|
|
336
|
+
return fn();
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
// other characters
|
|
340
|
+
return isTextStart(scnr, false);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
const ret = fn();
|
|
344
|
+
scnr.resetPeek();
|
|
345
|
+
return ret;
|
|
346
|
+
}
|
|
347
|
+
function isPluralStart(scnr) {
|
|
348
|
+
peekSpaces(scnr);
|
|
349
|
+
const ret = scnr.currentPeek() === "|" /* TokenChars.Pipe */;
|
|
350
|
+
scnr.resetPeek();
|
|
351
|
+
return ret;
|
|
352
|
+
}
|
|
353
|
+
function isTextStart(scnr, reset = true) {
|
|
354
|
+
const fn = (hasSpace = false, prev = '') => {
|
|
355
|
+
const ch = scnr.currentPeek();
|
|
356
|
+
if (ch === "{" /* TokenChars.BraceLeft */) {
|
|
357
|
+
return hasSpace;
|
|
358
|
+
}
|
|
359
|
+
else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) {
|
|
360
|
+
return hasSpace;
|
|
361
|
+
}
|
|
362
|
+
else if (ch === "|" /* TokenChars.Pipe */) {
|
|
363
|
+
return !(prev === CHAR_SP || prev === CHAR_LF);
|
|
364
|
+
}
|
|
365
|
+
else if (ch === CHAR_SP) {
|
|
366
|
+
scnr.peek();
|
|
367
|
+
return fn(true, CHAR_SP);
|
|
368
|
+
}
|
|
369
|
+
else if (ch === CHAR_LF) {
|
|
370
|
+
scnr.peek();
|
|
371
|
+
return fn(true, CHAR_LF);
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
const ret = fn();
|
|
378
|
+
reset && scnr.resetPeek();
|
|
379
|
+
return ret;
|
|
380
|
+
}
|
|
381
|
+
function takeChar(scnr, fn) {
|
|
382
|
+
const ch = scnr.currentChar();
|
|
383
|
+
if (ch === EOF) {
|
|
384
|
+
return EOF;
|
|
385
|
+
}
|
|
386
|
+
if (fn(ch)) {
|
|
387
|
+
scnr.next();
|
|
388
|
+
return ch;
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
function isIdentifier(ch) {
|
|
393
|
+
const cc = ch.charCodeAt(0);
|
|
394
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
395
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
396
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
397
|
+
cc === 95 || // _
|
|
398
|
+
cc === 36 // $
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
function takeIdentifierChar(scnr) {
|
|
402
|
+
return takeChar(scnr, isIdentifier);
|
|
403
|
+
}
|
|
404
|
+
function isNamedIdentifier(ch) {
|
|
405
|
+
const cc = ch.charCodeAt(0);
|
|
406
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
407
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
408
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
409
|
+
cc === 95 || // _
|
|
410
|
+
cc === 36 || // $
|
|
411
|
+
cc === 45 // -
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
function takeNamedIdentifierChar(scnr) {
|
|
415
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
416
|
+
}
|
|
417
|
+
function isDigit(ch) {
|
|
418
|
+
const cc = ch.charCodeAt(0);
|
|
419
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
420
|
+
}
|
|
421
|
+
function takeDigit(scnr) {
|
|
422
|
+
return takeChar(scnr, isDigit);
|
|
423
|
+
}
|
|
424
|
+
function isHexDigit(ch) {
|
|
425
|
+
const cc = ch.charCodeAt(0);
|
|
426
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
427
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
428
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
429
|
+
}
|
|
430
|
+
function takeHexDigit(scnr) {
|
|
431
|
+
return takeChar(scnr, isHexDigit);
|
|
432
|
+
}
|
|
433
|
+
function getDigits(scnr) {
|
|
434
|
+
let ch = '';
|
|
435
|
+
let num = '';
|
|
436
|
+
while ((ch = takeDigit(scnr))) {
|
|
437
|
+
num += ch;
|
|
438
|
+
}
|
|
439
|
+
return num;
|
|
440
|
+
}
|
|
441
|
+
function readText(scnr) {
|
|
442
|
+
let buf = '';
|
|
443
|
+
while (true) {
|
|
444
|
+
const ch = scnr.currentChar();
|
|
445
|
+
if (ch === "{" /* TokenChars.BraceLeft */ ||
|
|
446
|
+
ch === "}" /* TokenChars.BraceRight */ ||
|
|
447
|
+
ch === "@" /* TokenChars.LinkedAlias */ ||
|
|
448
|
+
ch === "|" /* TokenChars.Pipe */ ||
|
|
449
|
+
!ch) {
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
else if (ch === CHAR_SP || ch === CHAR_LF) {
|
|
453
|
+
if (isTextStart(scnr)) {
|
|
454
|
+
buf += ch;
|
|
455
|
+
scnr.next();
|
|
456
|
+
}
|
|
457
|
+
else if (isPluralStart(scnr)) {
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
buf += ch;
|
|
462
|
+
scnr.next();
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
buf += ch;
|
|
467
|
+
scnr.next();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return buf;
|
|
471
|
+
}
|
|
472
|
+
function readNamedIdentifier(scnr) {
|
|
473
|
+
skipSpaces(scnr);
|
|
474
|
+
let ch = '';
|
|
475
|
+
let name = '';
|
|
476
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
477
|
+
name += ch;
|
|
478
|
+
}
|
|
479
|
+
if (scnr.currentChar() === EOF) {
|
|
480
|
+
emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
|
|
481
|
+
}
|
|
482
|
+
return name;
|
|
483
|
+
}
|
|
484
|
+
function readListIdentifier(scnr) {
|
|
485
|
+
skipSpaces(scnr);
|
|
486
|
+
let value = '';
|
|
487
|
+
if (scnr.currentChar() === '-') {
|
|
488
|
+
scnr.next();
|
|
489
|
+
value += `-${getDigits(scnr)}`;
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
value += getDigits(scnr);
|
|
493
|
+
}
|
|
494
|
+
if (scnr.currentChar() === EOF) {
|
|
495
|
+
emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
|
|
496
|
+
}
|
|
497
|
+
return value;
|
|
498
|
+
}
|
|
499
|
+
function isLiteral(ch) {
|
|
500
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
501
|
+
}
|
|
502
|
+
function readLiteral(scnr) {
|
|
503
|
+
skipSpaces(scnr);
|
|
504
|
+
// eslint-disable-next-line no-useless-escape
|
|
505
|
+
eat(scnr, `\'`);
|
|
506
|
+
let ch = '';
|
|
507
|
+
let literal = '';
|
|
508
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
509
|
+
if (ch === '\\') {
|
|
510
|
+
literal += readEscapeSequence(scnr);
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
literal += ch;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
const current = scnr.currentChar();
|
|
517
|
+
if (current === CHAR_LF || current === EOF) {
|
|
518
|
+
emitError(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, currentPosition(), 0);
|
|
519
|
+
// TODO: Is it correct really?
|
|
520
|
+
if (current === CHAR_LF) {
|
|
521
|
+
scnr.next();
|
|
522
|
+
// eslint-disable-next-line no-useless-escape
|
|
523
|
+
eat(scnr, `\'`);
|
|
524
|
+
}
|
|
525
|
+
return literal;
|
|
526
|
+
}
|
|
527
|
+
// eslint-disable-next-line no-useless-escape
|
|
528
|
+
eat(scnr, `\'`);
|
|
529
|
+
return literal;
|
|
530
|
+
}
|
|
531
|
+
function readEscapeSequence(scnr) {
|
|
532
|
+
const ch = scnr.currentChar();
|
|
533
|
+
switch (ch) {
|
|
534
|
+
case '\\':
|
|
535
|
+
case `\'`: // eslint-disable-line no-useless-escape
|
|
536
|
+
scnr.next();
|
|
537
|
+
return `\\${ch}`;
|
|
538
|
+
case 'u':
|
|
539
|
+
return readUnicodeEscapeSequence(scnr, ch, 4);
|
|
540
|
+
case 'U':
|
|
541
|
+
return readUnicodeEscapeSequence(scnr, ch, 6);
|
|
542
|
+
default:
|
|
543
|
+
emitError(CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE, currentPosition(), 0, ch);
|
|
544
|
+
return '';
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function readUnicodeEscapeSequence(scnr, unicode, digits) {
|
|
548
|
+
eat(scnr, unicode);
|
|
549
|
+
let sequence = '';
|
|
550
|
+
for (let i = 0; i < digits; i++) {
|
|
551
|
+
const ch = takeHexDigit(scnr);
|
|
552
|
+
if (!ch) {
|
|
553
|
+
emitError(CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`);
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
sequence += ch;
|
|
557
|
+
}
|
|
558
|
+
return `\\${unicode}${sequence}`;
|
|
559
|
+
}
|
|
560
|
+
function isInvalidIdentifier(ch) {
|
|
561
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
562
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
563
|
+
ch !== CHAR_SP &&
|
|
564
|
+
ch !== CHAR_LF);
|
|
565
|
+
}
|
|
566
|
+
function readInvalidIdentifier(scnr) {
|
|
567
|
+
skipSpaces(scnr);
|
|
568
|
+
let ch = '';
|
|
569
|
+
let identifiers = '';
|
|
570
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
571
|
+
identifiers += ch;
|
|
572
|
+
}
|
|
573
|
+
return identifiers;
|
|
574
|
+
}
|
|
575
|
+
function readLinkedModifier(scnr) {
|
|
576
|
+
let ch = '';
|
|
577
|
+
let name = '';
|
|
578
|
+
while ((ch = takeIdentifierChar(scnr))) {
|
|
579
|
+
name += ch;
|
|
580
|
+
}
|
|
581
|
+
return name;
|
|
582
|
+
}
|
|
583
|
+
function readLinkedRefer(scnr) {
|
|
584
|
+
const fn = (buf) => {
|
|
585
|
+
const ch = scnr.currentChar();
|
|
586
|
+
if (ch === "{" /* TokenChars.BraceLeft */ ||
|
|
587
|
+
ch === "@" /* TokenChars.LinkedAlias */ ||
|
|
588
|
+
ch === "|" /* TokenChars.Pipe */ ||
|
|
589
|
+
ch === "(" /* TokenChars.ParenLeft */ ||
|
|
590
|
+
ch === ")" /* TokenChars.ParenRight */ ||
|
|
591
|
+
!ch) {
|
|
592
|
+
return buf;
|
|
593
|
+
}
|
|
594
|
+
else if (ch === CHAR_SP) {
|
|
595
|
+
return buf;
|
|
596
|
+
}
|
|
597
|
+
else if (ch === CHAR_LF || ch === DOT) {
|
|
598
|
+
buf += ch;
|
|
599
|
+
scnr.next();
|
|
600
|
+
return fn(buf);
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
buf += ch;
|
|
604
|
+
scnr.next();
|
|
605
|
+
return fn(buf);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
return fn('');
|
|
609
|
+
}
|
|
610
|
+
function readPlural(scnr) {
|
|
611
|
+
skipSpaces(scnr);
|
|
612
|
+
const plural = eat(scnr, "|" /* TokenChars.Pipe */);
|
|
613
|
+
skipSpaces(scnr);
|
|
614
|
+
return plural;
|
|
615
|
+
}
|
|
616
|
+
// TODO: We need refactoring of token parsing ...
|
|
617
|
+
function readTokenInPlaceholder(scnr, context) {
|
|
618
|
+
let token = null;
|
|
619
|
+
const ch = scnr.currentChar();
|
|
620
|
+
switch (ch) {
|
|
621
|
+
case "{" /* TokenChars.BraceLeft */:
|
|
622
|
+
if (context.braceNest >= 1) {
|
|
623
|
+
emitError(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER, currentPosition(), 0);
|
|
624
|
+
}
|
|
625
|
+
scnr.next();
|
|
626
|
+
token = getToken(context, 2 /* TokenTypes.BraceLeft */, "{" /* TokenChars.BraceLeft */);
|
|
627
|
+
skipSpaces(scnr);
|
|
628
|
+
context.braceNest++;
|
|
629
|
+
return token;
|
|
630
|
+
case "}" /* TokenChars.BraceRight */:
|
|
631
|
+
if (context.braceNest > 0 &&
|
|
632
|
+
context.currentType === 2 /* TokenTypes.BraceLeft */) {
|
|
633
|
+
emitError(CompileErrorCodes.EMPTY_PLACEHOLDER, currentPosition(), 0);
|
|
634
|
+
}
|
|
635
|
+
scnr.next();
|
|
636
|
+
token = getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */);
|
|
637
|
+
context.braceNest--;
|
|
638
|
+
context.braceNest > 0 && skipSpaces(scnr);
|
|
639
|
+
if (context.inLinked && context.braceNest === 0) {
|
|
640
|
+
context.inLinked = false;
|
|
641
|
+
}
|
|
642
|
+
return token;
|
|
643
|
+
case "@" /* TokenChars.LinkedAlias */:
|
|
644
|
+
if (context.braceNest > 0) {
|
|
645
|
+
emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
|
|
646
|
+
}
|
|
647
|
+
token = readTokenInLinked(scnr, context) || getEndToken(context);
|
|
648
|
+
context.braceNest = 0;
|
|
649
|
+
return token;
|
|
650
|
+
default: {
|
|
651
|
+
let validNamedIdentifier = true;
|
|
652
|
+
let validListIdentifier = true;
|
|
653
|
+
let validLiteral = true;
|
|
654
|
+
if (isPluralStart(scnr)) {
|
|
655
|
+
if (context.braceNest > 0) {
|
|
656
|
+
emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
|
|
657
|
+
}
|
|
658
|
+
token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr));
|
|
659
|
+
// reset
|
|
660
|
+
context.braceNest = 0;
|
|
661
|
+
context.inLinked = false;
|
|
662
|
+
return token;
|
|
663
|
+
}
|
|
664
|
+
if (context.braceNest > 0 &&
|
|
665
|
+
(context.currentType === 4 /* TokenTypes.Named */ ||
|
|
666
|
+
context.currentType === 5 /* TokenTypes.List */ ||
|
|
667
|
+
context.currentType === 6 /* TokenTypes.Literal */)) {
|
|
668
|
+
emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
|
|
669
|
+
context.braceNest = 0;
|
|
670
|
+
return readToken(scnr, context);
|
|
671
|
+
}
|
|
672
|
+
if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) {
|
|
673
|
+
token = getToken(context, 4 /* TokenTypes.Named */, readNamedIdentifier(scnr));
|
|
674
|
+
skipSpaces(scnr);
|
|
675
|
+
return token;
|
|
676
|
+
}
|
|
677
|
+
if ((validListIdentifier = isListIdentifierStart(scnr, context))) {
|
|
678
|
+
token = getToken(context, 5 /* TokenTypes.List */, readListIdentifier(scnr));
|
|
679
|
+
skipSpaces(scnr);
|
|
680
|
+
return token;
|
|
681
|
+
}
|
|
682
|
+
if ((validLiteral = isLiteralStart(scnr, context))) {
|
|
683
|
+
token = getToken(context, 6 /* TokenTypes.Literal */, readLiteral(scnr));
|
|
684
|
+
skipSpaces(scnr);
|
|
685
|
+
return token;
|
|
686
|
+
}
|
|
687
|
+
if (!validNamedIdentifier && !validListIdentifier && !validLiteral) {
|
|
688
|
+
// TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ...
|
|
689
|
+
token = getToken(context, 12 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr));
|
|
690
|
+
emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value);
|
|
691
|
+
skipSpaces(scnr);
|
|
692
|
+
return token;
|
|
693
|
+
}
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return token;
|
|
698
|
+
}
|
|
699
|
+
// TODO: We need refactoring of token parsing ...
|
|
700
|
+
function readTokenInLinked(scnr, context) {
|
|
701
|
+
const { currentType } = context;
|
|
702
|
+
let token = null;
|
|
703
|
+
const ch = scnr.currentChar();
|
|
704
|
+
if ((currentType === 7 /* TokenTypes.LinkedAlias */ ||
|
|
705
|
+
currentType === 8 /* TokenTypes.LinkedDot */ ||
|
|
706
|
+
currentType === 11 /* TokenTypes.LinkedModifier */ ||
|
|
707
|
+
currentType === 9 /* TokenTypes.LinkedDelimiter */) &&
|
|
708
|
+
(ch === CHAR_LF || ch === CHAR_SP)) {
|
|
709
|
+
emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
|
|
710
|
+
}
|
|
711
|
+
switch (ch) {
|
|
712
|
+
case "@" /* TokenChars.LinkedAlias */:
|
|
713
|
+
scnr.next();
|
|
714
|
+
token = getToken(context, 7 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */);
|
|
715
|
+
context.inLinked = true;
|
|
716
|
+
return token;
|
|
717
|
+
case "." /* TokenChars.LinkedDot */:
|
|
718
|
+
skipSpaces(scnr);
|
|
719
|
+
scnr.next();
|
|
720
|
+
return getToken(context, 8 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */);
|
|
721
|
+
case ":" /* TokenChars.LinkedDelimiter */:
|
|
722
|
+
skipSpaces(scnr);
|
|
723
|
+
scnr.next();
|
|
724
|
+
return getToken(context, 9 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */);
|
|
725
|
+
default:
|
|
726
|
+
if (isPluralStart(scnr)) {
|
|
727
|
+
token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr));
|
|
728
|
+
// reset
|
|
729
|
+
context.braceNest = 0;
|
|
730
|
+
context.inLinked = false;
|
|
731
|
+
return token;
|
|
732
|
+
}
|
|
733
|
+
if (isLinkedDotStart(scnr, context) ||
|
|
734
|
+
isLinkedDelimiterStart(scnr, context)) {
|
|
735
|
+
skipSpaces(scnr);
|
|
736
|
+
return readTokenInLinked(scnr, context);
|
|
737
|
+
}
|
|
738
|
+
if (isLinkedModifierStart(scnr, context)) {
|
|
739
|
+
skipSpaces(scnr);
|
|
740
|
+
return getToken(context, 11 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr));
|
|
741
|
+
}
|
|
742
|
+
if (isLinkedReferStart(scnr, context)) {
|
|
743
|
+
skipSpaces(scnr);
|
|
744
|
+
if (ch === "{" /* TokenChars.BraceLeft */) {
|
|
745
|
+
// scan the placeholder
|
|
746
|
+
return readTokenInPlaceholder(scnr, context) || token;
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
return getToken(context, 10 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr));
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
if (currentType === 7 /* TokenTypes.LinkedAlias */) {
|
|
753
|
+
emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
|
|
754
|
+
}
|
|
755
|
+
context.braceNest = 0;
|
|
756
|
+
context.inLinked = false;
|
|
757
|
+
return readToken(scnr, context);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
// TODO: We need refactoring of token parsing ...
|
|
761
|
+
function readToken(scnr, context) {
|
|
762
|
+
let token = { type: 13 /* TokenTypes.EOF */ };
|
|
763
|
+
if (context.braceNest > 0) {
|
|
764
|
+
return readTokenInPlaceholder(scnr, context) || getEndToken(context);
|
|
765
|
+
}
|
|
766
|
+
if (context.inLinked) {
|
|
767
|
+
return readTokenInLinked(scnr, context) || getEndToken(context);
|
|
768
|
+
}
|
|
769
|
+
const ch = scnr.currentChar();
|
|
770
|
+
switch (ch) {
|
|
771
|
+
case "{" /* TokenChars.BraceLeft */:
|
|
772
|
+
return readTokenInPlaceholder(scnr, context) || getEndToken(context);
|
|
773
|
+
case "}" /* TokenChars.BraceRight */:
|
|
774
|
+
emitError(CompileErrorCodes.UNBALANCED_CLOSING_BRACE, currentPosition(), 0);
|
|
775
|
+
scnr.next();
|
|
776
|
+
return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */);
|
|
777
|
+
case "@" /* TokenChars.LinkedAlias */:
|
|
778
|
+
return readTokenInLinked(scnr, context) || getEndToken(context);
|
|
779
|
+
default: {
|
|
780
|
+
if (isPluralStart(scnr)) {
|
|
781
|
+
token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr));
|
|
782
|
+
// reset
|
|
783
|
+
context.braceNest = 0;
|
|
784
|
+
context.inLinked = false;
|
|
785
|
+
return token;
|
|
786
|
+
}
|
|
787
|
+
if (isTextStart(scnr)) {
|
|
788
|
+
return getToken(context, 0 /* TokenTypes.Text */, readText(scnr));
|
|
789
|
+
}
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return token;
|
|
794
|
+
}
|
|
795
|
+
function nextToken() {
|
|
796
|
+
const { currentType, offset, startLoc, endLoc } = _context;
|
|
797
|
+
_context.lastType = currentType;
|
|
798
|
+
_context.lastOffset = offset;
|
|
799
|
+
_context.lastStartLoc = startLoc;
|
|
800
|
+
_context.lastEndLoc = endLoc;
|
|
801
|
+
_context.offset = currentOffset();
|
|
802
|
+
_context.startLoc = currentPosition();
|
|
803
|
+
if (_scnr.currentChar() === EOF) {
|
|
804
|
+
return getToken(_context, 13 /* TokenTypes.EOF */);
|
|
805
|
+
}
|
|
806
|
+
return readToken(_scnr, _context);
|
|
807
|
+
}
|
|
808
|
+
return {
|
|
809
|
+
nextToken,
|
|
810
|
+
currentOffset,
|
|
811
|
+
currentPosition,
|
|
812
|
+
context
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const ERROR_DOMAIN$2 = 'parser';
|
|
817
|
+
// Backslash backslash, backslash quote, uHHHH, UHHHHHH.
|
|
818
|
+
const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;
|
|
819
|
+
function fromEscapeSequence(match, codePoint4, codePoint6) {
|
|
820
|
+
switch (match) {
|
|
821
|
+
case `\\\\`:
|
|
822
|
+
return `\\`;
|
|
823
|
+
// eslint-disable-next-line no-useless-escape
|
|
824
|
+
case `\\\'`:
|
|
825
|
+
// eslint-disable-next-line no-useless-escape
|
|
826
|
+
return `\'`;
|
|
827
|
+
default: {
|
|
828
|
+
const codePoint = parseInt(codePoint4 || codePoint6, 16);
|
|
829
|
+
if (codePoint <= 0xd7ff || codePoint >= 0xe000) {
|
|
830
|
+
return String.fromCodePoint(codePoint);
|
|
831
|
+
}
|
|
832
|
+
// invalid ...
|
|
833
|
+
// Replace them with U+FFFD REPLACEMENT CHARACTER.
|
|
834
|
+
return '�';
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function createParser(options = {}) {
|
|
839
|
+
const location = options.location !== false;
|
|
840
|
+
const { onError } = options;
|
|
841
|
+
function emitError(tokenzer, code, start, offset, ...args) {
|
|
842
|
+
const end = tokenzer.currentPosition();
|
|
843
|
+
end.offset += offset;
|
|
844
|
+
end.column += offset;
|
|
845
|
+
if (onError) {
|
|
846
|
+
const loc = location ? createLocation(start, end) : null;
|
|
847
|
+
const err = createCompileError(code, loc, {
|
|
848
|
+
domain: ERROR_DOMAIN$2,
|
|
849
|
+
args
|
|
850
|
+
});
|
|
851
|
+
onError(err);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
function startNode(type, offset, loc) {
|
|
855
|
+
const node = { type };
|
|
856
|
+
if (location) {
|
|
857
|
+
node.start = offset;
|
|
858
|
+
node.end = offset;
|
|
859
|
+
node.loc = { start: loc, end: loc };
|
|
860
|
+
}
|
|
861
|
+
return node;
|
|
862
|
+
}
|
|
863
|
+
function endNode(node, offset, pos, type) {
|
|
864
|
+
if (location) {
|
|
865
|
+
node.end = offset;
|
|
866
|
+
if (node.loc) {
|
|
867
|
+
node.loc.end = pos;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
function parseText(tokenizer, value) {
|
|
872
|
+
const context = tokenizer.context();
|
|
873
|
+
const node = startNode(3 /* NodeTypes.Text */, context.offset, context.startLoc);
|
|
874
|
+
node.value = value;
|
|
875
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
876
|
+
return node;
|
|
877
|
+
}
|
|
878
|
+
function parseList(tokenizer, index) {
|
|
879
|
+
const context = tokenizer.context();
|
|
880
|
+
const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
|
|
881
|
+
const node = startNode(5 /* NodeTypes.List */, offset, loc);
|
|
882
|
+
node.index = parseInt(index, 10);
|
|
883
|
+
tokenizer.nextToken(); // skip brach right
|
|
884
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
885
|
+
return node;
|
|
886
|
+
}
|
|
887
|
+
function parseNamed(tokenizer, key) {
|
|
888
|
+
const context = tokenizer.context();
|
|
889
|
+
const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
|
|
890
|
+
const node = startNode(4 /* NodeTypes.Named */, offset, loc);
|
|
891
|
+
node.key = key;
|
|
892
|
+
tokenizer.nextToken(); // skip brach right
|
|
893
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
894
|
+
return node;
|
|
895
|
+
}
|
|
896
|
+
function parseLiteral(tokenizer, value) {
|
|
897
|
+
const context = tokenizer.context();
|
|
898
|
+
const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
|
|
899
|
+
const node = startNode(9 /* NodeTypes.Literal */, offset, loc);
|
|
900
|
+
node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence);
|
|
901
|
+
tokenizer.nextToken(); // skip brach right
|
|
902
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
903
|
+
return node;
|
|
904
|
+
}
|
|
905
|
+
function parseLinkedModifier(tokenizer) {
|
|
906
|
+
const token = tokenizer.nextToken();
|
|
907
|
+
const context = tokenizer.context();
|
|
908
|
+
const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc
|
|
909
|
+
const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc);
|
|
910
|
+
if (token.type !== 11 /* TokenTypes.LinkedModifier */) {
|
|
911
|
+
// empty modifier
|
|
912
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0);
|
|
913
|
+
node.value = '';
|
|
914
|
+
endNode(node, offset, loc);
|
|
915
|
+
return {
|
|
916
|
+
nextConsumeToken: token,
|
|
917
|
+
node
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
// check token
|
|
921
|
+
if (token.value == null) {
|
|
922
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
923
|
+
}
|
|
924
|
+
node.value = token.value || '';
|
|
925
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
926
|
+
return {
|
|
927
|
+
node
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function parseLinkedKey(tokenizer, value) {
|
|
931
|
+
const context = tokenizer.context();
|
|
932
|
+
const node = startNode(7 /* NodeTypes.LinkedKey */, context.offset, context.startLoc);
|
|
933
|
+
node.value = value;
|
|
934
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
935
|
+
return node;
|
|
936
|
+
}
|
|
937
|
+
function parseLinked(tokenizer) {
|
|
938
|
+
const context = tokenizer.context();
|
|
939
|
+
const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc);
|
|
940
|
+
let token = tokenizer.nextToken();
|
|
941
|
+
if (token.type === 8 /* TokenTypes.LinkedDot */) {
|
|
942
|
+
const parsed = parseLinkedModifier(tokenizer);
|
|
943
|
+
linkedNode.modifier = parsed.node;
|
|
944
|
+
token = parsed.nextConsumeToken || tokenizer.nextToken();
|
|
945
|
+
}
|
|
946
|
+
// asset check token
|
|
947
|
+
if (token.type !== 9 /* TokenTypes.LinkedDelimiter */) {
|
|
948
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
949
|
+
}
|
|
950
|
+
token = tokenizer.nextToken();
|
|
951
|
+
// skip brace left
|
|
952
|
+
if (token.type === 2 /* TokenTypes.BraceLeft */) {
|
|
953
|
+
token = tokenizer.nextToken();
|
|
954
|
+
}
|
|
955
|
+
switch (token.type) {
|
|
956
|
+
case 10 /* TokenTypes.LinkedKey */:
|
|
957
|
+
if (token.value == null) {
|
|
958
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
959
|
+
}
|
|
960
|
+
linkedNode.key = parseLinkedKey(tokenizer, token.value || '');
|
|
961
|
+
break;
|
|
962
|
+
case 4 /* TokenTypes.Named */:
|
|
963
|
+
if (token.value == null) {
|
|
964
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
965
|
+
}
|
|
966
|
+
linkedNode.key = parseNamed(tokenizer, token.value || '');
|
|
967
|
+
break;
|
|
968
|
+
case 5 /* TokenTypes.List */:
|
|
969
|
+
if (token.value == null) {
|
|
970
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
971
|
+
}
|
|
972
|
+
linkedNode.key = parseList(tokenizer, token.value || '');
|
|
973
|
+
break;
|
|
974
|
+
case 6 /* TokenTypes.Literal */:
|
|
975
|
+
if (token.value == null) {
|
|
976
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
977
|
+
}
|
|
978
|
+
linkedNode.key = parseLiteral(tokenizer, token.value || '');
|
|
979
|
+
break;
|
|
980
|
+
default: {
|
|
981
|
+
// empty key
|
|
982
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0);
|
|
983
|
+
const nextContext = tokenizer.context();
|
|
984
|
+
const emptyLinkedKeyNode = startNode(7 /* NodeTypes.LinkedKey */, nextContext.offset, nextContext.startLoc);
|
|
985
|
+
emptyLinkedKeyNode.value = '';
|
|
986
|
+
endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc);
|
|
987
|
+
linkedNode.key = emptyLinkedKeyNode;
|
|
988
|
+
endNode(linkedNode, nextContext.offset, nextContext.startLoc);
|
|
989
|
+
return {
|
|
990
|
+
nextConsumeToken: token,
|
|
991
|
+
node: linkedNode
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
996
|
+
return {
|
|
997
|
+
node: linkedNode
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
function parseMessage(tokenizer) {
|
|
1001
|
+
const context = tokenizer.context();
|
|
1002
|
+
const startOffset = context.currentType === 1 /* TokenTypes.Pipe */
|
|
1003
|
+
? tokenizer.currentOffset()
|
|
1004
|
+
: context.offset;
|
|
1005
|
+
const startLoc = context.currentType === 1 /* TokenTypes.Pipe */
|
|
1006
|
+
? context.endLoc
|
|
1007
|
+
: context.startLoc;
|
|
1008
|
+
const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc);
|
|
1009
|
+
node.items = [];
|
|
1010
|
+
let nextToken = null;
|
|
1011
|
+
do {
|
|
1012
|
+
const token = nextToken || tokenizer.nextToken();
|
|
1013
|
+
nextToken = null;
|
|
1014
|
+
switch (token.type) {
|
|
1015
|
+
case 0 /* TokenTypes.Text */:
|
|
1016
|
+
if (token.value == null) {
|
|
1017
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1018
|
+
}
|
|
1019
|
+
node.items.push(parseText(tokenizer, token.value || ''));
|
|
1020
|
+
break;
|
|
1021
|
+
case 5 /* TokenTypes.List */:
|
|
1022
|
+
if (token.value == null) {
|
|
1023
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1024
|
+
}
|
|
1025
|
+
node.items.push(parseList(tokenizer, token.value || ''));
|
|
1026
|
+
break;
|
|
1027
|
+
case 4 /* TokenTypes.Named */:
|
|
1028
|
+
if (token.value == null) {
|
|
1029
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1030
|
+
}
|
|
1031
|
+
node.items.push(parseNamed(tokenizer, token.value || ''));
|
|
1032
|
+
break;
|
|
1033
|
+
case 6 /* TokenTypes.Literal */:
|
|
1034
|
+
if (token.value == null) {
|
|
1035
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1036
|
+
}
|
|
1037
|
+
node.items.push(parseLiteral(tokenizer, token.value || ''));
|
|
1038
|
+
break;
|
|
1039
|
+
case 7 /* TokenTypes.LinkedAlias */: {
|
|
1040
|
+
const parsed = parseLinked(tokenizer);
|
|
1041
|
+
node.items.push(parsed.node);
|
|
1042
|
+
nextToken = parsed.nextConsumeToken || null;
|
|
1043
|
+
break;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
} while (context.currentType !== 13 /* TokenTypes.EOF */ &&
|
|
1047
|
+
context.currentType !== 1 /* TokenTypes.Pipe */);
|
|
1048
|
+
// adjust message node loc
|
|
1049
|
+
const endOffset = context.currentType === 1 /* TokenTypes.Pipe */
|
|
1050
|
+
? context.lastOffset
|
|
1051
|
+
: tokenizer.currentOffset();
|
|
1052
|
+
const endLoc = context.currentType === 1 /* TokenTypes.Pipe */
|
|
1053
|
+
? context.lastEndLoc
|
|
1054
|
+
: tokenizer.currentPosition();
|
|
1055
|
+
endNode(node, endOffset, endLoc);
|
|
1056
|
+
return node;
|
|
1057
|
+
}
|
|
1058
|
+
function parsePlural(tokenizer, offset, loc, msgNode) {
|
|
1059
|
+
const context = tokenizer.context();
|
|
1060
|
+
let hasEmptyMessage = msgNode.items.length === 0;
|
|
1061
|
+
const node = startNode(1 /* NodeTypes.Plural */, offset, loc);
|
|
1062
|
+
node.cases = [];
|
|
1063
|
+
node.cases.push(msgNode);
|
|
1064
|
+
do {
|
|
1065
|
+
const msg = parseMessage(tokenizer);
|
|
1066
|
+
if (!hasEmptyMessage) {
|
|
1067
|
+
hasEmptyMessage = msg.items.length === 0;
|
|
1068
|
+
}
|
|
1069
|
+
node.cases.push(msg);
|
|
1070
|
+
} while (context.currentType !== 13 /* TokenTypes.EOF */);
|
|
1071
|
+
if (hasEmptyMessage) {
|
|
1072
|
+
emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0);
|
|
1073
|
+
}
|
|
1074
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1075
|
+
return node;
|
|
1076
|
+
}
|
|
1077
|
+
function parseResource(tokenizer) {
|
|
1078
|
+
const context = tokenizer.context();
|
|
1079
|
+
const { offset, startLoc } = context;
|
|
1080
|
+
const msgNode = parseMessage(tokenizer);
|
|
1081
|
+
if (context.currentType === 13 /* TokenTypes.EOF */) {
|
|
1082
|
+
return msgNode;
|
|
1083
|
+
}
|
|
1084
|
+
else {
|
|
1085
|
+
return parsePlural(tokenizer, offset, startLoc, msgNode);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
function parse(source) {
|
|
1089
|
+
const tokenizer = createTokenizer(source, assign({}, options));
|
|
1090
|
+
const context = tokenizer.context();
|
|
1091
|
+
const node = startNode(0 /* NodeTypes.Resource */, context.offset, context.startLoc);
|
|
1092
|
+
if (location && node.loc) {
|
|
1093
|
+
node.loc.source = source;
|
|
1094
|
+
}
|
|
1095
|
+
node.body = parseResource(tokenizer);
|
|
1096
|
+
if (options.onCacheKey) {
|
|
1097
|
+
node.cacheKey = options.onCacheKey(source);
|
|
1098
|
+
}
|
|
1099
|
+
// assert whether achieved to EOF
|
|
1100
|
+
if (context.currentType !== 13 /* TokenTypes.EOF */) {
|
|
1101
|
+
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || '');
|
|
1102
|
+
}
|
|
1103
|
+
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1104
|
+
return node;
|
|
1105
|
+
}
|
|
1106
|
+
return { parse };
|
|
1107
|
+
}
|
|
1108
|
+
function getTokenCaption(token) {
|
|
1109
|
+
if (token.type === 13 /* TokenTypes.EOF */) {
|
|
1110
|
+
return 'EOF';
|
|
1111
|
+
}
|
|
1112
|
+
const name = (token.value || '').replace(/\r?\n/gu, '\\n');
|
|
1113
|
+
return name.length > 10 ? name.slice(0, 9) + '…' : name;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
function createTransformer(ast, options = {} // eslint-disable-line
|
|
1117
|
+
) {
|
|
1118
|
+
const _context = {
|
|
1119
|
+
ast,
|
|
1120
|
+
helpers: new Set()
|
|
1121
|
+
};
|
|
1122
|
+
const context = () => _context;
|
|
1123
|
+
const helper = (name) => {
|
|
1124
|
+
_context.helpers.add(name);
|
|
1125
|
+
return name;
|
|
1126
|
+
};
|
|
1127
|
+
return { context, helper };
|
|
1128
|
+
}
|
|
1129
|
+
function traverseNodes(nodes, transformer) {
|
|
1130
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1131
|
+
traverseNode(nodes[i], transformer);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
function traverseNode(node, transformer) {
|
|
1135
|
+
// TODO: if we need pre-hook of transform, should be implemented to here
|
|
1136
|
+
switch (node.type) {
|
|
1137
|
+
case 1 /* NodeTypes.Plural */:
|
|
1138
|
+
traverseNodes(node.cases, transformer);
|
|
1139
|
+
transformer.helper("plural" /* HelperNameMap.PLURAL */);
|
|
1140
|
+
break;
|
|
1141
|
+
case 2 /* NodeTypes.Message */:
|
|
1142
|
+
traverseNodes(node.items, transformer);
|
|
1143
|
+
break;
|
|
1144
|
+
case 6 /* NodeTypes.Linked */: {
|
|
1145
|
+
const linked = node;
|
|
1146
|
+
traverseNode(linked.key, transformer);
|
|
1147
|
+
transformer.helper("linked" /* HelperNameMap.LINKED */);
|
|
1148
|
+
transformer.helper("type" /* HelperNameMap.TYPE */);
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
case 5 /* NodeTypes.List */:
|
|
1152
|
+
transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */);
|
|
1153
|
+
transformer.helper("list" /* HelperNameMap.LIST */);
|
|
1154
|
+
break;
|
|
1155
|
+
case 4 /* NodeTypes.Named */:
|
|
1156
|
+
transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */);
|
|
1157
|
+
transformer.helper("named" /* HelperNameMap.NAMED */);
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1160
|
+
// TODO: if we need post-hook of transform, should be implemented to here
|
|
1161
|
+
}
|
|
1162
|
+
// transform AST
|
|
1163
|
+
function transform(ast, options = {} // eslint-disable-line
|
|
1164
|
+
) {
|
|
1165
|
+
const transformer = createTransformer(ast);
|
|
1166
|
+
transformer.helper("normalize" /* HelperNameMap.NORMALIZE */);
|
|
1167
|
+
// traverse
|
|
1168
|
+
ast.body && traverseNode(ast.body, transformer);
|
|
1169
|
+
// set meta information
|
|
1170
|
+
const context = transformer.context();
|
|
1171
|
+
ast.helpers = Array.from(context.helpers);
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
function optimize(ast) {
|
|
1175
|
+
const body = ast.body;
|
|
1176
|
+
if (body.type === 2 /* NodeTypes.Message */) {
|
|
1177
|
+
optimizeMessageNode(body);
|
|
1178
|
+
}
|
|
1179
|
+
else {
|
|
1180
|
+
body.cases.forEach(c => optimizeMessageNode(c));
|
|
1181
|
+
}
|
|
1182
|
+
return ast;
|
|
1183
|
+
}
|
|
1184
|
+
function optimizeMessageNode(message) {
|
|
1185
|
+
if (message.items.length === 1) {
|
|
1186
|
+
const item = message.items[0];
|
|
1187
|
+
if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) {
|
|
1188
|
+
message.static = item.value;
|
|
1189
|
+
delete item.value; // optimization for size
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
const values = [];
|
|
1194
|
+
for (let i = 0; i < message.items.length; i++) {
|
|
1195
|
+
const item = message.items[i];
|
|
1196
|
+
if (!(item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */)) {
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1199
|
+
if (item.value == null) {
|
|
1200
|
+
break;
|
|
1201
|
+
}
|
|
1202
|
+
values.push(item.value);
|
|
1203
|
+
}
|
|
1204
|
+
if (values.length === message.items.length) {
|
|
1205
|
+
message.static = join(values);
|
|
1206
|
+
for (let i = 0; i < message.items.length; i++) {
|
|
1207
|
+
const item = message.items[i];
|
|
1208
|
+
if (item.type === 3 /* NodeTypes.Text */ || item.type === 9 /* NodeTypes.Literal */) {
|
|
1209
|
+
delete item.value; // optimization for size
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
const ERROR_DOMAIN$1 = 'minifier';
|
|
1217
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1218
|
+
function minify(node) {
|
|
1219
|
+
node.t = node.type;
|
|
1220
|
+
switch (node.type) {
|
|
1221
|
+
case 0 /* NodeTypes.Resource */: {
|
|
1222
|
+
const resource = node;
|
|
1223
|
+
minify(resource.body);
|
|
1224
|
+
resource.b = resource.body;
|
|
1225
|
+
delete resource.body;
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
case 1 /* NodeTypes.Plural */: {
|
|
1229
|
+
const plural = node;
|
|
1230
|
+
const cases = plural.cases;
|
|
1231
|
+
for (let i = 0; i < cases.length; i++) {
|
|
1232
|
+
minify(cases[i]);
|
|
1233
|
+
}
|
|
1234
|
+
plural.c = cases;
|
|
1235
|
+
delete plural.cases;
|
|
1236
|
+
break;
|
|
1237
|
+
}
|
|
1238
|
+
case 2 /* NodeTypes.Message */: {
|
|
1239
|
+
const message = node;
|
|
1240
|
+
const items = message.items;
|
|
1241
|
+
for (let i = 0; i < items.length; i++) {
|
|
1242
|
+
minify(items[i]);
|
|
1243
|
+
}
|
|
1244
|
+
message.i = items;
|
|
1245
|
+
delete message.items;
|
|
1246
|
+
if (message.static) {
|
|
1247
|
+
message.s = message.static;
|
|
1248
|
+
delete message.static;
|
|
1249
|
+
}
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
case 3 /* NodeTypes.Text */:
|
|
1253
|
+
case 9 /* NodeTypes.Literal */:
|
|
1254
|
+
case 8 /* NodeTypes.LinkedModifier */:
|
|
1255
|
+
case 7 /* NodeTypes.LinkedKey */: {
|
|
1256
|
+
const valueNode = node;
|
|
1257
|
+
if (valueNode.value) {
|
|
1258
|
+
valueNode.v = valueNode.value;
|
|
1259
|
+
delete valueNode.value;
|
|
1260
|
+
}
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
case 6 /* NodeTypes.Linked */: {
|
|
1264
|
+
const linked = node;
|
|
1265
|
+
minify(linked.key);
|
|
1266
|
+
linked.k = linked.key;
|
|
1267
|
+
delete linked.key;
|
|
1268
|
+
if (linked.modifier) {
|
|
1269
|
+
minify(linked.modifier);
|
|
1270
|
+
linked.m = linked.modifier;
|
|
1271
|
+
delete linked.modifier;
|
|
1272
|
+
}
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
case 5 /* NodeTypes.List */: {
|
|
1276
|
+
const list = node;
|
|
1277
|
+
list.i = list.index;
|
|
1278
|
+
delete list.index;
|
|
1279
|
+
break;
|
|
1280
|
+
}
|
|
1281
|
+
case 4 /* NodeTypes.Named */: {
|
|
1282
|
+
const named = node;
|
|
1283
|
+
named.k = named.key;
|
|
1284
|
+
delete named.key;
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
default:
|
|
1288
|
+
if ((process.env.NODE_ENV !== 'production')) {
|
|
1289
|
+
throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, {
|
|
1290
|
+
domain: ERROR_DOMAIN$1,
|
|
1291
|
+
args: [node.type]
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
delete node.type;
|
|
1296
|
+
}
|
|
1297
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
1298
|
+
|
|
1299
|
+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
1300
|
+
/// <reference types="source-map-js" />
|
|
1301
|
+
const ERROR_DOMAIN = 'parser';
|
|
1302
|
+
function createCodeGenerator(ast, options) {
|
|
1303
|
+
const { filename, breakLineCode, needIndent: _needIndent } = options;
|
|
1304
|
+
const location = options.location !== false;
|
|
1305
|
+
const _context = {
|
|
1306
|
+
filename,
|
|
1307
|
+
code: '',
|
|
1308
|
+
column: 1,
|
|
1309
|
+
line: 1,
|
|
1310
|
+
offset: 0,
|
|
1311
|
+
map: undefined,
|
|
1312
|
+
breakLineCode,
|
|
1313
|
+
needIndent: _needIndent,
|
|
1314
|
+
indentLevel: 0
|
|
1315
|
+
};
|
|
1316
|
+
if (location && ast.loc) {
|
|
1317
|
+
_context.source = ast.loc.source;
|
|
1318
|
+
}
|
|
1319
|
+
const context = () => _context;
|
|
1320
|
+
function push(code, node) {
|
|
1321
|
+
_context.code += code;
|
|
1322
|
+
}
|
|
1323
|
+
function _newline(n, withBreakLine = true) {
|
|
1324
|
+
const _breakLineCode = withBreakLine ? breakLineCode : '';
|
|
1325
|
+
push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode);
|
|
1326
|
+
}
|
|
1327
|
+
function indent(withNewLine = true) {
|
|
1328
|
+
const level = ++_context.indentLevel;
|
|
1329
|
+
withNewLine && _newline(level);
|
|
1330
|
+
}
|
|
1331
|
+
function deindent(withNewLine = true) {
|
|
1332
|
+
const level = --_context.indentLevel;
|
|
1333
|
+
withNewLine && _newline(level);
|
|
1334
|
+
}
|
|
1335
|
+
function newline() {
|
|
1336
|
+
_newline(_context.indentLevel);
|
|
1337
|
+
}
|
|
1338
|
+
const helper = (key) => `_${key}`;
|
|
1339
|
+
const needIndent = () => _context.needIndent;
|
|
1340
|
+
return {
|
|
1341
|
+
context,
|
|
1342
|
+
push,
|
|
1343
|
+
indent,
|
|
1344
|
+
deindent,
|
|
1345
|
+
newline,
|
|
1346
|
+
helper,
|
|
1347
|
+
needIndent
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
function generateLinkedNode(generator, node) {
|
|
1351
|
+
const { helper } = generator;
|
|
1352
|
+
generator.push(`${helper("linked" /* HelperNameMap.LINKED */)}(`);
|
|
1353
|
+
generateNode(generator, node.key);
|
|
1354
|
+
if (node.modifier) {
|
|
1355
|
+
generator.push(`, `);
|
|
1356
|
+
generateNode(generator, node.modifier);
|
|
1357
|
+
generator.push(`, _type`);
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
generator.push(`, undefined, _type`);
|
|
1361
|
+
}
|
|
1362
|
+
generator.push(`)`);
|
|
1363
|
+
}
|
|
1364
|
+
function generateMessageNode(generator, node) {
|
|
1365
|
+
const { helper, needIndent } = generator;
|
|
1366
|
+
generator.push(`${helper("normalize" /* HelperNameMap.NORMALIZE */)}([`);
|
|
1367
|
+
generator.indent(needIndent());
|
|
1368
|
+
const length = node.items.length;
|
|
1369
|
+
for (let i = 0; i < length; i++) {
|
|
1370
|
+
generateNode(generator, node.items[i]);
|
|
1371
|
+
if (i === length - 1) {
|
|
1372
|
+
break;
|
|
1373
|
+
}
|
|
1374
|
+
generator.push(', ');
|
|
1375
|
+
}
|
|
1376
|
+
generator.deindent(needIndent());
|
|
1377
|
+
generator.push('])');
|
|
1378
|
+
}
|
|
1379
|
+
function generatePluralNode(generator, node) {
|
|
1380
|
+
const { helper, needIndent } = generator;
|
|
1381
|
+
if (node.cases.length > 1) {
|
|
1382
|
+
generator.push(`${helper("plural" /* HelperNameMap.PLURAL */)}([`);
|
|
1383
|
+
generator.indent(needIndent());
|
|
1384
|
+
const length = node.cases.length;
|
|
1385
|
+
for (let i = 0; i < length; i++) {
|
|
1386
|
+
generateNode(generator, node.cases[i]);
|
|
1387
|
+
if (i === length - 1) {
|
|
1388
|
+
break;
|
|
1389
|
+
}
|
|
1390
|
+
generator.push(', ');
|
|
1391
|
+
}
|
|
1392
|
+
generator.deindent(needIndent());
|
|
1393
|
+
generator.push(`])`);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
function generateResource(generator, node) {
|
|
1397
|
+
if (node.body) {
|
|
1398
|
+
generateNode(generator, node.body);
|
|
1399
|
+
}
|
|
1400
|
+
else {
|
|
1401
|
+
generator.push('null');
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
function generateNode(generator, node) {
|
|
1405
|
+
const { helper } = generator;
|
|
1406
|
+
switch (node.type) {
|
|
1407
|
+
case 0 /* NodeTypes.Resource */:
|
|
1408
|
+
generateResource(generator, node);
|
|
1409
|
+
break;
|
|
1410
|
+
case 1 /* NodeTypes.Plural */:
|
|
1411
|
+
generatePluralNode(generator, node);
|
|
1412
|
+
break;
|
|
1413
|
+
case 2 /* NodeTypes.Message */:
|
|
1414
|
+
generateMessageNode(generator, node);
|
|
1415
|
+
break;
|
|
1416
|
+
case 6 /* NodeTypes.Linked */:
|
|
1417
|
+
generateLinkedNode(generator, node);
|
|
1418
|
+
break;
|
|
1419
|
+
case 8 /* NodeTypes.LinkedModifier */:
|
|
1420
|
+
generator.push(JSON.stringify(node.value), node);
|
|
1421
|
+
break;
|
|
1422
|
+
case 7 /* NodeTypes.LinkedKey */:
|
|
1423
|
+
generator.push(JSON.stringify(node.value), node);
|
|
1424
|
+
break;
|
|
1425
|
+
case 5 /* NodeTypes.List */:
|
|
1426
|
+
generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("list" /* HelperNameMap.LIST */)}(${node.index}))`, node);
|
|
1427
|
+
break;
|
|
1428
|
+
case 4 /* NodeTypes.Named */:
|
|
1429
|
+
generator.push(`${helper("interpolate" /* HelperNameMap.INTERPOLATE */)}(${helper("named" /* HelperNameMap.NAMED */)}(${JSON.stringify(node.key)}))`, node);
|
|
1430
|
+
break;
|
|
1431
|
+
case 9 /* NodeTypes.Literal */:
|
|
1432
|
+
generator.push(JSON.stringify(node.value), node);
|
|
1433
|
+
break;
|
|
1434
|
+
case 3 /* NodeTypes.Text */:
|
|
1435
|
+
generator.push(JSON.stringify(node.value), node);
|
|
1436
|
+
break;
|
|
1437
|
+
default:
|
|
1438
|
+
if ((process.env.NODE_ENV !== 'production')) {
|
|
1439
|
+
throw createCompileError(CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE, null, {
|
|
1440
|
+
domain: ERROR_DOMAIN,
|
|
1441
|
+
args: [node.type]
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
// generate code from AST
|
|
1447
|
+
const generate = (ast, options = {}) => {
|
|
1448
|
+
const mode = isString(options.mode) ? options.mode : 'normal';
|
|
1449
|
+
const filename = isString(options.filename)
|
|
1450
|
+
? options.filename
|
|
1451
|
+
: 'message.intl';
|
|
1452
|
+
// prettier-ignore
|
|
1453
|
+
const breakLineCode = options.breakLineCode != null
|
|
1454
|
+
? options.breakLineCode
|
|
1455
|
+
: mode === 'arrow'
|
|
1456
|
+
? ';'
|
|
1457
|
+
: '\n';
|
|
1458
|
+
const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow';
|
|
1459
|
+
const helpers = ast.helpers || [];
|
|
1460
|
+
const generator = createCodeGenerator(ast, {
|
|
1461
|
+
filename,
|
|
1462
|
+
breakLineCode,
|
|
1463
|
+
needIndent
|
|
1464
|
+
});
|
|
1465
|
+
generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`);
|
|
1466
|
+
generator.indent(needIndent);
|
|
1467
|
+
if (helpers.length > 0) {
|
|
1468
|
+
generator.push(`const { ${join(helpers.map(s => `${s}: _${s}`), ', ')} } = ctx`);
|
|
1469
|
+
generator.newline();
|
|
1470
|
+
}
|
|
1471
|
+
generator.push(`return `);
|
|
1472
|
+
generateNode(generator, ast);
|
|
1473
|
+
generator.deindent(needIndent);
|
|
1474
|
+
generator.push(`}`);
|
|
1475
|
+
delete ast.helpers;
|
|
1476
|
+
const { code, map } = generator.context();
|
|
1477
|
+
return {
|
|
1478
|
+
ast,
|
|
1479
|
+
code,
|
|
1480
|
+
map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1481
|
+
};
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
function baseCompile(source, options = {}) {
|
|
1485
|
+
const assignedOptions = assign({}, options);
|
|
1486
|
+
const jit = !!assignedOptions.jit;
|
|
1487
|
+
const enalbeMinify = !!assignedOptions.minify;
|
|
1488
|
+
const enambeOptimize = assignedOptions.optimize == null ? true : assignedOptions.optimize;
|
|
1489
|
+
// parse source codes
|
|
1490
|
+
const parser = createParser(assignedOptions);
|
|
1491
|
+
const ast = parser.parse(source);
|
|
1492
|
+
if (!jit) {
|
|
1493
|
+
// transform ASTs
|
|
1494
|
+
transform(ast, assignedOptions);
|
|
1495
|
+
// generate javascript codes
|
|
1496
|
+
return generate(ast, assignedOptions);
|
|
1497
|
+
}
|
|
1498
|
+
else {
|
|
1499
|
+
// optimize ASTs
|
|
1500
|
+
enambeOptimize && optimize(ast);
|
|
1501
|
+
// minimize ASTs
|
|
1502
|
+
enalbeMinify && minify(ast);
|
|
1503
|
+
// In JIT mode, no ast transform, no code generation.
|
|
1504
|
+
return { ast, code: '' };
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
export { COMPILE_ERROR_CODES_EXTEND_POINT as C, defaultOnError as a, baseCompile as b, createCompileError as c, detectHtmlTag as d };
|