@vc-shell/framework 1.1.46 → 1.1.47
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 +4 -0
- package/core/plugins/modularity/loader.ts +126 -97
- package/dist/assets/042c75b764bc78a7.svg +1 -0
- package/dist/assets/0ba156439a339f2a.svg +1 -0
- package/dist/assets/0be560bfb22d0e72.woff2 +0 -0
- package/dist/assets/0f590f8a94577092.svg +1 -0
- package/dist/assets/0fc5820f8be53a1b.svg +1 -0
- package/dist/assets/10768e2cc79fc60b.svg +1 -0
- package/dist/assets/11b3d25a56fd9a21.woff2 +0 -0
- package/dist/assets/157b8721e0600ea8.svg +1 -0
- package/dist/assets/15e91cdd649cde9a.svg +1 -0
- package/dist/assets/1a3e84b2457f709a.woff +0 -0
- package/dist/assets/1de63eb118636cce.svg +1 -0
- package/dist/assets/1ea01de36eb5491b.svg +1 -0
- package/dist/assets/204eaf512fde2023.svg +1 -0
- package/dist/assets/2088983edf42e153.svg +1 -0
- package/dist/assets/208f810a9321a327.svg +1 -0
- package/dist/assets/21220a9d10e6c558.svg +1 -0
- package/dist/assets/220db345a102045d.woff2 +0 -0
- package/dist/assets/225da11d23968333.svg +1 -0
- package/dist/assets/226f862dd81bdc13.woff2 +0 -0
- package/dist/assets/23a2d53395ddb14f.woff +0 -0
- package/dist/assets/259e6ad461a52ad7.svg +1 -0
- package/dist/assets/261e6dec4d53b9ac.woff +0 -0
- package/dist/assets/262f46a0b6d94bb6.svg +1 -0
- package/dist/assets/2857c513073467da.svg +1 -0
- package/dist/assets/2b3be7889467d98f.woff +0 -0
- package/dist/assets/2d4e6190eec72737.svg +1 -0
- package/dist/assets/2eba973185078bc8.woff +0 -0
- package/dist/assets/327511cd4a7ba7f9.woff +0 -0
- package/dist/assets/334d3f6bc766c516.woff +0 -0
- package/dist/assets/34ff7dd0c2285956.svg +1 -0
- package/dist/assets/3d26b7c1ab78bbe2.woff +0 -0
- package/dist/assets/3f8c4cc8099e34b6.woff2 +0 -0
- package/dist/assets/40a0e53b79ce63c6.woff2 +0 -0
- package/dist/assets/41275bcb979cb650.svg +1 -0
- package/dist/assets/42df4e2d6fa3fd2a.woff2 +0 -0
- package/dist/assets/434f7982590e462f.woff +0 -0
- package/dist/assets/4ae5f23e0ca888e7.woff2 +0 -0
- package/dist/assets/4d7a77b0e5373992.svg +1 -0
- package/dist/assets/4e43c74354534fb3.svg +1 -0
- package/dist/assets/4fe75f5117100705.svg +1 -0
- package/dist/assets/52610491f372cb0c.woff2 +0 -0
- package/dist/assets/52e261a005074e1b.woff +0 -0
- package/dist/assets/5304c3d05a5f9789.woff2 +0 -0
- package/dist/assets/572bb1bb4156a9c1.svg +1 -0
- package/dist/assets/5b3661be8be679d0.woff2 +0 -0
- package/dist/assets/5d96cfcc5bedd917.woff2 +0 -0
- package/dist/assets/6075995d7e74da46.woff2 +0 -0
- package/dist/assets/617c4736236e199e.woff +0 -0
- package/dist/assets/6619e9e10beea0e7.woff2 +0 -0
- package/dist/assets/67230f05dc94a265.svg +1 -0
- package/dist/assets/6798e4dd4add9b48.svg +1 -0
- package/dist/assets/698ec6c722d4cb05.woff2 +0 -0
- package/dist/assets/6a3e73faf406cf33.svg +1 -0
- package/dist/assets/72de3a63bc0b70dd.svg +1 -0
- package/dist/assets/74c6a6ab81bb6340.woff2 +0 -0
- package/dist/assets/74ed5f8a78e71106.svg +1 -0
- package/dist/assets/7ce0c166fd6a1204.woff +0 -0
- package/dist/assets/7d55399c2a7bc985.svg +1 -0
- package/dist/assets/7d970675c69fca1d.woff +0 -0
- package/dist/assets/7eda727273fd98d3.svg +1 -0
- package/dist/assets/7f6ebfd707b76ca2.woff +0 -0
- package/dist/assets/7fa898d213fcc7bc.woff2 +0 -0
- package/dist/assets/861e6b7192b3b6c7.woff +0 -0
- package/dist/assets/8bbcde81ba21ecb2.woff2 +0 -0
- package/dist/assets/8f6657e5e0b8d3e4.woff +0 -0
- package/dist/assets/910b0d99b9e26568.svg +1 -0
- package/dist/assets/91eee1aa81f72683.woff +0 -0
- package/dist/assets/92508f8707159b51.svg +1 -0
- package/dist/assets/9392bf1d591e1abb.svg +1 -0
- package/dist/assets/97e8d4984ba0713a.woff2 +0 -0
- package/dist/assets/9cb83236f6bb7ab1.svg +1 -0
- package/dist/assets/9d37314695c0b68d.woff +0 -0
- package/dist/assets/a18404194e3f9047.svg +1 -0
- package/dist/assets/a2017fe7f0a26510.svg +1 -0
- package/dist/assets/a47034e65dbcc3d7.woff +0 -0
- package/dist/assets/a617e11804bbacb7.woff +0 -0
- package/dist/assets/ab6e7190bb1492d5.woff2 +0 -0
- package/dist/assets/abf88f301a0730f4.svg +1 -0
- package/dist/assets/aed17cb6fdad2ada.woff2 +0 -0
- package/dist/assets/b1a596e31ad1185a.svg +1 -0
- package/dist/assets/b27767411c8427be.woff +0 -0
- package/dist/assets/b291dc35a17511f7.woff +0 -0
- package/dist/assets/b325adcae33bbe7a.svg +1 -0
- package/dist/assets/b372390551ca2fa1.svg +1 -0
- package/dist/assets/b5bb1e8fc975decd.svg +1 -0
- package/dist/assets/b645a4a2181b9dc1.svg +1 -0
- package/dist/assets/b6499ddce0a4ef7d.svg +1 -0
- package/dist/assets/b94421fadd23b0f2.svg +1 -0
- package/dist/assets/bb28fb0f27f1c11b.svg +1 -0
- package/dist/assets/bfbe205759295eca.woff2 +0 -0
- package/dist/assets/ca791c5ca5848a03.svg +1 -0
- package/dist/assets/cb32840ce330103f.woff +0 -0
- package/dist/assets/d084bda16abe8a56.svg +1 -0
- package/dist/assets/d32b129cae2fffd6.svg +1 -0
- package/dist/assets/d35a4c7113315758.woff2 +0 -0
- package/dist/assets/d3f792f54ae4c307.svg +1 -0
- package/dist/assets/d5a5b8630120073d.svg +1 -0
- package/dist/assets/d5f9664ebbfb104b.svg +1 -0
- package/dist/assets/d80b05788e407de7.woff2 +0 -0
- package/dist/assets/d84247b59449dd88.woff2 +0 -0
- package/dist/assets/dd05d43ff0df2fc7.svg +1 -0
- package/dist/assets/e38acaa1757232e0.svg +1 -0
- package/dist/assets/e4a8550f1c7ffe36.svg +1 -0
- package/dist/assets/e5adb5ae3a3698f6.svg +1 -0
- package/dist/assets/e61a1889bac955f4.woff2 +0 -0
- package/dist/assets/e72bb11356af94c7.svg +1 -0
- package/dist/assets/e98196a9f8dcb2f0.svg +1 -0
- package/dist/assets/ebec912a42ad49ff.woff +0 -0
- package/dist/assets/f09d89268e4c0317.svg +1 -0
- package/dist/assets/f276d55184e05a07.woff +0 -0
- package/dist/assets/f5722262b6e7214e.woff2 +0 -0
- package/dist/assets/f7fc8bf46089d8b2.svg +1 -0
- package/dist/assets/fcb1c1ffb5640194.woff +0 -0
- package/dist/assets/fe141d99763f5d2b.woff +0 -0
- package/dist/assets/fed13b0d59903483.svg +1 -0
- package/dist/assets/fed757d2c2344ead.woff2 +0 -0
- package/dist/assets/ffc438f20e79ce73.woff +0 -0
- package/dist/core/plugins/modularity/loader.d.ts.map +1 -1
- package/dist/framework.js +16544 -25878
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-lucide-icon.vue.d.ts.map +1 -1
- package/dist/vendor-boolbase-Bgn9I6iN.js +21 -0
- package/dist/vendor-cheerio-CleDsuQZ.js +1053 -0
- package/dist/vendor-cheerio-select-CVkYl3Z-.js +191 -0
- package/dist/vendor-css-select-CtIzVIiG.js +622 -0
- package/dist/vendor-css-what-CZZaquJM.js +267 -0
- package/dist/vendor-cypress-signalr-mock-CdKwIhWw.js +769 -0
- package/dist/vendor-date-fns-CdFbeoHV.js +2989 -0
- package/dist/vendor-dom-serializer-CugO0RdN.js +213 -0
- package/dist/vendor-dom7-wvIUV9pT.js +529 -0
- package/dist/vendor-domelementtype-B3sFIGaC.js +21 -0
- package/dist/vendor-domhandler-CL40eeX9.js +311 -0
- package/dist/vendor-dompurify-eYFoHPwR.js +528 -0
- package/dist/vendor-domutils-D3Y2YQFR.js +386 -0
- package/dist/vendor-entities-v26HW8wW.js +363 -0
- package/dist/vendor-floating-ui-core-C9uEvi1M.js +349 -0
- package/dist/vendor-floating-ui-dom-CZkYGmv4.js +393 -0
- package/dist/vendor-floating-ui-utils-Bx3BTd6_.js +259 -0
- package/dist/vendor-floating-ui-vue-CLOiVYP7.js +107 -0
- package/dist/vendor-headlessui-vue-Dg0Llidi.js +961 -0
- package/dist/vendor-htmlparser2-CXL_uhMI.js +735 -0
- package/dist/vendor-iconify-vue-D4fihzvl.js +1205 -0
- package/dist/vendor-intlify-core-base-Bvt2vJFV.js +1129 -0
- package/dist/vendor-intlify-message-compiler-1VxNzq21.js +945 -0
- package/dist/vendor-intlify-shared-D7kiPMOG.js +130 -0
- package/dist/vendor-iso-639-1-dVGfSUIM.js +781 -0
- package/dist/vendor-linkify-it-LzoUhj6C.js +199 -0
- package/dist/vendor-linkifyjs-DTu7SY_Y.js +705 -0
- package/dist/vendor-lodash-es-CrYlgAi8.js +4816 -0
- package/dist/vendor-markdown-it-4AJoRTAg.js +2263 -0
- package/dist/vendor-markdown-it-task-lists-Byg1-ms9.js +69 -0
- package/dist/vendor-mdurl-DZFDNdqC.js +192 -0
- package/dist/vendor-microsoft-applicationinsights-analytics-js-DA-ctcAL.js +1105 -0
- package/dist/vendor-microsoft-applicationinsights-cfgsync-js-COfRj-2q.js +261 -0
- package/dist/vendor-microsoft-applicationinsights-channel-js-MTPYhH-I.js +1809 -0
- package/dist/vendor-microsoft-applicationinsights-common-CDVnJ6MR.js +1921 -0
- package/dist/vendor-microsoft-applicationinsights-core-js-D7Aicf8S.js +4127 -0
- package/dist/vendor-microsoft-applicationinsights-dependencies-js-CvQWWraU.js +1399 -0
- package/dist/vendor-microsoft-applicationinsights-properties-js-C0Iv1cZE.js +572 -0
- package/dist/vendor-microsoft-applicationinsights-shims-CxtPYiwp.js +43 -0
- package/dist/vendor-microsoft-applicationinsights-web-BRuQAzjU.js +487 -0
- package/dist/vendor-microsoft-dynamicproto-js-DSkQkH3T.js +147 -0
- package/dist/vendor-microsoft-signalr-qIrag5xx.js +1761 -0
- package/dist/vendor-moment-CwOqp704.js +2589 -0
- package/dist/vendor-nevware21-ts-async-FAyg3c9V.js +260 -0
- package/dist/vendor-nevware21-ts-utils-Dy41wRhA.js +853 -0
- package/dist/vendor-nth-check-BE7AeBMg.js +45 -0
- package/dist/vendor-orderedmap-B3SOk52B.js +103 -0
- package/dist/vendor-parse5-DqztJOGh.js +5747 -0
- package/dist/vendor-parse5-htmlparser2-tree-adapter-CNubfdOP.js +143 -0
- package/dist/vendor-popperjs-core-LGjf7Wza.js +905 -0
- package/dist/vendor-prettier-D8C9GG-0.js +4858 -0
- package/dist/vendor-prosemirror-commands-BqYcdumy.js +344 -0
- package/dist/vendor-prosemirror-dropcursor-zknUsW5x.js +86 -0
- package/dist/vendor-prosemirror-gapcursor-DjOZhP78.js +200 -0
- package/dist/vendor-prosemirror-history-l8l3CFac.js +248 -0
- package/dist/vendor-prosemirror-keymap-C17r08p-.js +62 -0
- package/dist/vendor-prosemirror-markdown-WJEDhc-w.js +650 -0
- package/dist/vendor-prosemirror-model-BN5TnJD_.js +2736 -0
- package/dist/vendor-prosemirror-schema-list-CR0gi7aY.js +87 -0
- package/dist/vendor-prosemirror-state-B0bFP8WI.js +821 -0
- package/dist/vendor-prosemirror-tables-B1txTKlC.js +1711 -0
- package/dist/vendor-prosemirror-transform-Bo7kNPme.js +1507 -0
- package/dist/vendor-prosemirror-view--C7TZvmQ.js +3746 -0
- package/dist/vendor-punycode-js-CNI-zL6U.js +133 -0
- package/dist/vendor-rope-sequence-sEGCUMi8.js +100 -0
- package/dist/vendor-semver-BoKYtkQw.js +1021 -0
- package/dist/vendor-ssr-window-D4k3p53c.js +133 -0
- package/dist/vendor-swiper-CMVLTGu0.js +2825 -0
- package/dist/vendor-tippy-js-BGdgwGX-.js +812 -0
- package/dist/vendor-tiptap-core-BRY37Sb2.js +2806 -0
- package/dist/vendor-tiptap-extension-blockquote-CPd5qv-9.js +43 -0
- package/dist/vendor-tiptap-extension-bold-B0GwBNks.js +71 -0
- package/dist/vendor-tiptap-extension-bubble-menu-B0sZZld7.js +128 -0
- package/dist/vendor-tiptap-extension-bullet-list-CQm4ReOu.js +53 -0
- package/dist/vendor-tiptap-extension-code-C8cy6bRj.js +51 -0
- package/dist/vendor-tiptap-extension-code-block-BqTchNEf.js +133 -0
- package/dist/vendor-tiptap-extension-document-Dka1Uu0g.js +9 -0
- package/dist/vendor-tiptap-extension-dropcursor-CFSh-BuE.js +20 -0
- package/dist/vendor-tiptap-extension-floating-menu-H8PB4zeI.js +99 -0
- package/dist/vendor-tiptap-extension-gapcursor-CzwfD_IT.js +24 -0
- package/dist/vendor-tiptap-extension-hard-break-Rm6aVcrK.js +55 -0
- package/dist/vendor-tiptap-extension-heading-CavI6u1v.js +54 -0
- package/dist/vendor-tiptap-extension-history-WEN1_74D.js +35 -0
- package/dist/vendor-tiptap-extension-horizontal-rule-DZkUEL6s.js +58 -0
- package/dist/vendor-tiptap-extension-image-B67_mxGM.js +64 -0
- package/dist/vendor-tiptap-extension-italic-BshxBFou.js +70 -0
- package/dist/vendor-tiptap-extension-link-CJAQIgui.js +262 -0
- package/dist/vendor-tiptap-extension-list-item-DF-iMpqO.js +33 -0
- package/dist/vendor-tiptap-extension-ordered-list-CN8MF-kN.js +71 -0
- package/dist/vendor-tiptap-extension-paragraph-DI577lM5.js +33 -0
- package/dist/vendor-tiptap-extension-placeholder-DwAtlfAF.js +52 -0
- package/dist/vendor-tiptap-extension-strike-CIty09KN.js +61 -0
- package/dist/vendor-tiptap-extension-table-C5nv-GUb.js +213 -0
- package/dist/vendor-tiptap-extension-table-cell-DXbBhJW3.js +40 -0
- package/dist/vendor-tiptap-extension-table-header-rtggsYXA.js +40 -0
- package/dist/vendor-tiptap-extension-table-row-67khjMDt.js +22 -0
- package/dist/vendor-tiptap-extension-text-D1OHb_a1.js +8 -0
- package/dist/vendor-tiptap-extension-underline-IqWixw3m.js +40 -0
- package/dist/vendor-tiptap-markdown-DVxB1hbO.js +825 -0
- package/dist/vendor-tiptap-starter-kit-CPH9gu2X.js +29 -0
- package/dist/vendor-tiptap-vue-3-CkBe4_xM.js +225 -0
- package/dist/vendor-truncate-html-Bx1HJzRq.js +145 -0
- package/dist/vendor-uc-micro-4lbSaZOs.js +17 -0
- package/dist/vendor-vee-validate-i18n-zT8NxX3R.js +93 -0
- package/dist/vendor-vee-validate-rules-DDeNM2Gc.js +314 -0
- package/dist/vendor-vue-currency-input-DxWnS-HB.js +315 -0
- package/dist/vendor-vue-devtools-api-aVYGocXp.js +93 -0
- package/dist/vendor-vue-i18n-DPtOLen3.js +1359 -0
- package/dist/vendor-vue3-application-insights-dAGGfA_M.js +69 -0
- package/dist/vendor-vue3-touch-events-8Pa3HHlV.js +169 -0
- package/dist/vendor-vuepic-vue-datepicker-DglsiNYa.js +4997 -0
- package/dist/vendor-vueuse-components-DtK_mxpP.js +219 -0
- package/dist/vendor-vueuse-core-cB-c7DzH.js +5129 -0
- package/dist/vendor-vueuse-shared-Dg7PMM0z.js +1169 -0
- package/dist/vendor-w3c-keyname-CLxH8j-f.js +92 -0
- package/dist/vendor-whatwg-fetch-l0sNRNKZ.js +1 -0
- package/package.json +5 -4
- package/ui/components/atoms/vc-icon/vc-lucide-icon.vue +2 -1
- package/dist/vendor-boolbase-Cp9L0GAZ.js +0 -25
- package/dist/vendor-cheerio-HN9zIPZn.js +0 -3135
- package/dist/vendor-cheerio-select-5Ry0HvBq.js +0 -306
- package/dist/vendor-css-select-DRIZ9kfZ.js +0 -966
- package/dist/vendor-css-what-DuPJ1HEF.js +0 -448
- package/dist/vendor-cypress-signalr-mock-BKdBJpdt.js +0 -778
- package/dist/vendor-date-fns-515YWkk-.js +0 -6724
- package/dist/vendor-dom-serializer-nQMsqjYW.js +0 -286
- package/dist/vendor-dom7-CJLPMwy5.js +0 -941
- package/dist/vendor-domelementtype-CjSzQey5.js +0 -53
- package/dist/vendor-domhandler-9z8cS16a.js +0 -484
- package/dist/vendor-dompurify-CRFzu7ib.js +0 -1336
- package/dist/vendor-domutils-Bc-Opz-v.js +0 -981
- package/dist/vendor-entities-Bfsx4xOQ.js +0 -636
- package/dist/vendor-floating-ui-core-wV8u8QP4.js +0 -511
- package/dist/vendor-floating-ui-dom-DDnRPs17.js +0 -706
- package/dist/vendor-floating-ui-utils-OMIFy1QU.js +0 -296
- package/dist/vendor-floating-ui-vue-D-tCDAMm.js +0 -167
- package/dist/vendor-fontsource-plus-jakarta-sans.css +0 -1
- package/dist/vendor-headlessui-vue-CY9FRgTb.js +0 -83
- package/dist/vendor-htmlparser2-B1dhFPOs.js +0 -1426
- package/dist/vendor-iconify-vue-DfRGgyNu.js +0 -1840
- package/dist/vendor-intlify-core-base-BuknsFQe.js +0 -1876
- package/dist/vendor-intlify-message-compiler-CuOQDWx1.js +0 -1508
- package/dist/vendor-intlify-shared-Cz4YRMuC.js +0 -241
- package/dist/vendor-iso-639-1-BJCk9DvE.js +0 -819
- package/dist/vendor-linkify-it-CKUf4vsc.js +0 -830
- package/dist/vendor-linkifyjs-BfyGgbCh.js +0 -1756
- package/dist/vendor-lodash-es-BySUOlwf.js +0 -18333
- package/dist/vendor-markdown-it-D-apazHa.js +0 -6000
- package/dist/vendor-markdown-it-task-lists-rxMVH6Ku.js +0 -131
- package/dist/vendor-mdurl-BNh2CCgT.js +0 -537
- package/dist/vendor-microsoft-applicationinsights-analytics-js-kG3lLg8X.js +0 -1275
- package/dist/vendor-microsoft-applicationinsights-cfgsync-js-C0uQkiQq.js +0 -591
- package/dist/vendor-microsoft-applicationinsights-channel-js-Dyd_PXA3.js +0 -2153
- package/dist/vendor-microsoft-applicationinsights-common-CfmP1_Qr.js +0 -2470
- package/dist/vendor-microsoft-applicationinsights-core-js-Cq4YSEvZ.js +0 -6589
- package/dist/vendor-microsoft-applicationinsights-dependencies-js-C56OBFr4.js +0 -1510
- package/dist/vendor-microsoft-applicationinsights-properties-js-CBJTBawx.js +0 -761
- package/dist/vendor-microsoft-applicationinsights-shims-CX8sJgar.js +0 -70
- package/dist/vendor-microsoft-applicationinsights-web-pim2ri-g.js +0 -667
- package/dist/vendor-microsoft-dynamicproto-js-CFBBUu9p.js +0 -520
- package/dist/vendor-microsoft-signalr-dUnlRsGm.js +0 -3339
- package/dist/vendor-moment-Mki5YqAR.js +0 -5679
- package/dist/vendor-nevware21-ts-async-CLMApQ9E.js +0 -395
- package/dist/vendor-nevware21-ts-utils-e8v8Jty3.js +0 -1160
- package/dist/vendor-nth-check-Bx8TxtJt.js +0 -157
- package/dist/vendor-orderedmap-dGG6uMFJ.js +0 -137
- package/dist/vendor-parse5-Bt2NhSzR.js +0 -8432
- package/dist/vendor-parse5-htmlparser2-tree-adapter-BUUtKzf8.js +0 -216
- package/dist/vendor-popperjs-core-Cr2byIky.js +0 -1790
- package/dist/vendor-prettier-B4PaeWRQ.js +0 -98
- package/dist/vendor-prosemirror-commands-BH9lWGpW.js +0 -561
- package/dist/vendor-prosemirror-dropcursor-CeyPcxrA.js +0 -146
- package/dist/vendor-prosemirror-gapcursor-U8UoUJII.js +0 -236
- package/dist/vendor-prosemirror-history-BDaJkvNx.js +0 -414
- package/dist/vendor-prosemirror-keymap-BbWvIWmH.js +0 -128
- package/dist/vendor-prosemirror-markdown-gB0PXBbz.js +0 -866
- package/dist/vendor-prosemirror-model-BZu3WVcD.js +0 -3463
- package/dist/vendor-prosemirror-schema-list-Bl9NpKA7.js +0 -158
- package/dist/vendor-prosemirror-state-BvL9Pxph.js +0 -1003
- package/dist/vendor-prosemirror-tables-17qAnviK.js +0 -2159
- package/dist/vendor-prosemirror-transform-CE9VV3qg.js +0 -2156
- package/dist/vendor-prosemirror-view-CU2WTHT7.js +0 -5811
- package/dist/vendor-punycode-js-iAs5RxMf.js +0 -441
- package/dist/vendor-rope-sequence-BdXDKoGt.js +0 -207
- package/dist/vendor-semver-CVLMK-S4.js +0 -2702
- package/dist/vendor-ssr-window-s6OpKa3O.js +0 -150
- package/dist/vendor-swiper-CdiyNHVt.js +0 -5679
- package/dist/vendor-tippy-js-DWFe2TfK.js +0 -1647
- package/dist/vendor-tiptap-core-NfwGfaQk.js +0 -4910
- package/dist/vendor-tiptap-extension-blockquote-jmWBTtsI.js +0 -57
- package/dist/vendor-tiptap-extension-bold-p5frh4ak.js +0 -97
- package/dist/vendor-tiptap-extension-bubble-menu-KUhZSfrs.js +0 -218
- package/dist/vendor-tiptap-extension-bullet-list-COmZRoSB.js +0 -73
- package/dist/vendor-tiptap-extension-code-block-DyTARZss.js +0 -221
- package/dist/vendor-tiptap-extension-code-jVv6CXpX.js +0 -75
- package/dist/vendor-tiptap-extension-document-DssuotYs.js +0 -13
- package/dist/vendor-tiptap-extension-dropcursor-BoO0Qv91.js +0 -26
- package/dist/vendor-tiptap-extension-floating-menu-CrO8CN5w.js +0 -165
- package/dist/vendor-tiptap-extension-gapcursor-KpsWEoMD.js +0 -30
- package/dist/vendor-tiptap-extension-hard-break-ldOzhSvf.js +0 -68
- package/dist/vendor-tiptap-extension-heading-CKz2llX0.js +0 -77
- package/dist/vendor-tiptap-extension-history-DeKZ2VQ9.js +0 -48
- package/dist/vendor-tiptap-extension-horizontal-rule-CAjWRyDS.js +0 -92
- package/dist/vendor-tiptap-extension-image-ZagcEYuk.js +0 -76
- package/dist/vendor-tiptap-extension-italic-CM4xdznY.js +0 -96
- package/dist/vendor-tiptap-extension-link-Z-AMC4Ri.js +0 -414
- package/dist/vendor-tiptap-extension-list-item-BJi5QpXc.js +0 -37
- package/dist/vendor-tiptap-extension-ordered-list-C_TMrfBE.js +0 -97
- package/dist/vendor-tiptap-extension-paragraph-CQw0E0Au.js +0 -39
- package/dist/vendor-tiptap-extension-placeholder-BBNVKfa_.js +0 -66
- package/dist/vendor-tiptap-extension-strike-DUyMYX1Z.js +0 -79
- package/dist/vendor-tiptap-extension-table-cell-CoDIMPA5.js +0 -47
- package/dist/vendor-tiptap-extension-table-header-DvbGHnmw.js +0 -47
- package/dist/vendor-tiptap-extension-table-row-D1uqN5Aj.js +0 -26
- package/dist/vendor-tiptap-extension-table-tKS4MOM4.js +0 -354
- package/dist/vendor-tiptap-extension-text-DtRBhKB2.js +0 -12
- package/dist/vendor-tiptap-extension-underline-DqaSFp_P.js +0 -50
- package/dist/vendor-tiptap-markdown-7-PCADTU.js +0 -1017
- package/dist/vendor-tiptap-starter-kit-CDSV_Zuu.js +0 -88
- package/dist/vendor-tiptap-vue-3-DZg2fjq_.js +0 -268
- package/dist/vendor-truncate-html-3qQY0Djo.js +0 -196
- package/dist/vendor-uc-micro-jjt6LQ65.js +0 -23
- package/dist/vendor-vee-validate-i18n-v_gHjRmD.js +0 -154
- package/dist/vendor-vee-validate-rules-DzV3VY3N.js +0 -536
- package/dist/vendor-vue-currency-input-DGAkEFBO.js +0 -545
- package/dist/vendor-vue-devtools-api-DXYR8qBG.js +0 -169
- package/dist/vendor-vue-i18n-Co752uk3.js +0 -1897
- package/dist/vendor-vue3-application-insights-CYWFCr_J.js +0 -119
- package/dist/vendor-vue3-touch-events-BJEAiSa3.js +0 -416
- package/dist/vendor-vuepic-vue-datepicker-BSWXRSiu.js +0 -5019
- package/dist/vendor-vueuse-components-l1bL12mE.js +0 -339
- package/dist/vendor-vueuse-core-DGcJOmwG.js +0 -7743
- package/dist/vendor-vueuse-shared-_mOXsFuM.js +0 -1568
- package/dist/vendor-w3c-keyname-BOm2dtJm.js +0 -121
|
@@ -1,1876 +0,0 @@
|
|
|
1
|
-
import { i as isArray, a as isPlainObject, b as isString, c as create, d as assign, e as isBoolean, f as isRegExp, g as isFunction, w as warnOnce, h as warn, j as isObject, k as hasOwn, l as format$1, m as getGlobalThis, n as isNumber, o as isEmptyObject, p as isDate, q as escapeHtml, r as inBrowser, s as mark, t as measure, u as join, v as toDisplayString, x as isPromise, y as generateFormatCacheKey, z as generateCodeFrame } from './vendor-intlify-shared-Cz4YRMuC.js';
|
|
2
|
-
import { c as createCompileError, C as COMPILE_ERROR_CODES_EXTEND_POINT, d as detectHtmlTag, a as defaultOnError, b as baseCompile$1 } from './vendor-intlify-message-compiler-CuOQDWx1.js';
|
|
3
|
-
|
|
4
|
-
/*!
|
|
5
|
-
* core-base v11.1.7
|
|
6
|
-
* (c) 2025 kazuya kawaguchi
|
|
7
|
-
* Released under the MIT License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This is only called in esm-bundler builds.
|
|
12
|
-
* istanbul-ignore-next
|
|
13
|
-
*/
|
|
14
|
-
function initFeatureFlags() {
|
|
15
|
-
if (typeof __INTLIFY_PROD_DEVTOOLS__ !== 'boolean') {
|
|
16
|
-
getGlobalThis().__INTLIFY_PROD_DEVTOOLS__ = false;
|
|
17
|
-
}
|
|
18
|
-
if (typeof __INTLIFY_DROP_MESSAGE_COMPILER__ !== 'boolean') {
|
|
19
|
-
getGlobalThis().__INTLIFY_DROP_MESSAGE_COMPILER__ = false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function isMessageAST(val) {
|
|
24
|
-
return (isObject(val) &&
|
|
25
|
-
resolveType(val) === 0 &&
|
|
26
|
-
(hasOwn(val, 'b') || hasOwn(val, 'body')));
|
|
27
|
-
}
|
|
28
|
-
const PROPS_BODY = ['b', 'body'];
|
|
29
|
-
function resolveBody(node) {
|
|
30
|
-
return resolveProps(node, PROPS_BODY);
|
|
31
|
-
}
|
|
32
|
-
const PROPS_CASES = ['c', 'cases'];
|
|
33
|
-
function resolveCases(node) {
|
|
34
|
-
return resolveProps(node, PROPS_CASES, []);
|
|
35
|
-
}
|
|
36
|
-
const PROPS_STATIC = ['s', 'static'];
|
|
37
|
-
function resolveStatic(node) {
|
|
38
|
-
return resolveProps(node, PROPS_STATIC);
|
|
39
|
-
}
|
|
40
|
-
const PROPS_ITEMS = ['i', 'items'];
|
|
41
|
-
function resolveItems(node) {
|
|
42
|
-
return resolveProps(node, PROPS_ITEMS, []);
|
|
43
|
-
}
|
|
44
|
-
const PROPS_TYPE = ['t', 'type'];
|
|
45
|
-
function resolveType(node) {
|
|
46
|
-
return resolveProps(node, PROPS_TYPE);
|
|
47
|
-
}
|
|
48
|
-
const PROPS_VALUE = ['v', 'value'];
|
|
49
|
-
function resolveValue$1(node, type) {
|
|
50
|
-
const resolved = resolveProps(node, PROPS_VALUE);
|
|
51
|
-
if (resolved != null) {
|
|
52
|
-
return resolved;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
throw createUnhandleNodeError(type);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const PROPS_MODIFIER = ['m', 'modifier'];
|
|
59
|
-
function resolveLinkedModifier(node) {
|
|
60
|
-
return resolveProps(node, PROPS_MODIFIER);
|
|
61
|
-
}
|
|
62
|
-
const PROPS_KEY = ['k', 'key'];
|
|
63
|
-
function resolveLinkedKey(node) {
|
|
64
|
-
const resolved = resolveProps(node, PROPS_KEY);
|
|
65
|
-
if (resolved) {
|
|
66
|
-
return resolved;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
throw createUnhandleNodeError(6 /* NodeTypes.Linked */);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function resolveProps(node, props, defaultValue) {
|
|
73
|
-
for (let i = 0; i < props.length; i++) {
|
|
74
|
-
const prop = props[i];
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
-
if (hasOwn(node, prop) && node[prop] != null) {
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
-
return node[prop];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return defaultValue;
|
|
82
|
-
}
|
|
83
|
-
const AST_NODE_PROPS_KEYS = [
|
|
84
|
-
...PROPS_BODY,
|
|
85
|
-
...PROPS_CASES,
|
|
86
|
-
...PROPS_STATIC,
|
|
87
|
-
...PROPS_ITEMS,
|
|
88
|
-
...PROPS_KEY,
|
|
89
|
-
...PROPS_MODIFIER,
|
|
90
|
-
...PROPS_VALUE,
|
|
91
|
-
...PROPS_TYPE
|
|
92
|
-
];
|
|
93
|
-
function createUnhandleNodeError(type) {
|
|
94
|
-
return new Error(`unhandled node type: ${type}`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function format(ast) {
|
|
98
|
-
const msg = (ctx) => formatParts(ctx, ast);
|
|
99
|
-
return msg;
|
|
100
|
-
}
|
|
101
|
-
function formatParts(ctx, ast) {
|
|
102
|
-
const body = resolveBody(ast);
|
|
103
|
-
if (body == null) {
|
|
104
|
-
throw createUnhandleNodeError(0 /* NodeTypes.Resource */);
|
|
105
|
-
}
|
|
106
|
-
const type = resolveType(body);
|
|
107
|
-
if (type === 1 /* NodeTypes.Plural */) {
|
|
108
|
-
const plural = body;
|
|
109
|
-
const cases = resolveCases(plural);
|
|
110
|
-
return ctx.plural(cases.reduce((messages, c) => [
|
|
111
|
-
...messages,
|
|
112
|
-
formatMessageParts(ctx, c)
|
|
113
|
-
], []));
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
return formatMessageParts(ctx, body);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function formatMessageParts(ctx, node) {
|
|
120
|
-
const static_ = resolveStatic(node);
|
|
121
|
-
if (static_ != null) {
|
|
122
|
-
return ctx.type === 'text'
|
|
123
|
-
? static_
|
|
124
|
-
: ctx.normalize([static_]);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []);
|
|
128
|
-
return ctx.normalize(messages);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function formatMessagePart(ctx, node) {
|
|
132
|
-
const type = resolveType(node);
|
|
133
|
-
switch (type) {
|
|
134
|
-
case 3 /* NodeTypes.Text */: {
|
|
135
|
-
return resolveValue$1(node, type);
|
|
136
|
-
}
|
|
137
|
-
case 9 /* NodeTypes.Literal */: {
|
|
138
|
-
return resolveValue$1(node, type);
|
|
139
|
-
}
|
|
140
|
-
case 4 /* NodeTypes.Named */: {
|
|
141
|
-
const named = node;
|
|
142
|
-
if (hasOwn(named, 'k') && named.k) {
|
|
143
|
-
return ctx.interpolate(ctx.named(named.k));
|
|
144
|
-
}
|
|
145
|
-
if (hasOwn(named, 'key') && named.key) {
|
|
146
|
-
return ctx.interpolate(ctx.named(named.key));
|
|
147
|
-
}
|
|
148
|
-
throw createUnhandleNodeError(type);
|
|
149
|
-
}
|
|
150
|
-
case 5 /* NodeTypes.List */: {
|
|
151
|
-
const list = node;
|
|
152
|
-
if (hasOwn(list, 'i') && isNumber(list.i)) {
|
|
153
|
-
return ctx.interpolate(ctx.list(list.i));
|
|
154
|
-
}
|
|
155
|
-
if (hasOwn(list, 'index') && isNumber(list.index)) {
|
|
156
|
-
return ctx.interpolate(ctx.list(list.index));
|
|
157
|
-
}
|
|
158
|
-
throw createUnhandleNodeError(type);
|
|
159
|
-
}
|
|
160
|
-
case 6 /* NodeTypes.Linked */: {
|
|
161
|
-
const linked = node;
|
|
162
|
-
const modifier = resolveLinkedModifier(linked);
|
|
163
|
-
const key = resolveLinkedKey(linked);
|
|
164
|
-
return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : undefined, ctx.type);
|
|
165
|
-
}
|
|
166
|
-
case 7 /* NodeTypes.LinkedKey */: {
|
|
167
|
-
return resolveValue$1(node, type);
|
|
168
|
-
}
|
|
169
|
-
case 8 /* NodeTypes.LinkedModifier */: {
|
|
170
|
-
return resolveValue$1(node, type);
|
|
171
|
-
}
|
|
172
|
-
default:
|
|
173
|
-
throw new Error(`unhandled node on format message part: ${type}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const WARN_MESSAGE = `Detected HTML in '{source}' message. Recommend not using HTML messages to avoid XSS.`;
|
|
178
|
-
function checkHtmlMessage(source, warnHtmlMessage) {
|
|
179
|
-
if (warnHtmlMessage && detectHtmlTag(source)) {
|
|
180
|
-
warn(format$1(WARN_MESSAGE, { source }));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const defaultOnCacheKey = (message) => message;
|
|
184
|
-
let compileCache = create();
|
|
185
|
-
function baseCompile(message, options = {}) {
|
|
186
|
-
// error detecting on compile
|
|
187
|
-
let detectError = false;
|
|
188
|
-
const onError = options.onError || defaultOnError;
|
|
189
|
-
options.onError = (err) => {
|
|
190
|
-
detectError = true;
|
|
191
|
-
onError(err);
|
|
192
|
-
};
|
|
193
|
-
// compile with mesasge-compiler
|
|
194
|
-
return { ...baseCompile$1(message, options), detectError };
|
|
195
|
-
}
|
|
196
|
-
/* #__NO_SIDE_EFFECTS__ */
|
|
197
|
-
function compile(message, context) {
|
|
198
|
-
if ((!__INTLIFY_DROP_MESSAGE_COMPILER__) &&
|
|
199
|
-
isString(message)) {
|
|
200
|
-
// check HTML message
|
|
201
|
-
const warnHtmlMessage = isBoolean(context.warnHtmlMessage)
|
|
202
|
-
? context.warnHtmlMessage
|
|
203
|
-
: true;
|
|
204
|
-
(process.env.NODE_ENV !== 'production') && checkHtmlMessage(message, warnHtmlMessage);
|
|
205
|
-
// check caches
|
|
206
|
-
const onCacheKey = context.onCacheKey || defaultOnCacheKey;
|
|
207
|
-
const cacheKey = onCacheKey(message);
|
|
208
|
-
const cached = compileCache[cacheKey];
|
|
209
|
-
if (cached) {
|
|
210
|
-
return cached;
|
|
211
|
-
}
|
|
212
|
-
// compile with JIT mode
|
|
213
|
-
const { ast, detectError } = baseCompile(message, {
|
|
214
|
-
...context,
|
|
215
|
-
location: (process.env.NODE_ENV !== 'production'),
|
|
216
|
-
jit: true
|
|
217
|
-
});
|
|
218
|
-
// compose message function from AST
|
|
219
|
-
const msg = format(ast);
|
|
220
|
-
// if occurred compile error, don't cache
|
|
221
|
-
return !detectError
|
|
222
|
-
? (compileCache[cacheKey] = msg)
|
|
223
|
-
: msg;
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
if ((process.env.NODE_ENV !== 'production') && !isMessageAST(message)) {
|
|
227
|
-
warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`);
|
|
228
|
-
return (() => message);
|
|
229
|
-
}
|
|
230
|
-
// AST case (passed from bundler)
|
|
231
|
-
const cacheKey = message.cacheKey;
|
|
232
|
-
if (cacheKey) {
|
|
233
|
-
const cached = compileCache[cacheKey];
|
|
234
|
-
if (cached) {
|
|
235
|
-
return cached;
|
|
236
|
-
}
|
|
237
|
-
// compose message function from message (AST)
|
|
238
|
-
return (compileCache[cacheKey] =
|
|
239
|
-
format(message));
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
return format(message);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
let devtools = null;
|
|
248
|
-
function setDevToolsHook(hook) {
|
|
249
|
-
devtools = hook;
|
|
250
|
-
}
|
|
251
|
-
function initI18nDevTools(i18n, version, meta) {
|
|
252
|
-
// TODO: queue if devtools is undefined
|
|
253
|
-
devtools &&
|
|
254
|
-
devtools.emit('i18n:init', {
|
|
255
|
-
timestamp: Date.now(),
|
|
256
|
-
i18n,
|
|
257
|
-
version,
|
|
258
|
-
meta
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
const translateDevTools =
|
|
262
|
-
/* #__PURE__*/ createDevToolsHook('function:translate');
|
|
263
|
-
function createDevToolsHook(hook) {
|
|
264
|
-
return (payloads) => devtools && devtools.emit(hook, payloads);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const CoreErrorCodes = {
|
|
268
|
-
INVALID_ARGUMENT: COMPILE_ERROR_CODES_EXTEND_POINT, // 17
|
|
269
|
-
INVALID_DATE_ARGUMENT: 18,
|
|
270
|
-
INVALID_ISO_DATE_ARGUMENT: 19,
|
|
271
|
-
NOT_SUPPORT_NON_STRING_MESSAGE: 20,
|
|
272
|
-
NOT_SUPPORT_LOCALE_PROMISE_VALUE: 21,
|
|
273
|
-
NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 22,
|
|
274
|
-
NOT_SUPPORT_LOCALE_TYPE: 23
|
|
275
|
-
};
|
|
276
|
-
const CORE_ERROR_CODES_EXTEND_POINT = 24;
|
|
277
|
-
function createCoreError(code) {
|
|
278
|
-
return createCompileError(code, null, (process.env.NODE_ENV !== 'production') ? { messages: errorMessages } : undefined);
|
|
279
|
-
}
|
|
280
|
-
/** @internal */
|
|
281
|
-
const errorMessages = {
|
|
282
|
-
[CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments',
|
|
283
|
-
[CoreErrorCodes.INVALID_DATE_ARGUMENT]: 'The date provided is an invalid Date object.' +
|
|
284
|
-
'Make sure your Date represents a valid date.',
|
|
285
|
-
[CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: 'The argument provided is not a valid ISO date string',
|
|
286
|
-
[CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: 'Not support non-string message',
|
|
287
|
-
[CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: 'cannot support promise value',
|
|
288
|
-
[CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: 'cannot support async function',
|
|
289
|
-
[CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type'
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
/** @internal */
|
|
293
|
-
function getLocale(context, options) {
|
|
294
|
-
return options.locale != null
|
|
295
|
-
? resolveLocale(options.locale)
|
|
296
|
-
: resolveLocale(context.locale);
|
|
297
|
-
}
|
|
298
|
-
let _resolveLocale;
|
|
299
|
-
/** @internal */
|
|
300
|
-
function resolveLocale(locale) {
|
|
301
|
-
if (isString(locale)) {
|
|
302
|
-
return locale;
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
if (isFunction(locale)) {
|
|
306
|
-
if (locale.resolvedOnce && _resolveLocale != null) {
|
|
307
|
-
return _resolveLocale;
|
|
308
|
-
}
|
|
309
|
-
else if (locale.constructor.name === 'Function') {
|
|
310
|
-
const resolve = locale();
|
|
311
|
-
if (isPromise(resolve)) {
|
|
312
|
-
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);
|
|
313
|
-
}
|
|
314
|
-
return (_resolveLocale = resolve);
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Fallback with simple implemenation
|
|
327
|
-
*
|
|
328
|
-
* @remarks
|
|
329
|
-
* A fallback locale function implemented with a simple fallback algorithm.
|
|
330
|
-
*
|
|
331
|
-
* Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify.
|
|
332
|
-
*
|
|
333
|
-
* @param ctx - A {@link CoreContext | context}
|
|
334
|
-
* @param fallback - A {@link FallbackLocale | fallback locale}
|
|
335
|
-
* @param start - A starting {@link Locale | locale}
|
|
336
|
-
*
|
|
337
|
-
* @returns Fallback locales
|
|
338
|
-
*
|
|
339
|
-
* @VueI18nGeneral
|
|
340
|
-
*/
|
|
341
|
-
function fallbackWithSimple(ctx, fallback, start) {
|
|
342
|
-
// prettier-ignore
|
|
343
|
-
return [...new Set([
|
|
344
|
-
start,
|
|
345
|
-
...(isArray(fallback)
|
|
346
|
-
? fallback
|
|
347
|
-
: isObject(fallback)
|
|
348
|
-
? Object.keys(fallback)
|
|
349
|
-
: isString(fallback)
|
|
350
|
-
? [fallback]
|
|
351
|
-
: [start])
|
|
352
|
-
])];
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Fallback with locale chain
|
|
356
|
-
*
|
|
357
|
-
* @remarks
|
|
358
|
-
* A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default.
|
|
359
|
-
*
|
|
360
|
-
* @param ctx - A {@link CoreContext | context}
|
|
361
|
-
* @param fallback - A {@link FallbackLocale | fallback locale}
|
|
362
|
-
* @param start - A starting {@link Locale | locale}
|
|
363
|
-
*
|
|
364
|
-
* @returns Fallback locales
|
|
365
|
-
*
|
|
366
|
-
* @VueI18nSee [Fallbacking](../guide/essentials/fallback)
|
|
367
|
-
*
|
|
368
|
-
* @VueI18nGeneral
|
|
369
|
-
*/
|
|
370
|
-
function fallbackWithLocaleChain(ctx, fallback, start) {
|
|
371
|
-
const startLocale = isString(start) ? start : DEFAULT_LOCALE;
|
|
372
|
-
const context = ctx;
|
|
373
|
-
if (!context.__localeChainCache) {
|
|
374
|
-
context.__localeChainCache = new Map();
|
|
375
|
-
}
|
|
376
|
-
let chain = context.__localeChainCache.get(startLocale);
|
|
377
|
-
if (!chain) {
|
|
378
|
-
chain = [];
|
|
379
|
-
// first block defined by start
|
|
380
|
-
let block = [start];
|
|
381
|
-
// while any intervening block found
|
|
382
|
-
while (isArray(block)) {
|
|
383
|
-
block = appendBlockToChain(chain, block, fallback);
|
|
384
|
-
}
|
|
385
|
-
// prettier-ignore
|
|
386
|
-
// last block defined by default
|
|
387
|
-
const defaults = isArray(fallback) || !isPlainObject(fallback)
|
|
388
|
-
? fallback
|
|
389
|
-
: fallback['default']
|
|
390
|
-
? fallback['default']
|
|
391
|
-
: null;
|
|
392
|
-
// convert defaults to array
|
|
393
|
-
block = isString(defaults) ? [defaults] : defaults;
|
|
394
|
-
if (isArray(block)) {
|
|
395
|
-
appendBlockToChain(chain, block, false);
|
|
396
|
-
}
|
|
397
|
-
context.__localeChainCache.set(startLocale, chain);
|
|
398
|
-
}
|
|
399
|
-
return chain;
|
|
400
|
-
}
|
|
401
|
-
function appendBlockToChain(chain, block, blocks) {
|
|
402
|
-
let follow = true;
|
|
403
|
-
for (let i = 0; i < block.length && isBoolean(follow); i++) {
|
|
404
|
-
const locale = block[i];
|
|
405
|
-
if (isString(locale)) {
|
|
406
|
-
follow = appendLocaleToChain(chain, block[i], blocks);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
return follow;
|
|
410
|
-
}
|
|
411
|
-
function appendLocaleToChain(chain, locale, blocks) {
|
|
412
|
-
let follow;
|
|
413
|
-
const tokens = locale.split('-');
|
|
414
|
-
do {
|
|
415
|
-
const target = tokens.join('-');
|
|
416
|
-
follow = appendItemToChain(chain, target, blocks);
|
|
417
|
-
tokens.splice(-1, 1);
|
|
418
|
-
} while (tokens.length && follow === true);
|
|
419
|
-
return follow;
|
|
420
|
-
}
|
|
421
|
-
function appendItemToChain(chain, target, blocks) {
|
|
422
|
-
let follow = false;
|
|
423
|
-
if (!chain.includes(target)) {
|
|
424
|
-
follow = true;
|
|
425
|
-
if (target) {
|
|
426
|
-
follow = target[target.length - 1] !== '!';
|
|
427
|
-
const locale = target.replace(/!/g, '');
|
|
428
|
-
chain.push(locale);
|
|
429
|
-
if ((isArray(blocks) || isPlainObject(blocks)) &&
|
|
430
|
-
blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
431
|
-
) {
|
|
432
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
433
|
-
follow = blocks[locale];
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
return follow;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
const pathStateMachine = [];
|
|
441
|
-
pathStateMachine[0 /* States.BEFORE_PATH */] = {
|
|
442
|
-
["w" /* PathCharTypes.WORKSPACE */]: [0 /* States.BEFORE_PATH */],
|
|
443
|
-
["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
|
|
444
|
-
["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */],
|
|
445
|
-
["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */]
|
|
446
|
-
};
|
|
447
|
-
pathStateMachine[1 /* States.IN_PATH */] = {
|
|
448
|
-
["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */],
|
|
449
|
-
["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */],
|
|
450
|
-
["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */],
|
|
451
|
-
["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */]
|
|
452
|
-
};
|
|
453
|
-
pathStateMachine[2 /* States.BEFORE_IDENT */] = {
|
|
454
|
-
["w" /* PathCharTypes.WORKSPACE */]: [2 /* States.BEFORE_IDENT */],
|
|
455
|
-
["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
|
|
456
|
-
["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */]
|
|
457
|
-
};
|
|
458
|
-
pathStateMachine[3 /* States.IN_IDENT */] = {
|
|
459
|
-
["i" /* PathCharTypes.IDENT */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
|
|
460
|
-
["0" /* PathCharTypes.ZERO */]: [3 /* States.IN_IDENT */, 0 /* Actions.APPEND */],
|
|
461
|
-
["w" /* PathCharTypes.WORKSPACE */]: [1 /* States.IN_PATH */, 1 /* Actions.PUSH */],
|
|
462
|
-
["." /* PathCharTypes.DOT */]: [2 /* States.BEFORE_IDENT */, 1 /* Actions.PUSH */],
|
|
463
|
-
["[" /* PathCharTypes.LEFT_BRACKET */]: [4 /* States.IN_SUB_PATH */, 1 /* Actions.PUSH */],
|
|
464
|
-
["o" /* PathCharTypes.END_OF_FAIL */]: [7 /* States.AFTER_PATH */, 1 /* Actions.PUSH */]
|
|
465
|
-
};
|
|
466
|
-
pathStateMachine[4 /* States.IN_SUB_PATH */] = {
|
|
467
|
-
["'" /* PathCharTypes.SINGLE_QUOTE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */],
|
|
468
|
-
["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */],
|
|
469
|
-
["[" /* PathCharTypes.LEFT_BRACKET */]: [
|
|
470
|
-
4 /* States.IN_SUB_PATH */,
|
|
471
|
-
2 /* Actions.INC_SUB_PATH_DEPTH */
|
|
472
|
-
],
|
|
473
|
-
["]" /* PathCharTypes.RIGHT_BRACKET */]: [1 /* States.IN_PATH */, 3 /* Actions.PUSH_SUB_PATH */],
|
|
474
|
-
["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */,
|
|
475
|
-
["l" /* PathCharTypes.ELSE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */]
|
|
476
|
-
};
|
|
477
|
-
pathStateMachine[5 /* States.IN_SINGLE_QUOTE */] = {
|
|
478
|
-
["'" /* PathCharTypes.SINGLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */],
|
|
479
|
-
["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */,
|
|
480
|
-
["l" /* PathCharTypes.ELSE */]: [5 /* States.IN_SINGLE_QUOTE */, 0 /* Actions.APPEND */]
|
|
481
|
-
};
|
|
482
|
-
pathStateMachine[6 /* States.IN_DOUBLE_QUOTE */] = {
|
|
483
|
-
["\"" /* PathCharTypes.DOUBLE_QUOTE */]: [4 /* States.IN_SUB_PATH */, 0 /* Actions.APPEND */],
|
|
484
|
-
["o" /* PathCharTypes.END_OF_FAIL */]: 8 /* States.ERROR */,
|
|
485
|
-
["l" /* PathCharTypes.ELSE */]: [6 /* States.IN_DOUBLE_QUOTE */, 0 /* Actions.APPEND */]
|
|
486
|
-
};
|
|
487
|
-
/**
|
|
488
|
-
* Check if an expression is a literal value.
|
|
489
|
-
*/
|
|
490
|
-
const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
|
|
491
|
-
function isLiteral(exp) {
|
|
492
|
-
return literalValueRE.test(exp);
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Strip quotes from a string
|
|
496
|
-
*/
|
|
497
|
-
function stripQuotes(str) {
|
|
498
|
-
const a = str.charCodeAt(0);
|
|
499
|
-
const b = str.charCodeAt(str.length - 1);
|
|
500
|
-
return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str;
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Determine the type of a character in a keypath.
|
|
504
|
-
*/
|
|
505
|
-
function getPathCharType(ch) {
|
|
506
|
-
if (ch === undefined || ch === null) {
|
|
507
|
-
return "o" /* PathCharTypes.END_OF_FAIL */;
|
|
508
|
-
}
|
|
509
|
-
const code = ch.charCodeAt(0);
|
|
510
|
-
switch (code) {
|
|
511
|
-
case 0x5b: // [
|
|
512
|
-
case 0x5d: // ]
|
|
513
|
-
case 0x2e: // .
|
|
514
|
-
case 0x22: // "
|
|
515
|
-
case 0x27: // '
|
|
516
|
-
return ch;
|
|
517
|
-
case 0x5f: // _
|
|
518
|
-
case 0x24: // $
|
|
519
|
-
case 0x2d: // -
|
|
520
|
-
return "i" /* PathCharTypes.IDENT */;
|
|
521
|
-
case 0x09: // Tab (HT)
|
|
522
|
-
case 0x0a: // Newline (LF)
|
|
523
|
-
case 0x0d: // Return (CR)
|
|
524
|
-
case 0xa0: // No-break space (NBSP)
|
|
525
|
-
case 0xfeff: // Byte Order Mark (BOM)
|
|
526
|
-
case 0x2028: // Line Separator (LS)
|
|
527
|
-
case 0x2029: // Paragraph Separator (PS)
|
|
528
|
-
return "w" /* PathCharTypes.WORKSPACE */;
|
|
529
|
-
}
|
|
530
|
-
return "i" /* PathCharTypes.IDENT */;
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Format a subPath, return its plain form if it is
|
|
534
|
-
* a literal string or number. Otherwise prepend the
|
|
535
|
-
* dynamic indicator (*).
|
|
536
|
-
*/
|
|
537
|
-
function formatSubPath(path) {
|
|
538
|
-
const trimmed = path.trim();
|
|
539
|
-
// invalid leading 0
|
|
540
|
-
if (path.charAt(0) === '0' && isNaN(parseInt(path))) {
|
|
541
|
-
return false;
|
|
542
|
-
}
|
|
543
|
-
return isLiteral(trimmed)
|
|
544
|
-
? stripQuotes(trimmed)
|
|
545
|
-
: "*" /* PathCharTypes.ASTARISK */ + trimmed;
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Parse a string path into an array of segments
|
|
549
|
-
*/
|
|
550
|
-
function parse(path) {
|
|
551
|
-
const keys = [];
|
|
552
|
-
let index = -1;
|
|
553
|
-
let mode = 0 /* States.BEFORE_PATH */;
|
|
554
|
-
let subPathDepth = 0;
|
|
555
|
-
let c;
|
|
556
|
-
let key; // eslint-disable-line
|
|
557
|
-
let newChar;
|
|
558
|
-
let type;
|
|
559
|
-
let transition;
|
|
560
|
-
let action;
|
|
561
|
-
let typeMap;
|
|
562
|
-
const actions = [];
|
|
563
|
-
actions[0 /* Actions.APPEND */] = () => {
|
|
564
|
-
if (key === undefined) {
|
|
565
|
-
key = newChar;
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
key += newChar;
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
actions[1 /* Actions.PUSH */] = () => {
|
|
572
|
-
if (key !== undefined) {
|
|
573
|
-
keys.push(key);
|
|
574
|
-
key = undefined;
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
actions[2 /* Actions.INC_SUB_PATH_DEPTH */] = () => {
|
|
578
|
-
actions[0 /* Actions.APPEND */]();
|
|
579
|
-
subPathDepth++;
|
|
580
|
-
};
|
|
581
|
-
actions[3 /* Actions.PUSH_SUB_PATH */] = () => {
|
|
582
|
-
if (subPathDepth > 0) {
|
|
583
|
-
subPathDepth--;
|
|
584
|
-
mode = 4 /* States.IN_SUB_PATH */;
|
|
585
|
-
actions[0 /* Actions.APPEND */]();
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
subPathDepth = 0;
|
|
589
|
-
if (key === undefined) {
|
|
590
|
-
return false;
|
|
591
|
-
}
|
|
592
|
-
key = formatSubPath(key);
|
|
593
|
-
if (key === false) {
|
|
594
|
-
return false;
|
|
595
|
-
}
|
|
596
|
-
else {
|
|
597
|
-
actions[1 /* Actions.PUSH */]();
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
function maybeUnescapeQuote() {
|
|
602
|
-
const nextChar = path[index + 1];
|
|
603
|
-
if ((mode === 5 /* States.IN_SINGLE_QUOTE */ &&
|
|
604
|
-
nextChar === "'" /* PathCharTypes.SINGLE_QUOTE */) ||
|
|
605
|
-
(mode === 6 /* States.IN_DOUBLE_QUOTE */ &&
|
|
606
|
-
nextChar === "\"" /* PathCharTypes.DOUBLE_QUOTE */)) {
|
|
607
|
-
index++;
|
|
608
|
-
newChar = '\\' + nextChar;
|
|
609
|
-
actions[0 /* Actions.APPEND */]();
|
|
610
|
-
return true;
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
while (mode !== null) {
|
|
614
|
-
index++;
|
|
615
|
-
c = path[index];
|
|
616
|
-
if (c === '\\' && maybeUnescapeQuote()) {
|
|
617
|
-
continue;
|
|
618
|
-
}
|
|
619
|
-
type = getPathCharType(c);
|
|
620
|
-
typeMap = pathStateMachine[mode];
|
|
621
|
-
transition = typeMap[type] || typeMap["l" /* PathCharTypes.ELSE */] || 8 /* States.ERROR */;
|
|
622
|
-
// check parse error
|
|
623
|
-
if (transition === 8 /* States.ERROR */) {
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
mode = transition[0];
|
|
627
|
-
if (transition[1] !== undefined) {
|
|
628
|
-
action = actions[transition[1]];
|
|
629
|
-
if (action) {
|
|
630
|
-
newChar = c;
|
|
631
|
-
if (action() === false) {
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
// check parse finish
|
|
637
|
-
if (mode === 7 /* States.AFTER_PATH */) {
|
|
638
|
-
return keys;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
// path token cache
|
|
643
|
-
const cache = new Map();
|
|
644
|
-
/**
|
|
645
|
-
* key-value message resolver
|
|
646
|
-
*
|
|
647
|
-
* @remarks
|
|
648
|
-
* Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved
|
|
649
|
-
*
|
|
650
|
-
* @param obj - A target object to be resolved with path
|
|
651
|
-
* @param path - A {@link Path | path} to resolve the value of message
|
|
652
|
-
*
|
|
653
|
-
* @returns A resolved {@link PathValue | path value}
|
|
654
|
-
*
|
|
655
|
-
* @VueI18nGeneral
|
|
656
|
-
*/
|
|
657
|
-
function resolveWithKeyValue(obj, path) {
|
|
658
|
-
return isObject(obj) ? obj[path] : null;
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* message resolver
|
|
662
|
-
*
|
|
663
|
-
* @remarks
|
|
664
|
-
* Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default.
|
|
665
|
-
*
|
|
666
|
-
* @param obj - A target object to be resolved with path
|
|
667
|
-
* @param path - A {@link Path | path} to resolve the value of message
|
|
668
|
-
*
|
|
669
|
-
* @returns A resolved {@link PathValue | path value}
|
|
670
|
-
*
|
|
671
|
-
* @VueI18nGeneral
|
|
672
|
-
*/
|
|
673
|
-
function resolveValue(obj, path) {
|
|
674
|
-
// check object
|
|
675
|
-
if (!isObject(obj)) {
|
|
676
|
-
return null;
|
|
677
|
-
}
|
|
678
|
-
// parse path
|
|
679
|
-
let hit = cache.get(path);
|
|
680
|
-
if (!hit) {
|
|
681
|
-
hit = parse(path);
|
|
682
|
-
if (hit) {
|
|
683
|
-
cache.set(path, hit);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
// check hit
|
|
687
|
-
if (!hit) {
|
|
688
|
-
return null;
|
|
689
|
-
}
|
|
690
|
-
// resolve path value
|
|
691
|
-
const len = hit.length;
|
|
692
|
-
let last = obj;
|
|
693
|
-
let i = 0;
|
|
694
|
-
while (i < len) {
|
|
695
|
-
const key = hit[i];
|
|
696
|
-
/**
|
|
697
|
-
* NOTE:
|
|
698
|
-
* if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it.
|
|
699
|
-
* because the AST node is not a key-value structure.
|
|
700
|
-
*/
|
|
701
|
-
if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) {
|
|
702
|
-
return null;
|
|
703
|
-
}
|
|
704
|
-
const val = last[key];
|
|
705
|
-
if (val === undefined) {
|
|
706
|
-
return null;
|
|
707
|
-
}
|
|
708
|
-
if (isFunction(last)) {
|
|
709
|
-
return null;
|
|
710
|
-
}
|
|
711
|
-
last = val;
|
|
712
|
-
i++;
|
|
713
|
-
}
|
|
714
|
-
return last;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
const CoreWarnCodes = {
|
|
718
|
-
NOT_FOUND_KEY: 1,
|
|
719
|
-
FALLBACK_TO_TRANSLATE: 2,
|
|
720
|
-
CANNOT_FORMAT_NUMBER: 3,
|
|
721
|
-
FALLBACK_TO_NUMBER_FORMAT: 4,
|
|
722
|
-
CANNOT_FORMAT_DATE: 5,
|
|
723
|
-
FALLBACK_TO_DATE_FORMAT: 6,
|
|
724
|
-
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: 7
|
|
725
|
-
};
|
|
726
|
-
const CORE_WARN_CODES_EXTEND_POINT = 8;
|
|
727
|
-
/** @internal */
|
|
728
|
-
const warnMessages = {
|
|
729
|
-
[CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`,
|
|
730
|
-
[CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`,
|
|
731
|
-
[CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
|
|
732
|
-
[CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`,
|
|
733
|
-
[CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
|
|
734
|
-
[CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`,
|
|
735
|
-
[CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.`
|
|
736
|
-
};
|
|
737
|
-
function getWarnMessage(code, ...args) {
|
|
738
|
-
return format$1(warnMessages[code], ...args);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
742
|
-
/**
|
|
743
|
-
* Intlify core-base version
|
|
744
|
-
* @internal
|
|
745
|
-
*/
|
|
746
|
-
const VERSION = '11.1.7';
|
|
747
|
-
const NOT_REOSLVED = -1;
|
|
748
|
-
const DEFAULT_LOCALE = 'en-US';
|
|
749
|
-
const MISSING_RESOLVE_VALUE = '';
|
|
750
|
-
const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`;
|
|
751
|
-
function getDefaultLinkedModifiers() {
|
|
752
|
-
return {
|
|
753
|
-
upper: (val, type) => {
|
|
754
|
-
// prettier-ignore
|
|
755
|
-
return type === 'text' && isString(val)
|
|
756
|
-
? val.toUpperCase()
|
|
757
|
-
: type === 'vnode' && isObject(val) && '__v_isVNode' in val
|
|
758
|
-
? val.children.toUpperCase()
|
|
759
|
-
: val;
|
|
760
|
-
},
|
|
761
|
-
lower: (val, type) => {
|
|
762
|
-
// prettier-ignore
|
|
763
|
-
return type === 'text' && isString(val)
|
|
764
|
-
? val.toLowerCase()
|
|
765
|
-
: type === 'vnode' && isObject(val) && '__v_isVNode' in val
|
|
766
|
-
? val.children.toLowerCase()
|
|
767
|
-
: val;
|
|
768
|
-
},
|
|
769
|
-
capitalize: (val, type) => {
|
|
770
|
-
// prettier-ignore
|
|
771
|
-
return (type === 'text' && isString(val)
|
|
772
|
-
? capitalize(val)
|
|
773
|
-
: type === 'vnode' && isObject(val) && '__v_isVNode' in val
|
|
774
|
-
? capitalize(val.children)
|
|
775
|
-
: val);
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
let _compiler;
|
|
780
|
-
function registerMessageCompiler(compiler) {
|
|
781
|
-
_compiler = compiler;
|
|
782
|
-
}
|
|
783
|
-
let _resolver;
|
|
784
|
-
/**
|
|
785
|
-
* Register the message resolver
|
|
786
|
-
*
|
|
787
|
-
* @param resolver - A {@link MessageResolver} function
|
|
788
|
-
*
|
|
789
|
-
* @VueI18nGeneral
|
|
790
|
-
*/
|
|
791
|
-
function registerMessageResolver(resolver) {
|
|
792
|
-
_resolver = resolver;
|
|
793
|
-
}
|
|
794
|
-
let _fallbacker;
|
|
795
|
-
/**
|
|
796
|
-
* Register the locale fallbacker
|
|
797
|
-
*
|
|
798
|
-
* @param fallbacker - A {@link LocaleFallbacker} function
|
|
799
|
-
*
|
|
800
|
-
* @VueI18nGeneral
|
|
801
|
-
*/
|
|
802
|
-
function registerLocaleFallbacker(fallbacker) {
|
|
803
|
-
_fallbacker = fallbacker;
|
|
804
|
-
}
|
|
805
|
-
// Additional Meta for Intlify DevTools
|
|
806
|
-
let _additionalMeta = null;
|
|
807
|
-
/* #__NO_SIDE_EFFECTS__ */
|
|
808
|
-
const setAdditionalMeta = (meta) => {
|
|
809
|
-
_additionalMeta = meta;
|
|
810
|
-
};
|
|
811
|
-
/* #__NO_SIDE_EFFECTS__ */
|
|
812
|
-
const getAdditionalMeta = () => _additionalMeta;
|
|
813
|
-
let _fallbackContext = null;
|
|
814
|
-
const setFallbackContext = (context) => {
|
|
815
|
-
_fallbackContext = context;
|
|
816
|
-
};
|
|
817
|
-
const getFallbackContext = () => _fallbackContext;
|
|
818
|
-
// ID for CoreContext
|
|
819
|
-
let _cid = 0;
|
|
820
|
-
function createCoreContext(options = {}) {
|
|
821
|
-
// setup options
|
|
822
|
-
const onWarn = isFunction(options.onWarn) ? options.onWarn : warn;
|
|
823
|
-
const version = isString(options.version) ? options.version : VERSION;
|
|
824
|
-
const locale = isString(options.locale) || isFunction(options.locale)
|
|
825
|
-
? options.locale
|
|
826
|
-
: DEFAULT_LOCALE;
|
|
827
|
-
const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale;
|
|
828
|
-
const fallbackLocale = isArray(options.fallbackLocale) ||
|
|
829
|
-
isPlainObject(options.fallbackLocale) ||
|
|
830
|
-
isString(options.fallbackLocale) ||
|
|
831
|
-
options.fallbackLocale === false
|
|
832
|
-
? options.fallbackLocale
|
|
833
|
-
: _locale;
|
|
834
|
-
const messages = isPlainObject(options.messages)
|
|
835
|
-
? options.messages
|
|
836
|
-
: createResources(_locale);
|
|
837
|
-
const datetimeFormats = isPlainObject(options.datetimeFormats)
|
|
838
|
-
? options.datetimeFormats
|
|
839
|
-
: createResources(_locale)
|
|
840
|
-
;
|
|
841
|
-
const numberFormats = isPlainObject(options.numberFormats)
|
|
842
|
-
? options.numberFormats
|
|
843
|
-
: createResources(_locale)
|
|
844
|
-
;
|
|
845
|
-
const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers());
|
|
846
|
-
const pluralRules = options.pluralRules || create();
|
|
847
|
-
const missing = isFunction(options.missing) ? options.missing : null;
|
|
848
|
-
const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn)
|
|
849
|
-
? options.missingWarn
|
|
850
|
-
: true;
|
|
851
|
-
const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn)
|
|
852
|
-
? options.fallbackWarn
|
|
853
|
-
: true;
|
|
854
|
-
const fallbackFormat = !!options.fallbackFormat;
|
|
855
|
-
const unresolving = !!options.unresolving;
|
|
856
|
-
const postTranslation = isFunction(options.postTranslation)
|
|
857
|
-
? options.postTranslation
|
|
858
|
-
: null;
|
|
859
|
-
const processor = isPlainObject(options.processor) ? options.processor : null;
|
|
860
|
-
const warnHtmlMessage = isBoolean(options.warnHtmlMessage)
|
|
861
|
-
? options.warnHtmlMessage
|
|
862
|
-
: true;
|
|
863
|
-
const escapeParameter = !!options.escapeParameter;
|
|
864
|
-
const messageCompiler = isFunction(options.messageCompiler)
|
|
865
|
-
? options.messageCompiler
|
|
866
|
-
: _compiler;
|
|
867
|
-
if ((process.env.NODE_ENV !== 'production') &&
|
|
868
|
-
true &&
|
|
869
|
-
true &&
|
|
870
|
-
isFunction(options.messageCompiler)) {
|
|
871
|
-
warnOnce(getWarnMessage(CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER));
|
|
872
|
-
}
|
|
873
|
-
const messageResolver = isFunction(options.messageResolver)
|
|
874
|
-
? options.messageResolver
|
|
875
|
-
: _resolver || resolveWithKeyValue;
|
|
876
|
-
const localeFallbacker = isFunction(options.localeFallbacker)
|
|
877
|
-
? options.localeFallbacker
|
|
878
|
-
: _fallbacker || fallbackWithSimple;
|
|
879
|
-
const fallbackContext = isObject(options.fallbackContext)
|
|
880
|
-
? options.fallbackContext
|
|
881
|
-
: undefined;
|
|
882
|
-
// setup internal options
|
|
883
|
-
const internalOptions = options;
|
|
884
|
-
const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters)
|
|
885
|
-
? internalOptions.__datetimeFormatters
|
|
886
|
-
: new Map()
|
|
887
|
-
;
|
|
888
|
-
const __numberFormatters = isObject(internalOptions.__numberFormatters)
|
|
889
|
-
? internalOptions.__numberFormatters
|
|
890
|
-
: new Map()
|
|
891
|
-
;
|
|
892
|
-
const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {};
|
|
893
|
-
_cid++;
|
|
894
|
-
const context = {
|
|
895
|
-
version,
|
|
896
|
-
cid: _cid,
|
|
897
|
-
locale,
|
|
898
|
-
fallbackLocale,
|
|
899
|
-
messages,
|
|
900
|
-
modifiers,
|
|
901
|
-
pluralRules,
|
|
902
|
-
missing,
|
|
903
|
-
missingWarn,
|
|
904
|
-
fallbackWarn,
|
|
905
|
-
fallbackFormat,
|
|
906
|
-
unresolving,
|
|
907
|
-
postTranslation,
|
|
908
|
-
processor,
|
|
909
|
-
warnHtmlMessage,
|
|
910
|
-
escapeParameter,
|
|
911
|
-
messageCompiler,
|
|
912
|
-
messageResolver,
|
|
913
|
-
localeFallbacker,
|
|
914
|
-
fallbackContext,
|
|
915
|
-
onWarn,
|
|
916
|
-
__meta
|
|
917
|
-
};
|
|
918
|
-
{
|
|
919
|
-
context.datetimeFormats = datetimeFormats;
|
|
920
|
-
context.numberFormats = numberFormats;
|
|
921
|
-
context.__datetimeFormatters = __datetimeFormatters;
|
|
922
|
-
context.__numberFormatters = __numberFormatters;
|
|
923
|
-
}
|
|
924
|
-
// for vue-devtools timeline event
|
|
925
|
-
if ((process.env.NODE_ENV !== 'production')) {
|
|
926
|
-
context.__v_emitter =
|
|
927
|
-
internalOptions.__v_emitter != null
|
|
928
|
-
? internalOptions.__v_emitter
|
|
929
|
-
: undefined;
|
|
930
|
-
}
|
|
931
|
-
// NOTE: experimental !!
|
|
932
|
-
if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) {
|
|
933
|
-
initI18nDevTools(context, version, __meta);
|
|
934
|
-
}
|
|
935
|
-
return context;
|
|
936
|
-
}
|
|
937
|
-
const createResources = (locale) => ({ [locale]: create() });
|
|
938
|
-
/** @internal */
|
|
939
|
-
function isTranslateFallbackWarn(fallback, key) {
|
|
940
|
-
return fallback instanceof RegExp ? fallback.test(key) : fallback;
|
|
941
|
-
}
|
|
942
|
-
/** @internal */
|
|
943
|
-
function isTranslateMissingWarn(missing, key) {
|
|
944
|
-
return missing instanceof RegExp ? missing.test(key) : missing;
|
|
945
|
-
}
|
|
946
|
-
/** @internal */
|
|
947
|
-
function handleMissing(context, key, locale, missingWarn, type) {
|
|
948
|
-
const { missing, onWarn } = context;
|
|
949
|
-
// for vue-devtools timeline event
|
|
950
|
-
if ((process.env.NODE_ENV !== 'production')) {
|
|
951
|
-
const emitter = context.__v_emitter;
|
|
952
|
-
if (emitter) {
|
|
953
|
-
emitter.emit('missing', {
|
|
954
|
-
locale,
|
|
955
|
-
key,
|
|
956
|
-
type,
|
|
957
|
-
groupId: `${type}:${key}`
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
if (missing !== null) {
|
|
962
|
-
const ret = missing(context, locale, key, type);
|
|
963
|
-
return isString(ret) ? ret : key;
|
|
964
|
-
}
|
|
965
|
-
else {
|
|
966
|
-
if ((process.env.NODE_ENV !== 'production') && isTranslateMissingWarn(missingWarn, key)) {
|
|
967
|
-
onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, { key, locale }));
|
|
968
|
-
}
|
|
969
|
-
return key;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
/** @internal */
|
|
973
|
-
function updateFallbackLocale(ctx, locale, fallback) {
|
|
974
|
-
const context = ctx;
|
|
975
|
-
context.__localeChainCache = new Map();
|
|
976
|
-
ctx.localeFallbacker(ctx, fallback, locale);
|
|
977
|
-
}
|
|
978
|
-
/** @internal */
|
|
979
|
-
function isAlmostSameLocale(locale, compareLocale) {
|
|
980
|
-
if (locale === compareLocale)
|
|
981
|
-
return false;
|
|
982
|
-
return locale.split('-')[0] === compareLocale.split('-')[0];
|
|
983
|
-
}
|
|
984
|
-
/** @internal */
|
|
985
|
-
function isImplicitFallback(targetLocale, locales) {
|
|
986
|
-
const index = locales.indexOf(targetLocale);
|
|
987
|
-
if (index === -1) {
|
|
988
|
-
return false;
|
|
989
|
-
}
|
|
990
|
-
for (let i = index + 1; i < locales.length; i++) {
|
|
991
|
-
if (isAlmostSameLocale(targetLocale, locales[i])) {
|
|
992
|
-
return true;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
return false;
|
|
996
|
-
}
|
|
997
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
998
|
-
|
|
999
|
-
const intlDefined = typeof Intl !== 'undefined';
|
|
1000
|
-
const Availabilities = {
|
|
1001
|
-
dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',
|
|
1002
|
-
numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'
|
|
1003
|
-
};
|
|
1004
|
-
|
|
1005
|
-
// implementation of `datetime` function
|
|
1006
|
-
function datetime(context, ...args) {
|
|
1007
|
-
const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
|
|
1008
|
-
const { __datetimeFormatters } = context;
|
|
1009
|
-
if ((process.env.NODE_ENV !== 'production') && !Availabilities.dateTimeFormat) {
|
|
1010
|
-
onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE));
|
|
1011
|
-
return MISSING_RESOLVE_VALUE;
|
|
1012
|
-
}
|
|
1013
|
-
const [key, value, options, overrides] = parseDateTimeArgs(...args);
|
|
1014
|
-
const missingWarn = isBoolean(options.missingWarn)
|
|
1015
|
-
? options.missingWarn
|
|
1016
|
-
: context.missingWarn;
|
|
1017
|
-
const fallbackWarn = isBoolean(options.fallbackWarn)
|
|
1018
|
-
? options.fallbackWarn
|
|
1019
|
-
: context.fallbackWarn;
|
|
1020
|
-
const part = !!options.part;
|
|
1021
|
-
const locale = getLocale(context, options);
|
|
1022
|
-
const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1023
|
-
fallbackLocale, locale);
|
|
1024
|
-
if (!isString(key) || key === '') {
|
|
1025
|
-
return new Intl.DateTimeFormat(locale, overrides).format(value);
|
|
1026
|
-
}
|
|
1027
|
-
// resolve format
|
|
1028
|
-
let datetimeFormat = {};
|
|
1029
|
-
let targetLocale;
|
|
1030
|
-
let format = null;
|
|
1031
|
-
let from = locale;
|
|
1032
|
-
let to = null;
|
|
1033
|
-
const type = 'datetime format';
|
|
1034
|
-
for (let i = 0; i < locales.length; i++) {
|
|
1035
|
-
targetLocale = to = locales[i];
|
|
1036
|
-
if ((process.env.NODE_ENV !== 'production') &&
|
|
1037
|
-
locale !== targetLocale &&
|
|
1038
|
-
isTranslateFallbackWarn(fallbackWarn, key)) {
|
|
1039
|
-
onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, {
|
|
1040
|
-
key,
|
|
1041
|
-
target: targetLocale
|
|
1042
|
-
}));
|
|
1043
|
-
}
|
|
1044
|
-
// for vue-devtools timeline event
|
|
1045
|
-
if ((process.env.NODE_ENV !== 'production') && locale !== targetLocale) {
|
|
1046
|
-
const emitter = context.__v_emitter;
|
|
1047
|
-
if (emitter) {
|
|
1048
|
-
emitter.emit('fallback', {
|
|
1049
|
-
type,
|
|
1050
|
-
key,
|
|
1051
|
-
from,
|
|
1052
|
-
to,
|
|
1053
|
-
groupId: `${type}:${key}`
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
datetimeFormat =
|
|
1058
|
-
datetimeFormats[targetLocale] || {};
|
|
1059
|
-
format = datetimeFormat[key];
|
|
1060
|
-
if (isPlainObject(format))
|
|
1061
|
-
break;
|
|
1062
|
-
handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1063
|
-
from = to;
|
|
1064
|
-
}
|
|
1065
|
-
// checking format and target locale
|
|
1066
|
-
if (!isPlainObject(format) || !isString(targetLocale)) {
|
|
1067
|
-
return unresolving ? NOT_REOSLVED : key;
|
|
1068
|
-
}
|
|
1069
|
-
let id = `${targetLocale}__${key}`;
|
|
1070
|
-
if (!isEmptyObject(overrides)) {
|
|
1071
|
-
id = `${id}__${JSON.stringify(overrides)}`;
|
|
1072
|
-
}
|
|
1073
|
-
let formatter = __datetimeFormatters.get(id);
|
|
1074
|
-
if (!formatter) {
|
|
1075
|
-
formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides));
|
|
1076
|
-
__datetimeFormatters.set(id, formatter);
|
|
1077
|
-
}
|
|
1078
|
-
return !part ? formatter.format(value) : formatter.formatToParts(value);
|
|
1079
|
-
}
|
|
1080
|
-
/** @internal */
|
|
1081
|
-
const DATETIME_FORMAT_OPTIONS_KEYS = [
|
|
1082
|
-
'localeMatcher',
|
|
1083
|
-
'weekday',
|
|
1084
|
-
'era',
|
|
1085
|
-
'year',
|
|
1086
|
-
'month',
|
|
1087
|
-
'day',
|
|
1088
|
-
'hour',
|
|
1089
|
-
'minute',
|
|
1090
|
-
'second',
|
|
1091
|
-
'timeZoneName',
|
|
1092
|
-
'formatMatcher',
|
|
1093
|
-
'hour12',
|
|
1094
|
-
'timeZone',
|
|
1095
|
-
'dateStyle',
|
|
1096
|
-
'timeStyle',
|
|
1097
|
-
'calendar',
|
|
1098
|
-
'dayPeriod',
|
|
1099
|
-
'numberingSystem',
|
|
1100
|
-
'hourCycle',
|
|
1101
|
-
'fractionalSecondDigits'
|
|
1102
|
-
];
|
|
1103
|
-
/** @internal */
|
|
1104
|
-
function parseDateTimeArgs(...args) {
|
|
1105
|
-
const [arg1, arg2, arg3, arg4] = args;
|
|
1106
|
-
const options = create();
|
|
1107
|
-
let overrides = create();
|
|
1108
|
-
let value;
|
|
1109
|
-
if (isString(arg1)) {
|
|
1110
|
-
// Only allow ISO strings - other date formats are often supported,
|
|
1111
|
-
// but may cause different results in different browsers.
|
|
1112
|
-
const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);
|
|
1113
|
-
if (!matches) {
|
|
1114
|
-
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
|
|
1115
|
-
}
|
|
1116
|
-
// Some browsers can not parse the iso datetime separated by space,
|
|
1117
|
-
// this is a compromise solution by replace the 'T'/' ' with 'T'
|
|
1118
|
-
const dateTime = matches[3]
|
|
1119
|
-
? matches[3].trim().startsWith('T')
|
|
1120
|
-
? `${matches[1].trim()}${matches[3].trim()}`
|
|
1121
|
-
: `${matches[1].trim()}T${matches[3].trim()}`
|
|
1122
|
-
: matches[1].trim();
|
|
1123
|
-
value = new Date(dateTime);
|
|
1124
|
-
try {
|
|
1125
|
-
// This will fail if the date is not valid
|
|
1126
|
-
value.toISOString();
|
|
1127
|
-
}
|
|
1128
|
-
catch {
|
|
1129
|
-
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
else if (isDate(arg1)) {
|
|
1133
|
-
if (isNaN(arg1.getTime())) {
|
|
1134
|
-
throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT);
|
|
1135
|
-
}
|
|
1136
|
-
value = arg1;
|
|
1137
|
-
}
|
|
1138
|
-
else if (isNumber(arg1)) {
|
|
1139
|
-
value = arg1;
|
|
1140
|
-
}
|
|
1141
|
-
else {
|
|
1142
|
-
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
1143
|
-
}
|
|
1144
|
-
if (isString(arg2)) {
|
|
1145
|
-
options.key = arg2;
|
|
1146
|
-
}
|
|
1147
|
-
else if (isPlainObject(arg2)) {
|
|
1148
|
-
Object.keys(arg2).forEach(key => {
|
|
1149
|
-
if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) {
|
|
1150
|
-
overrides[key] = arg2[key];
|
|
1151
|
-
}
|
|
1152
|
-
else {
|
|
1153
|
-
options[key] = arg2[key];
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
if (isString(arg3)) {
|
|
1158
|
-
options.locale = arg3;
|
|
1159
|
-
}
|
|
1160
|
-
else if (isPlainObject(arg3)) {
|
|
1161
|
-
overrides = arg3;
|
|
1162
|
-
}
|
|
1163
|
-
if (isPlainObject(arg4)) {
|
|
1164
|
-
overrides = arg4;
|
|
1165
|
-
}
|
|
1166
|
-
return [options.key || '', value, options, overrides];
|
|
1167
|
-
}
|
|
1168
|
-
/** @internal */
|
|
1169
|
-
function clearDateTimeFormat(ctx, locale, format) {
|
|
1170
|
-
const context = ctx;
|
|
1171
|
-
for (const key in format) {
|
|
1172
|
-
const id = `${locale}__${key}`;
|
|
1173
|
-
if (!context.__datetimeFormatters.has(id)) {
|
|
1174
|
-
continue;
|
|
1175
|
-
}
|
|
1176
|
-
context.__datetimeFormatters.delete(id);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
// implementation of `number` function
|
|
1181
|
-
function number(context, ...args) {
|
|
1182
|
-
const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
|
|
1183
|
-
const { __numberFormatters } = context;
|
|
1184
|
-
if ((process.env.NODE_ENV !== 'production') && !Availabilities.numberFormat) {
|
|
1185
|
-
onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER));
|
|
1186
|
-
return MISSING_RESOLVE_VALUE;
|
|
1187
|
-
}
|
|
1188
|
-
const [key, value, options, overrides] = parseNumberArgs(...args);
|
|
1189
|
-
const missingWarn = isBoolean(options.missingWarn)
|
|
1190
|
-
? options.missingWarn
|
|
1191
|
-
: context.missingWarn;
|
|
1192
|
-
const fallbackWarn = isBoolean(options.fallbackWarn)
|
|
1193
|
-
? options.fallbackWarn
|
|
1194
|
-
: context.fallbackWarn;
|
|
1195
|
-
const part = !!options.part;
|
|
1196
|
-
const locale = getLocale(context, options);
|
|
1197
|
-
const locales = localeFallbacker(context, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1198
|
-
fallbackLocale, locale);
|
|
1199
|
-
if (!isString(key) || key === '') {
|
|
1200
|
-
return new Intl.NumberFormat(locale, overrides).format(value);
|
|
1201
|
-
}
|
|
1202
|
-
// resolve format
|
|
1203
|
-
let numberFormat = {};
|
|
1204
|
-
let targetLocale;
|
|
1205
|
-
let format = null;
|
|
1206
|
-
let from = locale;
|
|
1207
|
-
let to = null;
|
|
1208
|
-
const type = 'number format';
|
|
1209
|
-
for (let i = 0; i < locales.length; i++) {
|
|
1210
|
-
targetLocale = to = locales[i];
|
|
1211
|
-
if ((process.env.NODE_ENV !== 'production') &&
|
|
1212
|
-
locale !== targetLocale &&
|
|
1213
|
-
isTranslateFallbackWarn(fallbackWarn, key)) {
|
|
1214
|
-
onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, {
|
|
1215
|
-
key,
|
|
1216
|
-
target: targetLocale
|
|
1217
|
-
}));
|
|
1218
|
-
}
|
|
1219
|
-
// for vue-devtools timeline event
|
|
1220
|
-
if ((process.env.NODE_ENV !== 'production') && locale !== targetLocale) {
|
|
1221
|
-
const emitter = context.__v_emitter;
|
|
1222
|
-
if (emitter) {
|
|
1223
|
-
emitter.emit('fallback', {
|
|
1224
|
-
type,
|
|
1225
|
-
key,
|
|
1226
|
-
from,
|
|
1227
|
-
to,
|
|
1228
|
-
groupId: `${type}:${key}`
|
|
1229
|
-
});
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
numberFormat =
|
|
1233
|
-
numberFormats[targetLocale] || {};
|
|
1234
|
-
format = numberFormat[key];
|
|
1235
|
-
if (isPlainObject(format))
|
|
1236
|
-
break;
|
|
1237
|
-
handleMissing(context, key, targetLocale, missingWarn, type); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1238
|
-
from = to;
|
|
1239
|
-
}
|
|
1240
|
-
// checking format and target locale
|
|
1241
|
-
if (!isPlainObject(format) || !isString(targetLocale)) {
|
|
1242
|
-
return unresolving ? NOT_REOSLVED : key;
|
|
1243
|
-
}
|
|
1244
|
-
let id = `${targetLocale}__${key}`;
|
|
1245
|
-
if (!isEmptyObject(overrides)) {
|
|
1246
|
-
id = `${id}__${JSON.stringify(overrides)}`;
|
|
1247
|
-
}
|
|
1248
|
-
let formatter = __numberFormatters.get(id);
|
|
1249
|
-
if (!formatter) {
|
|
1250
|
-
formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides));
|
|
1251
|
-
__numberFormatters.set(id, formatter);
|
|
1252
|
-
}
|
|
1253
|
-
return !part ? formatter.format(value) : formatter.formatToParts(value);
|
|
1254
|
-
}
|
|
1255
|
-
/** @internal */
|
|
1256
|
-
const NUMBER_FORMAT_OPTIONS_KEYS = [
|
|
1257
|
-
'localeMatcher',
|
|
1258
|
-
'style',
|
|
1259
|
-
'currency',
|
|
1260
|
-
'currencyDisplay',
|
|
1261
|
-
'currencySign',
|
|
1262
|
-
'useGrouping',
|
|
1263
|
-
'minimumIntegerDigits',
|
|
1264
|
-
'minimumFractionDigits',
|
|
1265
|
-
'maximumFractionDigits',
|
|
1266
|
-
'minimumSignificantDigits',
|
|
1267
|
-
'maximumSignificantDigits',
|
|
1268
|
-
'compactDisplay',
|
|
1269
|
-
'notation',
|
|
1270
|
-
'signDisplay',
|
|
1271
|
-
'unit',
|
|
1272
|
-
'unitDisplay',
|
|
1273
|
-
'roundingMode',
|
|
1274
|
-
'roundingPriority',
|
|
1275
|
-
'roundingIncrement',
|
|
1276
|
-
'trailingZeroDisplay'
|
|
1277
|
-
];
|
|
1278
|
-
/** @internal */
|
|
1279
|
-
function parseNumberArgs(...args) {
|
|
1280
|
-
const [arg1, arg2, arg3, arg4] = args;
|
|
1281
|
-
const options = create();
|
|
1282
|
-
let overrides = create();
|
|
1283
|
-
if (!isNumber(arg1)) {
|
|
1284
|
-
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
1285
|
-
}
|
|
1286
|
-
const value = arg1;
|
|
1287
|
-
if (isString(arg2)) {
|
|
1288
|
-
options.key = arg2;
|
|
1289
|
-
}
|
|
1290
|
-
else if (isPlainObject(arg2)) {
|
|
1291
|
-
Object.keys(arg2).forEach(key => {
|
|
1292
|
-
if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) {
|
|
1293
|
-
overrides[key] = arg2[key];
|
|
1294
|
-
}
|
|
1295
|
-
else {
|
|
1296
|
-
options[key] = arg2[key];
|
|
1297
|
-
}
|
|
1298
|
-
});
|
|
1299
|
-
}
|
|
1300
|
-
if (isString(arg3)) {
|
|
1301
|
-
options.locale = arg3;
|
|
1302
|
-
}
|
|
1303
|
-
else if (isPlainObject(arg3)) {
|
|
1304
|
-
overrides = arg3;
|
|
1305
|
-
}
|
|
1306
|
-
if (isPlainObject(arg4)) {
|
|
1307
|
-
overrides = arg4;
|
|
1308
|
-
}
|
|
1309
|
-
return [options.key || '', value, options, overrides];
|
|
1310
|
-
}
|
|
1311
|
-
/** @internal */
|
|
1312
|
-
function clearNumberFormat(ctx, locale, format) {
|
|
1313
|
-
const context = ctx;
|
|
1314
|
-
for (const key in format) {
|
|
1315
|
-
const id = `${locale}__${key}`;
|
|
1316
|
-
if (!context.__numberFormatters.has(id)) {
|
|
1317
|
-
continue;
|
|
1318
|
-
}
|
|
1319
|
-
context.__numberFormatters.delete(id);
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
const DEFAULT_MODIFIER = (str) => str;
|
|
1324
|
-
const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line
|
|
1325
|
-
const DEFAULT_MESSAGE_DATA_TYPE = 'text';
|
|
1326
|
-
const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : join(values);
|
|
1327
|
-
const DEFAULT_INTERPOLATE = toDisplayString;
|
|
1328
|
-
function pluralDefault(choice, choicesLength) {
|
|
1329
|
-
choice = Math.abs(choice);
|
|
1330
|
-
if (choicesLength === 2) {
|
|
1331
|
-
// prettier-ignore
|
|
1332
|
-
return choice
|
|
1333
|
-
? choice > 1
|
|
1334
|
-
? 1
|
|
1335
|
-
: 0
|
|
1336
|
-
: 1;
|
|
1337
|
-
}
|
|
1338
|
-
return choice ? Math.min(choice, 2) : 0;
|
|
1339
|
-
}
|
|
1340
|
-
function getPluralIndex(options) {
|
|
1341
|
-
// prettier-ignore
|
|
1342
|
-
const index = isNumber(options.pluralIndex)
|
|
1343
|
-
? options.pluralIndex
|
|
1344
|
-
: -1;
|
|
1345
|
-
// prettier-ignore
|
|
1346
|
-
return options.named && (isNumber(options.named.count) || isNumber(options.named.n))
|
|
1347
|
-
? isNumber(options.named.count)
|
|
1348
|
-
? options.named.count
|
|
1349
|
-
: isNumber(options.named.n)
|
|
1350
|
-
? options.named.n
|
|
1351
|
-
: index
|
|
1352
|
-
: index;
|
|
1353
|
-
}
|
|
1354
|
-
function normalizeNamed(pluralIndex, props) {
|
|
1355
|
-
if (!props.count) {
|
|
1356
|
-
props.count = pluralIndex;
|
|
1357
|
-
}
|
|
1358
|
-
if (!props.n) {
|
|
1359
|
-
props.n = pluralIndex;
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
function createMessageContext(options = {}) {
|
|
1363
|
-
const locale = options.locale;
|
|
1364
|
-
const pluralIndex = getPluralIndex(options);
|
|
1365
|
-
const pluralRule = isObject(options.pluralRules) &&
|
|
1366
|
-
isString(locale) &&
|
|
1367
|
-
isFunction(options.pluralRules[locale])
|
|
1368
|
-
? options.pluralRules[locale]
|
|
1369
|
-
: pluralDefault;
|
|
1370
|
-
const orgPluralRule = isObject(options.pluralRules) &&
|
|
1371
|
-
isString(locale) &&
|
|
1372
|
-
isFunction(options.pluralRules[locale])
|
|
1373
|
-
? pluralDefault
|
|
1374
|
-
: undefined;
|
|
1375
|
-
const plural = (messages) => {
|
|
1376
|
-
return messages[pluralRule(pluralIndex, messages.length, orgPluralRule)];
|
|
1377
|
-
};
|
|
1378
|
-
const _list = options.list || [];
|
|
1379
|
-
const list = (index) => _list[index];
|
|
1380
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1381
|
-
const _named = options.named || create();
|
|
1382
|
-
isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named);
|
|
1383
|
-
const named = (key) => _named[key];
|
|
1384
|
-
function message(key, useLinked) {
|
|
1385
|
-
// prettier-ignore
|
|
1386
|
-
const msg = isFunction(options.messages)
|
|
1387
|
-
? options.messages(key, !!useLinked)
|
|
1388
|
-
: isObject(options.messages)
|
|
1389
|
-
? options.messages[key]
|
|
1390
|
-
: false;
|
|
1391
|
-
return !msg
|
|
1392
|
-
? options.parent
|
|
1393
|
-
? options.parent.message(key) // resolve from parent messages
|
|
1394
|
-
: DEFAULT_MESSAGE
|
|
1395
|
-
: msg;
|
|
1396
|
-
}
|
|
1397
|
-
const _modifier = (name) => options.modifiers
|
|
1398
|
-
? options.modifiers[name]
|
|
1399
|
-
: DEFAULT_MODIFIER;
|
|
1400
|
-
const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize)
|
|
1401
|
-
? options.processor.normalize
|
|
1402
|
-
: DEFAULT_NORMALIZE;
|
|
1403
|
-
const interpolate = isPlainObject(options.processor) &&
|
|
1404
|
-
isFunction(options.processor.interpolate)
|
|
1405
|
-
? options.processor.interpolate
|
|
1406
|
-
: DEFAULT_INTERPOLATE;
|
|
1407
|
-
const type = isPlainObject(options.processor) && isString(options.processor.type)
|
|
1408
|
-
? options.processor.type
|
|
1409
|
-
: DEFAULT_MESSAGE_DATA_TYPE;
|
|
1410
|
-
const linked = (key, ...args) => {
|
|
1411
|
-
const [arg1, arg2] = args;
|
|
1412
|
-
let type = 'text';
|
|
1413
|
-
let modifier = '';
|
|
1414
|
-
if (args.length === 1) {
|
|
1415
|
-
if (isObject(arg1)) {
|
|
1416
|
-
modifier = arg1.modifier || modifier;
|
|
1417
|
-
type = arg1.type || type;
|
|
1418
|
-
}
|
|
1419
|
-
else if (isString(arg1)) {
|
|
1420
|
-
modifier = arg1 || modifier;
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
else if (args.length === 2) {
|
|
1424
|
-
if (isString(arg1)) {
|
|
1425
|
-
modifier = arg1 || modifier;
|
|
1426
|
-
}
|
|
1427
|
-
if (isString(arg2)) {
|
|
1428
|
-
type = arg2 || type;
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
const ret = message(key, true)(ctx);
|
|
1432
|
-
const msg =
|
|
1433
|
-
// The message in vnode resolved with linked are returned as an array by processor.nomalize
|
|
1434
|
-
type === 'vnode' && isArray(ret) && modifier
|
|
1435
|
-
? ret[0]
|
|
1436
|
-
: ret;
|
|
1437
|
-
return modifier ? _modifier(modifier)(msg, type) : msg;
|
|
1438
|
-
};
|
|
1439
|
-
const ctx = {
|
|
1440
|
-
["list" /* HelperNameMap.LIST */]: list,
|
|
1441
|
-
["named" /* HelperNameMap.NAMED */]: named,
|
|
1442
|
-
["plural" /* HelperNameMap.PLURAL */]: plural,
|
|
1443
|
-
["linked" /* HelperNameMap.LINKED */]: linked,
|
|
1444
|
-
["message" /* HelperNameMap.MESSAGE */]: message,
|
|
1445
|
-
["type" /* HelperNameMap.TYPE */]: type,
|
|
1446
|
-
["interpolate" /* HelperNameMap.INTERPOLATE */]: interpolate,
|
|
1447
|
-
["normalize" /* HelperNameMap.NORMALIZE */]: normalize,
|
|
1448
|
-
["values" /* HelperNameMap.VALUES */]: assign(create(), _list, _named)
|
|
1449
|
-
};
|
|
1450
|
-
return ctx;
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
const NOOP_MESSAGE_FUNCTION = () => '';
|
|
1454
|
-
const isMessageFunction = (val) => isFunction(val);
|
|
1455
|
-
// implementation of `translate` function
|
|
1456
|
-
function translate(context, ...args) {
|
|
1457
|
-
const { fallbackFormat, postTranslation, unresolving, messageCompiler, fallbackLocale, messages } = context;
|
|
1458
|
-
const [key, options] = parseTranslateArgs(...args);
|
|
1459
|
-
const missingWarn = isBoolean(options.missingWarn)
|
|
1460
|
-
? options.missingWarn
|
|
1461
|
-
: context.missingWarn;
|
|
1462
|
-
const fallbackWarn = isBoolean(options.fallbackWarn)
|
|
1463
|
-
? options.fallbackWarn
|
|
1464
|
-
: context.fallbackWarn;
|
|
1465
|
-
const escapeParameter = isBoolean(options.escapeParameter)
|
|
1466
|
-
? options.escapeParameter
|
|
1467
|
-
: context.escapeParameter;
|
|
1468
|
-
const resolvedMessage = !!options.resolvedMessage;
|
|
1469
|
-
// prettier-ignore
|
|
1470
|
-
const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option
|
|
1471
|
-
? !isBoolean(options.default)
|
|
1472
|
-
? options.default
|
|
1473
|
-
: (!messageCompiler ? () => key : key)
|
|
1474
|
-
: fallbackFormat // default by `fallbackFormat` option
|
|
1475
|
-
? (!messageCompiler ? () => key : key)
|
|
1476
|
-
: null;
|
|
1477
|
-
const enableDefaultMsg = fallbackFormat ||
|
|
1478
|
-
(defaultMsgOrKey != null &&
|
|
1479
|
-
(isString(defaultMsgOrKey) || isFunction(defaultMsgOrKey)));
|
|
1480
|
-
const locale = getLocale(context, options);
|
|
1481
|
-
// escape params
|
|
1482
|
-
escapeParameter && escapeParams(options);
|
|
1483
|
-
// resolve message format
|
|
1484
|
-
// eslint-disable-next-line prefer-const
|
|
1485
|
-
let [formatScope, targetLocale, message] = !resolvedMessage
|
|
1486
|
-
? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn)
|
|
1487
|
-
: [
|
|
1488
|
-
key,
|
|
1489
|
-
locale,
|
|
1490
|
-
messages[locale] || create()
|
|
1491
|
-
];
|
|
1492
|
-
// NOTE:
|
|
1493
|
-
// Fix to work around `ssrTransfrom` bug in Vite.
|
|
1494
|
-
// https://github.com/vitejs/vite/issues/4306
|
|
1495
|
-
// To get around this, use temporary variables.
|
|
1496
|
-
// https://github.com/nuxt/framework/issues/1461#issuecomment-954606243
|
|
1497
|
-
let format = formatScope;
|
|
1498
|
-
// if you use default message, set it as message format!
|
|
1499
|
-
let cacheBaseKey = key;
|
|
1500
|
-
if (!resolvedMessage &&
|
|
1501
|
-
!(isString(format) ||
|
|
1502
|
-
isMessageAST(format) ||
|
|
1503
|
-
isMessageFunction(format))) {
|
|
1504
|
-
if (enableDefaultMsg) {
|
|
1505
|
-
format = defaultMsgOrKey;
|
|
1506
|
-
cacheBaseKey = format;
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
// checking message format and target locale
|
|
1510
|
-
if (!resolvedMessage &&
|
|
1511
|
-
(!(isString(format) ||
|
|
1512
|
-
isMessageAST(format) ||
|
|
1513
|
-
isMessageFunction(format)) ||
|
|
1514
|
-
!isString(targetLocale))) {
|
|
1515
|
-
return unresolving ? NOT_REOSLVED : key;
|
|
1516
|
-
}
|
|
1517
|
-
// TODO: refactor
|
|
1518
|
-
if ((process.env.NODE_ENV !== 'production') && isString(format) && context.messageCompiler == null) {
|
|
1519
|
-
warn(`The message format compilation is not supported in this build. ` +
|
|
1520
|
-
`Because message compiler isn't included. ` +
|
|
1521
|
-
`You need to pre-compilation all message format. ` +
|
|
1522
|
-
`So translate function return '${key}'.`);
|
|
1523
|
-
return key;
|
|
1524
|
-
}
|
|
1525
|
-
// setup compile error detecting
|
|
1526
|
-
let occurred = false;
|
|
1527
|
-
const onError = () => {
|
|
1528
|
-
occurred = true;
|
|
1529
|
-
};
|
|
1530
|
-
// compile message format
|
|
1531
|
-
const msg = !isMessageFunction(format)
|
|
1532
|
-
? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError)
|
|
1533
|
-
: format;
|
|
1534
|
-
// if occurred compile error, return the message format
|
|
1535
|
-
if (occurred) {
|
|
1536
|
-
return format;
|
|
1537
|
-
}
|
|
1538
|
-
// evaluate message with context
|
|
1539
|
-
const ctxOptions = getMessageContextOptions(context, targetLocale, message, options);
|
|
1540
|
-
const msgContext = createMessageContext(ctxOptions);
|
|
1541
|
-
const messaged = evaluateMessage(context, msg, msgContext);
|
|
1542
|
-
// if use post translation option, proceed it with handler
|
|
1543
|
-
const ret = postTranslation
|
|
1544
|
-
? postTranslation(messaged, key)
|
|
1545
|
-
: messaged;
|
|
1546
|
-
// NOTE: experimental !!
|
|
1547
|
-
if ((process.env.NODE_ENV !== 'production') || __INTLIFY_PROD_DEVTOOLS__) {
|
|
1548
|
-
// prettier-ignore
|
|
1549
|
-
const payloads = {
|
|
1550
|
-
timestamp: Date.now(),
|
|
1551
|
-
key: isString(key)
|
|
1552
|
-
? key
|
|
1553
|
-
: isMessageFunction(format)
|
|
1554
|
-
? format.key
|
|
1555
|
-
: '',
|
|
1556
|
-
locale: targetLocale || (isMessageFunction(format)
|
|
1557
|
-
? format.locale
|
|
1558
|
-
: ''),
|
|
1559
|
-
format: isString(format)
|
|
1560
|
-
? format
|
|
1561
|
-
: isMessageFunction(format)
|
|
1562
|
-
? format.source
|
|
1563
|
-
: '',
|
|
1564
|
-
message: ret
|
|
1565
|
-
};
|
|
1566
|
-
payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {});
|
|
1567
|
-
translateDevTools(payloads);
|
|
1568
|
-
}
|
|
1569
|
-
return ret;
|
|
1570
|
-
}
|
|
1571
|
-
function escapeParams(options) {
|
|
1572
|
-
if (isArray(options.list)) {
|
|
1573
|
-
options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item);
|
|
1574
|
-
}
|
|
1575
|
-
else if (isObject(options.named)) {
|
|
1576
|
-
Object.keys(options.named).forEach(key => {
|
|
1577
|
-
if (isString(options.named[key])) {
|
|
1578
|
-
options.named[key] = escapeHtml(options.named[key]);
|
|
1579
|
-
}
|
|
1580
|
-
});
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
|
|
1584
|
-
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
|
|
1585
|
-
const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1586
|
-
let message = create();
|
|
1587
|
-
let targetLocale;
|
|
1588
|
-
let format = null;
|
|
1589
|
-
let from = locale;
|
|
1590
|
-
let to = null;
|
|
1591
|
-
const type = 'translate';
|
|
1592
|
-
for (let i = 0; i < locales.length; i++) {
|
|
1593
|
-
targetLocale = to = locales[i];
|
|
1594
|
-
if ((process.env.NODE_ENV !== 'production') &&
|
|
1595
|
-
locale !== targetLocale &&
|
|
1596
|
-
!isAlmostSameLocale(locale, targetLocale) &&
|
|
1597
|
-
isTranslateFallbackWarn(fallbackWarn, key)) {
|
|
1598
|
-
onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, {
|
|
1599
|
-
key,
|
|
1600
|
-
target: targetLocale
|
|
1601
|
-
}));
|
|
1602
|
-
}
|
|
1603
|
-
// for vue-devtools timeline event
|
|
1604
|
-
if ((process.env.NODE_ENV !== 'production') && locale !== targetLocale) {
|
|
1605
|
-
const emitter = context.__v_emitter;
|
|
1606
|
-
if (emitter) {
|
|
1607
|
-
emitter.emit('fallback', {
|
|
1608
|
-
type,
|
|
1609
|
-
key,
|
|
1610
|
-
from,
|
|
1611
|
-
to,
|
|
1612
|
-
groupId: `${type}:${key}`
|
|
1613
|
-
});
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
message =
|
|
1617
|
-
messages[targetLocale] || create();
|
|
1618
|
-
// for vue-devtools timeline event
|
|
1619
|
-
let start = null;
|
|
1620
|
-
let startTag;
|
|
1621
|
-
let endTag;
|
|
1622
|
-
if ((process.env.NODE_ENV !== 'production') && inBrowser) {
|
|
1623
|
-
start = window.performance.now();
|
|
1624
|
-
startTag = 'intlify-message-resolve-start';
|
|
1625
|
-
endTag = 'intlify-message-resolve-end';
|
|
1626
|
-
mark && mark(startTag);
|
|
1627
|
-
}
|
|
1628
|
-
if ((format = resolveValue(message, key)) === null) {
|
|
1629
|
-
// if null, resolve with object key path
|
|
1630
|
-
format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1631
|
-
}
|
|
1632
|
-
// for vue-devtools timeline event
|
|
1633
|
-
if ((process.env.NODE_ENV !== 'production') && inBrowser) {
|
|
1634
|
-
const end = window.performance.now();
|
|
1635
|
-
const emitter = context.__v_emitter;
|
|
1636
|
-
if (emitter && start && format) {
|
|
1637
|
-
emitter.emit('message-resolve', {
|
|
1638
|
-
type: 'message-resolve',
|
|
1639
|
-
key,
|
|
1640
|
-
message: format,
|
|
1641
|
-
time: end - start,
|
|
1642
|
-
groupId: `${type}:${key}`
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
-
if (startTag && endTag && mark && measure) {
|
|
1646
|
-
mark(endTag);
|
|
1647
|
-
measure('intlify message resolve', startTag, endTag);
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
if (isString(format) || isMessageAST(format) || isMessageFunction(format)) {
|
|
1651
|
-
break;
|
|
1652
|
-
}
|
|
1653
|
-
if (!isImplicitFallback(targetLocale, locales)) {
|
|
1654
|
-
const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1655
|
-
key, targetLocale, missingWarn, type);
|
|
1656
|
-
if (missingRet !== key) {
|
|
1657
|
-
format = missingRet;
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
from = to;
|
|
1661
|
-
}
|
|
1662
|
-
return [format, targetLocale, message];
|
|
1663
|
-
}
|
|
1664
|
-
function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) {
|
|
1665
|
-
const { messageCompiler, warnHtmlMessage } = context;
|
|
1666
|
-
if (isMessageFunction(format)) {
|
|
1667
|
-
const msg = format;
|
|
1668
|
-
msg.locale = msg.locale || targetLocale;
|
|
1669
|
-
msg.key = msg.key || key;
|
|
1670
|
-
return msg;
|
|
1671
|
-
}
|
|
1672
|
-
if (messageCompiler == null) {
|
|
1673
|
-
const msg = (() => format);
|
|
1674
|
-
msg.locale = targetLocale;
|
|
1675
|
-
msg.key = key;
|
|
1676
|
-
return msg;
|
|
1677
|
-
}
|
|
1678
|
-
// for vue-devtools timeline event
|
|
1679
|
-
let start = null;
|
|
1680
|
-
let startTag;
|
|
1681
|
-
let endTag;
|
|
1682
|
-
if ((process.env.NODE_ENV !== 'production') && inBrowser) {
|
|
1683
|
-
start = window.performance.now();
|
|
1684
|
-
startTag = 'intlify-message-compilation-start';
|
|
1685
|
-
endTag = 'intlify-message-compilation-end';
|
|
1686
|
-
mark && mark(startTag);
|
|
1687
|
-
}
|
|
1688
|
-
const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError));
|
|
1689
|
-
// for vue-devtools timeline event
|
|
1690
|
-
if ((process.env.NODE_ENV !== 'production') && inBrowser) {
|
|
1691
|
-
const end = window.performance.now();
|
|
1692
|
-
const emitter = context.__v_emitter;
|
|
1693
|
-
if (emitter && start) {
|
|
1694
|
-
emitter.emit('message-compilation', {
|
|
1695
|
-
type: 'message-compilation',
|
|
1696
|
-
message: format,
|
|
1697
|
-
time: end - start,
|
|
1698
|
-
groupId: `${'translate'}:${key}`
|
|
1699
|
-
});
|
|
1700
|
-
}
|
|
1701
|
-
if (startTag && endTag && mark && measure) {
|
|
1702
|
-
mark(endTag);
|
|
1703
|
-
measure('intlify message compilation', startTag, endTag);
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
msg.locale = targetLocale;
|
|
1707
|
-
msg.key = key;
|
|
1708
|
-
msg.source = format;
|
|
1709
|
-
return msg;
|
|
1710
|
-
}
|
|
1711
|
-
function evaluateMessage(context, msg, msgCtx) {
|
|
1712
|
-
// for vue-devtools timeline event
|
|
1713
|
-
let start = null;
|
|
1714
|
-
let startTag;
|
|
1715
|
-
let endTag;
|
|
1716
|
-
if ((process.env.NODE_ENV !== 'production') && inBrowser) {
|
|
1717
|
-
start = window.performance.now();
|
|
1718
|
-
startTag = 'intlify-message-evaluation-start';
|
|
1719
|
-
endTag = 'intlify-message-evaluation-end';
|
|
1720
|
-
mark && mark(startTag);
|
|
1721
|
-
}
|
|
1722
|
-
const messaged = msg(msgCtx);
|
|
1723
|
-
// for vue-devtools timeline event
|
|
1724
|
-
if ((process.env.NODE_ENV !== 'production') && inBrowser) {
|
|
1725
|
-
const end = window.performance.now();
|
|
1726
|
-
const emitter = context.__v_emitter;
|
|
1727
|
-
if (emitter && start) {
|
|
1728
|
-
emitter.emit('message-evaluation', {
|
|
1729
|
-
type: 'message-evaluation',
|
|
1730
|
-
value: messaged,
|
|
1731
|
-
time: end - start,
|
|
1732
|
-
groupId: `${'translate'}:${msg.key}`
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
if (startTag && endTag && mark && measure) {
|
|
1736
|
-
mark(endTag);
|
|
1737
|
-
measure('intlify message evaluation', startTag, endTag);
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
return messaged;
|
|
1741
|
-
}
|
|
1742
|
-
/** @internal */
|
|
1743
|
-
function parseTranslateArgs(...args) {
|
|
1744
|
-
const [arg1, arg2, arg3] = args;
|
|
1745
|
-
const options = create();
|
|
1746
|
-
if (!isString(arg1) &&
|
|
1747
|
-
!isNumber(arg1) &&
|
|
1748
|
-
!isMessageFunction(arg1) &&
|
|
1749
|
-
!isMessageAST(arg1)) {
|
|
1750
|
-
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
1751
|
-
}
|
|
1752
|
-
// prettier-ignore
|
|
1753
|
-
const key = isNumber(arg1)
|
|
1754
|
-
? String(arg1)
|
|
1755
|
-
: isMessageFunction(arg1)
|
|
1756
|
-
? arg1
|
|
1757
|
-
: arg1;
|
|
1758
|
-
if (isNumber(arg2)) {
|
|
1759
|
-
options.plural = arg2;
|
|
1760
|
-
}
|
|
1761
|
-
else if (isString(arg2)) {
|
|
1762
|
-
options.default = arg2;
|
|
1763
|
-
}
|
|
1764
|
-
else if (isPlainObject(arg2) && !isEmptyObject(arg2)) {
|
|
1765
|
-
options.named = arg2;
|
|
1766
|
-
}
|
|
1767
|
-
else if (isArray(arg2)) {
|
|
1768
|
-
options.list = arg2;
|
|
1769
|
-
}
|
|
1770
|
-
if (isNumber(arg3)) {
|
|
1771
|
-
options.plural = arg3;
|
|
1772
|
-
}
|
|
1773
|
-
else if (isString(arg3)) {
|
|
1774
|
-
options.default = arg3;
|
|
1775
|
-
}
|
|
1776
|
-
else if (isPlainObject(arg3)) {
|
|
1777
|
-
assign(options, arg3);
|
|
1778
|
-
}
|
|
1779
|
-
return [key, options];
|
|
1780
|
-
}
|
|
1781
|
-
function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) {
|
|
1782
|
-
return {
|
|
1783
|
-
locale,
|
|
1784
|
-
key,
|
|
1785
|
-
warnHtmlMessage,
|
|
1786
|
-
onError: (err) => {
|
|
1787
|
-
onError && onError(err);
|
|
1788
|
-
if ((process.env.NODE_ENV !== 'production')) {
|
|
1789
|
-
const _source = getSourceForCodeFrame(source);
|
|
1790
|
-
const message = `Message compilation error: ${err.message}`;
|
|
1791
|
-
const codeFrame = err.location &&
|
|
1792
|
-
_source &&
|
|
1793
|
-
generateCodeFrame(_source, err.location.start.offset, err.location.end.offset);
|
|
1794
|
-
const emitter = context.__v_emitter;
|
|
1795
|
-
if (emitter && _source) {
|
|
1796
|
-
emitter.emit('compile-error', {
|
|
1797
|
-
message: _source,
|
|
1798
|
-
error: err.message,
|
|
1799
|
-
start: err.location && err.location.start.offset,
|
|
1800
|
-
end: err.location && err.location.end.offset,
|
|
1801
|
-
groupId: `${'translate'}:${key}`
|
|
1802
|
-
});
|
|
1803
|
-
}
|
|
1804
|
-
console.error(codeFrame ? `${message}\n${codeFrame}` : message);
|
|
1805
|
-
}
|
|
1806
|
-
else {
|
|
1807
|
-
throw err;
|
|
1808
|
-
}
|
|
1809
|
-
},
|
|
1810
|
-
onCacheKey: (source) => generateFormatCacheKey(locale, key, source)
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
function getSourceForCodeFrame(source) {
|
|
1814
|
-
if (isString(source)) {
|
|
1815
|
-
return source;
|
|
1816
|
-
}
|
|
1817
|
-
else {
|
|
1818
|
-
if (source.loc && source.loc.source) {
|
|
1819
|
-
return source.loc.source;
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
function getMessageContextOptions(context, locale, message, options) {
|
|
1824
|
-
const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
|
|
1825
|
-
const resolveMessage = (key, useLinked) => {
|
|
1826
|
-
let val = resolveValue(message, key);
|
|
1827
|
-
// fallback
|
|
1828
|
-
if (val == null && (fallbackContext || useLinked)) {
|
|
1829
|
-
const [, , message] = resolveMessageFormat(fallbackContext || context, // NOTE: if has fallbackContext, fallback to root, else if use linked, fallback to local context
|
|
1830
|
-
key, locale, fallbackLocale, fallbackWarn, missingWarn);
|
|
1831
|
-
val = resolveValue(message, key);
|
|
1832
|
-
}
|
|
1833
|
-
if (isString(val) || isMessageAST(val)) {
|
|
1834
|
-
let occurred = false;
|
|
1835
|
-
const onError = () => {
|
|
1836
|
-
occurred = true;
|
|
1837
|
-
};
|
|
1838
|
-
const msg = compileMessageFormat(context, key, locale, val, key, onError);
|
|
1839
|
-
return !occurred
|
|
1840
|
-
? msg
|
|
1841
|
-
: NOOP_MESSAGE_FUNCTION;
|
|
1842
|
-
}
|
|
1843
|
-
else if (isMessageFunction(val)) {
|
|
1844
|
-
return val;
|
|
1845
|
-
}
|
|
1846
|
-
else {
|
|
1847
|
-
// TODO: should be implemented warning message
|
|
1848
|
-
return NOOP_MESSAGE_FUNCTION;
|
|
1849
|
-
}
|
|
1850
|
-
};
|
|
1851
|
-
const ctxOptions = {
|
|
1852
|
-
locale,
|
|
1853
|
-
modifiers,
|
|
1854
|
-
pluralRules,
|
|
1855
|
-
messages: resolveMessage
|
|
1856
|
-
};
|
|
1857
|
-
if (context.processor) {
|
|
1858
|
-
ctxOptions.processor = context.processor;
|
|
1859
|
-
}
|
|
1860
|
-
if (options.list) {
|
|
1861
|
-
ctxOptions.list = options.list;
|
|
1862
|
-
}
|
|
1863
|
-
if (options.named) {
|
|
1864
|
-
ctxOptions.named = options.named;
|
|
1865
|
-
}
|
|
1866
|
-
if (isNumber(options.plural)) {
|
|
1867
|
-
ctxOptions.pluralIndex = options.plural;
|
|
1868
|
-
}
|
|
1869
|
-
return ctxOptions;
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
{
|
|
1873
|
-
initFeatureFlags();
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
export { AST_NODE_PROPS_KEYS as A, setDevToolsHook as B, CORE_WARN_CODES_EXTEND_POINT as C, DEFAULT_LOCALE as D, MISSING_RESOLVE_VALUE as M, NOT_REOSLVED as N, clearDateTimeFormat as a, clearNumberFormat as b, createCoreContext as c, isTranslateFallbackWarn as d, isTranslateMissingWarn as e, fallbackWithLocaleChain as f, getFallbackContext as g, CORE_ERROR_CODES_EXTEND_POINT as h, isMessageAST as i, setFallbackContext as j, parseDateTimeArgs as k, datetime as l, parseNumberArgs as m, number as n, isMessageFunction as o, parseTranslateArgs as p, NUMBER_FORMAT_OPTIONS_KEYS as q, DATETIME_FORMAT_OPTIONS_KEYS as r, setAdditionalMeta as s, translate as t, updateFallbackLocale as u, registerMessageCompiler as v, registerMessageResolver as w, registerLocaleFallbacker as x, compile as y, resolveValue as z };
|