@builder.io/sdk-vue 0.5.9 → 0.6.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/package.json +145 -22
- package/vue2/css/package.json +4 -0
- package/vue2/node_modules/@types/node/LICENSE +21 -0
- package/vue2/node_modules/@types/node/README.md +16 -0
- package/vue2/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/vue2/node_modules/@types/node/assert.d.ts +962 -0
- package/vue2/node_modules/@types/node/async_hooks.d.ts +497 -0
- package/vue2/node_modules/@types/node/buffer.d.ts +2236 -0
- package/vue2/node_modules/@types/node/child_process.d.ts +1396 -0
- package/vue2/node_modules/@types/node/cluster.d.ts +414 -0
- package/vue2/node_modules/@types/node/console.d.ts +412 -0
- package/vue2/node_modules/@types/node/constants.d.ts +18 -0
- package/vue2/node_modules/@types/node/crypto.d.ts +3869 -0
- package/vue2/node_modules/@types/node/dgram.d.ts +545 -0
- package/vue2/node_modules/@types/node/diagnostics_channel.d.ts +191 -0
- package/vue2/node_modules/@types/node/dns/promises.d.ts +369 -0
- package/vue2/node_modules/@types/node/dns.d.ts +655 -0
- package/vue2/node_modules/@types/node/domain.d.ts +170 -0
- package/vue2/node_modules/@types/node/events.d.ts +641 -0
- package/vue2/node_modules/@types/node/fs/promises.d.ts +1094 -0
- package/vue2/node_modules/@types/node/fs.d.ts +3803 -0
- package/vue2/node_modules/@types/node/globals.d.ts +287 -0
- package/vue2/node_modules/@types/node/globals.global.d.ts +1 -0
- package/vue2/node_modules/@types/node/http.d.ts +1504 -0
- package/vue2/node_modules/@types/node/http2.d.ts +2100 -0
- package/vue2/node_modules/@types/node/https.d.ts +532 -0
- package/vue2/node_modules/@types/node/index.d.ts +131 -0
- package/vue2/node_modules/@types/node/inspector.d.ts +2745 -0
- package/vue2/node_modules/@types/node/module.d.ts +115 -0
- package/vue2/node_modules/@types/node/net.d.ts +828 -0
- package/vue2/node_modules/@types/node/os.d.ts +455 -0
- package/vue2/node_modules/@types/node/package.json +232 -0
- package/vue2/node_modules/@types/node/path.d.ts +191 -0
- package/vue2/node_modules/@types/node/perf_hooks.d.ts +586 -0
- package/vue2/node_modules/@types/node/process.d.ts +1481 -0
- package/vue2/node_modules/@types/node/punycode.d.ts +117 -0
- package/vue2/node_modules/@types/node/querystring.d.ts +131 -0
- package/vue2/node_modules/@types/node/readline.d.ts +543 -0
- package/vue2/node_modules/@types/node/repl.d.ts +424 -0
- package/vue2/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/vue2/node_modules/@types/node/stream/promises.d.ts +42 -0
- package/vue2/node_modules/@types/node/stream/web.d.ts +392 -0
- package/vue2/node_modules/@types/node/stream.d.ts +1363 -0
- package/vue2/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/vue2/node_modules/@types/node/test.d.ts +190 -0
- package/vue2/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/vue2/node_modules/@types/node/timers.d.ts +94 -0
- package/vue2/node_modules/@types/node/tls.d.ts +1019 -0
- package/vue2/node_modules/@types/node/trace_events.d.ts +161 -0
- package/vue2/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/vue2/node_modules/@types/node/ts4.8/assert.d.ts +962 -0
- package/vue2/node_modules/@types/node/ts4.8/async_hooks.d.ts +497 -0
- package/vue2/node_modules/@types/node/ts4.8/buffer.d.ts +2236 -0
- package/vue2/node_modules/@types/node/ts4.8/child_process.d.ts +1396 -0
- package/vue2/node_modules/@types/node/ts4.8/cluster.d.ts +414 -0
- package/vue2/node_modules/@types/node/ts4.8/console.d.ts +412 -0
- package/vue2/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
- package/vue2/node_modules/@types/node/ts4.8/crypto.d.ts +3866 -0
- package/vue2/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
- package/vue2/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +191 -0
- package/vue2/node_modules/@types/node/ts4.8/dns/promises.d.ts +368 -0
- package/vue2/node_modules/@types/node/ts4.8/dns.d.ts +654 -0
- package/vue2/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/vue2/node_modules/@types/node/ts4.8/events.d.ts +641 -0
- package/vue2/node_modules/@types/node/ts4.8/fs/promises.d.ts +1094 -0
- package/vue2/node_modules/@types/node/ts4.8/fs.d.ts +3802 -0
- package/vue2/node_modules/@types/node/ts4.8/globals.d.ts +284 -0
- package/vue2/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/vue2/node_modules/@types/node/ts4.8/http.d.ts +1503 -0
- package/vue2/node_modules/@types/node/ts4.8/http2.d.ts +2100 -0
- package/vue2/node_modules/@types/node/ts4.8/https.d.ts +532 -0
- package/vue2/node_modules/@types/node/ts4.8/index.d.ts +86 -0
- package/vue2/node_modules/@types/node/ts4.8/inspector.d.ts +2745 -0
- package/vue2/node_modules/@types/node/ts4.8/module.d.ts +115 -0
- package/vue2/node_modules/@types/node/ts4.8/net.d.ts +828 -0
- package/vue2/node_modules/@types/node/ts4.8/os.d.ts +456 -0
- package/vue2/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/vue2/node_modules/@types/node/ts4.8/perf_hooks.d.ts +586 -0
- package/vue2/node_modules/@types/node/ts4.8/process.d.ts +1481 -0
- package/vue2/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/vue2/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
- package/vue2/node_modules/@types/node/ts4.8/readline.d.ts +543 -0
- package/vue2/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
- package/vue2/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/vue2/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
- package/vue2/node_modules/@types/node/ts4.8/stream/web.d.ts +392 -0
- package/vue2/node_modules/@types/node/ts4.8/stream.d.ts +1363 -0
- package/vue2/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/vue2/node_modules/@types/node/ts4.8/test.d.ts +190 -0
- package/vue2/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/vue2/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
- package/vue2/node_modules/@types/node/ts4.8/tls.d.ts +1019 -0
- package/vue2/node_modules/@types/node/ts4.8/trace_events.d.ts +161 -0
- package/vue2/node_modules/@types/node/ts4.8/tty.d.ts +204 -0
- package/vue2/node_modules/@types/node/ts4.8/url.d.ts +855 -0
- package/vue2/node_modules/@types/node/ts4.8/util.d.ts +1594 -0
- package/vue2/node_modules/@types/node/ts4.8/v8.d.ts +472 -0
- package/vue2/node_modules/@types/node/ts4.8/vm.d.ts +507 -0
- package/vue2/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/vue2/node_modules/@types/node/ts4.8/worker_threads.d.ts +649 -0
- package/vue2/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/vue2/node_modules/@types/node/tty.d.ts +204 -0
- package/vue2/node_modules/@types/node/url.d.ts +855 -0
- package/vue2/node_modules/@types/node/util.d.ts +1594 -0
- package/vue2/node_modules/@types/node/v8.d.ts +472 -0
- package/vue2/node_modules/@types/node/vm.d.ts +507 -0
- package/vue2/node_modules/@types/node/wasi.d.ts +158 -0
- package/vue2/node_modules/@types/node/worker_threads.d.ts +649 -0
- package/vue2/node_modules/@types/node/zlib.d.ts +517 -0
- package/vue2/node_modules/@vitejs/plugin-vue2/LICENSE +21 -0
- package/vue2/node_modules/@vitejs/plugin-vue2/README.md +115 -0
- package/vue2/node_modules/@vitejs/plugin-vue2/package.json +65 -0
- package/vue2/node_modules/@vue/compiler-sfc/LICENSE +21 -0
- package/vue2/node_modules/@vue/compiler-sfc/package.json +34 -0
- package/vue2/node_modules/@vue/tsconfig/README.md +31 -0
- package/vue2/node_modules/@vue/tsconfig/package.json +35 -0
- package/vue2/node_modules/@vue/tsconfig/tsconfig.json +40 -0
- package/vue2/node_modules/@vue/tsconfig/tsconfig.node.json +17 -0
- package/vue2/node_modules/@vue/tsconfig/tsconfig.web.json +19 -0
- package/vue2/node_modules/rollup/LICENSE.md +695 -0
- package/vue2/node_modules/rollup/README.md +125 -0
- package/vue2/node_modules/rollup/package.json +178 -0
- package/vue2/node_modules/vite/LICENSE.md +3396 -0
- package/vue2/node_modules/vite/README.md +20 -0
- package/vue2/node_modules/vite/bin/openChrome.applescript +95 -0
- package/vue2/node_modules/vite/bin/vite.js +61 -0
- package/vue2/node_modules/vite/client.d.ts +281 -0
- package/vue2/node_modules/vite/index.cjs +34 -0
- package/vue2/node_modules/vite/package.json +170 -0
- package/vue2/node_modules/vite-plugin-dts/LICENSE +21 -0
- package/vue2/node_modules/vite-plugin-dts/README.md +368 -0
- package/vue2/node_modules/vite-plugin-dts/README.zh-CN.md +368 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/LICENSE +21 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/README.md +36 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/bin/vue-tsc.js +67 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/index.d.ts +16 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/index.js +120 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/shared.d.ts +8 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/shared.js +5 -0
- package/vue2/node_modules/vite-plugin-dts/node_modules/vue-tsc/package.json +28 -0
- package/vue2/node_modules/vite-plugin-dts/package.json +103 -0
- package/vue2/node_modules/vue/LICENSE +21 -0
- package/vue2/node_modules/vue/README.md +118 -0
- package/vue2/node_modules/vue/compiler-sfc/index.d.ts +1 -0
- package/vue2/node_modules/vue/compiler-sfc/index.js +1 -0
- package/vue2/node_modules/vue/compiler-sfc/index.mjs +1 -0
- package/vue2/node_modules/vue/compiler-sfc/package.json +5 -0
- package/vue2/node_modules/vue/package.json +132 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/api-extractor.json +64 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/node_modules/.bin/lessc +17 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/node_modules/.bin/parser +17 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/node_modules/.bin/sass +17 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/node_modules/.bin/stylus +17 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/package.json +34 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/babelUtils.ts +423 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/compileScript.ts +1911 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/compileStyle.ts +147 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/compileTemplate.ts +205 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/cssVars.ts +179 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/index.ts +31 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/parse.ts +129 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/parseComponent.ts +220 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/prefixIdentifiers.ts +82 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/rewriteDefault.ts +115 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/stylePlugins/scoped.ts +203 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/stylePlugins/trim.ts +18 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/stylePreprocessors.ts +135 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/templateCompilerModules/assetUrl.ts +84 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/templateCompilerModules/srcset.ts +76 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/templateCompilerModules/utils.ts +86 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/types.ts +69 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/src/warn.ts +16 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap +925 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/__snapshots__/cssVars.spec.ts.snap +189 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/compileScript.spec.ts +1594 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/compileStyle.spec.ts +203 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/compileTemplate.spec.ts +258 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/cssVars.spec.ts +247 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/parseComponent.spec.ts +269 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/prefixIdentifiers.spec.ts +97 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/rewriteDefault.spec.ts +245 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/stylePluginScoped.spec.ts +137 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/tsconfig.json +7 -0
- package/vue2/node_modules/vue/packages/compiler-sfc/test/util.ts +35 -0
- package/vue2/node_modules/vue/src/compiler/codeframe.ts +52 -0
- package/vue2/node_modules/vue/src/compiler/codegen/events.ts +170 -0
- package/vue2/node_modules/vue/src/compiler/codegen/index.ts +668 -0
- package/vue2/node_modules/vue/src/compiler/create-compiler.ts +83 -0
- package/vue2/node_modules/vue/src/compiler/directives/bind.ts +9 -0
- package/vue2/node_modules/vue/src/compiler/directives/index.ts +9 -0
- package/vue2/node_modules/vue/src/compiler/directives/model.ts +145 -0
- package/vue2/node_modules/vue/src/compiler/directives/on.ts +9 -0
- package/vue2/node_modules/vue/src/compiler/error-detector.ts +158 -0
- package/vue2/node_modules/vue/src/compiler/helpers.ts +243 -0
- package/vue2/node_modules/vue/src/compiler/index.ts +24 -0
- package/vue2/node_modules/vue/src/compiler/optimizer.ts +135 -0
- package/vue2/node_modules/vue/src/compiler/parser/entity-decoder.ts +9 -0
- package/vue2/node_modules/vue/src/compiler/parser/filter-parser.ts +116 -0
- package/vue2/node_modules/vue/src/compiler/parser/html-parser.ts +341 -0
- package/vue2/node_modules/vue/src/compiler/parser/index.ts +999 -0
- package/vue2/node_modules/vue/src/compiler/parser/text-parser.ts +52 -0
- package/vue2/node_modules/vue/src/compiler/to-function.ts +119 -0
- package/vue2/node_modules/vue/src/core/components/index.ts +5 -0
- package/vue2/node_modules/vue/src/core/components/keep-alive.ts +165 -0
- package/vue2/node_modules/vue/src/core/config.ts +128 -0
- package/vue2/node_modules/vue/src/core/global-api/assets.ts +35 -0
- package/vue2/node_modules/vue/src/core/global-api/extend.ts +94 -0
- package/vue2/node_modules/vue/src/core/global-api/index.ts +68 -0
- package/vue2/node_modules/vue/src/core/global-api/mixin.ts +9 -0
- package/vue2/node_modules/vue/src/core/global-api/use.ts +23 -0
- package/vue2/node_modules/vue/src/core/index.ts +27 -0
- package/vue2/node_modules/vue/src/core/instance/events.ts +160 -0
- package/vue2/node_modules/vue/src/core/instance/index.ts +27 -0
- package/vue2/node_modules/vue/src/core/instance/init.ts +140 -0
- package/vue2/node_modules/vue/src/core/instance/inject.ts +80 -0
- package/vue2/node_modules/vue/src/core/instance/lifecycle.ts +415 -0
- package/vue2/node_modules/vue/src/core/instance/proxy.ts +97 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/bind-dynamic-keys.ts +36 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/bind-object-listeners.ts +18 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/bind-object-props.ts +59 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/check-keycodes.ts +33 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/index.ts +31 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/render-list.ts +49 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/render-slot.ts +39 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/render-static.ts +57 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/resolve-filter.ts +8 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/resolve-scoped-slots.ts +30 -0
- package/vue2/node_modules/vue/src/core/instance/render-helpers/resolve-slots.ts +51 -0
- package/vue2/node_modules/vue/src/core/instance/render.ts +173 -0
- package/vue2/node_modules/vue/src/core/instance/state.ts +387 -0
- package/vue2/node_modules/vue/src/core/observer/array.ts +54 -0
- package/vue2/node_modules/vue/src/core/observer/dep.ts +108 -0
- package/vue2/node_modules/vue/src/core/observer/index.ts +338 -0
- package/vue2/node_modules/vue/src/core/observer/scheduler.ts +199 -0
- package/vue2/node_modules/vue/src/core/observer/traverse.ts +47 -0
- package/vue2/node_modules/vue/src/core/observer/watcher.ts +278 -0
- package/vue2/node_modules/vue/src/core/util/debug.ts +105 -0
- package/vue2/node_modules/vue/src/core/util/env.ts +93 -0
- package/vue2/node_modules/vue/src/core/util/error.ts +81 -0
- package/vue2/node_modules/vue/src/core/util/index.ts +9 -0
- package/vue2/node_modules/vue/src/core/util/lang.ts +45 -0
- package/vue2/node_modules/vue/src/core/util/next-tick.ts +117 -0
- package/vue2/node_modules/vue/src/core/util/options.ts +489 -0
- package/vue2/node_modules/vue/src/core/util/perf.ts +28 -0
- package/vue2/node_modules/vue/src/core/util/props.ts +254 -0
- package/vue2/node_modules/vue/src/core/vdom/create-component.ts +275 -0
- package/vue2/node_modules/vue/src/core/vdom/create-element.ts +172 -0
- package/vue2/node_modules/vue/src/core/vdom/create-functional-component.ts +180 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/extract-props.ts +75 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/get-first-component-child.ts +16 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/index.ts +7 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/merge-hook.ts +40 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/normalize-children.ts +99 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/normalize-scoped-slots.ts +97 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/resolve-async-component.ts +157 -0
- package/vue2/node_modules/vue/src/core/vdom/helpers/update-listeners.ts +101 -0
- package/vue2/node_modules/vue/src/core/vdom/modules/directives.ts +137 -0
- package/vue2/node_modules/vue/src/core/vdom/modules/index.ts +4 -0
- package/vue2/node_modules/vue/src/core/vdom/modules/template-ref.ts +94 -0
- package/vue2/node_modules/vue/src/core/vdom/patch.ts +904 -0
- package/vue2/node_modules/vue/src/core/vdom/vnode.ts +119 -0
- package/vue2/node_modules/vue/src/global.d.ts +17 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/directives/html.ts +8 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/directives/index.ts +9 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/directives/model.ts +181 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/directives/text.ts +8 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/index.ts +6 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/modules/class.ts +44 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/modules/index.ts +5 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/modules/model.ts +89 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/modules/style.ts +47 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/options.ts +25 -0
- package/vue2/node_modules/vue/src/platforms/web/compiler/util.ts +22 -0
- package/vue2/node_modules/vue/src/platforms/web/entry-compiler.ts +4 -0
- package/vue2/node_modules/vue/src/platforms/web/entry-runtime-esm.ts +5 -0
- package/vue2/node_modules/vue/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
- package/vue2/node_modules/vue/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
- package/vue2/node_modules/vue/src/platforms/web/entry-runtime.ts +7 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/class-util.ts +61 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/components/index.ts +7 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/components/transition-group.ts +204 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/components/transition.ts +205 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/directives/index.ts +7 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/directives/model.ts +148 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/directives/show.ts +61 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/index.ts +75 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/modules/attrs.ts +115 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/modules/class.ts +37 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/modules/dom-props.ts +123 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/modules/events.ts +127 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/modules/index.ts +8 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/modules/style.ts +104 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/modules/transition.ts +341 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/node-ops.ts +66 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/patch.ts +10 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime/transition-util.ts +215 -0
- package/vue2/node_modules/vue/src/platforms/web/runtime-with-compiler.ts +110 -0
- package/vue2/node_modules/vue/src/platforms/web/util/attrs.ts +58 -0
- package/vue2/node_modules/vue/src/platforms/web/util/class.ts +87 -0
- package/vue2/node_modules/vue/src/platforms/web/util/compat.ts +16 -0
- package/vue2/node_modules/vue/src/platforms/web/util/element.ts +76 -0
- package/vue2/node_modules/vue/src/platforms/web/util/index.ts +21 -0
- package/vue2/node_modules/vue/src/platforms/web/util/style.ts +71 -0
- package/vue2/node_modules/vue/src/shared/constants.ts +20 -0
- package/vue2/node_modules/vue/src/shared/util.ts +372 -0
- package/vue2/node_modules/vue/src/v3/apiAsyncComponent.ts +117 -0
- package/vue2/node_modules/vue/src/v3/apiInject.ts +71 -0
- package/vue2/node_modules/vue/src/v3/apiLifecycle.ts +68 -0
- package/vue2/node_modules/vue/src/v3/apiSetup.ts +246 -0
- package/vue2/node_modules/vue/src/v3/apiWatch.ts +349 -0
- package/vue2/node_modules/vue/src/v3/currentInstance.ts +23 -0
- package/vue2/node_modules/vue/src/v3/debug.ts +21 -0
- package/vue2/node_modules/vue/src/v3/h.ts +18 -0
- package/vue2/node_modules/vue/src/v3/index.ts +96 -0
- package/vue2/node_modules/vue/src/v3/reactivity/computed.ts +100 -0
- package/vue2/node_modules/vue/src/v3/reactivity/effect.ts +20 -0
- package/vue2/node_modules/vue/src/v3/reactivity/effectScope.ts +137 -0
- package/vue2/node_modules/vue/src/v3/reactivity/operations.ts +14 -0
- package/vue2/node_modules/vue/src/v3/reactivity/reactive.ts +137 -0
- package/vue2/node_modules/vue/src/v3/reactivity/readonly.ts +127 -0
- package/vue2/node_modules/vue/src/v3/reactivity/ref.ts +296 -0
- package/vue2/node_modules/vue/src/v3/sfc-helpers/useCssModule.ts +24 -0
- package/vue2/node_modules/vue/src/v3/sfc-helpers/useCssVars.ts +34 -0
- package/vue2/package.json +49 -0
- package/vue2/src/blocks/BaseText.vue +25 -0
- package/vue2/src/blocks/button/button.vue +68 -0
- package/vue2/src/blocks/button/component-info.ts +35 -0
- package/vue2/src/blocks/columns/columns.vue +238 -0
- package/vue2/src/blocks/columns/component-info.ts +219 -0
- package/vue2/src/blocks/custom-code/component-info.ts +24 -0
- package/vue2/src/blocks/custom-code/custom-code.vue +88 -0
- package/vue2/src/blocks/embed/component-info.ts +38 -0
- package/vue2/src/blocks/embed/embed.vue +71 -0
- package/vue2/src/blocks/embed/helpers.ts +2 -0
- package/vue2/src/blocks/form/component-info.ts +233 -0
- package/vue2/src/blocks/form/form.vue +7 -0
- package/vue2/src/blocks/fragment/component-info.ts +8 -0
- package/vue2/src/blocks/fragment/fragment.vue +19 -0
- package/vue2/src/blocks/helpers.ts +43 -0
- package/vue2/src/blocks/image/component-info.ts +124 -0
- package/vue2/src/blocks/image/image.helpers.ts +47 -0
- package/vue2/src/blocks/image/image.vue +174 -0
- package/vue2/src/blocks/img/component-info.ts +16 -0
- package/vue2/src/blocks/img/img.vue +59 -0
- package/vue2/src/blocks/input/component-info.ts +47 -0
- package/vue2/src/blocks/input/input.vue +52 -0
- package/vue2/src/blocks/raw-text/component-info.ts +11 -0
- package/vue2/src/blocks/raw-text/raw-text.vue +35 -0
- package/vue2/src/blocks/section/component-info.ts +41 -0
- package/vue2/src/blocks/section/section.vue +47 -0
- package/vue2/src/blocks/select/component-info.ts +44 -0
- package/vue2/src/blocks/select/select.vue +50 -0
- package/vue2/src/blocks/submit-button/component-info.ts +27 -0
- package/vue2/src/blocks/submit-button/submit-button.vue +34 -0
- package/vue2/src/blocks/symbol/component-info.ts +35 -0
- package/vue2/src/blocks/symbol/symbol.helpers.ts +47 -0
- package/vue2/src/blocks/symbol/symbol.vue +143 -0
- package/vue2/src/blocks/text/component-info.ts +20 -0
- package/vue2/src/blocks/text/text.vue +23 -0
- package/vue2/src/blocks/textarea/component-info.ts +38 -0
- package/vue2/src/blocks/textarea/textarea.vue +38 -0
- package/vue2/src/blocks/video/component-info.ts +83 -0
- package/vue2/src/blocks/video/video.vue +105 -0
- package/vue2/src/components/block/block.helpers.ts +89 -0
- package/vue2/src/components/block/block.vue +203 -0
- package/vue2/src/components/block/components/block-styles.vue +110 -0
- package/vue2/src/components/block/components/block-wrapper.vue +83 -0
- package/vue2/src/components/block/components/component-ref/component-ref.helpers.ts +52 -0
- package/vue2/src/components/block/components/component-ref/component-ref.vue +97 -0
- package/vue2/src/components/block/components/interactive-element.vue +48 -0
- package/vue2/src/components/block/components/repeated-block.vue +51 -0
- package/vue2/src/components/block/types.ts +6 -0
- package/vue2/src/components/blocks/blocks-wrapper.vue +91 -0
- package/vue2/src/components/blocks/blocks.vue +99 -0
- package/vue2/src/components/content/components/enable-editor.vue +418 -0
- package/vue2/src/components/content/components/styles.helpers.ts +77 -0
- package/vue2/src/components/content/components/styles.vue +60 -0
- package/vue2/src/components/content/content.helpers.ts +42 -0
- package/vue2/src/components/content/content.types.ts +23 -0
- package/vue2/src/components/content/content.vue +205 -0
- package/vue2/src/components/content/index.ts +1 -0
- package/vue2/src/components/content/wrap-component-ref.ts +6 -0
- package/vue2/src/components/content-variants/content-variants.types.ts +20 -0
- package/vue2/src/components/content-variants/content-variants.vue +177 -0
- package/vue2/src/components/content-variants/helpers.ts +207 -0
- package/vue2/src/components/inlined-script.vue +18 -0
- package/vue2/src/components/inlined-styles.vue +18 -0
- package/vue2/src/constants/builder-registered-components.ts +62 -0
- package/vue2/src/constants/device-sizes.ts +59 -0
- package/vue2/src/constants/sdk-version.ts +1 -0
- package/vue2/src/constants/target.ts +4 -0
- package/vue2/src/context/builder.context.ts +16 -0
- package/vue2/src/context/components.context.ts +6 -0
- package/vue2/src/context/types.ts +36 -0
- package/vue2/src/functions/apply-patch-with-mutation.ts +61 -0
- package/vue2/src/functions/camel-to-kebab-case.ts +1 -0
- package/vue2/src/functions/deopt.ts +6 -0
- package/vue2/src/functions/evaluate/browser-runtime/browser.ts +41 -0
- package/vue2/src/functions/evaluate/browser-runtime/index.ts +1 -0
- package/vue2/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
- package/vue2/src/functions/evaluate/edge-runtime/edge-runtime.ts +96 -0
- package/vue2/src/functions/evaluate/edge-runtime/index.ts +1 -0
- package/vue2/src/functions/evaluate/evaluate.ts +66 -0
- package/vue2/src/functions/evaluate/helpers.ts +32 -0
- package/vue2/src/functions/evaluate/index.ts +1 -0
- package/vue2/src/functions/evaluate/node-runtime/index.ts +1 -0
- package/vue2/src/functions/evaluate/placeholder-runtime.ts +4 -0
- package/vue2/src/functions/event-handler-name.ts +1 -0
- package/vue2/src/functions/extract-text-styles.ts +24 -0
- package/vue2/src/functions/fast-clone.ts +4 -0
- package/vue2/src/functions/fetch-builder-props.ts +62 -0
- package/vue2/src/functions/get-block-actions-handler.ts +16 -0
- package/vue2/src/functions/get-block-actions.ts +36 -0
- package/vue2/src/functions/get-block-component-options.ts +11 -0
- package/vue2/src/functions/get-block-properties.ts +82 -0
- package/vue2/src/functions/get-builder-search-params/index.ts +40 -0
- package/vue2/src/functions/get-content/generate-content-url.ts +45 -0
- package/vue2/src/functions/get-content/index.ts +110 -0
- package/vue2/src/functions/get-content/types.ts +62 -0
- package/vue2/src/functions/get-fetch.ts +11 -0
- package/vue2/src/functions/get-global-this.ts +16 -0
- package/vue2/src/functions/get-processed-block.ts +69 -0
- package/vue2/src/functions/get-react-native-block-styles.ts +27 -0
- package/vue2/src/functions/is-browser.ts +3 -0
- package/vue2/src/functions/is-edge-runtime.ts +9 -0
- package/vue2/src/functions/is-editing.ts +5 -0
- package/vue2/src/functions/is-iframe.ts +4 -0
- package/vue2/src/functions/is-previewing.ts +11 -0
- package/vue2/src/functions/on-change.ts +29 -0
- package/vue2/src/functions/register-component.ts +48 -0
- package/vue2/src/functions/register.ts +44 -0
- package/vue2/src/functions/sanitize-react-native-block-styles.ts +58 -0
- package/vue2/src/functions/set-editor-settings.ts +15 -0
- package/vue2/src/functions/set.ts +14 -0
- package/vue2/src/functions/track/helpers.ts +51 -0
- package/vue2/src/functions/track/index.ts +131 -0
- package/vue2/src/functions/track/interaction.ts +63 -0
- package/vue2/src/functions/transform-block-properties.ts +18 -0
- package/vue2/src/functions/transform-block.ts +6 -0
- package/vue2/src/helpers/ab-tests.ts +166 -0
- package/vue2/src/helpers/canTrack.ts +2 -0
- package/vue2/src/helpers/cookie.ts +81 -0
- package/vue2/src/helpers/css.ts +33 -0
- package/vue2/src/helpers/flatten.ts +19 -0
- package/vue2/src/helpers/localStorage.ts +36 -0
- package/vue2/src/helpers/logger.ts +7 -0
- package/vue2/src/helpers/nullable.ts +2 -0
- package/vue2/src/helpers/preview-lru-cache/get.ts +4 -0
- package/vue2/src/helpers/preview-lru-cache/helpers.ts +0 -0
- package/vue2/src/helpers/preview-lru-cache/init.ts +7 -0
- package/vue2/src/helpers/preview-lru-cache/set.ts +12 -0
- package/vue2/src/helpers/preview-lru-cache/types.ts +0 -0
- package/vue2/src/helpers/sessionId.ts +37 -0
- package/vue2/src/helpers/time.ts +2 -0
- package/vue2/src/helpers/url.ts +15 -0
- package/vue2/src/helpers/uuid.ts +17 -0
- package/vue2/src/helpers/visitorId.ts +37 -0
- package/vue2/src/index-helpers/blocks-exports.ts +20 -0
- package/vue2/src/index-helpers/top-of-file.ts +4 -0
- package/vue2/src/index.ts +8 -0
- package/vue2/src/scripts/init-editing.ts +113 -0
- package/vue2/src/server-index.ts +15 -0
- package/vue2/tsconfig.config.json +8 -0
- package/vue2/tsconfig.json +16 -0
- package/vue2/vite.config.js +31 -0
- package/vue3/css/package.json +4 -0
- package/vue3/node_modules/@types/node/LICENSE +21 -0
- package/vue3/node_modules/@types/node/README.md +16 -0
- package/vue3/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/vue3/node_modules/@types/node/assert.d.ts +962 -0
- package/vue3/node_modules/@types/node/async_hooks.d.ts +497 -0
- package/vue3/node_modules/@types/node/buffer.d.ts +2236 -0
- package/vue3/node_modules/@types/node/child_process.d.ts +1396 -0
- package/vue3/node_modules/@types/node/cluster.d.ts +414 -0
- package/vue3/node_modules/@types/node/console.d.ts +412 -0
- package/vue3/node_modules/@types/node/constants.d.ts +18 -0
- package/vue3/node_modules/@types/node/crypto.d.ts +3869 -0
- package/vue3/node_modules/@types/node/dgram.d.ts +545 -0
- package/vue3/node_modules/@types/node/diagnostics_channel.d.ts +191 -0
- package/vue3/node_modules/@types/node/dns/promises.d.ts +369 -0
- package/vue3/node_modules/@types/node/dns.d.ts +655 -0
- package/vue3/node_modules/@types/node/domain.d.ts +170 -0
- package/vue3/node_modules/@types/node/events.d.ts +641 -0
- package/vue3/node_modules/@types/node/fs/promises.d.ts +1094 -0
- package/vue3/node_modules/@types/node/fs.d.ts +3803 -0
- package/vue3/node_modules/@types/node/globals.d.ts +287 -0
- package/vue3/node_modules/@types/node/globals.global.d.ts +1 -0
- package/vue3/node_modules/@types/node/http.d.ts +1504 -0
- package/vue3/node_modules/@types/node/http2.d.ts +2100 -0
- package/vue3/node_modules/@types/node/https.d.ts +532 -0
- package/vue3/node_modules/@types/node/index.d.ts +131 -0
- package/vue3/node_modules/@types/node/inspector.d.ts +2745 -0
- package/vue3/node_modules/@types/node/module.d.ts +115 -0
- package/vue3/node_modules/@types/node/net.d.ts +828 -0
- package/vue3/node_modules/@types/node/os.d.ts +455 -0
- package/vue3/node_modules/@types/node/package.json +232 -0
- package/vue3/node_modules/@types/node/path.d.ts +191 -0
- package/vue3/node_modules/@types/node/perf_hooks.d.ts +586 -0
- package/vue3/node_modules/@types/node/process.d.ts +1481 -0
- package/vue3/node_modules/@types/node/punycode.d.ts +117 -0
- package/vue3/node_modules/@types/node/querystring.d.ts +131 -0
- package/vue3/node_modules/@types/node/readline.d.ts +543 -0
- package/vue3/node_modules/@types/node/repl.d.ts +424 -0
- package/vue3/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/vue3/node_modules/@types/node/stream/promises.d.ts +42 -0
- package/vue3/node_modules/@types/node/stream/web.d.ts +392 -0
- package/vue3/node_modules/@types/node/stream.d.ts +1363 -0
- package/vue3/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/vue3/node_modules/@types/node/test.d.ts +190 -0
- package/vue3/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/vue3/node_modules/@types/node/timers.d.ts +94 -0
- package/vue3/node_modules/@types/node/tls.d.ts +1019 -0
- package/vue3/node_modules/@types/node/trace_events.d.ts +161 -0
- package/vue3/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/vue3/node_modules/@types/node/ts4.8/assert.d.ts +962 -0
- package/vue3/node_modules/@types/node/ts4.8/async_hooks.d.ts +497 -0
- package/vue3/node_modules/@types/node/ts4.8/buffer.d.ts +2236 -0
- package/vue3/node_modules/@types/node/ts4.8/child_process.d.ts +1396 -0
- package/vue3/node_modules/@types/node/ts4.8/cluster.d.ts +414 -0
- package/vue3/node_modules/@types/node/ts4.8/console.d.ts +412 -0
- package/vue3/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
- package/vue3/node_modules/@types/node/ts4.8/crypto.d.ts +3866 -0
- package/vue3/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
- package/vue3/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +191 -0
- package/vue3/node_modules/@types/node/ts4.8/dns/promises.d.ts +368 -0
- package/vue3/node_modules/@types/node/ts4.8/dns.d.ts +654 -0
- package/vue3/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/vue3/node_modules/@types/node/ts4.8/events.d.ts +641 -0
- package/vue3/node_modules/@types/node/ts4.8/fs/promises.d.ts +1094 -0
- package/vue3/node_modules/@types/node/ts4.8/fs.d.ts +3802 -0
- package/vue3/node_modules/@types/node/ts4.8/globals.d.ts +284 -0
- package/vue3/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/vue3/node_modules/@types/node/ts4.8/http.d.ts +1503 -0
- package/vue3/node_modules/@types/node/ts4.8/http2.d.ts +2100 -0
- package/vue3/node_modules/@types/node/ts4.8/https.d.ts +532 -0
- package/vue3/node_modules/@types/node/ts4.8/index.d.ts +86 -0
- package/vue3/node_modules/@types/node/ts4.8/inspector.d.ts +2745 -0
- package/vue3/node_modules/@types/node/ts4.8/module.d.ts +115 -0
- package/vue3/node_modules/@types/node/ts4.8/net.d.ts +828 -0
- package/vue3/node_modules/@types/node/ts4.8/os.d.ts +456 -0
- package/vue3/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/vue3/node_modules/@types/node/ts4.8/perf_hooks.d.ts +586 -0
- package/vue3/node_modules/@types/node/ts4.8/process.d.ts +1481 -0
- package/vue3/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/vue3/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
- package/vue3/node_modules/@types/node/ts4.8/readline.d.ts +543 -0
- package/vue3/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
- package/vue3/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/vue3/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
- package/vue3/node_modules/@types/node/ts4.8/stream/web.d.ts +392 -0
- package/vue3/node_modules/@types/node/ts4.8/stream.d.ts +1363 -0
- package/vue3/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/vue3/node_modules/@types/node/ts4.8/test.d.ts +190 -0
- package/vue3/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/vue3/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
- package/vue3/node_modules/@types/node/ts4.8/tls.d.ts +1019 -0
- package/vue3/node_modules/@types/node/ts4.8/trace_events.d.ts +161 -0
- package/vue3/node_modules/@types/node/ts4.8/tty.d.ts +204 -0
- package/vue3/node_modules/@types/node/ts4.8/url.d.ts +855 -0
- package/vue3/node_modules/@types/node/ts4.8/util.d.ts +1594 -0
- package/vue3/node_modules/@types/node/ts4.8/v8.d.ts +472 -0
- package/vue3/node_modules/@types/node/ts4.8/vm.d.ts +507 -0
- package/vue3/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/vue3/node_modules/@types/node/ts4.8/worker_threads.d.ts +649 -0
- package/vue3/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/vue3/node_modules/@types/node/tty.d.ts +204 -0
- package/vue3/node_modules/@types/node/url.d.ts +855 -0
- package/vue3/node_modules/@types/node/util.d.ts +1594 -0
- package/vue3/node_modules/@types/node/v8.d.ts +472 -0
- package/vue3/node_modules/@types/node/vm.d.ts +507 -0
- package/vue3/node_modules/@types/node/wasi.d.ts +158 -0
- package/vue3/node_modules/@types/node/worker_threads.d.ts +649 -0
- package/vue3/node_modules/@types/node/zlib.d.ts +517 -0
- package/vue3/node_modules/@vitejs/plugin-vue/LICENSE +21 -0
- package/vue3/node_modules/@vitejs/plugin-vue/README.md +171 -0
- package/vue3/node_modules/@vitejs/plugin-vue/package.json +51 -0
- package/vue3/node_modules/@vue/server-renderer/LICENSE +21 -0
- package/vue3/node_modules/@vue/server-renderer/README.md +178 -0
- package/vue3/node_modules/@vue/server-renderer/index.js +7 -0
- package/vue3/node_modules/@vue/server-renderer/package.json +41 -0
- package/vue3/node_modules/@vue/tsconfig/README.md +31 -0
- package/vue3/node_modules/@vue/tsconfig/package.json +35 -0
- package/vue3/node_modules/@vue/tsconfig/tsconfig.json +40 -0
- package/vue3/node_modules/@vue/tsconfig/tsconfig.node.json +17 -0
- package/vue3/node_modules/@vue/tsconfig/tsconfig.web.json +19 -0
- package/vue3/node_modules/esbuild/LICENSE.md +21 -0
- package/vue3/node_modules/esbuild/README.md +3 -0
- package/vue3/node_modules/esbuild/bin/esbuild +212 -0
- package/vue3/node_modules/esbuild/install.js +245 -0
- package/vue3/node_modules/esbuild/package.json +42 -0
- package/vue3/node_modules/vite/LICENSE.md +3450 -0
- package/vue3/node_modules/vite/README.md +20 -0
- package/vue3/node_modules/vite/bin/openChrome.applescript +95 -0
- package/vue3/node_modules/vite/bin/vite.js +61 -0
- package/vue3/node_modules/vite/client.d.ts +248 -0
- package/vue3/node_modules/vite/index.cjs +34 -0
- package/vue3/node_modules/vite/package.json +154 -0
- package/vue3/node_modules/vite-plugin-dts/LICENSE +21 -0
- package/vue3/node_modules/vite-plugin-dts/README.md +368 -0
- package/vue3/node_modules/vite-plugin-dts/README.zh-CN.md +368 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/LICENSE +21 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/README.md +36 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/bin/vue-tsc.js +67 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/index.d.ts +16 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/index.js +120 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/shared.d.ts +8 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/out/shared.js +5 -0
- package/vue3/node_modules/vite-plugin-dts/node_modules/vue-tsc/package.json +28 -0
- package/vue3/node_modules/vite-plugin-dts/package.json +103 -0
- package/vue3/node_modules/vue/LICENSE +21 -0
- package/vue3/node_modules/vue/README.md +54 -0
- package/vue3/node_modules/vue/compiler-sfc/index.d.mts +1 -0
- package/vue3/node_modules/vue/compiler-sfc/index.d.ts +1 -0
- package/vue3/node_modules/vue/compiler-sfc/index.js +3 -0
- package/vue3/node_modules/vue/compiler-sfc/index.mjs +3 -0
- package/vue3/node_modules/vue/compiler-sfc/package.json +4 -0
- package/vue3/node_modules/vue/compiler-sfc/register-ts.js +5 -0
- package/vue3/node_modules/vue/index.js +7 -0
- package/vue3/node_modules/vue/index.mjs +1 -0
- package/vue3/node_modules/vue/jsx-runtime/index.d.ts +29 -0
- package/vue3/node_modules/vue/jsx-runtime/index.js +15 -0
- package/vue3/node_modules/vue/jsx-runtime/index.mjs +17 -0
- package/vue3/node_modules/vue/jsx-runtime/package.json +5 -0
- package/vue3/node_modules/vue/jsx.d.ts +26 -0
- package/vue3/node_modules/vue/macros-global.d.ts +19 -0
- package/vue3/node_modules/vue/macros.d.ts +112 -0
- package/vue3/node_modules/vue/package.json +103 -0
- package/vue3/node_modules/vue/ref-macros.d.ts +2 -0
- package/vue3/node_modules/vue/server-renderer/index.d.mts +1 -0
- package/vue3/node_modules/vue/server-renderer/index.d.ts +1 -0
- package/vue3/node_modules/vue/server-renderer/index.js +1 -0
- package/vue3/node_modules/vue/server-renderer/index.mjs +1 -0
- package/vue3/node_modules/vue/server-renderer/package.json +4 -0
- package/vue3/node_modules/vue-tsc/LICENSE +21 -0
- package/vue3/node_modules/vue-tsc/README.md +44 -0
- package/vue3/node_modules/vue-tsc/bin/vue-tsc.js +48 -0
- package/vue3/node_modules/vue-tsc/out/proxy.d.ts +4 -0
- package/vue3/node_modules/vue-tsc/out/proxy.js +110 -0
- package/vue3/node_modules/vue-tsc/package.json +26 -0
- package/vue3/package.json +48 -0
- package/vue3/src/blocks/BaseText.vue +25 -0
- package/vue3/src/blocks/button/button.vue +71 -0
- package/vue3/src/blocks/button/component-info.ts +35 -0
- package/vue3/src/blocks/columns/columns.vue +220 -0
- package/vue3/src/blocks/columns/component-info.ts +219 -0
- package/vue3/src/blocks/custom-code/component-info.ts +24 -0
- package/vue3/src/blocks/custom-code/custom-code.vue +88 -0
- package/vue3/src/blocks/embed/component-info.ts +38 -0
- package/vue3/src/blocks/embed/embed.vue +71 -0
- package/vue3/src/blocks/embed/helpers.ts +2 -0
- package/vue3/src/blocks/form/component-info.ts +233 -0
- package/vue3/src/blocks/form/form.vue +7 -0
- package/vue3/src/blocks/fragment/component-info.ts +8 -0
- package/vue3/src/blocks/fragment/fragment.vue +19 -0
- package/vue3/src/blocks/helpers.ts +43 -0
- package/vue3/src/blocks/image/component-info.ts +124 -0
- package/vue3/src/blocks/image/image.helpers.ts +47 -0
- package/vue3/src/blocks/image/image.vue +172 -0
- package/vue3/src/blocks/img/component-info.ts +16 -0
- package/vue3/src/blocks/img/img.vue +59 -0
- package/vue3/src/blocks/input/component-info.ts +47 -0
- package/vue3/src/blocks/input/input.vue +52 -0
- package/vue3/src/blocks/raw-text/component-info.ts +11 -0
- package/vue3/src/blocks/raw-text/raw-text.vue +35 -0
- package/vue3/src/blocks/section/component-info.ts +41 -0
- package/vue3/src/blocks/section/section.vue +47 -0
- package/vue3/src/blocks/select/component-info.ts +44 -0
- package/vue3/src/blocks/select/select.vue +46 -0
- package/vue3/src/blocks/submit-button/component-info.ts +27 -0
- package/vue3/src/blocks/submit-button/submit-button.vue +34 -0
- package/vue3/src/blocks/symbol/component-info.ts +35 -0
- package/vue3/src/blocks/symbol/symbol.helpers.ts +47 -0
- package/vue3/src/blocks/symbol/symbol.vue +134 -0
- package/vue3/src/blocks/text/component-info.ts +20 -0
- package/vue3/src/blocks/text/text.vue +23 -0
- package/vue3/src/blocks/textarea/component-info.ts +38 -0
- package/vue3/src/blocks/textarea/textarea.vue +38 -0
- package/vue3/src/blocks/video/component-info.ts +83 -0
- package/vue3/src/blocks/video/video.vue +105 -0
- package/vue3/src/components/block/block.helpers.ts +89 -0
- package/vue3/src/components/block/block.vue +214 -0
- package/vue3/src/components/block/components/block-styles.vue +100 -0
- package/vue3/src/components/block/components/block-wrapper.vue +86 -0
- package/vue3/src/components/block/components/component-ref/component-ref.helpers.ts +52 -0
- package/vue3/src/components/block/components/component-ref/component-ref.vue +74 -0
- package/vue3/src/components/block/components/interactive-element.vue +48 -0
- package/vue3/src/components/block/components/repeated-block.vue +51 -0
- package/vue3/src/components/block/types.ts +6 -0
- package/vue3/src/components/blocks/blocks-wrapper.vue +91 -0
- package/vue3/src/components/blocks/blocks.vue +78 -0
- package/vue3/src/components/content/components/enable-editor.vue +419 -0
- package/vue3/src/components/content/components/styles.helpers.ts +77 -0
- package/vue3/src/components/content/components/styles.vue +51 -0
- package/vue3/src/components/content/content.helpers.ts +42 -0
- package/vue3/src/components/content/content.types.ts +23 -0
- package/vue3/src/components/content/content.vue +169 -0
- package/vue3/src/components/content/index.ts +1 -0
- package/vue3/src/components/content/wrap-component-ref.ts +7 -0
- package/vue3/src/components/content-variants/content-variants.types.ts +20 -0
- package/vue3/src/components/content-variants/content-variants.vue +151 -0
- package/vue3/src/components/content-variants/helpers.ts +207 -0
- package/vue3/src/components/inlined-script.vue +12 -0
- package/vue3/src/components/inlined-styles.vue +12 -0
- package/vue3/src/constants/builder-registered-components.ts +62 -0
- package/vue3/src/constants/device-sizes.ts +59 -0
- package/vue3/src/constants/sdk-version.ts +1 -0
- package/vue3/src/constants/target.ts +4 -0
- package/vue3/src/context/builder.context.ts +16 -0
- package/vue3/src/context/components.context.ts +6 -0
- package/vue3/src/context/types.ts +36 -0
- package/vue3/src/functions/apply-patch-with-mutation.ts +61 -0
- package/vue3/src/functions/camel-to-kebab-case.ts +1 -0
- package/vue3/src/functions/deopt.ts +6 -0
- package/vue3/src/functions/evaluate/browser-runtime/browser.ts +41 -0
- package/vue3/src/functions/evaluate/browser-runtime/index.ts +1 -0
- package/vue3/src/functions/evaluate/edge-runtime/acorn-interpreter.ts +2891 -0
- package/vue3/src/functions/evaluate/edge-runtime/edge-runtime.ts +96 -0
- package/vue3/src/functions/evaluate/edge-runtime/index.ts +1 -0
- package/vue3/src/functions/evaluate/evaluate.ts +66 -0
- package/vue3/src/functions/evaluate/helpers.ts +32 -0
- package/vue3/src/functions/evaluate/index.ts +1 -0
- package/vue3/src/functions/evaluate/node-runtime/index.ts +1 -0
- package/vue3/src/functions/evaluate/placeholder-runtime.ts +4 -0
- package/vue3/src/functions/event-handler-name.ts +1 -0
- package/vue3/src/functions/extract-text-styles.ts +24 -0
- package/vue3/src/functions/fast-clone.ts +4 -0
- package/vue3/src/functions/fetch-builder-props.ts +62 -0
- package/vue3/src/functions/get-block-actions-handler.ts +16 -0
- package/vue3/src/functions/get-block-actions.ts +36 -0
- package/vue3/src/functions/get-block-component-options.ts +11 -0
- package/vue3/src/functions/get-block-properties.ts +82 -0
- package/vue3/src/functions/get-builder-search-params/index.ts +40 -0
- package/vue3/src/functions/get-content/generate-content-url.ts +45 -0
- package/vue3/src/functions/get-content/index.ts +110 -0
- package/vue3/src/functions/get-content/types.ts +62 -0
- package/vue3/src/functions/get-fetch.ts +11 -0
- package/vue3/src/functions/get-global-this.ts +16 -0
- package/vue3/src/functions/get-processed-block.ts +69 -0
- package/vue3/src/functions/get-react-native-block-styles.ts +27 -0
- package/vue3/src/functions/is-browser.ts +3 -0
- package/vue3/src/functions/is-edge-runtime.ts +9 -0
- package/vue3/src/functions/is-editing.ts +5 -0
- package/vue3/src/functions/is-iframe.ts +4 -0
- package/vue3/src/functions/is-previewing.ts +11 -0
- package/vue3/src/functions/on-change.ts +29 -0
- package/vue3/src/functions/register-component.ts +48 -0
- package/vue3/src/functions/register.ts +44 -0
- package/vue3/src/functions/sanitize-react-native-block-styles.ts +58 -0
- package/vue3/src/functions/set-editor-settings.ts +15 -0
- package/vue3/src/functions/set.ts +14 -0
- package/vue3/src/functions/track/helpers.ts +51 -0
- package/vue3/src/functions/track/index.ts +131 -0
- package/vue3/src/functions/track/interaction.ts +63 -0
- package/vue3/src/functions/transform-block-properties.ts +18 -0
- package/vue3/src/functions/transform-block.ts +6 -0
- package/vue3/src/helpers/ab-tests.ts +166 -0
- package/vue3/src/helpers/canTrack.ts +2 -0
- package/vue3/src/helpers/cookie.ts +81 -0
- package/vue3/src/helpers/css.ts +33 -0
- package/vue3/src/helpers/flatten.ts +19 -0
- package/vue3/src/helpers/localStorage.ts +36 -0
- package/vue3/src/helpers/logger.ts +7 -0
- package/vue3/src/helpers/nullable.ts +2 -0
- package/vue3/src/helpers/preview-lru-cache/get.ts +4 -0
- package/vue3/src/helpers/preview-lru-cache/helpers.ts +0 -0
- package/vue3/src/helpers/preview-lru-cache/init.ts +7 -0
- package/vue3/src/helpers/preview-lru-cache/set.ts +12 -0
- package/vue3/src/helpers/preview-lru-cache/types.ts +0 -0
- package/vue3/src/helpers/sessionId.ts +37 -0
- package/vue3/src/helpers/time.ts +2 -0
- package/vue3/src/helpers/url.ts +15 -0
- package/vue3/src/helpers/uuid.ts +17 -0
- package/vue3/src/helpers/visitorId.ts +37 -0
- package/vue3/src/index-helpers/blocks-exports.ts +20 -0
- package/vue3/src/index-helpers/top-of-file.ts +4 -0
- package/vue3/src/index.ts +8 -0
- package/vue3/src/scripts/init-editing.ts +113 -0
- package/vue3/src/server-index.ts +15 -0
- package/vue3/tsconfig.config.json +8 -0
- package/vue3/tsconfig.json +17 -0
- package/vue3/vite.config.js +31 -0
- package/packages/_vue2/dist/block-styles.2f2d681c.js +0 -78
- package/packages/_vue2/dist/block-styles.e0c362f1.cjs +0 -1
- package/packages/_vue2/dist/block-wrapper.60491ece.cjs +0 -1
- package/packages/_vue2/dist/block-wrapper.675417b1.js +0 -66
- package/packages/_vue2/dist/block.2b1ac86c.cjs +0 -3
- package/packages/_vue2/dist/block.b10ffc8d.js +0 -179
- package/packages/_vue2/dist/blocks-wrapper.1f4e53ec.js +0 -72
- package/packages/_vue2/dist/blocks-wrapper.87c356a1.cjs +0 -1
- package/packages/_vue2/dist/component-ref.d1a3e1db.js +0 -98
- package/packages/_vue2/dist/component-ref.e0e18275.cjs +0 -1
- package/packages/_vue2/dist/content.4dd9bed9.js +0 -913
- package/packages/_vue2/dist/content.e0c272e6.cjs +0 -1
- package/packages/_vue2/dist/css.3b52add0.js +0 -21
- package/packages/_vue2/dist/css.5b6afc6e.cjs +0 -6
- package/packages/_vue2/dist/enable-editor.29678a79.cjs +0 -1
- package/packages/_vue2/dist/enable-editor.c8c377d7.js +0 -427
- package/packages/_vue2/dist/evaluate.585803ce.cjs +0 -1
- package/packages/_vue2/dist/evaluate.b622b309.js +0 -97
- package/packages/_vue2/dist/get-block-actions.17f0418a.js +0 -36
- package/packages/_vue2/dist/get-block-actions.cc26a1a3.cjs +0 -1
- package/packages/_vue2/dist/get-block-properties.3a4c9314.js +0 -48
- package/packages/_vue2/dist/get-block-properties.fbe48fae.cjs +0 -1
- package/packages/_vue2/dist/get-processed-block.5937bfa6.cjs +0 -1
- package/packages/_vue2/dist/get-processed-block.92e6395c.js +0 -53
- package/packages/_vue2/dist/index.04a22940.cjs +0 -32
- package/packages/_vue2/dist/index.835b8ee0.js +0 -1413
- package/packages/_vue2/dist/inlined-script.0c7f9ce3.cjs +0 -1
- package/packages/_vue2/dist/inlined-script.3ec95873.js +0 -23
- package/packages/_vue2/dist/inlined-styles.89ce41e1.cjs +0 -1
- package/packages/_vue2/dist/inlined-styles.ccff7c47.js +0 -23
- package/packages/_vue2/dist/interactive-element.fa779554.js +0 -42
- package/packages/_vue2/dist/interactive-element.fdd261bc.cjs +0 -1
- package/packages/_vue2/dist/non-node-runtime.ddfeed94.cjs +0 -21
- package/packages/_vue2/dist/non-node-runtime.eb7f6595.js +0 -2477
- package/packages/_vue2/dist/repeated-block.3c989659.js +0 -38
- package/packages/_vue2/dist/repeated-block.48fbaaab.cjs +0 -1
- package/packages/_vue2/dist/sdk.cjs +0 -1
- package/packages/_vue2/dist/sdk.d.ts +0 -1
- package/packages/_vue2/dist/sdk.js +0 -29
- package/packages/_vue2/dist/set.87eb0329.cjs +0 -1
- package/packages/_vue2/dist/set.b219ab0e.js +0 -9
- package/packages/_vue2/dist/src/blocks/button/button.vue.d.ts +0 -17
- package/packages/_vue2/dist/src/blocks/button/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/columns/columns.vue.d.ts +0 -44
- package/packages/_vue2/dist/src/blocks/columns/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/custom-code/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/custom-code/custom-code.vue.d.ts +0 -14
- package/packages/_vue2/dist/src/blocks/embed/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/embed/embed.vue.d.ts +0 -18
- package/packages/_vue2/dist/src/blocks/embed/helpers.d.ts +0 -1
- package/packages/_vue2/dist/src/blocks/fragment/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/fragment/fragment.vue.d.ts +0 -7
- package/packages/_vue2/dist/src/blocks/helpers.d.ts +0 -13
- package/packages/_vue2/dist/src/blocks/image/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/image/image.helpers.d.ts +0 -1
- package/packages/_vue2/dist/src/blocks/image/image.vue.d.ts +0 -72
- package/packages/_vue2/dist/src/blocks/img/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/img/img.vue.d.ts +0 -38
- package/packages/_vue2/dist/src/blocks/section/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/section/section.vue.d.ts +0 -22
- package/packages/_vue2/dist/src/blocks/symbol/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/symbol/symbol.helpers.d.ts +0 -14
- package/packages/_vue2/dist/src/blocks/symbol/symbol.vue.d.ts +0 -37
- package/packages/_vue2/dist/src/blocks/text/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/text/text.vue.d.ts +0 -11
- package/packages/_vue2/dist/src/blocks/video/component-info.d.ts +0 -2
- package/packages/_vue2/dist/src/blocks/video/video.vue.d.ts +0 -64
- package/packages/_vue2/dist/src/components/block/block.helpers.d.ts +0 -13
- package/packages/_vue2/dist/src/components/block/block.vue.d.ts +0 -9
- package/packages/_vue2/dist/src/components/block/components/block-styles.vue.d.ts +0 -23
- package/packages/_vue2/dist/src/components/block/components/block-wrapper.vue.d.ts +0 -29
- package/packages/_vue2/dist/src/components/block/components/component-ref/component-ref.helpers.d.ts +0 -30
- package/packages/_vue2/dist/src/components/block/components/component-ref/component-ref.vue.d.ts +0 -2
- package/packages/_vue2/dist/src/components/block/components/interactive-element.vue.d.ts +0 -30
- package/packages/_vue2/dist/src/components/block/components/repeated-block.vue.d.ts +0 -16
- package/packages/_vue2/dist/src/components/block/types.d.ts +0 -6
- package/packages/_vue2/dist/src/components/blocks/blocks-wrapper.vue.d.ts +0 -30
- package/packages/_vue2/dist/src/components/blocks/blocks.vue.d.ts +0 -29
- package/packages/_vue2/dist/src/components/content/components/enable-editor.vue.d.ts +0 -56
- package/packages/_vue2/dist/src/components/content/components/styles.helpers.d.ts +0 -15
- package/packages/_vue2/dist/src/components/content/components/styles.vue.d.ts +0 -16
- package/packages/_vue2/dist/src/components/content/content.helpers.d.ts +0 -7
- package/packages/_vue2/dist/src/components/content/content.types.d.ts +0 -24
- package/packages/_vue2/dist/src/components/content/content.vue.d.ts +0 -26
- package/packages/_vue2/dist/src/components/content/wrap-component-ref.d.ts +0 -6
- package/packages/_vue2/dist/src/components/content-variants/content-variants.types.d.ts +0 -20
- package/packages/_vue2/dist/src/components/content-variants/content-variants.vue.d.ts +0 -50
- package/packages/_vue2/dist/src/components/content-variants/helpers.d.ts +0 -18
- package/packages/_vue2/dist/src/components/inlined-script.vue.d.ts +0 -11
- package/packages/_vue2/dist/src/components/inlined-styles.vue.d.ts +0 -11
- package/packages/_vue2/dist/src/constants/builder-registered-components.d.ts +0 -6
- package/packages/_vue2/dist/src/constants/device-sizes.d.ts +0 -13
- package/packages/_vue2/dist/src/constants/sdk-version.d.ts +0 -1
- package/packages/_vue2/dist/src/constants/target.d.ts +0 -2
- package/packages/_vue2/dist/src/context/builder.context.d.ts +0 -15
- package/packages/_vue2/dist/src/context/components.context.d.ts +0 -7
- package/packages/_vue2/dist/src/context/types.d.ts +0 -35
- package/packages/_vue2/dist/src/functions/camel-to-kebab-case.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/evaluate/browser-runtime/browser.d.ts +0 -4
- package/packages/_vue2/dist/src/functions/evaluate/evaluate.d.ts +0 -6
- package/packages/_vue2/dist/src/functions/evaluate/helpers.d.ts +0 -18
- package/packages/_vue2/dist/src/functions/evaluate/index.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/evaluate/non-node-runtime/acorn-interpreter.d.ts +0 -2
- package/packages/_vue2/dist/src/functions/evaluate/non-node-runtime/index.d.ts +0 -6
- package/packages/_vue2/dist/src/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +0 -2
- package/packages/_vue2/dist/src/functions/event-handler-name.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/extract-text-styles.d.ts +0 -4
- package/packages/_vue2/dist/src/functions/fast-clone.d.ts +0 -4
- package/packages/_vue2/dist/src/functions/fetch-builder-props.d.ts +0 -39
- package/packages/_vue2/dist/src/functions/get-block-actions-handler.d.ts +0 -8
- package/packages/_vue2/dist/src/functions/get-block-actions.d.ts +0 -10
- package/packages/_vue2/dist/src/functions/get-block-component-options.d.ts +0 -2
- package/packages/_vue2/dist/src/functions/get-block-properties.d.ts +0 -6
- package/packages/_vue2/dist/src/functions/get-builder-search-params/index.d.ts +0 -12
- package/packages/_vue2/dist/src/functions/get-content/generate-content-url.d.ts +0 -2
- package/packages/_vue2/dist/src/functions/get-content/index.d.ts +0 -29
- package/packages/_vue2/dist/src/functions/get-content/types.d.ts +0 -51
- package/packages/_vue2/dist/src/functions/get-fetch.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/get-processed-block.d.ts +0 -10
- package/packages/_vue2/dist/src/functions/get-react-native-block-styles.d.ts +0 -7
- package/packages/_vue2/dist/src/functions/is-browser.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/is-editing.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/is-iframe.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/is-non-node-server.d.ts +0 -4
- package/packages/_vue2/dist/src/functions/is-previewing.d.ts +0 -1
- package/packages/_vue2/dist/src/functions/register-component.d.ts +0 -15
- package/packages/_vue2/dist/src/functions/register.d.ts +0 -16
- package/packages/_vue2/dist/src/functions/sanitize-react-native-block-styles.d.ts +0 -3
- package/packages/_vue2/dist/src/functions/set-editor-settings.d.ts +0 -4
- package/packages/_vue2/dist/src/functions/set.d.ts +0 -7
- package/packages/_vue2/dist/src/functions/track/helpers.d.ts +0 -5
- package/packages/_vue2/dist/src/functions/track/index.d.ts +0 -51
- package/packages/_vue2/dist/src/functions/track/interaction.d.ts +0 -13
- package/packages/_vue2/dist/src/functions/transform-block-properties.d.ts +0 -2
- package/packages/_vue2/dist/src/functions/transform-block.d.ts +0 -2
- package/packages/_vue2/dist/src/helpers/ab-tests.d.ts +0 -9
- package/packages/_vue2/dist/src/helpers/canTrack.d.ts +0 -1
- package/packages/_vue2/dist/src/helpers/cookie.d.ts +0 -19
- package/packages/_vue2/dist/src/helpers/css.d.ts +0 -7
- package/packages/_vue2/dist/src/helpers/flatten.d.ts +0 -6
- package/packages/_vue2/dist/src/helpers/localStorage.d.ts +0 -9
- package/packages/_vue2/dist/src/helpers/logger.d.ts +0 -6
- package/packages/_vue2/dist/src/helpers/nullable.d.ts +0 -2
- package/packages/_vue2/dist/src/helpers/preview-lru-cache/get.d.ts +0 -2
- package/packages/_vue2/dist/src/helpers/preview-lru-cache/set.d.ts +0 -7
- package/packages/_vue2/dist/src/helpers/sessionId.d.ts +0 -6
- package/packages/_vue2/dist/src/helpers/url.d.ts +0 -6
- package/packages/_vue2/dist/src/helpers/uuid.d.ts +0 -8
- package/packages/_vue2/dist/src/helpers/visitorId.d.ts +0 -6
- package/packages/_vue2/dist/src/index-helpers/blocks-exports.d.ts +0 -88
- package/packages/_vue2/dist/src/index-helpers/top-of-file.d.ts +0 -1
- package/packages/_vue2/dist/src/index.d.ts +0 -7
- package/packages/_vue2/dist/src/scripts/init-editing.d.ts +0 -6
- package/packages/_vue2/dist/src/server-index.d.ts +0 -15
- package/packages/_vue2/dist/src/types/api-version.d.ts +0 -2
- package/packages/_vue2/dist/src/types/builder-block.d.ts +0 -66
- package/packages/_vue2/dist/src/types/builder-content.d.ts +0 -44
- package/packages/_vue2/dist/src/types/builder-props.d.ts +0 -9
- package/packages/_vue2/dist/src/types/can-track.d.ts +0 -3
- package/packages/_vue2/dist/src/types/components.d.ts +0 -111
- package/packages/_vue2/dist/src/types/deep-partial.d.ts +0 -3
- package/packages/_vue2/dist/src/types/element.d.ts +0 -59
- package/packages/_vue2/dist/src/types/enforced-partials.d.ts +0 -21
- package/packages/_vue2/dist/src/types/input.d.ts +0 -121
- package/packages/_vue2/dist/src/types/targets.d.ts +0 -1
- package/packages/_vue2/dist/src/types/typescript.d.ts +0 -11
- package/packages/_vue2/dist/style.css +0 -1
- package/packages/_vue2/dist/styles.22b87564.js +0 -89
- package/packages/_vue2/dist/styles.a3209286.cjs +0 -31
- package/packages/_vue3/dist/block-wrapper.4abbfa5d.cjs +0 -1
- package/packages/_vue3/dist/block-wrapper.e6a959ca.js +0 -54
- package/packages/_vue3/dist/component-ref.16c18e90.cjs +0 -1
- package/packages/_vue3/dist/component-ref.b3232d22.js +0 -111
- package/packages/_vue3/dist/get-block-actions.48118020.js +0 -79
- package/packages/_vue3/dist/get-block-actions.83a66ea4.cjs +0 -1
- package/packages/_vue3/dist/index.ee80c2d7.js +0 -3262
- package/packages/_vue3/dist/index.f36face2.cjs +0 -69
- package/packages/_vue3/dist/non-node-runtime.15581a63.js +0 -2475
- package/packages/_vue3/dist/non-node-runtime.fb2b33d0.cjs +0 -21
- package/packages/_vue3/dist/repeated-block.33f567b4.cjs +0 -1
- package/packages/_vue3/dist/repeated-block.53ae8c41.js +0 -33
- package/packages/_vue3/dist/sdk.cjs +0 -1
- package/packages/_vue3/dist/sdk.d.ts +0 -1
- package/packages/_vue3/dist/sdk.js +0 -29
- package/packages/_vue3/dist/src/blocks/button/button.vue.d.ts +0 -30
- package/packages/_vue3/dist/src/blocks/button/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/columns/columns.vue.d.ts +0 -69
- package/packages/_vue3/dist/src/blocks/columns/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/custom-code/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/custom-code/custom-code.vue.d.ts +0 -21
- package/packages/_vue3/dist/src/blocks/embed/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/embed/embed.vue.d.ts +0 -22
- package/packages/_vue3/dist/src/blocks/embed/helpers.d.ts +0 -1
- package/packages/_vue3/dist/src/blocks/fragment/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/fragment/fragment.vue.d.ts +0 -7
- package/packages/_vue3/dist/src/blocks/helpers.d.ts +0 -13
- package/packages/_vue3/dist/src/blocks/image/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/image/image.helpers.d.ts +0 -1
- package/packages/_vue3/dist/src/blocks/image/image.vue.d.ts +0 -72
- package/packages/_vue3/dist/src/blocks/img/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/img/img.vue.d.ts +0 -38
- package/packages/_vue3/dist/src/blocks/section/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/section/section.vue.d.ts +0 -22
- package/packages/_vue3/dist/src/blocks/symbol/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/symbol/symbol.helpers.d.ts +0 -14
- package/packages/_vue3/dist/src/blocks/symbol/symbol.vue.d.ts +0 -56
- package/packages/_vue3/dist/src/blocks/text/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/text/text.vue.d.ts +0 -11
- package/packages/_vue3/dist/src/blocks/video/component-info.d.ts +0 -2
- package/packages/_vue3/dist/src/blocks/video/video.vue.d.ts +0 -64
- package/packages/_vue3/dist/src/components/block/block.helpers.d.ts +0 -13
- package/packages/_vue3/dist/src/components/block/block.vue.d.ts +0 -9
- package/packages/_vue3/dist/src/components/block/components/block-styles.vue.d.ts +0 -23
- package/packages/_vue3/dist/src/components/block/components/block-wrapper.vue.d.ts +0 -29
- package/packages/_vue3/dist/src/components/block/components/component-ref/component-ref.helpers.d.ts +0 -30
- package/packages/_vue3/dist/src/components/block/components/component-ref/component-ref.vue.d.ts +0 -2
- package/packages/_vue3/dist/src/components/block/components/interactive-element.vue.d.ts +0 -30
- package/packages/_vue3/dist/src/components/block/components/repeated-block.vue.d.ts +0 -16
- package/packages/_vue3/dist/src/components/block/types.d.ts +0 -6
- package/packages/_vue3/dist/src/components/blocks/blocks-wrapper.vue.d.ts +0 -30
- package/packages/_vue3/dist/src/components/blocks/blocks.vue.d.ts +0 -29
- package/packages/_vue3/dist/src/components/content/components/enable-editor.vue.d.ts +0 -90
- package/packages/_vue3/dist/src/components/content/components/styles.helpers.d.ts +0 -15
- package/packages/_vue3/dist/src/components/content/components/styles.vue.d.ts +0 -16
- package/packages/_vue3/dist/src/components/content/content.helpers.d.ts +0 -7
- package/packages/_vue3/dist/src/components/content/content.types.d.ts +0 -24
- package/packages/_vue3/dist/src/components/content/content.vue.d.ts +0 -69
- package/packages/_vue3/dist/src/components/content/wrap-component-ref.d.ts +0 -6
- package/packages/_vue3/dist/src/components/content-variants/content-variants.types.d.ts +0 -20
- package/packages/_vue3/dist/src/components/content-variants/content-variants.vue.d.ts +0 -73
- package/packages/_vue3/dist/src/components/content-variants/helpers.d.ts +0 -41
- package/packages/_vue3/dist/src/components/inlined-script.vue.d.ts +0 -11
- package/packages/_vue3/dist/src/components/inlined-styles.vue.d.ts +0 -11
- package/packages/_vue3/dist/src/constants/builder-registered-components.d.ts +0 -6
- package/packages/_vue3/dist/src/constants/device-sizes.d.ts +0 -13
- package/packages/_vue3/dist/src/constants/sdk-version.d.ts +0 -1
- package/packages/_vue3/dist/src/constants/target.d.ts +0 -2
- package/packages/_vue3/dist/src/context/builder.context.d.ts +0 -15
- package/packages/_vue3/dist/src/context/components.context.d.ts +0 -7
- package/packages/_vue3/dist/src/context/types.d.ts +0 -35
- package/packages/_vue3/dist/src/functions/camel-to-kebab-case.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/evaluate/browser-runtime/browser.d.ts +0 -4
- package/packages/_vue3/dist/src/functions/evaluate/evaluate.d.ts +0 -6
- package/packages/_vue3/dist/src/functions/evaluate/helpers.d.ts +0 -18
- package/packages/_vue3/dist/src/functions/evaluate/index.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/evaluate/non-node-runtime/acorn-interpreter.d.ts +0 -2
- package/packages/_vue3/dist/src/functions/evaluate/non-node-runtime/index.d.ts +0 -6
- package/packages/_vue3/dist/src/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +0 -2
- package/packages/_vue3/dist/src/functions/event-handler-name.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/extract-text-styles.d.ts +0 -4
- package/packages/_vue3/dist/src/functions/fast-clone.d.ts +0 -4
- package/packages/_vue3/dist/src/functions/fetch-builder-props.d.ts +0 -39
- package/packages/_vue3/dist/src/functions/get-block-actions-handler.d.ts +0 -8
- package/packages/_vue3/dist/src/functions/get-block-actions.d.ts +0 -10
- package/packages/_vue3/dist/src/functions/get-block-component-options.d.ts +0 -2
- package/packages/_vue3/dist/src/functions/get-block-properties.d.ts +0 -6
- package/packages/_vue3/dist/src/functions/get-builder-search-params/index.d.ts +0 -12
- package/packages/_vue3/dist/src/functions/get-content/generate-content-url.d.ts +0 -2
- package/packages/_vue3/dist/src/functions/get-content/index.d.ts +0 -29
- package/packages/_vue3/dist/src/functions/get-content/types.d.ts +0 -51
- package/packages/_vue3/dist/src/functions/get-fetch.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/get-processed-block.d.ts +0 -10
- package/packages/_vue3/dist/src/functions/get-react-native-block-styles.d.ts +0 -7
- package/packages/_vue3/dist/src/functions/is-browser.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/is-editing.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/is-iframe.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/is-non-node-server.d.ts +0 -4
- package/packages/_vue3/dist/src/functions/is-previewing.d.ts +0 -1
- package/packages/_vue3/dist/src/functions/register-component.d.ts +0 -15
- package/packages/_vue3/dist/src/functions/register.d.ts +0 -16
- package/packages/_vue3/dist/src/functions/sanitize-react-native-block-styles.d.ts +0 -3
- package/packages/_vue3/dist/src/functions/set-editor-settings.d.ts +0 -4
- package/packages/_vue3/dist/src/functions/set.d.ts +0 -7
- package/packages/_vue3/dist/src/functions/track/helpers.d.ts +0 -5
- package/packages/_vue3/dist/src/functions/track/index.d.ts +0 -51
- package/packages/_vue3/dist/src/functions/track/interaction.d.ts +0 -13
- package/packages/_vue3/dist/src/functions/transform-block-properties.d.ts +0 -2
- package/packages/_vue3/dist/src/functions/transform-block.d.ts +0 -2
- package/packages/_vue3/dist/src/helpers/ab-tests.d.ts +0 -9
- package/packages/_vue3/dist/src/helpers/canTrack.d.ts +0 -1
- package/packages/_vue3/dist/src/helpers/cookie.d.ts +0 -19
- package/packages/_vue3/dist/src/helpers/css.d.ts +0 -7
- package/packages/_vue3/dist/src/helpers/flatten.d.ts +0 -6
- package/packages/_vue3/dist/src/helpers/localStorage.d.ts +0 -9
- package/packages/_vue3/dist/src/helpers/logger.d.ts +0 -6
- package/packages/_vue3/dist/src/helpers/nullable.d.ts +0 -2
- package/packages/_vue3/dist/src/helpers/preview-lru-cache/get.d.ts +0 -2
- package/packages/_vue3/dist/src/helpers/preview-lru-cache/set.d.ts +0 -7
- package/packages/_vue3/dist/src/helpers/sessionId.d.ts +0 -6
- package/packages/_vue3/dist/src/helpers/url.d.ts +0 -6
- package/packages/_vue3/dist/src/helpers/uuid.d.ts +0 -8
- package/packages/_vue3/dist/src/helpers/visitorId.d.ts +0 -6
- package/packages/_vue3/dist/src/index-helpers/blocks-exports.d.ts +0 -111
- package/packages/_vue3/dist/src/index-helpers/top-of-file.d.ts +0 -1
- package/packages/_vue3/dist/src/index.d.ts +0 -7
- package/packages/_vue3/dist/src/scripts/init-editing.d.ts +0 -6
- package/packages/_vue3/dist/src/server-index.d.ts +0 -15
- package/packages/_vue3/dist/src/types/api-version.d.ts +0 -2
- package/packages/_vue3/dist/src/types/builder-block.d.ts +0 -66
- package/packages/_vue3/dist/src/types/builder-content.d.ts +0 -44
- package/packages/_vue3/dist/src/types/builder-props.d.ts +0 -9
- package/packages/_vue3/dist/src/types/can-track.d.ts +0 -3
- package/packages/_vue3/dist/src/types/components.d.ts +0 -111
- package/packages/_vue3/dist/src/types/deep-partial.d.ts +0 -3
- package/packages/_vue3/dist/src/types/element.d.ts +0 -59
- package/packages/_vue3/dist/src/types/enforced-partials.d.ts +0 -21
- package/packages/_vue3/dist/src/types/input.d.ts +0 -121
- package/packages/_vue3/dist/src/types/targets.d.ts +0 -1
- package/packages/_vue3/dist/src/types/typescript.d.ts +0 -11
- package/packages/_vue3/dist/style.css +0 -1
- /package/{packages/_vue2/dist → vue2}/env.d.ts +0 -0
- /package/{packages/_vue3/dist → vue3}/env.d.ts +0 -0
|
@@ -0,0 +1,1911 @@
|
|
|
1
|
+
import MagicString from 'magic-string'
|
|
2
|
+
import LRU from 'lru-cache'
|
|
3
|
+
import { walkIdentifiers, isFunctionType } from './babelUtils'
|
|
4
|
+
import { BindingMetadata, BindingTypes } from './types'
|
|
5
|
+
import { SFCDescriptor, SFCScriptBlock } from './parseComponent'
|
|
6
|
+
import {
|
|
7
|
+
parse as _parse,
|
|
8
|
+
parseExpression,
|
|
9
|
+
ParserOptions,
|
|
10
|
+
ParserPlugin
|
|
11
|
+
} from '@babel/parser'
|
|
12
|
+
import { generateCodeFrame } from 'compiler/codeframe'
|
|
13
|
+
import { camelize, capitalize, isBuiltInTag, makeMap } from 'shared/util'
|
|
14
|
+
import { parseHTML } from 'compiler/parser/html-parser'
|
|
15
|
+
import { baseOptions as webCompilerOptions } from 'web/compiler/options'
|
|
16
|
+
import {
|
|
17
|
+
Node,
|
|
18
|
+
Declaration,
|
|
19
|
+
ObjectPattern,
|
|
20
|
+
ObjectExpression,
|
|
21
|
+
ArrayPattern,
|
|
22
|
+
Identifier,
|
|
23
|
+
ExportSpecifier,
|
|
24
|
+
TSType,
|
|
25
|
+
TSTypeLiteral,
|
|
26
|
+
TSFunctionType,
|
|
27
|
+
ObjectProperty,
|
|
28
|
+
ArrayExpression,
|
|
29
|
+
Statement,
|
|
30
|
+
CallExpression,
|
|
31
|
+
RestElement,
|
|
32
|
+
TSInterfaceBody,
|
|
33
|
+
Program,
|
|
34
|
+
ObjectMethod,
|
|
35
|
+
LVal,
|
|
36
|
+
Expression
|
|
37
|
+
} from '@babel/types'
|
|
38
|
+
import { walk } from 'estree-walker'
|
|
39
|
+
import { RawSourceMap } from 'source-map'
|
|
40
|
+
import { warnOnce } from './warn'
|
|
41
|
+
import { isReservedTag } from 'web/util'
|
|
42
|
+
import { bindRE, dirRE, onRE, slotRE } from 'compiler/parser'
|
|
43
|
+
import { parseText } from 'compiler/parser/text-parser'
|
|
44
|
+
import { DEFAULT_FILENAME } from './parseComponent'
|
|
45
|
+
import {
|
|
46
|
+
CSS_VARS_HELPER,
|
|
47
|
+
genCssVarsCode,
|
|
48
|
+
genNormalScriptCssVarsCode
|
|
49
|
+
} from './cssVars'
|
|
50
|
+
import { rewriteDefault } from './rewriteDefault'
|
|
51
|
+
|
|
52
|
+
// Special compiler macros
|
|
53
|
+
const DEFINE_PROPS = 'defineProps'
|
|
54
|
+
const DEFINE_EMITS = 'defineEmits'
|
|
55
|
+
const DEFINE_EXPOSE = 'defineExpose'
|
|
56
|
+
const WITH_DEFAULTS = 'withDefaults'
|
|
57
|
+
|
|
58
|
+
// constants
|
|
59
|
+
const DEFAULT_VAR = `__default__`
|
|
60
|
+
|
|
61
|
+
const isBuiltInDir = makeMap(
|
|
62
|
+
`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
export interface SFCScriptCompileOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Scope ID for prefixing injected CSS variables.
|
|
68
|
+
* This must be consistent with the `id` passed to `compileStyle`.
|
|
69
|
+
*/
|
|
70
|
+
id: string
|
|
71
|
+
/**
|
|
72
|
+
* Production mode. Used to determine whether to generate hashed CSS variables
|
|
73
|
+
*/
|
|
74
|
+
isProd?: boolean
|
|
75
|
+
/**
|
|
76
|
+
* Enable/disable source map. Defaults to true.
|
|
77
|
+
*/
|
|
78
|
+
sourceMap?: boolean
|
|
79
|
+
/**
|
|
80
|
+
* https://babeljs.io/docs/en/babel-parser#plugins
|
|
81
|
+
*/
|
|
82
|
+
babelParserPlugins?: ParserPlugin[]
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ImportBinding {
|
|
86
|
+
isType: boolean
|
|
87
|
+
imported: string
|
|
88
|
+
source: string
|
|
89
|
+
isFromSetup: boolean
|
|
90
|
+
isUsedInTemplate: boolean
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Compile `<script setup>`
|
|
95
|
+
* It requires the whole SFC descriptor because we need to handle and merge
|
|
96
|
+
* normal `<script>` + `<script setup>` if both are present.
|
|
97
|
+
*/
|
|
98
|
+
export function compileScript(
|
|
99
|
+
sfc: SFCDescriptor,
|
|
100
|
+
options: SFCScriptCompileOptions = { id: '' }
|
|
101
|
+
): SFCScriptBlock {
|
|
102
|
+
let { filename, script, scriptSetup, source } = sfc
|
|
103
|
+
const isProd = !!options.isProd
|
|
104
|
+
const genSourceMap = options.sourceMap !== false
|
|
105
|
+
let refBindings: string[] | undefined
|
|
106
|
+
|
|
107
|
+
const cssVars = sfc.cssVars
|
|
108
|
+
const scopeId = options.id ? options.id.replace(/^data-v-/, '') : ''
|
|
109
|
+
const scriptLang = script && script.lang
|
|
110
|
+
const scriptSetupLang = scriptSetup && scriptSetup.lang
|
|
111
|
+
const isTS =
|
|
112
|
+
scriptLang === 'ts' ||
|
|
113
|
+
scriptLang === 'tsx' ||
|
|
114
|
+
scriptSetupLang === 'ts' ||
|
|
115
|
+
scriptSetupLang === 'tsx'
|
|
116
|
+
|
|
117
|
+
// resolve parser plugins
|
|
118
|
+
const plugins: ParserPlugin[] = []
|
|
119
|
+
if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
|
|
120
|
+
plugins.push('jsx')
|
|
121
|
+
} else {
|
|
122
|
+
// If don't match the case of adding jsx, should remove the jsx from the babelParserPlugins
|
|
123
|
+
if (options.babelParserPlugins)
|
|
124
|
+
options.babelParserPlugins = options.babelParserPlugins.filter(
|
|
125
|
+
n => n !== 'jsx'
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
if (options.babelParserPlugins) plugins.push(...options.babelParserPlugins)
|
|
129
|
+
if (isTS) {
|
|
130
|
+
plugins.push('typescript')
|
|
131
|
+
if (!plugins.includes('decorators')) {
|
|
132
|
+
plugins.push('decorators-legacy')
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!scriptSetup) {
|
|
137
|
+
if (!script) {
|
|
138
|
+
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`)
|
|
139
|
+
}
|
|
140
|
+
if (scriptLang && !isTS && scriptLang !== 'jsx') {
|
|
141
|
+
// do not process non js/ts script blocks
|
|
142
|
+
return script
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
let content = script.content
|
|
146
|
+
let map = script.map
|
|
147
|
+
const scriptAst = _parse(content, {
|
|
148
|
+
plugins,
|
|
149
|
+
sourceType: 'module'
|
|
150
|
+
}).program
|
|
151
|
+
const bindings = analyzeScriptBindings(scriptAst.body)
|
|
152
|
+
if (cssVars.length) {
|
|
153
|
+
content = rewriteDefault(content, DEFAULT_VAR, plugins)
|
|
154
|
+
content += genNormalScriptCssVarsCode(
|
|
155
|
+
cssVars,
|
|
156
|
+
bindings,
|
|
157
|
+
scopeId,
|
|
158
|
+
isProd
|
|
159
|
+
)
|
|
160
|
+
content += `\nexport default ${DEFAULT_VAR}`
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
...script,
|
|
164
|
+
content,
|
|
165
|
+
map,
|
|
166
|
+
bindings,
|
|
167
|
+
scriptAst: scriptAst.body
|
|
168
|
+
}
|
|
169
|
+
} catch (e: any) {
|
|
170
|
+
// silently fallback if parse fails since user may be using custom
|
|
171
|
+
// babel syntax
|
|
172
|
+
return script
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (script && scriptLang !== scriptSetupLang) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
`[@vue/compiler-sfc] <script> and <script setup> must have the same ` +
|
|
179
|
+
`language type.`
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
|
|
184
|
+
// do not process non js/ts script blocks
|
|
185
|
+
return scriptSetup
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// metadata that needs to be returned
|
|
189
|
+
const bindingMetadata: BindingMetadata = {}
|
|
190
|
+
const helperImports: Set<string> = new Set()
|
|
191
|
+
const userImports: Record<string, ImportBinding> = Object.create(null)
|
|
192
|
+
const userImportAlias: Record<string, string> = Object.create(null)
|
|
193
|
+
const scriptBindings: Record<string, BindingTypes> = Object.create(null)
|
|
194
|
+
const setupBindings: Record<string, BindingTypes> = Object.create(null)
|
|
195
|
+
|
|
196
|
+
let defaultExport: Node | undefined
|
|
197
|
+
let hasDefinePropsCall = false
|
|
198
|
+
let hasDefineEmitCall = false
|
|
199
|
+
let hasDefineExposeCall = false
|
|
200
|
+
let hasDefaultExportName = false
|
|
201
|
+
let propsRuntimeDecl: Node | undefined
|
|
202
|
+
let propsRuntimeDefaults: ObjectExpression | undefined
|
|
203
|
+
let propsDestructureDecl: Node | undefined
|
|
204
|
+
let propsDestructureRestId: string | undefined
|
|
205
|
+
let propsTypeDecl: TSTypeLiteral | TSInterfaceBody | undefined
|
|
206
|
+
let propsTypeDeclRaw: Node | undefined
|
|
207
|
+
let propsIdentifier: string | undefined
|
|
208
|
+
let emitsRuntimeDecl: Node | undefined
|
|
209
|
+
let emitsTypeDecl:
|
|
210
|
+
| TSFunctionType
|
|
211
|
+
| TSTypeLiteral
|
|
212
|
+
| TSInterfaceBody
|
|
213
|
+
| undefined
|
|
214
|
+
let emitsTypeDeclRaw: Node | undefined
|
|
215
|
+
let emitIdentifier: string | undefined
|
|
216
|
+
let hasInlinedSsrRenderFn = false
|
|
217
|
+
// props/emits declared via types
|
|
218
|
+
const typeDeclaredProps: Record<string, PropTypeData> = {}
|
|
219
|
+
const typeDeclaredEmits: Set<string> = new Set()
|
|
220
|
+
// record declared types for runtime props type generation
|
|
221
|
+
const declaredTypes: Record<string, string[]> = {}
|
|
222
|
+
// props destructure data
|
|
223
|
+
const propsDestructuredBindings: Record<
|
|
224
|
+
string, // public prop key
|
|
225
|
+
{
|
|
226
|
+
local: string // local identifier, may be different
|
|
227
|
+
default?: Expression
|
|
228
|
+
}
|
|
229
|
+
> = Object.create(null)
|
|
230
|
+
|
|
231
|
+
// magic-string state
|
|
232
|
+
const s = new MagicString(source)
|
|
233
|
+
const startOffset = scriptSetup.start
|
|
234
|
+
const endOffset = scriptSetup.end
|
|
235
|
+
const scriptStartOffset = script && script.start
|
|
236
|
+
const scriptEndOffset = script && script.end
|
|
237
|
+
|
|
238
|
+
function helper(key: string): string {
|
|
239
|
+
helperImports.add(key)
|
|
240
|
+
return `_${key}`
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function parse(
|
|
244
|
+
input: string,
|
|
245
|
+
options: ParserOptions,
|
|
246
|
+
offset: number
|
|
247
|
+
): Program {
|
|
248
|
+
try {
|
|
249
|
+
return _parse(input, options).program
|
|
250
|
+
} catch (e: any) {
|
|
251
|
+
e.message = `[@vue/compiler-sfc] ${
|
|
252
|
+
e.message
|
|
253
|
+
}\n\n${filename}\n${generateCodeFrame(
|
|
254
|
+
source,
|
|
255
|
+
e.pos + offset,
|
|
256
|
+
e.pos + offset + 1
|
|
257
|
+
)}`
|
|
258
|
+
throw e
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function error(
|
|
263
|
+
msg: string,
|
|
264
|
+
node: Node,
|
|
265
|
+
end: number = node.end! + startOffset
|
|
266
|
+
): never {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`[@vue/compiler-sfc] ${msg}\n\n${filename}\n${generateCodeFrame(
|
|
269
|
+
source,
|
|
270
|
+
node.start! + startOffset,
|
|
271
|
+
end
|
|
272
|
+
)}`
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function registerUserImport(
|
|
277
|
+
source: string,
|
|
278
|
+
local: string,
|
|
279
|
+
imported: string | false,
|
|
280
|
+
isType: boolean,
|
|
281
|
+
isFromSetup: boolean
|
|
282
|
+
) {
|
|
283
|
+
if (source === 'vue' && imported) {
|
|
284
|
+
userImportAlias[imported] = local
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
let isUsedInTemplate = true
|
|
288
|
+
if (sfc.template && !sfc.template.src && !sfc.template.lang) {
|
|
289
|
+
isUsedInTemplate = isImportUsed(local, sfc, isTS)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
userImports[local] = {
|
|
293
|
+
isType,
|
|
294
|
+
imported: imported || 'default',
|
|
295
|
+
source,
|
|
296
|
+
isFromSetup,
|
|
297
|
+
isUsedInTemplate
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function processDefineProps(node: Node, declId?: LVal): boolean {
|
|
302
|
+
if (!isCallOf(node, DEFINE_PROPS)) {
|
|
303
|
+
return false
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (hasDefinePropsCall) {
|
|
307
|
+
error(`duplicate ${DEFINE_PROPS}() call`, node)
|
|
308
|
+
}
|
|
309
|
+
hasDefinePropsCall = true
|
|
310
|
+
|
|
311
|
+
propsRuntimeDecl = node.arguments[0]
|
|
312
|
+
|
|
313
|
+
// call has type parameters - infer runtime types from it
|
|
314
|
+
if (node.typeParameters) {
|
|
315
|
+
if (propsRuntimeDecl) {
|
|
316
|
+
error(
|
|
317
|
+
`${DEFINE_PROPS}() cannot accept both type and non-type arguments ` +
|
|
318
|
+
`at the same time. Use one or the other.`,
|
|
319
|
+
node
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
propsTypeDeclRaw = node.typeParameters.params[0]
|
|
324
|
+
propsTypeDecl = resolveQualifiedType(
|
|
325
|
+
propsTypeDeclRaw,
|
|
326
|
+
node => node.type === 'TSTypeLiteral'
|
|
327
|
+
) as TSTypeLiteral | TSInterfaceBody | undefined
|
|
328
|
+
|
|
329
|
+
if (!propsTypeDecl) {
|
|
330
|
+
error(
|
|
331
|
+
`type argument passed to ${DEFINE_PROPS}() must be a literal type, ` +
|
|
332
|
+
`or a reference to an interface or literal type.`,
|
|
333
|
+
propsTypeDeclRaw
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (declId) {
|
|
339
|
+
propsIdentifier = scriptSetup!.content.slice(declId.start!, declId.end!)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return true
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function processWithDefaults(node: Node, declId?: LVal): boolean {
|
|
346
|
+
if (!isCallOf(node, WITH_DEFAULTS)) {
|
|
347
|
+
return false
|
|
348
|
+
}
|
|
349
|
+
if (processDefineProps(node.arguments[0], declId)) {
|
|
350
|
+
if (propsRuntimeDecl) {
|
|
351
|
+
error(
|
|
352
|
+
`${WITH_DEFAULTS} can only be used with type-based ` +
|
|
353
|
+
`${DEFINE_PROPS} declaration.`,
|
|
354
|
+
node
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
if (propsDestructureDecl) {
|
|
358
|
+
error(
|
|
359
|
+
`${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().\n` +
|
|
360
|
+
`Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).`,
|
|
361
|
+
node.callee
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
propsRuntimeDefaults = node.arguments[1] as ObjectExpression
|
|
365
|
+
if (
|
|
366
|
+
!propsRuntimeDefaults ||
|
|
367
|
+
propsRuntimeDefaults.type !== 'ObjectExpression'
|
|
368
|
+
) {
|
|
369
|
+
error(
|
|
370
|
+
`The 2nd argument of ${WITH_DEFAULTS} must be an object literal.`,
|
|
371
|
+
propsRuntimeDefaults || node
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
error(
|
|
376
|
+
`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
|
|
377
|
+
node.arguments[0] || node
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
return true
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function processDefineEmits(node: Node, declId?: LVal): boolean {
|
|
384
|
+
if (!isCallOf(node, DEFINE_EMITS)) {
|
|
385
|
+
return false
|
|
386
|
+
}
|
|
387
|
+
if (hasDefineEmitCall) {
|
|
388
|
+
error(`duplicate ${DEFINE_EMITS}() call`, node)
|
|
389
|
+
}
|
|
390
|
+
hasDefineEmitCall = true
|
|
391
|
+
emitsRuntimeDecl = node.arguments[0]
|
|
392
|
+
if (node.typeParameters) {
|
|
393
|
+
if (emitsRuntimeDecl) {
|
|
394
|
+
error(
|
|
395
|
+
`${DEFINE_EMITS}() cannot accept both type and non-type arguments ` +
|
|
396
|
+
`at the same time. Use one or the other.`,
|
|
397
|
+
node
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
emitsTypeDeclRaw = node.typeParameters.params[0]
|
|
402
|
+
emitsTypeDecl = resolveQualifiedType(
|
|
403
|
+
emitsTypeDeclRaw,
|
|
404
|
+
node => node.type === 'TSFunctionType' || node.type === 'TSTypeLiteral'
|
|
405
|
+
) as TSFunctionType | TSTypeLiteral | TSInterfaceBody | undefined
|
|
406
|
+
|
|
407
|
+
if (!emitsTypeDecl) {
|
|
408
|
+
error(
|
|
409
|
+
`type argument passed to ${DEFINE_EMITS}() must be a function type, ` +
|
|
410
|
+
`a literal type with call signatures, or a reference to the above types.`,
|
|
411
|
+
emitsTypeDeclRaw
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (declId) {
|
|
417
|
+
emitIdentifier = scriptSetup!.content.slice(declId.start!, declId.end!)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return true
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function resolveQualifiedType(
|
|
424
|
+
node: Node,
|
|
425
|
+
qualifier: (node: Node) => boolean
|
|
426
|
+
) {
|
|
427
|
+
if (qualifier(node)) {
|
|
428
|
+
return node
|
|
429
|
+
}
|
|
430
|
+
if (
|
|
431
|
+
node.type === 'TSTypeReference' &&
|
|
432
|
+
node.typeName.type === 'Identifier'
|
|
433
|
+
) {
|
|
434
|
+
const refName = node.typeName.name
|
|
435
|
+
const isQualifiedType = (node: Node): Node | undefined => {
|
|
436
|
+
if (
|
|
437
|
+
node.type === 'TSInterfaceDeclaration' &&
|
|
438
|
+
node.id.name === refName
|
|
439
|
+
) {
|
|
440
|
+
return node.body
|
|
441
|
+
} else if (
|
|
442
|
+
node.type === 'TSTypeAliasDeclaration' &&
|
|
443
|
+
node.id.name === refName &&
|
|
444
|
+
qualifier(node.typeAnnotation)
|
|
445
|
+
) {
|
|
446
|
+
return node.typeAnnotation
|
|
447
|
+
} else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
|
|
448
|
+
return isQualifiedType(node.declaration)
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const body = scriptAst
|
|
452
|
+
? [...scriptSetupAst.body, ...scriptAst.body]
|
|
453
|
+
: scriptSetupAst.body
|
|
454
|
+
for (const node of body) {
|
|
455
|
+
const qualified = isQualifiedType(node)
|
|
456
|
+
if (qualified) {
|
|
457
|
+
return qualified
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function processDefineExpose(node: Node): boolean {
|
|
464
|
+
if (isCallOf(node, DEFINE_EXPOSE)) {
|
|
465
|
+
if (hasDefineExposeCall) {
|
|
466
|
+
error(`duplicate ${DEFINE_EXPOSE}() call`, node)
|
|
467
|
+
}
|
|
468
|
+
hasDefineExposeCall = true
|
|
469
|
+
return true
|
|
470
|
+
}
|
|
471
|
+
return false
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function checkInvalidScopeReference(node: Node | undefined, method: string) {
|
|
475
|
+
if (!node) return
|
|
476
|
+
walkIdentifiers(node, id => {
|
|
477
|
+
if (setupBindings[id.name]) {
|
|
478
|
+
error(
|
|
479
|
+
`\`${method}()\` in <script setup> cannot reference locally ` +
|
|
480
|
+
`declared variables because it will be hoisted outside of the ` +
|
|
481
|
+
`setup() function. If your component options require initialization ` +
|
|
482
|
+
`in the module scope, use a separate normal <script> to export ` +
|
|
483
|
+
`the options instead.`,
|
|
484
|
+
id
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
})
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* check defaults. If the default object is an object literal with only
|
|
492
|
+
* static properties, we can directly generate more optimized default
|
|
493
|
+
* declarations. Otherwise we will have to fallback to runtime merging.
|
|
494
|
+
*/
|
|
495
|
+
function hasStaticWithDefaults() {
|
|
496
|
+
return (
|
|
497
|
+
propsRuntimeDefaults &&
|
|
498
|
+
propsRuntimeDefaults.type === 'ObjectExpression' &&
|
|
499
|
+
propsRuntimeDefaults.properties.every(
|
|
500
|
+
node =>
|
|
501
|
+
(node.type === 'ObjectProperty' && !node.computed) ||
|
|
502
|
+
node.type === 'ObjectMethod'
|
|
503
|
+
)
|
|
504
|
+
)
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function genRuntimeProps(props: Record<string, PropTypeData>) {
|
|
508
|
+
const keys = Object.keys(props)
|
|
509
|
+
if (!keys.length) {
|
|
510
|
+
return ``
|
|
511
|
+
}
|
|
512
|
+
const hasStaticDefaults = hasStaticWithDefaults()
|
|
513
|
+
const scriptSetupSource = scriptSetup!.content
|
|
514
|
+
let propsDecls = `{
|
|
515
|
+
${keys
|
|
516
|
+
.map(key => {
|
|
517
|
+
let defaultString: string | undefined
|
|
518
|
+
const destructured = genDestructuredDefaultValue(key)
|
|
519
|
+
if (destructured) {
|
|
520
|
+
defaultString = `default: ${destructured}`
|
|
521
|
+
} else if (hasStaticDefaults) {
|
|
522
|
+
const prop = propsRuntimeDefaults!.properties.find(
|
|
523
|
+
(node: any) => node.key.name === key
|
|
524
|
+
) as ObjectProperty | ObjectMethod
|
|
525
|
+
if (prop) {
|
|
526
|
+
if (prop.type === 'ObjectProperty') {
|
|
527
|
+
// prop has corresponding static default value
|
|
528
|
+
defaultString = `default: ${scriptSetupSource.slice(
|
|
529
|
+
prop.value.start!,
|
|
530
|
+
prop.value.end!
|
|
531
|
+
)}`
|
|
532
|
+
} else {
|
|
533
|
+
defaultString = `default() ${scriptSetupSource.slice(
|
|
534
|
+
prop.body.start!,
|
|
535
|
+
prop.body.end!
|
|
536
|
+
)}`
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const { type, required } = props[key]
|
|
542
|
+
if (!isProd) {
|
|
543
|
+
return `${key}: { type: ${toRuntimeTypeString(
|
|
544
|
+
type
|
|
545
|
+
)}, required: ${required}${
|
|
546
|
+
defaultString ? `, ${defaultString}` : ``
|
|
547
|
+
} }`
|
|
548
|
+
} else if (
|
|
549
|
+
type.some(
|
|
550
|
+
el => el === 'Boolean' || (defaultString && el === 'Function')
|
|
551
|
+
)
|
|
552
|
+
) {
|
|
553
|
+
// #4783 production: if boolean or defaultString and function exists, should keep the type.
|
|
554
|
+
return `${key}: { type: ${toRuntimeTypeString(type)}${
|
|
555
|
+
defaultString ? `, ${defaultString}` : ``
|
|
556
|
+
} }`
|
|
557
|
+
} else {
|
|
558
|
+
// production: checks are useless
|
|
559
|
+
return `${key}: ${defaultString ? `{ ${defaultString} }` : 'null'}`
|
|
560
|
+
}
|
|
561
|
+
})
|
|
562
|
+
.join(',\n ')}\n }`
|
|
563
|
+
|
|
564
|
+
if (propsRuntimeDefaults && !hasStaticDefaults) {
|
|
565
|
+
propsDecls = `${helper('mergeDefaults')}(${propsDecls}, ${source.slice(
|
|
566
|
+
propsRuntimeDefaults.start! + startOffset,
|
|
567
|
+
propsRuntimeDefaults.end! + startOffset
|
|
568
|
+
)})`
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return `\n props: ${propsDecls},`
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function genDestructuredDefaultValue(key: string): string | undefined {
|
|
575
|
+
const destructured = propsDestructuredBindings[key]
|
|
576
|
+
if (destructured && destructured.default) {
|
|
577
|
+
const value = scriptSetup!.content.slice(
|
|
578
|
+
destructured.default.start!,
|
|
579
|
+
destructured.default.end!
|
|
580
|
+
)
|
|
581
|
+
const isLiteral = destructured.default.type.endsWith('Literal')
|
|
582
|
+
return isLiteral ? value : `() => (${value})`
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function genSetupPropsType(node: TSTypeLiteral | TSInterfaceBody) {
|
|
587
|
+
const scriptSetupSource = scriptSetup!.content
|
|
588
|
+
if (hasStaticWithDefaults()) {
|
|
589
|
+
// if withDefaults() is used, we need to remove the optional flags
|
|
590
|
+
// on props that have default values
|
|
591
|
+
let res = `{ `
|
|
592
|
+
const members = node.type === 'TSTypeLiteral' ? node.members : node.body
|
|
593
|
+
for (const m of members) {
|
|
594
|
+
if (
|
|
595
|
+
(m.type === 'TSPropertySignature' ||
|
|
596
|
+
m.type === 'TSMethodSignature') &&
|
|
597
|
+
m.typeAnnotation &&
|
|
598
|
+
m.key.type === 'Identifier'
|
|
599
|
+
) {
|
|
600
|
+
if (
|
|
601
|
+
propsRuntimeDefaults!.properties.some(
|
|
602
|
+
(p: any) => p.key.name === (m.key as Identifier).name
|
|
603
|
+
)
|
|
604
|
+
) {
|
|
605
|
+
res +=
|
|
606
|
+
m.key.name +
|
|
607
|
+
(m.type === 'TSMethodSignature' ? '()' : '') +
|
|
608
|
+
scriptSetupSource.slice(
|
|
609
|
+
m.typeAnnotation.start!,
|
|
610
|
+
m.typeAnnotation.end!
|
|
611
|
+
) +
|
|
612
|
+
', '
|
|
613
|
+
} else {
|
|
614
|
+
res +=
|
|
615
|
+
scriptSetupSource.slice(m.start!, m.typeAnnotation.end!) + `, `
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return (res.length ? res.slice(0, -2) : res) + ` }`
|
|
620
|
+
} else {
|
|
621
|
+
return scriptSetupSource.slice(node.start!, node.end!)
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// 1. process normal <script> first if it exists
|
|
626
|
+
let scriptAst: Program | undefined
|
|
627
|
+
if (script) {
|
|
628
|
+
scriptAst = parse(
|
|
629
|
+
script.content,
|
|
630
|
+
{
|
|
631
|
+
plugins,
|
|
632
|
+
sourceType: 'module'
|
|
633
|
+
},
|
|
634
|
+
scriptStartOffset!
|
|
635
|
+
)
|
|
636
|
+
|
|
637
|
+
for (const node of scriptAst.body) {
|
|
638
|
+
if (node.type === 'ImportDeclaration') {
|
|
639
|
+
// record imports for dedupe
|
|
640
|
+
for (const specifier of node.specifiers) {
|
|
641
|
+
const imported =
|
|
642
|
+
specifier.type === 'ImportSpecifier' &&
|
|
643
|
+
specifier.imported.type === 'Identifier' &&
|
|
644
|
+
specifier.imported.name
|
|
645
|
+
registerUserImport(
|
|
646
|
+
node.source.value,
|
|
647
|
+
specifier.local.name,
|
|
648
|
+
imported,
|
|
649
|
+
node.importKind === 'type' ||
|
|
650
|
+
(specifier.type === 'ImportSpecifier' &&
|
|
651
|
+
specifier.importKind === 'type'),
|
|
652
|
+
false
|
|
653
|
+
)
|
|
654
|
+
}
|
|
655
|
+
} else if (node.type === 'ExportDefaultDeclaration') {
|
|
656
|
+
// export default
|
|
657
|
+
defaultExport = node
|
|
658
|
+
|
|
659
|
+
// check if user has manually specified `name` or 'render` option in
|
|
660
|
+
// export default
|
|
661
|
+
// if has name, skip name inference
|
|
662
|
+
// if has render and no template, generate return object instead of
|
|
663
|
+
// empty render function (#4980)
|
|
664
|
+
let optionProperties
|
|
665
|
+
if (defaultExport.declaration.type === 'ObjectExpression') {
|
|
666
|
+
optionProperties = defaultExport.declaration.properties
|
|
667
|
+
} else if (
|
|
668
|
+
defaultExport.declaration.type === 'CallExpression' &&
|
|
669
|
+
defaultExport.declaration.arguments[0].type === 'ObjectExpression'
|
|
670
|
+
) {
|
|
671
|
+
optionProperties = defaultExport.declaration.arguments[0].properties
|
|
672
|
+
}
|
|
673
|
+
if (optionProperties) {
|
|
674
|
+
for (const s of optionProperties) {
|
|
675
|
+
if (
|
|
676
|
+
s.type === 'ObjectProperty' &&
|
|
677
|
+
s.key.type === 'Identifier' &&
|
|
678
|
+
s.key.name === 'name'
|
|
679
|
+
) {
|
|
680
|
+
hasDefaultExportName = true
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// export default { ... } --> const __default__ = { ... }
|
|
686
|
+
const start = node.start! + scriptStartOffset!
|
|
687
|
+
const end = node.declaration.start! + scriptStartOffset!
|
|
688
|
+
s.overwrite(start, end, `const ${DEFAULT_VAR} = `)
|
|
689
|
+
} else if (node.type === 'ExportNamedDeclaration') {
|
|
690
|
+
const defaultSpecifier = node.specifiers.find(
|
|
691
|
+
s => s.exported.type === 'Identifier' && s.exported.name === 'default'
|
|
692
|
+
) as ExportSpecifier
|
|
693
|
+
if (defaultSpecifier) {
|
|
694
|
+
defaultExport = node
|
|
695
|
+
// 1. remove specifier
|
|
696
|
+
if (node.specifiers.length > 1) {
|
|
697
|
+
s.remove(
|
|
698
|
+
defaultSpecifier.start! + scriptStartOffset!,
|
|
699
|
+
defaultSpecifier.end! + scriptStartOffset!
|
|
700
|
+
)
|
|
701
|
+
} else {
|
|
702
|
+
s.remove(
|
|
703
|
+
node.start! + scriptStartOffset!,
|
|
704
|
+
node.end! + scriptStartOffset!
|
|
705
|
+
)
|
|
706
|
+
}
|
|
707
|
+
if (node.source) {
|
|
708
|
+
// export { x as default } from './x'
|
|
709
|
+
// rewrite to `import { x as __default__ } from './x'` and
|
|
710
|
+
// add to top
|
|
711
|
+
s.prepend(
|
|
712
|
+
`import { ${defaultSpecifier.local.name} as ${DEFAULT_VAR} } from '${node.source.value}'\n`
|
|
713
|
+
)
|
|
714
|
+
} else {
|
|
715
|
+
// export { x as default }
|
|
716
|
+
// rewrite to `const __default__ = x` and move to end
|
|
717
|
+
s.appendLeft(
|
|
718
|
+
scriptEndOffset!,
|
|
719
|
+
`\nconst ${DEFAULT_VAR} = ${defaultSpecifier.local.name}\n`
|
|
720
|
+
)
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if (node.declaration) {
|
|
724
|
+
walkDeclaration(node.declaration, scriptBindings, userImportAlias)
|
|
725
|
+
}
|
|
726
|
+
} else if (
|
|
727
|
+
(node.type === 'VariableDeclaration' ||
|
|
728
|
+
node.type === 'FunctionDeclaration' ||
|
|
729
|
+
node.type === 'ClassDeclaration' ||
|
|
730
|
+
node.type === 'TSEnumDeclaration') &&
|
|
731
|
+
!node.declare
|
|
732
|
+
) {
|
|
733
|
+
walkDeclaration(node, scriptBindings, userImportAlias)
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// apply reactivity transform
|
|
738
|
+
// if (enableReactivityTransform && shouldTransform(script.content)) {
|
|
739
|
+
// const { rootRefs, importedHelpers } = transformAST(
|
|
740
|
+
// scriptAst,
|
|
741
|
+
// s,
|
|
742
|
+
// scriptStartOffset!
|
|
743
|
+
// )
|
|
744
|
+
// refBindings = rootRefs
|
|
745
|
+
// for (const h of importedHelpers) {
|
|
746
|
+
// helperImports.add(h)
|
|
747
|
+
// }
|
|
748
|
+
// }
|
|
749
|
+
|
|
750
|
+
// <script> after <script setup>
|
|
751
|
+
// we need to move the block up so that `const __default__` is
|
|
752
|
+
// declared before being used in the actual component definition
|
|
753
|
+
if (scriptStartOffset! > startOffset) {
|
|
754
|
+
// if content doesn't end with newline, add one
|
|
755
|
+
if (!/\n$/.test(script.content.trim())) {
|
|
756
|
+
s.appendLeft(scriptEndOffset!, `\n`)
|
|
757
|
+
}
|
|
758
|
+
s.move(scriptStartOffset!, scriptEndOffset!, 0)
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// 2. parse <script setup> and walk over top level statements
|
|
763
|
+
const scriptSetupAst = parse(
|
|
764
|
+
scriptSetup.content,
|
|
765
|
+
{
|
|
766
|
+
plugins: [
|
|
767
|
+
...plugins,
|
|
768
|
+
// allow top level await but only inside <script setup>
|
|
769
|
+
'topLevelAwait'
|
|
770
|
+
],
|
|
771
|
+
sourceType: 'module'
|
|
772
|
+
},
|
|
773
|
+
startOffset
|
|
774
|
+
)
|
|
775
|
+
|
|
776
|
+
for (const node of scriptSetupAst.body) {
|
|
777
|
+
const start = node.start! + startOffset
|
|
778
|
+
let end = node.end! + startOffset
|
|
779
|
+
// locate comment
|
|
780
|
+
if (node.trailingComments && node.trailingComments.length > 0) {
|
|
781
|
+
const lastCommentNode =
|
|
782
|
+
node.trailingComments[node.trailingComments.length - 1]
|
|
783
|
+
end = lastCommentNode.end! + startOffset
|
|
784
|
+
}
|
|
785
|
+
// locate the end of whitespace between this statement and the next
|
|
786
|
+
while (end <= source.length) {
|
|
787
|
+
if (!/\s/.test(source.charAt(end))) {
|
|
788
|
+
break
|
|
789
|
+
}
|
|
790
|
+
end++
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// (Dropped) `ref: x` bindings
|
|
794
|
+
if (
|
|
795
|
+
node.type === 'LabeledStatement' &&
|
|
796
|
+
node.label.name === 'ref' &&
|
|
797
|
+
node.body.type === 'ExpressionStatement'
|
|
798
|
+
) {
|
|
799
|
+
error(
|
|
800
|
+
`ref sugar using the label syntax was an experimental proposal and ` +
|
|
801
|
+
`has been dropped based on community feedback. Please check out ` +
|
|
802
|
+
`the new proposal at https://github.com/vuejs/rfcs/discussions/369`,
|
|
803
|
+
node
|
|
804
|
+
)
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
if (node.type === 'ImportDeclaration') {
|
|
808
|
+
// import declarations are moved to top
|
|
809
|
+
s.move(start, end, 0)
|
|
810
|
+
|
|
811
|
+
// dedupe imports
|
|
812
|
+
let removed = 0
|
|
813
|
+
const removeSpecifier = (i: number) => {
|
|
814
|
+
const removeLeft = i > removed
|
|
815
|
+
removed++
|
|
816
|
+
const current = node.specifiers[i]
|
|
817
|
+
const next = node.specifiers[i + 1]
|
|
818
|
+
s.remove(
|
|
819
|
+
removeLeft
|
|
820
|
+
? node.specifiers[i - 1].end! + startOffset
|
|
821
|
+
: current.start! + startOffset,
|
|
822
|
+
next && !removeLeft
|
|
823
|
+
? next.start! + startOffset
|
|
824
|
+
: current.end! + startOffset
|
|
825
|
+
)
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
for (let i = 0; i < node.specifiers.length; i++) {
|
|
829
|
+
const specifier = node.specifiers[i]
|
|
830
|
+
const local = specifier.local.name
|
|
831
|
+
let imported =
|
|
832
|
+
specifier.type === 'ImportSpecifier' &&
|
|
833
|
+
specifier.imported.type === 'Identifier' &&
|
|
834
|
+
specifier.imported.name
|
|
835
|
+
if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
836
|
+
imported = '*'
|
|
837
|
+
}
|
|
838
|
+
const source = node.source.value
|
|
839
|
+
const existing = userImports[local]
|
|
840
|
+
if (
|
|
841
|
+
source === 'vue' &&
|
|
842
|
+
(imported === DEFINE_PROPS ||
|
|
843
|
+
imported === DEFINE_EMITS ||
|
|
844
|
+
imported === DEFINE_EXPOSE)
|
|
845
|
+
) {
|
|
846
|
+
warnOnce(
|
|
847
|
+
`\`${imported}\` is a compiler macro and no longer needs to be imported.`
|
|
848
|
+
)
|
|
849
|
+
removeSpecifier(i)
|
|
850
|
+
} else if (existing) {
|
|
851
|
+
if (existing.source === source && existing.imported === imported) {
|
|
852
|
+
// already imported in <script setup>, dedupe
|
|
853
|
+
removeSpecifier(i)
|
|
854
|
+
} else {
|
|
855
|
+
error(`different imports aliased to same local name.`, specifier)
|
|
856
|
+
}
|
|
857
|
+
} else {
|
|
858
|
+
registerUserImport(
|
|
859
|
+
source,
|
|
860
|
+
local,
|
|
861
|
+
imported,
|
|
862
|
+
node.importKind === 'type' ||
|
|
863
|
+
(specifier.type === 'ImportSpecifier' &&
|
|
864
|
+
specifier.importKind === 'type'),
|
|
865
|
+
true
|
|
866
|
+
)
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (node.specifiers.length && removed === node.specifiers.length) {
|
|
870
|
+
s.remove(node.start! + startOffset, node.end! + startOffset)
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
if (node.type === 'ExpressionStatement') {
|
|
875
|
+
// process `defineProps` and `defineEmit(s)` calls
|
|
876
|
+
if (
|
|
877
|
+
processDefineProps(node.expression) ||
|
|
878
|
+
processDefineEmits(node.expression) ||
|
|
879
|
+
processWithDefaults(node.expression)
|
|
880
|
+
) {
|
|
881
|
+
s.remove(node.start! + startOffset, node.end! + startOffset)
|
|
882
|
+
} else if (processDefineExpose(node.expression)) {
|
|
883
|
+
// defineExpose({}) -> expose({})
|
|
884
|
+
const callee = (node.expression as CallExpression).callee
|
|
885
|
+
s.overwrite(
|
|
886
|
+
callee.start! + startOffset,
|
|
887
|
+
callee.end! + startOffset,
|
|
888
|
+
'expose'
|
|
889
|
+
)
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
if (node.type === 'VariableDeclaration' && !node.declare) {
|
|
894
|
+
const total = node.declarations.length
|
|
895
|
+
let left = total
|
|
896
|
+
for (let i = 0; i < total; i++) {
|
|
897
|
+
const decl = node.declarations[i]
|
|
898
|
+
if (decl.init) {
|
|
899
|
+
// defineProps / defineEmits
|
|
900
|
+
const isDefineProps =
|
|
901
|
+
processDefineProps(decl.init, decl.id) ||
|
|
902
|
+
processWithDefaults(decl.init, decl.id)
|
|
903
|
+
const isDefineEmits = processDefineEmits(decl.init, decl.id)
|
|
904
|
+
if (isDefineProps || isDefineEmits) {
|
|
905
|
+
if (left === 1) {
|
|
906
|
+
s.remove(node.start! + startOffset, node.end! + startOffset)
|
|
907
|
+
} else {
|
|
908
|
+
let start = decl.start! + startOffset
|
|
909
|
+
let end = decl.end! + startOffset
|
|
910
|
+
if (i < total - 1) {
|
|
911
|
+
// not the last one, locate the start of the next
|
|
912
|
+
end = node.declarations[i + 1].start! + startOffset
|
|
913
|
+
} else {
|
|
914
|
+
// last one, locate the end of the prev
|
|
915
|
+
start = node.declarations[i - 1].end! + startOffset
|
|
916
|
+
}
|
|
917
|
+
s.remove(start, end)
|
|
918
|
+
left--
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// walk declarations to record declared bindings
|
|
926
|
+
if (
|
|
927
|
+
(node.type === 'VariableDeclaration' ||
|
|
928
|
+
node.type === 'FunctionDeclaration' ||
|
|
929
|
+
node.type === 'ClassDeclaration') &&
|
|
930
|
+
!node.declare
|
|
931
|
+
) {
|
|
932
|
+
walkDeclaration(node, setupBindings, userImportAlias)
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// walk statements & named exports / variable declarations for top level
|
|
936
|
+
// await
|
|
937
|
+
if (
|
|
938
|
+
(node.type === 'VariableDeclaration' && !node.declare) ||
|
|
939
|
+
node.type.endsWith('Statement')
|
|
940
|
+
) {
|
|
941
|
+
const scope: Statement[][] = [scriptSetupAst.body]
|
|
942
|
+
;(walk as any)(node, {
|
|
943
|
+
enter(child: Node, parent: Node) {
|
|
944
|
+
if (isFunctionType(child)) {
|
|
945
|
+
this.skip()
|
|
946
|
+
}
|
|
947
|
+
if (child.type === 'BlockStatement') {
|
|
948
|
+
scope.push(child.body)
|
|
949
|
+
}
|
|
950
|
+
if (child.type === 'AwaitExpression') {
|
|
951
|
+
error(
|
|
952
|
+
`Vue 2 does not support top level await in <script setup>.`,
|
|
953
|
+
child
|
|
954
|
+
)
|
|
955
|
+
}
|
|
956
|
+
},
|
|
957
|
+
exit(node: Node) {
|
|
958
|
+
if (node.type === 'BlockStatement') scope.pop()
|
|
959
|
+
}
|
|
960
|
+
})
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if (
|
|
964
|
+
(node.type === 'ExportNamedDeclaration' && node.exportKind !== 'type') ||
|
|
965
|
+
node.type === 'ExportAllDeclaration' ||
|
|
966
|
+
node.type === 'ExportDefaultDeclaration'
|
|
967
|
+
) {
|
|
968
|
+
error(
|
|
969
|
+
`<script setup> cannot contain ES module exports. ` +
|
|
970
|
+
`If you are using a previous version of <script setup>, please ` +
|
|
971
|
+
`consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`,
|
|
972
|
+
node
|
|
973
|
+
)
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
if (isTS) {
|
|
977
|
+
// runtime enum
|
|
978
|
+
if (node.type === 'TSEnumDeclaration') {
|
|
979
|
+
registerBinding(setupBindings, node.id, BindingTypes.SETUP_CONST)
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// move all Type declarations to outer scope
|
|
983
|
+
if (
|
|
984
|
+
node.type.startsWith('TS') ||
|
|
985
|
+
(node.type === 'ExportNamedDeclaration' &&
|
|
986
|
+
node.exportKind === 'type') ||
|
|
987
|
+
(node.type === 'VariableDeclaration' && node.declare)
|
|
988
|
+
) {
|
|
989
|
+
recordType(node, declaredTypes)
|
|
990
|
+
s.move(start, end, 0)
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// 3. Apply reactivity transform
|
|
996
|
+
// if (
|
|
997
|
+
// (enableReactivityTransform &&
|
|
998
|
+
// // normal <script> had ref bindings that maybe used in <script setup>
|
|
999
|
+
// (refBindings || shouldTransform(scriptSetup.content))) ||
|
|
1000
|
+
// propsDestructureDecl
|
|
1001
|
+
// ) {
|
|
1002
|
+
// const { rootRefs, importedHelpers } = transformAST(
|
|
1003
|
+
// scriptSetupAst,
|
|
1004
|
+
// s,
|
|
1005
|
+
// startOffset,
|
|
1006
|
+
// refBindings,
|
|
1007
|
+
// propsDestructuredBindings
|
|
1008
|
+
// )
|
|
1009
|
+
// refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs
|
|
1010
|
+
// for (const h of importedHelpers) {
|
|
1011
|
+
// helperImports.add(h)
|
|
1012
|
+
// }
|
|
1013
|
+
// }
|
|
1014
|
+
|
|
1015
|
+
// 4. extract runtime props/emits code from setup context type
|
|
1016
|
+
if (propsTypeDecl) {
|
|
1017
|
+
extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes, isProd)
|
|
1018
|
+
}
|
|
1019
|
+
if (emitsTypeDecl) {
|
|
1020
|
+
extractRuntimeEmits(emitsTypeDecl, typeDeclaredEmits)
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// 5. check useOptions args to make sure it doesn't reference setup scope
|
|
1024
|
+
// variables
|
|
1025
|
+
checkInvalidScopeReference(propsRuntimeDecl, DEFINE_PROPS)
|
|
1026
|
+
checkInvalidScopeReference(propsRuntimeDefaults, DEFINE_PROPS)
|
|
1027
|
+
checkInvalidScopeReference(propsDestructureDecl, DEFINE_PROPS)
|
|
1028
|
+
checkInvalidScopeReference(emitsRuntimeDecl, DEFINE_EMITS)
|
|
1029
|
+
|
|
1030
|
+
// 6. remove non-script content
|
|
1031
|
+
if (script) {
|
|
1032
|
+
if (startOffset < scriptStartOffset!) {
|
|
1033
|
+
// <script setup> before <script>
|
|
1034
|
+
s.remove(0, startOffset)
|
|
1035
|
+
s.remove(endOffset, scriptStartOffset!)
|
|
1036
|
+
s.remove(scriptEndOffset!, source.length)
|
|
1037
|
+
} else {
|
|
1038
|
+
// <script> before <script setup>
|
|
1039
|
+
s.remove(0, scriptStartOffset!)
|
|
1040
|
+
s.remove(scriptEndOffset!, startOffset)
|
|
1041
|
+
s.remove(endOffset, source.length)
|
|
1042
|
+
}
|
|
1043
|
+
} else {
|
|
1044
|
+
// only <script setup>
|
|
1045
|
+
s.remove(0, startOffset)
|
|
1046
|
+
s.remove(endOffset, source.length)
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// 7. analyze binding metadata
|
|
1050
|
+
if (scriptAst) {
|
|
1051
|
+
Object.assign(bindingMetadata, analyzeScriptBindings(scriptAst.body))
|
|
1052
|
+
}
|
|
1053
|
+
if (propsRuntimeDecl) {
|
|
1054
|
+
for (const key of getObjectOrArrayExpressionKeys(propsRuntimeDecl)) {
|
|
1055
|
+
bindingMetadata[key] = BindingTypes.PROPS
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
for (const key in typeDeclaredProps) {
|
|
1059
|
+
bindingMetadata[key] = BindingTypes.PROPS
|
|
1060
|
+
}
|
|
1061
|
+
// props aliases
|
|
1062
|
+
// if (propsDestructureDecl) {
|
|
1063
|
+
// if (propsDestructureRestId) {
|
|
1064
|
+
// bindingMetadata[propsDestructureRestId] =
|
|
1065
|
+
// BindingTypes.SETUP_REACTIVE_CONST
|
|
1066
|
+
// }
|
|
1067
|
+
// for (const key in propsDestructuredBindings) {
|
|
1068
|
+
// const { local } = propsDestructuredBindings[key]
|
|
1069
|
+
// if (local !== key) {
|
|
1070
|
+
// bindingMetadata[local] = BindingTypes.PROPS_ALIASED
|
|
1071
|
+
// ;(bindingMetadata.__propsAliases ||
|
|
1072
|
+
// (bindingMetadata.__propsAliases = {}))[local] = key
|
|
1073
|
+
// }
|
|
1074
|
+
// }
|
|
1075
|
+
// }
|
|
1076
|
+
for (const [key, { isType, imported, source }] of Object.entries(
|
|
1077
|
+
userImports
|
|
1078
|
+
)) {
|
|
1079
|
+
if (isType) continue
|
|
1080
|
+
bindingMetadata[key] =
|
|
1081
|
+
imported === '*' ||
|
|
1082
|
+
(imported === 'default' && source.endsWith('.vue')) ||
|
|
1083
|
+
source === 'vue'
|
|
1084
|
+
? BindingTypes.SETUP_CONST
|
|
1085
|
+
: BindingTypes.SETUP_MAYBE_REF
|
|
1086
|
+
}
|
|
1087
|
+
for (const key in scriptBindings) {
|
|
1088
|
+
bindingMetadata[key] = scriptBindings[key]
|
|
1089
|
+
}
|
|
1090
|
+
for (const key in setupBindings) {
|
|
1091
|
+
bindingMetadata[key] = setupBindings[key]
|
|
1092
|
+
}
|
|
1093
|
+
// known ref bindings
|
|
1094
|
+
if (refBindings) {
|
|
1095
|
+
for (const key of refBindings) {
|
|
1096
|
+
bindingMetadata[key] = BindingTypes.SETUP_REF
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// 8. inject `useCssVars` calls
|
|
1101
|
+
if (cssVars.length) {
|
|
1102
|
+
helperImports.add(CSS_VARS_HELPER)
|
|
1103
|
+
s.prependRight(
|
|
1104
|
+
startOffset,
|
|
1105
|
+
`\n${genCssVarsCode(cssVars, bindingMetadata, scopeId, isProd)}\n`
|
|
1106
|
+
)
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// 9. finalize setup() argument signature
|
|
1110
|
+
let args = `__props`
|
|
1111
|
+
if (propsTypeDecl) {
|
|
1112
|
+
// mark as any and only cast on assignment
|
|
1113
|
+
// since the user defined complex types may be incompatible with the
|
|
1114
|
+
// inferred type from generated runtime declarations
|
|
1115
|
+
args += `: any`
|
|
1116
|
+
}
|
|
1117
|
+
// inject user assignment of props
|
|
1118
|
+
// we use a default __props so that template expressions referencing props
|
|
1119
|
+
// can use it directly
|
|
1120
|
+
if (propsIdentifier) {
|
|
1121
|
+
s.prependLeft(
|
|
1122
|
+
startOffset,
|
|
1123
|
+
`\nconst ${propsIdentifier} = __props${
|
|
1124
|
+
propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``
|
|
1125
|
+
}\n`
|
|
1126
|
+
)
|
|
1127
|
+
}
|
|
1128
|
+
if (propsDestructureRestId) {
|
|
1129
|
+
s.prependLeft(
|
|
1130
|
+
startOffset,
|
|
1131
|
+
`\nconst ${propsDestructureRestId} = ${helper(
|
|
1132
|
+
`createPropsRestProxy`
|
|
1133
|
+
)}(__props, ${JSON.stringify(Object.keys(propsDestructuredBindings))})\n`
|
|
1134
|
+
)
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
const destructureElements = hasDefineExposeCall ? [`expose`] : []
|
|
1138
|
+
if (emitIdentifier) {
|
|
1139
|
+
destructureElements.push(
|
|
1140
|
+
emitIdentifier === `emit` ? `emit` : `emit: ${emitIdentifier}`
|
|
1141
|
+
)
|
|
1142
|
+
}
|
|
1143
|
+
if (destructureElements.length) {
|
|
1144
|
+
args += `, { ${destructureElements.join(', ')} }`
|
|
1145
|
+
if (emitsTypeDecl) {
|
|
1146
|
+
args += `: { emit: (${scriptSetup.content.slice(
|
|
1147
|
+
emitsTypeDecl.start!,
|
|
1148
|
+
emitsTypeDecl.end!
|
|
1149
|
+
)}), expose: any, slots: any, attrs: any }`
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
// 10. generate return statement
|
|
1154
|
+
const allBindings: Record<string, any> = {
|
|
1155
|
+
...scriptBindings,
|
|
1156
|
+
...setupBindings
|
|
1157
|
+
}
|
|
1158
|
+
for (const key in userImports) {
|
|
1159
|
+
if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
|
|
1160
|
+
allBindings[key] = true
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
// __sfc marker indicates these bindings are compiled from <script setup>
|
|
1164
|
+
// and should not be proxied on `this`
|
|
1165
|
+
const returned = `{ ${__TEST__ ? `` : `__sfc: true,`}${Object.keys(
|
|
1166
|
+
allBindings
|
|
1167
|
+
).join(', ')} }`
|
|
1168
|
+
|
|
1169
|
+
s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`)
|
|
1170
|
+
|
|
1171
|
+
// 11. finalize default export
|
|
1172
|
+
let runtimeOptions = ``
|
|
1173
|
+
if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
|
|
1174
|
+
const match = filename.match(/([^/\\]+)\.\w+$/)
|
|
1175
|
+
if (match) {
|
|
1176
|
+
runtimeOptions += `\n __name: '${match[1]}',`
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
if (hasInlinedSsrRenderFn) {
|
|
1180
|
+
runtimeOptions += `\n __ssrInlineRender: true,`
|
|
1181
|
+
}
|
|
1182
|
+
if (propsRuntimeDecl) {
|
|
1183
|
+
let declCode = scriptSetup.content
|
|
1184
|
+
.slice(propsRuntimeDecl.start!, propsRuntimeDecl.end!)
|
|
1185
|
+
.trim()
|
|
1186
|
+
if (propsDestructureDecl) {
|
|
1187
|
+
const defaults: string[] = []
|
|
1188
|
+
for (const key in propsDestructuredBindings) {
|
|
1189
|
+
const d = genDestructuredDefaultValue(key)
|
|
1190
|
+
if (d) defaults.push(`${key}: ${d}`)
|
|
1191
|
+
}
|
|
1192
|
+
if (defaults.length) {
|
|
1193
|
+
declCode = `${helper(
|
|
1194
|
+
`mergeDefaults`
|
|
1195
|
+
)}(${declCode}, {\n ${defaults.join(',\n ')}\n})`
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
runtimeOptions += `\n props: ${declCode},`
|
|
1199
|
+
} else if (propsTypeDecl) {
|
|
1200
|
+
runtimeOptions += genRuntimeProps(typeDeclaredProps)
|
|
1201
|
+
}
|
|
1202
|
+
if (emitsRuntimeDecl) {
|
|
1203
|
+
runtimeOptions += `\n emits: ${scriptSetup.content
|
|
1204
|
+
.slice(emitsRuntimeDecl.start!, emitsRuntimeDecl.end!)
|
|
1205
|
+
.trim()},`
|
|
1206
|
+
} else if (emitsTypeDecl) {
|
|
1207
|
+
runtimeOptions += genRuntimeEmits(typeDeclaredEmits)
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// wrap setup code with function.
|
|
1211
|
+
if (isTS) {
|
|
1212
|
+
// for TS, make sure the exported type is still valid type with
|
|
1213
|
+
// correct props information
|
|
1214
|
+
// we have to use object spread for types to be merged properly
|
|
1215
|
+
// user's TS setting should compile it down to proper targets
|
|
1216
|
+
// export default defineComponent({ ...__default__, ... })
|
|
1217
|
+
const def = defaultExport ? `\n ...${DEFAULT_VAR},` : ``
|
|
1218
|
+
s.prependLeft(
|
|
1219
|
+
startOffset,
|
|
1220
|
+
`\nexport default /*#__PURE__*/${helper(
|
|
1221
|
+
`defineComponent`
|
|
1222
|
+
)}({${def}${runtimeOptions}\n setup(${args}) {\n`
|
|
1223
|
+
)
|
|
1224
|
+
s.appendRight(endOffset, `})`)
|
|
1225
|
+
} else {
|
|
1226
|
+
if (defaultExport) {
|
|
1227
|
+
// without TS, can't rely on rest spread, so we use Object.assign
|
|
1228
|
+
// export default Object.assign(__default__, { ... })
|
|
1229
|
+
s.prependLeft(
|
|
1230
|
+
startOffset,
|
|
1231
|
+
`\nexport default /*#__PURE__*/Object.assign(${DEFAULT_VAR}, {${runtimeOptions}\n ` +
|
|
1232
|
+
`setup(${args}) {\n`
|
|
1233
|
+
)
|
|
1234
|
+
s.appendRight(endOffset, `})`)
|
|
1235
|
+
} else {
|
|
1236
|
+
s.prependLeft(
|
|
1237
|
+
startOffset,
|
|
1238
|
+
`\nexport default {${runtimeOptions}\n setup(${args}) {\n`
|
|
1239
|
+
)
|
|
1240
|
+
s.appendRight(endOffset, `}`)
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// 12. finalize Vue helper imports
|
|
1245
|
+
if (helperImports.size > 0) {
|
|
1246
|
+
s.prepend(
|
|
1247
|
+
`import { ${[...helperImports]
|
|
1248
|
+
.map(h => `${h} as _${h}`)
|
|
1249
|
+
.join(', ')} } from 'vue'\n`
|
|
1250
|
+
)
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
s.trim()
|
|
1254
|
+
|
|
1255
|
+
return {
|
|
1256
|
+
...scriptSetup,
|
|
1257
|
+
bindings: bindingMetadata,
|
|
1258
|
+
imports: userImports,
|
|
1259
|
+
content: s.toString(),
|
|
1260
|
+
map: genSourceMap
|
|
1261
|
+
? (s.generateMap({
|
|
1262
|
+
source: filename,
|
|
1263
|
+
hires: true,
|
|
1264
|
+
includeContent: true
|
|
1265
|
+
}) as unknown as RawSourceMap)
|
|
1266
|
+
: undefined,
|
|
1267
|
+
scriptAst: scriptAst?.body,
|
|
1268
|
+
scriptSetupAst: scriptSetupAst?.body
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
function registerBinding(
|
|
1273
|
+
bindings: Record<string, BindingTypes>,
|
|
1274
|
+
node: Identifier,
|
|
1275
|
+
type: BindingTypes
|
|
1276
|
+
) {
|
|
1277
|
+
bindings[node.name] = type
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
function walkDeclaration(
|
|
1281
|
+
node: Declaration,
|
|
1282
|
+
bindings: Record<string, BindingTypes>,
|
|
1283
|
+
userImportAlias: Record<string, string>
|
|
1284
|
+
) {
|
|
1285
|
+
if (node.type === 'VariableDeclaration') {
|
|
1286
|
+
const isConst = node.kind === 'const'
|
|
1287
|
+
// export const foo = ...
|
|
1288
|
+
for (const { id, init } of node.declarations) {
|
|
1289
|
+
const isDefineCall = !!(
|
|
1290
|
+
isConst &&
|
|
1291
|
+
isCallOf(
|
|
1292
|
+
init,
|
|
1293
|
+
c => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS
|
|
1294
|
+
)
|
|
1295
|
+
)
|
|
1296
|
+
if (id.type === 'Identifier') {
|
|
1297
|
+
let bindingType
|
|
1298
|
+
const userReactiveBinding = userImportAlias['reactive'] || 'reactive'
|
|
1299
|
+
if (isCallOf(init, userReactiveBinding)) {
|
|
1300
|
+
// treat reactive() calls as let since it's meant to be mutable
|
|
1301
|
+
bindingType = isConst
|
|
1302
|
+
? BindingTypes.SETUP_REACTIVE_CONST
|
|
1303
|
+
: BindingTypes.SETUP_LET
|
|
1304
|
+
} else if (
|
|
1305
|
+
// if a declaration is a const literal, we can mark it so that
|
|
1306
|
+
// the generated render fn code doesn't need to unref() it
|
|
1307
|
+
isDefineCall ||
|
|
1308
|
+
(isConst && canNeverBeRef(init!, userReactiveBinding))
|
|
1309
|
+
) {
|
|
1310
|
+
bindingType = isCallOf(init, DEFINE_PROPS)
|
|
1311
|
+
? BindingTypes.SETUP_REACTIVE_CONST
|
|
1312
|
+
: BindingTypes.SETUP_CONST
|
|
1313
|
+
} else if (isConst) {
|
|
1314
|
+
if (isCallOf(init, userImportAlias['ref'] || 'ref')) {
|
|
1315
|
+
bindingType = BindingTypes.SETUP_REF
|
|
1316
|
+
} else {
|
|
1317
|
+
bindingType = BindingTypes.SETUP_MAYBE_REF
|
|
1318
|
+
}
|
|
1319
|
+
} else {
|
|
1320
|
+
bindingType = BindingTypes.SETUP_LET
|
|
1321
|
+
}
|
|
1322
|
+
registerBinding(bindings, id, bindingType)
|
|
1323
|
+
} else {
|
|
1324
|
+
if (isCallOf(init, DEFINE_PROPS)) {
|
|
1325
|
+
// skip walking props destructure
|
|
1326
|
+
return
|
|
1327
|
+
}
|
|
1328
|
+
if (id.type === 'ObjectPattern') {
|
|
1329
|
+
walkObjectPattern(id, bindings, isConst, isDefineCall)
|
|
1330
|
+
} else if (id.type === 'ArrayPattern') {
|
|
1331
|
+
walkArrayPattern(id, bindings, isConst, isDefineCall)
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
} else if (
|
|
1336
|
+
node.type === 'TSEnumDeclaration' ||
|
|
1337
|
+
node.type === 'FunctionDeclaration' ||
|
|
1338
|
+
node.type === 'ClassDeclaration'
|
|
1339
|
+
) {
|
|
1340
|
+
// export function foo() {} / export class Foo {}
|
|
1341
|
+
// export declarations must be named.
|
|
1342
|
+
bindings[node.id!.name] = BindingTypes.SETUP_CONST
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
function walkObjectPattern(
|
|
1347
|
+
node: ObjectPattern,
|
|
1348
|
+
bindings: Record<string, BindingTypes>,
|
|
1349
|
+
isConst: boolean,
|
|
1350
|
+
isDefineCall = false
|
|
1351
|
+
) {
|
|
1352
|
+
for (const p of node.properties) {
|
|
1353
|
+
if (p.type === 'ObjectProperty') {
|
|
1354
|
+
if (p.key.type === 'Identifier' && p.key === p.value) {
|
|
1355
|
+
// shorthand: const { x } = ...
|
|
1356
|
+
const type = isDefineCall
|
|
1357
|
+
? BindingTypes.SETUP_CONST
|
|
1358
|
+
: isConst
|
|
1359
|
+
? BindingTypes.SETUP_MAYBE_REF
|
|
1360
|
+
: BindingTypes.SETUP_LET
|
|
1361
|
+
registerBinding(bindings, p.key, type)
|
|
1362
|
+
} else {
|
|
1363
|
+
walkPattern(p.value, bindings, isConst, isDefineCall)
|
|
1364
|
+
}
|
|
1365
|
+
} else {
|
|
1366
|
+
// ...rest
|
|
1367
|
+
// argument can only be identifier when destructuring
|
|
1368
|
+
const type = isConst ? BindingTypes.SETUP_CONST : BindingTypes.SETUP_LET
|
|
1369
|
+
registerBinding(bindings, p.argument as Identifier, type)
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
function walkArrayPattern(
|
|
1375
|
+
node: ArrayPattern,
|
|
1376
|
+
bindings: Record<string, BindingTypes>,
|
|
1377
|
+
isConst: boolean,
|
|
1378
|
+
isDefineCall = false
|
|
1379
|
+
) {
|
|
1380
|
+
for (const e of node.elements) {
|
|
1381
|
+
e && walkPattern(e, bindings, isConst, isDefineCall)
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
function walkPattern(
|
|
1386
|
+
node: Node,
|
|
1387
|
+
bindings: Record<string, BindingTypes>,
|
|
1388
|
+
isConst: boolean,
|
|
1389
|
+
isDefineCall = false
|
|
1390
|
+
) {
|
|
1391
|
+
if (node.type === 'Identifier') {
|
|
1392
|
+
const type = isDefineCall
|
|
1393
|
+
? BindingTypes.SETUP_CONST
|
|
1394
|
+
: isConst
|
|
1395
|
+
? BindingTypes.SETUP_MAYBE_REF
|
|
1396
|
+
: BindingTypes.SETUP_LET
|
|
1397
|
+
registerBinding(bindings, node, type)
|
|
1398
|
+
} else if (node.type === 'RestElement') {
|
|
1399
|
+
// argument can only be identifier when destructuring
|
|
1400
|
+
const type = isConst ? BindingTypes.SETUP_CONST : BindingTypes.SETUP_LET
|
|
1401
|
+
registerBinding(bindings, node.argument as Identifier, type)
|
|
1402
|
+
} else if (node.type === 'ObjectPattern') {
|
|
1403
|
+
walkObjectPattern(node, bindings, isConst)
|
|
1404
|
+
} else if (node.type === 'ArrayPattern') {
|
|
1405
|
+
walkArrayPattern(node, bindings, isConst)
|
|
1406
|
+
} else if (node.type === 'AssignmentPattern') {
|
|
1407
|
+
if (node.left.type === 'Identifier') {
|
|
1408
|
+
const type = isDefineCall
|
|
1409
|
+
? BindingTypes.SETUP_CONST
|
|
1410
|
+
: isConst
|
|
1411
|
+
? BindingTypes.SETUP_MAYBE_REF
|
|
1412
|
+
: BindingTypes.SETUP_LET
|
|
1413
|
+
registerBinding(bindings, node.left, type)
|
|
1414
|
+
} else {
|
|
1415
|
+
walkPattern(node.left, bindings, isConst)
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
interface PropTypeData {
|
|
1421
|
+
key: string
|
|
1422
|
+
type: string[]
|
|
1423
|
+
required: boolean
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
function recordType(node: Node, declaredTypes: Record<string, string[]>) {
|
|
1427
|
+
if (node.type === 'TSInterfaceDeclaration') {
|
|
1428
|
+
declaredTypes[node.id.name] = [`Object`]
|
|
1429
|
+
} else if (node.type === 'TSTypeAliasDeclaration') {
|
|
1430
|
+
declaredTypes[node.id.name] = inferRuntimeType(
|
|
1431
|
+
node.typeAnnotation,
|
|
1432
|
+
declaredTypes
|
|
1433
|
+
)
|
|
1434
|
+
} else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
|
|
1435
|
+
recordType(node.declaration, declaredTypes)
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
function extractRuntimeProps(
|
|
1440
|
+
node: TSTypeLiteral | TSInterfaceBody,
|
|
1441
|
+
props: Record<string, PropTypeData>,
|
|
1442
|
+
declaredTypes: Record<string, string[]>,
|
|
1443
|
+
isProd: boolean
|
|
1444
|
+
) {
|
|
1445
|
+
const members = node.type === 'TSTypeLiteral' ? node.members : node.body
|
|
1446
|
+
for (const m of members) {
|
|
1447
|
+
if (
|
|
1448
|
+
(m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
|
|
1449
|
+
m.key.type === 'Identifier'
|
|
1450
|
+
) {
|
|
1451
|
+
let type
|
|
1452
|
+
if (m.type === 'TSMethodSignature') {
|
|
1453
|
+
type = ['Function']
|
|
1454
|
+
} else if (m.typeAnnotation) {
|
|
1455
|
+
type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes)
|
|
1456
|
+
}
|
|
1457
|
+
props[m.key.name] = {
|
|
1458
|
+
key: m.key.name,
|
|
1459
|
+
required: !m.optional,
|
|
1460
|
+
type: type || [`null`]
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
function inferRuntimeType(
|
|
1467
|
+
node: TSType,
|
|
1468
|
+
declaredTypes: Record<string, string[]>
|
|
1469
|
+
): string[] {
|
|
1470
|
+
switch (node.type) {
|
|
1471
|
+
case 'TSStringKeyword':
|
|
1472
|
+
return ['String']
|
|
1473
|
+
case 'TSNumberKeyword':
|
|
1474
|
+
return ['Number']
|
|
1475
|
+
case 'TSBooleanKeyword':
|
|
1476
|
+
return ['Boolean']
|
|
1477
|
+
case 'TSObjectKeyword':
|
|
1478
|
+
return ['Object']
|
|
1479
|
+
case 'TSTypeLiteral':
|
|
1480
|
+
// TODO (nice to have) generate runtime property validation
|
|
1481
|
+
return ['Object']
|
|
1482
|
+
case 'TSFunctionType':
|
|
1483
|
+
return ['Function']
|
|
1484
|
+
case 'TSArrayType':
|
|
1485
|
+
case 'TSTupleType':
|
|
1486
|
+
// TODO (nice to have) generate runtime element type/length checks
|
|
1487
|
+
return ['Array']
|
|
1488
|
+
|
|
1489
|
+
case 'TSLiteralType':
|
|
1490
|
+
switch (node.literal.type) {
|
|
1491
|
+
case 'StringLiteral':
|
|
1492
|
+
return ['String']
|
|
1493
|
+
case 'BooleanLiteral':
|
|
1494
|
+
return ['Boolean']
|
|
1495
|
+
case 'NumericLiteral':
|
|
1496
|
+
case 'BigIntLiteral':
|
|
1497
|
+
return ['Number']
|
|
1498
|
+
default:
|
|
1499
|
+
return [`null`]
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
case 'TSTypeReference':
|
|
1503
|
+
if (node.typeName.type === 'Identifier') {
|
|
1504
|
+
if (declaredTypes[node.typeName.name]) {
|
|
1505
|
+
return declaredTypes[node.typeName.name]
|
|
1506
|
+
}
|
|
1507
|
+
switch (node.typeName.name) {
|
|
1508
|
+
case 'Array':
|
|
1509
|
+
case 'Function':
|
|
1510
|
+
case 'Object':
|
|
1511
|
+
case 'Set':
|
|
1512
|
+
case 'Map':
|
|
1513
|
+
case 'WeakSet':
|
|
1514
|
+
case 'WeakMap':
|
|
1515
|
+
case 'Date':
|
|
1516
|
+
case 'Promise':
|
|
1517
|
+
return [node.typeName.name]
|
|
1518
|
+
case 'Record':
|
|
1519
|
+
case 'Partial':
|
|
1520
|
+
case 'Readonly':
|
|
1521
|
+
case 'Pick':
|
|
1522
|
+
case 'Omit':
|
|
1523
|
+
case 'Exclude':
|
|
1524
|
+
case 'Extract':
|
|
1525
|
+
case 'Required':
|
|
1526
|
+
case 'InstanceType':
|
|
1527
|
+
return ['Object']
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
return [`null`]
|
|
1531
|
+
|
|
1532
|
+
case 'TSParenthesizedType':
|
|
1533
|
+
return inferRuntimeType(node.typeAnnotation, declaredTypes)
|
|
1534
|
+
case 'TSUnionType':
|
|
1535
|
+
return [
|
|
1536
|
+
...new Set(
|
|
1537
|
+
[].concat(
|
|
1538
|
+
...(node.types.map(t => inferRuntimeType(t, declaredTypes)) as any)
|
|
1539
|
+
)
|
|
1540
|
+
)
|
|
1541
|
+
]
|
|
1542
|
+
case 'TSIntersectionType':
|
|
1543
|
+
return ['Object']
|
|
1544
|
+
|
|
1545
|
+
case 'TSSymbolKeyword':
|
|
1546
|
+
return ['Symbol']
|
|
1547
|
+
|
|
1548
|
+
default:
|
|
1549
|
+
return [`null`] // no runtime check
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
function toRuntimeTypeString(types: string[]) {
|
|
1554
|
+
return types.length > 1 ? `[${types.join(', ')}]` : types[0]
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
function extractRuntimeEmits(
|
|
1558
|
+
node: TSFunctionType | TSTypeLiteral | TSInterfaceBody,
|
|
1559
|
+
emits: Set<string>
|
|
1560
|
+
) {
|
|
1561
|
+
if (node.type === 'TSTypeLiteral' || node.type === 'TSInterfaceBody') {
|
|
1562
|
+
const members = node.type === 'TSTypeLiteral' ? node.members : node.body
|
|
1563
|
+
for (let t of members) {
|
|
1564
|
+
if (t.type === 'TSCallSignatureDeclaration') {
|
|
1565
|
+
extractEventNames(t.parameters[0], emits)
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
return
|
|
1569
|
+
} else {
|
|
1570
|
+
extractEventNames(node.parameters[0], emits)
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
function extractEventNames(
|
|
1575
|
+
eventName: Identifier | RestElement,
|
|
1576
|
+
emits: Set<string>
|
|
1577
|
+
) {
|
|
1578
|
+
if (
|
|
1579
|
+
eventName.type === 'Identifier' &&
|
|
1580
|
+
eventName.typeAnnotation &&
|
|
1581
|
+
eventName.typeAnnotation.type === 'TSTypeAnnotation'
|
|
1582
|
+
) {
|
|
1583
|
+
const typeNode = eventName.typeAnnotation.typeAnnotation
|
|
1584
|
+
if (typeNode.type === 'TSLiteralType') {
|
|
1585
|
+
if (
|
|
1586
|
+
typeNode.literal.type !== 'UnaryExpression' &&
|
|
1587
|
+
typeNode.literal.type !== 'TemplateLiteral'
|
|
1588
|
+
) {
|
|
1589
|
+
emits.add(String(typeNode.literal.value))
|
|
1590
|
+
}
|
|
1591
|
+
} else if (typeNode.type === 'TSUnionType') {
|
|
1592
|
+
for (const t of typeNode.types) {
|
|
1593
|
+
if (
|
|
1594
|
+
t.type === 'TSLiteralType' &&
|
|
1595
|
+
t.literal.type !== 'UnaryExpression' &&
|
|
1596
|
+
t.literal.type !== 'TemplateLiteral'
|
|
1597
|
+
) {
|
|
1598
|
+
emits.add(String(t.literal.value))
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
function genRuntimeEmits(emits: Set<string>) {
|
|
1606
|
+
return emits.size
|
|
1607
|
+
? `\n emits: [${Array.from(emits)
|
|
1608
|
+
.map(p => JSON.stringify(p))
|
|
1609
|
+
.join(', ')}],`
|
|
1610
|
+
: ``
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
function isCallOf(
|
|
1614
|
+
node: Node | null | undefined,
|
|
1615
|
+
test: string | ((id: string) => boolean)
|
|
1616
|
+
): node is CallExpression {
|
|
1617
|
+
return !!(
|
|
1618
|
+
node &&
|
|
1619
|
+
node.type === 'CallExpression' &&
|
|
1620
|
+
node.callee.type === 'Identifier' &&
|
|
1621
|
+
(typeof test === 'string'
|
|
1622
|
+
? node.callee.name === test
|
|
1623
|
+
: test(node.callee.name))
|
|
1624
|
+
)
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
function canNeverBeRef(node: Node, userReactiveImport: string): boolean {
|
|
1628
|
+
if (isCallOf(node, userReactiveImport)) {
|
|
1629
|
+
return true
|
|
1630
|
+
}
|
|
1631
|
+
switch (node.type) {
|
|
1632
|
+
case 'UnaryExpression':
|
|
1633
|
+
case 'BinaryExpression':
|
|
1634
|
+
case 'ArrayExpression':
|
|
1635
|
+
case 'ObjectExpression':
|
|
1636
|
+
case 'FunctionExpression':
|
|
1637
|
+
case 'ArrowFunctionExpression':
|
|
1638
|
+
case 'UpdateExpression':
|
|
1639
|
+
case 'ClassExpression':
|
|
1640
|
+
case 'TaggedTemplateExpression':
|
|
1641
|
+
return true
|
|
1642
|
+
case 'SequenceExpression':
|
|
1643
|
+
return canNeverBeRef(
|
|
1644
|
+
node.expressions[node.expressions.length - 1],
|
|
1645
|
+
userReactiveImport
|
|
1646
|
+
)
|
|
1647
|
+
default:
|
|
1648
|
+
if (node.type.endsWith('Literal')) {
|
|
1649
|
+
return true
|
|
1650
|
+
}
|
|
1651
|
+
return false
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* Analyze bindings in normal `<script>`
|
|
1657
|
+
* Note that `compileScriptSetup` already analyzes bindings as part of its
|
|
1658
|
+
* compilation process so this should only be used on single `<script>` SFCs.
|
|
1659
|
+
*/
|
|
1660
|
+
function analyzeScriptBindings(ast: Statement[]): BindingMetadata {
|
|
1661
|
+
for (const node of ast) {
|
|
1662
|
+
if (
|
|
1663
|
+
node.type === 'ExportDefaultDeclaration' &&
|
|
1664
|
+
node.declaration.type === 'ObjectExpression'
|
|
1665
|
+
) {
|
|
1666
|
+
return analyzeBindingsFromOptions(node.declaration)
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return {}
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
function analyzeBindingsFromOptions(node: ObjectExpression): BindingMetadata {
|
|
1673
|
+
const bindings: BindingMetadata = {}
|
|
1674
|
+
// #3270, #3275
|
|
1675
|
+
// mark non-script-setup so we don't resolve components/directives from these
|
|
1676
|
+
Object.defineProperty(bindings, '__isScriptSetup', {
|
|
1677
|
+
enumerable: false,
|
|
1678
|
+
value: false
|
|
1679
|
+
})
|
|
1680
|
+
for (const property of node.properties) {
|
|
1681
|
+
if (
|
|
1682
|
+
property.type === 'ObjectProperty' &&
|
|
1683
|
+
!property.computed &&
|
|
1684
|
+
property.key.type === 'Identifier'
|
|
1685
|
+
) {
|
|
1686
|
+
// props
|
|
1687
|
+
if (property.key.name === 'props') {
|
|
1688
|
+
// props: ['foo']
|
|
1689
|
+
// props: { foo: ... }
|
|
1690
|
+
for (const key of getObjectOrArrayExpressionKeys(property.value)) {
|
|
1691
|
+
bindings[key] = BindingTypes.PROPS
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
// inject
|
|
1696
|
+
else if (property.key.name === 'inject') {
|
|
1697
|
+
// inject: ['foo']
|
|
1698
|
+
// inject: { foo: {} }
|
|
1699
|
+
for (const key of getObjectOrArrayExpressionKeys(property.value)) {
|
|
1700
|
+
bindings[key] = BindingTypes.OPTIONS
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// computed & methods
|
|
1705
|
+
else if (
|
|
1706
|
+
property.value.type === 'ObjectExpression' &&
|
|
1707
|
+
(property.key.name === 'computed' || property.key.name === 'methods')
|
|
1708
|
+
) {
|
|
1709
|
+
// methods: { foo() {} }
|
|
1710
|
+
// computed: { foo() {} }
|
|
1711
|
+
for (const key of getObjectExpressionKeys(property.value)) {
|
|
1712
|
+
bindings[key] = BindingTypes.OPTIONS
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// setup & data
|
|
1718
|
+
else if (
|
|
1719
|
+
property.type === 'ObjectMethod' &&
|
|
1720
|
+
property.key.type === 'Identifier' &&
|
|
1721
|
+
(property.key.name === 'setup' || property.key.name === 'data')
|
|
1722
|
+
) {
|
|
1723
|
+
for (const bodyItem of property.body.body) {
|
|
1724
|
+
// setup() {
|
|
1725
|
+
// return {
|
|
1726
|
+
// foo: null
|
|
1727
|
+
// }
|
|
1728
|
+
// }
|
|
1729
|
+
if (
|
|
1730
|
+
bodyItem.type === 'ReturnStatement' &&
|
|
1731
|
+
bodyItem.argument &&
|
|
1732
|
+
bodyItem.argument.type === 'ObjectExpression'
|
|
1733
|
+
) {
|
|
1734
|
+
for (const key of getObjectExpressionKeys(bodyItem.argument)) {
|
|
1735
|
+
bindings[key] =
|
|
1736
|
+
property.key.name === 'setup'
|
|
1737
|
+
? BindingTypes.SETUP_MAYBE_REF
|
|
1738
|
+
: BindingTypes.DATA
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
return bindings
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
function getObjectExpressionKeys(node: ObjectExpression): string[] {
|
|
1749
|
+
const keys: string[] = []
|
|
1750
|
+
for (const prop of node.properties) {
|
|
1751
|
+
if (
|
|
1752
|
+
(prop.type === 'ObjectProperty' || prop.type === 'ObjectMethod') &&
|
|
1753
|
+
!prop.computed
|
|
1754
|
+
) {
|
|
1755
|
+
if (prop.key.type === 'Identifier') {
|
|
1756
|
+
keys.push(prop.key.name)
|
|
1757
|
+
} else if (prop.key.type === 'StringLiteral') {
|
|
1758
|
+
keys.push(prop.key.value)
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
return keys
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
function getArrayExpressionKeys(node: ArrayExpression): string[] {
|
|
1766
|
+
const keys: string[] = []
|
|
1767
|
+
for (const element of node.elements) {
|
|
1768
|
+
if (element && element.type === 'StringLiteral') {
|
|
1769
|
+
keys.push(element.value)
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
return keys
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
function getObjectOrArrayExpressionKeys(value: Node): string[] {
|
|
1776
|
+
if (value.type === 'ArrayExpression') {
|
|
1777
|
+
return getArrayExpressionKeys(value)
|
|
1778
|
+
}
|
|
1779
|
+
if (value.type === 'ObjectExpression') {
|
|
1780
|
+
return getObjectExpressionKeys(value)
|
|
1781
|
+
}
|
|
1782
|
+
return []
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
const templateUsageCheckCache = new LRU<string, string>(512)
|
|
1786
|
+
|
|
1787
|
+
function resolveTemplateUsageCheckString(sfc: SFCDescriptor, isTS: boolean) {
|
|
1788
|
+
const { content } = sfc.template!
|
|
1789
|
+
const cached = templateUsageCheckCache.get(content)
|
|
1790
|
+
if (cached) {
|
|
1791
|
+
return cached
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
let code = ''
|
|
1795
|
+
|
|
1796
|
+
parseHTML(content, {
|
|
1797
|
+
...webCompilerOptions,
|
|
1798
|
+
start(tag, attrs) {
|
|
1799
|
+
if (!isBuiltInTag(tag) && !isReservedTag(tag)) {
|
|
1800
|
+
code += `,${camelize(tag)},${capitalize(camelize(tag))}`
|
|
1801
|
+
}
|
|
1802
|
+
for (let i = 0; i < attrs.length; i++) {
|
|
1803
|
+
const { name, value } = attrs[i]
|
|
1804
|
+
if (dirRE.test(name)) {
|
|
1805
|
+
const baseName = onRE.test(name)
|
|
1806
|
+
? 'on'
|
|
1807
|
+
: slotRE.test(name)
|
|
1808
|
+
? 'slot'
|
|
1809
|
+
: bindRE.test(name)
|
|
1810
|
+
? 'bind'
|
|
1811
|
+
: name.replace(dirRE, '')
|
|
1812
|
+
if (!isBuiltInDir(baseName)) {
|
|
1813
|
+
code += `,v${capitalize(camelize(baseName))}`
|
|
1814
|
+
}
|
|
1815
|
+
if (value) {
|
|
1816
|
+
code += `,${processExp(value, isTS, baseName)}`
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
},
|
|
1821
|
+
chars(text) {
|
|
1822
|
+
const res = parseText(text)
|
|
1823
|
+
if (res) {
|
|
1824
|
+
code += `,${processExp(res.expression, isTS)}`
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
})
|
|
1828
|
+
|
|
1829
|
+
code += ';'
|
|
1830
|
+
templateUsageCheckCache.set(content, code)
|
|
1831
|
+
return code
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/
|
|
1835
|
+
|
|
1836
|
+
function processExp(exp: string, isTS: boolean, dir?: string): string {
|
|
1837
|
+
if (isTS && / as\s+\w|<.*>|:/.test(exp)) {
|
|
1838
|
+
if (dir === 'slot') {
|
|
1839
|
+
exp = `(${exp})=>{}`
|
|
1840
|
+
} else if (dir === 'on') {
|
|
1841
|
+
exp = `()=>{${exp}}`
|
|
1842
|
+
} else if (dir === 'for') {
|
|
1843
|
+
const inMatch = exp.match(forAliasRE)
|
|
1844
|
+
if (inMatch) {
|
|
1845
|
+
const [, LHS, RHS] = inMatch
|
|
1846
|
+
return processExp(`(${LHS})=>{}`, true) + processExp(RHS, true)
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
let ret = ''
|
|
1850
|
+
// has potential type cast or generic arguments that uses types
|
|
1851
|
+
const ast = parseExpression(exp, { plugins: ['typescript'] })
|
|
1852
|
+
walkIdentifiers(ast, node => {
|
|
1853
|
+
ret += `,` + node.name
|
|
1854
|
+
})
|
|
1855
|
+
return ret
|
|
1856
|
+
}
|
|
1857
|
+
return stripStrings(exp)
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
function stripStrings(exp: string) {
|
|
1861
|
+
return exp
|
|
1862
|
+
.replace(/'[^']*'|"[^"]*"/g, '')
|
|
1863
|
+
.replace(/`[^`]+`/g, stripTemplateString)
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
function stripTemplateString(str: string): string {
|
|
1867
|
+
const interpMatch = str.match(/\${[^}]+}/g)
|
|
1868
|
+
if (interpMatch) {
|
|
1869
|
+
return interpMatch.map(m => m.slice(2, -1)).join(',')
|
|
1870
|
+
}
|
|
1871
|
+
return ''
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
function isImportUsed(
|
|
1875
|
+
local: string,
|
|
1876
|
+
sfc: SFCDescriptor,
|
|
1877
|
+
isTS: boolean
|
|
1878
|
+
): boolean {
|
|
1879
|
+
return new RegExp(
|
|
1880
|
+
// #4274 escape $ since it's a special char in regex
|
|
1881
|
+
// (and is the only regex special char that is valid in identifiers)
|
|
1882
|
+
`[^\\w$_]${local.replace(/\$/g, '\\$')}[^\\w$_]`
|
|
1883
|
+
).test(resolveTemplateUsageCheckString(sfc, isTS))
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
/**
|
|
1887
|
+
* Note: this comparison assumes the prev/next script are already identical,
|
|
1888
|
+
* and only checks the special case where <script setup> unused import
|
|
1889
|
+
* pruning result changes due to template changes.
|
|
1890
|
+
*/
|
|
1891
|
+
export function hmrShouldReload(
|
|
1892
|
+
prevImports: Record<string, ImportBinding>,
|
|
1893
|
+
next: SFCDescriptor
|
|
1894
|
+
): boolean {
|
|
1895
|
+
if (!next.scriptSetup) {
|
|
1896
|
+
return false
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
const isTS = next.scriptSetup.lang === 'ts' || next.scriptSetup.lang === 'tsx'
|
|
1900
|
+
// for each previous import, check if its used status remain the same based on
|
|
1901
|
+
// the next descriptor's template
|
|
1902
|
+
for (const key in prevImports) {
|
|
1903
|
+
// if an import was previous unused, but now is used, we need to force
|
|
1904
|
+
// reload so that the script now includes that import.
|
|
1905
|
+
if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next, isTS)) {
|
|
1906
|
+
return true
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
return false
|
|
1911
|
+
}
|