nuxt-intlayer 6.1.6 → 7.0.0-canary.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/rolldown_runtime.cjs +40 -0
- package/dist/cjs/index.cjs +7 -25
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/module.cjs +73 -93
- package/dist/cjs/module.cjs.map +1 -1
- package/dist/cjs/node_modules/.bun/@babel_parser@7.28.4/node_modules/@babel/parser/lib/index.cjs +12494 -0
- package/dist/cjs/node_modules/.bun/@babel_parser@7.28.4/node_modules/@babel/parser/lib/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.cjs +2353 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.cjs +4751 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/index.cjs +18 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.cjs +660 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.cjs +442 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/index.cjs +18 -0
- package/dist/cjs/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.cjs +22 -0
- package/dist/cjs/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.cjs +1457 -0
- package/dist/cjs/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/index.cjs +18 -0
- package/dist/cjs/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.cjs +870 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.cjs +4204 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/index.cjs +18 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.cjs +1373 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.cjs +1270 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/index.cjs +18 -0
- package/dist/cjs/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.cjs +44 -0
- package/dist/cjs/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.prod.cjs +491 -0
- package/dist/cjs/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.prod.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/index.cjs +18 -0
- package/dist/cjs/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode.cjs +474 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode_codepoint.cjs +82 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode_codepoint.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-html.cjs +18 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-html.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-xml.cjs +18 -0
- package/dist/cjs/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-xml.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.cjs +255 -0
- package/dist/cjs/node_modules/.bun/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.cjs +103 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.cjs +76 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.cjs +44 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.cjs +71 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.cjs +80 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.cjs +92 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.cjs +791 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.cjs +298 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.cjs +296 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/util.cjs +355 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/util.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/source-map.cjs +20 -0
- package/dist/cjs/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/source-map.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/native.cjs +10 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/native.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/rng.cjs +18 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/rng.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/stringify.cjs +11 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/stringify.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/v4.cjs +28 -0
- package/dist/cjs/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/v4.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.cjs +65 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.prod.cjs +55 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.prod.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index.cjs +18 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index.cjs.map +1 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index2.cjs +15 -0
- package/dist/cjs/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index2.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/dictionaries-entry/dist/esm/index.cjs +25 -0
- package/dist/cjs/packages/@intlayer/dictionaries-entry/dist/esm/index.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs +36 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/compareUrls.cjs.map +1 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/messagesKeys.cjs +19 -0
- package/dist/cjs/packages/@intlayer/editor/dist/esm/messagesKeys.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/client/installIntlayer.cjs +31 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/client/installIntlayer.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/communicator.cjs +39 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/communicator.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/createSharedComposable.cjs +17 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/createSharedComposable.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/dictionariesRecord.cjs +38 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/dictionariesRecord.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/editedContent.cjs +46 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/editedContent.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/editorEnabled.cjs +44 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/editorEnabled.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/focusDictionary.cjs +38 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/focusDictionary.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/installIntlayerEditor.cjs +26 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/installIntlayerEditor.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/useCrossFrameMessageListener.cjs +35 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/useCrossFrameMessageListener.cjs.map +1 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/useCrossFrameState.cjs +57 -0
- package/dist/cjs/packages/vue-intlayer/dist/esm/editor/useCrossFrameState.cjs.map +1 -0
- package/dist/cjs/runtime/html-lang.cjs +18 -32
- package/dist/cjs/runtime/html-lang.cjs.map +1 -1
- package/dist/cjs/runtime/intlayer-plugin.cjs +34 -38
- package/dist/cjs/runtime/intlayer-plugin.cjs.map +1 -1
- package/dist/esm/_virtual/rolldown_runtime.mjs +38 -0
- package/dist/esm/index.mjs +6 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/module.mjs +62 -63
- package/dist/esm/module.mjs.map +1 -1
- package/dist/esm/node_modules/.bun/@babel_parser@7.28.4/node_modules/@babel/parser/lib/index.mjs +12491 -0
- package/dist/esm/node_modules/.bun/@babel_parser@7.28.4/node_modules/@babel/parser/lib/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.mjs +2350 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.mjs +4748 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/index.mjs +15 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-core@3.5.22/node_modules/@vue/compiler-core/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.mjs +657 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.mjs +439 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/index.mjs +15 -0
- package/dist/esm/node_modules/.bun/@vue_compiler-dom@3.5.22/node_modules/@vue/compiler-dom/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.mjs +19 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.mjs +1454 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.mjs +1312 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/index.mjs +15 -0
- package/dist/esm/node_modules/.bun/@vue_reactivity@3.5.22/node_modules/@vue/reactivity/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.mjs +867 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.mjs +4201 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs +995 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/index.mjs +15 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-core@3.5.22/node_modules/@vue/runtime-core/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.mjs +1370 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.mjs +1267 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/index.mjs +15 -0
- package/dist/esm/node_modules/.bun/@vue_runtime-dom@3.5.22/node_modules/@vue/runtime-dom/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.mjs +41 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.prod.mjs +488 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.cjs.prod.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.esm-bundler.mjs +77 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/dist/shared.esm-bundler.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/index.mjs +15 -0
- package/dist/esm/node_modules/.bun/@vue_shared@3.5.22/node_modules/@vue/shared/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode.mjs +471 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode_codepoint.mjs +79 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/decode_codepoint.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-html.mjs +15 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-html.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-xml.mjs +15 -0
- package/dist/esm/node_modules/.bun/entities@4.5.0/node_modules/entities/lib/generated/decode-data-xml.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.mjs +252 -0
- package/dist/esm/node_modules/.bun/estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.mjs +100 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.mjs +73 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.mjs +41 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.mjs +68 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/binary-search.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.mjs +77 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.mjs +89 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/quick-sort.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.mjs +788 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-consumer.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.mjs +295 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.mjs +293 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/source-node.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/util.mjs +352 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/lib/util.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/source-map.mjs +17 -0
- package/dist/esm/node_modules/.bun/source-map-js@1.2.1/node_modules/source-map-js/source-map.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/native.mjs +7 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/native.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/rng.mjs +14 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/rng.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/stringify.mjs +10 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/stringify.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/v4.mjs +28 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist/v4.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/native.mjs +8 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/native.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/rng.mjs +16 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/rng.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/stringify.mjs +10 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/stringify.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/v4.mjs +28 -0
- package/dist/esm/node_modules/.bun/uuid@13.0.0/node_modules/uuid/dist-node/v4.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.mjs +62 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.prod.mjs +52 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.cjs.prod.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.runtime.esm-bundler.mjs +12 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/dist/vue.runtime.esm-bundler.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index.mjs +15 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index.mjs.map +1 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index2.mjs +10 -0
- package/dist/esm/node_modules/.bun/vue@3.5.22_e72aefb0f8d0b841/node_modules/vue/index2.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/dictionaries-entry/dist/esm/index.mjs +20 -0
- package/dist/esm/packages/@intlayer/dictionaries-entry/dist/esm/index.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs +35 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/compareUrls.mjs.map +1 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/messagesKeys.mjs +18 -0
- package/dist/esm/packages/@intlayer/editor/dist/esm/messagesKeys.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/client/installIntlayer.mjs +28 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/client/installIntlayer.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/communicator.mjs +38 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/communicator.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/createSharedComposable.mjs +18 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/createSharedComposable.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/dictionariesRecord.mjs +40 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/dictionariesRecord.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/editedContent.mjs +46 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/editedContent.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/editorEnabled.mjs +44 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/editorEnabled.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/focusDictionary.mjs +40 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/focusDictionary.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/installIntlayerEditor.mjs +24 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/installIntlayerEditor.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/useCrossFrameMessageListener.mjs +37 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/useCrossFrameState.mjs +59 -0
- package/dist/esm/packages/vue-intlayer/dist/esm/editor/useCrossFrameState.mjs.map +1 -0
- package/dist/esm/runtime/html-lang.mjs +11 -9
- package/dist/esm/runtime/html-lang.mjs.map +1 -1
- package/dist/esm/runtime/intlayer-plugin.mjs +28 -15
- package/dist/esm/runtime/intlayer-plugin.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/module.d.ts +6 -2
- package/dist/types/module.d.ts.map +1 -1
- package/dist/types/runtime/html-lang.d.ts +3 -1
- package/dist/types/runtime/html-lang.d.ts.map +1 -1
- package/dist/types/runtime/intlayer-plugin.d.ts +3 -1
- package/dist/types/runtime/intlayer-plugin.d.ts.map +1 -1
- package/package.json +37 -43
- package/LICENSE +0 -202
- package/dist/types/index.d.ts.map +0 -1
|
@@ -0,0 +1,4748 @@
|
|
|
1
|
+
import { __commonJS } from "../../../../../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { require_shared } from "../../../../../@vue_shared@3.5.22/node_modules/@vue/shared/index.mjs";
|
|
3
|
+
import { require_decode } from "../../../../../entities@4.5.0/node_modules/entities/lib/decode.mjs";
|
|
4
|
+
import { require_lib } from "../../../../../@babel_parser@7.28.4/node_modules/@babel/parser/lib/index.mjs";
|
|
5
|
+
import { require_estree_walker } from "../../../../../estree-walker@2.0.2/node_modules/estree-walker/dist/umd/estree-walker.mjs";
|
|
6
|
+
import { require_source_map } from "../../../../../source-map-js@1.2.1/node_modules/source-map-js/source-map.mjs";
|
|
7
|
+
|
|
8
|
+
//#region ../../node_modules/.bun/@vue+compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js
|
|
9
|
+
var require_compiler_core_cjs_prod = /* @__PURE__ */ __commonJS({ "../../node_modules/.bun/@vue+compiler-core@3.5.22/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js": ((exports) => {
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
var shared = require_shared();
|
|
12
|
+
var decode_js = require_decode();
|
|
13
|
+
var parser = require_lib();
|
|
14
|
+
var estreeWalker = require_estree_walker();
|
|
15
|
+
var sourceMapJs = require_source_map();
|
|
16
|
+
const FRAGMENT = Symbol(``);
|
|
17
|
+
const TELEPORT = Symbol(``);
|
|
18
|
+
const SUSPENSE = Symbol(``);
|
|
19
|
+
const KEEP_ALIVE = Symbol(``);
|
|
20
|
+
const BASE_TRANSITION = Symbol(``);
|
|
21
|
+
const OPEN_BLOCK = Symbol(``);
|
|
22
|
+
const CREATE_BLOCK = Symbol(``);
|
|
23
|
+
const CREATE_ELEMENT_BLOCK = Symbol(``);
|
|
24
|
+
const CREATE_VNODE = Symbol(``);
|
|
25
|
+
const CREATE_ELEMENT_VNODE = Symbol(``);
|
|
26
|
+
const CREATE_COMMENT = Symbol(``);
|
|
27
|
+
const CREATE_TEXT = Symbol(``);
|
|
28
|
+
const CREATE_STATIC = Symbol(``);
|
|
29
|
+
const RESOLVE_COMPONENT = Symbol(``);
|
|
30
|
+
const RESOLVE_DYNAMIC_COMPONENT = Symbol(``);
|
|
31
|
+
const RESOLVE_DIRECTIVE = Symbol(``);
|
|
32
|
+
const RESOLVE_FILTER = Symbol(``);
|
|
33
|
+
const WITH_DIRECTIVES = Symbol(``);
|
|
34
|
+
const RENDER_LIST = Symbol(``);
|
|
35
|
+
const RENDER_SLOT = Symbol(``);
|
|
36
|
+
const CREATE_SLOTS = Symbol(``);
|
|
37
|
+
const TO_DISPLAY_STRING = Symbol(``);
|
|
38
|
+
const MERGE_PROPS = Symbol(``);
|
|
39
|
+
const NORMALIZE_CLASS = Symbol(``);
|
|
40
|
+
const NORMALIZE_STYLE = Symbol(``);
|
|
41
|
+
const NORMALIZE_PROPS = Symbol(``);
|
|
42
|
+
const GUARD_REACTIVE_PROPS = Symbol(``);
|
|
43
|
+
const TO_HANDLERS = Symbol(``);
|
|
44
|
+
const CAMELIZE = Symbol(``);
|
|
45
|
+
const CAPITALIZE = Symbol(``);
|
|
46
|
+
const TO_HANDLER_KEY = Symbol(``);
|
|
47
|
+
const SET_BLOCK_TRACKING = Symbol(``);
|
|
48
|
+
const PUSH_SCOPE_ID = Symbol(``);
|
|
49
|
+
const POP_SCOPE_ID = Symbol(``);
|
|
50
|
+
const WITH_CTX = Symbol(``);
|
|
51
|
+
const UNREF = Symbol(``);
|
|
52
|
+
const IS_REF = Symbol(``);
|
|
53
|
+
const WITH_MEMO = Symbol(``);
|
|
54
|
+
const IS_MEMO_SAME = Symbol(``);
|
|
55
|
+
const helperNameMap = {
|
|
56
|
+
[FRAGMENT]: `Fragment`,
|
|
57
|
+
[TELEPORT]: `Teleport`,
|
|
58
|
+
[SUSPENSE]: `Suspense`,
|
|
59
|
+
[KEEP_ALIVE]: `KeepAlive`,
|
|
60
|
+
[BASE_TRANSITION]: `BaseTransition`,
|
|
61
|
+
[OPEN_BLOCK]: `openBlock`,
|
|
62
|
+
[CREATE_BLOCK]: `createBlock`,
|
|
63
|
+
[CREATE_ELEMENT_BLOCK]: `createElementBlock`,
|
|
64
|
+
[CREATE_VNODE]: `createVNode`,
|
|
65
|
+
[CREATE_ELEMENT_VNODE]: `createElementVNode`,
|
|
66
|
+
[CREATE_COMMENT]: `createCommentVNode`,
|
|
67
|
+
[CREATE_TEXT]: `createTextVNode`,
|
|
68
|
+
[CREATE_STATIC]: `createStaticVNode`,
|
|
69
|
+
[RESOLVE_COMPONENT]: `resolveComponent`,
|
|
70
|
+
[RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
|
|
71
|
+
[RESOLVE_DIRECTIVE]: `resolveDirective`,
|
|
72
|
+
[RESOLVE_FILTER]: `resolveFilter`,
|
|
73
|
+
[WITH_DIRECTIVES]: `withDirectives`,
|
|
74
|
+
[RENDER_LIST]: `renderList`,
|
|
75
|
+
[RENDER_SLOT]: `renderSlot`,
|
|
76
|
+
[CREATE_SLOTS]: `createSlots`,
|
|
77
|
+
[TO_DISPLAY_STRING]: `toDisplayString`,
|
|
78
|
+
[MERGE_PROPS]: `mergeProps`,
|
|
79
|
+
[NORMALIZE_CLASS]: `normalizeClass`,
|
|
80
|
+
[NORMALIZE_STYLE]: `normalizeStyle`,
|
|
81
|
+
[NORMALIZE_PROPS]: `normalizeProps`,
|
|
82
|
+
[GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
|
|
83
|
+
[TO_HANDLERS]: `toHandlers`,
|
|
84
|
+
[CAMELIZE]: `camelize`,
|
|
85
|
+
[CAPITALIZE]: `capitalize`,
|
|
86
|
+
[TO_HANDLER_KEY]: `toHandlerKey`,
|
|
87
|
+
[SET_BLOCK_TRACKING]: `setBlockTracking`,
|
|
88
|
+
[PUSH_SCOPE_ID]: `pushScopeId`,
|
|
89
|
+
[POP_SCOPE_ID]: `popScopeId`,
|
|
90
|
+
[WITH_CTX]: `withCtx`,
|
|
91
|
+
[UNREF]: `unref`,
|
|
92
|
+
[IS_REF]: `isRef`,
|
|
93
|
+
[WITH_MEMO]: `withMemo`,
|
|
94
|
+
[IS_MEMO_SAME]: `isMemoSame`
|
|
95
|
+
};
|
|
96
|
+
function registerRuntimeHelpers(helpers) {
|
|
97
|
+
Object.getOwnPropertySymbols(helpers).forEach((s) => {
|
|
98
|
+
helperNameMap[s] = helpers[s];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const Namespaces = {
|
|
102
|
+
"HTML": 0,
|
|
103
|
+
"0": "HTML",
|
|
104
|
+
"SVG": 1,
|
|
105
|
+
"1": "SVG",
|
|
106
|
+
"MATH_ML": 2,
|
|
107
|
+
"2": "MATH_ML"
|
|
108
|
+
};
|
|
109
|
+
const NodeTypes = {
|
|
110
|
+
"ROOT": 0,
|
|
111
|
+
"0": "ROOT",
|
|
112
|
+
"ELEMENT": 1,
|
|
113
|
+
"1": "ELEMENT",
|
|
114
|
+
"TEXT": 2,
|
|
115
|
+
"2": "TEXT",
|
|
116
|
+
"COMMENT": 3,
|
|
117
|
+
"3": "COMMENT",
|
|
118
|
+
"SIMPLE_EXPRESSION": 4,
|
|
119
|
+
"4": "SIMPLE_EXPRESSION",
|
|
120
|
+
"INTERPOLATION": 5,
|
|
121
|
+
"5": "INTERPOLATION",
|
|
122
|
+
"ATTRIBUTE": 6,
|
|
123
|
+
"6": "ATTRIBUTE",
|
|
124
|
+
"DIRECTIVE": 7,
|
|
125
|
+
"7": "DIRECTIVE",
|
|
126
|
+
"COMPOUND_EXPRESSION": 8,
|
|
127
|
+
"8": "COMPOUND_EXPRESSION",
|
|
128
|
+
"IF": 9,
|
|
129
|
+
"9": "IF",
|
|
130
|
+
"IF_BRANCH": 10,
|
|
131
|
+
"10": "IF_BRANCH",
|
|
132
|
+
"FOR": 11,
|
|
133
|
+
"11": "FOR",
|
|
134
|
+
"TEXT_CALL": 12,
|
|
135
|
+
"12": "TEXT_CALL",
|
|
136
|
+
"VNODE_CALL": 13,
|
|
137
|
+
"13": "VNODE_CALL",
|
|
138
|
+
"JS_CALL_EXPRESSION": 14,
|
|
139
|
+
"14": "JS_CALL_EXPRESSION",
|
|
140
|
+
"JS_OBJECT_EXPRESSION": 15,
|
|
141
|
+
"15": "JS_OBJECT_EXPRESSION",
|
|
142
|
+
"JS_PROPERTY": 16,
|
|
143
|
+
"16": "JS_PROPERTY",
|
|
144
|
+
"JS_ARRAY_EXPRESSION": 17,
|
|
145
|
+
"17": "JS_ARRAY_EXPRESSION",
|
|
146
|
+
"JS_FUNCTION_EXPRESSION": 18,
|
|
147
|
+
"18": "JS_FUNCTION_EXPRESSION",
|
|
148
|
+
"JS_CONDITIONAL_EXPRESSION": 19,
|
|
149
|
+
"19": "JS_CONDITIONAL_EXPRESSION",
|
|
150
|
+
"JS_CACHE_EXPRESSION": 20,
|
|
151
|
+
"20": "JS_CACHE_EXPRESSION",
|
|
152
|
+
"JS_BLOCK_STATEMENT": 21,
|
|
153
|
+
"21": "JS_BLOCK_STATEMENT",
|
|
154
|
+
"JS_TEMPLATE_LITERAL": 22,
|
|
155
|
+
"22": "JS_TEMPLATE_LITERAL",
|
|
156
|
+
"JS_IF_STATEMENT": 23,
|
|
157
|
+
"23": "JS_IF_STATEMENT",
|
|
158
|
+
"JS_ASSIGNMENT_EXPRESSION": 24,
|
|
159
|
+
"24": "JS_ASSIGNMENT_EXPRESSION",
|
|
160
|
+
"JS_SEQUENCE_EXPRESSION": 25,
|
|
161
|
+
"25": "JS_SEQUENCE_EXPRESSION",
|
|
162
|
+
"JS_RETURN_STATEMENT": 26,
|
|
163
|
+
"26": "JS_RETURN_STATEMENT"
|
|
164
|
+
};
|
|
165
|
+
const ElementTypes = {
|
|
166
|
+
"ELEMENT": 0,
|
|
167
|
+
"0": "ELEMENT",
|
|
168
|
+
"COMPONENT": 1,
|
|
169
|
+
"1": "COMPONENT",
|
|
170
|
+
"SLOT": 2,
|
|
171
|
+
"2": "SLOT",
|
|
172
|
+
"TEMPLATE": 3,
|
|
173
|
+
"3": "TEMPLATE"
|
|
174
|
+
};
|
|
175
|
+
const ConstantTypes = {
|
|
176
|
+
"NOT_CONSTANT": 0,
|
|
177
|
+
"0": "NOT_CONSTANT",
|
|
178
|
+
"CAN_SKIP_PATCH": 1,
|
|
179
|
+
"1": "CAN_SKIP_PATCH",
|
|
180
|
+
"CAN_CACHE": 2,
|
|
181
|
+
"2": "CAN_CACHE",
|
|
182
|
+
"CAN_STRINGIFY": 3,
|
|
183
|
+
"3": "CAN_STRINGIFY"
|
|
184
|
+
};
|
|
185
|
+
const locStub = {
|
|
186
|
+
start: {
|
|
187
|
+
line: 1,
|
|
188
|
+
column: 1,
|
|
189
|
+
offset: 0
|
|
190
|
+
},
|
|
191
|
+
end: {
|
|
192
|
+
line: 1,
|
|
193
|
+
column: 1,
|
|
194
|
+
offset: 0
|
|
195
|
+
},
|
|
196
|
+
source: ""
|
|
197
|
+
};
|
|
198
|
+
function createRoot(children, source = "") {
|
|
199
|
+
return {
|
|
200
|
+
type: 0,
|
|
201
|
+
source,
|
|
202
|
+
children,
|
|
203
|
+
helpers: /* @__PURE__ */ new Set(),
|
|
204
|
+
components: [],
|
|
205
|
+
directives: [],
|
|
206
|
+
hoists: [],
|
|
207
|
+
imports: [],
|
|
208
|
+
cached: [],
|
|
209
|
+
temps: 0,
|
|
210
|
+
codegenNode: void 0,
|
|
211
|
+
loc: locStub
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent$1 = false, loc = locStub) {
|
|
215
|
+
if (context) {
|
|
216
|
+
if (isBlock) {
|
|
217
|
+
context.helper(OPEN_BLOCK);
|
|
218
|
+
context.helper(getVNodeBlockHelper(context.inSSR, isComponent$1));
|
|
219
|
+
} else context.helper(getVNodeHelper(context.inSSR, isComponent$1));
|
|
220
|
+
if (directives) context.helper(WITH_DIRECTIVES);
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
type: 13,
|
|
224
|
+
tag,
|
|
225
|
+
props,
|
|
226
|
+
children,
|
|
227
|
+
patchFlag,
|
|
228
|
+
dynamicProps,
|
|
229
|
+
directives,
|
|
230
|
+
isBlock,
|
|
231
|
+
disableTracking,
|
|
232
|
+
isComponent: isComponent$1,
|
|
233
|
+
loc
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function createArrayExpression(elements, loc = locStub) {
|
|
237
|
+
return {
|
|
238
|
+
type: 17,
|
|
239
|
+
loc,
|
|
240
|
+
elements
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function createObjectExpression(properties, loc = locStub) {
|
|
244
|
+
return {
|
|
245
|
+
type: 15,
|
|
246
|
+
loc,
|
|
247
|
+
properties
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function createObjectProperty(key, value) {
|
|
251
|
+
return {
|
|
252
|
+
type: 16,
|
|
253
|
+
loc: locStub,
|
|
254
|
+
key: shared.isString(key) ? createSimpleExpression(key, true) : key,
|
|
255
|
+
value
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
|
|
259
|
+
return {
|
|
260
|
+
type: 4,
|
|
261
|
+
loc,
|
|
262
|
+
content,
|
|
263
|
+
isStatic,
|
|
264
|
+
constType: isStatic ? 3 : constType
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function createInterpolation(content, loc) {
|
|
268
|
+
return {
|
|
269
|
+
type: 5,
|
|
270
|
+
loc,
|
|
271
|
+
content: shared.isString(content) ? createSimpleExpression(content, false, loc) : content
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function createCompoundExpression(children, loc = locStub) {
|
|
275
|
+
return {
|
|
276
|
+
type: 8,
|
|
277
|
+
loc,
|
|
278
|
+
children
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function createCallExpression(callee, args = [], loc = locStub) {
|
|
282
|
+
return {
|
|
283
|
+
type: 14,
|
|
284
|
+
loc,
|
|
285
|
+
callee,
|
|
286
|
+
arguments: args
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
|
|
290
|
+
return {
|
|
291
|
+
type: 18,
|
|
292
|
+
params,
|
|
293
|
+
returns,
|
|
294
|
+
newline,
|
|
295
|
+
isSlot,
|
|
296
|
+
loc
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function createConditionalExpression(test, consequent, alternate, newline = true) {
|
|
300
|
+
return {
|
|
301
|
+
type: 19,
|
|
302
|
+
test,
|
|
303
|
+
consequent,
|
|
304
|
+
alternate,
|
|
305
|
+
newline,
|
|
306
|
+
loc: locStub
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
|
|
310
|
+
return {
|
|
311
|
+
type: 20,
|
|
312
|
+
index,
|
|
313
|
+
value,
|
|
314
|
+
needPauseTracking,
|
|
315
|
+
inVOnce,
|
|
316
|
+
needArraySpread: false,
|
|
317
|
+
loc: locStub
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function createBlockStatement(body) {
|
|
321
|
+
return {
|
|
322
|
+
type: 21,
|
|
323
|
+
body,
|
|
324
|
+
loc: locStub
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function createTemplateLiteral(elements) {
|
|
328
|
+
return {
|
|
329
|
+
type: 22,
|
|
330
|
+
elements,
|
|
331
|
+
loc: locStub
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
function createIfStatement(test, consequent, alternate) {
|
|
335
|
+
return {
|
|
336
|
+
type: 23,
|
|
337
|
+
test,
|
|
338
|
+
consequent,
|
|
339
|
+
alternate,
|
|
340
|
+
loc: locStub
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function createAssignmentExpression(left, right) {
|
|
344
|
+
return {
|
|
345
|
+
type: 24,
|
|
346
|
+
left,
|
|
347
|
+
right,
|
|
348
|
+
loc: locStub
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function createSequenceExpression(expressions) {
|
|
352
|
+
return {
|
|
353
|
+
type: 25,
|
|
354
|
+
expressions,
|
|
355
|
+
loc: locStub
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function createReturnStatement(returns) {
|
|
359
|
+
return {
|
|
360
|
+
type: 26,
|
|
361
|
+
returns,
|
|
362
|
+
loc: locStub
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function getVNodeHelper(ssr, isComponent$1) {
|
|
366
|
+
return ssr || isComponent$1 ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
367
|
+
}
|
|
368
|
+
function getVNodeBlockHelper(ssr, isComponent$1) {
|
|
369
|
+
return ssr || isComponent$1 ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
|
370
|
+
}
|
|
371
|
+
function convertToBlock(node, { helper, removeHelper, inSSR }) {
|
|
372
|
+
if (!node.isBlock) {
|
|
373
|
+
node.isBlock = true;
|
|
374
|
+
removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
|
375
|
+
helper(OPEN_BLOCK);
|
|
376
|
+
helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const defaultDelimitersOpen = new Uint8Array([123, 123]);
|
|
380
|
+
const defaultDelimitersClose = new Uint8Array([125, 125]);
|
|
381
|
+
function isTagStartChar(c) {
|
|
382
|
+
return c >= 97 && c <= 122 || c >= 65 && c <= 90;
|
|
383
|
+
}
|
|
384
|
+
function isWhitespace(c) {
|
|
385
|
+
return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
|
|
386
|
+
}
|
|
387
|
+
function isEndOfTagSection(c) {
|
|
388
|
+
return c === 47 || c === 62 || isWhitespace(c);
|
|
389
|
+
}
|
|
390
|
+
function toCharCodes(str) {
|
|
391
|
+
const ret = new Uint8Array(str.length);
|
|
392
|
+
for (let i = 0; i < str.length; i++) ret[i] = str.charCodeAt(i);
|
|
393
|
+
return ret;
|
|
394
|
+
}
|
|
395
|
+
const Sequences = {
|
|
396
|
+
Cdata: new Uint8Array([
|
|
397
|
+
67,
|
|
398
|
+
68,
|
|
399
|
+
65,
|
|
400
|
+
84,
|
|
401
|
+
65,
|
|
402
|
+
91
|
|
403
|
+
]),
|
|
404
|
+
CdataEnd: new Uint8Array([
|
|
405
|
+
93,
|
|
406
|
+
93,
|
|
407
|
+
62
|
|
408
|
+
]),
|
|
409
|
+
CommentEnd: new Uint8Array([
|
|
410
|
+
45,
|
|
411
|
+
45,
|
|
412
|
+
62
|
|
413
|
+
]),
|
|
414
|
+
ScriptEnd: new Uint8Array([
|
|
415
|
+
60,
|
|
416
|
+
47,
|
|
417
|
+
115,
|
|
418
|
+
99,
|
|
419
|
+
114,
|
|
420
|
+
105,
|
|
421
|
+
112,
|
|
422
|
+
116
|
|
423
|
+
]),
|
|
424
|
+
StyleEnd: new Uint8Array([
|
|
425
|
+
60,
|
|
426
|
+
47,
|
|
427
|
+
115,
|
|
428
|
+
116,
|
|
429
|
+
121,
|
|
430
|
+
108,
|
|
431
|
+
101
|
|
432
|
+
]),
|
|
433
|
+
TitleEnd: new Uint8Array([
|
|
434
|
+
60,
|
|
435
|
+
47,
|
|
436
|
+
116,
|
|
437
|
+
105,
|
|
438
|
+
116,
|
|
439
|
+
108,
|
|
440
|
+
101
|
|
441
|
+
]),
|
|
442
|
+
TextareaEnd: new Uint8Array([
|
|
443
|
+
60,
|
|
444
|
+
47,
|
|
445
|
+
116,
|
|
446
|
+
101,
|
|
447
|
+
120,
|
|
448
|
+
116,
|
|
449
|
+
97,
|
|
450
|
+
114,
|
|
451
|
+
101,
|
|
452
|
+
97
|
|
453
|
+
])
|
|
454
|
+
};
|
|
455
|
+
var Tokenizer = class {
|
|
456
|
+
constructor(stack$1, cbs) {
|
|
457
|
+
this.stack = stack$1;
|
|
458
|
+
this.cbs = cbs;
|
|
459
|
+
/** The current state the tokenizer is in. */
|
|
460
|
+
this.state = 1;
|
|
461
|
+
/** The read buffer. */
|
|
462
|
+
this.buffer = "";
|
|
463
|
+
/** The beginning of the section that is currently being read. */
|
|
464
|
+
this.sectionStart = 0;
|
|
465
|
+
/** The index within the buffer that we are currently looking at. */
|
|
466
|
+
this.index = 0;
|
|
467
|
+
/** The start of the last entity. */
|
|
468
|
+
this.entityStart = 0;
|
|
469
|
+
/** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
|
|
470
|
+
this.baseState = 1;
|
|
471
|
+
/** For special parsing behavior inside of script and style tags. */
|
|
472
|
+
this.inRCDATA = false;
|
|
473
|
+
/** For disabling RCDATA tags handling */
|
|
474
|
+
this.inXML = false;
|
|
475
|
+
/** For disabling interpolation parsing in v-pre */
|
|
476
|
+
this.inVPre = false;
|
|
477
|
+
/** Record newline positions for fast line / column calculation */
|
|
478
|
+
this.newlines = [];
|
|
479
|
+
this.mode = 0;
|
|
480
|
+
this.delimiterOpen = defaultDelimitersOpen;
|
|
481
|
+
this.delimiterClose = defaultDelimitersClose;
|
|
482
|
+
this.delimiterIndex = -1;
|
|
483
|
+
this.currentSequence = void 0;
|
|
484
|
+
this.sequenceIndex = 0;
|
|
485
|
+
this.entityDecoder = new decode_js.EntityDecoder(decode_js.htmlDecodeTree, (cp, consumed) => this.emitCodePoint(cp, consumed));
|
|
486
|
+
}
|
|
487
|
+
get inSFCRoot() {
|
|
488
|
+
return this.mode === 2 && this.stack.length === 0;
|
|
489
|
+
}
|
|
490
|
+
reset() {
|
|
491
|
+
this.state = 1;
|
|
492
|
+
this.mode = 0;
|
|
493
|
+
this.buffer = "";
|
|
494
|
+
this.sectionStart = 0;
|
|
495
|
+
this.index = 0;
|
|
496
|
+
this.baseState = 1;
|
|
497
|
+
this.inRCDATA = false;
|
|
498
|
+
this.currentSequence = void 0;
|
|
499
|
+
this.newlines.length = 0;
|
|
500
|
+
this.delimiterOpen = defaultDelimitersOpen;
|
|
501
|
+
this.delimiterClose = defaultDelimitersClose;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Generate Position object with line / column information using recorded
|
|
505
|
+
* newline positions. We know the index is always going to be an already
|
|
506
|
+
* processed index, so all the newlines up to this index should have been
|
|
507
|
+
* recorded.
|
|
508
|
+
*/
|
|
509
|
+
getPos(index) {
|
|
510
|
+
let line = 1;
|
|
511
|
+
let column = index + 1;
|
|
512
|
+
for (let i = this.newlines.length - 1; i >= 0; i--) {
|
|
513
|
+
const newlineIndex = this.newlines[i];
|
|
514
|
+
if (index > newlineIndex) {
|
|
515
|
+
line = i + 2;
|
|
516
|
+
column = index - newlineIndex;
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
column,
|
|
522
|
+
line,
|
|
523
|
+
offset: index
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
peek() {
|
|
527
|
+
return this.buffer.charCodeAt(this.index + 1);
|
|
528
|
+
}
|
|
529
|
+
stateText(c) {
|
|
530
|
+
if (c === 60) {
|
|
531
|
+
if (this.index > this.sectionStart) this.cbs.ontext(this.sectionStart, this.index);
|
|
532
|
+
this.state = 5;
|
|
533
|
+
this.sectionStart = this.index;
|
|
534
|
+
} else if (c === 38) this.startEntity();
|
|
535
|
+
else if (!this.inVPre && c === this.delimiterOpen[0]) {
|
|
536
|
+
this.state = 2;
|
|
537
|
+
this.delimiterIndex = 0;
|
|
538
|
+
this.stateInterpolationOpen(c);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
stateInterpolationOpen(c) {
|
|
542
|
+
if (c === this.delimiterOpen[this.delimiterIndex]) if (this.delimiterIndex === this.delimiterOpen.length - 1) {
|
|
543
|
+
const start = this.index + 1 - this.delimiterOpen.length;
|
|
544
|
+
if (start > this.sectionStart) this.cbs.ontext(this.sectionStart, start);
|
|
545
|
+
this.state = 3;
|
|
546
|
+
this.sectionStart = start;
|
|
547
|
+
} else this.delimiterIndex++;
|
|
548
|
+
else if (this.inRCDATA) {
|
|
549
|
+
this.state = 32;
|
|
550
|
+
this.stateInRCDATA(c);
|
|
551
|
+
} else {
|
|
552
|
+
this.state = 1;
|
|
553
|
+
this.stateText(c);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
stateInterpolation(c) {
|
|
557
|
+
if (c === this.delimiterClose[0]) {
|
|
558
|
+
this.state = 4;
|
|
559
|
+
this.delimiterIndex = 0;
|
|
560
|
+
this.stateInterpolationClose(c);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
stateInterpolationClose(c) {
|
|
564
|
+
if (c === this.delimiterClose[this.delimiterIndex]) if (this.delimiterIndex === this.delimiterClose.length - 1) {
|
|
565
|
+
this.cbs.oninterpolation(this.sectionStart, this.index + 1);
|
|
566
|
+
if (this.inRCDATA) this.state = 32;
|
|
567
|
+
else this.state = 1;
|
|
568
|
+
this.sectionStart = this.index + 1;
|
|
569
|
+
} else this.delimiterIndex++;
|
|
570
|
+
else {
|
|
571
|
+
this.state = 3;
|
|
572
|
+
this.stateInterpolation(c);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
stateSpecialStartSequence(c) {
|
|
576
|
+
const isEnd = this.sequenceIndex === this.currentSequence.length;
|
|
577
|
+
if (!(isEnd ? isEndOfTagSection(c) : (c | 32) === this.currentSequence[this.sequenceIndex])) this.inRCDATA = false;
|
|
578
|
+
else if (!isEnd) {
|
|
579
|
+
this.sequenceIndex++;
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
this.sequenceIndex = 0;
|
|
583
|
+
this.state = 6;
|
|
584
|
+
this.stateInTagName(c);
|
|
585
|
+
}
|
|
586
|
+
/** Look for an end tag. For <title> and <textarea>, also decode entities. */
|
|
587
|
+
stateInRCDATA(c) {
|
|
588
|
+
if (this.sequenceIndex === this.currentSequence.length) {
|
|
589
|
+
if (c === 62 || isWhitespace(c)) {
|
|
590
|
+
const endOfText = this.index - this.currentSequence.length;
|
|
591
|
+
if (this.sectionStart < endOfText) {
|
|
592
|
+
const actualIndex = this.index;
|
|
593
|
+
this.index = endOfText;
|
|
594
|
+
this.cbs.ontext(this.sectionStart, endOfText);
|
|
595
|
+
this.index = actualIndex;
|
|
596
|
+
}
|
|
597
|
+
this.sectionStart = endOfText + 2;
|
|
598
|
+
this.stateInClosingTagName(c);
|
|
599
|
+
this.inRCDATA = false;
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
this.sequenceIndex = 0;
|
|
603
|
+
}
|
|
604
|
+
if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
|
|
605
|
+
else if (this.sequenceIndex === 0) {
|
|
606
|
+
if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
|
|
607
|
+
if (c === 38) this.startEntity();
|
|
608
|
+
else if (!this.inVPre && c === this.delimiterOpen[0]) {
|
|
609
|
+
this.state = 2;
|
|
610
|
+
this.delimiterIndex = 0;
|
|
611
|
+
this.stateInterpolationOpen(c);
|
|
612
|
+
}
|
|
613
|
+
} else if (this.fastForwardTo(60)) this.sequenceIndex = 1;
|
|
614
|
+
} else this.sequenceIndex = Number(c === 60);
|
|
615
|
+
}
|
|
616
|
+
stateCDATASequence(c) {
|
|
617
|
+
if (c === Sequences.Cdata[this.sequenceIndex]) {
|
|
618
|
+
if (++this.sequenceIndex === Sequences.Cdata.length) {
|
|
619
|
+
this.state = 28;
|
|
620
|
+
this.currentSequence = Sequences.CdataEnd;
|
|
621
|
+
this.sequenceIndex = 0;
|
|
622
|
+
this.sectionStart = this.index + 1;
|
|
623
|
+
}
|
|
624
|
+
} else {
|
|
625
|
+
this.sequenceIndex = 0;
|
|
626
|
+
this.state = 23;
|
|
627
|
+
this.stateInDeclaration(c);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* When we wait for one specific character, we can speed things up
|
|
632
|
+
* by skipping through the buffer until we find it.
|
|
633
|
+
*
|
|
634
|
+
* @returns Whether the character was found.
|
|
635
|
+
*/
|
|
636
|
+
fastForwardTo(c) {
|
|
637
|
+
while (++this.index < this.buffer.length) {
|
|
638
|
+
const cc = this.buffer.charCodeAt(this.index);
|
|
639
|
+
if (cc === 10) this.newlines.push(this.index);
|
|
640
|
+
if (cc === c) return true;
|
|
641
|
+
}
|
|
642
|
+
this.index = this.buffer.length - 1;
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Comments and CDATA end with `-->` and `]]>`.
|
|
647
|
+
*
|
|
648
|
+
* Their common qualities are:
|
|
649
|
+
* - Their end sequences have a distinct character they start with.
|
|
650
|
+
* - That character is then repeated, so we have to check multiple repeats.
|
|
651
|
+
* - All characters but the start character of the sequence can be skipped.
|
|
652
|
+
*/
|
|
653
|
+
stateInCommentLike(c) {
|
|
654
|
+
if (c === this.currentSequence[this.sequenceIndex]) {
|
|
655
|
+
if (++this.sequenceIndex === this.currentSequence.length) {
|
|
656
|
+
if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, this.index - 2);
|
|
657
|
+
else this.cbs.oncomment(this.sectionStart, this.index - 2);
|
|
658
|
+
this.sequenceIndex = 0;
|
|
659
|
+
this.sectionStart = this.index + 1;
|
|
660
|
+
this.state = 1;
|
|
661
|
+
}
|
|
662
|
+
} else if (this.sequenceIndex === 0) {
|
|
663
|
+
if (this.fastForwardTo(this.currentSequence[0])) this.sequenceIndex = 1;
|
|
664
|
+
} else if (c !== this.currentSequence[this.sequenceIndex - 1]) this.sequenceIndex = 0;
|
|
665
|
+
}
|
|
666
|
+
startSpecial(sequence, offset) {
|
|
667
|
+
this.enterRCDATA(sequence, offset);
|
|
668
|
+
this.state = 31;
|
|
669
|
+
}
|
|
670
|
+
enterRCDATA(sequence, offset) {
|
|
671
|
+
this.inRCDATA = true;
|
|
672
|
+
this.currentSequence = sequence;
|
|
673
|
+
this.sequenceIndex = offset;
|
|
674
|
+
}
|
|
675
|
+
stateBeforeTagName(c) {
|
|
676
|
+
if (c === 33) {
|
|
677
|
+
this.state = 22;
|
|
678
|
+
this.sectionStart = this.index + 1;
|
|
679
|
+
} else if (c === 63) {
|
|
680
|
+
this.state = 24;
|
|
681
|
+
this.sectionStart = this.index + 1;
|
|
682
|
+
} else if (isTagStartChar(c)) {
|
|
683
|
+
this.sectionStart = this.index;
|
|
684
|
+
if (this.mode === 0) this.state = 6;
|
|
685
|
+
else if (this.inSFCRoot) this.state = 34;
|
|
686
|
+
else if (!this.inXML) if (c === 116) this.state = 30;
|
|
687
|
+
else this.state = c === 115 ? 29 : 6;
|
|
688
|
+
else this.state = 6;
|
|
689
|
+
} else if (c === 47) this.state = 8;
|
|
690
|
+
else {
|
|
691
|
+
this.state = 1;
|
|
692
|
+
this.stateText(c);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
stateInTagName(c) {
|
|
696
|
+
if (isEndOfTagSection(c)) this.handleTagName(c);
|
|
697
|
+
}
|
|
698
|
+
stateInSFCRootTagName(c) {
|
|
699
|
+
if (isEndOfTagSection(c)) {
|
|
700
|
+
const tag = this.buffer.slice(this.sectionStart, this.index);
|
|
701
|
+
if (tag !== "template") this.enterRCDATA(toCharCodes(`</` + tag), 0);
|
|
702
|
+
this.handleTagName(c);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
handleTagName(c) {
|
|
706
|
+
this.cbs.onopentagname(this.sectionStart, this.index);
|
|
707
|
+
this.sectionStart = -1;
|
|
708
|
+
this.state = 11;
|
|
709
|
+
this.stateBeforeAttrName(c);
|
|
710
|
+
}
|
|
711
|
+
stateBeforeClosingTagName(c) {
|
|
712
|
+
if (isWhitespace(c));
|
|
713
|
+
else if (c === 62) {
|
|
714
|
+
this.cbs.onerr(14, this.index);
|
|
715
|
+
this.state = 1;
|
|
716
|
+
this.sectionStart = this.index + 1;
|
|
717
|
+
} else {
|
|
718
|
+
this.state = isTagStartChar(c) ? 9 : 27;
|
|
719
|
+
this.sectionStart = this.index;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
stateInClosingTagName(c) {
|
|
723
|
+
if (c === 62 || isWhitespace(c)) {
|
|
724
|
+
this.cbs.onclosetag(this.sectionStart, this.index);
|
|
725
|
+
this.sectionStart = -1;
|
|
726
|
+
this.state = 10;
|
|
727
|
+
this.stateAfterClosingTagName(c);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
stateAfterClosingTagName(c) {
|
|
731
|
+
if (c === 62) {
|
|
732
|
+
this.state = 1;
|
|
733
|
+
this.sectionStart = this.index + 1;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
stateBeforeAttrName(c) {
|
|
737
|
+
if (c === 62) {
|
|
738
|
+
this.cbs.onopentagend(this.index);
|
|
739
|
+
if (this.inRCDATA) this.state = 32;
|
|
740
|
+
else this.state = 1;
|
|
741
|
+
this.sectionStart = this.index + 1;
|
|
742
|
+
} else if (c === 47) {
|
|
743
|
+
this.state = 7;
|
|
744
|
+
if (this.peek() !== 62) this.cbs.onerr(22, this.index);
|
|
745
|
+
} else if (c === 60 && this.peek() === 47) {
|
|
746
|
+
this.cbs.onopentagend(this.index);
|
|
747
|
+
this.state = 5;
|
|
748
|
+
this.sectionStart = this.index;
|
|
749
|
+
} else if (!isWhitespace(c)) {
|
|
750
|
+
if (c === 61) this.cbs.onerr(19, this.index);
|
|
751
|
+
this.handleAttrStart(c);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
handleAttrStart(c) {
|
|
755
|
+
if (c === 118 && this.peek() === 45) {
|
|
756
|
+
this.state = 13;
|
|
757
|
+
this.sectionStart = this.index;
|
|
758
|
+
} else if (c === 46 || c === 58 || c === 64 || c === 35) {
|
|
759
|
+
this.cbs.ondirname(this.index, this.index + 1);
|
|
760
|
+
this.state = 14;
|
|
761
|
+
this.sectionStart = this.index + 1;
|
|
762
|
+
} else {
|
|
763
|
+
this.state = 12;
|
|
764
|
+
this.sectionStart = this.index;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
stateInSelfClosingTag(c) {
|
|
768
|
+
if (c === 62) {
|
|
769
|
+
this.cbs.onselfclosingtag(this.index);
|
|
770
|
+
this.state = 1;
|
|
771
|
+
this.sectionStart = this.index + 1;
|
|
772
|
+
this.inRCDATA = false;
|
|
773
|
+
} else if (!isWhitespace(c)) {
|
|
774
|
+
this.state = 11;
|
|
775
|
+
this.stateBeforeAttrName(c);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
stateInAttrName(c) {
|
|
779
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
780
|
+
this.cbs.onattribname(this.sectionStart, this.index);
|
|
781
|
+
this.handleAttrNameEnd(c);
|
|
782
|
+
} else if (c === 34 || c === 39 || c === 60) this.cbs.onerr(17, this.index);
|
|
783
|
+
}
|
|
784
|
+
stateInDirName(c) {
|
|
785
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
786
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
787
|
+
this.handleAttrNameEnd(c);
|
|
788
|
+
} else if (c === 58) {
|
|
789
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
790
|
+
this.state = 14;
|
|
791
|
+
this.sectionStart = this.index + 1;
|
|
792
|
+
} else if (c === 46) {
|
|
793
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
794
|
+
this.state = 16;
|
|
795
|
+
this.sectionStart = this.index + 1;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
stateInDirArg(c) {
|
|
799
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
800
|
+
this.cbs.ondirarg(this.sectionStart, this.index);
|
|
801
|
+
this.handleAttrNameEnd(c);
|
|
802
|
+
} else if (c === 91) this.state = 15;
|
|
803
|
+
else if (c === 46) {
|
|
804
|
+
this.cbs.ondirarg(this.sectionStart, this.index);
|
|
805
|
+
this.state = 16;
|
|
806
|
+
this.sectionStart = this.index + 1;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
stateInDynamicDirArg(c) {
|
|
810
|
+
if (c === 93) this.state = 14;
|
|
811
|
+
else if (c === 61 || isEndOfTagSection(c)) {
|
|
812
|
+
this.cbs.ondirarg(this.sectionStart, this.index + 1);
|
|
813
|
+
this.handleAttrNameEnd(c);
|
|
814
|
+
this.cbs.onerr(27, this.index);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
stateInDirModifier(c) {
|
|
818
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
819
|
+
this.cbs.ondirmodifier(this.sectionStart, this.index);
|
|
820
|
+
this.handleAttrNameEnd(c);
|
|
821
|
+
} else if (c === 46) {
|
|
822
|
+
this.cbs.ondirmodifier(this.sectionStart, this.index);
|
|
823
|
+
this.sectionStart = this.index + 1;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
handleAttrNameEnd(c) {
|
|
827
|
+
this.sectionStart = this.index;
|
|
828
|
+
this.state = 17;
|
|
829
|
+
this.cbs.onattribnameend(this.index);
|
|
830
|
+
this.stateAfterAttrName(c);
|
|
831
|
+
}
|
|
832
|
+
stateAfterAttrName(c) {
|
|
833
|
+
if (c === 61) this.state = 18;
|
|
834
|
+
else if (c === 47 || c === 62) {
|
|
835
|
+
this.cbs.onattribend(0, this.sectionStart);
|
|
836
|
+
this.sectionStart = -1;
|
|
837
|
+
this.state = 11;
|
|
838
|
+
this.stateBeforeAttrName(c);
|
|
839
|
+
} else if (!isWhitespace(c)) {
|
|
840
|
+
this.cbs.onattribend(0, this.sectionStart);
|
|
841
|
+
this.handleAttrStart(c);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
stateBeforeAttrValue(c) {
|
|
845
|
+
if (c === 34) {
|
|
846
|
+
this.state = 19;
|
|
847
|
+
this.sectionStart = this.index + 1;
|
|
848
|
+
} else if (c === 39) {
|
|
849
|
+
this.state = 20;
|
|
850
|
+
this.sectionStart = this.index + 1;
|
|
851
|
+
} else if (!isWhitespace(c)) {
|
|
852
|
+
this.sectionStart = this.index;
|
|
853
|
+
this.state = 21;
|
|
854
|
+
this.stateInAttrValueNoQuotes(c);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
handleInAttrValue(c, quote) {
|
|
858
|
+
if (c === quote || false) {
|
|
859
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
860
|
+
this.sectionStart = -1;
|
|
861
|
+
this.cbs.onattribend(quote === 34 ? 3 : 2, this.index + 1);
|
|
862
|
+
this.state = 11;
|
|
863
|
+
} else if (c === 38) this.startEntity();
|
|
864
|
+
}
|
|
865
|
+
stateInAttrValueDoubleQuotes(c) {
|
|
866
|
+
this.handleInAttrValue(c, 34);
|
|
867
|
+
}
|
|
868
|
+
stateInAttrValueSingleQuotes(c) {
|
|
869
|
+
this.handleInAttrValue(c, 39);
|
|
870
|
+
}
|
|
871
|
+
stateInAttrValueNoQuotes(c) {
|
|
872
|
+
if (isWhitespace(c) || c === 62) {
|
|
873
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
874
|
+
this.sectionStart = -1;
|
|
875
|
+
this.cbs.onattribend(1, this.index);
|
|
876
|
+
this.state = 11;
|
|
877
|
+
this.stateBeforeAttrName(c);
|
|
878
|
+
} else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) this.cbs.onerr(18, this.index);
|
|
879
|
+
else if (c === 38) this.startEntity();
|
|
880
|
+
}
|
|
881
|
+
stateBeforeDeclaration(c) {
|
|
882
|
+
if (c === 91) {
|
|
883
|
+
this.state = 26;
|
|
884
|
+
this.sequenceIndex = 0;
|
|
885
|
+
} else this.state = c === 45 ? 25 : 23;
|
|
886
|
+
}
|
|
887
|
+
stateInDeclaration(c) {
|
|
888
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
889
|
+
this.state = 1;
|
|
890
|
+
this.sectionStart = this.index + 1;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
stateInProcessingInstruction(c) {
|
|
894
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
895
|
+
this.cbs.onprocessinginstruction(this.sectionStart, this.index);
|
|
896
|
+
this.state = 1;
|
|
897
|
+
this.sectionStart = this.index + 1;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
stateBeforeComment(c) {
|
|
901
|
+
if (c === 45) {
|
|
902
|
+
this.state = 28;
|
|
903
|
+
this.currentSequence = Sequences.CommentEnd;
|
|
904
|
+
this.sequenceIndex = 2;
|
|
905
|
+
this.sectionStart = this.index + 1;
|
|
906
|
+
} else this.state = 23;
|
|
907
|
+
}
|
|
908
|
+
stateInSpecialComment(c) {
|
|
909
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
910
|
+
this.cbs.oncomment(this.sectionStart, this.index);
|
|
911
|
+
this.state = 1;
|
|
912
|
+
this.sectionStart = this.index + 1;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
stateBeforeSpecialS(c) {
|
|
916
|
+
if (c === Sequences.ScriptEnd[3]) this.startSpecial(Sequences.ScriptEnd, 4);
|
|
917
|
+
else if (c === Sequences.StyleEnd[3]) this.startSpecial(Sequences.StyleEnd, 4);
|
|
918
|
+
else {
|
|
919
|
+
this.state = 6;
|
|
920
|
+
this.stateInTagName(c);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
stateBeforeSpecialT(c) {
|
|
924
|
+
if (c === Sequences.TitleEnd[3]) this.startSpecial(Sequences.TitleEnd, 4);
|
|
925
|
+
else if (c === Sequences.TextareaEnd[3]) this.startSpecial(Sequences.TextareaEnd, 4);
|
|
926
|
+
else {
|
|
927
|
+
this.state = 6;
|
|
928
|
+
this.stateInTagName(c);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
startEntity() {
|
|
932
|
+
this.baseState = this.state;
|
|
933
|
+
this.state = 33;
|
|
934
|
+
this.entityStart = this.index;
|
|
935
|
+
this.entityDecoder.startEntity(this.baseState === 1 || this.baseState === 32 ? decode_js.DecodingMode.Legacy : decode_js.DecodingMode.Attribute);
|
|
936
|
+
}
|
|
937
|
+
stateInEntity() {
|
|
938
|
+
{
|
|
939
|
+
const length = this.entityDecoder.write(this.buffer, this.index);
|
|
940
|
+
if (length >= 0) {
|
|
941
|
+
this.state = this.baseState;
|
|
942
|
+
if (length === 0) this.index = this.entityStart;
|
|
943
|
+
} else this.index = this.buffer.length - 1;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Iterates through the buffer, calling the function corresponding to the current state.
|
|
948
|
+
*
|
|
949
|
+
* States that are more likely to be hit are higher up, as a performance improvement.
|
|
950
|
+
*/
|
|
951
|
+
parse(input) {
|
|
952
|
+
this.buffer = input;
|
|
953
|
+
while (this.index < this.buffer.length) {
|
|
954
|
+
const c = this.buffer.charCodeAt(this.index);
|
|
955
|
+
if (c === 10 && this.state !== 33) this.newlines.push(this.index);
|
|
956
|
+
switch (this.state) {
|
|
957
|
+
case 1:
|
|
958
|
+
this.stateText(c);
|
|
959
|
+
break;
|
|
960
|
+
case 2:
|
|
961
|
+
this.stateInterpolationOpen(c);
|
|
962
|
+
break;
|
|
963
|
+
case 3:
|
|
964
|
+
this.stateInterpolation(c);
|
|
965
|
+
break;
|
|
966
|
+
case 4:
|
|
967
|
+
this.stateInterpolationClose(c);
|
|
968
|
+
break;
|
|
969
|
+
case 31:
|
|
970
|
+
this.stateSpecialStartSequence(c);
|
|
971
|
+
break;
|
|
972
|
+
case 32:
|
|
973
|
+
this.stateInRCDATA(c);
|
|
974
|
+
break;
|
|
975
|
+
case 26:
|
|
976
|
+
this.stateCDATASequence(c);
|
|
977
|
+
break;
|
|
978
|
+
case 19:
|
|
979
|
+
this.stateInAttrValueDoubleQuotes(c);
|
|
980
|
+
break;
|
|
981
|
+
case 12:
|
|
982
|
+
this.stateInAttrName(c);
|
|
983
|
+
break;
|
|
984
|
+
case 13:
|
|
985
|
+
this.stateInDirName(c);
|
|
986
|
+
break;
|
|
987
|
+
case 14:
|
|
988
|
+
this.stateInDirArg(c);
|
|
989
|
+
break;
|
|
990
|
+
case 15:
|
|
991
|
+
this.stateInDynamicDirArg(c);
|
|
992
|
+
break;
|
|
993
|
+
case 16:
|
|
994
|
+
this.stateInDirModifier(c);
|
|
995
|
+
break;
|
|
996
|
+
case 28:
|
|
997
|
+
this.stateInCommentLike(c);
|
|
998
|
+
break;
|
|
999
|
+
case 27:
|
|
1000
|
+
this.stateInSpecialComment(c);
|
|
1001
|
+
break;
|
|
1002
|
+
case 11:
|
|
1003
|
+
this.stateBeforeAttrName(c);
|
|
1004
|
+
break;
|
|
1005
|
+
case 6:
|
|
1006
|
+
this.stateInTagName(c);
|
|
1007
|
+
break;
|
|
1008
|
+
case 34:
|
|
1009
|
+
this.stateInSFCRootTagName(c);
|
|
1010
|
+
break;
|
|
1011
|
+
case 9:
|
|
1012
|
+
this.stateInClosingTagName(c);
|
|
1013
|
+
break;
|
|
1014
|
+
case 5:
|
|
1015
|
+
this.stateBeforeTagName(c);
|
|
1016
|
+
break;
|
|
1017
|
+
case 17:
|
|
1018
|
+
this.stateAfterAttrName(c);
|
|
1019
|
+
break;
|
|
1020
|
+
case 20:
|
|
1021
|
+
this.stateInAttrValueSingleQuotes(c);
|
|
1022
|
+
break;
|
|
1023
|
+
case 18:
|
|
1024
|
+
this.stateBeforeAttrValue(c);
|
|
1025
|
+
break;
|
|
1026
|
+
case 8:
|
|
1027
|
+
this.stateBeforeClosingTagName(c);
|
|
1028
|
+
break;
|
|
1029
|
+
case 10:
|
|
1030
|
+
this.stateAfterClosingTagName(c);
|
|
1031
|
+
break;
|
|
1032
|
+
case 29:
|
|
1033
|
+
this.stateBeforeSpecialS(c);
|
|
1034
|
+
break;
|
|
1035
|
+
case 30:
|
|
1036
|
+
this.stateBeforeSpecialT(c);
|
|
1037
|
+
break;
|
|
1038
|
+
case 21:
|
|
1039
|
+
this.stateInAttrValueNoQuotes(c);
|
|
1040
|
+
break;
|
|
1041
|
+
case 7:
|
|
1042
|
+
this.stateInSelfClosingTag(c);
|
|
1043
|
+
break;
|
|
1044
|
+
case 23:
|
|
1045
|
+
this.stateInDeclaration(c);
|
|
1046
|
+
break;
|
|
1047
|
+
case 22:
|
|
1048
|
+
this.stateBeforeDeclaration(c);
|
|
1049
|
+
break;
|
|
1050
|
+
case 25:
|
|
1051
|
+
this.stateBeforeComment(c);
|
|
1052
|
+
break;
|
|
1053
|
+
case 24:
|
|
1054
|
+
this.stateInProcessingInstruction(c);
|
|
1055
|
+
break;
|
|
1056
|
+
case 33:
|
|
1057
|
+
this.stateInEntity();
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
this.index++;
|
|
1061
|
+
}
|
|
1062
|
+
this.cleanup();
|
|
1063
|
+
this.finish();
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Remove data that has already been consumed from the buffer.
|
|
1067
|
+
*/
|
|
1068
|
+
cleanup() {
|
|
1069
|
+
if (this.sectionStart !== this.index) {
|
|
1070
|
+
if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
|
|
1071
|
+
this.cbs.ontext(this.sectionStart, this.index);
|
|
1072
|
+
this.sectionStart = this.index;
|
|
1073
|
+
} else if (this.state === 19 || this.state === 20 || this.state === 21) {
|
|
1074
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
1075
|
+
this.sectionStart = this.index;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
finish() {
|
|
1080
|
+
if (this.state === 33) {
|
|
1081
|
+
this.entityDecoder.end();
|
|
1082
|
+
this.state = this.baseState;
|
|
1083
|
+
}
|
|
1084
|
+
this.handleTrailingData();
|
|
1085
|
+
this.cbs.onend();
|
|
1086
|
+
}
|
|
1087
|
+
/** Handle any trailing data. */
|
|
1088
|
+
handleTrailingData() {
|
|
1089
|
+
const endIndex = this.buffer.length;
|
|
1090
|
+
if (this.sectionStart >= endIndex) return;
|
|
1091
|
+
if (this.state === 28) if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, endIndex);
|
|
1092
|
+
else this.cbs.oncomment(this.sectionStart, endIndex);
|
|
1093
|
+
else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9);
|
|
1094
|
+
else this.cbs.ontext(this.sectionStart, endIndex);
|
|
1095
|
+
}
|
|
1096
|
+
emitCodePoint(cp, consumed) {
|
|
1097
|
+
if (this.baseState !== 1 && this.baseState !== 32) {
|
|
1098
|
+
if (this.sectionStart < this.entityStart) this.cbs.onattribdata(this.sectionStart, this.entityStart);
|
|
1099
|
+
this.sectionStart = this.entityStart + consumed;
|
|
1100
|
+
this.index = this.sectionStart - 1;
|
|
1101
|
+
this.cbs.onattribentity(decode_js.fromCodePoint(cp), this.entityStart, this.sectionStart);
|
|
1102
|
+
} else {
|
|
1103
|
+
if (this.sectionStart < this.entityStart) this.cbs.ontext(this.sectionStart, this.entityStart);
|
|
1104
|
+
this.sectionStart = this.entityStart + consumed;
|
|
1105
|
+
this.index = this.sectionStart - 1;
|
|
1106
|
+
this.cbs.ontextentity(decode_js.fromCodePoint(cp), this.entityStart, this.sectionStart);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
const CompilerDeprecationTypes = {
|
|
1111
|
+
"COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
|
|
1112
|
+
"COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
|
|
1113
|
+
"COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
|
|
1114
|
+
"COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
|
|
1115
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1116
|
+
"COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
|
|
1117
|
+
"COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
|
|
1118
|
+
"COMPILER_FILTERS": "COMPILER_FILTERS"
|
|
1119
|
+
};
|
|
1120
|
+
const deprecationData = {
|
|
1121
|
+
["COMPILER_IS_ON_ELEMENT"]: {
|
|
1122
|
+
message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
|
|
1123
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
1124
|
+
},
|
|
1125
|
+
["COMPILER_V_BIND_SYNC"]: {
|
|
1126
|
+
message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
|
|
1127
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
1128
|
+
},
|
|
1129
|
+
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
1130
|
+
message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
|
|
1131
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
1132
|
+
},
|
|
1133
|
+
["COMPILER_V_ON_NATIVE"]: {
|
|
1134
|
+
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
1135
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
1136
|
+
},
|
|
1137
|
+
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
1138
|
+
message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
|
|
1139
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
1140
|
+
},
|
|
1141
|
+
["COMPILER_NATIVE_TEMPLATE"]: { message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.` },
|
|
1142
|
+
["COMPILER_INLINE_TEMPLATE"]: {
|
|
1143
|
+
message: `"inline-template" has been removed in Vue 3.`,
|
|
1144
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
1145
|
+
},
|
|
1146
|
+
["COMPILER_FILTERS"]: {
|
|
1147
|
+
message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
|
|
1148
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
function getCompatValue(key, { compatConfig }) {
|
|
1152
|
+
const value = compatConfig && compatConfig[key];
|
|
1153
|
+
if (key === "MODE") return value || 3;
|
|
1154
|
+
else return value;
|
|
1155
|
+
}
|
|
1156
|
+
function isCompatEnabled(key, context) {
|
|
1157
|
+
const mode = getCompatValue("MODE", context);
|
|
1158
|
+
const value = getCompatValue(key, context);
|
|
1159
|
+
return mode === 3 ? value === true : value !== false;
|
|
1160
|
+
}
|
|
1161
|
+
function checkCompatEnabled(key, context, loc, ...args) {
|
|
1162
|
+
return isCompatEnabled(key, context);
|
|
1163
|
+
}
|
|
1164
|
+
function warnDeprecation(key, context, loc, ...args) {
|
|
1165
|
+
if (getCompatValue(key, context) === "suppress-warning") return;
|
|
1166
|
+
const { message, link } = deprecationData[key];
|
|
1167
|
+
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
1168
|
+
Details: ${link}` : ``}`;
|
|
1169
|
+
const err = new SyntaxError(msg);
|
|
1170
|
+
err.code = key;
|
|
1171
|
+
if (loc) err.loc = loc;
|
|
1172
|
+
context.onWarn(err);
|
|
1173
|
+
}
|
|
1174
|
+
function defaultOnError(error) {
|
|
1175
|
+
throw error;
|
|
1176
|
+
}
|
|
1177
|
+
function defaultOnWarn(msg) {}
|
|
1178
|
+
function createCompilerError(code, loc, messages, additionalMessage) {
|
|
1179
|
+
const msg = (messages || errorMessages)[code] + (additionalMessage || ``);
|
|
1180
|
+
const error = new SyntaxError(String(msg));
|
|
1181
|
+
error.code = code;
|
|
1182
|
+
error.loc = loc;
|
|
1183
|
+
return error;
|
|
1184
|
+
}
|
|
1185
|
+
const ErrorCodes = {
|
|
1186
|
+
"ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
|
|
1187
|
+
"0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
|
|
1188
|
+
"CDATA_IN_HTML_CONTENT": 1,
|
|
1189
|
+
"1": "CDATA_IN_HTML_CONTENT",
|
|
1190
|
+
"DUPLICATE_ATTRIBUTE": 2,
|
|
1191
|
+
"2": "DUPLICATE_ATTRIBUTE",
|
|
1192
|
+
"END_TAG_WITH_ATTRIBUTES": 3,
|
|
1193
|
+
"3": "END_TAG_WITH_ATTRIBUTES",
|
|
1194
|
+
"END_TAG_WITH_TRAILING_SOLIDUS": 4,
|
|
1195
|
+
"4": "END_TAG_WITH_TRAILING_SOLIDUS",
|
|
1196
|
+
"EOF_BEFORE_TAG_NAME": 5,
|
|
1197
|
+
"5": "EOF_BEFORE_TAG_NAME",
|
|
1198
|
+
"EOF_IN_CDATA": 6,
|
|
1199
|
+
"6": "EOF_IN_CDATA",
|
|
1200
|
+
"EOF_IN_COMMENT": 7,
|
|
1201
|
+
"7": "EOF_IN_COMMENT",
|
|
1202
|
+
"EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
|
|
1203
|
+
"8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
|
|
1204
|
+
"EOF_IN_TAG": 9,
|
|
1205
|
+
"9": "EOF_IN_TAG",
|
|
1206
|
+
"INCORRECTLY_CLOSED_COMMENT": 10,
|
|
1207
|
+
"10": "INCORRECTLY_CLOSED_COMMENT",
|
|
1208
|
+
"INCORRECTLY_OPENED_COMMENT": 11,
|
|
1209
|
+
"11": "INCORRECTLY_OPENED_COMMENT",
|
|
1210
|
+
"INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
|
|
1211
|
+
"12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
|
|
1212
|
+
"MISSING_ATTRIBUTE_VALUE": 13,
|
|
1213
|
+
"13": "MISSING_ATTRIBUTE_VALUE",
|
|
1214
|
+
"MISSING_END_TAG_NAME": 14,
|
|
1215
|
+
"14": "MISSING_END_TAG_NAME",
|
|
1216
|
+
"MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
|
|
1217
|
+
"15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
|
|
1218
|
+
"NESTED_COMMENT": 16,
|
|
1219
|
+
"16": "NESTED_COMMENT",
|
|
1220
|
+
"UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
|
|
1221
|
+
"17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
|
|
1222
|
+
"UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
|
|
1223
|
+
"18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
|
|
1224
|
+
"UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
|
|
1225
|
+
"19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
|
|
1226
|
+
"UNEXPECTED_NULL_CHARACTER": 20,
|
|
1227
|
+
"20": "UNEXPECTED_NULL_CHARACTER",
|
|
1228
|
+
"UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
|
|
1229
|
+
"21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
|
|
1230
|
+
"UNEXPECTED_SOLIDUS_IN_TAG": 22,
|
|
1231
|
+
"22": "UNEXPECTED_SOLIDUS_IN_TAG",
|
|
1232
|
+
"X_INVALID_END_TAG": 23,
|
|
1233
|
+
"23": "X_INVALID_END_TAG",
|
|
1234
|
+
"X_MISSING_END_TAG": 24,
|
|
1235
|
+
"24": "X_MISSING_END_TAG",
|
|
1236
|
+
"X_MISSING_INTERPOLATION_END": 25,
|
|
1237
|
+
"25": "X_MISSING_INTERPOLATION_END",
|
|
1238
|
+
"X_MISSING_DIRECTIVE_NAME": 26,
|
|
1239
|
+
"26": "X_MISSING_DIRECTIVE_NAME",
|
|
1240
|
+
"X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
|
|
1241
|
+
"27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
|
|
1242
|
+
"X_V_IF_NO_EXPRESSION": 28,
|
|
1243
|
+
"28": "X_V_IF_NO_EXPRESSION",
|
|
1244
|
+
"X_V_IF_SAME_KEY": 29,
|
|
1245
|
+
"29": "X_V_IF_SAME_KEY",
|
|
1246
|
+
"X_V_ELSE_NO_ADJACENT_IF": 30,
|
|
1247
|
+
"30": "X_V_ELSE_NO_ADJACENT_IF",
|
|
1248
|
+
"X_V_FOR_NO_EXPRESSION": 31,
|
|
1249
|
+
"31": "X_V_FOR_NO_EXPRESSION",
|
|
1250
|
+
"X_V_FOR_MALFORMED_EXPRESSION": 32,
|
|
1251
|
+
"32": "X_V_FOR_MALFORMED_EXPRESSION",
|
|
1252
|
+
"X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
|
|
1253
|
+
"33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
|
|
1254
|
+
"X_V_BIND_NO_EXPRESSION": 34,
|
|
1255
|
+
"34": "X_V_BIND_NO_EXPRESSION",
|
|
1256
|
+
"X_V_ON_NO_EXPRESSION": 35,
|
|
1257
|
+
"35": "X_V_ON_NO_EXPRESSION",
|
|
1258
|
+
"X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
|
|
1259
|
+
"36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
|
|
1260
|
+
"X_V_SLOT_MIXED_SLOT_USAGE": 37,
|
|
1261
|
+
"37": "X_V_SLOT_MIXED_SLOT_USAGE",
|
|
1262
|
+
"X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
|
|
1263
|
+
"38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
|
|
1264
|
+
"X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
|
|
1265
|
+
"39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
|
|
1266
|
+
"X_V_SLOT_MISPLACED": 40,
|
|
1267
|
+
"40": "X_V_SLOT_MISPLACED",
|
|
1268
|
+
"X_V_MODEL_NO_EXPRESSION": 41,
|
|
1269
|
+
"41": "X_V_MODEL_NO_EXPRESSION",
|
|
1270
|
+
"X_V_MODEL_MALFORMED_EXPRESSION": 42,
|
|
1271
|
+
"42": "X_V_MODEL_MALFORMED_EXPRESSION",
|
|
1272
|
+
"X_V_MODEL_ON_SCOPE_VARIABLE": 43,
|
|
1273
|
+
"43": "X_V_MODEL_ON_SCOPE_VARIABLE",
|
|
1274
|
+
"X_V_MODEL_ON_PROPS": 44,
|
|
1275
|
+
"44": "X_V_MODEL_ON_PROPS",
|
|
1276
|
+
"X_INVALID_EXPRESSION": 45,
|
|
1277
|
+
"45": "X_INVALID_EXPRESSION",
|
|
1278
|
+
"X_KEEP_ALIVE_INVALID_CHILDREN": 46,
|
|
1279
|
+
"46": "X_KEEP_ALIVE_INVALID_CHILDREN",
|
|
1280
|
+
"X_PREFIX_ID_NOT_SUPPORTED": 47,
|
|
1281
|
+
"47": "X_PREFIX_ID_NOT_SUPPORTED",
|
|
1282
|
+
"X_MODULE_MODE_NOT_SUPPORTED": 48,
|
|
1283
|
+
"48": "X_MODULE_MODE_NOT_SUPPORTED",
|
|
1284
|
+
"X_CACHE_HANDLER_NOT_SUPPORTED": 49,
|
|
1285
|
+
"49": "X_CACHE_HANDLER_NOT_SUPPORTED",
|
|
1286
|
+
"X_SCOPE_ID_NOT_SUPPORTED": 50,
|
|
1287
|
+
"50": "X_SCOPE_ID_NOT_SUPPORTED",
|
|
1288
|
+
"X_VNODE_HOOKS": 51,
|
|
1289
|
+
"51": "X_VNODE_HOOKS",
|
|
1290
|
+
"X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
|
|
1291
|
+
"52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
|
|
1292
|
+
"__EXTEND_POINT__": 53,
|
|
1293
|
+
"53": "__EXTEND_POINT__"
|
|
1294
|
+
};
|
|
1295
|
+
const errorMessages = {
|
|
1296
|
+
[0]: "Illegal comment.",
|
|
1297
|
+
[1]: "CDATA section is allowed only in XML context.",
|
|
1298
|
+
[2]: "Duplicate attribute.",
|
|
1299
|
+
[3]: "End tag cannot have attributes.",
|
|
1300
|
+
[4]: "Illegal '/' in tags.",
|
|
1301
|
+
[5]: "Unexpected EOF in tag.",
|
|
1302
|
+
[6]: "Unexpected EOF in CDATA section.",
|
|
1303
|
+
[7]: "Unexpected EOF in comment.",
|
|
1304
|
+
[8]: "Unexpected EOF in script.",
|
|
1305
|
+
[9]: "Unexpected EOF in tag.",
|
|
1306
|
+
[10]: "Incorrectly closed comment.",
|
|
1307
|
+
[11]: "Incorrectly opened comment.",
|
|
1308
|
+
[12]: "Illegal tag name. Use '<' to print '<'.",
|
|
1309
|
+
[13]: "Attribute value was expected.",
|
|
1310
|
+
[14]: "End tag name was expected.",
|
|
1311
|
+
[15]: "Whitespace was expected.",
|
|
1312
|
+
[16]: "Unexpected '<!--' in comment.",
|
|
1313
|
+
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
1314
|
+
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
1315
|
+
[19]: "Attribute name cannot start with '='.",
|
|
1316
|
+
[21]: "'<?' is allowed only in XML context.",
|
|
1317
|
+
[20]: `Unexpected null character.`,
|
|
1318
|
+
[22]: "Illegal '/' in tags.",
|
|
1319
|
+
[23]: "Invalid end tag.",
|
|
1320
|
+
[24]: "Element is missing end tag.",
|
|
1321
|
+
[25]: "Interpolation end sign was not found.",
|
|
1322
|
+
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
1323
|
+
[26]: "Legal directive name was expected.",
|
|
1324
|
+
[28]: `v-if/v-else-if is missing expression.`,
|
|
1325
|
+
[29]: `v-if/else branches must use unique keys.`,
|
|
1326
|
+
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
1327
|
+
[31]: `v-for is missing expression.`,
|
|
1328
|
+
[32]: `v-for has invalid expression.`,
|
|
1329
|
+
[33]: `<template v-for> key should be placed on the <template> tag.`,
|
|
1330
|
+
[34]: `v-bind is missing expression.`,
|
|
1331
|
+
[52]: `v-bind with same-name shorthand only allows static argument.`,
|
|
1332
|
+
[35]: `v-on is missing expression.`,
|
|
1333
|
+
[36]: `Unexpected custom directive on <slot> outlet.`,
|
|
1334
|
+
[37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
|
|
1335
|
+
[38]: `Duplicate slot names found. `,
|
|
1336
|
+
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
1337
|
+
[40]: `v-slot can only be used on components or <template> tags.`,
|
|
1338
|
+
[41]: `v-model is missing expression.`,
|
|
1339
|
+
[42]: `v-model value must be a valid JavaScript member expression.`,
|
|
1340
|
+
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
1341
|
+
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
1342
|
+
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
1343
|
+
[45]: `Error parsing JavaScript expression: `,
|
|
1344
|
+
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
1345
|
+
[51]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
|
|
1346
|
+
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
1347
|
+
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
1348
|
+
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
1349
|
+
[50]: `"scopeId" option is only supported in module mode.`,
|
|
1350
|
+
[53]: ``
|
|
1351
|
+
};
|
|
1352
|
+
function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
|
|
1353
|
+
const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
|
|
1354
|
+
estreeWalker.walk(root, {
|
|
1355
|
+
enter(node, parent) {
|
|
1356
|
+
parent && parentStack.push(parent);
|
|
1357
|
+
if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) return this.skip();
|
|
1358
|
+
if (node.type === "Identifier") {
|
|
1359
|
+
const isLocal = !!knownIds[node.name];
|
|
1360
|
+
const isRefed = isReferencedIdentifier(node, parent, parentStack);
|
|
1361
|
+
if (includeAll || isRefed && !isLocal) onIdentifier(node, parent, parentStack, isRefed, isLocal);
|
|
1362
|
+
} else if (node.type === "ObjectProperty" && (parent == null ? void 0 : parent.type) === "ObjectPattern") node.inPattern = true;
|
|
1363
|
+
else if (isFunctionType(node)) if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1364
|
+
else walkFunctionParams(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
1365
|
+
else if (node.type === "BlockStatement") if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1366
|
+
else walkBlockDeclarations(node, (id) => markScopeIdentifier(node, id, knownIds));
|
|
1367
|
+
else if (node.type === "SwitchStatement") if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1368
|
+
else walkSwitchStatement(node, false, (id) => markScopeIdentifier(node, id, knownIds));
|
|
1369
|
+
else if (node.type === "CatchClause" && node.param) if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1370
|
+
else for (const id of extractIdentifiers(node.param)) markScopeIdentifier(node, id, knownIds);
|
|
1371
|
+
else if (isForStatement(node)) if (node.scopeIds) node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1372
|
+
else walkForStatement(node, false, (id) => markScopeIdentifier(node, id, knownIds));
|
|
1373
|
+
},
|
|
1374
|
+
leave(node, parent) {
|
|
1375
|
+
parent && parentStack.pop();
|
|
1376
|
+
if (node !== rootExp && node.scopeIds) for (const id of node.scopeIds) {
|
|
1377
|
+
knownIds[id]--;
|
|
1378
|
+
if (knownIds[id] === 0) delete knownIds[id];
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
function isReferencedIdentifier(id, parent, parentStack) {
|
|
1384
|
+
if (!parent) return true;
|
|
1385
|
+
if (id.name === "arguments") return false;
|
|
1386
|
+
if (isReferenced(id, parent, parentStack[parentStack.length - 2])) return true;
|
|
1387
|
+
switch (parent.type) {
|
|
1388
|
+
case "AssignmentExpression":
|
|
1389
|
+
case "AssignmentPattern": return true;
|
|
1390
|
+
case "ObjectProperty": return parent.key !== id && isInDestructureAssignment(parent, parentStack);
|
|
1391
|
+
case "ArrayPattern": return isInDestructureAssignment(parent, parentStack);
|
|
1392
|
+
}
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1395
|
+
function isInDestructureAssignment(parent, parentStack) {
|
|
1396
|
+
if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
|
|
1397
|
+
let i = parentStack.length;
|
|
1398
|
+
while (i--) {
|
|
1399
|
+
const p = parentStack[i];
|
|
1400
|
+
if (p.type === "AssignmentExpression") return true;
|
|
1401
|
+
else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) break;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
function isInNewExpression(parentStack) {
|
|
1407
|
+
let i = parentStack.length;
|
|
1408
|
+
while (i--) {
|
|
1409
|
+
const p = parentStack[i];
|
|
1410
|
+
if (p.type === "NewExpression") return true;
|
|
1411
|
+
else if (p.type !== "MemberExpression") break;
|
|
1412
|
+
}
|
|
1413
|
+
return false;
|
|
1414
|
+
}
|
|
1415
|
+
function walkFunctionParams(node, onIdent) {
|
|
1416
|
+
for (const p of node.params) for (const id of extractIdentifiers(p)) onIdent(id);
|
|
1417
|
+
}
|
|
1418
|
+
function walkBlockDeclarations(block, onIdent) {
|
|
1419
|
+
const body = block.type === "SwitchCase" ? block.consequent : block.body;
|
|
1420
|
+
for (const stmt of body) if (stmt.type === "VariableDeclaration") {
|
|
1421
|
+
if (stmt.declare) continue;
|
|
1422
|
+
for (const decl of stmt.declarations) for (const id of extractIdentifiers(decl.id)) onIdent(id);
|
|
1423
|
+
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
1424
|
+
if (stmt.declare || !stmt.id) continue;
|
|
1425
|
+
onIdent(stmt.id);
|
|
1426
|
+
} else if (isForStatement(stmt)) walkForStatement(stmt, true, onIdent);
|
|
1427
|
+
else if (stmt.type === "SwitchStatement") walkSwitchStatement(stmt, true, onIdent);
|
|
1428
|
+
}
|
|
1429
|
+
function isForStatement(stmt) {
|
|
1430
|
+
return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
|
|
1431
|
+
}
|
|
1432
|
+
function walkForStatement(stmt, isVar, onIdent) {
|
|
1433
|
+
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
1434
|
+
if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) for (const decl of variable.declarations) for (const id of extractIdentifiers(decl.id)) onIdent(id);
|
|
1435
|
+
}
|
|
1436
|
+
function walkSwitchStatement(stmt, isVar, onIdent) {
|
|
1437
|
+
for (const cs of stmt.cases) {
|
|
1438
|
+
for (const stmt2 of cs.consequent) if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) for (const decl of stmt2.declarations) for (const id of extractIdentifiers(decl.id)) onIdent(id);
|
|
1439
|
+
walkBlockDeclarations(cs, onIdent);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
function extractIdentifiers(param, nodes = []) {
|
|
1443
|
+
switch (param.type) {
|
|
1444
|
+
case "Identifier":
|
|
1445
|
+
nodes.push(param);
|
|
1446
|
+
break;
|
|
1447
|
+
case "MemberExpression":
|
|
1448
|
+
let object = param;
|
|
1449
|
+
while (object.type === "MemberExpression") object = object.object;
|
|
1450
|
+
nodes.push(object);
|
|
1451
|
+
break;
|
|
1452
|
+
case "ObjectPattern":
|
|
1453
|
+
for (const prop of param.properties) if (prop.type === "RestElement") extractIdentifiers(prop.argument, nodes);
|
|
1454
|
+
else extractIdentifiers(prop.value, nodes);
|
|
1455
|
+
break;
|
|
1456
|
+
case "ArrayPattern":
|
|
1457
|
+
param.elements.forEach((element) => {
|
|
1458
|
+
if (element) extractIdentifiers(element, nodes);
|
|
1459
|
+
});
|
|
1460
|
+
break;
|
|
1461
|
+
case "RestElement":
|
|
1462
|
+
extractIdentifiers(param.argument, nodes);
|
|
1463
|
+
break;
|
|
1464
|
+
case "AssignmentPattern":
|
|
1465
|
+
extractIdentifiers(param.left, nodes);
|
|
1466
|
+
break;
|
|
1467
|
+
}
|
|
1468
|
+
return nodes;
|
|
1469
|
+
}
|
|
1470
|
+
function markKnownIds(name, knownIds) {
|
|
1471
|
+
if (name in knownIds) knownIds[name]++;
|
|
1472
|
+
else knownIds[name] = 1;
|
|
1473
|
+
}
|
|
1474
|
+
function markScopeIdentifier(node, child, knownIds) {
|
|
1475
|
+
const { name } = child;
|
|
1476
|
+
if (node.scopeIds && node.scopeIds.has(name)) return;
|
|
1477
|
+
markKnownIds(name, knownIds);
|
|
1478
|
+
(node.scopeIds || (node.scopeIds = /* @__PURE__ */ new Set())).add(name);
|
|
1479
|
+
}
|
|
1480
|
+
const isFunctionType = (node) => {
|
|
1481
|
+
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
1482
|
+
};
|
|
1483
|
+
const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
1484
|
+
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
1485
|
+
function isReferenced(node, parent, grandparent) {
|
|
1486
|
+
switch (parent.type) {
|
|
1487
|
+
case "MemberExpression":
|
|
1488
|
+
case "OptionalMemberExpression":
|
|
1489
|
+
if (parent.property === node) return !!parent.computed;
|
|
1490
|
+
return parent.object === node;
|
|
1491
|
+
case "JSXMemberExpression": return parent.object === node;
|
|
1492
|
+
case "VariableDeclarator": return parent.init === node;
|
|
1493
|
+
case "ArrowFunctionExpression": return parent.body === node;
|
|
1494
|
+
case "PrivateName": return false;
|
|
1495
|
+
case "ClassMethod":
|
|
1496
|
+
case "ClassPrivateMethod":
|
|
1497
|
+
case "ObjectMethod":
|
|
1498
|
+
if (parent.key === node) return !!parent.computed;
|
|
1499
|
+
return false;
|
|
1500
|
+
case "ObjectProperty":
|
|
1501
|
+
if (parent.key === node) return !!parent.computed;
|
|
1502
|
+
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
1503
|
+
case "ClassProperty":
|
|
1504
|
+
if (parent.key === node) return !!parent.computed;
|
|
1505
|
+
return true;
|
|
1506
|
+
case "ClassPrivateProperty": return parent.key !== node;
|
|
1507
|
+
case "ClassDeclaration":
|
|
1508
|
+
case "ClassExpression": return parent.superClass === node;
|
|
1509
|
+
case "AssignmentExpression": return parent.right === node;
|
|
1510
|
+
case "AssignmentPattern": return parent.right === node;
|
|
1511
|
+
case "LabeledStatement": return false;
|
|
1512
|
+
case "CatchClause": return false;
|
|
1513
|
+
case "RestElement": return false;
|
|
1514
|
+
case "BreakStatement":
|
|
1515
|
+
case "ContinueStatement": return false;
|
|
1516
|
+
case "FunctionDeclaration":
|
|
1517
|
+
case "FunctionExpression": return false;
|
|
1518
|
+
case "ExportNamespaceSpecifier":
|
|
1519
|
+
case "ExportDefaultSpecifier": return false;
|
|
1520
|
+
case "ExportSpecifier":
|
|
1521
|
+
if (grandparent == null ? void 0 : grandparent.source) return false;
|
|
1522
|
+
return parent.local === node;
|
|
1523
|
+
case "ImportDefaultSpecifier":
|
|
1524
|
+
case "ImportNamespaceSpecifier":
|
|
1525
|
+
case "ImportSpecifier": return false;
|
|
1526
|
+
case "ImportAttribute": return false;
|
|
1527
|
+
case "JSXAttribute": return false;
|
|
1528
|
+
case "ObjectPattern":
|
|
1529
|
+
case "ArrayPattern": return false;
|
|
1530
|
+
case "MetaProperty": return false;
|
|
1531
|
+
case "ObjectTypeProperty": return parent.key !== node;
|
|
1532
|
+
case "TSEnumMember": return parent.id !== node;
|
|
1533
|
+
case "TSPropertySignature":
|
|
1534
|
+
if (parent.key === node) return !!parent.computed;
|
|
1535
|
+
return true;
|
|
1536
|
+
}
|
|
1537
|
+
return true;
|
|
1538
|
+
}
|
|
1539
|
+
const TS_NODE_TYPES = [
|
|
1540
|
+
"TSAsExpression",
|
|
1541
|
+
"TSTypeAssertion",
|
|
1542
|
+
"TSNonNullExpression",
|
|
1543
|
+
"TSInstantiationExpression",
|
|
1544
|
+
"TSSatisfiesExpression"
|
|
1545
|
+
];
|
|
1546
|
+
function unwrapTSNode(node) {
|
|
1547
|
+
if (TS_NODE_TYPES.includes(node.type)) return unwrapTSNode(node.expression);
|
|
1548
|
+
else return node;
|
|
1549
|
+
}
|
|
1550
|
+
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
1551
|
+
function isCoreComponent(tag) {
|
|
1552
|
+
switch (tag) {
|
|
1553
|
+
case "Teleport":
|
|
1554
|
+
case "teleport": return TELEPORT;
|
|
1555
|
+
case "Suspense":
|
|
1556
|
+
case "suspense": return SUSPENSE;
|
|
1557
|
+
case "KeepAlive":
|
|
1558
|
+
case "keep-alive": return KEEP_ALIVE;
|
|
1559
|
+
case "BaseTransition":
|
|
1560
|
+
case "base-transition": return BASE_TRANSITION;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
|
|
1564
|
+
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
|
1565
|
+
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
|
1566
|
+
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
|
1567
|
+
const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
|
1568
|
+
const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
|
|
1569
|
+
const isMemberExpressionBrowser = (exp) => {
|
|
1570
|
+
const path = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
|
|
1571
|
+
let state = 0;
|
|
1572
|
+
let stateStack = [];
|
|
1573
|
+
let currentOpenBracketCount = 0;
|
|
1574
|
+
let currentOpenParensCount = 0;
|
|
1575
|
+
let currentStringType = null;
|
|
1576
|
+
for (let i = 0; i < path.length; i++) {
|
|
1577
|
+
const char = path.charAt(i);
|
|
1578
|
+
switch (state) {
|
|
1579
|
+
case 0:
|
|
1580
|
+
if (char === "[") {
|
|
1581
|
+
stateStack.push(state);
|
|
1582
|
+
state = 1;
|
|
1583
|
+
currentOpenBracketCount++;
|
|
1584
|
+
} else if (char === "(") {
|
|
1585
|
+
stateStack.push(state);
|
|
1586
|
+
state = 2;
|
|
1587
|
+
currentOpenParensCount++;
|
|
1588
|
+
} else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) return false;
|
|
1589
|
+
break;
|
|
1590
|
+
case 1:
|
|
1591
|
+
if (char === `'` || char === `"` || char === "`") {
|
|
1592
|
+
stateStack.push(state);
|
|
1593
|
+
state = 3;
|
|
1594
|
+
currentStringType = char;
|
|
1595
|
+
} else if (char === `[`) currentOpenBracketCount++;
|
|
1596
|
+
else if (char === `]`) {
|
|
1597
|
+
if (!--currentOpenBracketCount) state = stateStack.pop();
|
|
1598
|
+
}
|
|
1599
|
+
break;
|
|
1600
|
+
case 2:
|
|
1601
|
+
if (char === `'` || char === `"` || char === "`") {
|
|
1602
|
+
stateStack.push(state);
|
|
1603
|
+
state = 3;
|
|
1604
|
+
currentStringType = char;
|
|
1605
|
+
} else if (char === `(`) currentOpenParensCount++;
|
|
1606
|
+
else if (char === `)`) {
|
|
1607
|
+
if (i === path.length - 1) return false;
|
|
1608
|
+
if (!--currentOpenParensCount) state = stateStack.pop();
|
|
1609
|
+
}
|
|
1610
|
+
break;
|
|
1611
|
+
case 3:
|
|
1612
|
+
if (char === currentStringType) {
|
|
1613
|
+
state = stateStack.pop();
|
|
1614
|
+
currentStringType = null;
|
|
1615
|
+
}
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
1620
|
+
};
|
|
1621
|
+
const isMemberExpressionNode = (exp, context) => {
|
|
1622
|
+
try {
|
|
1623
|
+
let ret = exp.ast || parser.parseExpression(getExpSource(exp), { plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"] });
|
|
1624
|
+
ret = unwrapTSNode(ret);
|
|
1625
|
+
return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
|
|
1626
|
+
} catch (e) {
|
|
1627
|
+
return false;
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1630
|
+
const isMemberExpression = isMemberExpressionNode;
|
|
1631
|
+
const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
1632
|
+
const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
|
|
1633
|
+
const isFnExpressionNode = (exp, context) => {
|
|
1634
|
+
try {
|
|
1635
|
+
let ret = exp.ast || parser.parseExpression(getExpSource(exp), { plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"] });
|
|
1636
|
+
if (ret.type === "Program") {
|
|
1637
|
+
ret = ret.body[0];
|
|
1638
|
+
if (ret.type === "ExpressionStatement") ret = ret.expression;
|
|
1639
|
+
}
|
|
1640
|
+
ret = unwrapTSNode(ret);
|
|
1641
|
+
return ret.type === "FunctionExpression" || ret.type === "ArrowFunctionExpression";
|
|
1642
|
+
} catch (e) {
|
|
1643
|
+
return false;
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
const isFnExpression = isFnExpressionNode;
|
|
1647
|
+
function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
|
|
1648
|
+
return advancePositionWithMutation({
|
|
1649
|
+
offset: pos.offset,
|
|
1650
|
+
line: pos.line,
|
|
1651
|
+
column: pos.column
|
|
1652
|
+
}, source, numberOfCharacters);
|
|
1653
|
+
}
|
|
1654
|
+
function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
|
|
1655
|
+
let linesCount = 0;
|
|
1656
|
+
let lastNewLinePos = -1;
|
|
1657
|
+
for (let i = 0; i < numberOfCharacters; i++) if (source.charCodeAt(i) === 10) {
|
|
1658
|
+
linesCount++;
|
|
1659
|
+
lastNewLinePos = i;
|
|
1660
|
+
}
|
|
1661
|
+
pos.offset += numberOfCharacters;
|
|
1662
|
+
pos.line += linesCount;
|
|
1663
|
+
pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
|
|
1664
|
+
return pos;
|
|
1665
|
+
}
|
|
1666
|
+
function assert(condition, msg) {
|
|
1667
|
+
if (!condition) throw new Error(msg || `unexpected compiler condition`);
|
|
1668
|
+
}
|
|
1669
|
+
function findDir(node, name, allowEmpty = false) {
|
|
1670
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
1671
|
+
const p = node.props[i];
|
|
1672
|
+
if (p.type === 7 && (allowEmpty || p.exp) && (shared.isString(name) ? p.name === name : name.test(p.name))) return p;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
1676
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
1677
|
+
const p = node.props[i];
|
|
1678
|
+
if (p.type === 6) {
|
|
1679
|
+
if (dynamicOnly) continue;
|
|
1680
|
+
if (p.name === name && (p.value || allowEmpty)) return p;
|
|
1681
|
+
} else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) return p;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
function isStaticArgOf(arg, name) {
|
|
1685
|
+
return !!(arg && isStaticExp(arg) && arg.content === name);
|
|
1686
|
+
}
|
|
1687
|
+
function hasDynamicKeyVBind(node) {
|
|
1688
|
+
return node.props.some((p) => p.type === 7 && p.name === "bind" && (!p.arg || p.arg.type !== 4 || !p.arg.isStatic));
|
|
1689
|
+
}
|
|
1690
|
+
function isText$1(node) {
|
|
1691
|
+
return node.type === 5 || node.type === 2;
|
|
1692
|
+
}
|
|
1693
|
+
function isVPre(p) {
|
|
1694
|
+
return p.type === 7 && p.name === "pre";
|
|
1695
|
+
}
|
|
1696
|
+
function isVSlot(p) {
|
|
1697
|
+
return p.type === 7 && p.name === "slot";
|
|
1698
|
+
}
|
|
1699
|
+
function isTemplateNode(node) {
|
|
1700
|
+
return node.type === 1 && node.tagType === 3;
|
|
1701
|
+
}
|
|
1702
|
+
function isSlotOutlet(node) {
|
|
1703
|
+
return node.type === 1 && node.tagType === 2;
|
|
1704
|
+
}
|
|
1705
|
+
const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
|
1706
|
+
function getUnnormalizedProps(props, callPath = []) {
|
|
1707
|
+
if (props && !shared.isString(props) && props.type === 14) {
|
|
1708
|
+
const callee = props.callee;
|
|
1709
|
+
if (!shared.isString(callee) && propsHelperSet.has(callee)) return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
|
|
1710
|
+
}
|
|
1711
|
+
return [props, callPath];
|
|
1712
|
+
}
|
|
1713
|
+
function injectProp(node, prop, context) {
|
|
1714
|
+
let propsWithInjection;
|
|
1715
|
+
let props = node.type === 13 ? node.props : node.arguments[2];
|
|
1716
|
+
let callPath = [];
|
|
1717
|
+
let parentCall;
|
|
1718
|
+
if (props && !shared.isString(props) && props.type === 14) {
|
|
1719
|
+
const ret = getUnnormalizedProps(props);
|
|
1720
|
+
props = ret[0];
|
|
1721
|
+
callPath = ret[1];
|
|
1722
|
+
parentCall = callPath[callPath.length - 1];
|
|
1723
|
+
}
|
|
1724
|
+
if (props == null || shared.isString(props)) propsWithInjection = createObjectExpression([prop]);
|
|
1725
|
+
else if (props.type === 14) {
|
|
1726
|
+
const first = props.arguments[0];
|
|
1727
|
+
if (!shared.isString(first) && first.type === 15) {
|
|
1728
|
+
if (!hasProp(prop, first)) first.properties.unshift(prop);
|
|
1729
|
+
} else if (props.callee === TO_HANDLERS) propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [createObjectExpression([prop]), props]);
|
|
1730
|
+
else props.arguments.unshift(createObjectExpression([prop]));
|
|
1731
|
+
!propsWithInjection && (propsWithInjection = props);
|
|
1732
|
+
} else if (props.type === 15) {
|
|
1733
|
+
if (!hasProp(prop, props)) props.properties.unshift(prop);
|
|
1734
|
+
propsWithInjection = props;
|
|
1735
|
+
} else {
|
|
1736
|
+
propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [createObjectExpression([prop]), props]);
|
|
1737
|
+
if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) parentCall = callPath[callPath.length - 2];
|
|
1738
|
+
}
|
|
1739
|
+
if (node.type === 13) if (parentCall) parentCall.arguments[0] = propsWithInjection;
|
|
1740
|
+
else node.props = propsWithInjection;
|
|
1741
|
+
else if (parentCall) parentCall.arguments[0] = propsWithInjection;
|
|
1742
|
+
else node.arguments[2] = propsWithInjection;
|
|
1743
|
+
}
|
|
1744
|
+
function hasProp(prop, props) {
|
|
1745
|
+
let result = false;
|
|
1746
|
+
if (prop.key.type === 4) {
|
|
1747
|
+
const propKeyName = prop.key.content;
|
|
1748
|
+
result = props.properties.some((p) => p.key.type === 4 && p.key.content === propKeyName);
|
|
1749
|
+
}
|
|
1750
|
+
return result;
|
|
1751
|
+
}
|
|
1752
|
+
function toValidAssetId(name, type) {
|
|
1753
|
+
return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
|
|
1754
|
+
return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
|
|
1755
|
+
})}`;
|
|
1756
|
+
}
|
|
1757
|
+
function hasScopeRef(node, ids) {
|
|
1758
|
+
if (!node || Object.keys(ids).length === 0) return false;
|
|
1759
|
+
switch (node.type) {
|
|
1760
|
+
case 1:
|
|
1761
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
1762
|
+
const p = node.props[i];
|
|
1763
|
+
if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) return true;
|
|
1764
|
+
}
|
|
1765
|
+
return node.children.some((c) => hasScopeRef(c, ids));
|
|
1766
|
+
case 11:
|
|
1767
|
+
if (hasScopeRef(node.source, ids)) return true;
|
|
1768
|
+
return node.children.some((c) => hasScopeRef(c, ids));
|
|
1769
|
+
case 9: return node.branches.some((b) => hasScopeRef(b, ids));
|
|
1770
|
+
case 10:
|
|
1771
|
+
if (hasScopeRef(node.condition, ids)) return true;
|
|
1772
|
+
return node.children.some((c) => hasScopeRef(c, ids));
|
|
1773
|
+
case 4: return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
|
|
1774
|
+
case 8: return node.children.some((c) => shared.isObject(c) && hasScopeRef(c, ids));
|
|
1775
|
+
case 5:
|
|
1776
|
+
case 12: return hasScopeRef(node.content, ids);
|
|
1777
|
+
case 2:
|
|
1778
|
+
case 3:
|
|
1779
|
+
case 20: return false;
|
|
1780
|
+
default: return false;
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
function getMemoedVNodeCall(node) {
|
|
1784
|
+
if (node.type === 14 && node.callee === WITH_MEMO) return node.arguments[1].returns;
|
|
1785
|
+
else return node;
|
|
1786
|
+
}
|
|
1787
|
+
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
|
|
1788
|
+
const defaultParserOptions = {
|
|
1789
|
+
parseMode: "base",
|
|
1790
|
+
ns: 0,
|
|
1791
|
+
delimiters: [`{{`, `}}`],
|
|
1792
|
+
getNamespace: () => 0,
|
|
1793
|
+
isVoidTag: shared.NO,
|
|
1794
|
+
isPreTag: shared.NO,
|
|
1795
|
+
isIgnoreNewlineTag: shared.NO,
|
|
1796
|
+
isCustomElement: shared.NO,
|
|
1797
|
+
onError: defaultOnError,
|
|
1798
|
+
onWarn: defaultOnWarn,
|
|
1799
|
+
comments: false,
|
|
1800
|
+
prefixIdentifiers: false
|
|
1801
|
+
};
|
|
1802
|
+
let currentOptions = defaultParserOptions;
|
|
1803
|
+
let currentRoot = null;
|
|
1804
|
+
let currentInput = "";
|
|
1805
|
+
let currentOpenTag = null;
|
|
1806
|
+
let currentProp = null;
|
|
1807
|
+
let currentAttrValue = "";
|
|
1808
|
+
let currentAttrStartIndex = -1;
|
|
1809
|
+
let currentAttrEndIndex = -1;
|
|
1810
|
+
let inPre = 0;
|
|
1811
|
+
let inVPre = false;
|
|
1812
|
+
let currentVPreBoundary = null;
|
|
1813
|
+
const stack = [];
|
|
1814
|
+
const tokenizer = new Tokenizer(stack, {
|
|
1815
|
+
onerr: emitError,
|
|
1816
|
+
ontext(start, end) {
|
|
1817
|
+
onText(getSlice(start, end), start, end);
|
|
1818
|
+
},
|
|
1819
|
+
ontextentity(char, start, end) {
|
|
1820
|
+
onText(char, start, end);
|
|
1821
|
+
},
|
|
1822
|
+
oninterpolation(start, end) {
|
|
1823
|
+
if (inVPre) return onText(getSlice(start, end), start, end);
|
|
1824
|
+
let innerStart = start + tokenizer.delimiterOpen.length;
|
|
1825
|
+
let innerEnd = end - tokenizer.delimiterClose.length;
|
|
1826
|
+
while (isWhitespace(currentInput.charCodeAt(innerStart))) innerStart++;
|
|
1827
|
+
while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) innerEnd--;
|
|
1828
|
+
let exp = getSlice(innerStart, innerEnd);
|
|
1829
|
+
if (exp.includes("&")) exp = decode_js.decodeHTML(exp);
|
|
1830
|
+
addNode({
|
|
1831
|
+
type: 5,
|
|
1832
|
+
content: createExp(exp, false, getLoc(innerStart, innerEnd)),
|
|
1833
|
+
loc: getLoc(start, end)
|
|
1834
|
+
});
|
|
1835
|
+
},
|
|
1836
|
+
onopentagname(start, end) {
|
|
1837
|
+
const name = getSlice(start, end);
|
|
1838
|
+
currentOpenTag = {
|
|
1839
|
+
type: 1,
|
|
1840
|
+
tag: name,
|
|
1841
|
+
ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
|
|
1842
|
+
tagType: 0,
|
|
1843
|
+
props: [],
|
|
1844
|
+
children: [],
|
|
1845
|
+
loc: getLoc(start - 1, end),
|
|
1846
|
+
codegenNode: void 0
|
|
1847
|
+
};
|
|
1848
|
+
},
|
|
1849
|
+
onopentagend(end) {
|
|
1850
|
+
endOpenTag(end);
|
|
1851
|
+
},
|
|
1852
|
+
onclosetag(start, end) {
|
|
1853
|
+
const name = getSlice(start, end);
|
|
1854
|
+
if (!currentOptions.isVoidTag(name)) {
|
|
1855
|
+
let found = false;
|
|
1856
|
+
for (let i = 0; i < stack.length; i++) if (stack[i].tag.toLowerCase() === name.toLowerCase()) {
|
|
1857
|
+
found = true;
|
|
1858
|
+
if (i > 0) emitError(24, stack[0].loc.start.offset);
|
|
1859
|
+
for (let j = 0; j <= i; j++) onCloseTag(stack.shift(), end, j < i);
|
|
1860
|
+
break;
|
|
1861
|
+
}
|
|
1862
|
+
if (!found) emitError(23, backTrack(start, 60));
|
|
1863
|
+
}
|
|
1864
|
+
},
|
|
1865
|
+
onselfclosingtag(end) {
|
|
1866
|
+
const name = currentOpenTag.tag;
|
|
1867
|
+
currentOpenTag.isSelfClosing = true;
|
|
1868
|
+
endOpenTag(end);
|
|
1869
|
+
if (stack[0] && stack[0].tag === name) onCloseTag(stack.shift(), end);
|
|
1870
|
+
},
|
|
1871
|
+
onattribname(start, end) {
|
|
1872
|
+
currentProp = {
|
|
1873
|
+
type: 6,
|
|
1874
|
+
name: getSlice(start, end),
|
|
1875
|
+
nameLoc: getLoc(start, end),
|
|
1876
|
+
value: void 0,
|
|
1877
|
+
loc: getLoc(start)
|
|
1878
|
+
};
|
|
1879
|
+
},
|
|
1880
|
+
ondirname(start, end) {
|
|
1881
|
+
const raw = getSlice(start, end);
|
|
1882
|
+
const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
|
|
1883
|
+
if (!inVPre && name === "") emitError(26, start);
|
|
1884
|
+
if (inVPre || name === "") currentProp = {
|
|
1885
|
+
type: 6,
|
|
1886
|
+
name: raw,
|
|
1887
|
+
nameLoc: getLoc(start, end),
|
|
1888
|
+
value: void 0,
|
|
1889
|
+
loc: getLoc(start)
|
|
1890
|
+
};
|
|
1891
|
+
else {
|
|
1892
|
+
currentProp = {
|
|
1893
|
+
type: 7,
|
|
1894
|
+
name,
|
|
1895
|
+
rawName: raw,
|
|
1896
|
+
exp: void 0,
|
|
1897
|
+
arg: void 0,
|
|
1898
|
+
modifiers: raw === "." ? [createSimpleExpression("prop")] : [],
|
|
1899
|
+
loc: getLoc(start)
|
|
1900
|
+
};
|
|
1901
|
+
if (name === "pre") {
|
|
1902
|
+
inVPre = tokenizer.inVPre = true;
|
|
1903
|
+
currentVPreBoundary = currentOpenTag;
|
|
1904
|
+
const props = currentOpenTag.props;
|
|
1905
|
+
for (let i = 0; i < props.length; i++) if (props[i].type === 7) props[i] = dirToAttr(props[i]);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
},
|
|
1909
|
+
ondirarg(start, end) {
|
|
1910
|
+
if (start === end) return;
|
|
1911
|
+
const arg = getSlice(start, end);
|
|
1912
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
1913
|
+
currentProp.name += arg;
|
|
1914
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1915
|
+
} else {
|
|
1916
|
+
const isStatic = arg[0] !== `[`;
|
|
1917
|
+
currentProp.arg = createExp(isStatic ? arg : arg.slice(1, -1), isStatic, getLoc(start, end), isStatic ? 3 : 0);
|
|
1918
|
+
}
|
|
1919
|
+
},
|
|
1920
|
+
ondirmodifier(start, end) {
|
|
1921
|
+
const mod = getSlice(start, end);
|
|
1922
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
1923
|
+
currentProp.name += "." + mod;
|
|
1924
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1925
|
+
} else if (currentProp.name === "slot") {
|
|
1926
|
+
const arg = currentProp.arg;
|
|
1927
|
+
if (arg) {
|
|
1928
|
+
arg.content += "." + mod;
|
|
1929
|
+
setLocEnd(arg.loc, end);
|
|
1930
|
+
}
|
|
1931
|
+
} else {
|
|
1932
|
+
const exp = createSimpleExpression(mod, true, getLoc(start, end));
|
|
1933
|
+
currentProp.modifiers.push(exp);
|
|
1934
|
+
}
|
|
1935
|
+
},
|
|
1936
|
+
onattribdata(start, end) {
|
|
1937
|
+
currentAttrValue += getSlice(start, end);
|
|
1938
|
+
if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
|
|
1939
|
+
currentAttrEndIndex = end;
|
|
1940
|
+
},
|
|
1941
|
+
onattribentity(char, start, end) {
|
|
1942
|
+
currentAttrValue += char;
|
|
1943
|
+
if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
|
|
1944
|
+
currentAttrEndIndex = end;
|
|
1945
|
+
},
|
|
1946
|
+
onattribnameend(end) {
|
|
1947
|
+
const start = currentProp.loc.start.offset;
|
|
1948
|
+
const name = getSlice(start, end);
|
|
1949
|
+
if (currentProp.type === 7) currentProp.rawName = name;
|
|
1950
|
+
if (currentOpenTag.props.some((p) => (p.type === 7 ? p.rawName : p.name) === name)) emitError(2, start);
|
|
1951
|
+
},
|
|
1952
|
+
onattribend(quote, end) {
|
|
1953
|
+
if (currentOpenTag && currentProp) {
|
|
1954
|
+
setLocEnd(currentProp.loc, end);
|
|
1955
|
+
if (quote !== 0) if (currentProp.type === 6) {
|
|
1956
|
+
if (currentProp.name === "class") currentAttrValue = condense(currentAttrValue).trim();
|
|
1957
|
+
if (quote === 1 && !currentAttrValue) emitError(13, end);
|
|
1958
|
+
currentProp.value = {
|
|
1959
|
+
type: 2,
|
|
1960
|
+
content: currentAttrValue,
|
|
1961
|
+
loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
|
1962
|
+
};
|
|
1963
|
+
if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
|
1964
|
+
} else {
|
|
1965
|
+
let expParseMode = 0;
|
|
1966
|
+
if (currentProp.name === "for") expParseMode = 3;
|
|
1967
|
+
else if (currentProp.name === "slot") expParseMode = 1;
|
|
1968
|
+
else if (currentProp.name === "on" && currentAttrValue.includes(";")) expParseMode = 2;
|
|
1969
|
+
currentProp.exp = createExp(currentAttrValue, false, getLoc(currentAttrStartIndex, currentAttrEndIndex), 0, expParseMode);
|
|
1970
|
+
if (currentProp.name === "for") currentProp.forParseResult = parseForExpression(currentProp.exp);
|
|
1971
|
+
let syncIndex = -1;
|
|
1972
|
+
if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.findIndex((mod) => mod.content === "sync")) > -1 && checkCompatEnabled("COMPILER_V_BIND_SYNC", currentOptions, currentProp.loc, currentProp.arg.loc.source)) {
|
|
1973
|
+
currentProp.name = "model";
|
|
1974
|
+
currentProp.modifiers.splice(syncIndex, 1);
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
if (currentProp.type !== 7 || currentProp.name !== "pre") currentOpenTag.props.push(currentProp);
|
|
1978
|
+
}
|
|
1979
|
+
currentAttrValue = "";
|
|
1980
|
+
currentAttrStartIndex = currentAttrEndIndex = -1;
|
|
1981
|
+
},
|
|
1982
|
+
oncomment(start, end) {
|
|
1983
|
+
if (currentOptions.comments) addNode({
|
|
1984
|
+
type: 3,
|
|
1985
|
+
content: getSlice(start, end),
|
|
1986
|
+
loc: getLoc(start - 4, end + 3)
|
|
1987
|
+
});
|
|
1988
|
+
},
|
|
1989
|
+
onend() {
|
|
1990
|
+
const end = currentInput.length;
|
|
1991
|
+
if (tokenizer.state !== 1) switch (tokenizer.state) {
|
|
1992
|
+
case 5:
|
|
1993
|
+
case 8:
|
|
1994
|
+
emitError(5, end);
|
|
1995
|
+
break;
|
|
1996
|
+
case 3:
|
|
1997
|
+
case 4:
|
|
1998
|
+
emitError(25, tokenizer.sectionStart);
|
|
1999
|
+
break;
|
|
2000
|
+
case 28:
|
|
2001
|
+
if (tokenizer.currentSequence === Sequences.CdataEnd) emitError(6, end);
|
|
2002
|
+
else emitError(7, end);
|
|
2003
|
+
break;
|
|
2004
|
+
case 6:
|
|
2005
|
+
case 7:
|
|
2006
|
+
case 9:
|
|
2007
|
+
case 11:
|
|
2008
|
+
case 12:
|
|
2009
|
+
case 13:
|
|
2010
|
+
case 14:
|
|
2011
|
+
case 15:
|
|
2012
|
+
case 16:
|
|
2013
|
+
case 17:
|
|
2014
|
+
case 18:
|
|
2015
|
+
case 19:
|
|
2016
|
+
case 20:
|
|
2017
|
+
case 21:
|
|
2018
|
+
emitError(9, end);
|
|
2019
|
+
break;
|
|
2020
|
+
}
|
|
2021
|
+
for (let index = 0; index < stack.length; index++) {
|
|
2022
|
+
onCloseTag(stack[index], end - 1);
|
|
2023
|
+
emitError(24, stack[index].loc.start.offset);
|
|
2024
|
+
}
|
|
2025
|
+
},
|
|
2026
|
+
oncdata(start, end) {
|
|
2027
|
+
if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
|
|
2028
|
+
else emitError(1, start - 9);
|
|
2029
|
+
},
|
|
2030
|
+
onprocessinginstruction(start) {
|
|
2031
|
+
if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) emitError(21, start - 1);
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
|
2035
|
+
const stripParensRE = /^\(|\)$/g;
|
|
2036
|
+
function parseForExpression(input) {
|
|
2037
|
+
const loc = input.loc;
|
|
2038
|
+
const exp = input.content;
|
|
2039
|
+
const inMatch = exp.match(forAliasRE);
|
|
2040
|
+
if (!inMatch) return;
|
|
2041
|
+
const [, LHS, RHS] = inMatch;
|
|
2042
|
+
const createAliasExpression = (content, offset, asParam = false) => {
|
|
2043
|
+
const start = loc.start.offset + offset;
|
|
2044
|
+
return createExp(content, false, getLoc(start, start + content.length), 0, asParam ? 1 : 0);
|
|
2045
|
+
};
|
|
2046
|
+
const result = {
|
|
2047
|
+
source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
|
2048
|
+
value: void 0,
|
|
2049
|
+
key: void 0,
|
|
2050
|
+
index: void 0,
|
|
2051
|
+
finalized: false
|
|
2052
|
+
};
|
|
2053
|
+
let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
|
2054
|
+
const trimmedOffset = LHS.indexOf(valueContent);
|
|
2055
|
+
const iteratorMatch = valueContent.match(forIteratorRE);
|
|
2056
|
+
if (iteratorMatch) {
|
|
2057
|
+
valueContent = valueContent.replace(forIteratorRE, "").trim();
|
|
2058
|
+
const keyContent = iteratorMatch[1].trim();
|
|
2059
|
+
let keyOffset;
|
|
2060
|
+
if (keyContent) {
|
|
2061
|
+
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
2062
|
+
result.key = createAliasExpression(keyContent, keyOffset, true);
|
|
2063
|
+
}
|
|
2064
|
+
if (iteratorMatch[2]) {
|
|
2065
|
+
const indexContent = iteratorMatch[2].trim();
|
|
2066
|
+
if (indexContent) result.index = createAliasExpression(indexContent, exp.indexOf(indexContent, result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length), true);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
if (valueContent) result.value = createAliasExpression(valueContent, trimmedOffset, true);
|
|
2070
|
+
return result;
|
|
2071
|
+
}
|
|
2072
|
+
function getSlice(start, end) {
|
|
2073
|
+
return currentInput.slice(start, end);
|
|
2074
|
+
}
|
|
2075
|
+
function endOpenTag(end) {
|
|
2076
|
+
if (tokenizer.inSFCRoot) currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
|
|
2077
|
+
addNode(currentOpenTag);
|
|
2078
|
+
const { tag, ns } = currentOpenTag;
|
|
2079
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) inPre++;
|
|
2080
|
+
if (currentOptions.isVoidTag(tag)) onCloseTag(currentOpenTag, end);
|
|
2081
|
+
else {
|
|
2082
|
+
stack.unshift(currentOpenTag);
|
|
2083
|
+
if (ns === 1 || ns === 2) tokenizer.inXML = true;
|
|
2084
|
+
}
|
|
2085
|
+
currentOpenTag = null;
|
|
2086
|
+
}
|
|
2087
|
+
function onText(content, start, end) {
|
|
2088
|
+
const parent = stack[0] || currentRoot;
|
|
2089
|
+
const lastNode = parent.children[parent.children.length - 1];
|
|
2090
|
+
if (lastNode && lastNode.type === 2) {
|
|
2091
|
+
lastNode.content += content;
|
|
2092
|
+
setLocEnd(lastNode.loc, end);
|
|
2093
|
+
} else parent.children.push({
|
|
2094
|
+
type: 2,
|
|
2095
|
+
content,
|
|
2096
|
+
loc: getLoc(start, end)
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
function onCloseTag(el, end, isImplied = false) {
|
|
2100
|
+
if (isImplied) setLocEnd(el.loc, backTrack(end, 60));
|
|
2101
|
+
else setLocEnd(el.loc, lookAhead(end, 62) + 1);
|
|
2102
|
+
if (tokenizer.inSFCRoot) {
|
|
2103
|
+
if (el.children.length) el.innerLoc.end = shared.extend({}, el.children[el.children.length - 1].loc.end);
|
|
2104
|
+
else el.innerLoc.end = shared.extend({}, el.innerLoc.start);
|
|
2105
|
+
el.innerLoc.source = getSlice(el.innerLoc.start.offset, el.innerLoc.end.offset);
|
|
2106
|
+
}
|
|
2107
|
+
const { tag, ns, children } = el;
|
|
2108
|
+
if (!inVPre) {
|
|
2109
|
+
if (tag === "slot") el.tagType = 2;
|
|
2110
|
+
else if (isFragmentTemplate(el)) el.tagType = 3;
|
|
2111
|
+
else if (isComponent(el)) el.tagType = 1;
|
|
2112
|
+
}
|
|
2113
|
+
if (!tokenizer.inRCDATA) el.children = condenseWhitespace(children);
|
|
2114
|
+
if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
|
|
2115
|
+
const first = children[0];
|
|
2116
|
+
if (first && first.type === 2) first.content = first.content.replace(/^\r?\n/, "");
|
|
2117
|
+
}
|
|
2118
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) inPre--;
|
|
2119
|
+
if (currentVPreBoundary === el) {
|
|
2120
|
+
inVPre = tokenizer.inVPre = false;
|
|
2121
|
+
currentVPreBoundary = null;
|
|
2122
|
+
}
|
|
2123
|
+
if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) tokenizer.inXML = false;
|
|
2124
|
+
{
|
|
2125
|
+
const props = el.props;
|
|
2126
|
+
if (!tokenizer.inSFCRoot && isCompatEnabled("COMPILER_NATIVE_TEMPLATE", currentOptions) && el.tag === "template" && !isFragmentTemplate(el)) {
|
|
2127
|
+
const parent = stack[0] || currentRoot;
|
|
2128
|
+
const index = parent.children.indexOf(el);
|
|
2129
|
+
parent.children.splice(index, 1, ...el.children);
|
|
2130
|
+
}
|
|
2131
|
+
const inlineTemplateProp = props.find((p) => p.type === 6 && p.name === "inline-template");
|
|
2132
|
+
if (inlineTemplateProp && checkCompatEnabled("COMPILER_INLINE_TEMPLATE", currentOptions, inlineTemplateProp.loc) && el.children.length) inlineTemplateProp.value = {
|
|
2133
|
+
type: 2,
|
|
2134
|
+
content: getSlice(el.children[0].loc.start.offset, el.children[el.children.length - 1].loc.end.offset),
|
|
2135
|
+
loc: inlineTemplateProp.loc
|
|
2136
|
+
};
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function lookAhead(index, c) {
|
|
2140
|
+
let i = index;
|
|
2141
|
+
while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
|
|
2142
|
+
return i;
|
|
2143
|
+
}
|
|
2144
|
+
function backTrack(index, c) {
|
|
2145
|
+
let i = index;
|
|
2146
|
+
while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
|
|
2147
|
+
return i;
|
|
2148
|
+
}
|
|
2149
|
+
const specialTemplateDir = /* @__PURE__ */ new Set([
|
|
2150
|
+
"if",
|
|
2151
|
+
"else",
|
|
2152
|
+
"else-if",
|
|
2153
|
+
"for",
|
|
2154
|
+
"slot"
|
|
2155
|
+
]);
|
|
2156
|
+
function isFragmentTemplate({ tag, props }) {
|
|
2157
|
+
if (tag === "template") {
|
|
2158
|
+
for (let i = 0; i < props.length; i++) if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) return true;
|
|
2159
|
+
}
|
|
2160
|
+
return false;
|
|
2161
|
+
}
|
|
2162
|
+
function isComponent({ tag, props }) {
|
|
2163
|
+
if (currentOptions.isCustomElement(tag)) return false;
|
|
2164
|
+
if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) return true;
|
|
2165
|
+
for (let i = 0; i < props.length; i++) {
|
|
2166
|
+
const p = props[i];
|
|
2167
|
+
if (p.type === 6) {
|
|
2168
|
+
if (p.name === "is" && p.value) {
|
|
2169
|
+
if (p.value.content.startsWith("vue:")) return true;
|
|
2170
|
+
else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT", currentOptions, p.loc)) return true;
|
|
2171
|
+
}
|
|
2172
|
+
} else if (p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled("COMPILER_IS_ON_ELEMENT", currentOptions, p.loc)) return true;
|
|
2173
|
+
}
|
|
2174
|
+
return false;
|
|
2175
|
+
}
|
|
2176
|
+
function isUpperCase(c) {
|
|
2177
|
+
return c > 64 && c < 91;
|
|
2178
|
+
}
|
|
2179
|
+
const windowsNewlineRE = /\r\n/g;
|
|
2180
|
+
function condenseWhitespace(nodes) {
|
|
2181
|
+
const shouldCondense = currentOptions.whitespace !== "preserve";
|
|
2182
|
+
let removedWhitespace = false;
|
|
2183
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
2184
|
+
const node = nodes[i];
|
|
2185
|
+
if (node.type === 2) if (!inPre) {
|
|
2186
|
+
if (isAllWhitespace(node.content)) {
|
|
2187
|
+
const prev = nodes[i - 1] && nodes[i - 1].type;
|
|
2188
|
+
const next = nodes[i + 1] && nodes[i + 1].type;
|
|
2189
|
+
if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
|
2190
|
+
removedWhitespace = true;
|
|
2191
|
+
nodes[i] = null;
|
|
2192
|
+
} else node.content = " ";
|
|
2193
|
+
} else if (shouldCondense) node.content = condense(node.content);
|
|
2194
|
+
} else node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
2195
|
+
}
|
|
2196
|
+
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
2197
|
+
}
|
|
2198
|
+
function isAllWhitespace(str) {
|
|
2199
|
+
for (let i = 0; i < str.length; i++) if (!isWhitespace(str.charCodeAt(i))) return false;
|
|
2200
|
+
return true;
|
|
2201
|
+
}
|
|
2202
|
+
function hasNewlineChar(str) {
|
|
2203
|
+
for (let i = 0; i < str.length; i++) {
|
|
2204
|
+
const c = str.charCodeAt(i);
|
|
2205
|
+
if (c === 10 || c === 13) return true;
|
|
2206
|
+
}
|
|
2207
|
+
return false;
|
|
2208
|
+
}
|
|
2209
|
+
function condense(str) {
|
|
2210
|
+
let ret = "";
|
|
2211
|
+
let prevCharIsWhitespace = false;
|
|
2212
|
+
for (let i = 0; i < str.length; i++) if (isWhitespace(str.charCodeAt(i))) {
|
|
2213
|
+
if (!prevCharIsWhitespace) {
|
|
2214
|
+
ret += " ";
|
|
2215
|
+
prevCharIsWhitespace = true;
|
|
2216
|
+
}
|
|
2217
|
+
} else {
|
|
2218
|
+
ret += str[i];
|
|
2219
|
+
prevCharIsWhitespace = false;
|
|
2220
|
+
}
|
|
2221
|
+
return ret;
|
|
2222
|
+
}
|
|
2223
|
+
function addNode(node) {
|
|
2224
|
+
(stack[0] || currentRoot).children.push(node);
|
|
2225
|
+
}
|
|
2226
|
+
function getLoc(start, end) {
|
|
2227
|
+
return {
|
|
2228
|
+
start: tokenizer.getPos(start),
|
|
2229
|
+
end: end == null ? end : tokenizer.getPos(end),
|
|
2230
|
+
source: end == null ? end : getSlice(start, end)
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
function cloneLoc(loc) {
|
|
2234
|
+
return getLoc(loc.start.offset, loc.end.offset);
|
|
2235
|
+
}
|
|
2236
|
+
function setLocEnd(loc, end) {
|
|
2237
|
+
loc.end = tokenizer.getPos(end);
|
|
2238
|
+
loc.source = getSlice(loc.start.offset, end);
|
|
2239
|
+
}
|
|
2240
|
+
function dirToAttr(dir) {
|
|
2241
|
+
const attr = {
|
|
2242
|
+
type: 6,
|
|
2243
|
+
name: dir.rawName,
|
|
2244
|
+
nameLoc: getLoc(dir.loc.start.offset, dir.loc.start.offset + dir.rawName.length),
|
|
2245
|
+
value: void 0,
|
|
2246
|
+
loc: dir.loc
|
|
2247
|
+
};
|
|
2248
|
+
if (dir.exp) {
|
|
2249
|
+
const loc = dir.exp.loc;
|
|
2250
|
+
if (loc.end.offset < dir.loc.end.offset) {
|
|
2251
|
+
loc.start.offset--;
|
|
2252
|
+
loc.start.column--;
|
|
2253
|
+
loc.end.offset++;
|
|
2254
|
+
loc.end.column++;
|
|
2255
|
+
}
|
|
2256
|
+
attr.value = {
|
|
2257
|
+
type: 2,
|
|
2258
|
+
content: dir.exp.content,
|
|
2259
|
+
loc
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
return attr;
|
|
2263
|
+
}
|
|
2264
|
+
function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0) {
|
|
2265
|
+
const exp = createSimpleExpression(content, isStatic, loc, constType);
|
|
2266
|
+
if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 && content.trim()) {
|
|
2267
|
+
if (isSimpleIdentifier(content)) {
|
|
2268
|
+
exp.ast = null;
|
|
2269
|
+
return exp;
|
|
2270
|
+
}
|
|
2271
|
+
try {
|
|
2272
|
+
const plugins = currentOptions.expressionPlugins;
|
|
2273
|
+
const options = { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] };
|
|
2274
|
+
if (parseMode === 2) exp.ast = parser.parse(` ${content} `, options).program;
|
|
2275
|
+
else if (parseMode === 1) exp.ast = parser.parseExpression(`(${content})=>{}`, options);
|
|
2276
|
+
else exp.ast = parser.parseExpression(`(${content})`, options);
|
|
2277
|
+
} catch (e) {
|
|
2278
|
+
exp.ast = false;
|
|
2279
|
+
emitError(45, loc.start.offset, e.message);
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
return exp;
|
|
2283
|
+
}
|
|
2284
|
+
function emitError(code, index, message) {
|
|
2285
|
+
currentOptions.onError(createCompilerError(code, getLoc(index, index), void 0, message));
|
|
2286
|
+
}
|
|
2287
|
+
function reset() {
|
|
2288
|
+
tokenizer.reset();
|
|
2289
|
+
currentOpenTag = null;
|
|
2290
|
+
currentProp = null;
|
|
2291
|
+
currentAttrValue = "";
|
|
2292
|
+
currentAttrStartIndex = -1;
|
|
2293
|
+
currentAttrEndIndex = -1;
|
|
2294
|
+
stack.length = 0;
|
|
2295
|
+
}
|
|
2296
|
+
function baseParse(input, options) {
|
|
2297
|
+
reset();
|
|
2298
|
+
currentInput = input;
|
|
2299
|
+
currentOptions = shared.extend({}, defaultParserOptions);
|
|
2300
|
+
if (options) {
|
|
2301
|
+
let key;
|
|
2302
|
+
for (key in options) if (options[key] != null) currentOptions[key] = options[key];
|
|
2303
|
+
}
|
|
2304
|
+
tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
2305
|
+
tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
|
|
2306
|
+
const delimiters = options && options.delimiters;
|
|
2307
|
+
if (delimiters) {
|
|
2308
|
+
tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
|
2309
|
+
tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
|
2310
|
+
}
|
|
2311
|
+
const root = currentRoot = createRoot([], input);
|
|
2312
|
+
tokenizer.parse(currentInput);
|
|
2313
|
+
root.loc = getLoc(0, input.length);
|
|
2314
|
+
root.children = condenseWhitespace(root.children);
|
|
2315
|
+
currentRoot = null;
|
|
2316
|
+
return root;
|
|
2317
|
+
}
|
|
2318
|
+
function cacheStatic(root, context) {
|
|
2319
|
+
walk(root, void 0, context, !!getSingleElementRoot(root));
|
|
2320
|
+
}
|
|
2321
|
+
function getSingleElementRoot(root) {
|
|
2322
|
+
const children = root.children.filter((x) => x.type !== 3);
|
|
2323
|
+
return children.length === 1 && children[0].type === 1 && !isSlotOutlet(children[0]) ? children[0] : null;
|
|
2324
|
+
}
|
|
2325
|
+
function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
2326
|
+
const { children } = node;
|
|
2327
|
+
const toCache = [];
|
|
2328
|
+
for (let i = 0; i < children.length; i++) {
|
|
2329
|
+
const child = children[i];
|
|
2330
|
+
if (child.type === 1 && child.tagType === 0) {
|
|
2331
|
+
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
2332
|
+
if (constantType > 0) {
|
|
2333
|
+
if (constantType >= 2) {
|
|
2334
|
+
child.codegenNode.patchFlag = -1;
|
|
2335
|
+
toCache.push(child);
|
|
2336
|
+
continue;
|
|
2337
|
+
}
|
|
2338
|
+
} else {
|
|
2339
|
+
const codegenNode = child.codegenNode;
|
|
2340
|
+
if (codegenNode.type === 13) {
|
|
2341
|
+
const flag = codegenNode.patchFlag;
|
|
2342
|
+
if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
|
|
2343
|
+
const props = getNodeProps(child);
|
|
2344
|
+
if (props) codegenNode.props = context.hoist(props);
|
|
2345
|
+
}
|
|
2346
|
+
if (codegenNode.dynamicProps) codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
} else if (child.type === 12) {
|
|
2350
|
+
if ((doNotHoistNode ? 0 : getConstantType(child, context)) >= 2) {
|
|
2351
|
+
if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) child.codegenNode.arguments.push("-1");
|
|
2352
|
+
toCache.push(child);
|
|
2353
|
+
continue;
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
if (child.type === 1) {
|
|
2357
|
+
const isComponent$1 = child.tagType === 1;
|
|
2358
|
+
if (isComponent$1) context.scopes.vSlot++;
|
|
2359
|
+
walk(child, node, context, false, inFor);
|
|
2360
|
+
if (isComponent$1) context.scopes.vSlot--;
|
|
2361
|
+
} else if (child.type === 11) walk(child, node, context, child.children.length === 1, true);
|
|
2362
|
+
else if (child.type === 9) for (let i2 = 0; i2 < child.branches.length; i2++) walk(child.branches[i2], node, context, child.branches[i2].children.length === 1, inFor);
|
|
2363
|
+
}
|
|
2364
|
+
let cachedAsArray = false;
|
|
2365
|
+
if (toCache.length === children.length && node.type === 1) {
|
|
2366
|
+
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
|
|
2367
|
+
node.codegenNode.children = getCacheExpression(createArrayExpression(node.codegenNode.children));
|
|
2368
|
+
cachedAsArray = true;
|
|
2369
|
+
} else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
2370
|
+
const slot = getSlotNode(node.codegenNode, "default");
|
|
2371
|
+
if (slot) {
|
|
2372
|
+
slot.returns = getCacheExpression(createArrayExpression(slot.returns));
|
|
2373
|
+
cachedAsArray = true;
|
|
2374
|
+
}
|
|
2375
|
+
} else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !shared.isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
|
|
2376
|
+
const slotName = findDir(node, "slot", true);
|
|
2377
|
+
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
2378
|
+
if (slot) {
|
|
2379
|
+
slot.returns = getCacheExpression(createArrayExpression(slot.returns));
|
|
2380
|
+
cachedAsArray = true;
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
if (!cachedAsArray) for (const child of toCache) child.codegenNode = context.cache(child.codegenNode);
|
|
2385
|
+
function getCacheExpression(value) {
|
|
2386
|
+
const exp = context.cache(value);
|
|
2387
|
+
exp.needArraySpread = true;
|
|
2388
|
+
return exp;
|
|
2389
|
+
}
|
|
2390
|
+
function getSlotNode(node2, name) {
|
|
2391
|
+
if (node2.children && !shared.isArray(node2.children) && node2.children.type === 15) {
|
|
2392
|
+
const slot = node2.children.properties.find((p) => p.key === name || p.key.content === name);
|
|
2393
|
+
return slot && slot.value;
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
if (toCache.length && context.transformHoist) context.transformHoist(children, context, node);
|
|
2397
|
+
}
|
|
2398
|
+
function getConstantType(node, context) {
|
|
2399
|
+
const { constantCache } = context;
|
|
2400
|
+
switch (node.type) {
|
|
2401
|
+
case 1:
|
|
2402
|
+
if (node.tagType !== 0) return 0;
|
|
2403
|
+
const cached = constantCache.get(node);
|
|
2404
|
+
if (cached !== void 0) return cached;
|
|
2405
|
+
const codegenNode = node.codegenNode;
|
|
2406
|
+
if (codegenNode.type !== 13) return 0;
|
|
2407
|
+
if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") return 0;
|
|
2408
|
+
if (codegenNode.patchFlag === void 0) {
|
|
2409
|
+
let returnType2 = 3;
|
|
2410
|
+
const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
|
2411
|
+
if (generatedPropsType === 0) {
|
|
2412
|
+
constantCache.set(node, 0);
|
|
2413
|
+
return 0;
|
|
2414
|
+
}
|
|
2415
|
+
if (generatedPropsType < returnType2) returnType2 = generatedPropsType;
|
|
2416
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
2417
|
+
const childType = getConstantType(node.children[i], context);
|
|
2418
|
+
if (childType === 0) {
|
|
2419
|
+
constantCache.set(node, 0);
|
|
2420
|
+
return 0;
|
|
2421
|
+
}
|
|
2422
|
+
if (childType < returnType2) returnType2 = childType;
|
|
2423
|
+
}
|
|
2424
|
+
if (returnType2 > 1) for (let i = 0; i < node.props.length; i++) {
|
|
2425
|
+
const p = node.props[i];
|
|
2426
|
+
if (p.type === 7 && p.name === "bind" && p.exp) {
|
|
2427
|
+
const expType = getConstantType(p.exp, context);
|
|
2428
|
+
if (expType === 0) {
|
|
2429
|
+
constantCache.set(node, 0);
|
|
2430
|
+
return 0;
|
|
2431
|
+
}
|
|
2432
|
+
if (expType < returnType2) returnType2 = expType;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
if (codegenNode.isBlock) {
|
|
2436
|
+
for (let i = 0; i < node.props.length; i++) if (node.props[i].type === 7) {
|
|
2437
|
+
constantCache.set(node, 0);
|
|
2438
|
+
return 0;
|
|
2439
|
+
}
|
|
2440
|
+
context.removeHelper(OPEN_BLOCK);
|
|
2441
|
+
context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
|
|
2442
|
+
codegenNode.isBlock = false;
|
|
2443
|
+
context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
|
|
2444
|
+
}
|
|
2445
|
+
constantCache.set(node, returnType2);
|
|
2446
|
+
return returnType2;
|
|
2447
|
+
} else {
|
|
2448
|
+
constantCache.set(node, 0);
|
|
2449
|
+
return 0;
|
|
2450
|
+
}
|
|
2451
|
+
case 2:
|
|
2452
|
+
case 3: return 3;
|
|
2453
|
+
case 9:
|
|
2454
|
+
case 11:
|
|
2455
|
+
case 10: return 0;
|
|
2456
|
+
case 5:
|
|
2457
|
+
case 12: return getConstantType(node.content, context);
|
|
2458
|
+
case 4: return node.constType;
|
|
2459
|
+
case 8:
|
|
2460
|
+
let returnType = 3;
|
|
2461
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
2462
|
+
const child = node.children[i];
|
|
2463
|
+
if (shared.isString(child) || shared.isSymbol(child)) continue;
|
|
2464
|
+
const childType = getConstantType(child, context);
|
|
2465
|
+
if (childType === 0) return 0;
|
|
2466
|
+
else if (childType < returnType) returnType = childType;
|
|
2467
|
+
}
|
|
2468
|
+
return returnType;
|
|
2469
|
+
case 20: return 2;
|
|
2470
|
+
default: return 0;
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
const allowHoistedHelperSet = /* @__PURE__ */ new Set([
|
|
2474
|
+
NORMALIZE_CLASS,
|
|
2475
|
+
NORMALIZE_STYLE,
|
|
2476
|
+
NORMALIZE_PROPS,
|
|
2477
|
+
GUARD_REACTIVE_PROPS
|
|
2478
|
+
]);
|
|
2479
|
+
function getConstantTypeOfHelperCall(value, context) {
|
|
2480
|
+
if (value.type === 14 && !shared.isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
|
2481
|
+
const arg = value.arguments[0];
|
|
2482
|
+
if (arg.type === 4) return getConstantType(arg, context);
|
|
2483
|
+
else if (arg.type === 14) return getConstantTypeOfHelperCall(arg, context);
|
|
2484
|
+
}
|
|
2485
|
+
return 0;
|
|
2486
|
+
}
|
|
2487
|
+
function getGeneratedPropsConstantType(node, context) {
|
|
2488
|
+
let returnType = 3;
|
|
2489
|
+
const props = getNodeProps(node);
|
|
2490
|
+
if (props && props.type === 15) {
|
|
2491
|
+
const { properties } = props;
|
|
2492
|
+
for (let i = 0; i < properties.length; i++) {
|
|
2493
|
+
const { key, value } = properties[i];
|
|
2494
|
+
const keyType = getConstantType(key, context);
|
|
2495
|
+
if (keyType === 0) return keyType;
|
|
2496
|
+
if (keyType < returnType) returnType = keyType;
|
|
2497
|
+
let valueType;
|
|
2498
|
+
if (value.type === 4) valueType = getConstantType(value, context);
|
|
2499
|
+
else if (value.type === 14) valueType = getConstantTypeOfHelperCall(value, context);
|
|
2500
|
+
else valueType = 0;
|
|
2501
|
+
if (valueType === 0) return valueType;
|
|
2502
|
+
if (valueType < returnType) returnType = valueType;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
return returnType;
|
|
2506
|
+
}
|
|
2507
|
+
function getNodeProps(node) {
|
|
2508
|
+
const codegenNode = node.codegenNode;
|
|
2509
|
+
if (codegenNode.type === 13) return codegenNode.props;
|
|
2510
|
+
}
|
|
2511
|
+
function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = shared.NOOP, isCustomElement = shared.NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = shared.EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
|
|
2512
|
+
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
2513
|
+
const context = {
|
|
2514
|
+
filename,
|
|
2515
|
+
selfName: nameMatch && shared.capitalize(shared.camelize(nameMatch[1])),
|
|
2516
|
+
prefixIdentifiers,
|
|
2517
|
+
hoistStatic,
|
|
2518
|
+
hmr,
|
|
2519
|
+
cacheHandlers,
|
|
2520
|
+
nodeTransforms,
|
|
2521
|
+
directiveTransforms,
|
|
2522
|
+
transformHoist,
|
|
2523
|
+
isBuiltInComponent,
|
|
2524
|
+
isCustomElement,
|
|
2525
|
+
expressionPlugins,
|
|
2526
|
+
scopeId,
|
|
2527
|
+
slotted,
|
|
2528
|
+
ssr,
|
|
2529
|
+
inSSR,
|
|
2530
|
+
ssrCssVars,
|
|
2531
|
+
bindingMetadata,
|
|
2532
|
+
inline,
|
|
2533
|
+
isTS,
|
|
2534
|
+
onError,
|
|
2535
|
+
onWarn,
|
|
2536
|
+
compatConfig,
|
|
2537
|
+
root,
|
|
2538
|
+
helpers: /* @__PURE__ */ new Map(),
|
|
2539
|
+
components: /* @__PURE__ */ new Set(),
|
|
2540
|
+
directives: /* @__PURE__ */ new Set(),
|
|
2541
|
+
hoists: [],
|
|
2542
|
+
imports: [],
|
|
2543
|
+
cached: [],
|
|
2544
|
+
constantCache: /* @__PURE__ */ new WeakMap(),
|
|
2545
|
+
temps: 0,
|
|
2546
|
+
identifiers: /* @__PURE__ */ Object.create(null),
|
|
2547
|
+
scopes: {
|
|
2548
|
+
vFor: 0,
|
|
2549
|
+
vSlot: 0,
|
|
2550
|
+
vPre: 0,
|
|
2551
|
+
vOnce: 0
|
|
2552
|
+
},
|
|
2553
|
+
parent: null,
|
|
2554
|
+
grandParent: null,
|
|
2555
|
+
currentNode: root,
|
|
2556
|
+
childIndex: 0,
|
|
2557
|
+
inVOnce: false,
|
|
2558
|
+
helper(name) {
|
|
2559
|
+
const count = context.helpers.get(name) || 0;
|
|
2560
|
+
context.helpers.set(name, count + 1);
|
|
2561
|
+
return name;
|
|
2562
|
+
},
|
|
2563
|
+
removeHelper(name) {
|
|
2564
|
+
const count = context.helpers.get(name);
|
|
2565
|
+
if (count) {
|
|
2566
|
+
const currentCount = count - 1;
|
|
2567
|
+
if (!currentCount) context.helpers.delete(name);
|
|
2568
|
+
else context.helpers.set(name, currentCount);
|
|
2569
|
+
}
|
|
2570
|
+
},
|
|
2571
|
+
helperString(name) {
|
|
2572
|
+
return `_${helperNameMap[context.helper(name)]}`;
|
|
2573
|
+
},
|
|
2574
|
+
replaceNode(node) {
|
|
2575
|
+
context.parent.children[context.childIndex] = context.currentNode = node;
|
|
2576
|
+
},
|
|
2577
|
+
removeNode(node) {
|
|
2578
|
+
const list = context.parent.children;
|
|
2579
|
+
const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
|
|
2580
|
+
if (!node || node === context.currentNode) {
|
|
2581
|
+
context.currentNode = null;
|
|
2582
|
+
context.onNodeRemoved();
|
|
2583
|
+
} else if (context.childIndex > removalIndex) {
|
|
2584
|
+
context.childIndex--;
|
|
2585
|
+
context.onNodeRemoved();
|
|
2586
|
+
}
|
|
2587
|
+
context.parent.children.splice(removalIndex, 1);
|
|
2588
|
+
},
|
|
2589
|
+
onNodeRemoved: shared.NOOP,
|
|
2590
|
+
addIdentifiers(exp) {
|
|
2591
|
+
if (shared.isString(exp)) addId(exp);
|
|
2592
|
+
else if (exp.identifiers) exp.identifiers.forEach(addId);
|
|
2593
|
+
else if (exp.type === 4) addId(exp.content);
|
|
2594
|
+
},
|
|
2595
|
+
removeIdentifiers(exp) {
|
|
2596
|
+
if (shared.isString(exp)) removeId(exp);
|
|
2597
|
+
else if (exp.identifiers) exp.identifiers.forEach(removeId);
|
|
2598
|
+
else if (exp.type === 4) removeId(exp.content);
|
|
2599
|
+
},
|
|
2600
|
+
hoist(exp) {
|
|
2601
|
+
if (shared.isString(exp)) exp = createSimpleExpression(exp);
|
|
2602
|
+
context.hoists.push(exp);
|
|
2603
|
+
const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2);
|
|
2604
|
+
identifier.hoisted = exp;
|
|
2605
|
+
return identifier;
|
|
2606
|
+
},
|
|
2607
|
+
cache(exp, isVNode = false, inVOnce = false) {
|
|
2608
|
+
const cacheExp = createCacheExpression(context.cached.length, exp, isVNode, inVOnce);
|
|
2609
|
+
context.cached.push(cacheExp);
|
|
2610
|
+
return cacheExp;
|
|
2611
|
+
}
|
|
2612
|
+
};
|
|
2613
|
+
context.filters = /* @__PURE__ */ new Set();
|
|
2614
|
+
function addId(id) {
|
|
2615
|
+
const { identifiers } = context;
|
|
2616
|
+
if (identifiers[id] === void 0) identifiers[id] = 0;
|
|
2617
|
+
identifiers[id]++;
|
|
2618
|
+
}
|
|
2619
|
+
function removeId(id) {
|
|
2620
|
+
context.identifiers[id]--;
|
|
2621
|
+
}
|
|
2622
|
+
return context;
|
|
2623
|
+
}
|
|
2624
|
+
function transform(root, options) {
|
|
2625
|
+
const context = createTransformContext(root, options);
|
|
2626
|
+
traverseNode(root, context);
|
|
2627
|
+
if (options.hoistStatic) cacheStatic(root, context);
|
|
2628
|
+
if (!options.ssr) createRootCodegen(root, context);
|
|
2629
|
+
root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
|
|
2630
|
+
root.components = [...context.components];
|
|
2631
|
+
root.directives = [...context.directives];
|
|
2632
|
+
root.imports = context.imports;
|
|
2633
|
+
root.hoists = context.hoists;
|
|
2634
|
+
root.temps = context.temps;
|
|
2635
|
+
root.cached = context.cached;
|
|
2636
|
+
root.transformed = true;
|
|
2637
|
+
root.filters = [...context.filters];
|
|
2638
|
+
}
|
|
2639
|
+
function createRootCodegen(root, context) {
|
|
2640
|
+
const { helper } = context;
|
|
2641
|
+
const { children } = root;
|
|
2642
|
+
if (children.length === 1) {
|
|
2643
|
+
const singleElementRootChild = getSingleElementRoot(root);
|
|
2644
|
+
if (singleElementRootChild && singleElementRootChild.codegenNode) {
|
|
2645
|
+
const codegenNode = singleElementRootChild.codegenNode;
|
|
2646
|
+
if (codegenNode.type === 13) convertToBlock(codegenNode, context);
|
|
2647
|
+
root.codegenNode = codegenNode;
|
|
2648
|
+
} else root.codegenNode = children[0];
|
|
2649
|
+
} else if (children.length > 1) root.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, root.children, 64, void 0, void 0, true, void 0, false);
|
|
2650
|
+
}
|
|
2651
|
+
function traverseChildren(parent, context) {
|
|
2652
|
+
let i = 0;
|
|
2653
|
+
const nodeRemoved = () => {
|
|
2654
|
+
i--;
|
|
2655
|
+
};
|
|
2656
|
+
for (; i < parent.children.length; i++) {
|
|
2657
|
+
const child = parent.children[i];
|
|
2658
|
+
if (shared.isString(child)) continue;
|
|
2659
|
+
context.grandParent = context.parent;
|
|
2660
|
+
context.parent = parent;
|
|
2661
|
+
context.childIndex = i;
|
|
2662
|
+
context.onNodeRemoved = nodeRemoved;
|
|
2663
|
+
traverseNode(child, context);
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
function traverseNode(node, context) {
|
|
2667
|
+
context.currentNode = node;
|
|
2668
|
+
const { nodeTransforms } = context;
|
|
2669
|
+
const exitFns = [];
|
|
2670
|
+
for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
|
|
2671
|
+
const onExit = nodeTransforms[i2](node, context);
|
|
2672
|
+
if (onExit) if (shared.isArray(onExit)) exitFns.push(...onExit);
|
|
2673
|
+
else exitFns.push(onExit);
|
|
2674
|
+
if (!context.currentNode) return;
|
|
2675
|
+
else node = context.currentNode;
|
|
2676
|
+
}
|
|
2677
|
+
switch (node.type) {
|
|
2678
|
+
case 3:
|
|
2679
|
+
if (!context.ssr) context.helper(CREATE_COMMENT);
|
|
2680
|
+
break;
|
|
2681
|
+
case 5:
|
|
2682
|
+
if (!context.ssr) context.helper(TO_DISPLAY_STRING);
|
|
2683
|
+
break;
|
|
2684
|
+
case 9:
|
|
2685
|
+
for (let i2 = 0; i2 < node.branches.length; i2++) traverseNode(node.branches[i2], context);
|
|
2686
|
+
break;
|
|
2687
|
+
case 10:
|
|
2688
|
+
case 11:
|
|
2689
|
+
case 1:
|
|
2690
|
+
case 0:
|
|
2691
|
+
traverseChildren(node, context);
|
|
2692
|
+
break;
|
|
2693
|
+
}
|
|
2694
|
+
context.currentNode = node;
|
|
2695
|
+
let i = exitFns.length;
|
|
2696
|
+
while (i--) exitFns[i]();
|
|
2697
|
+
}
|
|
2698
|
+
function createStructuralDirectiveTransform(name, fn) {
|
|
2699
|
+
const matches = shared.isString(name) ? (n) => n === name : (n) => name.test(n);
|
|
2700
|
+
return (node, context) => {
|
|
2701
|
+
if (node.type === 1) {
|
|
2702
|
+
const { props } = node;
|
|
2703
|
+
if (node.tagType === 3 && props.some(isVSlot)) return;
|
|
2704
|
+
const exitFns = [];
|
|
2705
|
+
for (let i = 0; i < props.length; i++) {
|
|
2706
|
+
const prop = props[i];
|
|
2707
|
+
if (prop.type === 7 && matches(prop.name)) {
|
|
2708
|
+
props.splice(i, 1);
|
|
2709
|
+
i--;
|
|
2710
|
+
const onExit = fn(node, prop, context);
|
|
2711
|
+
if (onExit) exitFns.push(onExit);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
return exitFns;
|
|
2715
|
+
}
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
const PURE_ANNOTATION = `/*@__PURE__*/`;
|
|
2719
|
+
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2720
|
+
function createCodegenContext(ast, { mode = "function", prefixIdentifiers = mode === "module", sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = "vue/server-renderer", ssr = false, isTS = false, inSSR = false }) {
|
|
2721
|
+
const context = {
|
|
2722
|
+
mode,
|
|
2723
|
+
prefixIdentifiers,
|
|
2724
|
+
sourceMap,
|
|
2725
|
+
filename,
|
|
2726
|
+
scopeId,
|
|
2727
|
+
optimizeImports,
|
|
2728
|
+
runtimeGlobalName,
|
|
2729
|
+
runtimeModuleName,
|
|
2730
|
+
ssrRuntimeModuleName,
|
|
2731
|
+
ssr,
|
|
2732
|
+
isTS,
|
|
2733
|
+
inSSR,
|
|
2734
|
+
source: ast.source,
|
|
2735
|
+
code: ``,
|
|
2736
|
+
column: 1,
|
|
2737
|
+
line: 1,
|
|
2738
|
+
offset: 0,
|
|
2739
|
+
indentLevel: 0,
|
|
2740
|
+
pure: false,
|
|
2741
|
+
map: void 0,
|
|
2742
|
+
helper(key) {
|
|
2743
|
+
return `_${helperNameMap[key]}`;
|
|
2744
|
+
},
|
|
2745
|
+
push(code, newlineIndex = -2, node) {
|
|
2746
|
+
context.code += code;
|
|
2747
|
+
if (context.map) {
|
|
2748
|
+
if (node) {
|
|
2749
|
+
let name;
|
|
2750
|
+
if (node.type === 4 && !node.isStatic) {
|
|
2751
|
+
const content = node.content.replace(/^_ctx\./, "");
|
|
2752
|
+
if (content !== node.content && isSimpleIdentifier(content)) name = content;
|
|
2753
|
+
}
|
|
2754
|
+
if (node.loc.source) addMapping(node.loc.start, name);
|
|
2755
|
+
}
|
|
2756
|
+
if (newlineIndex === -3) advancePositionWithMutation(context, code);
|
|
2757
|
+
else {
|
|
2758
|
+
context.offset += code.length;
|
|
2759
|
+
if (newlineIndex === -2) context.column += code.length;
|
|
2760
|
+
else {
|
|
2761
|
+
if (newlineIndex === -1) newlineIndex = code.length - 1;
|
|
2762
|
+
context.line++;
|
|
2763
|
+
context.column = code.length - newlineIndex;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
if (node && node.loc !== locStub && node.loc.source) addMapping(node.loc.end);
|
|
2767
|
+
}
|
|
2768
|
+
},
|
|
2769
|
+
indent() {
|
|
2770
|
+
newline(++context.indentLevel);
|
|
2771
|
+
},
|
|
2772
|
+
deindent(withoutNewLine = false) {
|
|
2773
|
+
if (withoutNewLine) --context.indentLevel;
|
|
2774
|
+
else newline(--context.indentLevel);
|
|
2775
|
+
},
|
|
2776
|
+
newline() {
|
|
2777
|
+
newline(context.indentLevel);
|
|
2778
|
+
}
|
|
2779
|
+
};
|
|
2780
|
+
function newline(n) {
|
|
2781
|
+
context.push("\n" + ` `.repeat(n), 0);
|
|
2782
|
+
}
|
|
2783
|
+
function addMapping(loc, name = null) {
|
|
2784
|
+
const { _names, _mappings } = context.map;
|
|
2785
|
+
if (name !== null && !_names.has(name)) _names.add(name);
|
|
2786
|
+
_mappings.add({
|
|
2787
|
+
originalLine: loc.line,
|
|
2788
|
+
originalColumn: loc.column - 1,
|
|
2789
|
+
generatedLine: context.line,
|
|
2790
|
+
generatedColumn: context.column - 1,
|
|
2791
|
+
source: filename,
|
|
2792
|
+
name
|
|
2793
|
+
});
|
|
2794
|
+
}
|
|
2795
|
+
if (sourceMap) {
|
|
2796
|
+
context.map = new sourceMapJs.SourceMapGenerator();
|
|
2797
|
+
context.map.setSourceContent(filename, context.source);
|
|
2798
|
+
context.map._sources.add(filename);
|
|
2799
|
+
}
|
|
2800
|
+
return context;
|
|
2801
|
+
}
|
|
2802
|
+
function generate(ast, options = {}) {
|
|
2803
|
+
const context = createCodegenContext(ast, options);
|
|
2804
|
+
if (options.onContextCreated) options.onContextCreated(context);
|
|
2805
|
+
const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
|
|
2806
|
+
const helpers = Array.from(ast.helpers);
|
|
2807
|
+
const hasHelpers = helpers.length > 0;
|
|
2808
|
+
const useWithBlock = !prefixIdentifiers && mode !== "module";
|
|
2809
|
+
const genScopeId = scopeId != null && mode === "module";
|
|
2810
|
+
const isSetupInlined = !!options.inline;
|
|
2811
|
+
const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
|
|
2812
|
+
if (mode === "module") genModulePreamble(ast, preambleContext, genScopeId, isSetupInlined);
|
|
2813
|
+
else genFunctionPreamble(ast, preambleContext);
|
|
2814
|
+
const functionName = ssr ? `ssrRender` : `render`;
|
|
2815
|
+
const args = ssr ? [
|
|
2816
|
+
"_ctx",
|
|
2817
|
+
"_push",
|
|
2818
|
+
"_parent",
|
|
2819
|
+
"_attrs"
|
|
2820
|
+
] : ["_ctx", "_cache"];
|
|
2821
|
+
if (options.bindingMetadata && !options.inline) args.push("$props", "$setup", "$data", "$options");
|
|
2822
|
+
const signature = options.isTS ? args.map((arg) => `${arg}: any`).join(",") : args.join(", ");
|
|
2823
|
+
if (isSetupInlined) push(`(${signature}) => {`);
|
|
2824
|
+
else push(`function ${functionName}(${signature}) {`);
|
|
2825
|
+
indent();
|
|
2826
|
+
if (useWithBlock) {
|
|
2827
|
+
push(`with (_ctx) {`);
|
|
2828
|
+
indent();
|
|
2829
|
+
if (hasHelpers) {
|
|
2830
|
+
push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
2831
|
+
`, -1);
|
|
2832
|
+
newline();
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
if (ast.components.length) {
|
|
2836
|
+
genAssets(ast.components, "component", context);
|
|
2837
|
+
if (ast.directives.length || ast.temps > 0) newline();
|
|
2838
|
+
}
|
|
2839
|
+
if (ast.directives.length) {
|
|
2840
|
+
genAssets(ast.directives, "directive", context);
|
|
2841
|
+
if (ast.temps > 0) newline();
|
|
2842
|
+
}
|
|
2843
|
+
if (ast.filters && ast.filters.length) {
|
|
2844
|
+
newline();
|
|
2845
|
+
genAssets(ast.filters, "filter", context);
|
|
2846
|
+
newline();
|
|
2847
|
+
}
|
|
2848
|
+
if (ast.temps > 0) {
|
|
2849
|
+
push(`let `);
|
|
2850
|
+
for (let i = 0; i < ast.temps; i++) push(`${i > 0 ? `, ` : ``}_temp${i}`);
|
|
2851
|
+
}
|
|
2852
|
+
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
2853
|
+
push(`
|
|
2854
|
+
`, 0);
|
|
2855
|
+
newline();
|
|
2856
|
+
}
|
|
2857
|
+
if (!ssr) push(`return `);
|
|
2858
|
+
if (ast.codegenNode) genNode(ast.codegenNode, context);
|
|
2859
|
+
else push(`null`);
|
|
2860
|
+
if (useWithBlock) {
|
|
2861
|
+
deindent();
|
|
2862
|
+
push(`}`);
|
|
2863
|
+
}
|
|
2864
|
+
deindent();
|
|
2865
|
+
push(`}`);
|
|
2866
|
+
return {
|
|
2867
|
+
ast,
|
|
2868
|
+
code: context.code,
|
|
2869
|
+
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
2870
|
+
map: context.map ? context.map.toJSON() : void 0
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
function genFunctionPreamble(ast, context) {
|
|
2874
|
+
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
2875
|
+
const VueBinding = ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName;
|
|
2876
|
+
const helpers = Array.from(ast.helpers);
|
|
2877
|
+
if (helpers.length > 0) if (prefixIdentifiers) push(`const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
|
|
2878
|
+
`, -1);
|
|
2879
|
+
else {
|
|
2880
|
+
push(`const _Vue = ${VueBinding}
|
|
2881
|
+
`, -1);
|
|
2882
|
+
if (ast.hoists.length) push(`const { ${[
|
|
2883
|
+
CREATE_VNODE,
|
|
2884
|
+
CREATE_ELEMENT_VNODE,
|
|
2885
|
+
CREATE_COMMENT,
|
|
2886
|
+
CREATE_TEXT,
|
|
2887
|
+
CREATE_STATIC
|
|
2888
|
+
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ")} } = _Vue
|
|
2889
|
+
`, -1);
|
|
2890
|
+
}
|
|
2891
|
+
if (ast.ssrHelpers && ast.ssrHelpers.length) push(`const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
|
|
2892
|
+
`, -1);
|
|
2893
|
+
genHoists(ast.hoists, context);
|
|
2894
|
+
newline();
|
|
2895
|
+
push(`return `);
|
|
2896
|
+
}
|
|
2897
|
+
function genModulePreamble(ast, context, genScopeId, inline) {
|
|
2898
|
+
const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
|
|
2899
|
+
if (ast.helpers.size) {
|
|
2900
|
+
const helpers = Array.from(ast.helpers);
|
|
2901
|
+
if (optimizeImports) {
|
|
2902
|
+
push(`import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
|
|
2903
|
+
`, -1);
|
|
2904
|
+
push(`
|
|
2905
|
+
// Binding optimization for webpack code-split
|
|
2906
|
+
const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
|
|
2907
|
+
`, -1);
|
|
2908
|
+
} else push(`import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
|
|
2909
|
+
`, -1);
|
|
2910
|
+
}
|
|
2911
|
+
if (ast.ssrHelpers && ast.ssrHelpers.length) push(`import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
|
|
2912
|
+
`, -1);
|
|
2913
|
+
if (ast.imports.length) {
|
|
2914
|
+
genImports(ast.imports, context);
|
|
2915
|
+
newline();
|
|
2916
|
+
}
|
|
2917
|
+
genHoists(ast.hoists, context);
|
|
2918
|
+
newline();
|
|
2919
|
+
if (!inline) push(`export `);
|
|
2920
|
+
}
|
|
2921
|
+
function genAssets(assets, type, { helper, push, newline, isTS }) {
|
|
2922
|
+
const resolver = helper(type === "filter" ? RESOLVE_FILTER : type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE);
|
|
2923
|
+
for (let i = 0; i < assets.length; i++) {
|
|
2924
|
+
let id = assets[i];
|
|
2925
|
+
const maybeSelfReference = id.endsWith("__self");
|
|
2926
|
+
if (maybeSelfReference) id = id.slice(0, -6);
|
|
2927
|
+
push(`const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`);
|
|
2928
|
+
if (i < assets.length - 1) newline();
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
function genHoists(hoists, context) {
|
|
2932
|
+
if (!hoists.length) return;
|
|
2933
|
+
context.pure = true;
|
|
2934
|
+
const { push, newline } = context;
|
|
2935
|
+
newline();
|
|
2936
|
+
for (let i = 0; i < hoists.length; i++) {
|
|
2937
|
+
const exp = hoists[i];
|
|
2938
|
+
if (exp) {
|
|
2939
|
+
push(`const _hoisted_${i + 1} = `);
|
|
2940
|
+
genNode(exp, context);
|
|
2941
|
+
newline();
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
context.pure = false;
|
|
2945
|
+
}
|
|
2946
|
+
function genImports(importsOptions, context) {
|
|
2947
|
+
if (!importsOptions.length) return;
|
|
2948
|
+
importsOptions.forEach((imports) => {
|
|
2949
|
+
context.push(`import `);
|
|
2950
|
+
genNode(imports.exp, context);
|
|
2951
|
+
context.push(` from '${imports.path}'`);
|
|
2952
|
+
context.newline();
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2955
|
+
function isText(n) {
|
|
2956
|
+
return shared.isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
|
|
2957
|
+
}
|
|
2958
|
+
function genNodeListAsArray(nodes, context) {
|
|
2959
|
+
const multilines = nodes.length > 3 || nodes.some((n) => shared.isArray(n) || !isText(n));
|
|
2960
|
+
context.push(`[`);
|
|
2961
|
+
multilines && context.indent();
|
|
2962
|
+
genNodeList(nodes, context, multilines);
|
|
2963
|
+
multilines && context.deindent();
|
|
2964
|
+
context.push(`]`);
|
|
2965
|
+
}
|
|
2966
|
+
function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
2967
|
+
const { push, newline } = context;
|
|
2968
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
2969
|
+
const node = nodes[i];
|
|
2970
|
+
if (shared.isString(node)) push(node, -3);
|
|
2971
|
+
else if (shared.isArray(node)) genNodeListAsArray(node, context);
|
|
2972
|
+
else genNode(node, context);
|
|
2973
|
+
if (i < nodes.length - 1) if (multilines) {
|
|
2974
|
+
comma && push(",");
|
|
2975
|
+
newline();
|
|
2976
|
+
} else comma && push(", ");
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
function genNode(node, context) {
|
|
2980
|
+
if (shared.isString(node)) {
|
|
2981
|
+
context.push(node, -3);
|
|
2982
|
+
return;
|
|
2983
|
+
}
|
|
2984
|
+
if (shared.isSymbol(node)) {
|
|
2985
|
+
context.push(context.helper(node));
|
|
2986
|
+
return;
|
|
2987
|
+
}
|
|
2988
|
+
switch (node.type) {
|
|
2989
|
+
case 1:
|
|
2990
|
+
case 9:
|
|
2991
|
+
case 11:
|
|
2992
|
+
genNode(node.codegenNode, context);
|
|
2993
|
+
break;
|
|
2994
|
+
case 2:
|
|
2995
|
+
genText(node, context);
|
|
2996
|
+
break;
|
|
2997
|
+
case 4:
|
|
2998
|
+
genExpression(node, context);
|
|
2999
|
+
break;
|
|
3000
|
+
case 5:
|
|
3001
|
+
genInterpolation(node, context);
|
|
3002
|
+
break;
|
|
3003
|
+
case 12:
|
|
3004
|
+
genNode(node.codegenNode, context);
|
|
3005
|
+
break;
|
|
3006
|
+
case 8:
|
|
3007
|
+
genCompoundExpression(node, context);
|
|
3008
|
+
break;
|
|
3009
|
+
case 3:
|
|
3010
|
+
genComment(node, context);
|
|
3011
|
+
break;
|
|
3012
|
+
case 13:
|
|
3013
|
+
genVNodeCall(node, context);
|
|
3014
|
+
break;
|
|
3015
|
+
case 14:
|
|
3016
|
+
genCallExpression(node, context);
|
|
3017
|
+
break;
|
|
3018
|
+
case 15:
|
|
3019
|
+
genObjectExpression(node, context);
|
|
3020
|
+
break;
|
|
3021
|
+
case 17:
|
|
3022
|
+
genArrayExpression(node, context);
|
|
3023
|
+
break;
|
|
3024
|
+
case 18:
|
|
3025
|
+
genFunctionExpression(node, context);
|
|
3026
|
+
break;
|
|
3027
|
+
case 19:
|
|
3028
|
+
genConditionalExpression(node, context);
|
|
3029
|
+
break;
|
|
3030
|
+
case 20:
|
|
3031
|
+
genCacheExpression(node, context);
|
|
3032
|
+
break;
|
|
3033
|
+
case 21:
|
|
3034
|
+
genNodeList(node.body, context, true, false);
|
|
3035
|
+
break;
|
|
3036
|
+
case 22:
|
|
3037
|
+
genTemplateLiteral(node, context);
|
|
3038
|
+
break;
|
|
3039
|
+
case 23:
|
|
3040
|
+
genIfStatement(node, context);
|
|
3041
|
+
break;
|
|
3042
|
+
case 24:
|
|
3043
|
+
genAssignmentExpression(node, context);
|
|
3044
|
+
break;
|
|
3045
|
+
case 25:
|
|
3046
|
+
genSequenceExpression(node, context);
|
|
3047
|
+
break;
|
|
3048
|
+
case 26:
|
|
3049
|
+
genReturnStatement(node, context);
|
|
3050
|
+
break;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
function genText(node, context) {
|
|
3054
|
+
context.push(JSON.stringify(node.content), -3, node);
|
|
3055
|
+
}
|
|
3056
|
+
function genExpression(node, context) {
|
|
3057
|
+
const { content, isStatic } = node;
|
|
3058
|
+
context.push(isStatic ? JSON.stringify(content) : content, -3, node);
|
|
3059
|
+
}
|
|
3060
|
+
function genInterpolation(node, context) {
|
|
3061
|
+
const { push, helper, pure } = context;
|
|
3062
|
+
if (pure) push(PURE_ANNOTATION);
|
|
3063
|
+
push(`${helper(TO_DISPLAY_STRING)}(`);
|
|
3064
|
+
genNode(node.content, context);
|
|
3065
|
+
push(`)`);
|
|
3066
|
+
}
|
|
3067
|
+
function genCompoundExpression(node, context) {
|
|
3068
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
3069
|
+
const child = node.children[i];
|
|
3070
|
+
if (shared.isString(child)) context.push(child, -3);
|
|
3071
|
+
else genNode(child, context);
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
function genExpressionAsPropertyKey(node, context) {
|
|
3075
|
+
const { push } = context;
|
|
3076
|
+
if (node.type === 8) {
|
|
3077
|
+
push(`[`);
|
|
3078
|
+
genCompoundExpression(node, context);
|
|
3079
|
+
push(`]`);
|
|
3080
|
+
} else if (node.isStatic) push(isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content), -2, node);
|
|
3081
|
+
else push(`[${node.content}]`, -3, node);
|
|
3082
|
+
}
|
|
3083
|
+
function genComment(node, context) {
|
|
3084
|
+
const { push, helper, pure } = context;
|
|
3085
|
+
if (pure) push(PURE_ANNOTATION);
|
|
3086
|
+
push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, -3, node);
|
|
3087
|
+
}
|
|
3088
|
+
function genVNodeCall(node, context) {
|
|
3089
|
+
const { push, helper, pure } = context;
|
|
3090
|
+
const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent: isComponent$1 } = node;
|
|
3091
|
+
let patchFlagString;
|
|
3092
|
+
if (patchFlag) patchFlagString = String(patchFlag);
|
|
3093
|
+
if (directives) push(helper(WITH_DIRECTIVES) + `(`);
|
|
3094
|
+
if (isBlock) push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
|
|
3095
|
+
if (pure) push(PURE_ANNOTATION);
|
|
3096
|
+
push(helper(isBlock ? getVNodeBlockHelper(context.inSSR, isComponent$1) : getVNodeHelper(context.inSSR, isComponent$1)) + `(`, -2, node);
|
|
3097
|
+
genNodeList(genNullableArgs([
|
|
3098
|
+
tag,
|
|
3099
|
+
props,
|
|
3100
|
+
children,
|
|
3101
|
+
patchFlagString,
|
|
3102
|
+
dynamicProps
|
|
3103
|
+
]), context);
|
|
3104
|
+
push(`)`);
|
|
3105
|
+
if (isBlock) push(`)`);
|
|
3106
|
+
if (directives) {
|
|
3107
|
+
push(`, `);
|
|
3108
|
+
genNode(directives, context);
|
|
3109
|
+
push(`)`);
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
function genNullableArgs(args) {
|
|
3113
|
+
let i = args.length;
|
|
3114
|
+
while (i--) if (args[i] != null) break;
|
|
3115
|
+
return args.slice(0, i + 1).map((arg) => arg || `null`);
|
|
3116
|
+
}
|
|
3117
|
+
function genCallExpression(node, context) {
|
|
3118
|
+
const { push, helper, pure } = context;
|
|
3119
|
+
const callee = shared.isString(node.callee) ? node.callee : helper(node.callee);
|
|
3120
|
+
if (pure) push(PURE_ANNOTATION);
|
|
3121
|
+
push(callee + `(`, -2, node);
|
|
3122
|
+
genNodeList(node.arguments, context);
|
|
3123
|
+
push(`)`);
|
|
3124
|
+
}
|
|
3125
|
+
function genObjectExpression(node, context) {
|
|
3126
|
+
const { push, indent, deindent, newline } = context;
|
|
3127
|
+
const { properties } = node;
|
|
3128
|
+
if (!properties.length) {
|
|
3129
|
+
push(`{}`, -2, node);
|
|
3130
|
+
return;
|
|
3131
|
+
}
|
|
3132
|
+
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
3133
|
+
push(multilines ? `{` : `{ `);
|
|
3134
|
+
multilines && indent();
|
|
3135
|
+
for (let i = 0; i < properties.length; i++) {
|
|
3136
|
+
const { key, value } = properties[i];
|
|
3137
|
+
genExpressionAsPropertyKey(key, context);
|
|
3138
|
+
push(`: `);
|
|
3139
|
+
genNode(value, context);
|
|
3140
|
+
if (i < properties.length - 1) {
|
|
3141
|
+
push(`,`);
|
|
3142
|
+
newline();
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
multilines && deindent();
|
|
3146
|
+
push(multilines ? `}` : ` }`);
|
|
3147
|
+
}
|
|
3148
|
+
function genArrayExpression(node, context) {
|
|
3149
|
+
genNodeListAsArray(node.elements, context);
|
|
3150
|
+
}
|
|
3151
|
+
function genFunctionExpression(node, context) {
|
|
3152
|
+
const { push, indent, deindent } = context;
|
|
3153
|
+
const { params, returns, body, newline, isSlot } = node;
|
|
3154
|
+
if (isSlot) push(`_${helperNameMap[WITH_CTX]}(`);
|
|
3155
|
+
push(`(`, -2, node);
|
|
3156
|
+
if (shared.isArray(params)) genNodeList(params, context);
|
|
3157
|
+
else if (params) genNode(params, context);
|
|
3158
|
+
push(`) => `);
|
|
3159
|
+
if (newline || body) {
|
|
3160
|
+
push(`{`);
|
|
3161
|
+
indent();
|
|
3162
|
+
}
|
|
3163
|
+
if (returns) {
|
|
3164
|
+
if (newline) push(`return `);
|
|
3165
|
+
if (shared.isArray(returns)) genNodeListAsArray(returns, context);
|
|
3166
|
+
else genNode(returns, context);
|
|
3167
|
+
} else if (body) genNode(body, context);
|
|
3168
|
+
if (newline || body) {
|
|
3169
|
+
deindent();
|
|
3170
|
+
push(`}`);
|
|
3171
|
+
}
|
|
3172
|
+
if (isSlot) {
|
|
3173
|
+
if (node.isNonScopedSlot) push(`, undefined, true`);
|
|
3174
|
+
push(`)`);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
function genConditionalExpression(node, context) {
|
|
3178
|
+
const { test, consequent, alternate, newline: needNewline } = node;
|
|
3179
|
+
const { push, indent, deindent, newline } = context;
|
|
3180
|
+
if (test.type === 4) {
|
|
3181
|
+
const needsParens = !isSimpleIdentifier(test.content);
|
|
3182
|
+
needsParens && push(`(`);
|
|
3183
|
+
genExpression(test, context);
|
|
3184
|
+
needsParens && push(`)`);
|
|
3185
|
+
} else {
|
|
3186
|
+
push(`(`);
|
|
3187
|
+
genNode(test, context);
|
|
3188
|
+
push(`)`);
|
|
3189
|
+
}
|
|
3190
|
+
needNewline && indent();
|
|
3191
|
+
context.indentLevel++;
|
|
3192
|
+
needNewline || push(` `);
|
|
3193
|
+
push(`? `);
|
|
3194
|
+
genNode(consequent, context);
|
|
3195
|
+
context.indentLevel--;
|
|
3196
|
+
needNewline && newline();
|
|
3197
|
+
needNewline || push(` `);
|
|
3198
|
+
push(`: `);
|
|
3199
|
+
const isNested = alternate.type === 19;
|
|
3200
|
+
if (!isNested) context.indentLevel++;
|
|
3201
|
+
genNode(alternate, context);
|
|
3202
|
+
if (!isNested) context.indentLevel--;
|
|
3203
|
+
needNewline && deindent(true);
|
|
3204
|
+
}
|
|
3205
|
+
function genCacheExpression(node, context) {
|
|
3206
|
+
const { push, helper, indent, deindent, newline } = context;
|
|
3207
|
+
const { needPauseTracking, needArraySpread } = node;
|
|
3208
|
+
if (needArraySpread) push(`[...(`);
|
|
3209
|
+
push(`_cache[${node.index}] || (`);
|
|
3210
|
+
if (needPauseTracking) {
|
|
3211
|
+
indent();
|
|
3212
|
+
push(`${helper(SET_BLOCK_TRACKING)}(-1`);
|
|
3213
|
+
if (node.inVOnce) push(`, true`);
|
|
3214
|
+
push(`),`);
|
|
3215
|
+
newline();
|
|
3216
|
+
push(`(`);
|
|
3217
|
+
}
|
|
3218
|
+
push(`_cache[${node.index}] = `);
|
|
3219
|
+
genNode(node.value, context);
|
|
3220
|
+
if (needPauseTracking) {
|
|
3221
|
+
push(`).cacheIndex = ${node.index},`);
|
|
3222
|
+
newline();
|
|
3223
|
+
push(`${helper(SET_BLOCK_TRACKING)}(1),`);
|
|
3224
|
+
newline();
|
|
3225
|
+
push(`_cache[${node.index}]`);
|
|
3226
|
+
deindent();
|
|
3227
|
+
}
|
|
3228
|
+
push(`)`);
|
|
3229
|
+
if (needArraySpread) push(`)]`);
|
|
3230
|
+
}
|
|
3231
|
+
function genTemplateLiteral(node, context) {
|
|
3232
|
+
const { push, indent, deindent } = context;
|
|
3233
|
+
push("`");
|
|
3234
|
+
const l = node.elements.length;
|
|
3235
|
+
const multilines = l > 3;
|
|
3236
|
+
for (let i = 0; i < l; i++) {
|
|
3237
|
+
const e = node.elements[i];
|
|
3238
|
+
if (shared.isString(e)) push(e.replace(/(`|\$|\\)/g, "\\$1"), -3);
|
|
3239
|
+
else {
|
|
3240
|
+
push("${");
|
|
3241
|
+
if (multilines) indent();
|
|
3242
|
+
genNode(e, context);
|
|
3243
|
+
if (multilines) deindent();
|
|
3244
|
+
push("}");
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
push("`");
|
|
3248
|
+
}
|
|
3249
|
+
function genIfStatement(node, context) {
|
|
3250
|
+
const { push, indent, deindent } = context;
|
|
3251
|
+
const { test, consequent, alternate } = node;
|
|
3252
|
+
push(`if (`);
|
|
3253
|
+
genNode(test, context);
|
|
3254
|
+
push(`) {`);
|
|
3255
|
+
indent();
|
|
3256
|
+
genNode(consequent, context);
|
|
3257
|
+
deindent();
|
|
3258
|
+
push(`}`);
|
|
3259
|
+
if (alternate) {
|
|
3260
|
+
push(` else `);
|
|
3261
|
+
if (alternate.type === 23) genIfStatement(alternate, context);
|
|
3262
|
+
else {
|
|
3263
|
+
push(`{`);
|
|
3264
|
+
indent();
|
|
3265
|
+
genNode(alternate, context);
|
|
3266
|
+
deindent();
|
|
3267
|
+
push(`}`);
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
function genAssignmentExpression(node, context) {
|
|
3272
|
+
genNode(node.left, context);
|
|
3273
|
+
context.push(` = `);
|
|
3274
|
+
genNode(node.right, context);
|
|
3275
|
+
}
|
|
3276
|
+
function genSequenceExpression(node, context) {
|
|
3277
|
+
context.push(`(`);
|
|
3278
|
+
genNodeList(node.expressions, context);
|
|
3279
|
+
context.push(`)`);
|
|
3280
|
+
}
|
|
3281
|
+
function genReturnStatement({ returns }, context) {
|
|
3282
|
+
context.push(`return `);
|
|
3283
|
+
if (shared.isArray(returns)) genNodeListAsArray(returns, context);
|
|
3284
|
+
else genNode(returns, context);
|
|
3285
|
+
}
|
|
3286
|
+
const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
|
|
3287
|
+
const transformExpression = (node, context) => {
|
|
3288
|
+
if (node.type === 5) node.content = processExpression(node.content, context);
|
|
3289
|
+
else if (node.type === 1) {
|
|
3290
|
+
const memo = findDir(node, "memo");
|
|
3291
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
3292
|
+
const dir = node.props[i];
|
|
3293
|
+
if (dir.type === 7 && dir.name !== "for") {
|
|
3294
|
+
const exp = dir.exp;
|
|
3295
|
+
const arg = dir.arg;
|
|
3296
|
+
if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
|
|
3297
|
+
if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
};
|
|
3302
|
+
function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
3303
|
+
if (!context.prefixIdentifiers || !node.content.trim()) return node;
|
|
3304
|
+
const { inline, bindingMetadata } = context;
|
|
3305
|
+
const rewriteIdentifier = (raw, parent, id) => {
|
|
3306
|
+
const type = shared.hasOwn(bindingMetadata, raw) && bindingMetadata[raw];
|
|
3307
|
+
if (inline) {
|
|
3308
|
+
const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
|
|
3309
|
+
const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
|
|
3310
|
+
const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
|
|
3311
|
+
const isNewExpression = parent && isInNewExpression(parentStack);
|
|
3312
|
+
const wrapWithUnref = (raw2) => {
|
|
3313
|
+
const wrapped = `${context.helperString(UNREF)}(${raw2})`;
|
|
3314
|
+
return isNewExpression ? `(${wrapped})` : wrapped;
|
|
3315
|
+
};
|
|
3316
|
+
if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) return raw;
|
|
3317
|
+
else if (type === "setup-ref") return `${raw}.value`;
|
|
3318
|
+
else if (type === "setup-maybe-ref") return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
|
|
3319
|
+
else if (type === "setup-let") if (isAssignmentLVal) {
|
|
3320
|
+
const { right: rVal, operator } = parent;
|
|
3321
|
+
const rExpString = stringifyExpression(processExpression(createSimpleExpression(rawExp.slice(rVal.start - 1, rVal.end - 1), false), context, false, false, knownIds));
|
|
3322
|
+
return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
|
|
3323
|
+
` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
|
|
3324
|
+
} else if (isUpdateArg) {
|
|
3325
|
+
id.start = parent.start;
|
|
3326
|
+
id.end = parent.end;
|
|
3327
|
+
const { prefix: isPrefix, operator } = parent;
|
|
3328
|
+
const prefix = isPrefix ? operator : ``;
|
|
3329
|
+
const postfix = isPrefix ? `` : operator;
|
|
3330
|
+
return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore
|
|
3331
|
+
` : ``} ? ${prefix}${raw}.value${postfix} : ${prefix}${raw}${postfix}`;
|
|
3332
|
+
} else if (isDestructureAssignment) return raw;
|
|
3333
|
+
else return wrapWithUnref(raw);
|
|
3334
|
+
else if (type === "props") return shared.genPropsAccessExp(raw);
|
|
3335
|
+
else if (type === "props-aliased") return shared.genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
|
|
3336
|
+
} else if (type && type.startsWith("setup") || type === "literal-const") return `$setup.${raw}`;
|
|
3337
|
+
else if (type === "props-aliased") return `$props['${bindingMetadata.__propsAliases[raw]}']`;
|
|
3338
|
+
else if (type) return `$${type}.${raw}`;
|
|
3339
|
+
return `_ctx.${raw}`;
|
|
3340
|
+
};
|
|
3341
|
+
const rawExp = node.content;
|
|
3342
|
+
let ast = node.ast;
|
|
3343
|
+
if (ast === false) return node;
|
|
3344
|
+
if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
|
|
3345
|
+
const isScopeVarReference = context.identifiers[rawExp];
|
|
3346
|
+
const isAllowedGlobal = shared.isGloballyAllowed(rawExp);
|
|
3347
|
+
const isLiteral = isLiteralWhitelisted(rawExp);
|
|
3348
|
+
if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
|
|
3349
|
+
if (isConst(bindingMetadata[rawExp])) node.constType = 1;
|
|
3350
|
+
node.content = rewriteIdentifier(rawExp);
|
|
3351
|
+
} else if (!isScopeVarReference) if (isLiteral) node.constType = 3;
|
|
3352
|
+
else node.constType = 2;
|
|
3353
|
+
return node;
|
|
3354
|
+
}
|
|
3355
|
+
if (!ast) {
|
|
3356
|
+
const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
|
|
3357
|
+
try {
|
|
3358
|
+
ast = parser.parseExpression(source, {
|
|
3359
|
+
sourceType: "module",
|
|
3360
|
+
plugins: context.expressionPlugins
|
|
3361
|
+
});
|
|
3362
|
+
} catch (e) {
|
|
3363
|
+
context.onError(createCompilerError(45, node.loc, void 0, e.message));
|
|
3364
|
+
return node;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
const ids = [];
|
|
3368
|
+
const parentStack = [];
|
|
3369
|
+
const knownIds = Object.create(context.identifiers);
|
|
3370
|
+
walkIdentifiers(ast, (node2, parent, _, isReferenced$1, isLocal) => {
|
|
3371
|
+
if (isStaticPropertyKey(node2, parent)) return;
|
|
3372
|
+
if (node2.name.startsWith("_filter_")) return;
|
|
3373
|
+
const needPrefix = isReferenced$1 && canPrefix(node2);
|
|
3374
|
+
if (needPrefix && !isLocal) {
|
|
3375
|
+
if (isStaticProperty(parent) && parent.shorthand) node2.prefix = `${node2.name}: `;
|
|
3376
|
+
node2.name = rewriteIdentifier(node2.name, parent, node2);
|
|
3377
|
+
ids.push(node2);
|
|
3378
|
+
} else {
|
|
3379
|
+
if (!(needPrefix && isLocal) && (!parent || parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression")) node2.isConstant = true;
|
|
3380
|
+
ids.push(node2);
|
|
3381
|
+
}
|
|
3382
|
+
}, true, parentStack, knownIds);
|
|
3383
|
+
const children = [];
|
|
3384
|
+
ids.sort((a, b) => a.start - b.start);
|
|
3385
|
+
ids.forEach((id, i) => {
|
|
3386
|
+
const start = id.start - 1;
|
|
3387
|
+
const end = id.end - 1;
|
|
3388
|
+
const last = ids[i - 1];
|
|
3389
|
+
const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
|
|
3390
|
+
if (leadingText.length || id.prefix) children.push(leadingText + (id.prefix || ``));
|
|
3391
|
+
const source = rawExp.slice(start, end);
|
|
3392
|
+
children.push(createSimpleExpression(id.name, false, {
|
|
3393
|
+
start: advancePositionWithClone(node.loc.start, source, start),
|
|
3394
|
+
end: advancePositionWithClone(node.loc.start, source, end),
|
|
3395
|
+
source
|
|
3396
|
+
}, id.isConstant ? 3 : 0));
|
|
3397
|
+
if (i === ids.length - 1 && end < rawExp.length) children.push(rawExp.slice(end));
|
|
3398
|
+
});
|
|
3399
|
+
let ret;
|
|
3400
|
+
if (children.length) {
|
|
3401
|
+
ret = createCompoundExpression(children, node.loc);
|
|
3402
|
+
ret.ast = ast;
|
|
3403
|
+
} else {
|
|
3404
|
+
ret = node;
|
|
3405
|
+
ret.constType = 3;
|
|
3406
|
+
}
|
|
3407
|
+
ret.identifiers = Object.keys(knownIds);
|
|
3408
|
+
return ret;
|
|
3409
|
+
}
|
|
3410
|
+
function canPrefix(id) {
|
|
3411
|
+
if (shared.isGloballyAllowed(id.name)) return false;
|
|
3412
|
+
if (id.name === "require") return false;
|
|
3413
|
+
return true;
|
|
3414
|
+
}
|
|
3415
|
+
function stringifyExpression(exp) {
|
|
3416
|
+
if (shared.isString(exp)) return exp;
|
|
3417
|
+
else if (exp.type === 4) return exp.content;
|
|
3418
|
+
else return exp.children.map(stringifyExpression).join("");
|
|
3419
|
+
}
|
|
3420
|
+
function isConst(type) {
|
|
3421
|
+
return type === "setup-const" || type === "literal-const";
|
|
3422
|
+
}
|
|
3423
|
+
const transformIf = createStructuralDirectiveTransform(/^(?:if|else|else-if)$/, (node, dir, context) => {
|
|
3424
|
+
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
|
3425
|
+
const siblings = context.parent.children;
|
|
3426
|
+
let i = siblings.indexOf(ifNode);
|
|
3427
|
+
let key = 0;
|
|
3428
|
+
while (i-- >= 0) {
|
|
3429
|
+
const sibling = siblings[i];
|
|
3430
|
+
if (sibling && sibling.type === 9) key += sibling.branches.length;
|
|
3431
|
+
}
|
|
3432
|
+
return () => {
|
|
3433
|
+
if (isRoot) ifNode.codegenNode = createCodegenNodeForBranch(branch, key, context);
|
|
3434
|
+
else {
|
|
3435
|
+
const parentCondition = getParentCondition(ifNode.codegenNode);
|
|
3436
|
+
parentCondition.alternate = createCodegenNodeForBranch(branch, key + ifNode.branches.length - 1, context);
|
|
3437
|
+
}
|
|
3438
|
+
};
|
|
3439
|
+
});
|
|
3440
|
+
});
|
|
3441
|
+
function processIf(node, dir, context, processCodegen) {
|
|
3442
|
+
if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
|
3443
|
+
const loc = dir.exp ? dir.exp.loc : node.loc;
|
|
3444
|
+
context.onError(createCompilerError(28, dir.loc));
|
|
3445
|
+
dir.exp = createSimpleExpression(`true`, false, loc);
|
|
3446
|
+
}
|
|
3447
|
+
if (context.prefixIdentifiers && dir.exp) dir.exp = processExpression(dir.exp, context);
|
|
3448
|
+
if (dir.name === "if") {
|
|
3449
|
+
const branch = createIfBranch(node, dir);
|
|
3450
|
+
const ifNode = {
|
|
3451
|
+
type: 9,
|
|
3452
|
+
loc: cloneLoc(node.loc),
|
|
3453
|
+
branches: [branch]
|
|
3454
|
+
};
|
|
3455
|
+
context.replaceNode(ifNode);
|
|
3456
|
+
if (processCodegen) return processCodegen(ifNode, branch, true);
|
|
3457
|
+
} else {
|
|
3458
|
+
const siblings = context.parent.children;
|
|
3459
|
+
let i = siblings.indexOf(node);
|
|
3460
|
+
while (i-- >= -1) {
|
|
3461
|
+
const sibling = siblings[i];
|
|
3462
|
+
if (sibling && sibling.type === 3) {
|
|
3463
|
+
context.removeNode(sibling);
|
|
3464
|
+
continue;
|
|
3465
|
+
}
|
|
3466
|
+
if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
|
|
3467
|
+
context.removeNode(sibling);
|
|
3468
|
+
continue;
|
|
3469
|
+
}
|
|
3470
|
+
if (sibling && sibling.type === 9) {
|
|
3471
|
+
if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) context.onError(createCompilerError(30, node.loc));
|
|
3472
|
+
context.removeNode();
|
|
3473
|
+
const branch = createIfBranch(node, dir);
|
|
3474
|
+
{
|
|
3475
|
+
const key = branch.userKey;
|
|
3476
|
+
if (key) sibling.branches.forEach(({ userKey }) => {
|
|
3477
|
+
if (isSameKey(userKey, key)) context.onError(createCompilerError(29, branch.userKey.loc));
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
sibling.branches.push(branch);
|
|
3481
|
+
const onExit = processCodegen && processCodegen(sibling, branch, false);
|
|
3482
|
+
traverseNode(branch, context);
|
|
3483
|
+
if (onExit) onExit();
|
|
3484
|
+
context.currentNode = null;
|
|
3485
|
+
} else context.onError(createCompilerError(30, node.loc));
|
|
3486
|
+
break;
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
function createIfBranch(node, dir) {
|
|
3491
|
+
const isTemplateIf = node.tagType === 3;
|
|
3492
|
+
return {
|
|
3493
|
+
type: 10,
|
|
3494
|
+
loc: node.loc,
|
|
3495
|
+
condition: dir.name === "else" ? void 0 : dir.exp,
|
|
3496
|
+
children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
|
|
3497
|
+
userKey: findProp(node, `key`),
|
|
3498
|
+
isTemplateIf
|
|
3499
|
+
};
|
|
3500
|
+
}
|
|
3501
|
+
function createCodegenNodeForBranch(branch, keyIndex, context) {
|
|
3502
|
+
if (branch.condition) return createConditionalExpression(branch.condition, createChildrenCodegenNode(branch, keyIndex, context), createCallExpression(context.helper(CREATE_COMMENT), ["\"\"", "true"]));
|
|
3503
|
+
else return createChildrenCodegenNode(branch, keyIndex, context);
|
|
3504
|
+
}
|
|
3505
|
+
function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
3506
|
+
const { helper } = context;
|
|
3507
|
+
const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2));
|
|
3508
|
+
const { children } = branch;
|
|
3509
|
+
const firstChild = children[0];
|
|
3510
|
+
if (children.length !== 1 || firstChild.type !== 1) if (children.length === 1 && firstChild.type === 11) {
|
|
3511
|
+
const vnodeCall = firstChild.codegenNode;
|
|
3512
|
+
injectProp(vnodeCall, keyProperty, context);
|
|
3513
|
+
return vnodeCall;
|
|
3514
|
+
} else return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, 64, void 0, void 0, true, false, false, branch.loc);
|
|
3515
|
+
else {
|
|
3516
|
+
const ret = firstChild.codegenNode;
|
|
3517
|
+
const vnodeCall = getMemoedVNodeCall(ret);
|
|
3518
|
+
if (vnodeCall.type === 13) convertToBlock(vnodeCall, context);
|
|
3519
|
+
injectProp(vnodeCall, keyProperty, context);
|
|
3520
|
+
return ret;
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
function isSameKey(a, b) {
|
|
3524
|
+
if (!a || a.type !== b.type) return false;
|
|
3525
|
+
if (a.type === 6) {
|
|
3526
|
+
if (a.value.content !== b.value.content) return false;
|
|
3527
|
+
} else {
|
|
3528
|
+
const exp = a.exp;
|
|
3529
|
+
const branchExp = b.exp;
|
|
3530
|
+
if (exp.type !== branchExp.type) return false;
|
|
3531
|
+
if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) return false;
|
|
3532
|
+
}
|
|
3533
|
+
return true;
|
|
3534
|
+
}
|
|
3535
|
+
function getParentCondition(node) {
|
|
3536
|
+
while (true) if (node.type === 19) if (node.alternate.type === 19) node = node.alternate;
|
|
3537
|
+
else return node;
|
|
3538
|
+
else if (node.type === 20) node = node.value;
|
|
3539
|
+
}
|
|
3540
|
+
const transformFor = createStructuralDirectiveTransform("for", (node, dir, context) => {
|
|
3541
|
+
const { helper, removeHelper } = context;
|
|
3542
|
+
return processFor(node, dir, context, (forNode) => {
|
|
3543
|
+
const renderExp = createCallExpression(helper(RENDER_LIST), [forNode.source]);
|
|
3544
|
+
const isTemplate = isTemplateNode(node);
|
|
3545
|
+
const memo = findDir(node, "memo");
|
|
3546
|
+
const keyProp = findProp(node, `key`, false, true);
|
|
3547
|
+
const isDirKey = keyProp && keyProp.type === 7;
|
|
3548
|
+
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
3549
|
+
if (memo && keyExp && isDirKey) keyProp.exp = keyExp = processExpression(keyExp, context);
|
|
3550
|
+
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
3551
|
+
if (isTemplate) {
|
|
3552
|
+
if (memo) memo.exp = processExpression(memo.exp, context);
|
|
3553
|
+
if (keyProperty && keyProp.type !== 6) keyProperty.value = processExpression(keyProperty.value, context);
|
|
3554
|
+
}
|
|
3555
|
+
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
3556
|
+
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
3557
|
+
forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, renderExp, fragmentFlag, void 0, void 0, true, !isStableFragment, false, node.loc);
|
|
3558
|
+
return () => {
|
|
3559
|
+
let childBlock;
|
|
3560
|
+
const { children } = forNode;
|
|
3561
|
+
if (isTemplate) node.children.some((c) => {
|
|
3562
|
+
if (c.type === 1) {
|
|
3563
|
+
const key = findProp(c, "key");
|
|
3564
|
+
if (key) {
|
|
3565
|
+
context.onError(createCompilerError(33, key.loc));
|
|
3566
|
+
return true;
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
});
|
|
3570
|
+
const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
|
|
3571
|
+
const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
|
3572
|
+
if (slotOutlet) {
|
|
3573
|
+
childBlock = slotOutlet.codegenNode;
|
|
3574
|
+
if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
|
|
3575
|
+
} else if (needFragmentWrapper) childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : void 0, node.children, 64, void 0, void 0, true, void 0, false);
|
|
3576
|
+
else {
|
|
3577
|
+
childBlock = children[0].codegenNode;
|
|
3578
|
+
if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
|
|
3579
|
+
if (childBlock.isBlock !== !isStableFragment) if (childBlock.isBlock) {
|
|
3580
|
+
removeHelper(OPEN_BLOCK);
|
|
3581
|
+
removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
|
3582
|
+
} else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
|
3583
|
+
childBlock.isBlock = !isStableFragment;
|
|
3584
|
+
if (childBlock.isBlock) {
|
|
3585
|
+
helper(OPEN_BLOCK);
|
|
3586
|
+
helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
|
3587
|
+
} else helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
|
3588
|
+
}
|
|
3589
|
+
if (memo) {
|
|
3590
|
+
const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
|
|
3591
|
+
loop.body = createBlockStatement([
|
|
3592
|
+
createCompoundExpression([
|
|
3593
|
+
`const _memo = (`,
|
|
3594
|
+
memo.exp,
|
|
3595
|
+
`)`
|
|
3596
|
+
]),
|
|
3597
|
+
createCompoundExpression([
|
|
3598
|
+
`if (_cached`,
|
|
3599
|
+
...keyExp ? [` && _cached.key === `, keyExp] : [],
|
|
3600
|
+
` && ${context.helperString(IS_MEMO_SAME)}(_cached, _memo)) return _cached`
|
|
3601
|
+
]),
|
|
3602
|
+
createCompoundExpression([`const _item = `, childBlock]),
|
|
3603
|
+
createSimpleExpression(`_item.memo = _memo`),
|
|
3604
|
+
createSimpleExpression(`return _item`)
|
|
3605
|
+
]);
|
|
3606
|
+
renderExp.arguments.push(loop, createSimpleExpression(`_cache`), createSimpleExpression(String(context.cached.length)));
|
|
3607
|
+
context.cached.push(null);
|
|
3608
|
+
} else renderExp.arguments.push(createFunctionExpression(createForLoopParams(forNode.parseResult), childBlock, true));
|
|
3609
|
+
};
|
|
3610
|
+
});
|
|
3611
|
+
});
|
|
3612
|
+
function processFor(node, dir, context, processCodegen) {
|
|
3613
|
+
if (!dir.exp) {
|
|
3614
|
+
context.onError(createCompilerError(31, dir.loc));
|
|
3615
|
+
return;
|
|
3616
|
+
}
|
|
3617
|
+
const parseResult = dir.forParseResult;
|
|
3618
|
+
if (!parseResult) {
|
|
3619
|
+
context.onError(createCompilerError(32, dir.loc));
|
|
3620
|
+
return;
|
|
3621
|
+
}
|
|
3622
|
+
finalizeForParseResult(parseResult, context);
|
|
3623
|
+
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3624
|
+
const { source, value, key, index } = parseResult;
|
|
3625
|
+
const forNode = {
|
|
3626
|
+
type: 11,
|
|
3627
|
+
loc: dir.loc,
|
|
3628
|
+
source,
|
|
3629
|
+
valueAlias: value,
|
|
3630
|
+
keyAlias: key,
|
|
3631
|
+
objectIndexAlias: index,
|
|
3632
|
+
parseResult,
|
|
3633
|
+
children: isTemplateNode(node) ? node.children : [node]
|
|
3634
|
+
};
|
|
3635
|
+
context.replaceNode(forNode);
|
|
3636
|
+
scopes.vFor++;
|
|
3637
|
+
if (context.prefixIdentifiers) {
|
|
3638
|
+
value && addIdentifiers(value);
|
|
3639
|
+
key && addIdentifiers(key);
|
|
3640
|
+
index && addIdentifiers(index);
|
|
3641
|
+
}
|
|
3642
|
+
const onExit = processCodegen && processCodegen(forNode);
|
|
3643
|
+
return () => {
|
|
3644
|
+
scopes.vFor--;
|
|
3645
|
+
if (context.prefixIdentifiers) {
|
|
3646
|
+
value && removeIdentifiers(value);
|
|
3647
|
+
key && removeIdentifiers(key);
|
|
3648
|
+
index && removeIdentifiers(index);
|
|
3649
|
+
}
|
|
3650
|
+
if (onExit) onExit();
|
|
3651
|
+
};
|
|
3652
|
+
}
|
|
3653
|
+
function finalizeForParseResult(result, context) {
|
|
3654
|
+
if (result.finalized) return;
|
|
3655
|
+
if (context.prefixIdentifiers) {
|
|
3656
|
+
result.source = processExpression(result.source, context);
|
|
3657
|
+
if (result.key) result.key = processExpression(result.key, context, true);
|
|
3658
|
+
if (result.index) result.index = processExpression(result.index, context, true);
|
|
3659
|
+
if (result.value) result.value = processExpression(result.value, context, true);
|
|
3660
|
+
}
|
|
3661
|
+
result.finalized = true;
|
|
3662
|
+
}
|
|
3663
|
+
function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
3664
|
+
return createParamsList([
|
|
3665
|
+
value,
|
|
3666
|
+
key,
|
|
3667
|
+
index,
|
|
3668
|
+
...memoArgs
|
|
3669
|
+
]);
|
|
3670
|
+
}
|
|
3671
|
+
function createParamsList(args) {
|
|
3672
|
+
let i = args.length;
|
|
3673
|
+
while (i--) if (args[i]) break;
|
|
3674
|
+
return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
|
|
3675
|
+
}
|
|
3676
|
+
const defaultFallback = createSimpleExpression(`undefined`, false);
|
|
3677
|
+
const trackSlotScopes = (node, context) => {
|
|
3678
|
+
if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
|
|
3679
|
+
const vSlot = findDir(node, "slot");
|
|
3680
|
+
if (vSlot) {
|
|
3681
|
+
const slotProps = vSlot.exp;
|
|
3682
|
+
if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps);
|
|
3683
|
+
context.scopes.vSlot++;
|
|
3684
|
+
return () => {
|
|
3685
|
+
if (context.prefixIdentifiers) slotProps && context.removeIdentifiers(slotProps);
|
|
3686
|
+
context.scopes.vSlot--;
|
|
3687
|
+
};
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
};
|
|
3691
|
+
const trackVForSlotScopes = (node, context) => {
|
|
3692
|
+
let vFor;
|
|
3693
|
+
if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
|
|
3694
|
+
const result = vFor.forParseResult;
|
|
3695
|
+
if (result) {
|
|
3696
|
+
finalizeForParseResult(result, context);
|
|
3697
|
+
const { value, key, index } = result;
|
|
3698
|
+
const { addIdentifiers, removeIdentifiers } = context;
|
|
3699
|
+
value && addIdentifiers(value);
|
|
3700
|
+
key && addIdentifiers(key);
|
|
3701
|
+
index && addIdentifiers(index);
|
|
3702
|
+
return () => {
|
|
3703
|
+
value && removeIdentifiers(value);
|
|
3704
|
+
key && removeIdentifiers(key);
|
|
3705
|
+
index && removeIdentifiers(index);
|
|
3706
|
+
};
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
};
|
|
3710
|
+
const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(props, children, false, true, children.length ? children[0].loc : loc);
|
|
3711
|
+
function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
3712
|
+
context.helper(WITH_CTX);
|
|
3713
|
+
const { children, loc } = node;
|
|
3714
|
+
const slotsProperties = [];
|
|
3715
|
+
const dynamicSlots = [];
|
|
3716
|
+
let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
|
3717
|
+
if (!context.ssr && context.prefixIdentifiers) hasDynamicSlots = node.props.some((prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))) || children.some((child) => hasScopeRef(child, context.identifiers));
|
|
3718
|
+
const onComponentSlot = findDir(node, "slot", true);
|
|
3719
|
+
if (onComponentSlot) {
|
|
3720
|
+
const { arg, exp } = onComponentSlot;
|
|
3721
|
+
if (arg && !isStaticExp(arg)) hasDynamicSlots = true;
|
|
3722
|
+
slotsProperties.push(createObjectProperty(arg || createSimpleExpression("default", true), buildSlotFn(exp, void 0, children, loc)));
|
|
3723
|
+
}
|
|
3724
|
+
let hasTemplateSlots = false;
|
|
3725
|
+
let hasNamedDefaultSlot = false;
|
|
3726
|
+
const implicitDefaultChildren = [];
|
|
3727
|
+
const seenSlotNames = /* @__PURE__ */ new Set();
|
|
3728
|
+
let conditionalBranchIndex = 0;
|
|
3729
|
+
for (let i = 0; i < children.length; i++) {
|
|
3730
|
+
const slotElement = children[i];
|
|
3731
|
+
let slotDir;
|
|
3732
|
+
if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
|
3733
|
+
if (slotElement.type !== 3) implicitDefaultChildren.push(slotElement);
|
|
3734
|
+
continue;
|
|
3735
|
+
}
|
|
3736
|
+
if (onComponentSlot) {
|
|
3737
|
+
context.onError(createCompilerError(37, slotDir.loc));
|
|
3738
|
+
break;
|
|
3739
|
+
}
|
|
3740
|
+
hasTemplateSlots = true;
|
|
3741
|
+
const { children: slotChildren, loc: slotLoc } = slotElement;
|
|
3742
|
+
const { arg: slotName = createSimpleExpression(`default`, true), exp: slotProps, loc: dirLoc } = slotDir;
|
|
3743
|
+
let staticSlotName;
|
|
3744
|
+
if (isStaticExp(slotName)) staticSlotName = slotName ? slotName.content : `default`;
|
|
3745
|
+
else hasDynamicSlots = true;
|
|
3746
|
+
const vFor = findDir(slotElement, "for");
|
|
3747
|
+
const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
|
3748
|
+
let vIf;
|
|
3749
|
+
let vElse;
|
|
3750
|
+
if (vIf = findDir(slotElement, "if")) {
|
|
3751
|
+
hasDynamicSlots = true;
|
|
3752
|
+
dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback));
|
|
3753
|
+
} else if (vElse = findDir(slotElement, /^else(?:-if)?$/, true)) {
|
|
3754
|
+
let j = i;
|
|
3755
|
+
let prev;
|
|
3756
|
+
while (j--) {
|
|
3757
|
+
prev = children[j];
|
|
3758
|
+
if (prev.type !== 3 && isNonWhitespaceContent(prev)) break;
|
|
3759
|
+
}
|
|
3760
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
|
|
3761
|
+
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
3762
|
+
while (conditional.alternate.type === 19) conditional = conditional.alternate;
|
|
3763
|
+
conditional.alternate = vElse.exp ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
|
3764
|
+
} else context.onError(createCompilerError(30, vElse.loc));
|
|
3765
|
+
} else if (vFor) {
|
|
3766
|
+
hasDynamicSlots = true;
|
|
3767
|
+
const parseResult = vFor.forParseResult;
|
|
3768
|
+
if (parseResult) {
|
|
3769
|
+
finalizeForParseResult(parseResult, context);
|
|
3770
|
+
dynamicSlots.push(createCallExpression(context.helper(RENDER_LIST), [parseResult.source, createFunctionExpression(createForLoopParams(parseResult), buildDynamicSlot(slotName, slotFunction), true)]));
|
|
3771
|
+
} else context.onError(createCompilerError(32, vFor.loc));
|
|
3772
|
+
} else {
|
|
3773
|
+
if (staticSlotName) {
|
|
3774
|
+
if (seenSlotNames.has(staticSlotName)) {
|
|
3775
|
+
context.onError(createCompilerError(38, dirLoc));
|
|
3776
|
+
continue;
|
|
3777
|
+
}
|
|
3778
|
+
seenSlotNames.add(staticSlotName);
|
|
3779
|
+
if (staticSlotName === "default") hasNamedDefaultSlot = true;
|
|
3780
|
+
}
|
|
3781
|
+
slotsProperties.push(createObjectProperty(slotName, slotFunction));
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
if (!onComponentSlot) {
|
|
3785
|
+
const buildDefaultSlotProperty = (props, children2) => {
|
|
3786
|
+
const fn = buildSlotFn(props, void 0, children2, loc);
|
|
3787
|
+
if (context.compatConfig) fn.isNonScopedSlot = true;
|
|
3788
|
+
return createObjectProperty(`default`, fn);
|
|
3789
|
+
};
|
|
3790
|
+
if (!hasTemplateSlots) slotsProperties.push(buildDefaultSlotProperty(void 0, children));
|
|
3791
|
+
else if (implicitDefaultChildren.length && implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) if (hasNamedDefaultSlot) context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
|
|
3792
|
+
else slotsProperties.push(buildDefaultSlotProperty(void 0, implicitDefaultChildren));
|
|
3793
|
+
}
|
|
3794
|
+
const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
|
|
3795
|
+
let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`, createSimpleExpression(slotFlag + ``, false))), loc);
|
|
3796
|
+
if (dynamicSlots.length) slots = createCallExpression(context.helper(CREATE_SLOTS), [slots, createArrayExpression(dynamicSlots)]);
|
|
3797
|
+
return {
|
|
3798
|
+
slots,
|
|
3799
|
+
hasDynamicSlots
|
|
3800
|
+
};
|
|
3801
|
+
}
|
|
3802
|
+
function buildDynamicSlot(name, fn, index) {
|
|
3803
|
+
const props = [createObjectProperty(`name`, name), createObjectProperty(`fn`, fn)];
|
|
3804
|
+
if (index != null) props.push(createObjectProperty(`key`, createSimpleExpression(String(index), true)));
|
|
3805
|
+
return createObjectExpression(props);
|
|
3806
|
+
}
|
|
3807
|
+
function hasForwardedSlots(children) {
|
|
3808
|
+
for (let i = 0; i < children.length; i++) {
|
|
3809
|
+
const child = children[i];
|
|
3810
|
+
switch (child.type) {
|
|
3811
|
+
case 1:
|
|
3812
|
+
if (child.tagType === 2 || hasForwardedSlots(child.children)) return true;
|
|
3813
|
+
break;
|
|
3814
|
+
case 9:
|
|
3815
|
+
if (hasForwardedSlots(child.branches)) return true;
|
|
3816
|
+
break;
|
|
3817
|
+
case 10:
|
|
3818
|
+
case 11:
|
|
3819
|
+
if (hasForwardedSlots(child.children)) return true;
|
|
3820
|
+
break;
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
return false;
|
|
3824
|
+
}
|
|
3825
|
+
function isNonWhitespaceContent(node) {
|
|
3826
|
+
if (node.type !== 2 && node.type !== 12) return true;
|
|
3827
|
+
return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
|
3828
|
+
}
|
|
3829
|
+
const directiveImportMap = /* @__PURE__ */ new WeakMap();
|
|
3830
|
+
const transformElement = (node, context) => {
|
|
3831
|
+
return function postTransformElement() {
|
|
3832
|
+
node = context.currentNode;
|
|
3833
|
+
if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) return;
|
|
3834
|
+
const { tag, props } = node;
|
|
3835
|
+
const isComponent$1 = node.tagType === 1;
|
|
3836
|
+
let vnodeTag = isComponent$1 ? resolveComponentType(node, context) : `"${tag}"`;
|
|
3837
|
+
const isDynamicComponent = shared.isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
|
3838
|
+
let vnodeProps;
|
|
3839
|
+
let vnodeChildren;
|
|
3840
|
+
let patchFlag = 0;
|
|
3841
|
+
let vnodeDynamicProps;
|
|
3842
|
+
let dynamicPropNames;
|
|
3843
|
+
let vnodeDirectives;
|
|
3844
|
+
let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent$1 && (tag === "svg" || tag === "foreignObject" || tag === "math");
|
|
3845
|
+
if (props.length > 0) {
|
|
3846
|
+
const propsBuildResult = buildProps(node, context, void 0, isComponent$1, isDynamicComponent);
|
|
3847
|
+
vnodeProps = propsBuildResult.props;
|
|
3848
|
+
patchFlag = propsBuildResult.patchFlag;
|
|
3849
|
+
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
3850
|
+
const directives = propsBuildResult.directives;
|
|
3851
|
+
vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
|
|
3852
|
+
if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
|
|
3853
|
+
}
|
|
3854
|
+
if (node.children.length > 0) {
|
|
3855
|
+
if (vnodeTag === KEEP_ALIVE) {
|
|
3856
|
+
shouldUseBlock = true;
|
|
3857
|
+
patchFlag |= 1024;
|
|
3858
|
+
}
|
|
3859
|
+
if (isComponent$1 && vnodeTag !== TELEPORT && vnodeTag !== KEEP_ALIVE) {
|
|
3860
|
+
const { slots, hasDynamicSlots } = buildSlots(node, context);
|
|
3861
|
+
vnodeChildren = slots;
|
|
3862
|
+
if (hasDynamicSlots) patchFlag |= 1024;
|
|
3863
|
+
} else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
|
3864
|
+
const child = node.children[0];
|
|
3865
|
+
const type = child.type;
|
|
3866
|
+
const hasDynamicTextChild = type === 5 || type === 8;
|
|
3867
|
+
if (hasDynamicTextChild && getConstantType(child, context) === 0) patchFlag |= 1;
|
|
3868
|
+
if (hasDynamicTextChild || type === 2) vnodeChildren = child;
|
|
3869
|
+
else vnodeChildren = node.children;
|
|
3870
|
+
} else vnodeChildren = node.children;
|
|
3871
|
+
}
|
|
3872
|
+
if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
|
3873
|
+
node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent$1, node.loc);
|
|
3874
|
+
};
|
|
3875
|
+
};
|
|
3876
|
+
function resolveComponentType(node, context, ssr = false) {
|
|
3877
|
+
let { tag } = node;
|
|
3878
|
+
const isExplicitDynamic = isComponentTag(tag);
|
|
3879
|
+
const isProp = findProp(node, "is", false, true);
|
|
3880
|
+
if (isProp) {
|
|
3881
|
+
if (isExplicitDynamic || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context)) {
|
|
3882
|
+
let exp;
|
|
3883
|
+
if (isProp.type === 6) exp = isProp.value && createSimpleExpression(isProp.value.content, true);
|
|
3884
|
+
else {
|
|
3885
|
+
exp = isProp.exp;
|
|
3886
|
+
if (!exp) {
|
|
3887
|
+
exp = createSimpleExpression(`is`, false, isProp.arg.loc);
|
|
3888
|
+
exp = isProp.exp = processExpression(exp, context);
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
if (exp) return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [exp]);
|
|
3892
|
+
} else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) tag = isProp.value.content.slice(4);
|
|
3893
|
+
}
|
|
3894
|
+
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
3895
|
+
if (builtIn) {
|
|
3896
|
+
if (!ssr) context.helper(builtIn);
|
|
3897
|
+
return builtIn;
|
|
3898
|
+
}
|
|
3899
|
+
{
|
|
3900
|
+
const fromSetup = resolveSetupReference(tag, context);
|
|
3901
|
+
if (fromSetup) return fromSetup;
|
|
3902
|
+
const dotIndex = tag.indexOf(".");
|
|
3903
|
+
if (dotIndex > 0) {
|
|
3904
|
+
const ns = resolveSetupReference(tag.slice(0, dotIndex), context);
|
|
3905
|
+
if (ns) return ns + tag.slice(dotIndex);
|
|
3906
|
+
}
|
|
3907
|
+
}
|
|
3908
|
+
if (context.selfName && shared.capitalize(shared.camelize(tag)) === context.selfName) {
|
|
3909
|
+
context.helper(RESOLVE_COMPONENT);
|
|
3910
|
+
context.components.add(tag + `__self`);
|
|
3911
|
+
return toValidAssetId(tag, `component`);
|
|
3912
|
+
}
|
|
3913
|
+
context.helper(RESOLVE_COMPONENT);
|
|
3914
|
+
context.components.add(tag);
|
|
3915
|
+
return toValidAssetId(tag, `component`);
|
|
3916
|
+
}
|
|
3917
|
+
function resolveSetupReference(name, context) {
|
|
3918
|
+
const bindings = context.bindingMetadata;
|
|
3919
|
+
if (!bindings || bindings.__isScriptSetup === false) return;
|
|
3920
|
+
const camelName = shared.camelize(name);
|
|
3921
|
+
const PascalName = shared.capitalize(camelName);
|
|
3922
|
+
const checkType = (type) => {
|
|
3923
|
+
if (bindings[name] === type) return name;
|
|
3924
|
+
if (bindings[camelName] === type) return camelName;
|
|
3925
|
+
if (bindings[PascalName] === type) return PascalName;
|
|
3926
|
+
};
|
|
3927
|
+
const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
|
|
3928
|
+
if (fromConst) return context.inline ? fromConst : `$setup[${JSON.stringify(fromConst)}]`;
|
|
3929
|
+
const fromMaybeRef = checkType("setup-let") || checkType("setup-ref") || checkType("setup-maybe-ref");
|
|
3930
|
+
if (fromMaybeRef) return context.inline ? `${context.helperString(UNREF)}(${fromMaybeRef})` : `$setup[${JSON.stringify(fromMaybeRef)}]`;
|
|
3931
|
+
const fromProps = checkType("props");
|
|
3932
|
+
if (fromProps) return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
|
|
3933
|
+
}
|
|
3934
|
+
function buildProps(node, context, props = node.props, isComponent$1, isDynamicComponent, ssr = false) {
|
|
3935
|
+
const { tag, loc: elementLoc, children } = node;
|
|
3936
|
+
let properties = [];
|
|
3937
|
+
const mergeArgs = [];
|
|
3938
|
+
const runtimeDirectives = [];
|
|
3939
|
+
const hasChildren = children.length > 0;
|
|
3940
|
+
let shouldUseBlock = false;
|
|
3941
|
+
let patchFlag = 0;
|
|
3942
|
+
let hasRef = false;
|
|
3943
|
+
let hasClassBinding = false;
|
|
3944
|
+
let hasStyleBinding = false;
|
|
3945
|
+
let hasHydrationEventBinding = false;
|
|
3946
|
+
let hasDynamicKeys = false;
|
|
3947
|
+
let hasVnodeHook = false;
|
|
3948
|
+
const dynamicPropNames = [];
|
|
3949
|
+
const pushMergeArg = (arg) => {
|
|
3950
|
+
if (properties.length) {
|
|
3951
|
+
mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
|
|
3952
|
+
properties = [];
|
|
3953
|
+
}
|
|
3954
|
+
if (arg) mergeArgs.push(arg);
|
|
3955
|
+
};
|
|
3956
|
+
const pushRefVForMarker = () => {
|
|
3957
|
+
if (context.scopes.vFor > 0) properties.push(createObjectProperty(createSimpleExpression("ref_for", true), createSimpleExpression("true")));
|
|
3958
|
+
};
|
|
3959
|
+
const analyzePatchFlag = ({ key, value }) => {
|
|
3960
|
+
if (isStaticExp(key)) {
|
|
3961
|
+
const name = key.content;
|
|
3962
|
+
const isEventHandler = shared.isOn(name);
|
|
3963
|
+
if (isEventHandler && (!isComponent$1 || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !shared.isReservedProp(name)) hasHydrationEventBinding = true;
|
|
3964
|
+
if (isEventHandler && shared.isReservedProp(name)) hasVnodeHook = true;
|
|
3965
|
+
if (isEventHandler && value.type === 14) value = value.arguments[0];
|
|
3966
|
+
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
|
|
3967
|
+
if (name === "ref") hasRef = true;
|
|
3968
|
+
else if (name === "class") hasClassBinding = true;
|
|
3969
|
+
else if (name === "style") hasStyleBinding = true;
|
|
3970
|
+
else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
3971
|
+
if (isComponent$1 && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
|
|
3972
|
+
} else hasDynamicKeys = true;
|
|
3973
|
+
};
|
|
3974
|
+
for (let i = 0; i < props.length; i++) {
|
|
3975
|
+
const prop = props[i];
|
|
3976
|
+
if (prop.type === 6) {
|
|
3977
|
+
const { loc, name, nameLoc, value } = prop;
|
|
3978
|
+
let isStatic = true;
|
|
3979
|
+
if (name === "ref") {
|
|
3980
|
+
hasRef = true;
|
|
3981
|
+
pushRefVForMarker();
|
|
3982
|
+
if (value && context.inline) {
|
|
3983
|
+
const binding = context.bindingMetadata[value.content];
|
|
3984
|
+
if (binding === "setup-let" || binding === "setup-ref" || binding === "setup-maybe-ref") {
|
|
3985
|
+
isStatic = false;
|
|
3986
|
+
properties.push(createObjectProperty(createSimpleExpression("ref_key", true), createSimpleExpression(value.content, true, value.loc)));
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) continue;
|
|
3991
|
+
properties.push(createObjectProperty(createSimpleExpression(name, true, nameLoc), createSimpleExpression(value ? value.content : "", isStatic, value ? value.loc : loc)));
|
|
3992
|
+
} else {
|
|
3993
|
+
const { name, arg, exp, loc, modifiers } = prop;
|
|
3994
|
+
const isVBind = name === "bind";
|
|
3995
|
+
const isVOn = name === "on";
|
|
3996
|
+
if (name === "slot") {
|
|
3997
|
+
if (!isComponent$1) context.onError(createCompilerError(40, loc));
|
|
3998
|
+
continue;
|
|
3999
|
+
}
|
|
4000
|
+
if (name === "once" || name === "memo") continue;
|
|
4001
|
+
if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) continue;
|
|
4002
|
+
if (isVOn && ssr) continue;
|
|
4003
|
+
if (isVBind && isStaticArgOf(arg, "key") || isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")) shouldUseBlock = true;
|
|
4004
|
+
if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
|
|
4005
|
+
if (!arg && (isVBind || isVOn)) {
|
|
4006
|
+
hasDynamicKeys = true;
|
|
4007
|
+
if (exp) if (isVBind) {
|
|
4008
|
+
pushMergeArg();
|
|
4009
|
+
if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
|
|
4010
|
+
mergeArgs.unshift(exp);
|
|
4011
|
+
continue;
|
|
4012
|
+
}
|
|
4013
|
+
pushRefVForMarker();
|
|
4014
|
+
pushMergeArg();
|
|
4015
|
+
mergeArgs.push(exp);
|
|
4016
|
+
} else pushMergeArg({
|
|
4017
|
+
type: 14,
|
|
4018
|
+
loc,
|
|
4019
|
+
callee: context.helper(TO_HANDLERS),
|
|
4020
|
+
arguments: isComponent$1 ? [exp] : [exp, `true`]
|
|
4021
|
+
});
|
|
4022
|
+
else context.onError(createCompilerError(isVBind ? 34 : 35, loc));
|
|
4023
|
+
continue;
|
|
4024
|
+
}
|
|
4025
|
+
if (isVBind && modifiers.some((mod) => mod.content === "prop")) patchFlag |= 32;
|
|
4026
|
+
const directiveTransform = context.directiveTransforms[name];
|
|
4027
|
+
if (directiveTransform) {
|
|
4028
|
+
const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
|
4029
|
+
!ssr && props2.forEach(analyzePatchFlag);
|
|
4030
|
+
if (isVOn && arg && !isStaticExp(arg)) pushMergeArg(createObjectExpression(props2, elementLoc));
|
|
4031
|
+
else properties.push(...props2);
|
|
4032
|
+
if (needRuntime) {
|
|
4033
|
+
runtimeDirectives.push(prop);
|
|
4034
|
+
if (shared.isSymbol(needRuntime)) directiveImportMap.set(prop, needRuntime);
|
|
4035
|
+
}
|
|
4036
|
+
} else if (!shared.isBuiltInDirective(name)) {
|
|
4037
|
+
runtimeDirectives.push(prop);
|
|
4038
|
+
if (hasChildren) shouldUseBlock = true;
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4042
|
+
let propsExpression = void 0;
|
|
4043
|
+
if (mergeArgs.length) {
|
|
4044
|
+
pushMergeArg();
|
|
4045
|
+
if (mergeArgs.length > 1) propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
|
|
4046
|
+
else propsExpression = mergeArgs[0];
|
|
4047
|
+
} else if (properties.length) propsExpression = createObjectExpression(dedupeProperties(properties), elementLoc);
|
|
4048
|
+
if (hasDynamicKeys) patchFlag |= 16;
|
|
4049
|
+
else {
|
|
4050
|
+
if (hasClassBinding && !isComponent$1) patchFlag |= 2;
|
|
4051
|
+
if (hasStyleBinding && !isComponent$1) patchFlag |= 4;
|
|
4052
|
+
if (dynamicPropNames.length) patchFlag |= 8;
|
|
4053
|
+
if (hasHydrationEventBinding) patchFlag |= 32;
|
|
4054
|
+
}
|
|
4055
|
+
if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) patchFlag |= 512;
|
|
4056
|
+
if (!context.inSSR && propsExpression) switch (propsExpression.type) {
|
|
4057
|
+
case 15:
|
|
4058
|
+
let classKeyIndex = -1;
|
|
4059
|
+
let styleKeyIndex = -1;
|
|
4060
|
+
let hasDynamicKey = false;
|
|
4061
|
+
for (let i = 0; i < propsExpression.properties.length; i++) {
|
|
4062
|
+
const key = propsExpression.properties[i].key;
|
|
4063
|
+
if (isStaticExp(key)) {
|
|
4064
|
+
if (key.content === "class") classKeyIndex = i;
|
|
4065
|
+
else if (key.content === "style") styleKeyIndex = i;
|
|
4066
|
+
} else if (!key.isHandlerKey) hasDynamicKey = true;
|
|
4067
|
+
}
|
|
4068
|
+
const classProp = propsExpression.properties[classKeyIndex];
|
|
4069
|
+
const styleProp = propsExpression.properties[styleKeyIndex];
|
|
4070
|
+
if (!hasDynamicKey) {
|
|
4071
|
+
if (classProp && !isStaticExp(classProp.value)) classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
|
4072
|
+
if (styleProp && (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || styleProp.value.type === 17)) styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
|
|
4073
|
+
} else propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
|
|
4074
|
+
break;
|
|
4075
|
+
case 14: break;
|
|
4076
|
+
default:
|
|
4077
|
+
propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
|
|
4078
|
+
break;
|
|
4079
|
+
}
|
|
4080
|
+
return {
|
|
4081
|
+
props: propsExpression,
|
|
4082
|
+
directives: runtimeDirectives,
|
|
4083
|
+
patchFlag,
|
|
4084
|
+
dynamicPropNames,
|
|
4085
|
+
shouldUseBlock
|
|
4086
|
+
};
|
|
4087
|
+
}
|
|
4088
|
+
function dedupeProperties(properties) {
|
|
4089
|
+
const knownProps = /* @__PURE__ */ new Map();
|
|
4090
|
+
const deduped = [];
|
|
4091
|
+
for (let i = 0; i < properties.length; i++) {
|
|
4092
|
+
const prop = properties[i];
|
|
4093
|
+
if (prop.key.type === 8 || !prop.key.isStatic) {
|
|
4094
|
+
deduped.push(prop);
|
|
4095
|
+
continue;
|
|
4096
|
+
}
|
|
4097
|
+
const name = prop.key.content;
|
|
4098
|
+
const existing = knownProps.get(name);
|
|
4099
|
+
if (existing) {
|
|
4100
|
+
if (name === "style" || name === "class" || shared.isOn(name)) mergeAsArray(existing, prop);
|
|
4101
|
+
} else {
|
|
4102
|
+
knownProps.set(name, prop);
|
|
4103
|
+
deduped.push(prop);
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
return deduped;
|
|
4107
|
+
}
|
|
4108
|
+
function mergeAsArray(existing, incoming) {
|
|
4109
|
+
if (existing.value.type === 17) existing.value.elements.push(incoming.value);
|
|
4110
|
+
else existing.value = createArrayExpression([existing.value, incoming.value], existing.loc);
|
|
4111
|
+
}
|
|
4112
|
+
function buildDirectiveArgs(dir, context) {
|
|
4113
|
+
const dirArgs = [];
|
|
4114
|
+
const runtime = directiveImportMap.get(dir);
|
|
4115
|
+
if (runtime) dirArgs.push(context.helperString(runtime));
|
|
4116
|
+
else {
|
|
4117
|
+
const fromSetup = resolveSetupReference("v-" + dir.name, context);
|
|
4118
|
+
if (fromSetup) dirArgs.push(fromSetup);
|
|
4119
|
+
else {
|
|
4120
|
+
context.helper(RESOLVE_DIRECTIVE);
|
|
4121
|
+
context.directives.add(dir.name);
|
|
4122
|
+
dirArgs.push(toValidAssetId(dir.name, `directive`));
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
const { loc } = dir;
|
|
4126
|
+
if (dir.exp) dirArgs.push(dir.exp);
|
|
4127
|
+
if (dir.arg) {
|
|
4128
|
+
if (!dir.exp) dirArgs.push(`void 0`);
|
|
4129
|
+
dirArgs.push(dir.arg);
|
|
4130
|
+
}
|
|
4131
|
+
if (Object.keys(dir.modifiers).length) {
|
|
4132
|
+
if (!dir.arg) {
|
|
4133
|
+
if (!dir.exp) dirArgs.push(`void 0`);
|
|
4134
|
+
dirArgs.push(`void 0`);
|
|
4135
|
+
}
|
|
4136
|
+
const trueExpression = createSimpleExpression(`true`, false, loc);
|
|
4137
|
+
dirArgs.push(createObjectExpression(dir.modifiers.map((modifier) => createObjectProperty(modifier, trueExpression)), loc));
|
|
4138
|
+
}
|
|
4139
|
+
return createArrayExpression(dirArgs, dir.loc);
|
|
4140
|
+
}
|
|
4141
|
+
function stringifyDynamicPropNames(props) {
|
|
4142
|
+
let propsNamesString = `[`;
|
|
4143
|
+
for (let i = 0, l = props.length; i < l; i++) {
|
|
4144
|
+
propsNamesString += JSON.stringify(props[i]);
|
|
4145
|
+
if (i < l - 1) propsNamesString += ", ";
|
|
4146
|
+
}
|
|
4147
|
+
return propsNamesString + `]`;
|
|
4148
|
+
}
|
|
4149
|
+
function isComponentTag(tag) {
|
|
4150
|
+
return tag === "component" || tag === "Component";
|
|
4151
|
+
}
|
|
4152
|
+
const transformSlotOutlet = (node, context) => {
|
|
4153
|
+
if (isSlotOutlet(node)) {
|
|
4154
|
+
const { children, loc } = node;
|
|
4155
|
+
const { slotName, slotProps } = processSlotOutlet(node, context);
|
|
4156
|
+
const slotArgs = [
|
|
4157
|
+
context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
|
|
4158
|
+
slotName,
|
|
4159
|
+
"{}",
|
|
4160
|
+
"undefined",
|
|
4161
|
+
"true"
|
|
4162
|
+
];
|
|
4163
|
+
let expectedLen = 2;
|
|
4164
|
+
if (slotProps) {
|
|
4165
|
+
slotArgs[2] = slotProps;
|
|
4166
|
+
expectedLen = 3;
|
|
4167
|
+
}
|
|
4168
|
+
if (children.length) {
|
|
4169
|
+
slotArgs[3] = createFunctionExpression([], children, false, false, loc);
|
|
4170
|
+
expectedLen = 4;
|
|
4171
|
+
}
|
|
4172
|
+
if (context.scopeId && !context.slotted) expectedLen = 5;
|
|
4173
|
+
slotArgs.splice(expectedLen);
|
|
4174
|
+
node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
|
|
4175
|
+
}
|
|
4176
|
+
};
|
|
4177
|
+
function processSlotOutlet(node, context) {
|
|
4178
|
+
let slotName = `"default"`;
|
|
4179
|
+
let slotProps = void 0;
|
|
4180
|
+
const nonNameProps = [];
|
|
4181
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
4182
|
+
const p = node.props[i];
|
|
4183
|
+
if (p.type === 6) {
|
|
4184
|
+
if (p.value) if (p.name === "name") slotName = JSON.stringify(p.value.content);
|
|
4185
|
+
else {
|
|
4186
|
+
p.name = shared.camelize(p.name);
|
|
4187
|
+
nonNameProps.push(p);
|
|
4188
|
+
}
|
|
4189
|
+
} else if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
|
|
4190
|
+
if (p.exp) slotName = p.exp;
|
|
4191
|
+
else if (p.arg && p.arg.type === 4) {
|
|
4192
|
+
slotName = p.exp = createSimpleExpression(shared.camelize(p.arg.content), false, p.arg.loc);
|
|
4193
|
+
slotName = p.exp = processExpression(p.exp, context);
|
|
4194
|
+
}
|
|
4195
|
+
} else {
|
|
4196
|
+
if (p.name === "bind" && p.arg && isStaticExp(p.arg)) p.arg.content = shared.camelize(p.arg.content);
|
|
4197
|
+
nonNameProps.push(p);
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
if (nonNameProps.length > 0) {
|
|
4201
|
+
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
4202
|
+
slotProps = props;
|
|
4203
|
+
if (directives.length) context.onError(createCompilerError(36, directives[0].loc));
|
|
4204
|
+
}
|
|
4205
|
+
return {
|
|
4206
|
+
slotName,
|
|
4207
|
+
slotProps
|
|
4208
|
+
};
|
|
4209
|
+
}
|
|
4210
|
+
const transformOn = (dir, node, context, augmentor) => {
|
|
4211
|
+
const { loc, modifiers, arg } = dir;
|
|
4212
|
+
if (!dir.exp && !modifiers.length) context.onError(createCompilerError(35, loc));
|
|
4213
|
+
let eventName;
|
|
4214
|
+
if (arg.type === 4) if (arg.isStatic) {
|
|
4215
|
+
let rawName = arg.content;
|
|
4216
|
+
if (rawName.startsWith("vue:")) rawName = `vnode-${rawName.slice(4)}`;
|
|
4217
|
+
eventName = createSimpleExpression(node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? shared.toHandlerKey(shared.camelize(rawName)) : `on:${rawName}`, true, arg.loc);
|
|
4218
|
+
} else eventName = createCompoundExpression([
|
|
4219
|
+
`${context.helperString(TO_HANDLER_KEY)}(`,
|
|
4220
|
+
arg,
|
|
4221
|
+
`)`
|
|
4222
|
+
]);
|
|
4223
|
+
else {
|
|
4224
|
+
eventName = arg;
|
|
4225
|
+
eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
|
|
4226
|
+
eventName.children.push(`)`);
|
|
4227
|
+
}
|
|
4228
|
+
let exp = dir.exp;
|
|
4229
|
+
if (exp && !exp.content.trim()) exp = void 0;
|
|
4230
|
+
let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
|
|
4231
|
+
if (exp) {
|
|
4232
|
+
const isMemberExp = isMemberExpression(exp, context);
|
|
4233
|
+
const isInlineStatement = !(isMemberExp || isFnExpression(exp, context));
|
|
4234
|
+
const hasMultipleStatements = exp.content.includes(`;`);
|
|
4235
|
+
if (context.prefixIdentifiers) {
|
|
4236
|
+
isInlineStatement && context.addIdentifiers(`$event`);
|
|
4237
|
+
exp = dir.exp = processExpression(exp, context, false, hasMultipleStatements);
|
|
4238
|
+
isInlineStatement && context.removeIdentifiers(`$event`);
|
|
4239
|
+
shouldCache = context.cacheHandlers && !context.inVOnce && !(exp.type === 4 && exp.constType > 0) && !(isMemberExp && node.tagType === 1) && !hasScopeRef(exp, context.identifiers);
|
|
4240
|
+
if (shouldCache && isMemberExp) if (exp.type === 4) exp.content = `${exp.content} && ${exp.content}(...args)`;
|
|
4241
|
+
else exp.children = [
|
|
4242
|
+
...exp.children,
|
|
4243
|
+
` && `,
|
|
4244
|
+
...exp.children,
|
|
4245
|
+
`(...args)`
|
|
4246
|
+
];
|
|
4247
|
+
}
|
|
4248
|
+
if (isInlineStatement || shouldCache && isMemberExp) exp = createCompoundExpression([
|
|
4249
|
+
`${isInlineStatement ? context.isTS ? `($event: any)` : `$event` : `${context.isTS ? `
|
|
4250
|
+
//@ts-ignore
|
|
4251
|
+
` : ``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
|
|
4252
|
+
exp,
|
|
4253
|
+
hasMultipleStatements ? `}` : `)`
|
|
4254
|
+
]);
|
|
4255
|
+
}
|
|
4256
|
+
let ret = { props: [createObjectProperty(eventName, exp || createSimpleExpression(`() => {}`, false, loc))] };
|
|
4257
|
+
if (augmentor) ret = augmentor(ret);
|
|
4258
|
+
if (shouldCache) ret.props[0].value = context.cache(ret.props[0].value);
|
|
4259
|
+
ret.props.forEach((p) => p.key.isHandlerKey = true);
|
|
4260
|
+
return ret;
|
|
4261
|
+
};
|
|
4262
|
+
const transformBind = (dir, _node, context) => {
|
|
4263
|
+
const { modifiers, loc } = dir;
|
|
4264
|
+
const arg = dir.arg;
|
|
4265
|
+
let { exp } = dir;
|
|
4266
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4267
|
+
context.onError(createCompilerError(34, loc));
|
|
4268
|
+
return { props: [createObjectProperty(arg, createSimpleExpression("", true, loc))] };
|
|
4269
|
+
}
|
|
4270
|
+
if (arg.type !== 4) {
|
|
4271
|
+
arg.children.unshift(`(`);
|
|
4272
|
+
arg.children.push(`) || ""`);
|
|
4273
|
+
} else if (!arg.isStatic) arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
4274
|
+
if (modifiers.some((mod) => mod.content === "camel")) if (arg.type === 4) if (arg.isStatic) arg.content = shared.camelize(arg.content);
|
|
4275
|
+
else arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4276
|
+
else {
|
|
4277
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4278
|
+
arg.children.push(`)`);
|
|
4279
|
+
}
|
|
4280
|
+
if (!context.inSSR) {
|
|
4281
|
+
if (modifiers.some((mod) => mod.content === "prop")) injectPrefix(arg, ".");
|
|
4282
|
+
if (modifiers.some((mod) => mod.content === "attr")) injectPrefix(arg, "^");
|
|
4283
|
+
}
|
|
4284
|
+
return { props: [createObjectProperty(arg, exp)] };
|
|
4285
|
+
};
|
|
4286
|
+
const injectPrefix = (arg, prefix) => {
|
|
4287
|
+
if (arg.type === 4) if (arg.isStatic) arg.content = prefix + arg.content;
|
|
4288
|
+
else arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4289
|
+
else {
|
|
4290
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
4291
|
+
arg.children.push(`)`);
|
|
4292
|
+
}
|
|
4293
|
+
};
|
|
4294
|
+
const transformText = (node, context) => {
|
|
4295
|
+
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) return () => {
|
|
4296
|
+
const children = node.children;
|
|
4297
|
+
let currentContainer = void 0;
|
|
4298
|
+
let hasText = false;
|
|
4299
|
+
for (let i = 0; i < children.length; i++) {
|
|
4300
|
+
const child = children[i];
|
|
4301
|
+
if (isText$1(child)) {
|
|
4302
|
+
hasText = true;
|
|
4303
|
+
for (let j = i + 1; j < children.length; j++) {
|
|
4304
|
+
const next = children[j];
|
|
4305
|
+
if (isText$1(next)) {
|
|
4306
|
+
if (!currentContainer) currentContainer = children[i] = createCompoundExpression([child], child.loc);
|
|
4307
|
+
currentContainer.children.push(` + `, next);
|
|
4308
|
+
children.splice(j, 1);
|
|
4309
|
+
j--;
|
|
4310
|
+
} else {
|
|
4311
|
+
currentContainer = void 0;
|
|
4312
|
+
break;
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
if (!hasText || children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && !node.props.find((p) => p.type === 7 && !context.directiveTransforms[p.name]) && !(node.tag === "template"))) return;
|
|
4318
|
+
for (let i = 0; i < children.length; i++) {
|
|
4319
|
+
const child = children[i];
|
|
4320
|
+
if (isText$1(child) || child.type === 8) {
|
|
4321
|
+
const callArgs = [];
|
|
4322
|
+
if (child.type !== 2 || child.content !== " ") callArgs.push(child);
|
|
4323
|
+
if (!context.ssr && getConstantType(child, context) === 0) callArgs.push("1");
|
|
4324
|
+
children[i] = {
|
|
4325
|
+
type: 12,
|
|
4326
|
+
content: child,
|
|
4327
|
+
loc: child.loc,
|
|
4328
|
+
codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
|
|
4329
|
+
};
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
};
|
|
4333
|
+
};
|
|
4334
|
+
const seen$1 = /* @__PURE__ */ new WeakSet();
|
|
4335
|
+
const transformOnce = (node, context) => {
|
|
4336
|
+
if (node.type === 1 && findDir(node, "once", true)) {
|
|
4337
|
+
if (seen$1.has(node) || context.inVOnce || context.inSSR) return;
|
|
4338
|
+
seen$1.add(node);
|
|
4339
|
+
context.inVOnce = true;
|
|
4340
|
+
context.helper(SET_BLOCK_TRACKING);
|
|
4341
|
+
return () => {
|
|
4342
|
+
context.inVOnce = false;
|
|
4343
|
+
const cur = context.currentNode;
|
|
4344
|
+
if (cur.codegenNode) cur.codegenNode = context.cache(cur.codegenNode, true, true);
|
|
4345
|
+
};
|
|
4346
|
+
}
|
|
4347
|
+
};
|
|
4348
|
+
const transformModel = (dir, node, context) => {
|
|
4349
|
+
const { exp, arg } = dir;
|
|
4350
|
+
if (!exp) {
|
|
4351
|
+
context.onError(createCompilerError(41, dir.loc));
|
|
4352
|
+
return createTransformProps();
|
|
4353
|
+
}
|
|
4354
|
+
const rawExp = exp.loc.source.trim();
|
|
4355
|
+
const expString = exp.type === 4 ? exp.content : rawExp;
|
|
4356
|
+
const bindingType = context.bindingMetadata[rawExp];
|
|
4357
|
+
if (bindingType === "props" || bindingType === "props-aliased") {
|
|
4358
|
+
context.onError(createCompilerError(44, exp.loc));
|
|
4359
|
+
return createTransformProps();
|
|
4360
|
+
}
|
|
4361
|
+
const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
|
|
4362
|
+
if (!expString.trim() || !isMemberExpression(exp, context) && !maybeRef) {
|
|
4363
|
+
context.onError(createCompilerError(42, exp.loc));
|
|
4364
|
+
return createTransformProps();
|
|
4365
|
+
}
|
|
4366
|
+
if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
|
|
4367
|
+
context.onError(createCompilerError(43, exp.loc));
|
|
4368
|
+
return createTransformProps();
|
|
4369
|
+
}
|
|
4370
|
+
const propName = arg ? arg : createSimpleExpression("modelValue", true);
|
|
4371
|
+
const eventName = arg ? isStaticExp(arg) ? `onUpdate:${shared.camelize(arg.content)}` : createCompoundExpression(["\"onUpdate:\" + ", arg]) : `onUpdate:modelValue`;
|
|
4372
|
+
let assignmentExp;
|
|
4373
|
+
const eventArg = context.isTS ? `($event: any)` : `$event`;
|
|
4374
|
+
if (maybeRef) if (bindingType === "setup-ref") assignmentExp = createCompoundExpression([
|
|
4375
|
+
`${eventArg} => ((`,
|
|
4376
|
+
createSimpleExpression(rawExp, false, exp.loc),
|
|
4377
|
+
`).value = $event)`
|
|
4378
|
+
]);
|
|
4379
|
+
else {
|
|
4380
|
+
const altAssignment = bindingType === "setup-let" ? `${rawExp} = $event` : `null`;
|
|
4381
|
+
assignmentExp = createCompoundExpression([
|
|
4382
|
+
`${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
|
|
4383
|
+
createSimpleExpression(rawExp, false, exp.loc),
|
|
4384
|
+
`).value = $event : ${altAssignment})`
|
|
4385
|
+
]);
|
|
4386
|
+
}
|
|
4387
|
+
else assignmentExp = createCompoundExpression([
|
|
4388
|
+
`${eventArg} => ((`,
|
|
4389
|
+
exp,
|
|
4390
|
+
`) = $event)`
|
|
4391
|
+
]);
|
|
4392
|
+
const props = [createObjectProperty(propName, dir.exp), createObjectProperty(eventName, assignmentExp)];
|
|
4393
|
+
if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) props[1].value = context.cache(props[1].value);
|
|
4394
|
+
if (dir.modifiers.length && node.tagType === 1) {
|
|
4395
|
+
const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
|
4396
|
+
const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, " + \"Modifiers\""]) : `modelModifiers`;
|
|
4397
|
+
props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2)));
|
|
4398
|
+
}
|
|
4399
|
+
return createTransformProps(props);
|
|
4400
|
+
};
|
|
4401
|
+
function createTransformProps(props = []) {
|
|
4402
|
+
return { props };
|
|
4403
|
+
}
|
|
4404
|
+
const validDivisionCharRE = /[\w).+\-_$\]]/;
|
|
4405
|
+
const transformFilter = (node, context) => {
|
|
4406
|
+
if (!isCompatEnabled("COMPILER_FILTERS", context)) return;
|
|
4407
|
+
if (node.type === 5) rewriteFilter(node.content, context);
|
|
4408
|
+
else if (node.type === 1) node.props.forEach((prop) => {
|
|
4409
|
+
if (prop.type === 7 && prop.name !== "for" && prop.exp) rewriteFilter(prop.exp, context);
|
|
4410
|
+
});
|
|
4411
|
+
};
|
|
4412
|
+
function rewriteFilter(node, context) {
|
|
4413
|
+
if (node.type === 4) parseFilter(node, context);
|
|
4414
|
+
else for (let i = 0; i < node.children.length; i++) {
|
|
4415
|
+
const child = node.children[i];
|
|
4416
|
+
if (typeof child !== "object") continue;
|
|
4417
|
+
if (child.type === 4) parseFilter(child, context);
|
|
4418
|
+
else if (child.type === 8) rewriteFilter(node, context);
|
|
4419
|
+
else if (child.type === 5) rewriteFilter(child.content, context);
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
function parseFilter(node, context) {
|
|
4423
|
+
const exp = node.content;
|
|
4424
|
+
let inSingle = false;
|
|
4425
|
+
let inDouble = false;
|
|
4426
|
+
let inTemplateString = false;
|
|
4427
|
+
let inRegex = false;
|
|
4428
|
+
let curly = 0;
|
|
4429
|
+
let square = 0;
|
|
4430
|
+
let paren = 0;
|
|
4431
|
+
let lastFilterIndex = 0;
|
|
4432
|
+
let c, prev, i, expression, filters = [];
|
|
4433
|
+
for (i = 0; i < exp.length; i++) {
|
|
4434
|
+
prev = c;
|
|
4435
|
+
c = exp.charCodeAt(i);
|
|
4436
|
+
if (inSingle) {
|
|
4437
|
+
if (c === 39 && prev !== 92) inSingle = false;
|
|
4438
|
+
} else if (inDouble) {
|
|
4439
|
+
if (c === 34 && prev !== 92) inDouble = false;
|
|
4440
|
+
} else if (inTemplateString) {
|
|
4441
|
+
if (c === 96 && prev !== 92) inTemplateString = false;
|
|
4442
|
+
} else if (inRegex) {
|
|
4443
|
+
if (c === 47 && prev !== 92) inRegex = false;
|
|
4444
|
+
} else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) if (expression === void 0) {
|
|
4445
|
+
lastFilterIndex = i + 1;
|
|
4446
|
+
expression = exp.slice(0, i).trim();
|
|
4447
|
+
} else pushFilter();
|
|
4448
|
+
else {
|
|
4449
|
+
switch (c) {
|
|
4450
|
+
case 34:
|
|
4451
|
+
inDouble = true;
|
|
4452
|
+
break;
|
|
4453
|
+
case 39:
|
|
4454
|
+
inSingle = true;
|
|
4455
|
+
break;
|
|
4456
|
+
case 96:
|
|
4457
|
+
inTemplateString = true;
|
|
4458
|
+
break;
|
|
4459
|
+
case 40:
|
|
4460
|
+
paren++;
|
|
4461
|
+
break;
|
|
4462
|
+
case 41:
|
|
4463
|
+
paren--;
|
|
4464
|
+
break;
|
|
4465
|
+
case 91:
|
|
4466
|
+
square++;
|
|
4467
|
+
break;
|
|
4468
|
+
case 93:
|
|
4469
|
+
square--;
|
|
4470
|
+
break;
|
|
4471
|
+
case 123:
|
|
4472
|
+
curly++;
|
|
4473
|
+
break;
|
|
4474
|
+
case 125:
|
|
4475
|
+
curly--;
|
|
4476
|
+
break;
|
|
4477
|
+
}
|
|
4478
|
+
if (c === 47) {
|
|
4479
|
+
let j = i - 1;
|
|
4480
|
+
let p;
|
|
4481
|
+
for (; j >= 0; j--) {
|
|
4482
|
+
p = exp.charAt(j);
|
|
4483
|
+
if (p !== " ") break;
|
|
4484
|
+
}
|
|
4485
|
+
if (!p || !validDivisionCharRE.test(p)) inRegex = true;
|
|
4486
|
+
}
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4489
|
+
if (expression === void 0) expression = exp.slice(0, i).trim();
|
|
4490
|
+
else if (lastFilterIndex !== 0) pushFilter();
|
|
4491
|
+
function pushFilter() {
|
|
4492
|
+
filters.push(exp.slice(lastFilterIndex, i).trim());
|
|
4493
|
+
lastFilterIndex = i + 1;
|
|
4494
|
+
}
|
|
4495
|
+
if (filters.length) {
|
|
4496
|
+
for (i = 0; i < filters.length; i++) expression = wrapFilter(expression, filters[i], context);
|
|
4497
|
+
node.content = expression;
|
|
4498
|
+
node.ast = void 0;
|
|
4499
|
+
}
|
|
4500
|
+
}
|
|
4501
|
+
function wrapFilter(exp, filter, context) {
|
|
4502
|
+
context.helper(RESOLVE_FILTER);
|
|
4503
|
+
const i = filter.indexOf("(");
|
|
4504
|
+
if (i < 0) {
|
|
4505
|
+
context.filters.add(filter);
|
|
4506
|
+
return `${toValidAssetId(filter, "filter")}(${exp})`;
|
|
4507
|
+
} else {
|
|
4508
|
+
const name = filter.slice(0, i);
|
|
4509
|
+
const args = filter.slice(i + 1);
|
|
4510
|
+
context.filters.add(name);
|
|
4511
|
+
return `${toValidAssetId(name, "filter")}(${exp}${args !== ")" ? "," + args : args}`;
|
|
4512
|
+
}
|
|
4513
|
+
}
|
|
4514
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
4515
|
+
const transformMemo = (node, context) => {
|
|
4516
|
+
if (node.type === 1) {
|
|
4517
|
+
const dir = findDir(node, "memo");
|
|
4518
|
+
if (!dir || seen.has(node) || context.inSSR) return;
|
|
4519
|
+
seen.add(node);
|
|
4520
|
+
return () => {
|
|
4521
|
+
const codegenNode = node.codegenNode || context.currentNode.codegenNode;
|
|
4522
|
+
if (codegenNode && codegenNode.type === 13) {
|
|
4523
|
+
if (node.tagType !== 1) convertToBlock(codegenNode, context);
|
|
4524
|
+
node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
|
4525
|
+
dir.exp,
|
|
4526
|
+
createFunctionExpression(void 0, codegenNode),
|
|
4527
|
+
`_cache`,
|
|
4528
|
+
String(context.cached.length)
|
|
4529
|
+
]);
|
|
4530
|
+
context.cached.push(null);
|
|
4531
|
+
}
|
|
4532
|
+
};
|
|
4533
|
+
}
|
|
4534
|
+
};
|
|
4535
|
+
const transformVBindShorthand = (node, context) => {
|
|
4536
|
+
if (node.type === 1) {
|
|
4537
|
+
for (const prop of node.props) if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
|
|
4538
|
+
const arg = prop.arg;
|
|
4539
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
4540
|
+
context.onError(createCompilerError(52, arg.loc));
|
|
4541
|
+
prop.exp = createSimpleExpression("", true, arg.loc);
|
|
4542
|
+
} else {
|
|
4543
|
+
const propName = shared.camelize(arg.content);
|
|
4544
|
+
if (validFirstIdentCharRE.test(propName[0]) || propName[0] === "-") prop.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4547
|
+
}
|
|
4548
|
+
};
|
|
4549
|
+
function getBaseTransformPreset(prefixIdentifiers) {
|
|
4550
|
+
return [[
|
|
4551
|
+
transformVBindShorthand,
|
|
4552
|
+
transformOnce,
|
|
4553
|
+
transformIf,
|
|
4554
|
+
transformMemo,
|
|
4555
|
+
transformFor,
|
|
4556
|
+
...[transformFilter],
|
|
4557
|
+
...prefixIdentifiers ? [trackVForSlotScopes, transformExpression] : [],
|
|
4558
|
+
transformSlotOutlet,
|
|
4559
|
+
transformElement,
|
|
4560
|
+
trackSlotScopes,
|
|
4561
|
+
transformText
|
|
4562
|
+
], {
|
|
4563
|
+
on: transformOn,
|
|
4564
|
+
bind: transformBind,
|
|
4565
|
+
model: transformModel
|
|
4566
|
+
}];
|
|
4567
|
+
}
|
|
4568
|
+
function baseCompile(source, options = {}) {
|
|
4569
|
+
const onError = options.onError || defaultOnError;
|
|
4570
|
+
const isModuleMode = options.mode === "module";
|
|
4571
|
+
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
|
|
4572
|
+
if (!prefixIdentifiers && options.cacheHandlers) onError(createCompilerError(49));
|
|
4573
|
+
if (options.scopeId && !isModuleMode) onError(createCompilerError(50));
|
|
4574
|
+
const resolvedOptions = shared.extend({}, options, { prefixIdentifiers });
|
|
4575
|
+
const ast = shared.isString(source) ? baseParse(source, resolvedOptions) : source;
|
|
4576
|
+
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
|
|
4577
|
+
if (options.isTS) {
|
|
4578
|
+
const { expressionPlugins } = options;
|
|
4579
|
+
if (!expressionPlugins || !expressionPlugins.includes("typescript")) options.expressionPlugins = [...expressionPlugins || [], "typescript"];
|
|
4580
|
+
}
|
|
4581
|
+
transform(ast, shared.extend({}, resolvedOptions, {
|
|
4582
|
+
nodeTransforms: [...nodeTransforms, ...options.nodeTransforms || []],
|
|
4583
|
+
directiveTransforms: shared.extend({}, directiveTransforms, options.directiveTransforms || {})
|
|
4584
|
+
}));
|
|
4585
|
+
return generate(ast, resolvedOptions);
|
|
4586
|
+
}
|
|
4587
|
+
const BindingTypes = {
|
|
4588
|
+
"DATA": "data",
|
|
4589
|
+
"PROPS": "props",
|
|
4590
|
+
"PROPS_ALIASED": "props-aliased",
|
|
4591
|
+
"SETUP_LET": "setup-let",
|
|
4592
|
+
"SETUP_CONST": "setup-const",
|
|
4593
|
+
"SETUP_REACTIVE_CONST": "setup-reactive-const",
|
|
4594
|
+
"SETUP_MAYBE_REF": "setup-maybe-ref",
|
|
4595
|
+
"SETUP_REF": "setup-ref",
|
|
4596
|
+
"OPTIONS": "options",
|
|
4597
|
+
"LITERAL_CONST": "literal-const"
|
|
4598
|
+
};
|
|
4599
|
+
const noopDirectiveTransform = () => ({ props: [] });
|
|
4600
|
+
exports.generateCodeFrame = shared.generateCodeFrame;
|
|
4601
|
+
exports.BASE_TRANSITION = BASE_TRANSITION;
|
|
4602
|
+
exports.BindingTypes = BindingTypes;
|
|
4603
|
+
exports.CAMELIZE = CAMELIZE;
|
|
4604
|
+
exports.CAPITALIZE = CAPITALIZE;
|
|
4605
|
+
exports.CREATE_BLOCK = CREATE_BLOCK;
|
|
4606
|
+
exports.CREATE_COMMENT = CREATE_COMMENT;
|
|
4607
|
+
exports.CREATE_ELEMENT_BLOCK = CREATE_ELEMENT_BLOCK;
|
|
4608
|
+
exports.CREATE_ELEMENT_VNODE = CREATE_ELEMENT_VNODE;
|
|
4609
|
+
exports.CREATE_SLOTS = CREATE_SLOTS;
|
|
4610
|
+
exports.CREATE_STATIC = CREATE_STATIC;
|
|
4611
|
+
exports.CREATE_TEXT = CREATE_TEXT;
|
|
4612
|
+
exports.CREATE_VNODE = CREATE_VNODE;
|
|
4613
|
+
exports.CompilerDeprecationTypes = CompilerDeprecationTypes;
|
|
4614
|
+
exports.ConstantTypes = ConstantTypes;
|
|
4615
|
+
exports.ElementTypes = ElementTypes;
|
|
4616
|
+
exports.ErrorCodes = ErrorCodes;
|
|
4617
|
+
exports.FRAGMENT = FRAGMENT;
|
|
4618
|
+
exports.GUARD_REACTIVE_PROPS = GUARD_REACTIVE_PROPS;
|
|
4619
|
+
exports.IS_MEMO_SAME = IS_MEMO_SAME;
|
|
4620
|
+
exports.IS_REF = IS_REF;
|
|
4621
|
+
exports.KEEP_ALIVE = KEEP_ALIVE;
|
|
4622
|
+
exports.MERGE_PROPS = MERGE_PROPS;
|
|
4623
|
+
exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
|
|
4624
|
+
exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
|
|
4625
|
+
exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
|
|
4626
|
+
exports.Namespaces = Namespaces;
|
|
4627
|
+
exports.NodeTypes = NodeTypes;
|
|
4628
|
+
exports.OPEN_BLOCK = OPEN_BLOCK;
|
|
4629
|
+
exports.POP_SCOPE_ID = POP_SCOPE_ID;
|
|
4630
|
+
exports.PUSH_SCOPE_ID = PUSH_SCOPE_ID;
|
|
4631
|
+
exports.RENDER_LIST = RENDER_LIST;
|
|
4632
|
+
exports.RENDER_SLOT = RENDER_SLOT;
|
|
4633
|
+
exports.RESOLVE_COMPONENT = RESOLVE_COMPONENT;
|
|
4634
|
+
exports.RESOLVE_DIRECTIVE = RESOLVE_DIRECTIVE;
|
|
4635
|
+
exports.RESOLVE_DYNAMIC_COMPONENT = RESOLVE_DYNAMIC_COMPONENT;
|
|
4636
|
+
exports.RESOLVE_FILTER = RESOLVE_FILTER;
|
|
4637
|
+
exports.SET_BLOCK_TRACKING = SET_BLOCK_TRACKING;
|
|
4638
|
+
exports.SUSPENSE = SUSPENSE;
|
|
4639
|
+
exports.TELEPORT = TELEPORT;
|
|
4640
|
+
exports.TO_DISPLAY_STRING = TO_DISPLAY_STRING;
|
|
4641
|
+
exports.TO_HANDLERS = TO_HANDLERS;
|
|
4642
|
+
exports.TO_HANDLER_KEY = TO_HANDLER_KEY;
|
|
4643
|
+
exports.TS_NODE_TYPES = TS_NODE_TYPES;
|
|
4644
|
+
exports.UNREF = UNREF;
|
|
4645
|
+
exports.WITH_CTX = WITH_CTX;
|
|
4646
|
+
exports.WITH_DIRECTIVES = WITH_DIRECTIVES;
|
|
4647
|
+
exports.WITH_MEMO = WITH_MEMO;
|
|
4648
|
+
exports.advancePositionWithClone = advancePositionWithClone;
|
|
4649
|
+
exports.advancePositionWithMutation = advancePositionWithMutation;
|
|
4650
|
+
exports.assert = assert;
|
|
4651
|
+
exports.baseCompile = baseCompile;
|
|
4652
|
+
exports.baseParse = baseParse;
|
|
4653
|
+
exports.buildDirectiveArgs = buildDirectiveArgs;
|
|
4654
|
+
exports.buildProps = buildProps;
|
|
4655
|
+
exports.buildSlots = buildSlots;
|
|
4656
|
+
exports.checkCompatEnabled = checkCompatEnabled;
|
|
4657
|
+
exports.convertToBlock = convertToBlock;
|
|
4658
|
+
exports.createArrayExpression = createArrayExpression;
|
|
4659
|
+
exports.createAssignmentExpression = createAssignmentExpression;
|
|
4660
|
+
exports.createBlockStatement = createBlockStatement;
|
|
4661
|
+
exports.createCacheExpression = createCacheExpression;
|
|
4662
|
+
exports.createCallExpression = createCallExpression;
|
|
4663
|
+
exports.createCompilerError = createCompilerError;
|
|
4664
|
+
exports.createCompoundExpression = createCompoundExpression;
|
|
4665
|
+
exports.createConditionalExpression = createConditionalExpression;
|
|
4666
|
+
exports.createForLoopParams = createForLoopParams;
|
|
4667
|
+
exports.createFunctionExpression = createFunctionExpression;
|
|
4668
|
+
exports.createIfStatement = createIfStatement;
|
|
4669
|
+
exports.createInterpolation = createInterpolation;
|
|
4670
|
+
exports.createObjectExpression = createObjectExpression;
|
|
4671
|
+
exports.createObjectProperty = createObjectProperty;
|
|
4672
|
+
exports.createReturnStatement = createReturnStatement;
|
|
4673
|
+
exports.createRoot = createRoot;
|
|
4674
|
+
exports.createSequenceExpression = createSequenceExpression;
|
|
4675
|
+
exports.createSimpleExpression = createSimpleExpression;
|
|
4676
|
+
exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform;
|
|
4677
|
+
exports.createTemplateLiteral = createTemplateLiteral;
|
|
4678
|
+
exports.createTransformContext = createTransformContext;
|
|
4679
|
+
exports.createVNodeCall = createVNodeCall;
|
|
4680
|
+
exports.errorMessages = errorMessages;
|
|
4681
|
+
exports.extractIdentifiers = extractIdentifiers;
|
|
4682
|
+
exports.findDir = findDir;
|
|
4683
|
+
exports.findProp = findProp;
|
|
4684
|
+
exports.forAliasRE = forAliasRE;
|
|
4685
|
+
exports.generate = generate;
|
|
4686
|
+
exports.getBaseTransformPreset = getBaseTransformPreset;
|
|
4687
|
+
exports.getConstantType = getConstantType;
|
|
4688
|
+
exports.getMemoedVNodeCall = getMemoedVNodeCall;
|
|
4689
|
+
exports.getVNodeBlockHelper = getVNodeBlockHelper;
|
|
4690
|
+
exports.getVNodeHelper = getVNodeHelper;
|
|
4691
|
+
exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
|
|
4692
|
+
exports.hasScopeRef = hasScopeRef;
|
|
4693
|
+
exports.helperNameMap = helperNameMap;
|
|
4694
|
+
exports.injectProp = injectProp;
|
|
4695
|
+
exports.isCoreComponent = isCoreComponent;
|
|
4696
|
+
exports.isFnExpression = isFnExpression;
|
|
4697
|
+
exports.isFnExpressionBrowser = isFnExpressionBrowser;
|
|
4698
|
+
exports.isFnExpressionNode = isFnExpressionNode;
|
|
4699
|
+
exports.isFunctionType = isFunctionType;
|
|
4700
|
+
exports.isInDestructureAssignment = isInDestructureAssignment;
|
|
4701
|
+
exports.isInNewExpression = isInNewExpression;
|
|
4702
|
+
exports.isMemberExpression = isMemberExpression;
|
|
4703
|
+
exports.isMemberExpressionBrowser = isMemberExpressionBrowser;
|
|
4704
|
+
exports.isMemberExpressionNode = isMemberExpressionNode;
|
|
4705
|
+
exports.isReferencedIdentifier = isReferencedIdentifier;
|
|
4706
|
+
exports.isSimpleIdentifier = isSimpleIdentifier;
|
|
4707
|
+
exports.isSlotOutlet = isSlotOutlet;
|
|
4708
|
+
exports.isStaticArgOf = isStaticArgOf;
|
|
4709
|
+
exports.isStaticExp = isStaticExp;
|
|
4710
|
+
exports.isStaticProperty = isStaticProperty;
|
|
4711
|
+
exports.isStaticPropertyKey = isStaticPropertyKey;
|
|
4712
|
+
exports.isTemplateNode = isTemplateNode;
|
|
4713
|
+
exports.isText = isText$1;
|
|
4714
|
+
exports.isVPre = isVPre;
|
|
4715
|
+
exports.isVSlot = isVSlot;
|
|
4716
|
+
exports.locStub = locStub;
|
|
4717
|
+
exports.noopDirectiveTransform = noopDirectiveTransform;
|
|
4718
|
+
exports.processExpression = processExpression;
|
|
4719
|
+
exports.processFor = processFor;
|
|
4720
|
+
exports.processIf = processIf;
|
|
4721
|
+
exports.processSlotOutlet = processSlotOutlet;
|
|
4722
|
+
exports.registerRuntimeHelpers = registerRuntimeHelpers;
|
|
4723
|
+
exports.resolveComponentType = resolveComponentType;
|
|
4724
|
+
exports.stringifyExpression = stringifyExpression;
|
|
4725
|
+
exports.toValidAssetId = toValidAssetId;
|
|
4726
|
+
exports.trackSlotScopes = trackSlotScopes;
|
|
4727
|
+
exports.trackVForSlotScopes = trackVForSlotScopes;
|
|
4728
|
+
exports.transform = transform;
|
|
4729
|
+
exports.transformBind = transformBind;
|
|
4730
|
+
exports.transformElement = transformElement;
|
|
4731
|
+
exports.transformExpression = transformExpression;
|
|
4732
|
+
exports.transformModel = transformModel;
|
|
4733
|
+
exports.transformOn = transformOn;
|
|
4734
|
+
exports.transformVBindShorthand = transformVBindShorthand;
|
|
4735
|
+
exports.traverseNode = traverseNode;
|
|
4736
|
+
exports.unwrapTSNode = unwrapTSNode;
|
|
4737
|
+
exports.validFirstIdentCharRE = validFirstIdentCharRE;
|
|
4738
|
+
exports.walkBlockDeclarations = walkBlockDeclarations;
|
|
4739
|
+
exports.walkFunctionParams = walkFunctionParams;
|
|
4740
|
+
exports.walkIdentifiers = walkIdentifiers;
|
|
4741
|
+
exports.warnDeprecation = warnDeprecation;
|
|
4742
|
+
}) });
|
|
4743
|
+
|
|
4744
|
+
//#endregion
|
|
4745
|
+
export default require_compiler_core_cjs_prod();
|
|
4746
|
+
|
|
4747
|
+
export { require_compiler_core_cjs_prod };
|
|
4748
|
+
//# sourceMappingURL=compiler-core.cjs.prod.mjs.map
|