mirror of https://github.com/vuejs/core.git
feat(runtime-shared): init
This commit is contained in:
parent
1ec90db776
commit
bfb52502f8
|
|
@ -11,7 +11,7 @@
|
||||||
"size": "run-s \"size-*\" && tsx scripts/usage-size.ts",
|
"size": "run-s \"size-*\" && tsx scripts/usage-size.ts",
|
||||||
"size-global": "node scripts/build.js vue vue-vapor runtime-dom runtime-vapor compiler-dom compiler-vapor -f global -p --size",
|
"size-global": "node scripts/build.js vue vue-vapor runtime-dom runtime-vapor compiler-dom compiler-vapor -f global -p --size",
|
||||||
"size-esm-runtime": "node scripts/build.js vue vue-vapor -f esm-bundler-runtime",
|
"size-esm-runtime": "node scripts/build.js vue vue-vapor -f esm-bundler-runtime",
|
||||||
"size-esm": "node scripts/build.js runtime-dom runtime-vapor runtime-core reactivity shared -f esm-bundler",
|
"size-esm": "node scripts/build.js runtime-shared runtime-dom runtime-vapor runtime-core reactivity shared -f esm-bundler",
|
||||||
"check": "tsc --incremental --noEmit",
|
"check": "tsc --incremental --noEmit",
|
||||||
"lint": "eslint --cache .",
|
"lint": "eslint --cache .",
|
||||||
"format": "prettier --write --cache .",
|
"format": "prettier --write --cache .",
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,7 @@ export function render(_ctx) {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`compiler: element transform > component > v-on="obj" 1`] = `
|
exports[`compiler: element transform > component > v-on="obj" 1`] = `
|
||||||
"import { toHandlers as _toHandlers } from 'vue';
|
"import { resolveComponent as _resolveComponent, toHandlers as _toHandlers, createComponent as _createComponent } from 'vue/vapor';
|
||||||
import { resolveComponent as _resolveComponent, createComponent as _createComponent } from 'vue/vapor';
|
|
||||||
|
|
||||||
export function render(_ctx) {
|
export function render(_ctx) {
|
||||||
const _component_Foo = _resolveComponent("Foo")
|
const _component_Foo = _resolveComponent("Foo")
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ export function genCreateComponent(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genRawProps(props: IRProps[], context: CodegenContext) {
|
export function genRawProps(props: IRProps[], context: CodegenContext) {
|
||||||
|
const { vaporHelper } = context
|
||||||
const frag = props
|
const frag = props
|
||||||
.map(props => {
|
.map(props => {
|
||||||
if (isArray(props)) {
|
if (isArray(props)) {
|
||||||
|
|
@ -70,7 +71,7 @@ export function genRawProps(props: IRProps[], context: CodegenContext) {
|
||||||
expr = genMulti(SEGMENTS_OBJECT, genProp(props, context))
|
expr = genMulti(SEGMENTS_OBJECT, genProp(props, context))
|
||||||
else {
|
else {
|
||||||
expr = genExpression(props.value, context)
|
expr = genExpression(props.value, context)
|
||||||
if (props.handler) expr = genCall(context.helper('toHandlers'), expr)
|
if (props.handler) expr = genCall(vaporHelper('toHandlers'), expr)
|
||||||
}
|
}
|
||||||
return ['() => (', ...expr, ')']
|
return ['() => (', ...expr, ')']
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
"homepage": "https://github.com/vuejs/core-vapor/tree/main/packages/runtime-core#readme",
|
"homepage": "https://github.com/vuejs/core-vapor/tree/main/packages/runtime-core#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/shared": "workspace:*",
|
"@vue/shared": "workspace:*",
|
||||||
"@vue/reactivity": "workspace:*"
|
"@vue/reactivity": "workspace:*",
|
||||||
|
"@vue/runtime-shared": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,4 @@
|
||||||
import { isObject, toHandlerKey } from '@vue/shared'
|
import { toHandlers as _toHandlers } from '@vue/runtime-shared'
|
||||||
import { warn } from '../warning'
|
import { warn } from '../warning'
|
||||||
|
|
||||||
/**
|
export const toHandlers = _toHandlers.bind(undefined, warn)
|
||||||
* For prefixing keys in v-on="obj" with "on"
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
export function toHandlers(
|
|
||||||
obj: Record<string, any>,
|
|
||||||
preserveCaseIfNecessary?: boolean,
|
|
||||||
): Record<string, any> {
|
|
||||||
const ret: Record<string, any> = {}
|
|
||||||
if (__DEV__ && !isObject(obj)) {
|
|
||||||
warn(`v-on with no argument expects an object value.`)
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
for (const key in obj) {
|
|
||||||
ret[
|
|
||||||
preserveCaseIfNecessary && /[A-Z]/.test(key)
|
|
||||||
? `on:${key}`
|
|
||||||
: toHandlerKey(key)
|
|
||||||
] = obj[key]
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018-present, Yuxi (Evan) You
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
# @vue/runtime-shared
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports = require('./dist/runtime-shared.cjs.prod.js')
|
||||||
|
} else {
|
||||||
|
module.exports = require('./dist/runtime-shared.cjs.js')
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"name": "@vue/runtime-shared",
|
||||||
|
"version": "3.0.0-vapor",
|
||||||
|
"description": "@vue/runtime-shared",
|
||||||
|
"main": "index.js",
|
||||||
|
"module": "dist/runtime-shared.esm-bundler.js",
|
||||||
|
"types": "dist/runtime-shared.d.ts",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/runtime-shared.d.ts",
|
||||||
|
"node": {
|
||||||
|
"production": "./dist/runtime-shared.cjs.prod.js",
|
||||||
|
"development": "./dist/runtime-shared.cjs.js",
|
||||||
|
"default": "./index.js"
|
||||||
|
},
|
||||||
|
"module": "./dist/runtime-shared.esm-bundler.js",
|
||||||
|
"import": "./dist/runtime-shared.esm-bundler.js",
|
||||||
|
"require": "./index.js"
|
||||||
|
},
|
||||||
|
"./*": "./*"
|
||||||
|
},
|
||||||
|
"sideEffects": false,
|
||||||
|
"buildOptions": {
|
||||||
|
"formats": [
|
||||||
|
"esm-bundler",
|
||||||
|
"cjs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/vuejs/core-vapor.git",
|
||||||
|
"directory": "packages/runtime-shared"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"author": "Evan You",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/vuejs/core-vapor/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/vuejs/core-vapor/tree/main/packages/runtime-shared#readme"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export { toHandlers } from './toHandlers'
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { isObject, toHandlerKey } from '@vue/shared'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For prefixing keys in v-on="obj" with "on"
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export function toHandlers(
|
||||||
|
warn: (msg: string) => void,
|
||||||
|
obj: Record<string, any>,
|
||||||
|
preserveCaseIfNecessary?: boolean,
|
||||||
|
): Record<string, any> {
|
||||||
|
const ret: Record<string, any> = {}
|
||||||
|
if (__DEV__ && !isObject(obj)) {
|
||||||
|
warn(`v-on with no argument expects an object value.`)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
for (const key in obj) {
|
||||||
|
ret[
|
||||||
|
preserveCaseIfNecessary && /[A-Z]/.test(key)
|
||||||
|
? `on:${key}`
|
||||||
|
: toHandlerKey(key)
|
||||||
|
] = obj[key]
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
"homepage": "https://github.com/vuejs/core-vapor/tree/dev/packages/runtime-vapor#readme",
|
"homepage": "https://github.com/vuejs/core-vapor/tree/dev/packages/runtime-vapor#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/shared": "workspace:*",
|
"@vue/shared": "workspace:*",
|
||||||
"@vue/reactivity": "workspace:*"
|
"@vue/reactivity": "workspace:*",
|
||||||
|
"@vue/runtime-shared": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { toHandlers as _toHandlers } from '@vue/runtime-shared'
|
||||||
|
import { warn } from '../warning'
|
||||||
|
|
||||||
|
export const toHandlers = _toHandlers.bind(undefined, warn)
|
||||||
|
|
@ -127,6 +127,7 @@ export { createFor } from './apiCreateFor'
|
||||||
export { createComponent } from './apiCreateComponent'
|
export { createComponent } from './apiCreateComponent'
|
||||||
|
|
||||||
export { resolveComponent, resolveDirective } from './helpers/resolveAssets'
|
export { resolveComponent, resolveDirective } from './helpers/resolveAssets'
|
||||||
|
export { toHandlers } from './helpers/toHandlers'
|
||||||
|
|
||||||
// **Internal** DOM-only runtime directive helpers
|
// **Internal** DOM-only runtime directive helpers
|
||||||
export {
|
export {
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,9 @@ importers:
|
||||||
'@vue/reactivity':
|
'@vue/reactivity':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../reactivity
|
version: link:../reactivity
|
||||||
|
'@vue/runtime-shared':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../runtime-shared
|
||||||
'@vue/shared':
|
'@vue/shared':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../shared
|
version: link:../shared
|
||||||
|
|
@ -335,6 +338,8 @@ importers:
|
||||||
specifier: ^3.1.3
|
specifier: ^3.1.3
|
||||||
version: 3.1.3
|
version: 3.1.3
|
||||||
|
|
||||||
|
packages/runtime-shared: {}
|
||||||
|
|
||||||
packages/runtime-test:
|
packages/runtime-test:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vue/runtime-core':
|
'@vue/runtime-core':
|
||||||
|
|
@ -349,6 +354,9 @@ importers:
|
||||||
'@vue/reactivity':
|
'@vue/reactivity':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../reactivity
|
version: link:../reactivity
|
||||||
|
'@vue/runtime-shared':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../runtime-shared
|
||||||
'@vue/shared':
|
'@vue/shared':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../shared
|
version: link:../shared
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ export function fuzzyMatchTarget(partialTargets, includeAllMatching) {
|
||||||
/** @type {Array<string>} */
|
/** @type {Array<string>} */
|
||||||
const matched = []
|
const matched = []
|
||||||
partialTargets.forEach(partialTarget => {
|
partialTargets.forEach(partialTarget => {
|
||||||
|
if (!includeAllMatching && targets.includes(partialTarget)) {
|
||||||
|
matched.push(partialTarget)
|
||||||
|
return
|
||||||
|
}
|
||||||
for (const target of targets) {
|
for (const target of targets) {
|
||||||
if (target.match(partialTarget)) {
|
if (target.match(partialTarget)) {
|
||||||
matched.push(target)
|
matched.push(target)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue